Package com.mypurecloud.sdk.v2
Class ApiClient
java.lang.Object
com.mypurecloud.sdk.v2.ApiClient
- All Implemented Interfaces:
AutoCloseable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionauthorizeClientCredentials(String clientId, String clientSecret) Authorizes the SDK by completing a client credentials OAuth grantauthorizeCodeAuthorization(String clientId, String clientSecret, String authCode, String redirectUri) authorizePKCE(String clientId, String codeVerifier, String authCode, String redirectUri) authorizeSaml2Bearer(String clientId, String clientSecret, String orgName, String assertion) static com.fasterxml.jackson.databind.ObjectMapperbuildObjectMapper(DateFormat dateFormat) voidclose()Compute Base64Url PKCE Code Challenge from Code Verifier<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.generatePKCECodeVerifier(int len) Generate a random string used as PKCE Code VerifierbooleanintConnect timeout (in milliseconds).com.mypurecloud.sdk.v2.Loggercom.fasterxml.jackson.databind.ObjectMapperintbooleanboolean<T> ApiResponse<T>invoke(ApiRequest<?> request, com.fasterxml.jackson.core.type.TypeReference<T> returnType) <T> Future<ApiResponse<T>>invokeAsync(ApiRequest<?> request, com.fasterxml.jackson.core.type.TypeReference<T> returnType, AsyncApiCallback<ApiResponse<T>> callback) 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.refreshCodeAuthorization(String clientId, String clientSecret, String refreshToken) 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.voidsetAutoReloadConfig(boolean autoReloadConfig) voidsetBasePath(String basePath) voidsetRefreshTokenWaitTime(int refreshTokenWaitTime) voidsetRetryConfiguration(ApiClient.RetryConfiguration retryConfig) voidsetShouldRefreshAccessToken(boolean shouldRefreshAccessToken)
-
Constructor Details
-
ApiClient
public ApiClient()
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
buildObjectMapper
-
getShouldThrowErrors
public boolean getShouldThrowErrors() -
getRefreshTokenWaitTime
public int getRefreshTokenWaitTime() -
setRefreshTokenWaitTime
public void setRefreshTokenWaitTime(int refreshTokenWaitTime) -
getShouldRefreshAccessToken
public boolean getShouldRefreshAccessToken() -
setShouldRefreshAccessToken
public void setShouldRefreshAccessToken(boolean shouldRefreshAccessToken) -
getBasePath
-
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getConfigFilePath
-
getLoggingConfiguration
-
getLogger
public com.mypurecloud.sdk.v2.Logger getLogger() -
getAutoReloadConfig
public boolean getAutoReloadConfig() -
setAutoReloadConfig
public void setAutoReloadConfig(boolean autoReloadConfig) -
getRetryConfiguration
-
setRetryConfiguration
-
setAccessToken
Helper method to set access token for the first OAuth2 authentication. -
setBasePath
-
authorizeClientCredentials
public ApiResponse<AuthResponse> authorizeClientCredentials(String clientId, String clientSecret) throws IOException, ApiException Authorizes the SDK by completing a client credentials OAuth grant- Parameters:
clientId- The OAuth client's Client IDclientSecret- The OAuth client's Client Secret- Throws:
IOExceptionApiException
-
authorizeSaml2Bearer
public ApiResponse<AuthResponse> authorizeSaml2Bearer(String clientId, String clientSecret, String orgName, String assertion) throws IOException, ApiException - Throws:
IOExceptionApiException
-
authorizeCodeAuthorization
public ApiResponse<AuthResponse> authorizeCodeAuthorization(String clientId, String clientSecret, String authCode, String redirectUri) throws IOException, ApiException - Throws:
IOExceptionApiException
-
refreshCodeAuthorization
public ApiResponse<AuthResponse> refreshCodeAuthorization(String clientId, String clientSecret, String refreshToken) throws IOException, ApiException - Throws:
IOExceptionApiException
-
generatePKCECodeVerifier
Generate a random string used as PKCE Code Verifier -
computePKCECodeChallenge
Compute Base64Url PKCE Code Challenge from Code Verifier -
authorizePKCE
public ApiResponse<AuthResponse> authorizePKCE(String clientId, String codeVerifier, String authCode, String redirectUri) throws IOException, ApiException - Throws:
IOExceptionApiException
-
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 ApiException, IOException - Throws:
ApiExceptionIOException
-
invokeAsync
public <T> Future<ApiResponse<T>> invokeAsync(ApiRequest<?> request, com.fasterxml.jackson.core.type.TypeReference<T> returnType, AsyncApiCallback<ApiResponse<T>> callback)
-