public class Client
extends java.lang.Object
| Constructor and Description |
|---|
Client()
Constructor for using the default CloseableHttpClient.
|
Client(java.lang.Boolean test)
Constructor for passing in a test parameter to allow for http calls
|
Client(org.apache.http.impl.client.CloseableHttpClient httpClient)
Constructor for passing in an httpClient for mocking.
|
| Modifier and Type | Method and Description |
|---|---|
Response |
api(Request request)
A thin wrapper around the HTTP methods.
|
java.net.URI |
buildUri(java.lang.String baseUri,
java.lang.String endpoint,
java.util.Map<java.lang.String,java.lang.String> queryParams)
Add query parameters to a URL.
|
Response |
delete(Request request)
Make a DELETE request and provide the status code and response headers.
|
void |
finalize() |
Response |
get(Request request)
Make a GET request and provide the status code, response body and
response headers.
|
Response |
getResponse(org.apache.http.client.methods.CloseableHttpResponse response)
Prepare a Response object from an API call via Apache's HTTP client.
|
Response |
patch(Request request)
Make a PATCH request and provide the status code, response body and
response headers.
|
Response |
post(Request request)
Make a POST request and provide the status code, response body and
response headers.
|
Response |
put(Request request)
Make a PUT request and provide the status code, response body and
response headers.
|
public Client()
public Client(org.apache.http.impl.client.CloseableHttpClient httpClient)
httpClient - an Apache CloseableHttpClientpublic Client(java.lang.Boolean test)
test - is a Boolpublic java.net.URI buildUri(java.lang.String baseUri,
java.lang.String endpoint,
java.util.Map<java.lang.String,java.lang.String> queryParams)
throws java.net.URISyntaxException
baseUri - (e.g. "api.sendgrid.com")endpoint - (e.g. "/your/endpoint/path")queryParams - map of key, values representing the query parametersjava.net.URISyntaxExceptionpublic Response getResponse(org.apache.http.client.methods.CloseableHttpResponse response) throws java.io.IOException
response - from a call to a CloseableHttpClientjava.io.IOExceptionpublic Response get(Request request) throws java.net.URISyntaxException, java.io.IOException
java.net.URISyntaxExceptionjava.io.IOExceptionpublic Response post(Request request) throws java.net.URISyntaxException, java.io.IOException
java.net.URISyntaxExceptionjava.io.IOExceptionpublic Response patch(Request request) throws java.net.URISyntaxException, java.io.IOException
java.net.URISyntaxExceptionjava.io.IOExceptionpublic Response put(Request request) throws java.net.URISyntaxException, java.io.IOException
java.net.URISyntaxExceptionjava.io.IOExceptionpublic Response delete(Request request) throws java.net.URISyntaxException, java.io.IOException
java.net.URISyntaxExceptionjava.io.IOExceptionpublic Response api(Request request) throws java.io.IOException
java.io.IOExceptionpublic void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable