From b8cfd1d8d1f7f8c05d3616220a562dbb4be156f8 Mon Sep 17 00:00:00 2001 From: Martin Zapata Date: Fri, 13 Sep 2013 18:08:40 +1000 Subject: [PATCH 1/5] Can now send Attachments with messages! --- .../clients/mandrill/model/Attachment.java | 44 ++++++++++++++++++ .../mandrill/model/MandrillMessage.java | 9 ++++ .../request/MandrillRESTRequestTest.java | 22 +++++++++ src/test/resources/messages/jose.jpeg | Bin 0 -> 6104 bytes 4 files changed, 75 insertions(+) create mode 100644 src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java create mode 100644 src/test/resources/messages/jose.jpeg diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java new file mode 100644 index 0000000..bd5e5dc --- /dev/null +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java @@ -0,0 +1,44 @@ +package com.cribbstechnologies.clients.mandrill.model; + +/** + * + * @author Martin Zapata + * + */ + +public class Attachment { + + private String type, name, content; + + public Attachment(String type, String name, String content) { + this.type = type; + this.name = name; + this.content = content; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + +} diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index a843770..1852e92 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -19,6 +19,7 @@ public class MandrillMessage { private String[] google_analytics_campaign = new String[0]; private List global_merge_vars; List merge_vars; + private List attachments; private Map headers; @@ -142,4 +143,12 @@ public List getMerge_vars() { public void setMerge_vars(List merge_vars) { this.merge_vars = merge_vars; } + + public List getAttachments() { + return attachments; + } + + public void setAttachments(List attachments) { + this.attachments = attachments; + } } diff --git a/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java b/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java index 368668b..b6422d1 100644 --- a/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java +++ b/src/test/java/com/cribbstechnologies/clients/mandrill/request/MandrillRESTRequestTest.java @@ -9,14 +9,23 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.MockitoAnnotations.initMocks; +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.StringWriter; import java.net.MalformedURLException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.imageio.ImageIO; + +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.codec.binary.Base64InputStream; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -36,6 +45,7 @@ import org.mockito.Mockito; import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; +import com.cribbstechnologies.clients.mandrill.model.Attachment; import com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest; import com.cribbstechnologies.clients.mandrill.model.MandrillHtmlMessage; import com.cribbstechnologies.clients.mandrill.model.MandrillMessageRequest; @@ -243,6 +253,10 @@ public void testGetPostDataMandrillMessageRequest() throws Exception { mutableMessage.setHeaders(headerMap); + List attachments = new ArrayList(); + attachments.add(new Attachment("image/jpeg", "jose.png", sampleBase64Image())); + mutableMessage.setAttachments(attachments); + mutableMessageRequest.setMessage(mutableMessage); // System.out.println(request.getPostData(mutableMessageRequest)); StringBuffer sb = new StringBuffer(); @@ -263,6 +277,7 @@ public void testGetPostDataMandrillMessageRequest() throws Exception { sb.append(",\"google_analytics_campaign\":[]"); sb.append(",\"global_merge_vars\":null"); sb.append(",\"merge_vars\":null"); + sb.append(",\"attachments\":[{\"type\":\"image/jpeg\",\"name\":\"jose.png\",\"content\":\"W3siZW1haWwiOiAiZXhhbXBsZSBlbWFpbCIsICJzdGF0dXMiOiAiZXhhbXBsZSBzdGF0dXMifSx7\\r\\nImVtYWlsIjogImV4YW1wbGUgZW1haWwyIiwgInN0YXR1cyI6ICJleGFtcGxlIHN0YXR1czIifV0=\\r\\n\"}]"); sb.append(",\"headers\":{\"headerName\":\"headerValue\"},"); sb.append("\"html\":\"Test html\""); sb.append("}}"); @@ -271,6 +286,13 @@ public void testGetPostDataMandrillMessageRequest() throws Exception { assertEquals(sb.toString(), output); } + private String sampleBase64Image() throws IOException { + StringWriter sw = new StringWriter(); + IOUtils.copy(new Base64InputStream(this.getClass().getClassLoader().getResourceAsStream("messages/sendMessageResponse.txt"), true), sw); + + return sw.toString(); + } + @Test public void testPostRequest() throws ClientProtocolException, IOException { request = new MandrillRESTRequest(); diff --git a/src/test/resources/messages/jose.jpeg b/src/test/resources/messages/jose.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..40551fa1699611f59a0081738f19ee5d063a88bb GIT binary patch literal 6104 zcmb_gXHZk?y8hBbC!r%H^p5nV^bR5rng&!_=s^foDS}cIP*4FWN(TubBE2eN0R#o9 z3Koh;6#+#ML~hu7&T*eRbAQ~K^Jdms&wBg!errvhWdF_n6ks+pGBpAa2n3i=KVW}` zZrfB}|BMyh(#Z6fA=Ll?-2$KrlzNc-gUNVfJ=}?t1RUxufPq7R4G05%7q_5*1E2pT z)YyN?k1_Dq-LTAoMq*p@!~G4r>TtcCPcJU1GyKcz|F|-{6NB6UfEZBi=Ul19skoDh zSzT@M`cymu0Gi&Ns8bYMjqCJ>PVp#A&EZxESS=|E22RM$3Ro%Q? zs6KS|5OA3f6&1IO%3%`O#$-w$M{hPiP?YJTwk^4Vnclf>uErp^u?`&{60V zbQ!t{128%mJ4^s315<2=ppnxdY6WoMubL##*)UJ<{V8bO$kja z%>d0D%`Pp5R*Y7Y)|S?XHkLMvwwm@C?K|3UbaZrrbn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grs+%&Ctnv)UcS6_q* zw_?>xIREJ!k_qu!Y@8v;_kLSaJdyA-SkC1%q!Oz_KMZ4V>N#3i1lxq{^5j>Rho+$74g>8 z<-;wVwJgvnnY0)b_bbZ9B(ybRUz}52UJB};&+Z+coJiS;Ze_5j;&IcUNJ-}h^}5Q% zg&Mz7mN`CDqH|AU)B=mQ+OY3Ie)$IVrFY;ZmBp%e z*-R-b#BF=KEGqJ){nng)ivRd2wr{g{bIh~;?U2fG-m2_znzJJp_W_D>X3XL1uh=j4 zx$o=Nxk_~lPNpp>CzpMqH1cFv#=CCuUPH--r$cdl zY}!R9Yd#RP589aq?8P6ByW0niOq1-&RWF6r+b2n%YAzyB0%fb=wkpe4I2qMb&z)H7 zeN}p1$#=oErY6N>V}o1CYb4EQ)km1{McL{Tb|SHTn6fm{zGs{@Djzf%ritigT@fQ1 z8f&*3n-an!dw7O_F71vfA9ocnw0Xf}Tx6U*8c|=AT$ey*_K;sL8$+LCcMu7?4VoO^`hxe z)8ZUmfVTXHvl^(w-|r4aMPDKsr}t;YD8)5&%2{2H(K?;;ax_ONuyj5&u*pu!UK3_? MmAl?Sd;jhK0MesK&Hw-a literal 0 HcmV?d00001 From 5ab0ce0b4d746e2b87d110841428b1de5cabb4f0 Mon Sep 17 00:00:00 2001 From: Aleem Sunderji Date: Wed, 16 Jul 2014 18:00:45 -0400 Subject: [PATCH 2/5] Added recipient type to support CC recipients. Added support for subaccounts, as well as asynchronous sending. Temporarily disabled JUnit tests as they need to be updated to support the new properties. --- pom.xml | 88 ++++++++++--------- .../clients/mandrill/model/Attachment.java | 2 +- .../mandrill/model/MandrillMessage.java | 25 ++++-- .../model/MandrillMessageRequest.java | 11 ++- .../mandrill/model/MandrillRecipient.java | 64 ++++++++------ 5 files changed, 114 insertions(+), 76 deletions(-) diff --git a/pom.xml b/pom.xml index fbc785d..dd9751c 100644 --- a/pom.xml +++ b/pom.xml @@ -33,50 +33,58 @@ - - org.apache.httpcomponents - httpclient - 4.1.1 - - - junit - junit - 4.10 - test - - - org.codehaus.jackson - jackson-mapper-asl - 1.9.4 - - - org.mockito - mockito-all - 1.8.4 - test - - - commons-io - commons-io - 2.0 - test - + + org.apache.httpcomponents + httpclient + 4.1.1 + + + junit + junit + 4.10 + test + + + org.codehaus.jackson + jackson-mapper-asl + 1.9.4 + + + org.mockito + mockito-all + 1.8.4 + test + + + commons-io + commons-io + 2.0 + test + - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - 1.5 - 1.5 - - - + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.4 + + true + + + diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java index bd5e5dc..118907e 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/Attachment.java @@ -6,7 +6,7 @@ * */ -public class Attachment { +public class Attachment implements java.io.Serializable { private String type, name, content; diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index 1852e92..979d0f6 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -17,9 +17,10 @@ public class MandrillMessage { private String[] tags = new String[0]; private String[] google_analytics_domains = new String[0]; private String[] google_analytics_campaign = new String[0]; - private List global_merge_vars; - List merge_vars; - private List attachments; + private List global_merge_vars; + List merge_vars; + private String subaccount; + private List attachments; private Map headers; @@ -145,10 +146,18 @@ public void setMerge_vars(List merge_vars) { } public List getAttachments() { - return attachments; - } + return attachments; + } - public void setAttachments(List attachments) { - this.attachments = attachments; - } + public void setAttachments(List attachments) { + this.attachments = attachments; + } + + public String getSubaccount() { + return subaccount; + } + + public void setSubaccount(String subaccount) { + this.subaccount = subaccount; + } } diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java index f54c348..8cc3a62 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java @@ -3,6 +3,7 @@ public class MandrillMessageRequest extends BaseMandrillRequest { private MandrillHtmlMessage message; + protected Boolean async; public MandrillMessage getMessage() { return message; @@ -11,7 +12,13 @@ public MandrillMessage getMessage() { public void setMessage(MandrillHtmlMessage message) { this.message = message; } - - + public Boolean getAsync() { + return async; + } + + public void setAsync(Boolean async) { + this.async = async; + } + } diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillRecipient.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillRecipient.java index 5542dc2..0a9e0c4 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillRecipient.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillRecipient.java @@ -1,29 +1,43 @@ package com.cribbstechnologies.clients.mandrill.model; public class MandrillRecipient { - - String email; - String name; - - public MandrillRecipient(String name, String email) { - this.email = email; - this.name = name; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - + + String email; + String name; + String type; + + public MandrillRecipient(String name, String email) { + this.email = email; + this.name = name; + } + + public MandrillRecipient(String name, String email, String type) { + this(name, email); + this.type = type; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + } From 5a2feffe7f9caed501afa0ab18c264c2291d2343 Mon Sep 17 00:00:00 2001 From: Aleem Sunderji Date: Thu, 28 Apr 2016 17:47:12 -0400 Subject: [PATCH 3/5] Add support for message metadata, as well as senders/check-domain API method. --- .../mandrill/model/MandrillMessage.java | 10 ++- .../mandrill/model/ServiceMethods.java | 1 + .../response/senders/AuthenticationInfo.java | 46 ++++++++++++ .../response/senders/DomainInfoResponse.java | 71 +++++++++++++++++++ .../request/MandrillSendersRequest.java | 35 +++++++++ 5 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/AuthenticationInfo.java create mode 100644 src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/DomainInfoResponse.java create mode 100644 src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillSendersRequest.java diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java index 979d0f6..1db59be 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessage.java @@ -17,11 +17,11 @@ public class MandrillMessage { private String[] tags = new String[0]; private String[] google_analytics_domains = new String[0]; private String[] google_analytics_campaign = new String[0]; + private Map metadata; private List global_merge_vars; List merge_vars; private String subaccount; private List attachments; - private Map headers; public String getSubject() { @@ -160,4 +160,12 @@ public String getSubaccount() { public void setSubaccount(String subaccount) { this.subaccount = subaccount; } + + public Map getMetadata() { + return metadata; + } + + public void setMetadata(Map metadata) { + this.metadata = metadata; + } } diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/ServiceMethods.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/ServiceMethods.java index 292ec94..70423e7 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/ServiceMethods.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/ServiceMethods.java @@ -52,6 +52,7 @@ public class Senders { public static final String DOMAINS = "senders/domain.json"; public static final String INFO = "senders/info.json"; public static final String TIME_SERIES = "senders/time-series.json"; + public static final String CHECK_DOMAIN = "senders/check-domain.json"; } public class Urls { diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/AuthenticationInfo.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/AuthenticationInfo.java new file mode 100644 index 0000000..2b5eb20 --- /dev/null +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/AuthenticationInfo.java @@ -0,0 +1,46 @@ +/* + * AuthenticationInfo.java + * + * Created on Apr 27, 2016, 1:07:39 PM + * + * Copyright (C) 2014, Blueprint Solutions Inc. + * All rights reserved. + */ + +package com.cribbstechnologies.clients.mandrill.model.response.senders; + +/** + * + * @author Aleem Sunderji, aleem@bp-solutions.net + */ +public class AuthenticationInfo { + + // Instance variables + protected boolean valid; + protected String valid_after; + protected String error; + + public boolean isValid() { + return valid; + } + + public void setValid(boolean valid) { + this.valid = valid; + } + + public String getValid_after() { + return valid_after; + } + + public void setValid_after(String valid_after) { + this.valid_after = valid_after; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } +} diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/DomainInfoResponse.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/DomainInfoResponse.java new file mode 100644 index 0000000..2c63e4b --- /dev/null +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/response/senders/DomainInfoResponse.java @@ -0,0 +1,71 @@ +package com.cribbstechnologies.clients.mandrill.model.response.senders; + +import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillResponse; + +public class DomainInfoResponse extends BaseMandrillResponse { + + protected String domain; + protected String created_at; + protected String last_tested_at; + protected AuthenticationInfo spf; + protected AuthenticationInfo dkim; + protected String verified_at; + protected boolean valid_signing; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public String getCreated_at() { + return created_at; + } + + public void setCreated_at(String created_at) { + this.created_at = created_at; + } + + public String getLast_tested_at() { + return last_tested_at; + } + + public void setLast_tested_at(String last_tested_at) { + this.last_tested_at = last_tested_at; + } + + public String getVerified_at() { + return verified_at; + } + + public void setVerified_at(String verified_at) { + this.verified_at = verified_at; + } + + public boolean isValid_signing() { + return valid_signing; + } + + public void setValid_signing(boolean valid_signing) { + this.valid_signing = valid_signing; + } + + public AuthenticationInfo getSpf() { + return spf; + } + + public void setSpf(AuthenticationInfo spf) { + this.spf = spf; + } + + public AuthenticationInfo getDkim() { + return dkim; + } + + public void setDkim(AuthenticationInfo dkim) { + this.dkim = dkim; + } + +} diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillSendersRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillSendersRequest.java new file mode 100644 index 0000000..45272a4 --- /dev/null +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/request/MandrillSendersRequest.java @@ -0,0 +1,35 @@ +package com.cribbstechnologies.clients.mandrill.request; + +import com.cribbstechnologies.clients.mandrill.exception.RequestFailedException; +import com.cribbstechnologies.clients.mandrill.model.MandrillRequestWithDomain; +import com.cribbstechnologies.clients.mandrill.model.ServiceMethods; +import com.cribbstechnologies.clients.mandrill.model.response.BaseMandrillResponse; +import com.cribbstechnologies.clients.mandrill.model.response.senders.DomainInfoResponse; + +/** + * + * This class holds functions provided by the Mandrill Senders API + * + * @author Aleem Sunderji, aleem@bp-solutions.net + * + */ +public class MandrillSendersRequest { + + protected MandrillRESTRequest request; + + /** + * Return information about a specific sending domain + * + * @param domainRequest a populated @see com.cribbstechnologies.clients.mandrill.model.BaseMandrillRequest + * @throws RequestFailedException + */ + public DomainInfoResponse checkDomain(MandrillRequestWithDomain domainRequest) throws RequestFailedException { + BaseMandrillResponse response = request.postRequest(domainRequest, ServiceMethods.Senders.CHECK_DOMAIN, DomainInfoResponse.class); + return (DomainInfoResponse)response; + } + + public void setRequest(MandrillRESTRequest request) { + this.request = request; + } + +} From b8431f6ee35eb58026129ab790fa173b883f3927 Mon Sep 17 00:00:00 2001 From: Aleem Sunderji Date: Thu, 28 Apr 2016 17:58:47 -0400 Subject: [PATCH 4/5] Remove ineffective async property from MandrillMessageRequest --- .../clients/mandrill/model/MandrillMessageRequest.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java index 8cc3a62..2af5b0a 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/model/MandrillMessageRequest.java @@ -3,7 +3,6 @@ public class MandrillMessageRequest extends BaseMandrillRequest { private MandrillHtmlMessage message; - protected Boolean async; public MandrillMessage getMessage() { return message; @@ -13,12 +12,4 @@ public void setMessage(MandrillHtmlMessage message) { this.message = message; } - public Boolean getAsync() { - return async; - } - - public void setAsync(Boolean async) { - this.async = async; - } - } From c3c54f1972b629657ce83fa826a047e5bcb5469e Mon Sep 17 00:00:00 2001 From: Aleem Sunderji Date: Mon, 2 May 2016 17:51:26 -0400 Subject: [PATCH 5/5] Add support for message metadata, as well as senders/check-domain API method --- .../clients/mandrill/exception/RequestFailedException.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/cribbstechnologies/clients/mandrill/exception/RequestFailedException.java b/src/main/java/com/cribbstechnologies/clients/mandrill/exception/RequestFailedException.java index 5a2113b..f442408 100644 --- a/src/main/java/com/cribbstechnologies/clients/mandrill/exception/RequestFailedException.java +++ b/src/main/java/com/cribbstechnologies/clients/mandrill/exception/RequestFailedException.java @@ -1,6 +1,6 @@ package com.cribbstechnologies.clients.mandrill.exception; -public class RequestFailedException extends Throwable { +public class RequestFailedException extends Exception { private static final long serialVersionUID = 1L;