Class Response<T>

java.lang.Object
de.sonallux.spotify.api.http.Response<T>

public class Response<T> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the parsed response body for successful responses.
    int
    Returns the HTTP status code
    static <T> Response<T>
    error(Error error, okhttp3.Response rawResponse)
     
    Returns an error representation for non successful responses.
    boolean
    Returns true if the code is in [200..300), which means the request was successful.
    Returns the HTTP status message
    okhttp3.Response
    raw()
    Returns the underlying OkHttp response object
    static <T> Response<T>
    success(T body, okhttp3.Response rawResponse)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Response

      public Response()
  • Method Details

    • success

      public static <T> Response<T> success(T body, okhttp3.Response rawResponse)
    • error

      public static <T> Response<T> error(Error error, okhttp3.Response rawResponse)
    • raw

      public okhttp3.Response raw()
      Returns the underlying OkHttp response object
    • code

      public int code()
      Returns the HTTP status code
    • message

      public String message()
      Returns the HTTP status message
    • isSuccessful

      public boolean isSuccessful()
      Returns true if the code is in [200..300), which means the request was successful.
    • body

      public T body()
      Returns the parsed response body for successful responses. null is returned if the response type is Void or the response has no body. For non successful response this is always null. Use {errorBody()} to get the associated error.
    • errorBody

      public Error errorBody()
      Returns an error representation for non successful responses. This is null if the response is successful.