Package com.mailersend.sdk
Class MailerSendApi
- java.lang.Object
-
- com.mailersend.sdk.MailerSendApi
-
public class MailerSendApi extends Object
Handles all requests to the MailerSend API- Version:
- $Id: $Id
- Author:
- john
-
-
Constructor Summary
Constructors Constructor Description MailerSendApi()Constructor, initializes the HttpClient
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends MailerSendResponse>
TdeleteRequest(String endpoint, Class<T> responseClass)Does a DELETE request to the given endpoint of the MailerSend API<T extends MailerSendResponse>
TdeleteRequest(String endpoint, String requestBody, Class<T> responseClass)Does a DELETE request to the given endpoint of the MailerSend API<T extends MailerSendResponse>
TgetRequest(String endpoint, Class<T> responseClass)Does a GET request to the given endpoint of the MailerSend API<T extends MailerSendResponse>
TpostRequest(String endpoint, String requestBody, Class<T> responseClass)Does a POST request to the given endpoint of the MailerSend API<T extends MailerSendResponse>
TputRequest(String endpoint, String requestBody, Class<T> responseClass)Does a PUT request to the given endpoint of the MailerSend APIvoidsetToken(String token)Sets the MailerSend API token
-
-
-
Method Detail
-
setToken
public void setToken(String token)
Sets the MailerSend API token- Parameters:
token- the MailerSend API token
-
getRequest
public <T extends MailerSendResponse> T getRequest(String endpoint, Class<T> responseClass) throws MailerSendException
Does a GET request to the given endpoint of the MailerSend API- Parameters:
endpoint- The MailerSend API endpointresponseClass- The class of the response object- Returns:
- T
- Throws:
MailerSendException- if an error is returned from the API this exception will contain the details
-
postRequest
public <T extends MailerSendResponse> T postRequest(String endpoint, String requestBody, Class<T> responseClass) throws MailerSendException
Does a POST request to the given endpoint of the MailerSend API- Parameters:
endpoint- The MailerSend API endpointrequestBody- The body of the POST requestresponseClass- The class of the response object- Returns:
- T
- Throws:
MailerSendException- if an error is returned from the API this exception will contain the details
-
deleteRequest
public <T extends MailerSendResponse> T deleteRequest(String endpoint, Class<T> responseClass) throws MailerSendException
Does a DELETE request to the given endpoint of the MailerSend API- Parameters:
endpoint- The MailerSend API endpointresponseClass- The class of the response object- Returns:
- T
- Throws:
MailerSendException- if an error is returned from the API this exception will contain the details
-
deleteRequest
public <T extends MailerSendResponse> T deleteRequest(String endpoint, String requestBody, Class<T> responseClass) throws MailerSendException
Does a DELETE request to the given endpoint of the MailerSend API- Parameters:
endpoint- The MailerSend API endpointrequestBody- The body of the DELETE requestresponseClass- The class of the response object- Returns:
- T
- Throws:
MailerSendException- if an error is returned from the API this exception will contain the details
-
putRequest
public <T extends MailerSendResponse> T putRequest(String endpoint, String requestBody, Class<T> responseClass) throws MailerSendException
Does a PUT request to the given endpoint of the MailerSend API- Parameters:
endpoint- The MailerSend API endpointrequestBody- The body of the PUT requestresponseClass- The class of the response object- Returns:
- T
- Throws:
MailerSendException- if an error is returned from the API this exception will contain the details
-
-