public final class Response<T> extends Object
Modifier and Type | Method and Description |
---|---|
T |
body()
The deserialized response body of a successful response.
|
int |
code()
HTTP status code.
|
static <T> Response<T> |
error(int code,
okhttp3.ResponseBody body)
Create a synthetic error response with an HTTP status code of
code and body
as the error body. |
static <T> Response<T> |
error(okhttp3.ResponseBody body,
okhttp3.Response rawResponse)
Create an error response from
rawResponse with body as the error body. |
okhttp3.ResponseBody |
errorBody()
The raw response body of an unsuccessful response.
|
okhttp3.Headers |
headers()
HTTP headers.
|
boolean |
isSuccessful()
Returns true if
code() is in the range [200..300). |
String |
message()
HTTP status message or null if unknown.
|
okhttp3.Response |
raw()
The raw response from the HTTP client.
|
static <T> Response<T> |
success(int code,
T body)
Create a synthetic successful response with an HTTP status code of
code and
body as the deserialized body. |
static <T> Response<T> |
success(T body)
Create a synthetic successful response with
body as the deserialized body. |
static <T> Response<T> |
success(T body,
okhttp3.Headers headers)
Create a synthetic successful response using
headers with body as the
deserialized body. |
static <T> Response<T> |
success(T body,
okhttp3.Response rawResponse)
Create a successful response from
rawResponse with body as the deserialized
body. |
String |
toString() |
public static <T> Response<T> success(@Nullable T body)
body
as the deserialized body.public static <T> Response<T> success(int code, @Nullable T body)
code
and
body
as the deserialized body.public static <T> Response<T> success(@Nullable T body, okhttp3.Headers headers)
headers
with body
as the
deserialized body.public static <T> Response<T> success(@Nullable T body, okhttp3.Response rawResponse)
rawResponse
with body
as the deserialized
body.public static <T> Response<T> error(int code, okhttp3.ResponseBody body)
code
and body
as the error body.public static <T> Response<T> error(okhttp3.ResponseBody body, okhttp3.Response rawResponse)
rawResponse
with body
as the error body.public okhttp3.Response raw()
public int code()
public String message()
public okhttp3.Headers headers()
public boolean isSuccessful()
code()
is in the range [200..300).@Nullable public T body()
@Nullable public okhttp3.ResponseBody errorBody()
Copyright © 2020 Square, Inc.. All rights reserved.