Skip to content

Commit 31a92f8

Browse files
author
Chris Wilson
committed
Releases SparkPost lib 0.23
1 parent aef38c6 commit 31a92f8

24 files changed

+239
-202
lines changed

apps/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>com.sparkpost</groupId>
55
<artifactId>sparkpost</artifactId>
6-
<version>0.22</version>
6+
<version>0.23</version>
77
</parent>
88
<modelVersion>4.0.0</modelVersion>
99
<artifactId>apps</artifactId>

apps/sparkpost-documentor-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.sparkpost</groupId>
66
<artifactId>apps</artifactId>
7-
<version>0.22</version>
7+
<version>0.23</version>
88
</parent>
99
<artifactId>sparkpost-documentor-app</artifactId>
1010
<name>Generates Markdown of Protocol</name>

apps/sparkpost-javamail-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.sparkpost</groupId>
88
<artifactId>apps</artifactId>
9-
<version>0.22</version>
9+
<version>0.23</version>
1010
</parent>
1111
<groupId>com.sparkpost.sample</groupId>
1212
<artifactId>sparkpost-javamail-app</artifactId>

apps/sparkpost-samples-app/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.sparkpost</groupId>
66
<artifactId>apps</artifactId>
7-
<version>0.22</version>
7+
<version>0.23</version>
88
</parent>
99
<artifactId>sparkpost-samples-app</artifactId>
1010
<name>Example use SparkPost library</name>

apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples/MandrillBlacklistImport.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ private void runApp() throws SparkPostException, IOException {
109109
entry.setDescription("MBL: " + line);
110110
entry.setEmail(entryRow[Fields.EMAIL_COL]);
111111
// Assumes Mandrill blacklist is only for non-transactional email
112-
entry.setTransactional(false);
113-
entry.setNonTransactional(true);
112+
entry.setType(SuppressionListEntry.TypeTypes.TRANSACTIONAL_TYPE);
114113

115114
// Leave off source so it is set to "Manually Added"
116115
// entry.setSource(null);

apps/sparkpost-samples-app/src/main/java/com/sparkpost/samples/MessageEventSearchSample.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ private void doSearch() throws SparkPostException, IOException, InterruptedExcep
4444

4545
// Message events can be filtered with the Message Event Query Builder
4646
MessageEventsQueryBuilder query = null;
47-
//query = new MessageEventsQueryBuilder();
47+
query = new MessageEventsQueryBuilder();
48+
49+
// Query by date range
50+
//query.setFromDateTime("2020-09-27T00:00");
51+
//query.setToDateTime("2020-10-01T00:00");
52+
53+
// Query by Message Id
4854
//query.addMessageId("Message ID Here");
4955

5056
response = ResourceMessageEvents.searchMessageEvents(connection, 10, query);
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
package com.sparkpost.samples;
3+
4+
import java.io.IOException;
5+
import java.util.ArrayList;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
10+
import org.apache.log4j.Level;
11+
import org.apache.log4j.Logger;
12+
13+
import com.sparkpost.Client;
14+
import com.sparkpost.exception.SparkPostException;
15+
import com.sparkpost.model.AddressAttributes;
16+
import com.sparkpost.model.RecipientAttributes;
17+
import com.sparkpost.model.TemplateContentAttributes;
18+
import com.sparkpost.model.TransmissionWithRecipientArray;
19+
import com.sparkpost.model.responses.Response;
20+
import com.sparkpost.resources.ResourceTransmissions;
21+
import com.sparkpost.sdk.samples.helpers.SparkPostBaseApp;
22+
import com.sparkpost.transport.IRestConnection;
23+
import com.sparkpost.transport.RestConnection;
24+
25+
public class SendAmpEmailSample extends SparkPostBaseApp {
26+
27+
static final Logger logger = Logger.getLogger(CreateTemplateSimple.class);
28+
29+
private Client client;
30+
31+
public static void main(String[] args) throws SparkPostException, IOException {
32+
Logger.getRootLogger().setLevel(Level.DEBUG);
33+
34+
SendAmpEmailSample sample = new SendAmpEmailSample();
35+
sample.runApp();
36+
}
37+
38+
private void runApp() throws SparkPostException, IOException {
39+
this.client = this.newConfiguredClient();
40+
41+
// Loads an email to send from the file system
42+
String fromAddress = getFromAddress();
43+
String[] recipients = getTestRecipients();
44+
45+
sendEmail(fromAddress, recipients);
46+
47+
}
48+
49+
private void sendEmail(String from, String[] recipients) throws SparkPostException {
50+
TransmissionWithRecipientArray transmission = new TransmissionWithRecipientArray();
51+
52+
// Populate Recipients
53+
List<RecipientAttributes> recipientArray = new ArrayList<RecipientAttributes>();
54+
for (String recipient : recipients) {
55+
RecipientAttributes recipientAttribs = new RecipientAttributes();
56+
recipientAttribs.setAddress(new AddressAttributes(recipient));
57+
recipientArray.add(recipientAttribs);
58+
}
59+
transmission.setRecipientArray(recipientArray);
60+
61+
// Populate Substitution Data
62+
Map<String, Object> substitutionData = new HashMap<String, Object>();
63+
substitutionData.put("yourContent", "You can add substitution data too.");
64+
transmission.setSubstitutionData(substitutionData);
65+
66+
// Populate Email Body
67+
TemplateContentAttributes contentAttributes = new TemplateContentAttributes();
68+
contentAttributes.setFrom(new AddressAttributes(from));
69+
contentAttributes.setSubject("☰ Your subject content here. {{yourContent}}");
70+
contentAttributes.setText("Your Text content here. {{yourContent}}");
71+
contentAttributes.setHtml("<p>Your <b>HTML</b> content here. {{yourContent}}</p>");
72+
contentAttributes.setAmpHtml("<p>Your <b>AMP HTML</b> content here. {{yourContent}}</p>");
73+
transmission.setContentAttributes(contentAttributes);
74+
75+
transmission.setContentAttributes(contentAttributes);
76+
77+
// Send the Email
78+
IRestConnection connection = new RestConnection(this.client, getEndPoint());
79+
Response response = ResourceTransmissions.create(connection, 0, transmission);
80+
81+
logger.debug("Transmission Response: " + response);
82+
}
83+
84+
}

libs/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.sparkpost</groupId>
66
<artifactId>sparkpost</artifactId>
7-
<version>0.22</version>
7+
<version>0.23</version>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
1010
<artifactId>libs</artifactId>

libs/sparkpost-lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.sparkpost</groupId>
66
<artifactId>libs</artifactId>
7-
<version>0.22</version>
7+
<version>0.23</version>
88
</parent>
99
<!-- <version>0.10</version> -->
1010
<artifactId>sparkpost-lib</artifactId>

libs/sparkpost-lib/src/main/java/com/sparkpost/Build.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
public class Build {
55

6-
public static final String VERSION = "BUILD_VERSION_NAME";
6+
public static final String VERSION = "0.23";
77

8-
public static final String BUILD_VERSION = "BUILD_GENERATED_VERSION";
8+
public static final String BUILD_VERSION = "230";
99

10-
public static final String GIT_HASH = "BUILD_GENERATED_GIT_HASH";
10+
public static final String GIT_HASH = "aef38c687cd621e3e313c9a3be7d03c3806ce342";
1111

12-
public static final String GIT_SHORT_HASH = "BUILD_GENERATED_SHORT_GIT_HASH";
12+
public static final String GIT_SHORT_HASH = "aef38c6";
1313

14-
public static final String BUILD_DATE = "BUILD_GENERATED_DATE";
14+
public static final String BUILD_DATE = "Fri Oct 23 14:52:00 CDT 2020";
1515

1616
}

0 commit comments

Comments
 (0)