Class DefaultAPIClient

  • All Implemented Interfaces:
    APIClient

    public class DefaultAPIClient
    extends AbstractAPIClient
    Author:
    Łukasz Kajda , Slawomir Pawluk , Krzysztof Fonał
    • Field Detail

      • BITBAR_API_OAUTH2_CLIENT_ID

        public static final java.lang.String BITBAR_API_OAUTH2_CLIENT_ID
        See Also:
        Constant Field Values
      • accessToken

        protected java.lang.String accessToken
      • accessTokenExpireTime

        protected long accessTokenExpireTime
      • cloudURL

        protected java.lang.String cloudURL
      • password

        protected java.lang.String password
      • refreshToken

        protected java.lang.String refreshToken
      • username

        protected java.lang.String username
    • Constructor Detail

      • DefaultAPIClient

        public DefaultAPIClient​(java.lang.String cloudURL,
                                java.lang.String username,
                                java.lang.String password)
      • DefaultAPIClient

        public DefaultAPIClient​(java.lang.String cloudURL,
                                java.lang.String username,
                                java.lang.String password,
                                boolean skipCheckCertificate)
      • DefaultAPIClient

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

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

      • get

        public <T extends APIEntity> T get​(java.lang.String uri,
                                           java.lang.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 java.io.InputStream get​(java.lang.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​(java.lang.String uri,
                                            java.lang.Object body,
                                            java.lang.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​(java.lang.String uri,
                                                java.lang.String contentType,
                                                java.io.File file,
                                                java.util.Map<java.lang.String,​java.lang.String> fileExtraParams,
                                                java.lang.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​(java.lang.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