org.appng.openapi.invoke

## Class ApiClient

- java.lang.Object
- - org.appng.openapi.invoke.JavaTimeFormatter
  - - org.appng.openapi.invoke.ApiClient

-     @Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
                 date="2023-03-20T12:57:48.851+01:00[Europe/Berlin]")
       @Component(value="org.appng.openapi.invoke.ApiClient")
      public class ApiClient
      extends JavaTimeFormatter

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `ApiClient.CollectionFormat`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ApiClient()`
    `ApiClient(org.springframework.web.client.RestTemplate restTemplate)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addCookiesToRequest(org.springframework.util.MultiValueMap<String,String> cookies, org.springframework.http.RequestEntity.BodyBuilder requestBuilder)` Add cookies to the request that is being built
    `ApiClient` | `addDefaultCookie(String name, String value)` Add a default cookie.
    `ApiClient` | `addDefaultHeader(String name, String value)` Add a default header.
    `protected void` | `addHeadersToRequest(org.springframework.http.HttpHeaders headers, org.springframework.http.RequestEntity.BodyBuilder requestBuilder)` Add headers to the request that is being built
    `protected org.springframework.web.client.RestTemplate` | `buildRestTemplate()` Build the RestTemplate used to make HTTP requests.
    `String` | `collectionPathParameterToString(ApiClient.CollectionFormat collectionFormat, Collection<?> values)` Formats the specified collection path parameter to a string value.
    `String` | `expandPath(String pathTemplate, Map<String,Object> variables)` Expand path template with variables
    `String` | `formatDate(Date date)` Format the given Date object into string.
    `Authentication` | `getAuthentication(String authName)` Get authentication for the given name.
    `Map<String,Authentication>` | `getAuthentications()` Get authentications (key: authentication name, value: authentication).
    `String` | `getBasePath()` Get the current base path
    `DateFormat` | `getDateFormat()` Get the date format used to parse/format date parameters.
    `protected void` | `init()`
    `<T> org.springframework.http.ResponseEntity<T>` | `invokeAPI(String path, org.springframework.http.HttpMethod method, 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.
    `boolean` | `isDebugging()` Check that whether debugging is enabled for this API client.
    `boolean` | `isJsonMime(org.springframework.http.MediaType mediaType)` Check if the given MIME is a JSON MIME.
    `boolean` | `isJsonMime(String mediaType)` Check if the given `String` is a JSON MIME.
    `boolean` | `isProblemJsonMime(String mediaType)` Check if the given `String` is a Problem JSON MIME (RFC-7807).
    `org.springframework.util.MultiValueMap<String,String>` | `parameterToMultiValueMap(ApiClient.CollectionFormat collectionFormat, String name, Object value)` Converts a parameter to a `MultiValueMap` for use in REST requests
    `String` | `parameterToString(Object param)` Format the given parameter object into string.
    `Date` | `parseDate(String str)` Parse the given string into Date object.
    `protected Object` | `selectBody(Object obj, org.springframework.util.MultiValueMap<String,Object> formParams, org.springframework.http.MediaType contentType)` Select the body to use for the request
    `List<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.MediaType` | `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.
    `void` | `setApiKey(String apiKey)` Helper method to set API key value for the first API key authentication.
    `void` | `setApiKeyPrefix(String apiKeyPrefix)` Helper method to set API key prefix for the first API key authentication.
    `ApiClient` | `setBasePath(String basePath)` Set the base path, which should include the host
    `ApiClient` | `setDateFormat(DateFormat dateFormat)` Set the date format used to parse/format date parameters.
    `void` | `setDebugging(boolean debugging)`
    `ApiClient` | `setUserAgent(String userAgent)` Set the User-Agent header's value (by adding to the default header map).
    `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.

    - ### Methods inherited from class org.appng.openapi.invoke.JavaTimeFormatter

      `formatOffsetDateTime, getOffsetDateTimeFormatter, parseOffsetDateTime, setOffsetDateTimeFormatter`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ApiClient

          public ApiClient()

    - #### ApiClient

          @Autowired
          public ApiClient(org.springframework.web.client.RestTemplate restTemplate)

  - ### Method Detail

    - #### init

          protected void init()

    - #### getBasePath

          public String getBasePath()

      Get the current base path
      Returns:
        String the base path

    - #### setBasePath

          public ApiClient setBasePath(String basePath)

      Set the base path, which should include the host
      Parameters:
        `basePath` - the base path
      Returns:
        ApiClient this client

    - #### getAuthentications

          public Map<String,Authentication> getAuthentications()

      Get authentications (key: authentication name, value: authentication).
      Returns:
        Map the currently configured authentication types

    - #### getAuthentication

          public Authentication getAuthentication(String authName)

      Get authentication for the given name.
      Parameters:
        `authName` - The authentication name
      Returns:
        The authentication, null if not found

    - #### setApiKey

          public void setApiKey(String apiKey)

      Helper method to set API key value for the first API key authentication.
      Parameters:
        `apiKey` - the API key

    - #### setApiKeyPrefix

          public void setApiKeyPrefix(String apiKeyPrefix)

      Helper method to set API key prefix for the first API key authentication.
      Parameters:
        `apiKeyPrefix` - API key prefix

    - #### setUserAgent

          public ApiClient setUserAgent(String userAgent)

      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

          public ApiClient addDefaultHeader(String name,
                                            String value)

      Add a default header.
      Parameters:
        `name` - The header's name
        `value` - The header's value
      Returns:
        ApiClient this client

    - #### addDefaultCookie

          public ApiClient addDefaultCookie(String name,
                                            String value)

      Add a default cookie.
      Parameters:
        `name` - The cookie's name
        `value` - The cookie's value
      Returns:
        ApiClient this client

    - #### setDebugging

          public void setDebugging(boolean debugging)

    - #### isDebugging

          public boolean isDebugging()

      Check that whether debugging is enabled for this API client.
      Returns:
        boolean true if this client is enabled for debugging, false otherwise

    - #### getDateFormat

          public DateFormat getDateFormat()

      Get the date format used to parse/format date parameters.
      Returns:
        DateFormat format

    - #### setDateFormat

          public ApiClient setDateFormat(DateFormat dateFormat)

      Set the date format used to parse/format date parameters.
      Parameters:
        `dateFormat` - Date format
      Returns:
        API client

    - #### parseDate

          public Date parseDate(String str)

      Parse the given string into Date object.
      Parameters:
        `str` - the string to parse
      Returns:
        the Date parsed from the string

    - #### formatDate

          public String formatDate(Date date)

      Format the given Date object into string.
      Parameters:
        `date` - the date to format
      Returns:
        the formatted date as string

    - #### parameterToString

          public String parameterToString(Object param)

      Format the given parameter object into string.
      Parameters:
        `param` - the object to convert
      Returns:
        String the parameter represented as a String

    - #### 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

    - #### parameterToMultiValueMap

          public org.springframework.util.MultiValueMap<String,String> parameterToMultiValueMap(ApiClient.CollectionFormat collectionFormat,
                                                                                                String name,
                                                                                                Object value)

      Converts a parameter to a `MultiValueMap` for use in REST requests
      Parameters:
        `collectionFormat` - The format to convert to
        `name` - The name of the parameter
        `value` - The parameter's value
      Returns:
        a Map containing the String value(s) of the input parameter

    - #### isJsonMime

          public boolean isJsonMime(String mediaType)

      Check if the given `String` is 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

          public boolean isProblemJsonMime(String mediaType)

      Check if the given `String` is a Problem JSON MIME (RFC-7807).
      Parameters:
        `mediaType` - the input MediaType
      Returns:
        boolean true if the MediaType represents Problem JSON, false otherwise

    - #### selectHeaderAccept

          public List<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)
      Parameters:
        `accepts` - The accepts array to select from
      Returns:
        List The list of MediaTypes to use for the Accept header

    - #### selectHeaderContentType

          public org.springframework.http.MediaType 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:
        MediaType The Content-Type header to use. If the given array is empty, JSON will be used.

    - #### selectBody

          protected Object 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 object
        `formParams` - the form parameters
        `contentType` - the content type of the request
      Returns:
        Object the selected body

    - #### expandPath

          public String expandPath(String pathTemplate,
                                   Map<String,Object> variables)

      Expand path template with variables
      Parameters:
        `pathTemplate` - path template with placeholders
        `variables` - variables to replace
      Returns:
        path with placeholders replaced by variables

    - #### invokeAPI

          public <T> org.springframework.http.ResponseEntity<T> invokeAPI(String path,
                                                                          org.springframework.http.HttpMethod method,
                                                                          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)
                                                                   throws org.springframework.web.client.RestClientException

      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 URL
        `method` - The request method
        `queryParams` - The query parameters
        `body` - The request body object
        `headerParams` - The header parameters
        `cookieParams` - The cookie parameters
        `formParams` - The form parameters
        `accept` - The request's Accept header
        `contentType` - The request's Content-Type header
        `authNames` - The authentications to apply
        `returnType` - The return type into which to deserialize the response
      Returns:
        ResponseEntity<T> The response of the chosen type
      Throws:
        `org.springframework.web.client.RestClientException`

    - #### addHeadersToRequest

          protected void addHeadersToRequest(org.springframework.http.HttpHeaders headers,
                                             org.springframework.http.RequestEntity.BodyBuilder requestBuilder)

      Add headers to the request that is being built
      Parameters:
        `headers` - The headers to add
        `requestBuilder` - The current request

    - #### addCookiesToRequest

          protected void addCookiesToRequest(org.springframework.util.MultiValueMap<String,String> cookies,
                                             org.springframework.http.RequestEntity.BodyBuilder requestBuilder)

      Add cookies to the request that is being built
      Parameters:
        `cookies` - The cookies to add
        `requestBuilder` - The current request

    - #### buildRestTemplate

          protected org.springframework.web.client.RestTemplate buildRestTemplate()

      Build the RestTemplate used to make HTTP requests.
      Returns:
        RestTemplate

    - #### 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 apply
        `queryParams` - The query parameters
        `headerParams` - The header parameters

Copyright © 2011–2023 aiticon GmbH. All rights reserved.