Search in sources :

Example 1 with MessageResponse

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

the class MandrillRESTRequestTest method testSendMessageResponseConversion.

@Test
public void testSendMessageResponseConversion() throws IOException {
    this.initRequestWithActualMapper();
    StringWriter sw = new StringWriter();
    IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("messages/sendMessageResponse.txt"), sw);
    TypeReference responseListReference = new TypeReference<List<MessageResponse>>() {
    };
    BaseMandrillAnonymousListResponse<MessageResponse> response = (BaseMandrillAnonymousListResponse<MessageResponse>) this.request.convertAnonymousListResponseData(sw.toString(), SendMessageResponse.class, responseListReference);
    assertEquals(2, response.getList().size());
    MessageResponse resp = response.getList().get(0);
    assertEquals("example email", resp.getEmail());
    assertEquals("example status", resp.getStatus());
    resp = response.getList().get(1);
    assertEquals("example email2", resp.getEmail());
    assertEquals("example status2", resp.getStatus());
}
Also used : BaseMandrillAnonymousListResponse(com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) StringWriter(java.io.StringWriter) MessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse) SendMessageResponse(com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Test(org.junit.Test)

Example 2 with MessageResponse

use of com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse 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 3 with MessageResponse

use of com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse 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)

Aggregations

MessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.MessageResponse)3 SendMessageResponse (com.cribbstechnologies.clients.mandrill.model.response.message.SendMessageResponse)3 BaseMandrillAnonymousListResponse (com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillAnonymousListResponse)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 StringWriter (java.io.StringWriter)1 Test (org.junit.Test)1