Search in sources :

Example 1 with SendMessageResponse

use of com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse in project Java-Mandrill-Wrapper by cribbstechnologies.

the class MandrillMessagesRequest method sendMessage.

/**
     * 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<MessageResponse>) request.postRequest(messageRequest, ServiceMethods.Messages.SEND, SendMessageResponse.class, messageResponseListReference)).getList());
    return response;
}
Also used : SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) MessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse)

Example 2 with SendMessageResponse

use of com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse in project Java-Mandrill-Wrapper by cribbstechnologies.

the class MandrillMessagesRequest method sendTemplatedMessage.

public SendMessageResponse sendTemplatedMessage(MandrillTemplatedMessageRequest templateMessage) throws RequestFailedException {
    SendMessageResponse response = new SendMessageResponse();
    response.setList(((BaseMandrillAnonymousListResponse<MessageResponse>) request.postRequest(templateMessage, ServiceMethods.Messages.SEND_TEMPLATE, SendMessageResponse.class, messageResponseListReference)).getList());
    return response;
}
Also used : SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) MessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse)

Example 3 with SendMessageResponse

use of com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse in project Java-Mandrill-Wrapper by cribbstechnologies.

the class MessagesTest method testSendMessage.

@Test
public void testSendMessage() {
    MandrillMessageRequest mmr = new MandrillMessageRequest();
    MandrillHtmlMessage message = new MandrillHtmlMessage();
    Map<String, String> headers = new HashMap<String, String>();
    message.setFrom_email(props.getProperty("email.from"));
    message.setFrom_name("Big Jimmy");
    message.setHeaders(headers);
    message.setHtml("<html><body><h1>Oh snap!</h1>Guess what I saw?<a href=\"http://www.google.com\">google</a></body></html>");
    message.setSubject("This is the subject");
    MandrillRecipient[] recipients = new MandrillRecipient[] { new MandrillRecipient(props.getProperty("email.to.name1"), props.getProperty("email.to.address1")), new MandrillRecipient(props.getProperty("email.to.name2"), props.getProperty("email.to.address2")) };
    message.setTo(recipients);
    message.setTrack_clicks(true);
    message.setTrack_opens(true);
    String[] tags = new String[] { "tag1", "tag2", "tag3" };
    message.setTags(tags);
    mmr.setMessage(message);
    try {
        SendMessageResponse response = messagesRequest.sendMessage(mmr);
    } catch (RequestFailedException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) HashMap(java.util.HashMap) RequestFailedException(com.cribbstechnologies.clients.mandrill.exception.RequestFailedException) MandrillMessageRequest(com.cribbstechnologies.clients.mandrill.model.MandrillMessageRequest) MandrillHtmlMessage(com.cribbstechnologies.clients.mandrill.model.MandrillHtmlMessage) MandrillRecipient(com.cribbstechnologies.clients.mandrill.model.MandrillRecipient) Test(org.junit.Test)

Aggregations

SendMessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse)3 MessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse)2 RequestFailedException (com.cribbstechnologies.clients.mandrill.exception.RequestFailedException)1 MandrillHtmlMessage (com.cribbstechnologies.clients.mandrill.model.MandrillHtmlMessage)1 MandrillMessageRequest (com.cribbstechnologies.clients.mandrill.model.MandrillMessageRequest)1 MandrillRecipient (com.cribbstechnologies.clients.mandrill.model.MandrillRecipient)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1