Skip to content

Commit 7a58fcd

Browse files
authored
fix: Add missing bypass settings to MailSettings (#707)
* Add missing bypass settings to MailSettings
1 parent a2c71ef commit 7a58fcd

3 files changed

Lines changed: 109 additions & 1 deletion

File tree

examples/helpers/mail/Example.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,17 @@ public static Mail buildKitchenSink() {
149149
Setting bypassListManagement = new Setting();
150150
bypassListManagement.setEnable(true);
151151
mailSettings.setBypassListManagement(bypassListManagement);
152+
// Note: Bypass Spam, Bounce, and Unsubscribe management cannot
153+
// be combined with Bypass List Management
154+
Setting bypassSpamManagement = new Setting();
155+
bypassSpamManagement.setEnable(true);
156+
mailSettings.setBypassSpamManagement(bypassSpamManagement);
157+
Setting bypassBounceManagement = new Setting();
158+
bypassBounceManagement.setEnable(true);
159+
mailSettings.setBypassBounceManagement(bypassBounceManagement);
160+
Setting bypassUnsubscribeManagement = new Setting();
161+
bypassUnsubscribeManagement.setEnable(true);
162+
mailSettings.setBypassUnsubscribeManagement(bypassUnsubscribeManagement);
152163
FooterSetting footerSetting = new FooterSetting();
153164
footerSetting.setEnable(true);
154165
footerSetting.setText("Footer Text");

src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public class MailSettings {
1818
@JsonProperty("bypass_list_management")
1919
private Setting bypassListManagement;
2020

21+
@JsonProperty("bypass_spam_management")
22+
private Setting bypassSpamManagement;
23+
24+
@JsonProperty("bypass_bounce_management")
25+
private Setting bypassBounceManagement;
26+
27+
@JsonProperty("bypass_unsubscribe_management")
28+
private Setting bypassUnsubscribeManagement;
29+
2130
@JsonProperty("footer")
2231
private FooterSetting footerSetting;
2332

@@ -58,6 +67,58 @@ public void setBypassListManagement(Setting bypassListManagement) {
5867
this.bypassListManagement = bypassListManagement;
5968
}
6069

70+
/**
71+
* Allows you to bypass the spam report list to ensure that the email is delivered to recipients.
72+
* Bounce and unsubscribe lists will still be checked; addresses on these other lists will not
73+
* receive the message.
74+
*
75+
* This filter cannot be combined with the bypass_list_management filter.
76+
* @return the bypass spam setting
77+
*/
78+
79+
@JsonProperty("bypass_spam_management")
80+
public Setting getBypassSpamManagement() {
81+
return bypassSpamManagement;
82+
}
83+
84+
public void setBypassSpamManagement(Setting bypassSpamManagement) {
85+
this.bypassSpamManagement = bypassSpamManagement;
86+
}
87+
88+
/**
89+
* Allows you to bypass the bounce list to ensure that the email is delivered to recipients.
90+
* Spam report and unsubscribe lists will still be checked; addresses on these other lists
91+
* will not receive the message.
92+
*
93+
* This filter cannot be combined with the bypass_list_management filter.
94+
* @return the bypass bounce setting
95+
*/
96+
@JsonProperty("bypass_bounce_management")
97+
public Setting getBypassBounceManagement() {
98+
return bypassBounceManagement;
99+
}
100+
public void setBypassBounceManagement(Setting bypassBounceManagement) {
101+
this.bypassBounceManagement = bypassBounceManagement;
102+
}
103+
104+
/**
105+
* Allows you to bypass the global unsubscribe list to ensure that the email is delivered
106+
* to recipients. Bounce and spam report lists will still be checked; addresses on these
107+
* other lists will not receive the message. This filter applies only to global unsubscribes
108+
* and will not bypass group unsubscribes.
109+
*
110+
* This filter cannot be combined with the bypass_list_management filter.
111+
* @return the bypass unsubscribe setting
112+
*/
113+
@JsonProperty("bypass_unsubscribe_management")
114+
public Setting getBypassUnsubscribeManagement() {
115+
return bypassUnsubscribeManagement;
116+
}
117+
118+
public void setBypassUnsubscribeManagement(Setting bypassUnsubscribeManagement) {
119+
this.bypassUnsubscribeManagement = bypassUnsubscribeManagement;
120+
}
121+
61122
/**
62123
* Get the footer settings that you would like included on every email.
63124
*
@@ -128,6 +189,12 @@ public int hashCode() {
128189
result = prime * result + ((bccSettings == null) ? 0 : bccSettings.hashCode());
129190
result =
130191
prime * result + ((bypassListManagement == null) ? 0 : bypassListManagement.hashCode());
192+
result =
193+
prime * result + ((bypassSpamManagement == null) ? 0 : bypassSpamManagement.hashCode());
194+
result =
195+
prime * result + ((bypassBounceManagement == null) ? 0 : bypassBounceManagement.hashCode());
196+
result =
197+
prime * result + ((bypassUnsubscribeManagement == null) ? 0 : bypassUnsubscribeManagement.hashCode());
131198
result = prime * result + ((footerSetting == null) ? 0 : footerSetting.hashCode());
132199
result = prime * result + ((sandBoxMode == null) ? 0 : sandBoxMode.hashCode());
133200
result = prime * result + ((spamCheckSetting == null) ? 0 : spamCheckSetting.hashCode());
@@ -160,6 +227,27 @@ public boolean equals(Object obj) {
160227
} else if (!bypassListManagement.equals(other.bypassListManagement)) {
161228
return false;
162229
}
230+
if (bypassSpamManagement == null) {
231+
if (other.bypassSpamManagement != null) {
232+
return false;
233+
}
234+
} else if (!bypassSpamManagement.equals(other.bypassSpamManagement)) {
235+
return false;
236+
}
237+
if (bypassBounceManagement == null) {
238+
if (other.bypassBounceManagement != null) {
239+
return false;
240+
}
241+
} else if (!bypassBounceManagement.equals(other.bypassBounceManagement)) {
242+
return false;
243+
}
244+
if (bypassUnsubscribeManagement == null) {
245+
if (other.bypassUnsubscribeManagement != null) {
246+
return false;
247+
}
248+
} else if (!bypassUnsubscribeManagement.equals(other.bypassUnsubscribeManagement)) {
249+
return false;
250+
}
163251
if (footerSetting == null) {
164252
if (other.footerSetting != null) {
165253
return false;

src/test/java/com/sendgrid/helpers/MailTest.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,16 @@ public void testKitchenSink() throws IOException {
212212
mailSettings.setSandboxMode(sandBoxMode);
213213
Setting bypassListManagement = new Setting();
214214
bypassListManagement.setEnable(true);
215+
Setting bypassSpamManagement = new Setting();
216+
bypassSpamManagement.setEnable(true);
217+
Setting bypassBounceManagement = new Setting();
218+
bypassBounceManagement.setEnable(true);
219+
Setting bypassUnsubscribeManagement = new Setting();
220+
bypassUnsubscribeManagement.setEnable(true);
215221
mailSettings.setBypassListManagement(bypassListManagement);
222+
mailSettings.setBypassSpamManagement(bypassSpamManagement);
223+
mailSettings.setBypassBounceManagement(bypassBounceManagement);
224+
mailSettings.setBypassUnsubscribeManagement(bypassUnsubscribeManagement);
216225
FooterSetting footerSetting = new FooterSetting();
217226
footerSetting.setEnable(true);
218227
footerSetting.setText("Footer Text");
@@ -255,7 +264,7 @@ public void testKitchenSink() throws IOException {
255264
replyTo.setEmail("test@example.com");
256265
mail.setReplyTo(replyTo);
257266

258-
Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"from\":{\"name\":\"Example Sender\",\"email\":\"sender@example.com\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"from\":{\"name\":\"Example Sender2\",\"email\":\"sender2@example.com\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"dynamic_template_data\":{\"city\":\"Denver\",\"items\":[{\"price\":\"$ 59.95\",\"text\":\"New Line Sneakers\"},{\"text\":\"Old Line Sneakers\"}],\"name\":\"Example User\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"<html><body>some text here</body></html>\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"<html><body>Footer Text</body></html>\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":false},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"<html><body>html to insert into the text/html portion of the message</body></html>\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
267+
Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"test@example.com\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"from\":{\"name\":\"Example Sender\",\"email\":\"sender@example.com\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"substitutions\":{\"%city%\":\"Denver\",\"%name%\":\"Example User\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"send_at\":1443636843},{\"to\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"from\":{\"name\":\"Example Sender2\",\"email\":\"sender2@example.com\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"test@example.com\"},{\"name\":\"Example User\",\"email\":\"test@example.com\"}],\"subject\":\"Hello World from the Personalized SendGrid Java Library\",\"headers\":{\"X-Mock\":\"true\",\"X-Test\":\"test\"},\"custom_args\":{\"type\":\"marketing\",\"user_id\":\"343\"},\"dynamic_template_data\":{\"city\":\"Denver\",\"items\":[{\"price\":\"$ 59.95\",\"text\":\"New Line Sneakers\"},{\"text\":\"Old Line Sneakers\"}],\"name\":\"Example User\"},\"send_at\":1443636843}],\"content\":[{\"type\":\"text/plain\",\"value\":\"some text here\"},{\"type\":\"text/html\",\"value\":\"<html><body>some text here</body></html>\"}],\"attachments\":[{\"content\":\"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12\",\"type\":\"application/pdf\",\"filename\":\"balance_001.pdf\",\"disposition\":\"attachment\",\"content_id\":\"Balance Sheet\"},{\"content\":\"BwdW\",\"type\":\"image/png\",\"filename\":\"banner.png\",\"disposition\":\"inline\",\"content_id\":\"Banner\"}],\"template_id\":\"13b8f94f-bcae-4ec6-b752-70d6cb59f932\",\"sections\":{\"%section1%\":\"Substitution Text for Section 1\",\"%section2%\":\"Substitution Text for Section 2\"},\"headers\":{\"X-Test1\":\"1\",\"X-Test2\":\"2\"},\"categories\":[\"May\",\"2016\"],\"custom_args\":{\"campaign\":\"welcome\",\"weekday\":\"morning\"},\"send_at\":1443636842,\"asm\":{\"group_id\":99,\"groups_to_display\":[4,5,6,7,8]},\"ip_pool_name\":\"23\",\"mail_settings\":{\"bcc\":{\"enable\":true,\"email\":\"test@example.com\"},\"bypass_list_management\":{\"enable\":true},\"bypass_spam_management\":{\"enable\":true},\"bypass_bounce_management\":{\"enable\":true},\"bypass_unsubscribe_management\":{\"enable\":true},\"footer\":{\"enable\":true,\"text\":\"Footer Text\",\"html\":\"<html><body>Footer Text</body></html>\"},\"sandbox_mode\":{\"enable\":true},\"spam_check\":{\"enable\":true,\"threshold\":1,\"post_to_url\":\"https://spamcatcher.sendgrid.com\"}},\"tracking_settings\":{\"click_tracking\":{\"enable\":true,\"enable_text\":false},\"open_tracking\":{\"enable\":true,\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"subscription_tracking\":{\"enable\":true,\"text\":\"text to insert into the text/plain portion of the message\",\"html\":\"<html><body>html to insert into the text/html portion of the message</body></html>\",\"substitution_tag\":\"Optional tag to replace with the open image in the body of the message\"},\"ganalytics\":{\"enable\":true,\"utm_source\":\"some source\",\"utm_term\":\"some term\",\"utm_content\":\"some content\",\"utm_campaign\":\"some name\",\"utm_medium\":\"some medium\"}},\"reply_to\":{\"name\":\"Example User\",\"email\":\"test@example.com\"}}");
259268
}
260269

261270
@Test

0 commit comments

Comments
 (0)