public interface TrelloHttpClient
Provides standard set of methods to perform GET, POST, PUT, DELETE method.
The implementation should not transparently rethrow any exception that comes with third-party HTTP client library.
Implementors can use wrapping exceptions like NotFoundException, NotAuthorizedException etc. If there
is no specific exception for particular case TrelloHttpException should be rethrown. It is very recommended
to embed native exception as cause, to provide more details about exception occurred.
The Trello API does support gzip response compression when user send the Accept-Encoding: gzip, so
implementor should at least consider (although many modern HTTP clients handles gzip
compression/decompression transparently) to send appropriate header and subsequently decompress bodies.
The most basic implementation is JDKTrelloHttpClient, it is default implementation for this interface and
does not require any additional dependencies.
| Modifier and Type | Method and Description |
|---|---|
<T> T |
delete(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.String... params)
Performs HTTP
DELETE request and converts response. |
<T> T |
get(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.String... params)
Performs HTTP
GET request and converts response. |
default <T> T |
postFileForObject(java.lang.String url,
java.io.File file,
java.lang.Class<T> responseType,
java.lang.String... params)
Performs HTTP
POST request and converts response. |
java.net.URI |
postForLocation(java.lang.String url,
java.lang.Object body,
java.lang.String... params)
Performs HTTP
POST request and returns the value of the Location header. |
<T> T |
postForObject(java.lang.String url,
java.lang.Object body,
java.lang.Class<T> responseType,
java.lang.String... params)
Performs HTTP
POST request and converts response. |
<T> T |
putForObject(java.lang.String url,
java.lang.Object body,
java.lang.Class<T> responseType,
java.lang.String... params)
Performs HTTP
PUT request and converts response. |
<T> T get(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.String... params)
GET request and converts response.
The template variables in url are expanded using the given params, if any.
T - The response object type.url - The URL to make request to.responseType - The response object class object.params - The URL query part or path parameters that should be expanded.<T> T postForObject(java.lang.String url,
java.lang.Object body,
java.lang.Class<T> responseType,
java.lang.String... params)
POST request and converts response.
The template variables in url are expanded using the given params, if any.
T - The response object type.url - The URL to make request to.body - The object to be converted to its JSON representation and POSTed. Use null to send request with empty body.responseType - The response object class object.params - The URL query part or path parameters that should be expanded.java.net.URI postForLocation(java.lang.String url,
java.lang.Object body,
java.lang.String... params)
POST request and returns the value of the Location header.
The template variables in url are expanded using the given params, if any.
url - The URL to make request to.body - The object to be converted to its JSON representation and POSTed. Use null
to send request with empty body.params - The URL query part or path parameters that should be expanded.POSTed resource location.<T> T putForObject(java.lang.String url,
java.lang.Object body,
java.lang.Class<T> responseType,
java.lang.String... params)
PUT request and converts response.
The template variables in url are expanded using the given params, if any.
T - The response object type.url - The URL to make request to.body - The object to be converted to its JSON representation and POSTed. Use null send request with empty body.responseType - The response object class object.params - The URL query part or path parameters that should be expanded.<T> T delete(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.String... params)
DELETE request and converts response.
The template variables in url are expanded using the given params, if any.
T - The response object type.url - The URL to make request to.responseType - The response object class object.params - The URL query part or path parameters that should be expanded.default <T> T postFileForObject(java.lang.String url,
java.io.File file,
java.lang.Class<T> responseType,
java.lang.String... params)
POST request and converts response. The file should be transmitted using multipart/form-data.
This is optional method.
The template variables in url are expanded using the given params, if any.
T - The response object type.url - The URL to make request to.file - The file to upload.responseType - The response object class object.params - The URL query part or path parameters that should be expanded.