Class 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

      Constructors 
      Constructor Description
      ApiResponse​(javax.ws.rs.core.Response response, T result)
      Creates a new API response.
    • Constructor Detail

      • ApiResponse

        public ApiResponse​(javax.ws.rs.core.Response response,
                           T result)
        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 Detail

      • 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, or 500.
        Returns:
        The status code returned by the server.
      • isSuccess

        public boolean isSuccess()
        Checks if the request was successful, i.e. whether the HTTP response had a 2xx status code.
        Returns:
        boolean true when the status code is a 2xx success code.
      • success

        public T success()
                  throws UnsuccessfulStatusCodeException
        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

        public T result()
        Gets the result of the API call. Note that this does not throw even when the API call was not successful. Use success() to do so.
        Returns:
        The result of the API call.