Skip to content

Commit 99aed08

Browse files
committed
Added bcc and cc to basic message. Added replyTo to generateBaseMessage method
1 parent 4c4345c commit 99aed08

File tree

3 files changed

+8
-33
lines changed

3 files changed

+8
-33
lines changed

injectionApi/src/main/java/com/socketLabs/injectionApi/Main.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static void main(String[] args) throws Exception {
3232
// =========================
3333
// Add Email Addresses using an Array
3434
List<EmailAddress> toRecipients = new ArrayList<>();
35-
toRecipients.add(new EmailAddress("recipient1@example.com"));
35+
toRecipients.add(new EmailAddress("ross.brazuk@socketlabs.com"));
3636
toRecipients.add(new EmailAddress("[email protected]", "Recipient #2"));
3737
message.setTo(toRecipients);
3838

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,14 @@ public String GenerateRequest(BasicMessage basicMessage) throws IOException {
105105

106106
MessageJson messageJson = generateBaseMessage(basicMessage);
107107

108-
messageJson.setTo(populateTo(basicMessage.getTo()));
108+
messageJson.setTo(populateEmailList(basicMessage.getTo()));
109109

110110
messageJsonList.add(messageJson);
111111

112+
messageJson.setCc(populateEmailList(basicMessage.getCc()));
113+
114+
messageJson.setBcc(populateEmailList(basicMessage.getBcc()));
115+
112116
return GetAsJson(new InjectionRequest(this.serverId, this.apiKey, messageJsonList));
113117
}
114118

@@ -133,23 +137,18 @@ private MessageJson generateBaseMessage(MessageBase messageBase) {
133137
messageJson.setSubject(messageBase.getSubject());
134138
messageJson.setPlainTextBody(messageBase.getPlainTextBody());
135139
messageJson.setHtmlBody(messageBase.getHtmlBody());
140+
messageJson.setReplyTo(new AddressJson(messageBase.getReplyTo().getEmailAddress(), messageBase.getReplyTo().getFriendlyName()));
136141
messageJson.setMailingId(messageBase.getMailingId());
137142
messageJson.setMessageId(messageBase.getMessageId());
138143
messageJson.setCharSet(messageBase.getCharSet());
139144
messageJson.setFrom(new AddressJson(messageBase.getFrom().getEmailAddress(), messageBase.getFrom().getFriendlyName()));
140-
// todo: set cc and bcc here
141145
messageJson.setCustomHeaders(populateCustomHeaders(messageBase.getCustomHeaders()));
142146
messageJson.setAttachments(populateAttachments(messageBase.getAttachments()));
143147

144148
if (messageBase.getApiTemplate() != null) {
145149
messageJson.setApiTemplate(String.valueOf(messageBase.getApiTemplate()));
146150
}
147151

148-
try {
149-
System.out.println(mapper.writeValueAsString(messageJson));
150-
} catch (JsonProcessingException e) {
151-
e.printStackTrace();
152-
}
153152
return messageJson;
154153
}
155154

@@ -199,7 +198,7 @@ private List<AttachmentJson> populateAttachments(List<Attachment> baseAttachment
199198
* @param baseTo List of EmailAddress objects
200199
* @return List<AddressJson>
201200
*/
202-
private List<AddressJson> populateTo(List<EmailAddress> baseTo) {
201+
private List<AddressJson> populateEmailList(List<EmailAddress> baseTo) {
203202
if (baseTo == null) {
204203
return null;
205204
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,30 +85,6 @@ 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-
11288
/**
11389
* Get the optional ReplyTo address for the message.
11490
* @return EmailAddress

0 commit comments

Comments
 (0)