Class ApiClient
java.lang.Object
travel.wink.sdk.booking.engine.invoker.JavaTimeFormatter
travel.wink.sdk.booking.engine.invoker.ApiClient
@Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
date="2022-06-20T22:26:28.213326+07:00[Asia/Bangkok]")
public class ApiClient
extends JavaTimeFormatter
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionApiClient(com.fasterxml.jackson.databind.ObjectMapper mapper, DateFormat format) ApiClient(org.springframework.web.reactive.function.client.WebClient webClient) ApiClient(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper mapper, DateFormat format) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCookiesToRequest(org.springframework.util.MultiValueMap<String, String> cookies, org.springframework.web.reactive.function.client.WebClient.RequestBodySpec requestBuilder) Add cookies to the request that is being builtaddDefaultCookie(String name, String value) Add a default cookie.addDefaultHeader(String name, String value) Add a default header.protected voidaddHeadersToRequest(org.springframework.http.HttpHeaders headers, org.springframework.web.reactive.function.client.WebClient.RequestBodySpec requestBuilder) Add headers to the request that is being builtstatic org.springframework.web.reactive.function.client.WebClientBuild the WebClient used to make HTTP requests.static org.springframework.web.reactive.function.client.WebClientbuildWebClient(com.fasterxml.jackson.databind.ObjectMapper mapper) Build the WebClient used to make HTTP requests.static org.springframework.web.reactive.function.client.WebClient.BuilderBuild the WebClientBuilder used to make WebClient.static org.springframework.web.reactive.function.client.WebClient.BuilderbuildWebClientBuilder(com.fasterxml.jackson.databind.ObjectMapper mapper) Build the WebClientBuilder used to make WebClient.collectionPathParameterToString(ApiClient.CollectionFormat collectionFormat, Collection<?> values) Formats the specified collection path parameter to a string value.static DateFormatstatic com.fasterxml.jackson.databind.ObjectMappercreateDefaultObjectMapper(DateFormat dateFormat) formatDate(Date date) Format the given Date object into string.getAuthentication(String authName) Get authentication for the given name.Get authentications (key: authentication name, value: authentication).Get the current base pathGet the date format used to parse/format date parameters.com.fasterxml.jackson.databind.ObjectMapperGet the ObjectMapper used to make HTTP requests.org.springframework.web.reactive.function.client.WebClientGet the WebClient used to make HTTP requests.protected voidinit()<T> org.springframework.web.reactive.function.client.WebClient.ResponseSpecinvokeAPI(String path, org.springframework.http.HttpMethod method, Map<String, Object> pathParams, org.springframework.util.MultiValueMap<String, String> queryParams, Object body, org.springframework.http.HttpHeaders headerParams, org.springframework.util.MultiValueMap<String, String> cookieParams, org.springframework.util.MultiValueMap<String, Object> formParams, List<org.springframework.http.MediaType> accept, org.springframework.http.MediaType contentType, String[] authNames, org.springframework.core.ParameterizedTypeReference<T> returnType) Invoke API by sending HTTP request with the given options.booleanisJsonMime(String mediaType) Check if the givenStringis a JSON MIME.booleanisJsonMime(org.springframework.http.MediaType mediaType) Check if the given MIME is a JSON MIME.booleanisProblemJsonMime(String mediaType) Check if the givenStringis a Problem JSON MIME (RFC-7807).parameterToMultiValueMap(ApiClient.CollectionFormat collectionFormat, String name, Object value) Converts a parameter to aMultiValueMapfor use in REST requestsparameterToString(Object param) Format the given parameter object into string.Parse the given string into Date object.protected org.springframework.web.reactive.function.BodyInserter<?,? super org.springframework.http.client.reactive.ClientHttpRequest> selectBody(Object obj, org.springframework.util.MultiValueMap<String, Object> formParams, org.springframework.http.MediaType contentType) Select the body to use for the requestList<org.springframework.http.MediaType>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)org.springframework.http.MediaTypeselectHeaderContentType(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.voidsetAccessToken(String accessToken) Helper method to set access token for the first OAuth2 authentication.voidHelper method to set API key value for the first API key authentication.voidsetApiKeyPrefix(String apiKeyPrefix) Helper method to set API key prefix for the first API key authentication.setBasePath(String basePath) Set the base path, which should include the hostvoidsetBearerToken(String bearerToken) Helper method to set access token for the first Bearer authentication.voidsetPassword(String password) Helper method to set password for the first HTTP basic authentication.setUserAgent(String userAgent) Set the User-Agent header's value (by adding to the default header map).voidsetUsername(String username) Helper method to set username for the first HTTP basic authentication.protected voidupdateParamsForAuth(String[] authNames, org.springframework.util.MultiValueMap<String, String> queryParams, org.springframework.http.HttpHeaders headerParams, org.springframework.util.MultiValueMap<String, String> cookieParams) Update query and header parameters based on authentication settings.Methods inherited from class travel.wink.sdk.booking.engine.invoker.JavaTimeFormatter
formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter
-
Constructor Details
-
ApiClient
public ApiClient() -
ApiClient
public ApiClient(org.springframework.web.reactive.function.client.WebClient webClient) -
ApiClient
-
ApiClient
public ApiClient(org.springframework.web.reactive.function.client.WebClient webClient, com.fasterxml.jackson.databind.ObjectMapper mapper, DateFormat format)
-
-
Method Details
-
createDefaultDateFormat
-
createDefaultObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper createDefaultObjectMapper(@Nullable DateFormat dateFormat) -
init
protected void init() -
buildWebClientBuilder
public static org.springframework.web.reactive.function.client.WebClient.Builder buildWebClientBuilder(com.fasterxml.jackson.databind.ObjectMapper mapper) Build the WebClientBuilder used to make WebClient.- Parameters:
mapper- ObjectMapper used for serialize/deserialize- Returns:
- WebClient
-
buildWebClientBuilder
public static org.springframework.web.reactive.function.client.WebClient.Builder buildWebClientBuilder()Build the WebClientBuilder used to make WebClient.- Returns:
- WebClient
-
buildWebClient
public static org.springframework.web.reactive.function.client.WebClient buildWebClient(com.fasterxml.jackson.databind.ObjectMapper mapper) Build the WebClient used to make HTTP requests.- Parameters:
mapper- ObjectMapper used for serialize/deserialize- Returns:
- WebClient
-
buildWebClient
public static org.springframework.web.reactive.function.client.WebClient buildWebClient()Build the WebClient used to make HTTP requests.- Returns:
- WebClient
-
getBasePath
Get the current base path- Returns:
- String the base path
-
setBasePath
Set the base path, which should include the host- Parameters:
basePath- the base path- Returns:
- ApiClient this client
-
getAuthentications
Get authentications (key: authentication name, value: authentication).- Returns:
- Map the currently configured authentication types
-
getAuthentication
Get authentication for the given name.- Parameters:
authName- The authentication name- Returns:
- The authentication, null if not found
-
setBearerToken
Helper method to set access token for the first Bearer authentication.- Parameters:
bearerToken- Bearer token
-
setUsername
Helper method to set username for the first HTTP basic authentication.- Parameters:
username- the username
-
setPassword
Helper method to set password for the first HTTP basic authentication.- Parameters:
password- the password
-
setApiKey
Helper method to set API key value for the first API key authentication.- Parameters:
apiKey- the API key
-
setApiKeyPrefix
Helper method to set API key prefix for the first API key authentication.- Parameters:
apiKeyPrefix- the API key prefix
-
setAccessToken
Helper method to set access token for the first OAuth2 authentication.- Parameters:
accessToken- the access token
-
setUserAgent
Set the User-Agent header's value (by adding to the default header map).- Parameters:
userAgent- the user agent string- Returns:
- ApiClient this client
-
addDefaultHeader
Add a default header.- Parameters:
name- The header's namevalue- The header's value- Returns:
- ApiClient this client
-
addDefaultCookie
Add a default cookie.- Parameters:
name- The cookie's namevalue- The cookie's value- Returns:
- ApiClient this client
-
getDateFormat
Get the date format used to parse/format date parameters.- Returns:
- DateFormat format
-
parseDate
Parse the given string into Date object. -
formatDate
Format the given Date object into string. -
getObjectMapper
public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()Get the ObjectMapper used to make HTTP requests.- Returns:
- ObjectMapper objectMapper
-
getWebClient
public org.springframework.web.reactive.function.client.WebClient getWebClient()Get the WebClient used to make HTTP requests.- Returns:
- WebClient webClient
-
parameterToString
Format the given parameter object into string.- Parameters:
param- the object to convert- Returns:
- String the parameter represented as a String
-
parameterToMultiValueMap
public org.springframework.util.MultiValueMap<String,String> parameterToMultiValueMap(ApiClient.CollectionFormat collectionFormat, String name, Object value) Converts a parameter to aMultiValueMapfor use in REST requests- Parameters:
collectionFormat- The format to convert toname- The name of the parametervalue- The parameter's value- Returns:
- a Map containing the String value(s) of the input parameter
-
isJsonMime
Check if the givenStringis a JSON MIME.- Parameters:
mediaType- the input MediaType- Returns:
- boolean true if the MediaType represents JSON, false otherwise
-
isJsonMime
public boolean isJsonMime(org.springframework.http.MediaType mediaType) Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON- Parameters:
mediaType- the input MediaType- Returns:
- boolean true if the MediaType represents JSON, false otherwise
-
isProblemJsonMime
Check if the givenStringis a Problem JSON MIME (RFC-7807).- Parameters:
mediaType- the input MediaType- Returns:
- boolean true if the MediaType represents Problem JSON, false otherwise
-
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:
- List The list of MediaTypes to use for the Accept header
-
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:
- MediaType The Content-Type header to use. If the given array is empty, null will be returned.
-
selectBody
protected org.springframework.web.reactive.function.BodyInserter<?,? super org.springframework.http.client.reactive.ClientHttpRequest> selectBody(Object obj, org.springframework.util.MultiValueMap<String, Object> formParams, org.springframework.http.MediaType contentType) Select the body to use for the request- Parameters:
obj- the body objectformParams- the form parameterscontentType- the content type of the request- Returns:
- Object the selected body
-
invokeAPI
public <T> org.springframework.web.reactive.function.client.WebClient.ResponseSpec invokeAPI(String path, org.springframework.http.HttpMethod method, Map<String, Object> pathParams, org.springframework.util.MultiValueMap<String, throws org.springframework.web.client.RestClientExceptionString> queryParams, Object body, org.springframework.http.HttpHeaders headerParams, org.springframework.util.MultiValueMap<String, String> cookieParams, org.springframework.util.MultiValueMap<String, Object> formParams, List<org.springframework.http.MediaType> accept, org.springframework.http.MediaType contentType, String[] authNames, org.springframework.core.ParameterizedTypeReference<T> returnType) Invoke API by sending HTTP request with the given options.- Type Parameters:
T- the return type to use- Parameters:
path- The sub-path of the HTTP URLmethod- The request methodpathParams- The path parametersqueryParams- The query parametersbody- The request body objectheaderParams- The header parametersformParams- The form parametersaccept- The request's Accept headercontentType- The request's Content-Type headerauthNames- The authentications to applyreturnType- The return type into which to deserialize the response- Returns:
- The response body in chosen type
- Throws:
org.springframework.web.client.RestClientException
-
addHeadersToRequest
protected void addHeadersToRequest(org.springframework.http.HttpHeaders headers, org.springframework.web.reactive.function.client.WebClient.RequestBodySpec requestBuilder) Add headers to the request that is being built- Parameters:
headers- The headers to addrequestBuilder- The current request
-
addCookiesToRequest
protected void addCookiesToRequest(org.springframework.util.MultiValueMap<String, String> cookies, org.springframework.web.reactive.function.client.WebClient.RequestBodySpec requestBuilder) Add cookies to the request that is being built- Parameters:
cookies- The cookies to addrequestBuilder- The current request
-
updateParamsForAuth
protected void updateParamsForAuth(String[] authNames, org.springframework.util.MultiValueMap<String, String> queryParams, org.springframework.http.HttpHeaders headerParams, org.springframework.util.MultiValueMap<String, String> cookieParams) Update query and header parameters based on authentication settings.- Parameters:
authNames- The authentications to applyqueryParams- The query parametersheaderParams- The header parameterscookieParams- the cookie parameters
-
collectionPathParameterToString
public String collectionPathParameterToString(ApiClient.CollectionFormat collectionFormat, Collection<?> values) Formats the specified collection path parameter to a string value.- Parameters:
collectionFormat- The collection format of the parameter.values- The values of the parameter.- Returns:
- String representation of the parameter
-