Class ApiClientJersey2

java.lang.Object
com.symphony.bdk.http.jersey2.ApiClientJersey2
All Implemented Interfaces:
com.symphony.bdk.http.api.ApiClient

@API(status=STABLE) public class ApiClientJersey2 extends Object implements com.symphony.bdk.http.api.ApiClient
Jersey2 implementation for the ApiClient interface called by generated code.
  • Field Details

    • httpClient

      protected jakarta.ws.rs.client.Client httpClient
    • basePath

      protected String basePath
    • defaultHeaderMap

      protected Map<String,String> defaultHeaderMap
    • tempFolderPath

      protected String tempFolderPath
    • authentications

      protected Map<String,com.symphony.bdk.http.api.auth.Authentication> authentications
    • enforcedAuthenticationSchemes

      protected List<String> enforcedAuthenticationSchemes
  • Constructor Details

    • ApiClientJersey2

      public ApiClientJersey2(jakarta.ws.rs.client.Client httpClient, String basePath, Map<String,String> defaultHeaders, String temporaryFolderPath)
  • Method Details

    • invokeAPI

      public <T> com.symphony.bdk.http.api.ApiResponse<T> invokeAPI(String path, String method, List<com.symphony.bdk.http.api.Pair> queryParams, Object body, Map<String,String> headerParams, Map<String,String> cookieParams, Map<String,Object> formParams, String accept, String contentType, String[] authNames, com.symphony.bdk.http.api.util.TypeReference<T> returnType) throws com.symphony.bdk.http.api.ApiException
      Specified by:
      invokeAPI in interface com.symphony.bdk.http.api.ApiClient
      Throws:
      com.symphony.bdk.http.api.ApiException
    • getBasePath

      public String getBasePath()
      Specified by:
      getBasePath in interface com.symphony.bdk.http.api.ApiClient
    • parameterToString

      public String parameterToString(Object param)
      Specified by:
      parameterToString in interface com.symphony.bdk.http.api.ApiClient
    • parameterToPairs

      public List<com.symphony.bdk.http.api.Pair> parameterToPairs(String collectionFormat, String name, Object value)
      Specified by:
      parameterToPairs in interface com.symphony.bdk.http.api.ApiClient
    • selectHeaderAccept

      public String selectHeaderAccept(String[] accepts)
      Specified by:
      selectHeaderAccept in interface com.symphony.bdk.http.api.ApiClient
    • selectHeaderContentType

      public String selectHeaderContentType(String[] contentTypes)
      Specified by:
      selectHeaderContentType in interface com.symphony.bdk.http.api.ApiClient
    • escapeString

      public String escapeString(String str)
      Specified by:
      escapeString in interface com.symphony.bdk.http.api.ApiClient
    • getAuthentications

      public Map<String,com.symphony.bdk.http.api.auth.Authentication> getAuthentications()
      Specified by:
      getAuthentications in interface com.symphony.bdk.http.api.ApiClient
    • addEnforcedAuthenticationScheme

      public void addEnforcedAuthenticationScheme(String name)
      Specified by:
      addEnforcedAuthenticationScheme in interface com.symphony.bdk.http.api.ApiClient
    • isJsonMime

      protected boolean isJsonMime(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
    • serialize

      protected jakarta.ws.rs.client.Entity<?> serialize(Object obj, Map<String,Object> formParams, String contentType)
      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
    • deserialize

      protected <T> T deserialize(jakarta.ws.rs.core.Response response, jakarta.ws.rs.core.GenericType<T> returnType) throws com.symphony.bdk.http.api.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:
      com.symphony.bdk.http.api.ApiException - API exception
    • downloadFileFromResponse

      protected File downloadFileFromResponse(jakarta.ws.rs.core.Response response) throws com.symphony.bdk.http.api.ApiException
      Download file from the given response.
      Parameters:
      response - Response
      Returns:
      File
      Throws:
      com.symphony.bdk.http.api.ApiException - If fail to read file content from response and write to disk
    • prepareDownloadFile

      protected File prepareDownloadFile(jakarta.ws.rs.core.Response response) throws IOException
      Throws:
      IOException
    • buildResponseHeaders

      protected Map<String,List<String>> buildResponseHeaders(jakarta.ws.rs.core.Response response)
    • updateParamsForAuth

      protected void updateParamsForAuth(String[] authNames, Map<String,String> headerParams) throws com.symphony.bdk.http.api.ApiException
      Update query and header parameters based on authentication settings.
      Parameters:
      authNames - The authentications to apply
      Throws:
      com.symphony.bdk.http.api.ApiException