Interface ClientService

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      Optional<org.apache.http.client.methods.HttpGet> buildGetAcceptionApplicatonJson​(String endpoint, String authToken)
      builds a HttpGet request object for the given endpoint using authToken as basic authentication header.
      Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding​(String endpoint, String authToken)
      Builds a HttpGet request object for the endpoint given by endpoint using authToken as basic authentication header
      Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding​(String endpoint, String authToken, org.apache.http.NameValuePair... params)
      builds a HttpGet request object for the given endpoint using authToken as basic authentication header and params as additional URL key/value parameters
      Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingApplicationJson​(String endpoint, org.apache.http.HttpEntity body)
      builds a HttpPost request object for the given endpoint containing the provided body content body will be posted using Content-Type of application/json
      Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingFormUrlEncoding​(String endpoint, String authToken, org.apache.http.NameValuePair... params)
      builds a HttpPost request object for the given endpoint containing the provided body content body will be posted using Content-Type as application/x-www-form-urlencoded
      Optional<org.json.JSONObject> executeJsonRequest​(org.apache.http.client.methods.HttpRequestBase request)
      executes the provided HttpRequestBase returning the result as a JSONObject
    • Method Detail

      • executeJsonRequest

        Optional<org.json.JSONObject> executeJsonRequest​(org.apache.http.client.methods.HttpRequestBase request)
        executes the provided HttpRequestBase returning the result as a JSONObject
        Parameters:
        request - the request to send/execute
        Returns:
        on success an Optional containing a JSONObject; otherwise, Optional.empty()
      • buildGetRequestUsingFormUrlEncoding

        Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding​(String endpoint,
                                                                                             String authToken)
        Builds a HttpGet request object for the endpoint given by endpoint using authToken as basic authentication header
        Parameters:
        endpoint - endpoint to perform get request on
        authToken - authorization token for basic authentication
        Returns:
        Optional of HttpGet containing the request object
        Throws:
        IllegalArgumentException - when either endpoint or authToken are null or empty
      • buildGetRequestUsingFormUrlEncoding

        Optional<org.apache.http.client.methods.HttpGet> buildGetRequestUsingFormUrlEncoding​(String endpoint,
                                                                                             String authToken,
                                                                                             org.apache.http.NameValuePair... params)
        builds a HttpGet request object for the given endpoint using authToken as basic authentication header and params as additional URL key/value parameters
        Parameters:
        endpoint - endpoint to perform get request on
        authToken - authorization token for basic authentication
        params - name/value pairs encoded and added to endpoint
        Returns:
        Optional of HttpGet containing the request object
        Throws:
        IllegalArgumentException - when either endpoint or authToken are null or empty
      • buildGetAcceptionApplicatonJson

        Optional<org.apache.http.client.methods.HttpGet> buildGetAcceptionApplicatonJson​(String endpoint,
                                                                                         String authToken)
        builds a HttpGet request object for the given endpoint using authToken as basic authentication header. Request is sent using Content-Type and Accept as Application/json
        Parameters:
        endpoint - endpoint to perform get request on
        authToken - authorization token for basic authentication
        Returns:
        Optional of HttpGet containing the request object
        Throws:
        IllegalArgumentException - when either endpoint or authToken are null or empty
      • buildPostRequestUsingApplicationJson

        Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingApplicationJson​(String endpoint,
                                                                                               org.apache.http.HttpEntity body)
        builds a HttpPost request object for the given endpoint containing the provided body content body will be posted using Content-Type of application/json
        Parameters:
        endpoint - endpoint to perform post request on
        body - JSON body to be sent with the request
        Returns:
        Optional of HttpPost containg the request object
      • buildPostRequestUsingFormUrlEncoding

        Optional<org.apache.http.client.methods.HttpPost> buildPostRequestUsingFormUrlEncoding​(String endpoint,
                                                                                               String authToken,
                                                                                               org.apache.http.NameValuePair... params)
        builds a HttpPost request object for the given endpoint containing the provided body content body will be posted using Content-Type as application/x-www-form-urlencoded
        Parameters:
        endpoint - endpoint to perform post request on
        authToken - authorization token for basic authentication
        params - name/value pairs sent as the entity of the request
        Returns:
        Optional of HttpPost containg the request object