Class ApiResponse<T>
java.lang.Object
de.xima.fc.api.rest.pub.client.security.ApiResponse<T>
- Type Parameters:
T- Type of the deserialized response data.
@Generated("de.xima.openapi.codegen.java_jaxrs.XimaJavaJaxrsGenerator")
public final class ApiResponse<T>
extends Object
Represents the result of a REST API call. Includes the raw HTTP response data as well as
the deserialized data.
-
Constructor Summary
ConstructorsConstructorDescriptionApiResponse(javax.ws.rs.core.Response response, T result) Creates a new API response. -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks if the request was successful, i.e. whether the HTTP response had a 2xx status code.booleanChecks if the request was successful, i.e. whether the HTTP response had a 2xx status code.javax.ws.rs.core.Responseresponse()The raw response returned by the server, without any deserialized objects.result()Gets the result of the API call.intReturns the status code returned by the server, e.g.success()Returns the success response, defined as an HTTP response with a 2xx status code.
-
Constructor Details
-
ApiResponse
Creates a new API response. An instance of this class is usually created by the API client.- Parameters:
response- The raw HTTP response data as returned by the server.result- The transformed or deserialized data.
-
-
Method Details
-
response
public javax.ws.rs.core.Response response()The raw response returned by the server, without any deserialized objects.- Returns:
- The raw HTTP resonse data.
-
statusCode
public int statusCode()Returns the status code returned by the server, e.g.200,404, or500.- Returns:
- The status code returned by the server.
-
assertSuccess
Checks if the request was successful, i.e. whether the HTTP response had a 2xx status code.- Throws:
UnsuccessfulStatusCodeException- When the status code is not a 2xx success code.
-
isSuccess
public boolean isSuccess()Checks if the request was successful, i.e. whether the HTTP response had a 2xx status code.- Returns:
- boolean
truewhen the status code is a 2xx success code.
-
success
Returns the success response, defined as an HTTP response with a 2xx status code. Otherwise, this method throws a check exception if the API call was not successful.- Returns:
- The result, if this API call was successful (status code 2xx).
- Throws:
UnsuccessfulStatusCodeException- When the status code is not a 2xx success code.
-
result
-