java.lang.Object
com.sap.cloud.sdk.services.openapi.apache.ApiClient

public class ApiClient extends Object
API client for executing HTTP requests using Apache HttpClient 5.
  • Method Details

    • fromHttpClient

      @Nonnull public static ApiClient fromHttpClient(@Nonnull org.apache.hc.client5.http.impl.classic.CloseableHttpClient httpClient)
      Creates an ApiClient instance from an existing HttpClient.
      Parameters:
      httpClient - The HttpClient to use for requests
      Returns:
      A new ApiClient instance
    • create

      @Nonnull public static ApiClient create(@Nonnull Destination destination)
      Creates an ApiClient instance configured for the given destination.
      Parameters:
      destination - The destination to use for requests
      Returns:
      A new ApiClient instance configured with the destination
    • create

      @Nonnull public static ApiClient create()
      Creates an ApiClient instance with default configuration.
      Returns:
      A new ApiClient instance
    • parameterToString

      @Nonnull public static String parameterToString(@Nullable Object param)
      Format the given parameter object into string.
      Parameters:
      param - Object
      Returns:
      Object in string format
    • parameterToPair

      @Nonnull public static List<Pair> parameterToPair(@Nullable String name, @Nullable Object value)
      Formats the specified query parameter to a list containing a single Pair object.

      Note that value must not be a collection.

      Parameters:
      name - The name of the parameter.
      value - The value of the parameter.
      Returns:
      A list containing a single Pair object.
    • parameterToPairs

      @Nonnull public static List<Pair> parameterToPairs(@Nonnull String collectionFormat, @Nullable String name, @Nullable Collection<?> value)
      Formats the specified collection query parameters to a list of Pair objects.

      Note that the values of each of the returned Pair objects are percent-encoded.

      Parameters:
      collectionFormat - The collection format of the parameter.
      name - The name of the parameter.
      value - The value of the parameter.
      Returns:
      A list of Pair objects.
    • selectHeaderAccept

      @Nullable public static String selectHeaderAccept(@Nonnull 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

      @Nonnull public static String selectHeaderContentType(@Nonnull 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, or matches "any", JSON will be used.
    • escapeString

      @Nonnull public static String escapeString(@Nonnull String str)
      Escape the given string to be used as URL query value.
      Parameters:
      str - String
      Returns:
      Escaped string
    • invokeAPI

      @Beta @Nullable public <T> T invokeAPI(@Nonnull String path, @Nonnull String method, @Nullable List<Pair> queryParams, @Nullable List<Pair> collectionQueryParams, @Nullable String urlQueryDeepObject, @Nullable Object body, @Nonnull Map<String,String> headerParams, @Nonnull Map<String,Object> formParams, @Nullable String accept, @Nonnull String contentType, @Nonnull com.fasterxml.jackson.core.type.TypeReference<T> returnType) throws OpenApiRequestException
      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", and "DELETE"
      queryParams - The query parameters
      collectionQueryParams - The collection query parameters
      urlQueryDeepObject - A URL query string for deep object parameters
      body - The request body object - if it is not binary, otherwise null
      headerParams - The header parameters
      formParams - The form parameters
      accept - The request's Accept header
      contentType - The request's Content-Type header
      returnType - Return type
      Returns:
      The response body in type of string
      Throws:
      OpenApiRequestException - API exception
    • equals

      public boolean equals(@Nullable Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(@Nullable Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • withBasePath

      @Nonnull public ApiClient withBasePath(@Nonnull String basePath)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • getBasePath

      @Nonnull public String getBasePath()
    • withObjectMapper

      @Nonnull @Beta public ApiClient withObjectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper objectMapper)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withTempFolderPath

      @Nonnull public ApiClient withTempFolderPath(@Nullable String tempFolderPath)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).
    • withOpenApiResponseListener

      @Nonnull @Beta public ApiClient withOpenApiResponseListener(@Nullable OpenApiResponseListener openApiResponseListener)
      Returns:
      a clone of this object, except with this updated property (returns this if an identical value is passed).