Class Requestor
java.lang.Object
com.easypost.http.Requestor
-
Nested Class Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static void
handleAPIError
(String rBody, int rCode) Handles API error based on the error status code.static <T> T
request
(Requestor.RequestMethod method, String endpoint, Map<String, Object> params, Class<T> clazz, EasyPostClient client) Send an HTTP request to EasyPost.static <T> T
request
(Requestor.RequestMethod method, String endpoint, Map<String, Object> params, Class<T> clazz, EasyPostClient client, String apiVersion) Send an HTTP request to EasyPost.
-
Constructor Details
-
Requestor
public Requestor()
-
-
Method Details
-
request
public static <T> T request(Requestor.RequestMethod method, String endpoint, Map<String, Object> params, Class<T> clazz, EasyPostClient client) throws GatewayTimeoutError, RateLimitError, BadRequestError, InvalidRequestError, NotFoundError, TimeoutError, EncodingError, UnauthorizedError, MethodNotAllowedError, InternalServerError, UnknownApiError, ServiceUnavailableError, ForbiddenError, JsonError, HttpError, RedirectError, PaymentError, MissingParameterErrorSend an HTTP request to EasyPost.- Type Parameters:
T
- Any class.- Parameters:
method
- The method of the API request.endpoint
- The endpoint of the API request.params
- The params of the API request.clazz
- The class of the object for deserializationclient
- The EasyPostClient object.- Returns:
- A clazz-type object.
- Throws:
HttpError
- when the HTTP connection cannot be made.EncodingError
- when the request query cannot be encoded.JsonError
- when the request body cannot be encoded.RedirectError
- when the request is redirected.UnauthorizedError
- when the request is unauthorized.ForbiddenError
- when the request is forbidden.PaymentError
- when the request requires payment.NotFoundError
- when the request endpoint is not found.MethodNotAllowedError
- when the request method is not allowed.MissingParameterError
- when the request client doesn't have API key.TimeoutError
- when the request times out.BadRequestError
- when the request is bad.InvalidRequestError
- when the request is invalid.RateLimitError
- when the request exceeds the rate limit.InternalServerError
- when the request fails due to an internal server error.ServiceUnavailableError
- when the request fails due to a service unavailability.GatewayTimeoutError
- when the request fails due to a gateway timeout.UnknownApiError
- when the request fails due to an unknown API error.
-
request
public static <T> T request(Requestor.RequestMethod method, String endpoint, Map<String, Object> params, Class<T> clazz, EasyPostClient client, String apiVersion) throws EncodingError, JsonError, RedirectError, UnauthorizedError, ForbiddenError, PaymentError, NotFoundError, MethodNotAllowedError, TimeoutError, BadRequestError, InvalidRequestError, RateLimitError, InternalServerError, ServiceUnavailableError, GatewayTimeoutError, UnknownApiError, HttpError, MissingParameterErrorSend an HTTP request to EasyPost.- Type Parameters:
T
- Any class.- Parameters:
method
- The method of the API request.endpoint
- The endpoint of the API request.params
- The params of the API request.clazz
- The class of the object for deserializationclient
- The EasyPostClient object.apiVersion
- The API version to use for this request.- Returns:
- A clazz-type object.
- Throws:
HttpError
- when the HTTP connection cannot be made.EncodingError
- when the request query cannot be encoded.JsonError
- when the request body cannot be encoded.RedirectError
- when the request is redirected.UnauthorizedError
- when the request is unauthorized.ForbiddenError
- when the request is forbidden.PaymentError
- when the request requires payment.NotFoundError
- when the request endpoint is not found.MethodNotAllowedError
- when the request method is not allowed.MissingParameterError
- when the request client doesn't have API key.TimeoutError
- when the request times out.BadRequestError
- when the request is bad.InvalidRequestError
- when the request is invalid.RateLimitError
- when the request exceeds the rate limit.InternalServerError
- when the request fails due to an internal server error.ServiceUnavailableError
- when the request fails due to a service unavailability.GatewayTimeoutError
- when the request fails due to a gateway timeout.UnknownApiError
- when the request fails due to an unknown API error.
-
handleAPIError
protected static void handleAPIError(String rBody, int rCode) throws RedirectError, UnauthorizedError, ForbiddenError, PaymentError, NotFoundError, MethodNotAllowedError, TimeoutError, BadRequestError, InvalidRequestError, RateLimitError, InternalServerError, ServiceUnavailableError, GatewayTimeoutError, UnknownApiError Handles API error based on the error status code.- Parameters:
rBody
- Body of the error message.rCode
- Status code of the error message.- Throws:
RedirectError
- when the request is redirected.UnauthorizedError
- when the request is unauthorized.ForbiddenError
- when the request is forbidden.PaymentError
- when the request requires payment.NotFoundError
- when the request endpoint is not found.MethodNotAllowedError
- when the request method is not allowed.TimeoutError
- when the request times out.BadRequestError
- when the request is bad.InvalidRequestError
- when the request is invalid.RateLimitError
- when the request exceeds the rate limit.InternalServerError
- when the request fails due to an internal server error.ServiceUnavailableError
- when the request fails due to a service unavailability.GatewayTimeoutError
- when the request fails due to a gateway timeout.UnknownApiError
- when the request fails due to an unknown API error.
-