Package com.xero.api

Class ApiClient


  • public class ApiClient
    extends Object
    ApiClient for managing global http client and object mapper
    • Constructor Summary

      Constructors 
      Constructor Description
      ApiClient()
      method for initiazing object instance with default properties
      ApiClient​(String basePath, com.google.api.client.http.HttpTransport transport, com.google.api.client.http.HttpRequestInitializer initializer, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.google.api.client.http.HttpRequestFactory reqFactory)
      ApiClient method for initiazing object instance with custom properties
    • Constructor Detail

      • ApiClient

        public ApiClient()
        method for initiazing object instance with default properties
      • ApiClient

        public ApiClient​(String basePath,
                         com.google.api.client.http.HttpTransport transport,
                         com.google.api.client.http.HttpRequestInitializer initializer,
                         com.fasterxml.jackson.databind.ObjectMapper objectMapper,
                         com.google.api.client.http.HttpRequestFactory reqFactory)
        ApiClient method for initiazing object instance with custom properties
        Parameters:
        basePath - String that defines the base path for each API request
        transport - HttpTransport required for creating the httpRequestFactory
        initializer - HttpRequestInitializer for additional configuration during creation of httpRequestFactory
        objectMapper - ObjectMapper object used to serialize and deserialize using model classes.
        reqFactory - HttpRequestFactory is the thread-safe light-weight HTTP request factory layer on top of the HTTP transport
    • Method Detail

      • getHttpRequestFactory

        public com.google.api.client.http.HttpRequestFactory getHttpRequestFactory()
        method for retrieving the httpRequestFactory property
        Returns:
        HttpRequestFactory
      • getConnectionTimeout

        public int getConnectionTimeout()
        method for retrieving the connectionTimeout property
        Returns:
        int
      • setConnectionTimeout

        public void setConnectionTimeout​(int connectionTimeout)
        method for setting the connectionTimeout property
        Parameters:
        connectionTimeout - int defines in milliseconds the time allowed making the initial connection to the server.
      • getReadTimeout

        public int getReadTimeout()
        method for retrieving the readTimeout property
        Returns:
        int
      • setReadTimeout

        public void setReadTimeout​(int readTimeout)
        method for setting the readTimeout property
        Parameters:
        readTimeout - int defines in milliseconds the time allowed to complete reading data from the server.
      • getHttpTransport

        public com.google.api.client.http.HttpTransport getHttpTransport()
        method for retrieving the httpTransport property
        Returns:
        HttpTransport
      • setHttpTransport

        public void setHttpTransport​(com.google.api.client.http.HttpTransport transport)
        method for setting the httpTransport property
        Parameters:
        transport - HttpTransport required for creating the httpRequestFactory
      • getBasePath

        public String getBasePath()
        method for retrieving the basePath property
        Returns:
        String
      • getObjectMapper

        public com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
        method for retrieving the objectMapper property
        Returns:
        ObjectMapper
      • accountingApi

        public AccountingApi accountingApi()
        Builder pattern to get API instances for this client.
        Returns:
        AccountingApi
      • verify

        public com.auth0.jwt.interfaces.DecodedJWT verify​(String accessToken)
                                                   throws MalformedURLException,
                                                          com.auth0.jwk.JwkException
        method for verifying an access token using RSA256 Algorithm
        Parameters:
        accessToken - String the JWT token used to access the API
        Returns:
        DecodedJWT
        Throws:
        MalformedURLException - Thrown to indicate that a malformed URL has occurred.
        com.auth0.jwk.JwkException - thrown to indicate a problem while verifying a JWT
      • revoke

        public com.google.api.client.http.HttpResponse revoke​(String clientId,
                                                              String clientSecret,
                                                              String refreshToken)
                                                       throws IOException
        method for revoking a refresh token
        Parameters:
        refreshToken - String the refresh token used to obtain a new access token via the API
        clientId - String the client id used to authtenticate with the API
        clientSecret - String the client secret used to authtenticate with the API
        Returns:
        revokeResponse HttpResponse a successful revocation request will return a 200 response with an empty body.
        Throws:
        IOException