Package cloud.genesys.webmessaging.sdk
Class ApiClient
java.lang.Object
cloud.genesys.webmessaging.sdk.ApiClient
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.fasterxml.jackson.databind.ObjectMapperbuildObjectMapper(DateFormat dateFormat) voidclose()<T> Tdeserialize(String obj, Class<T> type) Deserialize the string into the provided typeescapeString(String str) Escape the given string to be used as URL query value.formatDate(Date date) Format the given Date object into string.intConnect timeout (in milliseconds).com.fasterxml.jackson.databind.ObjectMapperboolean<T> ApiResponse<T>invoke(ApiRequest<?> request, com.fasterxml.jackson.core.type.TypeReference<T> returnType) booleanisJsonMime(String mime) Check if the given MIME is a JSON MIME.parameterToPairs(String collectionFormat, String name, Object value) parameterToString(Object param) Format the given parameter object into string.Parse the given string into Date object.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)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.Serialize the given Java object into string according the given Content-Type (only JSON is supported for now).voidsetAccessToken(String accessToken) Helper method to set access token for the first OAuth2 authentication.
-
Constructor Details
-
ApiClient
public ApiClient()
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
buildObjectMapper
-
getShouldThrowErrors
public boolean getShouldThrowErrors() -
getBasePath
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
setAccessToken
Helper method to set access token for the first OAuth2 authentication. -
getConnectTimeout
public int getConnectTimeout()Connect timeout (in milliseconds). -
parseDate
Parse the given string into Date object. -
formatDate
Format the given Date object into string. -
parameterToString
Format the given parameter object into string. -
parameterToPairs
-
isJsonMime
Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON -
selectHeaderAccept
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
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
Escape the given string to be used as URL query value. -
serialize
Serialize the given Java object into string according the given Content-Type (only JSON is supported for now).- Throws:
IOException
-
deserialize
Deserialize the string into the provided type- Parameters:
obj- the string to deserializetype- 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:
WebMessagingExceptionIOException
-