Class ApiClient

java.lang.Object
cloud.genesys.webmessaging.sdk.ApiClient
All Implemented Interfaces:
AutoCloseable

public class ApiClient extends Object implements AutoCloseable
  • Constructor Details

    • ApiClient

      public ApiClient()
  • Method Details

    • close

      public void close() throws Exception
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • buildObjectMapper

      public static com.fasterxml.jackson.databind.ObjectMapper buildObjectMapper(DateFormat dateFormat)
    • getShouldThrowErrors

      public boolean getShouldThrowErrors()
    • getBasePath

      public String getBasePath()
    • getObjectMapper

      public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • setAccessToken

      public void setAccessToken(String accessToken)
      Helper method to set access token for the first OAuth2 authentication.
    • getConnectTimeout

      public int getConnectTimeout()
      Connect timeout (in milliseconds).
    • parseDate

      public Date parseDate(String str)
      Parse the given string into Date object.
    • formatDate

      public String formatDate(Date date)
      Format the given Date object into string.
    • parameterToString

      public String parameterToString(Object param)
      Format the given parameter object into string.
    • parameterToPairs

      public List<Pair> parameterToPairs(String collectionFormat, String name, Object value)
    • isJsonMime

      public boolean isJsonMime(String mime)
      Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON
    • selectHeaderAccept

      public String selectHeaderAccept(String[] accepts)
      Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string)
      Parameters:
      accepts - The accepts array to select from
      Returns:
      The Accept header to use. If the given array is empty, null will be returned (not to set the Accept header explicitly).
    • selectHeaderContentType

      public String selectHeaderContentType(String[] contentTypes)
      Select the Content-Type header's value from the given array: if JSON exists in the given array, use it; otherwise use the first one of the array.
      Parameters:
      contentTypes - The Content-Type array to select from
      Returns:
      The Content-Type header to use. If the given array is empty, JSON will be used.
    • escapeString

      public String escapeString(String str)
      Escape the given string to be used as URL query value.
    • serialize

      public String serialize(Object obj) throws IOException
      Serialize the given Java object into string according the given Content-Type (only JSON is supported for now).
      Throws:
      IOException
    • deserialize

      public <T> T deserialize(String obj, Class<T> type) throws IOException
      Deserialize the string into the provided type
      Parameters:
      obj - the string to deserialize
      type - the target type for deserialization
      Throws:
      IOException
    • invoke

      public <T> ApiResponse<T> invoke(ApiRequest<?> request, com.fasterxml.jackson.core.type.TypeReference<T> returnType) throws WebMessagingException, IOException
      Throws:
      WebMessagingException
      IOException