Class ApiClient


  • public class ApiClient
    extends Object
    • Constructor Detail

      • ApiClient

        public ApiClient()
      • ApiClient

        public ApiClient​(String apiKey)
        Helper constructor for single api key
        Parameters:
        apiKey - API key
    • Method Detail

      • setBasePath

        public ApiClient setBasePath​(String basePath)
        Set base path
        Parameters:
        basePath - Base path of the URL (e.g https://localhost/api/v2
        Returns:
        An instance of OkHttpClient
      • setVerifyingSsl

        public ApiClient setVerifyingSsl​(boolean verifyingSsl)
        Configure whether to verify certificate and hostname when making https requests. Default to true. NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks.
        Parameters:
        verifyingSsl - True to verify TLS/SSL connection
        Returns:
        ApiClient
      • setDebugging

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

        public <S> S createService​(Class<S> serviceClass)
      • setApiKey

        public ApiClient setApiKey​(String apiKey)
        Helper method to configure the first api key found
        Parameters:
        apiKey - API key
        Returns:
        ApiClient
      • getAdapterBuilder

        public retrofit2.Retrofit.Builder getAdapterBuilder()
      • setAdapterBuilder

        public ApiClient setAdapterBuilder​(retrofit2.Retrofit.Builder adapterBuilder)
      • getOkBuilder

        public okhttp3.OkHttpClient.Builder getOkBuilder()
      • execute

        public <T> ApiResponse<T> execute​(retrofit2.Call<T> call)
                                   throws ApiException
        Execute HTTP call and deserialize the HTTP response body into the given return type.
        Parameters:
        call - Call
        Returns:
        ApiResponse object containing response status, headers and data, which is a Java object deserialized from response body and would be null when returnType is null.
        Throws:
        ApiException - If fail to execute the call