diff options
author | Maxim <maximdubrovkin@Maxims-MBP.Dlink> | 2016-06-19 22:11:26 +0500 |
---|---|---|
committer | Maxim <maximdubrovkin@Maxims-MBP.Dlink> | 2016-06-19 22:11:26 +0500 |
commit | f4d5a2ffcdebc1edfc067c6cb6a9938b8dc284ab (patch) | |
tree | 43c47723f1ee5339371a84c5522bbf57705d087c | |
parent | 4c390ab8af4044f478bee14133c38aad3f8f7766 (diff) | |
download | sendgrid-csharp-f4d5a2ffcdebc1edfc067c6cb6a9938b8dc284ab.zip sendgrid-csharp-f4d5a2ffcdebc1edfc067c6cb6a9938b8dc284ab.tar.gz sendgrid-csharp-f4d5a2ffcdebc1edfc067c6cb6a9938b8dc284ab.tar.bz2 |
Mail was refactored. Inner DTOs were extracted.
18 files changed, 453 insertions, 1284 deletions
diff --git a/SendGrid/SendGrid/Helpers/Mail/ASM.cs b/SendGrid/SendGrid/Helpers/Mail/ASM.cs new file mode 100644 index 0000000..c12499d --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/ASM.cs @@ -0,0 +1,14 @@ +using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class ASM
+ {
+ [JsonProperty(PropertyName = "group_id")]
+ public int GroupId { get; set; }
+
+ [JsonProperty(PropertyName = "groups_to_display")]
+ public List<int> GroupsToDisplay { get; set; }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Attachment.cs b/SendGrid/SendGrid/Helpers/Mail/Attachment.cs new file mode 100644 index 0000000..809b607 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/Attachment.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class Attachment
+ {
+ [JsonProperty(PropertyName = "content")]
+ public string Content { get; set; }
+
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; set; }
+
+ [JsonProperty(PropertyName = "filename")]
+ public string Filename { get; set; }
+
+ [JsonProperty(PropertyName = "disposition")]
+ public string Disposition { get; set; }
+
+ [JsonProperty(PropertyName = "content_id")]
+ public string ContentId { get; set; }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/BCCSettings.cs b/SendGrid/SendGrid/Helpers/Mail/BCCSettings.cs new file mode 100644 index 0000000..d638bb6 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/BCCSettings.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class BCCSettings + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "email")] + public string Email { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/BypassListManagement.cs b/SendGrid/SendGrid/Helpers/Mail/BypassListManagement.cs new file mode 100644 index 0000000..16b035c --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/BypassListManagement.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class BypassListManagement + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/ClickTracking.cs b/SendGrid/SendGrid/Helpers/Mail/ClickTracking.cs new file mode 100644 index 0000000..ce2c142 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/ClickTracking.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class ClickTracking + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "enable_text")] + public bool EnableText { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Content.cs b/SendGrid/SendGrid/Helpers/Mail/Content.cs new file mode 100644 index 0000000..9ba86b5 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/Content.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class Content
+ {
+ public Content()
+ {
+ }
+
+ public Content(string type, string value)
+ {
+ this.Type = type;
+ this.Value = value;
+ }
+
+ [JsonProperty(PropertyName = "type")]
+ public string Type { get; set; }
+
+ [JsonProperty(PropertyName = "value")]
+ public string Value { get; set; }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Email.cs b/SendGrid/SendGrid/Helpers/Mail/Email.cs new file mode 100644 index 0000000..bfca779 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/Email.cs @@ -0,0 +1,23 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class Email
+ {
+ public Email()
+ {
+ }
+
+ public Email(string email, string name = null)
+ {
+ this.Address = email;
+ this.Name = name;
+ }
+
+ [JsonProperty(PropertyName = "name")]
+ public string Name { get; set; }
+
+ [JsonProperty(PropertyName = "email")]
+ public string Address { get; set; }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/FooterSettings.cs b/SendGrid/SendGrid/Helpers/Mail/FooterSettings.cs new file mode 100644 index 0000000..f804a31 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/FooterSettings.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class FooterSettings + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + [JsonProperty(PropertyName = "html")] + public string Html { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Ganalytics.cs b/SendGrid/SendGrid/Helpers/Mail/Ganalytics.cs new file mode 100644 index 0000000..7284876 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/Ganalytics.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class Ganalytics + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "utm_source")] + public string UtmSource { get; set; } + + [JsonProperty(PropertyName = "utm_medium")] + public string UtmMedium { get; set; } + + [JsonProperty(PropertyName = "utm_term")] + public string UtmTerm { get; set; } + + [JsonProperty(PropertyName = "utm_content")] + public string UtmContent { get; set; } + + [JsonProperty(PropertyName = "utm_campaign")] + public string UtmCampaign { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Mail.cs b/SendGrid/SendGrid/Helpers/Mail/Mail.cs index b134734..16c1615 100644 --- a/SendGrid/SendGrid/Helpers/Mail/Mail.cs +++ b/SendGrid/SendGrid/Helpers/Mail/Mail.cs @@ -1,5 +1,4 @@ using Newtonsoft.Json; -using System; using System.Collections.Generic; namespace SendGrid.Helpers.Mail @@ -9,1283 +8,117 @@ namespace SendGrid.Helpers.Mail /// </summary> public class Mail { - private Email from; - private String subject; - private List<Personalization> personalizations; - private List<Content> contents; - private List<Attachment> attachments; - private String templateId; - private Dictionary<String, String> headers; - private Dictionary<String, String> sections; - private List<String> categories; - private Dictionary<String, String> customArgs; - private long sendAt; - private ASM asm; - private String batchId; - private String setIpPoolId; - private MailSettings mailSettings; - private TrackingSettings trackingSettings; - private Email replyTo; - public Mail() { - return; } - public Mail(Email from, String subject, Email to, Content content) + public Mail(Email from, string subject, Email to, Content content) { this.From = from; - Personalization personalization = new Personalization(); + + var personalization = new Personalization(); personalization.AddTo(to); this.AddPersonalization(personalization); + this.Subject = subject; this.AddContent(content); } [JsonProperty(PropertyName = "from")] - public Email From - { - get - { - return from; - } - - set - { - from = value; - } - } + public Email From { get; set; } [JsonProperty(PropertyName = "subject")] - public string Subject - { - get - { - return subject; - } - - set - { - subject = value; - } - } + public string Subject { get; set; } [JsonProperty(PropertyName = "personalizations")] - public List<Personalization> Personalization - { - get - { - return personalizations; - } - - set - { - personalizations = value; - } - } + public List<Personalization> Personalization { get; } = new List<Personalization>(); [JsonProperty(PropertyName = "content")] - public List<Content> Contents - { - get - { - return contents; - } - - set - { - contents = value; - } - } + public List<Content> Contents { get; } = new List<Content>(); [JsonProperty(PropertyName = "attachments")] - public List<Attachment> Attachments - { - get - { - return attachments; - } - - set - { - attachments = value; - } - } + public List<Attachment> Attachments { get; } = new List<Attachment>(); [JsonProperty(PropertyName = "template_id")] - public string TemplateId - { - get - { - return templateId; - } - - set - { - templateId = value; - } - } + public string TemplateId { get; set; } [JsonProperty(PropertyName = "headers")] - public Dictionary<string, string> Headers - { - get - { - return headers; - } - - set - { - headers = value; - } - } + public Dictionary<string, string> Headers { get; } = new Dictionary<string, string>(); [JsonProperty(PropertyName = "sections")] - public Dictionary<string, string> Sections - { - get - { - return sections; - } - - set - { - sections = value; - } - } + public Dictionary<string, string> Sections { get; } = new Dictionary<string, string>(); [JsonProperty(PropertyName = "categories")] - public List<string> Categories - { - get - { - return categories; - } - - set - { - categories = value; - } - } + public List<string> Categories { get; } = new List<string>(); [JsonProperty(PropertyName = "custom_args")] - public Dictionary<string, string> CustomArgs - { - get - { - return customArgs; - } - - set - { - customArgs = value; - } - } + public Dictionary<string, string> CustomArgs { get; } = new Dictionary<string, string>(); [JsonProperty(PropertyName = "send_at")] - public long SendAt - { - get - { - return sendAt; - } - - set - { - sendAt = value; - } - } + public long SendAt { get; set; } [JsonProperty(PropertyName = "asm")] - public ASM Asm - { - get - { - return asm; - } - - set - { - asm = value; - } - } + public ASM Asm { get; set; } [JsonProperty(PropertyName = "batch_id")] - public string BatchId - { - get - { - return batchId; - } - - set - { - batchId = value; - } - } + public string BatchId { get; set; } [JsonProperty(PropertyName = "ip_pool_name")] - public string SetIpPoolId - { - get - { - return setIpPoolId; - } - - set - { - setIpPoolId = value; - } - } + public string SetIpPoolId { get; set; } [JsonProperty(PropertyName = "mail_settings")] - public MailSettings MailSettings - { - get - { - return mailSettings; - } - - set - { - mailSettings = value; - } - } + public MailSettings MailSettings { get; set; } [JsonProperty(PropertyName = "tracking_settings")] - public TrackingSettings TrackingSettings - { - get - { - return trackingSettings; - } - - set - { - trackingSettings = value; - } - } + public TrackingSettings TrackingSettings { get; set; } [JsonProperty(PropertyName = "reply_to")] - public Email ReplyTo - { - get - { - return replyTo; - } - - set - { - replyTo = value; - } - } + public Email ReplyTo { get; set; } public void AddPersonalization(Personalization personalization) { - if (Personalization == null) - { - Personalization = new List<Personalization>(); - } Personalization.Add(personalization); } public void AddContent(Content content) { - if (Contents == null) - { - Contents = new List<Content>(); - } Contents.Add(content); } public void AddAttachment(Attachment attachment) { - if (Attachments == null) - { - Attachments = new List<Attachment>(); - } Attachments.Add(attachment); } - public void AddHeader(String key, String value) + public void AddHeader(string key, string value) { - if (headers == null) - { - headers = new Dictionary<String, String>(); - } - headers.Add(key, value); + Headers.Add(key, value); } - public void AddSection(String key, String value) + public void AddSection(string key, string value) { - if (sections == null) - { - sections = new Dictionary<String, String>(); - } - sections.Add(key, value); + Sections.Add(key, value); } - public void AddCategory(String category) + public void AddCategory(string category) { - if (Categories == null) - { - Categories = new List<String>(); - } Categories.Add(category); } - public void AddCustomArgs(String key, String value) + public void AddCustomArgs(string key, string value) { - if (customArgs == null) - { - customArgs = new Dictionary<String, String>(); - } - customArgs.Add(key, value); + CustomArgs.Add(key, value); } - public String Get() + public string Get() { return JsonConvert.SerializeObject(this, - Formatting.None, - new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, DefaultValueHandling = DefaultValueHandling.Ignore }); - } - } - - - public class ClickTracking - { - private bool enable; - private bool enableText; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "enable_text")] - public bool EnableText - { - get - { - return enableText; - } - - set - { - enableText = value; - } - } - } - - - public class OpenTracking - { - private bool enable; - private String substitutionTag; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "substitution_tag")] - public string SubstitutionTag - { - get - { - return substitutionTag; - } - - set - { - substitutionTag = value; - } - } - } - - - public class SubscriptionTracking - { - private bool enable; - private String text; - private String html; - private String substitutionTag; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "text")] - public string Text - { - get - { - return text; - } - - set - { - text = value; - } - } - - [JsonProperty(PropertyName = "html")] - public string Html - { - get - { - return html; - } - - set - { - html = value; - } - } - - [JsonProperty(PropertyName = "substitution_tag")] - public string SubstitutionTag - { - get - { - return substitutionTag; - } - - set - { - substitutionTag = value; - } - } - } - - - public class Ganalytics - { - private bool enable; - private String utmSource; - private String utmMedium; - private String utmTerm; - private String utmContent; - private String utmCampaign; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "utm_source")] - public string UtmSource - { - get - { - return utmSource; - } - - set - { - utmSource = value; - } - } - - [JsonProperty(PropertyName = "utm_medium")] - public string UtmMedium - { - get - { - return utmMedium; - } - - set - { - utmMedium = value; - } - } - - [JsonProperty(PropertyName = "utm_term")] - public string UtmTerm - { - get - { - return utmTerm; - } - - set - { - utmTerm = value; - } - } - - [JsonProperty(PropertyName = "utm_content")] - public string UtmContent - { - get - { - return utmContent; - } - - set - { - utmContent = value; - } - } - - [JsonProperty(PropertyName = "utm_campaign")] - public string UtmCampaign - { - get - { - return utmCampaign; - } - - set - { - utmCampaign = value; - } - } - } - - - public class TrackingSettings - { - private ClickTracking clickTracking; - private OpenTracking openTracking; - private SubscriptionTracking subscriptionTracking; - private Ganalytics ganalytics; - - [JsonProperty(PropertyName = "click_tracking")] - public ClickTracking ClickTracking - { - get - { - return clickTracking; - } - - set - { - clickTracking = value; - } - } - - [JsonProperty(PropertyName = "open_tracking")] - public OpenTracking OpenTracking - { - get - { - return openTracking; - } - - set - { - openTracking = value; - } - } - - [JsonProperty(PropertyName = "subscription_tracking")] - public SubscriptionTracking SubscriptionTracking - { - get - { - return subscriptionTracking; - } - - set - { - subscriptionTracking = value; - } - } - - [JsonProperty(PropertyName = "ganalytics")] - public Ganalytics Ganalytics - { - get - { - return ganalytics; - } - - set - { - ganalytics = value; - } - } - } - - - public class BCCSettings - { - private bool enable; - private String email; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "email")] - public string Email - { - get - { - return email; - } - - set - { - email = value; - } - } - } - - - public class BypassListManagement - { - private bool enable; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - } - - - public class FooterSettings - { - private bool enable; - private String text; - private String html; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "text")] - public string Text - { - get - { - return text; - } - - set - { - text = value; - } - } - - [JsonProperty(PropertyName = "html")] - public string Html - { - get - { - return html; - } - - set - { - html = value; - } + Formatting.None, + new JsonSerializerSettings + { + NullValueHandling = NullValueHandling.Ignore, + DefaultValueHandling = DefaultValueHandling.Ignore + }); } } - - - public class SandboxMode - { - private bool enable; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - } - - - public class SpamCheck - { - private bool enable; - private int threshold; - private String postToUrl; - - [JsonProperty(PropertyName = "enable")] - public bool Enable - { - get - { - return enable; - } - - set - { - enable = value; - } - } - - [JsonProperty(PropertyName = "threshold")] - public int Threshold - { - get - { - return threshold; - } - - set - { - threshold = value; - } - } - - [JsonProperty(PropertyName = "post_to_url")] - public string PostToUrl - { - get - { - return postToUrl; - } - - set - { - postToUrl = value; - } - } - } - - - public class MailSettings - { - private BCCSettings bccSettings; - private BypassListManagement bypassListManagement; - private FooterSettings footerSettings; - private SandboxMode sandboxMode; - private SpamCheck spamCheck; - - [JsonProperty(PropertyName = "bcc")] - public BCCSettings BccSettings - { - get - { - return bccSettings; - } - - set - { - bccSettings = value; - } - } - - [JsonProperty(PropertyName = "bypass_list_management")] - public BypassListManagement BypassListManagement - { - get - { - return bypassListManagement; - } - - set - { - bypassListManagement = value; - } - } - - [JsonProperty(PropertyName = "footer")] - public FooterSettings FooterSettings - { - get - { - return footerSettings; - } - - set - { - footerSettings = value; - } - } - - [JsonProperty(PropertyName = "sandbox_mode")] - public SandboxMode SandboxMode - { - get - { - return sandboxMode; - } - - set - { - sandboxMode = value; - } - } - - [JsonProperty(PropertyName = "spam_check")] - public SpamCheck SpamCheck - { - get - { - return spamCheck; - } - - set - { - spamCheck = value; - } - } - } - - - public class ASM - { - private int groupId; - private List<int> groupsToDisplay; - - [JsonProperty(PropertyName = "group_id")] - public int GroupId - { - get - { - return groupId; - } - - set - { - groupId = value; - } - } - - [JsonProperty(PropertyName = "groups_to_display")] - public List<int> GroupsToDisplay - { - get - { - return groupsToDisplay; - } - - set - { - groupsToDisplay = value; - } - } - } - - - public class Attachment - { - private String content; - private String type; - private String filename; - private String disposition; - private String contentId; - - [JsonProperty(PropertyName = "content")] - public string Content - { - get - { - return content; - } - - set - { - content = value; - } - } - - [JsonProperty(PropertyName = "type")] - public string Type - { - get - { - return type; - } - - set - { - type = value; - } - } - - [JsonProperty(PropertyName = "filename")] - public string Filename - { - get - { - return filename; - } - - set - { - filename = value; - } - } - - [JsonProperty(PropertyName = "disposition")] - public string Disposition - { - get - { - return disposition; - } - - set - { - disposition = value; - } - } - - [JsonProperty(PropertyName = "content_id")] - public string ContentId - { - get - { - return contentId; - } - - set - { - contentId = value; - } - } - } - - - public class Content - { - private String type; - private String value; - - public Content() - { - return; - } - - public Content(String type, String value) - { - this.Type = type; - this.Value = value; - } - - [JsonProperty(PropertyName = "type")] - public string Type - { - get - { - return type; - } - - set - { - type = value; - } - } - - [JsonProperty(PropertyName = "value")] - public string Value - { - get - { - return value; - } - - set - { - this.value = value; - } - } - } - - - public class Email - { - private String name; - private String address; - - public Email() - { - return; - } - - public Email(String email, String name = null) - { - this.Address = email; - this.Name = name; - } - - [JsonProperty(PropertyName = "name")] - public string Name - { - get - { - return name; - } - - set - { - name = value; - } - } - - [JsonProperty(PropertyName = "email")] - public string Address - { - get - { - return address; - } - - set - { - address = value; - } - } - } - - - public class Personalization - { - private List<Email> tos; - private List<Email> ccs; - private List<Email> bccs; - private String subject; - private Dictionary<String, String> headers; - private Dictionary<String, String> substitutions; - private Dictionary<String, String> customArgs; - private long sendAt; - - [JsonProperty(PropertyName = "to")] - public List<Email> Tos - { - get - { - return tos; - } - - set - { - tos = value; - } - } - - [JsonProperty(PropertyName = "cc")] - public List<Email> Ccs - { - get - { - return ccs; - } - - set - { - ccs = value; - } - } - - [JsonProperty(PropertyName = "bcc")] - public List<Email> Bccs - { - get - { - return bccs; - } - - set - { - bccs = value; - } - } - - [JsonProperty(PropertyName = "subject")] - public string Subject - { - get - { - return subject; - } - - set - { - subject = value; - } - } - - [JsonProperty(PropertyName = "headers")] - public Dictionary<string, string> Headers - { - get - { - return headers; - } - - set - { - headers = value; - } - } - - [JsonProperty(PropertyName = "substitutions")] - public Dictionary<string, string> Substitutions - { - get - { - return substitutions; - } - - set - { - substitutions = value; - } - } - - [JsonProperty(PropertyName = "custom_args")] - public Dictionary<string, string> CustomArgs - { - get - { - return customArgs; - } - - set - { - customArgs = value; - } - } - - [JsonProperty(PropertyName = "send_at")] - public long SendAt - { - get - { - return sendAt; - } - - set - { - sendAt = value; - } - } - - public void AddTo(Email email) - { - if (tos == null) - { - tos = new List<Email>(); - - } - tos.Add(email); - } - - public void AddCc(Email email) - { - if (ccs == null) - { - ccs = new List<Email>(); - } - ccs.Add(email); - } - - public void AddBcc(Email email) - { - if (bccs == null) - { - bccs = new List<Email>(); - } - bccs.Add(email); - } - - public void AddHeader(String key, String value) - { - if (headers == null) - { - headers = new Dictionary<String, String>(); - } - headers.Add(key, value); - } - - public void AddSubstitution(String key, String value) - { - if (substitutions == null) - { - substitutions = new Dictionary<String, String>(); - } - substitutions.Add(key, value); - } - - public void AddCustomArgs(String key, String value) - { - if (customArgs == null) - { - customArgs = new Dictionary<String, String>(); - } - customArgs.Add(key, value); - } - } -} - +}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/MailSettings.cs b/SendGrid/SendGrid/Helpers/Mail/MailSettings.cs new file mode 100644 index 0000000..f4b2e70 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/MailSettings.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class MailSettings + { + [JsonProperty(PropertyName = "bcc")] + public BCCSettings BccSettings { get; set; } + + [JsonProperty(PropertyName = "bypass_list_management")] + public BypassListManagement BypassListManagement { get; set; } + + [JsonProperty(PropertyName = "footer")] + public FooterSettings FooterSettings { get; set; } + + [JsonProperty(PropertyName = "sandbox_mode")] + public SandboxMode SandboxMode { get; set; } + + [JsonProperty(PropertyName = "spam_check")] + public SpamCheck SpamCheck { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/OpenTracking.cs b/SendGrid/SendGrid/Helpers/Mail/OpenTracking.cs new file mode 100644 index 0000000..27b6429 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/OpenTracking.cs @@ -0,0 +1,13 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class OpenTracking + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "substitution_tag")] + public string SubstitutionTag { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/Personalization.cs b/SendGrid/SendGrid/Helpers/Mail/Personalization.cs new file mode 100644 index 0000000..4deeede --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/Personalization.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic;
+using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class Personalization
+ {
+ [JsonProperty(PropertyName = "to")]
+ public List<Email> Tos { get; set; } = new List<Email>();
+
+ [JsonProperty(PropertyName = "cc")]
+ public List<Email> Ccs { get; set; } = new List<Email>();
+
+ [JsonProperty(PropertyName = "bcc")]
+ public List<Email> Bccs { get; set; } = new List<Email>();
+
+ [JsonProperty(PropertyName = "subject")]
+ public string Subject { get; set; }
+
+ [JsonProperty(PropertyName = "headers")]
+ public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();
+
+ [JsonProperty(PropertyName = "substitutions")]
+ public Dictionary<string, string> Substitutions { get; set; } = new Dictionary<string, string>();
+
+ [JsonProperty(PropertyName = "custom_args")]
+ public Dictionary<string, string> CustomArgs { get; set; } = new Dictionary<string, string>();
+
+ [JsonProperty(PropertyName = "send_at")]
+ public long SendAt { get; set; }
+
+ public void AddTo(Email email)
+ {
+ Tos.Add(email);
+ }
+
+ public void AddCc(Email email)
+ {
+ Ccs.Add(email);
+ }
+
+ public void AddBcc(Email email)
+ {
+ Bccs.Add(email);
+ }
+
+ public void AddHeader(string key, string value)
+ {
+ Headers.Add(key, value);
+ }
+
+ public void AddSubstitution(string key, string value)
+ {
+ Substitutions.Add(key, value);
+ }
+
+ public void AddCustomArgs(string key, string value)
+ {
+ CustomArgs.Add(key, value);
+ }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/SandboxMode.cs b/SendGrid/SendGrid/Helpers/Mail/SandboxMode.cs new file mode 100644 index 0000000..7e2bdd7 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/SandboxMode.cs @@ -0,0 +1,10 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class SandboxMode + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/SpamCheck.cs b/SendGrid/SendGrid/Helpers/Mail/SpamCheck.cs new file mode 100644 index 0000000..d156df1 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/SpamCheck.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class SpamCheck
+ {
+ [JsonProperty(PropertyName = "enable")]
+ public bool Enable { get; set; }
+
+ [JsonProperty(PropertyName = "threshold")]
+ public int Threshold { get; set; }
+
+ [JsonProperty(PropertyName = "post_to_url")]
+ public string PostToUrl { get; set; }
+ }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/SubscriptionTracking.cs b/SendGrid/SendGrid/Helpers/Mail/SubscriptionTracking.cs new file mode 100644 index 0000000..c34e9c8 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/SubscriptionTracking.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class SubscriptionTracking + { + [JsonProperty(PropertyName = "enable")] + public bool Enable { get; set; } + + [JsonProperty(PropertyName = "text")] + public string Text { get; set; } + + [JsonProperty(PropertyName = "html")] + public string Html { get; set; } + + [JsonProperty(PropertyName = "substitution_tag")] + public string SubstitutionTag { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/Helpers/Mail/TrackingSettings.cs b/SendGrid/SendGrid/Helpers/Mail/TrackingSettings.cs new file mode 100644 index 0000000..8bb0a32 --- /dev/null +++ b/SendGrid/SendGrid/Helpers/Mail/TrackingSettings.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json;
+
+namespace SendGrid.Helpers.Mail
+{
+ public class TrackingSettings + { + [JsonProperty(PropertyName = "click_tracking")] + public ClickTracking ClickTracking { get; set; } + + [JsonProperty(PropertyName = "open_tracking")] + public OpenTracking OpenTracking { get; set; } + + [JsonProperty(PropertyName = "subscription_tracking")] + public SubscriptionTracking SubscriptionTracking { get; set; } + + [JsonProperty(PropertyName = "ganalytics")] + public Ganalytics Ganalytics { get; set; } + }
+}
\ No newline at end of file diff --git a/SendGrid/SendGrid/SendGrid.csproj b/SendGrid/SendGrid/SendGrid.csproj index 81592a8..1480c67 100644 --- a/SendGrid/SendGrid/SendGrid.csproj +++ b/SendGrid/SendGrid/SendGrid.csproj @@ -1,88 +1,104 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProjectGuid>{1C318867-440B-4EB9-99E3-C0CC2C556962}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>SendGrid</RootNamespace> - <AssemblyName>SendGrid</AssemblyName> - <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> - <FileAlignment>512</FileAlignment> - <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> - <TargetFrameworkProfile /> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugSymbols>true</DebugSymbols> - <DebugType>full</DebugType> - <Optimize>false</Optimize> - <OutputPath>bin\Debug\</OutputPath> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <PlatformTarget>AnyCPU</PlatformTarget> - <DebugType>none</DebugType> - <Optimize>true</Optimize> - <OutputPath>bin\Release\</OutputPath> - <DefineConstants>TRACE</DefineConstants> - <ErrorReport>prompt</ErrorReport> - <WarningLevel>4</WarningLevel> - </PropertyGroup> - <PropertyGroup> - <StartupObject /> - </PropertyGroup> - <PropertyGroup> - <SignAssembly>true</SignAssembly> - </PropertyGroup> - <PropertyGroup> - <AssemblyOriginatorKeyFile>sendgrid-csharp.snk</AssemblyOriginatorKeyFile> - </PropertyGroup> - <ItemGroup> - <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> - <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.4.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL"> - <HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.4\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System" /> - <Reference Include="System.Core" /> - <Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> - <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath> - <Private>True</Private> - </Reference> - <Reference Include="System.Web" /> - <Reference Include="System.Web.Extensions" /> - <Reference Include="System.Xml.Linq" /> - <Reference Include="System.Data.DataSetExtensions" /> - <Reference Include="Microsoft.CSharp" /> - <Reference Include="System.Data" /> - <Reference Include="System.Net.Http" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="Client.cs" /> - <Compile Include="Helpers\Mail\Mail.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - </ItemGroup> - <ItemGroup> - <None Include="App.config" /> - <None Include="packages.config" /> - <None Include="sendgrid-csharp.snk" /> - </ItemGroup> - <ItemGroup /> - <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{1C318867-440B-4EB9-99E3-C0CC2C556962}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>SendGrid</RootNamespace>
+ <AssemblyName>SendGrid</AssemblyName>
+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+ <TargetFrameworkProfile />
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup>
+ <StartupObject />
+ </PropertyGroup>
+ <PropertyGroup>
+ <SignAssembly>true</SignAssembly>
+ </PropertyGroup>
+ <PropertyGroup>
+ <AssemblyOriginatorKeyFile>sendgrid-csharp.snk</AssemblyOriginatorKeyFile>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+ <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="SendGrid.CSharp.HTTP.Client, Version=2.0.4.0, Culture=neutral, PublicKeyToken=79219bf4e5ecaaca, processorArchitecture=MSIL">
+ <HintPath>..\packages\SendGrid.CSharp.HTTP.Client.2.0.4\lib\SendGrid.CSharp.HTTP.Client.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
+ <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Net.Http" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Client.cs" />
+ <Compile Include="Helpers\Mail\ASM.cs" />
+ <Compile Include="Helpers\Mail\Attachment.cs" />
+ <Compile Include="Helpers\Mail\BCCSettings.cs" />
+ <Compile Include="Helpers\Mail\BypassListManagement.cs" />
+ <Compile Include="Helpers\Mail\ClickTracking.cs" />
+ <Compile Include="Helpers\Mail\Content.cs" />
+ <Compile Include="Helpers\Mail\Email.cs" />
+ <Compile Include="Helpers\Mail\FooterSettings.cs" />
+ <Compile Include="Helpers\Mail\Ganalytics.cs" />
+ <Compile Include="Helpers\Mail\Mail.cs" />
+ <Compile Include="Helpers\Mail\MailSettings.cs" />
+ <Compile Include="Helpers\Mail\OpenTracking.cs" />
+ <Compile Include="Helpers\Mail\Personalization.cs" />
+ <Compile Include="Helpers\Mail\SandboxMode.cs" />
+ <Compile Include="Helpers\Mail\SpamCheck.cs" />
+ <Compile Include="Helpers\Mail\SubscriptionTracking.cs" />
+ <Compile Include="Helpers\Mail\TrackingSettings.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config" />
+ <None Include="sendgrid-csharp.snk" />
+ </ItemGroup>
+ <ItemGroup />
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild"> </Target> <Target Name="AfterBuild"> </Target> - --> + -->
</Project>
\ No newline at end of file |