Class DefaultAPIClient

java.lang.Object
com.testdroid.api.AbstractAPIClient
com.testdroid.api.DefaultAPIClient
All Implemented Interfaces:
APIClient

public class DefaultAPIClient extends AbstractAPIClient
Author:
Łukasz Kajda <[email protected]>, Slawomir Pawluk <[email protected]>, Krzysztof Fonał <[email protected]>
  • Field Details

    • HTTP_CONNECT_TIMEOUT

      public static final int HTTP_CONNECT_TIMEOUT
      See Also:
    • HTTP_READ_TIMEOUT

      public static final int HTTP_READ_TIMEOUT
      See Also:
    • BITBAR_API_OAUTH2_CLIENT_ID

      public static final String BITBAR_API_OAUTH2_CLIENT_ID
      See Also:
    • accessToken

      protected String accessToken
    • accessTokenExpireTime

      protected long accessTokenExpireTime
    • cloudURL

      protected String cloudURL
    • password

      protected String password
    • refreshToken

      protected String refreshToken
    • username

      protected String username
  • Constructor Details

    • DefaultAPIClient

      public DefaultAPIClient(String cloudURL, String username, String password)
    • DefaultAPIClient

      public DefaultAPIClient(String cloudURL, String username, String password, boolean skipCheckCertificate)
    • DefaultAPIClient

      public DefaultAPIClient(String cloudURL, String username, String password, org.apache.http.HttpHost proxy, boolean skipCheckCertificate)
    • DefaultAPIClient

      public DefaultAPIClient(String cloudURL, String username, String password, org.apache.http.HttpHost proxy, String proxyUser, String proxyPassword, boolean skipCheckCertificate)
  • Method Details

    • getRequestFactory

      protected com.google.api.client.http.HttpRequestFactory getRequestFactory() throws APIException
      Overrides:
      getRequestFactory in class AbstractAPIClient
      Throws:
      APIException - Overriding classes may throw this exception if they execute some API calls
    • acquireAccessToken

      protected String acquireAccessToken() throws APIException
      Throws:
      APIException
    • refreshAccessToken

      protected String refreshAccessToken() throws APIException
      Throws:
      APIException
    • get

      public <T extends APIEntity> T get(String uri, Class<T> type) throws APIException
      Description copied from interface: APIClient
      Calls GET request to API
      Specified by:
      get in interface APIClient
      Overrides:
      get in class AbstractAPIClient
      Type Parameters:
      T - expected result class to be parsed from response
      Parameters:
      uri - context URI of the resource (without /api/v2 prefix
      type - expected result class to be parsed from response
      Returns:
      object defined as T if succesfully returned and parsed
      Throws:
      APIException - on any problem related to API communication
    • get

      public InputStream get(String uri) throws APIException
      Description copied from interface: APIClient
      Calls GET request to API. Used when result expected as stream.
      Specified by:
      get in interface APIClient
      Overrides:
      get in class AbstractAPIClient
      Parameters:
      uri - context URI of the resource (without /api/v2 prefix
      Returns:
      stream with response
      Throws:
      APIException - on any problem related to API communication
    • post

      public <T extends APIEntity> T post(String uri, Object body, Class<T> type) throws APIException
      Description copied from interface: APIClient
      Calls POST request to API
      Specified by:
      post in interface APIClient
      Overrides:
      post in class AbstractAPIClient
      Type Parameters:
      T - expected result class to be parsed from response
      Parameters:
      uri - context URI of the resource (without /api/v2 prefix
      body - body - usually url encoded, to POST to API
      type - expected result class to be parsed from response
      Returns:
      object defined as T if succesfully returned and parsed
      Throws:
      APIException - on any problem related to API communication
    • postFile

      public <T extends APIEntity> T postFile(String uri, String contentType, File file, Map<String,String> fileExtraParams, Class<T> type) throws APIException
      Description copied from interface: APIClient
      Calls POST request to API
      Specified by:
      postFile in interface APIClient
      Overrides:
      postFile in class AbstractAPIClient
      Type Parameters:
      T - expected result class to be parsed from response
      Parameters:
      uri - context URI of the resource (without /api/v2 prefix)
      contentType - content type of uploaded file
      file - file to be uploaded with that request
      fileExtraParams - extra parameters for form-data describing the file
      type - expected result class to be parsed from response
      Returns:
      object defined as T if successfully returned and parsed
      Throws:
      APIException - on any problem related to API communication
    • delete

      public void delete(String uri) throws APIException
      Description copied from interface: APIClient
      Calls DELETE request to API
      Specified by:
      delete in interface APIClient
      Overrides:
      delete in class AbstractAPIClient
      Parameters:
      uri - context URI of the resource (without /api/v2 prefix
      Throws:
      APIException - on any problem related to API communication
    • getHttpHeaders

      protected com.google.api.client.http.HttpHeaders getHttpHeaders()
      Specified by:
      getHttpHeaders in class AbstractAPIClient