public class MessageBirdServiceImpl extends Object implements MessageBirdService
Created by rvt on 1/5/15.
| Constructor and Description |
|---|
MessageBirdServiceImpl(String accessKey)
Initiate service with default serviceUrl.
|
MessageBirdServiceImpl(String accessKey,
String serviceUrl) |
| Modifier and Type | Method and Description |
|---|---|
<R> R |
delete(String request,
Class<R> clazz)
Send DELETE request.
|
void |
deleteByID(String request,
String id)
Delete a object by ID.
|
String |
getAccessKey()
Get the used access key
|
String |
getBinaryData(String request,
String basePath,
String fileName)
Gets the data from the request URL and stores it to basePath/fileName
|
String |
getClientVersion()
Get the client version
|
<P> HttpURLConnection |
getConnection(String serviceUrl,
P body,
String requestType)
Create a HttpURLConnection connection object
|
<P> HttpURLConnection |
getConnection(String serviceUrl,
P body,
String requestType,
Map<String,String> headers)
Create a HttpURLConnection connection object
|
<T,P> T |
getJsonData(String request,
P payload,
String requestType,
Class<T> clazz) |
<T,P> T |
getJsonData(String request,
P payload,
String requestType,
Map<String,String> headers,
Class<T> clazz) |
<P,E> List<E> |
getJsonDataAsList(String request,
P payload,
String requestType,
Class<E> elementClass) |
<P,E> List<E> |
getJsonDataAsList(String request,
P payload,
String requestType,
Map<String,String> headers,
Class<E> elementClass) |
Proxy |
getProxy()
Get the proxy object if set
|
String |
getServiceUrl()
get the used service URL
|
String |
getUserAgentString()
Get the user agent string
|
<R> R |
request(String request,
Class<R> clazz)
Send GET request .
|
<R> R |
requestByID(String request,
String id,
Class<R> clazz)
Execute a object by ID request.
|
<R> R |
requestByID(String request,
String id,
Map<String,Object> params,
Class<R> clazz) |
<E> List<E> |
requestByIdAsList(String request,
String id,
Class<E> elementClass)
Execute a object by ID request.
|
<R> R |
requestList(String request,
Integer offset,
Integer limit,
Class<R> clazz)
Request a List 'of' object.
|
<R> R |
requestList(String request,
Map<String,Object> params,
Integer offset,
Integer limit,
Class<R> clazz)
Request a List 'of' object.
|
<R> R |
requestList(String request,
PagedPaging pagedPaging,
Class<R> clazz)
Request a List 'of' object.
|
<R,P> R |
sendPayLoad(String request,
P payload,
Class<R> clazz)
Send a payload with the POST method and receive a payload object.
|
<R,P> R |
sendPayLoad(String method,
String request,
Map<String,String> headers,
P payload,
Class<R> clazz)
Send a payload with the provided method and headers and receive a payload object.
|
<R,P> R |
sendPayLoad(String method,
String request,
P payload,
Class<R> clazz)
Send a payload with the provided method and receive a payload object.
|
void |
setProxy(Proxy proxy)
Enable proxy support
example:
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("10.0.0.1", 8080));
messageBirdService.setProxy(proxy);
|
public MessageBirdServiceImpl(String accessKey)
accessKey - developer access keypublic <R> R request(String request, Class<R> clazz) throws UnauthorizedException, GeneralException, NotFoundException
MessageBirdServicerequest in interface MessageBirdServicerequest - path to the request, for example "/messages/id/language"clazz - Class type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionNotFoundException - if id not foundpublic <R> R requestByID(String request, String id, Class<R> clazz) throws UnauthorizedException, GeneralException, NotFoundException
MessageBirdServicerequestByID in interface MessageBirdServicerequest - path to the request, for example "/messages"id - id of the object to request. id can be null in case request's that don't need a id, for example /balanceclazz - Class type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionNotFoundExceptionpublic <R> R requestByID(String request, String id, Map<String,Object> params, Class<R> clazz) throws UnauthorizedException, GeneralException, NotFoundException
requestByID in interface MessageBirdServiceUnauthorizedExceptionGeneralExceptionNotFoundExceptionpublic <E> List<E> requestByIdAsList(String request, String id, Class<E> elementClass) throws UnauthorizedException, GeneralException, NotFoundException
MessageBirdServicerequestByIdAsList in interface MessageBirdServicerequest - path to the request, for example "/messages"id - id of the object to request. id can be null in case request's that don't need a id, for example /balanceelementClass - Class type of List to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionNotFoundExceptionpublic void deleteByID(String request, String id) throws UnauthorizedException, GeneralException, NotFoundException
MessageBirdServicedeleteByID in interface MessageBirdServicerequest - path to the request, for example "/messages"id - id of the object to deleteUnauthorizedException - if client is unauthorizedGeneralException - general exceptionNotFoundException - if id not foundpublic <R> R delete(String request, Class<R> clazz) throws UnauthorizedException, GeneralException, NotFoundException
MessageBirdServicedelete in interface MessageBirdServicerequest - path to the request, for example "/messages/id/language"clazz - Class type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionNotFoundException - if id not foundpublic <R> R requestList(String request, Integer offset, Integer limit, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicerequestList in interface MessageBirdServicerequest - request from clientoffset - offset of data to returnlimit - limit number of objects, incase you notice you pass in '1' a lot, please consider using requestByID if you know the ID of the messageclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionMessageListpublic <R> R requestList(String request, Map<String,Object> params, Integer offset, Integer limit, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicerequestList in interface MessageBirdServicerequest - request from clientparams - additional query paramsoffset - offset of data to returnlimit - limit number of objects, incase you notice you pass in '1' a lot, please consider using requestByID if you know the ID of the messageclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionMessageListpublic <R> R requestList(String request, PagedPaging pagedPaging, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicerequestList in interface MessageBirdServicerequest - request from clientpagedPaging - includes page and page sizeclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionMessageListpublic <R,P> R sendPayLoad(String request, P payload, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicesendPayLoad in interface MessageBirdServicerequest - path to the request, for example "/messages"payload - payload to send to the serverclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionpublic <R,P> R sendPayLoad(String method, String request, P payload, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicesendPayLoad in interface MessageBirdServicemethod - HTTP method to use for the requestrequest - path to the request, for example "/messages"payload - payload to send to the serverclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionpublic <R,P> R sendPayLoad(String method, String request, Map<String,String> headers, P payload, Class<R> clazz) throws UnauthorizedException, GeneralException
MessageBirdServicesendPayLoad in interface MessageBirdServicemethod - HTTP method to use for the requestrequest - path to the request, for example "/messages"headers - additional headers to set on the requestpayload - payload to send to the serverclazz - object type to returnUnauthorizedException - if client is unauthorizedGeneralException - general exceptionpublic String getBinaryData(String request, String basePath, String fileName) throws GeneralException, UnauthorizedException, NotFoundException
MessageBirdServicegetBinaryData in interface MessageBirdServicerequest - path to the request, for example "/messages"basePath - base path for storing directoryfileName - the fileName that is going to be stored.GeneralException - general exceptionUnauthorizedException - if client is unauthorizedNotFoundException - if the file is not foundpublic <T,P> T getJsonData(String request, P payload, String requestType, Class<T> clazz) throws UnauthorizedException, GeneralException, NotFoundException
public <P,E> List<E> getJsonDataAsList(String request, P payload, String requestType, Class<E> elementClass) throws UnauthorizedException, GeneralException, NotFoundException
public <T,P> T getJsonData(String request, P payload, String requestType, Map<String,String> headers, Class<T> clazz) throws UnauthorizedException, GeneralException, NotFoundException
public <P,E> List<E> getJsonDataAsList(String request, P payload, String requestType, Map<String,String> headers, Class<E> elementClass) throws UnauthorizedException, GeneralException, NotFoundException
public <P> HttpURLConnection getConnection(String serviceUrl, P body, String requestType) throws IOException
serviceUrl - URL that needs to be requestedbody - body could not be empty for POST or PUT requestsrequestType - Request type POST requests without a payload will generate a exceptionIOException - io exceptionpublic <P> HttpURLConnection getConnection(String serviceUrl, P body, String requestType, Map<String,String> headers) throws IOException
serviceUrl - URL that needs to be requestedbody - body could not be empty for POST or PUT requestsrequestType - Request type POST requests without a payload will generate a exceptionheaders - additional headers to set on the requestIOException - io exceptionpublic String getAccessKey()
public String getServiceUrl()
public String getClientVersion()
public String getUserAgentString()
public void setProxy(Proxy proxy)
proxy - proxypublic Proxy getProxy()
Copyright © 2024. All rights reserved.