com.cribbstechnologies.clients.mandrill.request.MandrillMessagesRequest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mandrillClient Show documentation
Show all versions of mandrillClient Show documentation
A Java wrapper for Mandrill
package com.cribbstechnologies.clients.mandrill.request;
import java.util.List;
import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException;
import com.cribbstechnologies.clients.mandrill.model.MandrillMessageRequest;
import com.cribbstechnologies.clients.mandrill.model.MandrillTemplatedMessageRequest;
import com.cribbstechnologies.clients.mandrill.model.ServiceMethods;
import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse;
import com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse;
import com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse;
import com.fasterxml.jackson.core.type.TypeReference;
/**
* This class holds various functions for the Mandrill Messages API
*
* @author Brian Cribbs
*
*/
public class MandrillMessagesRequest {
MandrillRESTRequest request;
TypeReference> messageResponseListReference = new TypeReference>() {
};
/**
* Send a new transactional message through Mandrill
*
* @param messageRequest
* a populated @see com.cribstechnologies.clients.mandrill.model.MandrillMessageRequest
* @throws RequestFailedException
*/
public SendMessageResponse sendMessage(MandrillMessageRequest messageRequest) throws RequestFailedException {
SendMessageResponse response = new SendMessageResponse();
response.setList(((BaseMandrillAnonymousListResponse) request.postRequest(messageRequest, ServiceMethods.Messages.SEND, SendMessageResponse.class,
messageResponseListReference)).getList());
return response;
}
public SendMessageResponse sendTemplatedMessage(MandrillTemplatedMessageRequest templateMessage) throws RequestFailedException {
SendMessageResponse response = new SendMessageResponse();
response.setList(((BaseMandrillAnonymousListResponse) request.postRequest(templateMessage, ServiceMethods.Messages.SEND_TEMPLATE,
SendMessageResponse.class, messageResponseListReference)).getList());
return response;
}
public void setRequest(MandrillRESTRequest request) {
this.request = request;
}
}