Skip to content

feat: Added mail settings attributes for bypass_spam_management, bypass_bou… #1153

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

Merged
merged 7 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 13 additions & 1 deletion USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,9 @@ This endpoint allows you to send email over Twilio SendGrid's v3 Web API, the mo
* Top level parameters are referred to as "global".
* Individual fields within the personalizations array will override any other global, or message level, parameters that are defined outside of personalizations.

* Note: bypass_bounce_management, bypass_spam_management, and bypass_unsubscribe_management cannot
* be combined with bypass_list_management

For an overview of the v3 Mail Send endpoint, please visit our [v3 API Reference](https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html)

For more detailed information about how to use the v3 Mail Send endpoint, please visit our [Classroom](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/index.html).
Expand Down Expand Up @@ -2501,7 +2504,16 @@ string data = @"{
},
'bypass_list_management': {
'enable': true
},
},
'bypass_spam_management': {
'enable': true
},
'bypass_bounce_management': {
'enable': true
},
'bypass_unsubscribe_management': {
'enable': true
},
'footer': {
'enable': true,
'html': '<p>Thanks</br>The Twilio SendGrid Team</p>',
Expand Down
8 changes: 8 additions & 0 deletions USE_CASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,14 @@ namespace Example

msg.SetBccSetting(true, "[email protected]");

// Note: Bypass Spam, Bounce, and Unsubscribe management cannot be combined with Bypass List Management
msg.BypassSpamManagement(true);

msg.BypassBounceManagement(true);

msg.BypassUnsubscribeManagement(true);

// OR
msg.SetBypassListManagement(true);

msg.SetFooterSetting(true, "Some Footer HTML", "Some Footer Text");
Expand Down
22 changes: 22 additions & 0 deletions src/SendGrid/Helpers/Mail/Model/BypassBounceManagement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// <copyright file="BypassListManagement.cs" company="Twilio SendGrid">
// Copyright (c) Twilio SendGrid. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>

using Newtonsoft.Json;

namespace SendGrid.Helpers.Mail
{
/// <summary>
/// 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.
/// </summary>
[JsonObject(IsReference = false)]
public class BypassBounceManagement
{
/// <summary>
/// Gets or sets a value indicating whether this setting is enabled.
/// </summary>
[JsonProperty(PropertyName = "enable")]
public bool Enable { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/SendGrid/Helpers/Mail/Model/BypassSpamManagement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// <copyright file="BypassListManagement.cs" company="Twilio SendGrid">
// Copyright (c) Twilio SendGrid. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>

using Newtonsoft.Json;

namespace SendGrid.Helpers.Mail
{
/// <summary>
/// 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.
/// </summary>
[JsonObject(IsReference = false)]
public class BypassSpamManagement
{
/// <summary>
/// Gets or sets a value indicating whether this setting is enabled.
/// </summary>
[JsonProperty(PropertyName = "enable")]
public bool Enable { get; set; }
}
}
22 changes: 22 additions & 0 deletions src/SendGrid/Helpers/Mail/Model/BypassUnsubscribeManagement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// <copyright file="BypassListManagement.cs" company="Twilio SendGrid">
// Copyright (c) Twilio SendGrid. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>

using Newtonsoft.Json;

namespace SendGrid.Helpers.Mail
{
/// <summary>
/// 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.
/// </summary>
[JsonObject(IsReference = false)]
public class BypassUnsubscribeManagement
{
/// <summary>
/// Gets or sets a value indicating whether this setting is enabled.
/// </summary>
[JsonProperty(PropertyName = "enable")]
public bool Enable { get; set; }
}
}
18 changes: 18 additions & 0 deletions src/SendGrid/Helpers/Mail/Model/MailSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@ public class MailSettings
[JsonProperty(PropertyName = "bypass_list_management")]
public BypassListManagement BypassListManagement { get; set; }

/// <summary>
/// Gets or sets the bypass of 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.
/// </summary>
[JsonProperty(PropertyName = "bypass_spam_management")]
public BypassSpamManagement BypassSpamManagement { get; set; }

/// <summary>
/// Gets or sets the 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.
/// </summary>
[JsonProperty(PropertyName = "bypass_bounce_management")]
public BypassBounceManagement BypassBounceManagement { get; set; }

/// <summary>
/// Gets or sets the 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.
/// </summary>
[JsonProperty(PropertyName = "bypass_unsubscribe_management")]
public BypassUnsubscribeManagement BypassUnsubscribeManagement { get; set; }

/// <summary>
/// Gets or sets the default footer that you would like appended to the bottom of every email.
/// </summary>
Expand Down
57 changes: 57 additions & 0 deletions src/SendGrid/Helpers/Mail/SendGridMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,63 @@ public void SetBypassListManagement(bool enable)
return;
}

/// <summary>
/// Set the bypass spam management setting.
/// 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.
/// </summary>
/// <param name="enable">Gets or sets a value indicating whether this setting is enabled.</param>
public void SetBypassSpamManagement(bool enable)
{
if (this.MailSettings == null)
{
this.MailSettings = new MailSettings();
}

this.MailSettings.BypassSpamManagement = new BypassSpamManagement
{
Enable = enable,
};
return;
}

/// <summary>
/// Set the bypass bounce management setting.
/// 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.
/// </summary>
/// <param name="enable">Gets or sets a value indicating whether this setting is enabled.</param>
public void SetBypassBounceManagement(bool enable)
{
if (this.MailSettings == null)
{
this.MailSettings = new MailSettings();
}

this.MailSettings.BypassBounceManagement = new BypassBounceManagement
{
Enable = enable,
};
return;
}

/// <summary>
/// Set the bypass unsubscribe management setting.
/// 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.
/// </summary>
/// <param name="enable">Gets or sets a value indicating whether this setting is enabled.</param>
public void SetBypassUnsubscribeManagement(bool enable)
{
if (this.MailSettings == null)
{
this.MailSettings = new MailSettings();
}

this.MailSettings.BypassUnsubscribeManagement = new BypassUnsubscribeManagement
{
Enable = enable,
};
return;
}

/// <summary>
/// Set the footer setting.
/// The default footer that you would like appended to the bottom of every email.
Expand Down
Loading