Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing bypass settings to MailSettings #707

Merged
merged 4 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ public class MailSettings {
@JsonProperty("bypass_list_management")
private Setting bypassListManagement;

@JsonProperty("bypass_spam_management")
private Setting bypassSpamManagement;

@JsonProperty("bypass_bounce_management")
private Setting bypassBounceManagement;

@JsonProperty("bypass_unsubscribe_management")
private Setting bypassUnsubscribeManagement;

@JsonProperty("footer")
private FooterSetting footerSetting;

Expand Down Expand Up @@ -58,6 +67,58 @@ public void setBypassListManagement(Setting bypassListManagement) {
this.bypassListManagement = bypassListManagement;
}

/**
* Allows you to bypass the spam report list to ensure that the email is delivered to recipients.
* Bounce and unsubscribe lists will still be checked; addresses on these other lists will not
* receive the message.
*
* This filter cannot be combined with the bypass_list_management filter.
* @return the bypass spam setting
*/

@JsonProperty("bypass_spam_management")
public Setting getBypassSpamManagement() {
return bypassSpamManagement;
}

public void setBypassSpamManagement(Setting bypassSpamManagement) {
this.bypassSpamManagement = bypassSpamManagement;
}

/**
* Allows you to bypass the bounce list to ensure that the email is delivered to recipients.
* Spam report and unsubscribe lists will still be checked; addresses on these other lists
* will not receive the message.
*
* This filter cannot be combined with the bypass_list_management filter.
* @return the bypass bounce setting
*/
@JsonProperty("bypass_bounce_management")
public Setting getBypassBounceManagement() {
return bypassBounceManagement;
}
public void setBypassBounceManagement(Setting bypassBounceManagement) {
this.bypassBounceManagement = bypassBounceManagement;
}

/**
* Allows you to bypass the global unsubscribe list to ensure that the email is delivered
* to recipients. Bounce and spam report lists will still be checked; addresses on these
* other lists will not receive the message. This filter applies only to global unsubscribes
* and will not bypass group unsubscribes.
*
* This filter cannot be combined with the bypass_list_management filter.
* @return the bypass unsubscribe setting
*/
@JsonProperty("bypass_unsubscribe_management")
public Setting getBypassUnsubscribeManagement() {
return bypassUnsubscribeManagement;
}

public void setBypassUnsubscribeManagement(Setting bypassUnsubscribeManagement) {
this.bypassUnsubscribeManagement = bypassUnsubscribeManagement;
}

shwetha-manvinkurke marked this conversation as resolved.
Show resolved Hide resolved
/**
* Get the footer settings that you would like included on every email.
*
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/com/sendgrid/helpers/MailTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,16 @@ public void testKitchenSink() throws IOException {
mailSettings.setSandboxMode(sandBoxMode);
Setting bypassListManagement = new Setting();
bypassListManagement.setEnable(true);
Setting bypassSpamManagement = new Setting();
bypassSpamManagement.setEnable(true);
Setting bypassBounceManagement = new Setting();
bypassBounceManagement.setEnable(true);
Setting bypassUnsubscribeManagement = new Setting();
bypassUnsubscribeManagement.setEnable(true);
mailSettings.setBypassListManagement(bypassListManagement);
mailSettings.setBypassSpamManagement(bypassSpamManagement);
mailSettings.setBypassBounceManagement(bypassBounceManagement);
mailSettings.setBypassUnsubscribeManagement(bypassUnsubscribeManagement);
FooterSetting footerSetting = new FooterSetting();
footerSetting.setEnable(true);
footerSetting.setText("Footer Text");
Expand Down Expand Up @@ -255,7 +264,7 @@ public void testKitchenSink() throws IOException {
replyTo.setEmail("[email protected]");
mail.setReplyTo(replyTo);

Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"[email protected]\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"from\":{\"name\":\"Example Sender\",\"email\":\"[email protected]\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"from\":{\"name\":\"Example Sender2\",\"email\":\"[email protected]\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},\"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\":\"[email protected]\"}}");
Assert.assertEquals(mail.build(), "{\"from\":{\"name\":\"Example User\",\"email\":\"[email protected]\"},\"subject\":\"Hello World from the SendGrid Java Library\",\"personalizations\":[{\"to\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"from\":{\"name\":\"Example Sender\",\"email\":\"[email protected]\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"from\":{\"name\":\"Example Sender2\",\"email\":\"[email protected]\"},\"cc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"bcc\":[{\"name\":\"Example User\",\"email\":\"[email protected]\"},{\"name\":\"Example User\",\"email\":\"[email protected]\"}],\"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\":\"[email protected]\"},\"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\":\"[email protected]\"}}");
}

@Test
Expand Down