Class ApiClient


  • @Generated(value="org.openapitools.codegen.languages.JavaClientCodegen",
               date="2020-05-15T14:38:14.328808-03:00[America/Argentina/Buenos_Aires]")
    public class ApiClient
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ApiClient()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ApiClient addDefaultCookie​(java.lang.String key, java.lang.String value)
      Add a default cookie.
      ApiClient addDefaultHeader​(java.lang.String key, java.lang.String value)
      Add a default header.
      protected javax.ws.rs.client.Client buildHttpClient​(boolean debugging)
      Build the Client used to make HTTP requests.
      protected java.util.Map<java.lang.String,​java.util.List<java.lang.String>> buildResponseHeaders​(javax.ws.rs.core.Response response)  
      <T> T deserialize​(javax.ws.rs.core.Response response, javax.ws.rs.core.GenericType<T> returnType)
      Deserialize response body to Java object according to the Content-Type.
      java.io.File downloadFileFromResponse​(javax.ws.rs.core.Response response)
      Download file from the given response.
      java.lang.String escapeString​(java.lang.String str)
      Escape the given string to be used as URL query value.
      java.lang.String formatDate​(java.util.Date date)
      Format the given Date object into string.
      Authentication getAuthentication​(java.lang.String authName)
      Get authentication for the given name.
      java.util.Map<java.lang.String,​Authentication> getAuthentications()
      Get authentications (key: authentication name, value: authentication).
      java.lang.String getBasePath()  
      int getConnectTimeout()
      Connect timeout (in milliseconds).
      java.text.DateFormat getDateFormat()
      Get the date format used to parse/format date parameters.
      javax.ws.rs.client.Client getHttpClient()  
      JSON getJSON()
      Gets the JSON instance to do JSON serialization and deserialization.
      int getReadTimeout()
      read timeout (in milliseconds).
      java.lang.String getTempFolderPath()
      The path of temporary folder used to store downloaded files from endpoints with file response.
      <T> ApiResponse<T> invokeAPI​(java.lang.String path, java.lang.String method, java.util.List<Pair> queryParams, java.lang.Object body, java.util.Map<java.lang.String,​java.lang.String> headerParams, java.util.Map<java.lang.String,​java.lang.String> cookieParams, java.util.Map<java.lang.String,​java.lang.Object> formParams, java.lang.String accept, java.lang.String contentType, java.lang.String[] authNames, javax.ws.rs.core.GenericType<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​(java.lang.String mime)
      Check if the given MIME is a JSON MIME.
      java.util.List<Pair> parameterToPairs​(java.lang.String collectionFormat, java.lang.String name, java.lang.Object value)  
      java.lang.String parameterToString​(java.lang.Object param)
      Format the given parameter object into string.
      java.util.Date parseDate​(java.lang.String str)
      Parse the given string into Date object.
      protected void performAdditionalClientConfiguration​(org.glassfish.jersey.client.ClientConfig clientConfig)  
      java.io.File prepareDownloadFile​(javax.ws.rs.core.Response response)  
      java.lang.String selectHeaderAccept​(java.lang.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)
      java.lang.String selectHeaderContentType​(java.lang.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.
      javax.ws.rs.client.Entity<?> serialize​(java.lang.Object obj, java.util.Map<java.lang.String,​java.lang.Object> formParams, java.lang.String contentType)
      Serialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).
      void setApiKey​(java.lang.String apiKey)
      Helper method to set API key value for the first API key authentication.
      void setApiKeyPrefix​(java.lang.String apiKeyPrefix)
      Helper method to set API key prefix for the first API key authentication.
      ApiClient setBasePath​(java.lang.String basePath)  
      void setBearerToken​(java.lang.String bearerToken)
      Helper method to set bearer token for the first Bearer authentication.
      ApiClient setConnectTimeout​(int connectionTimeout)
      Set the connect timeout (in milliseconds).
      ApiClient setDateFormat​(java.text.DateFormat dateFormat)
      Set the date format used to parse/format date parameters.
      ApiClient setDebugging​(boolean debugging)
      Enable/disable debugging for this API client.
      ApiClient setHttpClient​(javax.ws.rs.client.Client httpClient)  
      void setPassword​(java.lang.String password)
      Helper method to set password for the first HTTP basic authentication.
      ApiClient setReadTimeout​(int readTimeout)
      Set the read timeout (in milliseconds).
      ApiClient setTempFolderPath​(java.lang.String tempFolderPath)
      Set temp folder path
      ApiClient setUserAgent​(java.lang.String userAgent)
      Set the User-Agent header's value (by adding to the default header map).
      void setUsername​(java.lang.String username)
      Helper method to set username for the first HTTP basic authentication.
      protected void updateParamsForAuth​(java.lang.String[] authNames, java.util.List<Pair> queryParams, java.util.Map<java.lang.String,​java.lang.String> headerParams, java.util.Map<java.lang.String,​java.lang.String> cookieParams)
      Update query and header parameters based on authentication settings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • defaultHeaderMap

        protected java.util.Map<java.lang.String,​java.lang.String> defaultHeaderMap
      • defaultCookieMap

        protected java.util.Map<java.lang.String,​java.lang.String> defaultCookieMap
      • basePath

        protected java.lang.String basePath
      • debugging

        protected boolean debugging
      • connectionTimeout

        protected int connectionTimeout
      • httpClient

        protected javax.ws.rs.client.Client httpClient
      • json

        protected JSON json
      • tempFolderPath

        protected java.lang.String tempFolderPath
      • authentications

        protected java.util.Map<java.lang.String,​Authentication> authentications
      • dateFormat

        protected java.text.DateFormat dateFormat
    • Constructor Detail

      • ApiClient

        public ApiClient()
    • Method Detail

      • getJSON

        public JSON getJSON()
        Gets the JSON instance to do JSON serialization and deserialization.
        Returns:
        JSON
      • getHttpClient

        public javax.ws.rs.client.Client getHttpClient()
      • setHttpClient

        public ApiClient setHttpClient​(javax.ws.rs.client.Client httpClient)
      • getBasePath

        public java.lang.String getBasePath()
      • setBasePath

        public ApiClient setBasePath​(java.lang.String basePath)
      • getAuthentications

        public java.util.Map<java.lang.String,​Authentication> getAuthentications()
        Get authentications (key: authentication name, value: authentication).
        Returns:
        Map of authentication object
      • getAuthentication

        public Authentication getAuthentication​(java.lang.String authName)
        Get authentication for the given name.
        Parameters:
        authName - The authentication name
        Returns:
        The authentication, null if not found
      • setUsername

        public void setUsername​(java.lang.String username)
        Helper method to set username for the first HTTP basic authentication.
        Parameters:
        username - Username
      • setPassword

        public void setPassword​(java.lang.String password)
        Helper method to set password for the first HTTP basic authentication.
        Parameters:
        password - Password
      • setApiKey

        public void setApiKey​(java.lang.String apiKey)
        Helper method to set API key value for the first API key authentication.
        Parameters:
        apiKey - API key
      • setApiKeyPrefix

        public void setApiKeyPrefix​(java.lang.String apiKeyPrefix)
        Helper method to set API key prefix for the first API key authentication.
        Parameters:
        apiKeyPrefix - API key prefix
      • setBearerToken

        public void setBearerToken​(java.lang.String bearerToken)
        Helper method to set bearer token for the first Bearer authentication.
        Parameters:
        bearerToken - Bearer token
      • setUserAgent

        public ApiClient setUserAgent​(java.lang.String userAgent)
        Set the User-Agent header's value (by adding to the default header map).
        Parameters:
        userAgent - Http user agent
        Returns:
        API client
      • addDefaultHeader

        public ApiClient addDefaultHeader​(java.lang.String key,
                                          java.lang.String value)
        Add a default header.
        Parameters:
        key - The header's key
        value - The header's value
        Returns:
        API client
      • addDefaultCookie

        public ApiClient addDefaultCookie​(java.lang.String key,
                                          java.lang.String value)
        Add a default cookie.
        Parameters:
        key - The cookie's key
        value - The cookie's value
        Returns:
        API client
      • isDebugging

        public boolean isDebugging()
        Check that whether debugging is enabled for this API client.
        Returns:
        True if debugging is switched on
      • setDebugging

        public ApiClient setDebugging​(boolean debugging)
        Enable/disable debugging for this API client.
        Parameters:
        debugging - To enable (true) or disable (false) debugging
        Returns:
        API client
      • getTempFolderPath

        public java.lang.String getTempFolderPath()
        The path of temporary folder used to store downloaded files from endpoints with file response. The default value is null, i.e. using the system's default tempopary folder.
        Returns:
        Temp folder path
      • setTempFolderPath

        public ApiClient setTempFolderPath​(java.lang.String tempFolderPath)
        Set temp folder path
        Parameters:
        tempFolderPath - Temp folder path
        Returns:
        API client
      • getConnectTimeout

        public int getConnectTimeout()
        Connect timeout (in milliseconds).
        Returns:
        Connection timeout
      • setConnectTimeout

        public ApiClient setConnectTimeout​(int connectionTimeout)
        Set the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE.
        Parameters:
        connectionTimeout - Connection timeout in milliseconds
        Returns:
        API client
      • getReadTimeout

        public int getReadTimeout()
        read timeout (in milliseconds).
        Returns:
        Read timeout
      • setReadTimeout

        public ApiClient setReadTimeout​(int readTimeout)
        Set the read timeout (in milliseconds). A value of 0 means no timeout, otherwise values must be between 1 and Integer.MAX_VALUE.
        Parameters:
        readTimeout - Read timeout in milliseconds
        Returns:
        API client
      • getDateFormat

        public java.text.DateFormat getDateFormat()
        Get the date format used to parse/format date parameters.
        Returns:
        Date format
      • setDateFormat

        public ApiClient setDateFormat​(java.text.DateFormat dateFormat)
        Set the date format used to parse/format date parameters.
        Parameters:
        dateFormat - Date format
        Returns:
        API client
      • parseDate

        public java.util.Date parseDate​(java.lang.String str)
        Parse the given string into Date object.
        Parameters:
        str - String
        Returns:
        Date
      • formatDate

        public java.lang.String formatDate​(java.util.Date date)
        Format the given Date object into string.
        Parameters:
        date - Date
        Returns:
        Date in string format
      • parameterToString

        public java.lang.String parameterToString​(java.lang.Object param)
        Format the given parameter object into string.
        Parameters:
        param - Object
        Returns:
        Object in string format
      • parameterToPairs

        public java.util.List<Pair> parameterToPairs​(java.lang.String collectionFormat,
                                                     java.lang.String name,
                                                     java.lang.Object value)
      • isJsonMime

        public boolean isJsonMime​(java.lang.String mime)
        Check if the given MIME is a JSON MIME. JSON MIME examples: application/json application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / *" is also default to JSON
        Parameters:
        mime - MIME
        Returns:
        True if the MIME type is JSON
      • selectHeaderAccept

        public java.lang.String selectHeaderAccept​(java.lang.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 java.lang.String selectHeaderContentType​(java.lang.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 java.lang.String escapeString​(java.lang.String str)
        Escape the given string to be used as URL query value.
        Parameters:
        str - String
        Returns:
        Escaped string
      • serialize

        public javax.ws.rs.client.Entity<?> serialize​(java.lang.Object obj,
                                                      java.util.Map<java.lang.String,​java.lang.Object> formParams,
                                                      java.lang.String contentType)
                                               throws ApiException
        Serialize the given Java object into string entity according the given Content-Type (only JSON is supported for now).
        Parameters:
        obj - Object
        formParams - Form parameters
        contentType - Context type
        Returns:
        Entity
        Throws:
        ApiException - API exception
      • deserialize

        public <T> T deserialize​(javax.ws.rs.core.Response response,
                                 javax.ws.rs.core.GenericType<T> returnType)
                          throws ApiException
        Deserialize response body to Java object according to the Content-Type.
        Type Parameters:
        T - Type
        Parameters:
        response - Response
        returnType - Return type
        Returns:
        Deserialize object
        Throws:
        ApiException - API exception
      • downloadFileFromResponse

        public java.io.File downloadFileFromResponse​(javax.ws.rs.core.Response response)
                                              throws ApiException
        Download file from the given response.
        Parameters:
        response - Response
        Returns:
        File
        Throws:
        ApiException - If fail to read file content from response and write to disk
      • prepareDownloadFile

        public java.io.File prepareDownloadFile​(javax.ws.rs.core.Response response)
                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • invokeAPI

        public <T> ApiResponse<T> invokeAPI​(java.lang.String path,
                                            java.lang.String method,
                                            java.util.List<Pair> queryParams,
                                            java.lang.Object body,
                                            java.util.Map<java.lang.String,​java.lang.String> headerParams,
                                            java.util.Map<java.lang.String,​java.lang.String> cookieParams,
                                            java.util.Map<java.lang.String,​java.lang.Object> formParams,
                                            java.lang.String accept,
                                            java.lang.String contentType,
                                            java.lang.String[] authNames,
                                            javax.ws.rs.core.GenericType<T> returnType)
                                     throws ApiException
        Invoke API by sending HTTP request with the given options.
        Type Parameters:
        T - Type
        Parameters:
        path - The sub-path of the HTTP URL
        method - The request method, one of "GET", "POST", "PUT", "HEAD" and "DELETE"
        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:
        The response body in type of string
        Throws:
        ApiException - API exception
      • buildHttpClient

        protected javax.ws.rs.client.Client buildHttpClient​(boolean debugging)
        Build the Client used to make HTTP requests.
        Parameters:
        debugging - Debug setting
        Returns:
        Client
      • performAdditionalClientConfiguration

        protected void performAdditionalClientConfiguration​(org.glassfish.jersey.client.ClientConfig clientConfig)
      • buildResponseHeaders

        protected java.util.Map<java.lang.String,​java.util.List<java.lang.String>> buildResponseHeaders​(javax.ws.rs.core.Response response)
      • updateParamsForAuth

        protected void updateParamsForAuth​(java.lang.String[] authNames,
                                           java.util.List<Pair> queryParams,
                                           java.util.Map<java.lang.String,​java.lang.String> headerParams,
                                           java.util.Map<java.lang.String,​java.lang.String> cookieParams)
        Update query and header parameters based on authentication settings.
        Parameters:
        authNames - The authentications to apply
        queryParams - List of query parameters
        headerParams - Map of header parameters
        cookieParams - Map of cookie parameters