diff --git a/examples/helpers/mail/Example.java b/examples/helpers/mail/Example.java index bffcdfdb..174e38ba 100644 --- a/examples/helpers/mail/Example.java +++ b/examples/helpers/mail/Example.java @@ -149,6 +149,17 @@ public static Mail buildKitchenSink() { Setting bypassListManagement = new Setting(); bypassListManagement.setEnable(true); mailSettings.setBypassListManagement(bypassListManagement); + // Note: Bypass Spam, Bounce, and Unsubscribe management cannot + // be combined with Bypass List Management + Setting bypassSpamManagement = new Setting(); + bypassSpamManagement.setEnable(true); + mailSettings.setBypassSpamManagement(bypassSpamManagement); + Setting bypassBounceManagement = new Setting(); + bypassBounceManagement.setEnable(true); + mailSettings.setBypassBounceManagement(bypassBounceManagement); + Setting bypassUnsubscribeManagement = new Setting(); + bypassUnsubscribeManagement.setEnable(true); + mailSettings.setBypassUnsubscribeManagement(bypassUnsubscribeManagement); FooterSetting footerSetting = new FooterSetting(); footerSetting.setEnable(true); footerSetting.setText("Footer Text"); diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java index d83a56b6..1bad6b09 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java @@ -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; @@ -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; + } + /** * Get the footer settings that you would like included on every email. * @@ -128,6 +189,12 @@ public int hashCode() { result = prime * result + ((bccSettings == null) ? 0 : bccSettings.hashCode()); result = prime * result + ((bypassListManagement == null) ? 0 : bypassListManagement.hashCode()); + result = + prime * result + ((bypassSpamManagement == null) ? 0 : bypassSpamManagement.hashCode()); + result = + prime * result + ((bypassBounceManagement == null) ? 0 : bypassBounceManagement.hashCode()); + result = + prime * result + ((bypassUnsubscribeManagement == null) ? 0 : bypassUnsubscribeManagement.hashCode()); result = prime * result + ((footerSetting == null) ? 0 : footerSetting.hashCode()); result = prime * result + ((sandBoxMode == null) ? 0 : sandBoxMode.hashCode()); result = prime * result + ((spamCheckSetting == null) ? 0 : spamCheckSetting.hashCode()); @@ -160,6 +227,27 @@ public boolean equals(Object obj) { } else if (!bypassListManagement.equals(other.bypassListManagement)) { return false; } + if (bypassSpamManagement == null) { + if (other.bypassSpamManagement != null) { + return false; + } + } else if (!bypassSpamManagement.equals(other.bypassSpamManagement)) { + return false; + } + if (bypassBounceManagement == null) { + if (other.bypassBounceManagement != null) { + return false; + } + } else if (!bypassBounceManagement.equals(other.bypassBounceManagement)) { + return false; + } + if (bypassUnsubscribeManagement == null) { + if (other.bypassUnsubscribeManagement != null) { + return false; + } + } else if (!bypassUnsubscribeManagement.equals(other.bypassUnsubscribeManagement)) { + return false; + } if (footerSetting == null) { if (other.footerSetting != null) { return false; diff --git a/src/test/java/com/sendgrid/helpers/MailTest.java b/src/test/java/com/sendgrid/helpers/MailTest.java index 9cdc194c..22c7f8db 100644 --- a/src/test/java/com/sendgrid/helpers/MailTest.java +++ b/src/test/java/com/sendgrid/helpers/MailTest.java @@ -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"); @@ -255,7 +264,7 @@ public void testKitchenSink() throws IOException { replyTo.setEmail("test@example.com"); mail.setReplyTo(replyTo); - 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\":\"some text here\"}],\"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\":\"Footer Text\"},\"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 to insert into the text/html portion of the message\",\"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\"}}"); + 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\":\"some text here\"}],\"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\":\"Footer Text\"},\"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 to insert into the text/html portion of the message\",\"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\"}}"); } @Test