Class EasyPostClient

java.lang.Object
com.easypost.service.EasyPostClient

public class EasyPostClient extends Object
  • Field Details

  • Constructor Details

    • EasyPostClient

      public EasyPostClient(String apiKey) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      Throws:
      MissingParameterError - When the request fails.
    • EasyPostClient

      public EasyPostClient(String apiKey, String apiBase) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      apiBase - API base for API calls.
      Throws:
      MissingParameterError - When the request fails.
    • EasyPostClient

      public EasyPostClient(String apiKey, int connectTimeoutMilliseconds) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      connectTimeoutMilliseconds - Timeout for connection.
      Throws:
      MissingParameterError - When the request fails.
    • EasyPostClient

      public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, String apiBase) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      connectTimeoutMilliseconds - Timeout for connection.
      apiBase - API base for API calls.
      Throws:
      MissingParameterError - When the request fails.
    • EasyPostClient

      public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTimeoutMilliseconds) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      connectTimeoutMilliseconds - Timeout for connection.
      readTimeoutMilliseconds - Timeout for read.
      Throws:
      MissingParameterError - When the request fails.
    • EasyPostClient

      public EasyPostClient(String apiKey, int connectTimeoutMilliseconds, int readTimeoutMilliseconds, String apiBase) throws MissingParameterError
      EasyPostClient constructor.
      Parameters:
      apiKey - API key for API calls.
      connectTimeoutMilliseconds - Timeout for connection.
      readTimeoutMilliseconds - Timeout for read.
      apiBase - API base for API calls.
      Throws:
      MissingParameterError - When the request fails.
  • Method Details

    • subscribeToRequestHook

      public void subscribeToRequestHook(Function<RequestHookResponses, Object> function)
      Subscribes to a request hook from the given function.
      Parameters:
      function - The function to be subscribed to the request hook
    • unsubscribeFromRequestHook

      public void unsubscribeFromRequestHook(Function<RequestHookResponses, Object> function)
      Unsubscribes to a request hook from the given function.
      Parameters:
      function - The function to be unsubscribed from the request hook
    • subscribeToResponseHook

      public void subscribeToResponseHook(Function<ResponseHookResponses, Object> function)
      Subscribes to a response hook from the given function.
      Parameters:
      function - The function to be subscribed to the response hook
    • unsubscribeFromResponseHook

      public void unsubscribeFromResponseHook(Function<ResponseHookResponses, Object> function)
      Unubscribes to a response hook from the given function.
      Parameters:
      function - The function to be unsubscribed from the response hook
    • getConnectionTimeoutMilliseconds

      public int getConnectionTimeoutMilliseconds()
      Get connection timeout milliseconds for this EasyPostClient object.
      Returns:
      the connection timeout for this EasyPostClient object
    • getReadTimeoutMilliseconds

      public int getReadTimeoutMilliseconds()
      Get read timeout milliseconds for this EasyPostClient object.
      Returns:
      the read timeout for this EasyPostClient object
    • getApiKey

      public String getApiKey()
      Get API key for this EasyPostClient object.
      Returns:
      the API key for this EasyPostClient object
    • getApiVersion

      public String getApiVersion()
      Get API version for this EasyPostClient object.
      Returns:
      the API version for this EasyPostClient object.
    • getApiBase

      public String getApiBase()
      Get API base for this EasyPostClient object.
      Returns:
      the API base for this EasyPostClient object.
    • makeApiCall

      public Map<String,Object> makeApiCall(Requestor.RequestMethod method, String endpoint, Map<String,Object> params) throws EasyPostException
      Make an API call to the EasyPost API. This public, generic interface is useful for making arbitrary API calls to the EasyPost API that are not yet supported by the client library's services. When possible, the service for your use case should be used instead as it provides a more convenient and higher-level interface depending on the endpoint.
      Parameters:
      method - The HTTP method to use for the request.
      endpoint - The endpoint to call (e.g., "/addresses").
      params - The parameters to send with the request.
      Returns:
      A Map containing the API response.
      Throws:
      EasyPostException - when the request fails.