Skip to content

Commit 4c4345c

Browse files
committed
Added getters and setters for CC and BCC in MessageBase interface.
1 parent 1789288 commit 4c4345c

File tree

4 files changed

+137
-59
lines changed

4 files changed

+137
-59
lines changed

injectionApi/build.gradle

Lines changed: 6 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ repositories {
3131
mavenCentral()
3232
}
3333

34+
compileJava {
35+
sourceCompatibility = '1.8'
36+
targetCompatibility = '1.8'
37+
}
38+
3439
dependencies {
3540
testCompile group: 'junit', name: 'junit', version: '4.12'
3641
compile 'com.fasterxml.jackson.core:jackson-core:2.9.5'
@@ -72,62 +77,4 @@ artifacts {
7277
archives packageJavadoc
7378
}
7479

75-
uploadArchives {
76-
repositories {
77-
mavenDeployer {
78-
79-
beforeDeployment {
80-
MavenDeployment deployment -> signing.signPom(deployment)
81-
}
82-
83-
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
84-
authentication(userName: sonatypeUsername, password: sonatypePassword)
85-
}
86-
87-
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
88-
authentication(userName: sonatypeUsername, password: sonatypePassword)
89-
}
90-
pom.project {
91-
92-
groupId "${baseGroupId}"
93-
artifactId "${baseArtifactId}"
94-
version "${version}"
95-
96-
name 'socketlabs-java'
97-
packaging 'jar'
98-
description 'SocketLabs Email Delivery Java library'
99-
url 'https://github.com/socketlabs/socketlabs-java/'
100-
101-
organization {
102-
name 'com.socketlabs'
103-
url 'https://github.com/socketlabs'
104-
}
105-
issueManagement {
106-
system 'GitHub'
107-
url 'https://github.com/socketlabs/socketlabs-java/issues'
108-
}
109-
licenses {
110-
license {
111-
name 'MIT License'
112-
url 'https://github.com/socketlabs/socketlabs-java/blob/master/LICENSE'
113-
}
114-
}
115-
scm {
116-
url 'https://github.com/socketlabs/socketlabs-java'
117-
connection 'scm:git:git://github.com/socketlabs/socketlabs-java.git'
118-
developerConnection 'scm:git:ssh://[email protected]:socketlabs/socketlabs-java.git'
119-
}
120-
developers {
121-
developer {
122-
id 'david-schrenker'
123-
name 'David Schrenker'
124-
}
125-
developer {
126-
id 'rbrazuk'
127-
name 'Ross Brazuk'
128-
}
129-
}
130-
}.writeTo("$projectDir/pom.xml")
131-
}
132-
}
133-
}
80+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.socketLabs.injectionApi;
2+
3+
import com.socketLabs.injectionApi.message.Attachment;
4+
import com.socketLabs.injectionApi.message.BasicMessage;
5+
import com.socketLabs.injectionApi.message.CustomHeader;
6+
import com.socketLabs.injectionApi.message.EmailAddress;
7+
8+
import java.io.File;
9+
import java.io.FileInputStream;
10+
import java.io.InputStream;
11+
import java.util.ArrayList;
12+
import java.util.List;
13+
14+
public class Main {
15+
public static void main(String[] args) throws Exception {
16+
SocketLabsClient client = new SocketLabsClient(17067, "r4W7SaJi38FyLp6k5NKs");
17+
18+
BasicMessage message = new BasicMessage();
19+
20+
message.setMessageId("ComplexExample");
21+
message.setMailingId("BasicSend");
22+
23+
message.setSubject("Sending A Complex Test Message (basic Send)");
24+
25+
message.setHtmlBody("<html><body><h1>Sending A Complex Test Message</h1><p>This is the html Body of my message.</p><h2>Embedded Image:</h2><p><img src=\"cid:bus\" /></p></body></html>");
26+
message.setPlainTextBody("This is the Plain Text Body of my message.");
27+
28+
message.setFrom(new EmailAddress("[email protected]"));
29+
message.setReplyTo(new EmailAddress("[email protected]"));
30+
31+
// Adding To Recipients
32+
// =========================
33+
// Add Email Addresses using an Array
34+
List<EmailAddress> toRecipients = new ArrayList<>();
35+
toRecipients.add(new EmailAddress("[email protected]"));
36+
toRecipients.add(new EmailAddress("[email protected]", "Recipient #2"));
37+
message.setTo(toRecipients);
38+
39+
// Add Email Addresses using new EmailAddress
40+
message.addToEmailAddress(new EmailAddress("[email protected]", "Recipient #3"));
41+
42+
// Add Email Addresses using the addToEmailAddress function
43+
message.addToEmailAddress("[email protected]");
44+
message.addToEmailAddress("[email protected]", "Recipient #5");
45+
46+
// Adding CC Recipients
47+
// =========================
48+
// Add Email Addresses using an Array
49+
List<EmailAddress> ccRecipients = new ArrayList<>();
50+
ccRecipients.add(new EmailAddress("[email protected]"));
51+
ccRecipients.add(new EmailAddress("[email protected]", "Recipient #2"));
52+
message.setCc(ccRecipients);
53+
54+
// Add Email Addresses using new EmailAddress
55+
message.addCcEmailAddress(new EmailAddress("[email protected]", "Recipient #3" ));
56+
57+
// Add Email Addresses using the addCcEmailAddress function
58+
message.addCcEmailAddress("[email protected]");
59+
message.addCcEmailAddress("[email protected]", "Recipient #5");
60+
61+
// Adding Bcc Recipients
62+
// =========================
63+
// Add Email Addresses using an Array
64+
List<EmailAddress> bccRecipients = new ArrayList<>();
65+
bccRecipients.add(new EmailAddress("[email protected]"));
66+
bccRecipients.add(new EmailAddress("[email protected]", "Recipient #2"));
67+
message.setBcc(bccRecipients);
68+
69+
// Add Email Addresses using new EmailAddress
70+
message.addBccEmailAddress(new EmailAddress( "[email protected]", "Recipient #3" ));
71+
72+
// Add Email Addresses using the addBccEmailAddress function
73+
message.addBccEmailAddress("[email protected]");
74+
message.addBccEmailAddress("[email protected]", "Recipient #5");
75+
76+
77+
78+
// Adding Custom Headers
79+
// =========================
80+
// Add Custom Headers using an Array
81+
List<CustomHeader> headers = new ArrayList<>();
82+
headers.add(new CustomHeader("example-type", "basic-send-complex"));
83+
headers.add(new CustomHeader("message-contains", "attachments, headers"));
84+
message.setCustomHeaders(headers);
85+
86+
// Add Custom Headers directly to the Array
87+
message.addCustomHeader(new CustomHeader("message-has-attachments", "true"));
88+
89+
// Add Custom Headers using the addCustomHeaders function
90+
message.addCustomHeader("testMessageHeader", "I am a message header");
91+
92+
System.out.println(message.toString());
93+
94+
// send the message
95+
SendResponse response = client.send(message);
96+
97+
98+
99+
}
100+
}

injectionApi/src/main/java/com/socketLabs/injectionApi/core/serialization/InjectionRequestFactory.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.socketLabs.injectionApi.core.serialization;
22

33
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.core.JsonProcessingException;
45
import com.fasterxml.jackson.databind.ObjectMapper;
56
import com.socketLabs.injectionApi.message.*;
67

@@ -136,13 +137,19 @@ private MessageJson generateBaseMessage(MessageBase messageBase) {
136137
messageJson.setMessageId(messageBase.getMessageId());
137138
messageJson.setCharSet(messageBase.getCharSet());
138139
messageJson.setFrom(new AddressJson(messageBase.getFrom().getEmailAddress(), messageBase.getFrom().getFriendlyName()));
140+
// todo: set cc and bcc here
139141
messageJson.setCustomHeaders(populateCustomHeaders(messageBase.getCustomHeaders()));
140142
messageJson.setAttachments(populateAttachments(messageBase.getAttachments()));
141143

142144
if (messageBase.getApiTemplate() != null) {
143145
messageJson.setApiTemplate(String.valueOf(messageBase.getApiTemplate()));
144146
}
145147

148+
try {
149+
System.out.println(mapper.writeValueAsString(messageJson));
150+
} catch (JsonProcessingException e) {
151+
e.printStackTrace();
152+
}
146153
return messageJson;
147154
}
148155

injectionApi/src/main/java/com/socketLabs/injectionApi/message/MessageBase.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,30 @@ public interface MessageBase {
8585
*/
8686
void setFrom(EmailAddress value);
8787

88+
/**
89+
* Get the list of CC addresses.
90+
* @return {@code List<EmailAddress>}
91+
*/
92+
List<EmailAddress> getCc();
93+
94+
/**
95+
* Set the list of CC addresses.
96+
* @param value {@code List<EmailAddress>}
97+
*/
98+
void setCc(List<EmailAddress> value);
99+
100+
/**
101+
* Get the list of BCC addresses.
102+
* @return {@code List<EmailAddress>}
103+
*/
104+
List<EmailAddress> getBcc();
105+
106+
/**
107+
* Set the list of BCC addresses.
108+
* @param value {@code List<EmailAddress>}
109+
*/
110+
void setBcc(List<EmailAddress> value);
111+
88112
/**
89113
* Get the optional ReplyTo address for the message.
90114
* @return EmailAddress

0 commit comments

Comments
 (0)