From 6facf253f46c2ebf438faec167dcc95a51575eb1 Mon Sep 17 00:00:00 2001 From: Jericho Date: Sat, 26 Nov 2016 02:05:05 -0600 Subject: [PATCH 01/24] Fix typos in comments --- Source/StrongGrid/Resources/User.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/StrongGrid/Resources/User.cs b/Source/StrongGrid/Resources/User.cs index cc4d159f..91725bdf 100644 --- a/Source/StrongGrid/Resources/User.cs +++ b/Source/StrongGrid/Resources/User.cs @@ -197,9 +197,9 @@ public User(IClient client, string endpoint = "/user/profile") // The response contains the following header: Content-Type: application/json; charset=utf8 // The specified charset is not valid. The correct syntax is: charset=utf-8 // The fact that the charset is slightly misspelled prevents the .Net HttpClient from - // being able to parse the body of the reponse. The HttpClient throws the following excpetion - // when we try to get the content of the reposne like so: response.Content.ReadAsStreamAsync() - // The character set provided in ContentType is invalid.Cannot read content as string using + // being able to parse the body of the reponse. The HttpClient throws the following exception + // when we try to get the content of the response like so: response.Content.ReadAsStreamAsync() + // The character set provided in ContentType is invalid. Cannot read content as string using // an invalid character set. System.ArgumentException: 'utf8' is not a supported encoding name // I contacted SendGrid on 11/23/2016 to report this problem: https://support.sendgrid.com/hc/en-us/requests/806220 @@ -209,7 +209,7 @@ public User(IClient client, string endpoint = "/user/profile") // the charset removed from that API call // Until SendGrid solves the problem on their end by either omiting the charset or fixing the misspelling, - // we must resd the content into a stream and convert the stream to a string which allows us to specify + // we must read the content into a stream and convert the stream to a string which allows us to specify // the desired charset (which is Encoding.UTF8 in this case). var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); var responseContent = string.Empty; From 9e6be3c98c603a559260677f8d38f80d22cd332a Mon Sep 17 00:00:00 2001 From: Jeremie Desautels Date: Sun, 27 Nov 2016 17:38:10 -0600 Subject: [PATCH 02/24] We already build on .net standard 1.3 therefore no need to build on .net standard 1.6 --- README.md | 3 +-- Source/StrongGrid/project.json | 11 ----------- nuspec/StrongGrid.nuspec | 9 +-------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index d04c846d..a287dfef 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,7 @@ StrongGrid supports the following .NET frameworks: - 4.6 - 4.6.1 - 4.6.2 -- .Net Standard 1.3 -- .Net Standard 1.6 +- .Net Core ## Usage diff --git a/Source/StrongGrid/project.json b/Source/StrongGrid/project.json index d4b62333..592167a3 100644 --- a/Source/StrongGrid/project.json +++ b/Source/StrongGrid/project.json @@ -24,17 +24,6 @@ } }, "frameworks": { - "netstandard1.6": { - "buildOptions": { - "define": [ "NETSTANDARD", "NETSTANDARD16" ] - }, - "imports": "dnxcore50", - "dependencies": { - "NETStandard.Library": "1.6.1", - "Newtonsoft.Json": "9.0.1", - "System.Reflection.TypeExtensions": "4.3.0" - } - }, "netstandard1.3": { "buildOptions": { "define": [ "NETSTANDARD", "NETSTANDARD13" ] diff --git a/nuspec/StrongGrid.nuspec b/nuspec/StrongGrid.nuspec index f99e5399..6166c4dd 100644 --- a/nuspec/StrongGrid.nuspec +++ b/nuspec/StrongGrid.nuspec @@ -38,12 +38,6 @@ - - - - - - @@ -57,7 +51,6 @@ - - + From 6ae01f33491b34f8038027a83a2079dbfa1fd38d Mon Sep 17 00:00:00 2001 From: Jeremie Desautels Date: Sun, 27 Nov 2016 18:02:45 -0600 Subject: [PATCH 03/24] More xml comments (#76) --- Source/StrongGrid/Client.cs | 111 +++++++++++++++-- Source/StrongGrid/Resources/Alerts.cs | 20 ++- Source/StrongGrid/Resources/ApiKeys.cs | 32 ++--- Source/StrongGrid/Resources/Batches.cs | 14 +-- Source/StrongGrid/Resources/Blocks.cs | 12 +- Source/StrongGrid/Resources/Bounces.cs | 4 +- Source/StrongGrid/Resources/Campaigns.cs | 116 ++++++++++++++++-- Source/StrongGrid/Resources/Categories.cs | 15 ++- Source/StrongGrid/Resources/Contacts.cs | 4 +- Source/StrongGrid/Resources/CustomFields.cs | 4 +- .../Resources/GlobalSuppressions.cs | 4 +- Source/StrongGrid/Resources/InvalidEmails.cs | 12 +- Source/StrongGrid/Resources/Lists.cs | 4 +- Source/StrongGrid/Resources/Mail.cs | 3 +- Source/StrongGrid/Resources/Segments.cs | 8 +- .../StrongGrid/Resources/SenderIdentities.cs | 4 +- Source/StrongGrid/Resources/Settings.cs | 4 +- Source/StrongGrid/Resources/SpamReports.cs | 13 +- Source/StrongGrid/Resources/Statistics.cs | 4 +- Source/StrongGrid/Resources/Suppressions.cs | 4 +- Source/StrongGrid/Resources/Templates.cs | 4 +- .../StrongGrid/Resources/UnsubscribeGroups.cs | 6 +- Source/StrongGrid/Resources/User.cs | 20 +-- Source/StrongGrid/Resources/Whitelabel.cs | 34 ++++- Source/StrongGrid/Utilities/Extensions.cs | 2 + nuspec/StrongGrid.nuspec | 6 +- 26 files changed, 369 insertions(+), 95 deletions(-) diff --git a/Source/StrongGrid/Client.cs b/Source/StrongGrid/Client.cs index 0a97f21d..f454623e 100644 --- a/Source/StrongGrid/Client.cs +++ b/Source/StrongGrid/Client.cs @@ -12,6 +12,9 @@ namespace StrongGrid { + /// + /// REST client for interacting with SendGrid's API + /// public class Client : IClient, IDisposable { #region FIELDS @@ -36,50 +39,119 @@ private enum Methods #region PROPERTIES + /// + /// Gets the Alerts resource which allows you to receive notifications regarding your email usage or statistics. + /// public Alerts Alerts { get; private set; } + /// + /// Gets the API Keys resource which allows you to manage your API Keys. + /// public ApiKeys ApiKeys { get; private set; } + /// + /// Gets the Batches resource. + /// public Batches Batches { get; private set; } + /// + /// Gets the Blocks resource which allows you to manage blacked email addresses. + /// public Blocks Blocks { get; private set; } + /// + /// Gets the Campaigns resource which allows you to manage your campaigns. + /// public Campaigns Campaigns { get; private set; } + /// + /// Gets the Categories resource which allows you to manages your categories. + /// public Categories Categories { get; private set; } + /// + /// Gets the Contacts resource which allows you to manage your contacts (also sometimes refered to as 'recipients'). + /// public Contacts Contacts { get; private set; } + /// + /// Gets the CustomFields resource which allows you to manage your custom fields. + /// public CustomFields CustomFields { get; private set; } + /// + /// Gets the GlobalSuppressions resource. + /// public GlobalSuppressions GlobalSuppressions { get; private set; } + /// + /// Gets the InvalidEmails resource. + /// public InvalidEmails InvalidEmails { get; private set; } + /// + /// Gets the Lists resource. + /// public Lists Lists { get; private set; } + /// + /// Gets the Mail resource. + /// public Mail Mail { get; private set; } + /// + /// Gets the Segments resource. + /// public Segments Segments { get; private set; } + /// + /// Gets the SenderIdentities resource. + /// public SenderIdentities SenderIdentities { get; private set; } + /// + /// Gets the Settings resource. + /// public Settings Settings { get; private set; } + /// + /// Gets the SpamReports resource. + /// public SpamReports SpamReports { get; private set; } + /// + /// Gets the Statistics resource. + /// public Statistics Statistics { get; private set; } + /// + /// Gets the Suppressions resource. + /// public Suppressions Suppressions { get; private set; } + /// + /// Gets the Templates resource. + /// public Templates Templates { get; private set; } + /// + /// Gets the UnsubscribeGroups resource. + /// public UnsubscribeGroups UnsubscribeGroups { get; private set; } + /// + /// Gets the User resource. + /// public User User { get; private set; } + /// + /// Gets the Version. + /// public string Version { get; private set; } + /// + /// Gets the Whitelabel resource. + /// public Whitelabel Whitelabel { get; private set; } #endregion @@ -87,7 +159,7 @@ private enum Methods #region CTOR /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// /// Your SendGrid API Key public Client(string apiKey) @@ -96,7 +168,7 @@ public Client(string apiKey) } /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// /// Your SendGrid API Key /// Allows you to specify a proxy @@ -107,7 +179,7 @@ public Client(string apiKey, IWebProxy proxy = null) } /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// /// Your SendGrid API Key /// Base SendGrid API Uri @@ -120,16 +192,20 @@ public Client(string apiKey, string baseUri = DEFAULT_BASE_URI, string apiVersio } /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// + /// Your username + /// Your password public Client(string username, string password) : this(null, username, password, DEFAULT_BASE_URI, DEFAULT_API_VERSION, null, null) { } /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// + /// Your username + /// Your password /// Allows you to specify a proxy public Client(string username, string password, IWebProxy proxy = null) : this(null, username, password, DEFAULT_BASE_URI, DEFAULT_API_VERSION, new HttpClient(new HttpClientHandler { Proxy = proxy, UseProxy = proxy != null }), null) @@ -138,7 +214,7 @@ public Client(string username, string password, IWebProxy proxy = null) } /// - /// Initializes a new instance of the Client class. + /// Initializes a new instance of the class. /// /// Your username /// Your password @@ -203,6 +279,7 @@ private Client(string apiKey, string username, string password, string baseUri, #region PUBLIC METHODS /// Resource endpoint + /// Cancellation token /// The resulting message from the API call public Task GetAsync(string endpoint, CancellationToken cancellationToken = default(CancellationToken)) { @@ -211,6 +288,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task PostAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -219,6 +297,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JArray representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task PostAsync(string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -226,6 +305,7 @@ private Client(string apiKey, string username, string password, string baseUri, } /// Resource endpoint + /// Cancellation token /// The resulting message from the API call public Task DeleteAsync(string endpoint, CancellationToken cancellationToken = default(CancellationToken)) { @@ -234,6 +314,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An optional JObject representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task DeleteAsync(string endpoint, JObject data = null, CancellationToken cancellationToken = default(CancellationToken)) { @@ -242,6 +323,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An optional JArray representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task DeleteAsync(string endpoint, JArray data = null, CancellationToken cancellationToken = default(CancellationToken)) { @@ -250,6 +332,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task PatchAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -258,6 +341,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JArray representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task PatchAsync(string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -266,6 +350,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data + /// Cancellation token /// The resulting message from the API call public Task PutAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -301,11 +386,12 @@ protected virtual void Dispose(bool disposing) #region PRIVATE METHODS /// - /// Create a client that connects to the SendGrid Web API + /// Issue a request to the SendGrid Web API /// /// HTTP verb, case-insensitive /// Resource endpoint /// An JObject representing the resource's data + /// Cancellation token /// An asyncronous task private Task RequestAsync(Methods method, string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -314,11 +400,12 @@ protected virtual void Dispose(bool disposing) } /// - /// Create a client that connects to the SendGrid Web API + /// Issue a request to the SendGrid Web API /// /// HTTP verb, case-insensitive /// Resource endpoint /// An JArray representing the resource's data + /// Cancellation token /// An asyncronous task private Task RequestAsync(Methods method, string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { @@ -327,11 +414,13 @@ protected virtual void Dispose(bool disposing) } /// - /// Create a client that connects to the SendGrid Web API + /// Issue a request to the SendGrid Web API /// /// HTTP verb, case-insensitive /// Resource endpoint - /// A StringContent representing the content of the http request + /// A string representing the content of the http request + /// The number of retries remaining in case SendGrid responds with HTTP 429 (aka TOO MANY REQUESTS) + /// Cancellation token /// An asyncronous task private async Task RequestAsync(Methods method, string endpoint, string content, int retriesRemaining, CancellationToken cancellationToken = default(CancellationToken)) { @@ -357,7 +446,7 @@ protected virtual void Dispose(bool disposing) { Method = new HttpMethod(methodAsString), RequestUri = new Uri(string.Format("{0}{1}{2}", _baseUri, endpoint.StartsWith("/", StringComparison.Ordinal) ? string.Empty : "/", endpoint)), - Content = (content == null ? null : new StringContent(content, Encoding.UTF8, MEDIA_TYPE)) + Content = content == null ? null : new StringContent(content, Encoding.UTF8, MEDIA_TYPE) }; var response = await _httpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); retriesRemaining--; diff --git a/Source/StrongGrid/Resources/Alerts.cs b/Source/StrongGrid/Resources/Alerts.cs index 09bf1d47..955d2cdf 100644 --- a/Source/StrongGrid/Resources/Alerts.cs +++ b/Source/StrongGrid/Resources/Alerts.cs @@ -7,13 +7,23 @@ namespace StrongGrid.Resources { + /// + /// Alerts allow you to specify an email address to receive notifications regarding your email usage or statistics. + /// - Usage alerts allow you to set the threshold at which an alert will be sent.For example, if you want to be + /// notified when you've used 90% of your current package's allotted emails, you would set the "percentage" + /// parameter to 90. + /// - Stats notifications allow you to set how frequently you would like to receive email + /// statistics reports.For example, if you want to receive your stats notifications every day, simply set the + /// "frequency" parameter to "daily". Stats notifications include data such as how many emails you sent each day, + /// in addition to other email events such as bounces, drops, unsubscribes, etc. + /// public class Alerts { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the Alerts class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html /// /// SendGrid Web API v3 client @@ -28,7 +38,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// Retrieve a specific alert. /// /// - /// + /// Cancellation token /// public async Task GetAsync(long alertId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -44,7 +54,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Retrieve all alerts. /// - /// + /// Cancellation token /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { @@ -59,6 +69,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Create a new alert /// + /// Cancellation token public async Task CreateAsync(AlertType type, string emailTo = null, Frequency? frequency = null, int? percentage = null, CancellationToken cancellationToken = default(CancellationToken)) { var data = CreateJObjectForAlert(type, emailTo, frequency, percentage); @@ -74,7 +85,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// Delete an alert. /// /// - /// + /// Cancellation token /// public async Task DeleteAsync(long alertId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -86,6 +97,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Update an alert. /// + /// Cancellation token public async Task UpdateAsync(long alertId, AlertType? type, string emailTo = null, Frequency? frequency = null, int? percentage = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, alertId); diff --git a/Source/StrongGrid/Resources/ApiKeys.cs b/Source/StrongGrid/Resources/ApiKeys.cs index 9ff3346a..93cb0c7e 100644 --- a/Source/StrongGrid/Resources/ApiKeys.cs +++ b/Source/StrongGrid/Resources/ApiKeys.cs @@ -10,13 +10,17 @@ namespace StrongGrid.Resources { + /// + /// API Keys allow you to generate an API Key credential which can be used for authentication + /// with the SendGrid v3 Web API, the v3 Mail Send endpoint, and the v2 Mail Send endpoint. + /// public class ApiKeys { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the APIKeys class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/index.html /// /// SendGrid Web API v3 client @@ -31,7 +35,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// Get an existing API Key /// /// - /// + /// Cancellation token /// public async Task GetAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -50,7 +54,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// The response does not include the permissions associated with each api key. /// In order to get the permission for a given key, you need to retrieve keys one at a time. /// - /// + /// Cancellation token /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { @@ -81,11 +85,11 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// /// - /// + /// Cancellation token /// public async Task CreateAsync(string name, IEnumerable scopes = null, CancellationToken cancellationToken = default(CancellationToken)) { - scopes = (scopes ?? Enumerable.Empty()); + scopes = scopes ?? Enumerable.Empty(); var data = CreateJObjectForApiKey(name, scopes); var response = await _client.PostAsync(_endpoint, data, cancellationToken).ConfigureAwait(false); @@ -100,7 +104,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// Revoke an existing API Key /// /// - /// + /// Cancellation token /// public async Task DeleteAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -114,11 +118,11 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// /// - /// + /// Cancellation token /// public async Task UpdateAsync(string keyId, string name, IEnumerable scopes = null, CancellationToken cancellationToken = default(CancellationToken)) { - scopes = (scopes ?? Enumerable.Empty()); + scopes = scopes ?? Enumerable.Empty(); HttpResponseMessage response = null; var data = CreateJObjectForApiKey(name, scopes); @@ -139,12 +143,12 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") } /// - /// Generate a new API Key for billing + /// Generate a new API Key for billing /// /// - /// + /// Cancellation token /// - public Task CreateWithBillingPermissionsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) + public Task CreateWithBillingPermissionsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) { var scopes = new[] { @@ -164,7 +168,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// If you specify a username and password when instanciating the , the new API Key will inherit the permissions of that user. /// /// - /// + /// Cancellation token /// public async Task CreateWithAllPermissionsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) { @@ -172,8 +176,8 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") var permissions = await _client.User.GetPermissionsAsync(cancellationToken).ConfigureAwait(false); // The SendGrid documentation clearly states: - // Billing permissions are mutually exclusive from all others. - // An API Key can either have Billing Permissions, or any other set of Permissions. + // Billing permissions are mutually exclusive from all others. + // An API Key can either have Billing Permissions, or any other set of Permissions. // Therefore it's important to exclude 'billing' permissions. permissions = permissions.Where(p => !p.StartsWith("Billing", StringComparison.OrdinalIgnoreCase)).ToArray(); diff --git a/Source/StrongGrid/Resources/Batches.cs b/Source/StrongGrid/Resources/Batches.cs index 8787a0b7..a9d375c7 100644 --- a/Source/StrongGrid/Resources/Batches.cs +++ b/Source/StrongGrid/Resources/Batches.cs @@ -13,7 +13,7 @@ public class Batches private readonly IClient _client; /// - /// Initializes a new instance of the Batches class. + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -26,7 +26,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// /// Generate a new Batch ID to associate with scheduled sends /// - /// + /// Cancellation token /// public async Task GenerateBatchIdAsync(CancellationToken cancellationToken = default(CancellationToken)) { @@ -49,7 +49,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// Validate whether or not a batch id is valid /// /// - /// + /// Cancellation token /// public async Task ValidateBatchIdAsync(string batchId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -96,7 +96,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled /// /// - /// + /// Cancellation token /// public async Task Cancel(string batchId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -113,7 +113,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// The Pause Scheduled Sends feature allows the customer to pause a scheduled send based on a Batch ID. /// /// - /// + /// Cancellation token /// public async Task Pause(string batchId, CancellationToken cancellationToken = default(CancellationToken)) { @@ -129,7 +129,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// /// Get all cancel/paused scheduled send information /// - /// + /// Cancellation token /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { @@ -145,7 +145,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// Delete the cancellation/pause of a scheduled send. /// /// - /// + /// Cancellation token /// public async Task Resume(string batchId, CancellationToken cancellationToken = default(CancellationToken)) { diff --git a/Source/StrongGrid/Resources/Blocks.cs b/Source/StrongGrid/Resources/Blocks.cs index 39d88527..cbff99a3 100644 --- a/Source/StrongGrid/Resources/Blocks.cs +++ b/Source/StrongGrid/Resources/Blocks.cs @@ -17,7 +17,7 @@ public class Blocks private readonly IClient _client; /// - /// Initializes a new instance of the Blocks class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/blocks.html /// /// SendGrid Web API v3 client @@ -31,7 +31,11 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Retrieve all blocks. /// - /// + /// + /// + /// + /// + /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { @@ -47,6 +51,7 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Retrieve a specific block. /// + /// Cancellation token public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); @@ -61,6 +66,7 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Delete all blocks. /// + /// Cancellation token public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -74,6 +80,7 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Delete multiple blocks. /// + /// Cancellation token public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -87,6 +94,7 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Delete a specific block. /// + /// Cancellation token public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Bounces.cs b/Source/StrongGrid/Resources/Bounces.cs index 49c367b7..d3d00e99 100644 --- a/Source/StrongGrid/Resources/Bounces.cs +++ b/Source/StrongGrid/Resources/Bounces.cs @@ -15,11 +15,11 @@ public class Bounces private readonly IClient _client; /// - /// Initializes a new instance of the Bounces class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Bounces(IClient client, string endpoint = "/suppression/bounces") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/Campaigns.cs b/Source/StrongGrid/Resources/Campaigns.cs index 58b31c44..b2796311 100644 --- a/Source/StrongGrid/Resources/Campaigns.cs +++ b/Source/StrongGrid/Resources/Campaigns.cs @@ -9,28 +9,49 @@ namespace StrongGrid.Resources { + /// + /// A campaign requires a title to be created. In order to send or schedule the campaign, + /// you will be required to provide a subject, sender ID, content (we suggest both html + /// and plain text), and at least one list or segment ID. + /// public class Campaigns { private string _endpoint; private IClient _client; /// - /// Initializes a new instance of the Campaigns class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html + /// Initializes a new instance of the class. + /// See also: https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Campaigns(IClient client, string endpoint = "/campaigns") { _endpoint = endpoint; _client = client; } + /// + /// Create a campaign. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Cancellation token + /// public async Task CreateAsync(string title, long suppressionGroupId, long senderId, string subject = null, string htmlContent = null, string textContent = null, IEnumerable listIds = null, IEnumerable segmentIds = null, IEnumerable categories = null, string customUnsubscribeUrl = null, string ipPool = null, CancellationToken cancellationToken = default(CancellationToken)) { - listIds = (listIds ?? Enumerable.Empty()); - segmentIds = (segmentIds ?? Enumerable.Empty()); - categories = (categories ?? Enumerable.Empty()); + listIds = listIds ?? Enumerable.Empty(); + segmentIds = segmentIds ?? Enumerable.Empty(); + categories = categories ?? Enumerable.Empty(); var data = CreateJObjectForCampaign(title, suppressionGroupId, senderId, subject, htmlContent, textContent, listIds, segmentIds, categories, customUnsubscribeUrl, ipPool); var response = await _client.PostAsync(_endpoint, data, cancellationToken).ConfigureAwait(false); @@ -41,6 +62,13 @@ public Campaigns(IClient client, string endpoint = "/campaigns") return campaign; } + /// + /// Retrieve all campaigns. + /// + /// + /// + /// Cancellation token + /// public async Task GetAllAsync(int limit = 10, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}?limit={1}&offset={2}", _endpoint, limit, offset); @@ -84,6 +112,12 @@ public Campaigns(IClient client, string endpoint = "/campaigns") return campaigns; } + /// + /// Retrieve a campaign. + /// + /// The id of the campaign + /// Cancellation token + /// public async Task GetAsync(long campaignId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, campaignId), cancellationToken).ConfigureAwait(false); @@ -94,17 +128,40 @@ public Campaigns(IClient client, string endpoint = "/campaigns") return campaign; } + /// + /// Delete a campaign. + /// + /// The id of the campaign + /// Cancellation token + /// public async Task DeleteAsync(long campaignId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}", _endpoint, campaignId), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Update a campaign + /// + /// The id of the campaign + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// Cancellation token + /// public async Task UpdateAsync(long campaignId, string title = null, long? suppressionGroupId = null, long? senderId = null, string subject = null, string htmlContent = null, string textContent = null, IEnumerable listIds = null, IEnumerable segmentIds = null, IEnumerable categories = null, string customUnsubscribeUrl = null, string ipPool = null, CancellationToken cancellationToken = default(CancellationToken)) { - listIds = (listIds ?? Enumerable.Empty()); - segmentIds = (segmentIds ?? Enumerable.Empty()); - categories = (categories ?? Enumerable.Empty()); + listIds = listIds ?? Enumerable.Empty(); + segmentIds = segmentIds ?? Enumerable.Empty(); + categories = categories ?? Enumerable.Empty(); var data = CreateJObjectForCampaign(title, suppressionGroupId, senderId, subject, htmlContent, textContent, listIds, segmentIds, categories, customUnsubscribeUrl, ipPool); var response = await _client.PatchAsync(string.Format("{0}/{1}", _endpoint, campaignId), data, cancellationToken).ConfigureAwait(false); @@ -115,6 +172,12 @@ public Campaigns(IClient client, string endpoint = "/campaigns") return campaign; } + /// + /// Send a campaign immediately. + /// + /// The id of the campaign + /// Cancellation token + /// public async Task SendNowAsync(long campaignId, CancellationToken cancellationToken = default(CancellationToken)) { var data = (JObject)null; @@ -122,6 +185,13 @@ public Campaigns(IClient client, string endpoint = "/campaigns") response.EnsureSuccess(); } + /// + /// Schedule a campaign to be sewnt at a later time. + /// + /// The id of the campaign + /// + /// Cancellation token + /// public async Task ScheduleAsync(long campaignId, DateTime sendOn, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -132,6 +202,13 @@ public Campaigns(IClient client, string endpoint = "/campaigns") response.EnsureSuccess(); } + /// + /// Change the date a campaign is scheduled to be sent + /// + /// The id of the campaign + /// + /// Cancellation token + /// public async Task RescheduleAsync(long campaignId, DateTime sendOn, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -142,6 +219,12 @@ public Campaigns(IClient client, string endpoint = "/campaigns") response.EnsureSuccess(); } + /// + /// Retrieve the date a campaign is scheduled to be sent + /// + /// The id of the campaign + /// Cancellation token + /// public async Task GetScheduledDateAsync(long campaignId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}/schedules", _endpoint, campaignId), cancellationToken).ConfigureAwait(false); @@ -162,15 +245,28 @@ public Campaigns(IClient client, string endpoint = "/campaigns") else return unixTime.FromUnixTime(); } + /// + /// Unschedule a scheduled campaign. + /// + /// The id of the campaign + /// Cancellation token + /// public async Task UnscheduleAsync(long campaignId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}/schedules", _endpoint, campaignId), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Send a test campaign + /// + /// The id of the campaign + /// + /// Cancellation token + /// public async Task SendTestAsync(long campaignId, IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { - emailAddresses = (emailAddresses ?? Enumerable.Empty()); + emailAddresses = emailAddresses ?? Enumerable.Empty(); if (!emailAddresses.Any()) throw new ArgumentException("You must specify at least one email address"); var data = new JObject(); diff --git a/Source/StrongGrid/Resources/Categories.cs b/Source/StrongGrid/Resources/Categories.cs index f94e0cf9..976caca0 100644 --- a/Source/StrongGrid/Resources/Categories.cs +++ b/Source/StrongGrid/Resources/Categories.cs @@ -6,23 +6,34 @@ namespace StrongGrid.Resources { + /// + /// Categories help organize your email analytics by enabling you to tag emails you send by topics you define. + /// public class Categories { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the Categories class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Categories/categories.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Categories(IClient client, string endpoint = "/categories") { _endpoint = endpoint; _client = client; } + /// + /// Retrieve a list of your categories. + /// + /// Performs a prefix search on this value. + /// Optional field to limit the number of results returned. + /// Optional beginning point in the list to retrieve from. + /// Cancellation token + /// public async Task GetAsync(string searchPrefix = null, int limit = 50, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}?category={1}&limit={2}&offset={3}", _endpoint, searchPrefix, limit, offset); diff --git a/Source/StrongGrid/Resources/Contacts.cs b/Source/StrongGrid/Resources/Contacts.cs index 18e29bed..1947e029 100644 --- a/Source/StrongGrid/Resources/Contacts.cs +++ b/Source/StrongGrid/Resources/Contacts.cs @@ -15,11 +15,11 @@ public class Contacts private readonly IClient _client; /// - /// Initializes a new instance of the Recipients class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Contacts(IClient client, string endpoint = "/contactdb/recipients") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/CustomFields.cs b/Source/StrongGrid/Resources/CustomFields.cs index b4c4fd06..0d2d9c1a 100644 --- a/Source/StrongGrid/Resources/CustomFields.cs +++ b/Source/StrongGrid/Resources/CustomFields.cs @@ -14,11 +14,11 @@ public class CustomFields private readonly IClient _client; /// - /// Initializes a new instance of the Recipients class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public CustomFields(IClient client, string endpoint = "/contactdb/custom_fields") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/GlobalSuppressions.cs b/Source/StrongGrid/Resources/GlobalSuppressions.cs index d4fa349b..95480551 100644 --- a/Source/StrongGrid/Resources/GlobalSuppressions.cs +++ b/Source/StrongGrid/Resources/GlobalSuppressions.cs @@ -13,11 +13,11 @@ public class GlobalSuppressions private readonly IClient _client; /// - /// Initializes a new instance of the Global Suppressions class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public GlobalSuppressions(IClient client, string endpoint = "/asm/suppressions/global") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/InvalidEmails.cs b/Source/StrongGrid/Resources/InvalidEmails.cs index ebdfeae5..7be4df1d 100644 --- a/Source/StrongGrid/Resources/InvalidEmails.cs +++ b/Source/StrongGrid/Resources/InvalidEmails.cs @@ -16,7 +16,7 @@ public class InvalidEmails private readonly IClient _client; /// - /// Initializes a new instance of the InvalidEmails class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html /// /// SendGrid Web API v3 client @@ -30,7 +30,11 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Retrieve all invalid emails. /// - /// + /// + /// + /// + /// + /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { @@ -46,6 +50,7 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Retrieve a specific invalid email. /// + /// Cancellation token public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); @@ -60,6 +65,7 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Delete all invalid emails. /// + /// Cancellation token public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -73,6 +79,7 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Delete multiple invalid emails. /// + /// Cancellation token public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -86,6 +93,7 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Delete a specific invalid emails. /// + /// Cancellation token public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Lists.cs b/Source/StrongGrid/Resources/Lists.cs index bcf08520..233d97d0 100644 --- a/Source/StrongGrid/Resources/Lists.cs +++ b/Source/StrongGrid/Resources/Lists.cs @@ -14,11 +14,11 @@ public class Lists private readonly IClient _client; /// - /// Initializes a new instance of the Lists class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Lists(IClient client, string endpoint = "/contactdb/lists") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/Mail.cs b/Source/StrongGrid/Resources/Mail.cs index 8b8302cd..7495f053 100644 --- a/Source/StrongGrid/Resources/Mail.cs +++ b/Source/StrongGrid/Resources/Mail.cs @@ -15,7 +15,7 @@ public class Mail private readonly IClient _client; /// - /// Initializes a new instance of the Mail class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html /// /// SendGrid Web API v3 client @@ -112,6 +112,7 @@ public Task SendToMultipleRecipientsAsync( /// /// Send email(s) over SendGrid’s v3 Web API /// + /// Cancellation token public async Task SendAsync( IEnumerable personalizations, string subject, diff --git a/Source/StrongGrid/Resources/Segments.cs b/Source/StrongGrid/Resources/Segments.cs index 0041d7a6..006f64cb 100644 --- a/Source/StrongGrid/Resources/Segments.cs +++ b/Source/StrongGrid/Resources/Segments.cs @@ -14,11 +14,11 @@ public class Segments private readonly IClient _client; /// - /// Initializes a new instance of the Campaigns class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Segments(IClient client, string endpoint = "/contactdb/segments") { _endpoint = endpoint; @@ -27,7 +27,7 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") public async Task CreateAsync(string name, long listId, IEnumerable conditions, CancellationToken cancellationToken = default(CancellationToken)) { - conditions = (conditions ?? Enumerable.Empty()); + conditions = conditions ?? Enumerable.Empty(); var data = new JObject { @@ -89,7 +89,7 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") public async Task UpdateAsync(long segmentId, string name = null, long? listId = null, IEnumerable conditions = null, CancellationToken cancellationToken = default(CancellationToken)) { - conditions = (conditions ?? Enumerable.Empty()); + conditions = conditions ?? Enumerable.Empty(); var data = new JObject(); if (!string.IsNullOrEmpty(name)) data.Add("name", name); diff --git a/Source/StrongGrid/Resources/SenderIdentities.cs b/Source/StrongGrid/Resources/SenderIdentities.cs index e7963a0e..36be295c 100644 --- a/Source/StrongGrid/Resources/SenderIdentities.cs +++ b/Source/StrongGrid/Resources/SenderIdentities.cs @@ -12,11 +12,11 @@ public class SenderIdentities private readonly IClient _client; /// - /// Initializes a new instance of the SenderIdentities class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/sender_identities.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public SenderIdentities(IClient client, string endpoint = "/senders") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/Settings.cs b/Source/StrongGrid/Resources/Settings.cs index edfc83fd..0850f0b0 100644 --- a/Source/StrongGrid/Resources/Settings.cs +++ b/Source/StrongGrid/Resources/Settings.cs @@ -14,11 +14,11 @@ public class Settings private readonly IClient _client; /// - /// Initializes a new instance of the Settings class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/index.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Settings(IClient client, string endpoint = "/settings") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/SpamReports.cs b/Source/StrongGrid/Resources/SpamReports.cs index 7beefe9b..c66a1e75 100644 --- a/Source/StrongGrid/Resources/SpamReports.cs +++ b/Source/StrongGrid/Resources/SpamReports.cs @@ -15,7 +15,7 @@ public class SpamReports private readonly IClient _client; /// - /// Initializes a new instance of the SpamReport class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/spam_reports.html /// /// SendGrid Web API v3 client @@ -30,7 +30,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// Retrieve a specific spam report. /// /// - /// + /// Cancellation token /// public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { @@ -46,7 +46,11 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// List all spam reports. /// - /// + /// + /// + /// + /// + /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { @@ -62,6 +66,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Delete all spam reports. /// + /// Cancellation token public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -75,6 +80,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Delete multiple spam reports. /// + /// Cancellation token public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -88,6 +94,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Delete a specific spam report. /// + /// Cancellation token public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Statistics.cs b/Source/StrongGrid/Resources/Statistics.cs index fb765567..e30b66ed 100644 --- a/Source/StrongGrid/Resources/Statistics.cs +++ b/Source/StrongGrid/Resources/Statistics.cs @@ -16,11 +16,11 @@ public class Statistics private readonly IClient _client; /// - /// Initializes a new instance of the Statistics class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/index.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Statistics(IClient client, string endpoint = "/stats") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/Suppressions.cs b/Source/StrongGrid/Resources/Suppressions.cs index 3339af5b..d845f206 100644 --- a/Source/StrongGrid/Resources/Suppressions.cs +++ b/Source/StrongGrid/Resources/Suppressions.cs @@ -14,11 +14,11 @@ public class Suppressions private readonly IClient _client; /// - /// Initializes a new instance of the Suppressions class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Suppressions(IClient client, string endpoint = "/asm/groups") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/Templates.cs b/Source/StrongGrid/Resources/Templates.cs index b9ea7b56..fb201b80 100644 --- a/Source/StrongGrid/Resources/Templates.cs +++ b/Source/StrongGrid/Resources/Templates.cs @@ -12,11 +12,11 @@ public class Templates private readonly IClient _client; /// - /// Initializes a new instance of the Templates class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Transactional_Templates/templates.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Templates(IClient client, string endpoint = "/templates") { _endpoint = endpoint; diff --git a/Source/StrongGrid/Resources/UnsubscribeGroups.cs b/Source/StrongGrid/Resources/UnsubscribeGroups.cs index 598b4214..790c7ed8 100644 --- a/Source/StrongGrid/Resources/UnsubscribeGroups.cs +++ b/Source/StrongGrid/Resources/UnsubscribeGroups.cs @@ -12,11 +12,11 @@ public class UnsubscribeGroups private readonly IClient _client; /// - /// Initializes a new instance of the UnsubscribeGroups class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public UnsubscribeGroups(IClient client, string endpoint = "/asm/groups") { _endpoint = endpoint; @@ -78,8 +78,10 @@ public UnsubscribeGroups(IClient client, string endpoint = "/asm/groups") /// /// Update an existing suppression group. /// + /// /// The name of the new suppression group /// A description of the suppression group + /// Cancellation token /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html public async Task UpdateAsync(int groupId, string name = null, string description = null, CancellationToken cancellationToken = default(CancellationToken)) { diff --git a/Source/StrongGrid/Resources/User.cs b/Source/StrongGrid/Resources/User.cs index 91725bdf..d4333800 100644 --- a/Source/StrongGrid/Resources/User.cs +++ b/Source/StrongGrid/Resources/User.cs @@ -14,11 +14,11 @@ public class User private readonly IClient _client; /// - /// Initializes a new instance of the Users class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/user.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public User(IClient client, string endpoint = "/user/profile") { _endpoint = endpoint; @@ -186,7 +186,7 @@ public User(IClient client, string endpoint = "/user/profile") /// /// List all available scopes for a user /// - /// + /// Cancellation token /// public async Task GetPermissionsAsync(CancellationToken cancellationToken = default(CancellationToken)) { @@ -199,17 +199,17 @@ public User(IClient client, string endpoint = "/user/profile") // The fact that the charset is slightly misspelled prevents the .Net HttpClient from // being able to parse the body of the reponse. The HttpClient throws the following exception // when we try to get the content of the response like so: response.Content.ReadAsStreamAsync() - // The character set provided in ContentType is invalid. Cannot read content as string using - // an invalid character set. System.ArgumentException: 'utf8' is not a supported encoding name - + // The character set provided in ContentType is invalid. Cannot read content as string using + // an invalid character set. System.ArgumentException: 'utf8' is not a supported encoding name + // I contacted SendGrid on 11/23/2016 to report this problem: https://support.sendgrid.com/hc/en-us/requests/806220 - + // A support engineer from SendGrid confirmed the issue on 11/24/2016 and said: - // I will put in a new feature request to our engineers to see if they will be able to have - // the charset removed from that API call + // I will put in a new feature request to our engineers to see if they will be able to have + // the charset removed from that API call // Until SendGrid solves the problem on their end by either omiting the charset or fixing the misspelling, - // we must read the content into a stream and convert the stream to a string which allows us to specify + // we must read the content into a stream and convert the stream to a string which allows us to specify // the desired charset (which is Encoding.UTF8 in this case). var responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); var responseContent = string.Empty; diff --git a/Source/StrongGrid/Resources/Whitelabel.cs b/Source/StrongGrid/Resources/Whitelabel.cs index e0e3c01c..77ae2490 100644 --- a/Source/StrongGrid/Resources/Whitelabel.cs +++ b/Source/StrongGrid/Resources/Whitelabel.cs @@ -12,11 +12,11 @@ public class Whitelabel private readonly IClient _client; /// - /// Initializes a new instance of the Whitelabel class. + /// Initializes a new instance of the class. /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/domains.html /// /// SendGrid Web API v3 client - /// Resource endpoint, do not prepend slash + /// Resource endpoint public Whitelabel(IClient client, string endpoint = "/whitelabel") { _endpoint = endpoint; @@ -49,6 +49,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Get a specific domain whitelabel /// + /// Cancellation token public async Task GetDomainAsync(long domainId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}", _endpoint, domainId); @@ -63,6 +64,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Create a new domain whitelabel /// + /// Cancellation token public async Task CreateDomainAsync(string domain, string subdomain, bool automaticSecurity = false, bool customSpf = false, bool isDefault = false, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains", _endpoint); @@ -85,6 +87,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Update a whitelabel domain. /// + /// Cancellation token public async Task UpdateDomainAsync(long domainId, bool isDefault = false, bool customSpf = false, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}", _endpoint, domainId); @@ -104,6 +107,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Delete a whitelabel domain. /// + /// Cancellation token public async Task DeleteDomainAsync(long id, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}", _endpoint, id); @@ -114,6 +118,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Add an IP to a Domain /// + /// Cancellation token public async Task AddIpAddressToDomainAsync(long domainId, string ipAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}/ips", _endpoint, domainId); @@ -132,6 +137,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Remove an IP from a Domain /// + /// Cancellation token public async Task DeleteIpAddressFromDomainAsync(long domainId, string ipAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}/ips/{2}", _endpoint, domainId, ipAddress); @@ -146,6 +152,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Validate a Domain /// + /// Cancellation token public async Task ValidateDomainAsync(long domainId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}/validate", _endpoint, domainId); @@ -166,6 +173,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// parent account must first create a Whitelabel and validate it. Then the parent may associate /// the Whitelabel in subuser management. /// + /// Cancellation token public async Task GetAssociatedDomainAsync(string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/subuser?username={1}", _endpoint, username); @@ -180,6 +188,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Disassociate Domain /// + /// Cancellation token public async Task DisassociateDomainAsync(string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/subuser?username={1}", _endpoint, username); @@ -190,6 +199,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Associate Domain /// + /// Cancellation token public async Task AssociateDomainAsync(long domainId, string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/domains/{1}/subuser", _endpoint, domainId); @@ -215,6 +225,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// the IP. /// /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html + /// Cancellation token public async Task GetAllIpsAsync(string segmentPrefix = null, int limit = 50, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/ips?limit={1}&offset={2}&ip={3}", _endpoint, limit, offset, segmentPrefix); @@ -230,6 +241,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// Get a specific IP whitelabel /// /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/ips.html + /// Cancellation token public async Task GetIpAsync(long id, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/ips/{1}", _endpoint, id); @@ -244,6 +256,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Create an IP /// + /// Cancellation token public async Task CreateIpAsync(string ipAddress, string domain, string subdomain, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/ips", _endpoint); @@ -264,6 +277,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Delete an IP /// + /// Cancellation token public async Task DeleteIpAsync(long ipId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/ips/{1}", _endpoint, ipId); @@ -274,6 +288,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Validate an IP /// + /// Cancellation token public async Task ValidateIpAsync(long ipId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/ips/{1}/validate", _endpoint, ipId); @@ -294,6 +309,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// rewritten to and for us to verify that they are the domain owners. /// /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Whitelabel/links.html + /// Cancellation token public async Task GetAllLinksAsync(string segmentPrefix = null, int limit = 50, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links?limit={1}&offset={2}&ip={3}", _endpoint, limit, offset, segmentPrefix); @@ -308,6 +324,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Get a specific Link whitelabel /// + /// Cancellation token public async Task GetLinkAsync(long id, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/{1}", _endpoint, id); @@ -322,6 +339,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Create a Link /// + /// Cancellation token public async Task CreateLinkAsync(string domain, string subdomain, bool isDefault, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links", _endpoint); @@ -342,6 +360,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Update a Link /// + /// Cancellation token public async Task UpdateLinkAsync(long linkId, bool isDefault, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/{1}", _endpoint, linkId); @@ -360,6 +379,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Delete a link /// + /// Cancellation token public async Task DeleteLinkAsync(long linkId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/{1}", _endpoint, linkId); @@ -370,6 +390,7 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Get the default link for a domain /// + /// Cancellation token public async Task GetDefaultLinkAsync(string domain, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/default?domain={1}", _endpoint, domain); @@ -384,6 +405,8 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Validate a link /// + /// + /// Cancellation token public async Task ValidateLinkAsync(long linkId, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/{1}/validate", _endpoint, linkId); @@ -404,6 +427,8 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// account must first create a Whitelabel and validate it. Then the parent may associate the /// Whitelabel in subuser management. /// + /// + /// Cancellation token public async Task GetAssociatedLinkAsync(string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/subuser?username={1}", _endpoint, username); @@ -418,6 +443,8 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Disassociate Link /// + /// + /// Cancellation token public async Task DisassociateLinkAsync(string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/subuser?username={1}", _endpoint, username); @@ -428,6 +455,9 @@ public Whitelabel(IClient client, string endpoint = "/whitelabel") /// /// Associate Link /// + /// + /// + /// Cancellation token public async Task AssociateLinkAsync(long linkId, string username = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/links/{1}/subuser", _endpoint, linkId); diff --git a/Source/StrongGrid/Utilities/Extensions.cs b/Source/StrongGrid/Utilities/Extensions.cs index a495c345..8afc5e94 100644 --- a/Source/StrongGrid/Utilities/Extensions.cs +++ b/Source/StrongGrid/Utilities/Extensions.cs @@ -46,7 +46,9 @@ public static void EnsureSuccess(this HttpResponseMessage response) dynamic firstError = dynamicArray.First; content = firstError.message.ToString(); +#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body } catch +#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body { // Intentionally ignore parsing errors } diff --git a/nuspec/StrongGrid.nuspec b/nuspec/StrongGrid.nuspec index 6166c4dd..ced4e54b 100644 --- a/nuspec/StrongGrid.nuspec +++ b/nuspec/StrongGrid.nuspec @@ -43,14 +43,18 @@ + + + + - + From e60e648e9c8c484c44b4df786781a3048745a923 Mon Sep 17 00:00:00 2001 From: Jeremie Desautels Date: Sun, 27 Nov 2016 21:59:44 -0600 Subject: [PATCH 04/24] More xml comments (#76) --- Source/StrongGrid/Client.cs | 93 +++++++++-- Source/StrongGrid/Resources/Alerts.cs | 21 ++- Source/StrongGrid/Resources/ApiKeys.cs | 36 +++-- Source/StrongGrid/Resources/Batches.cs | 10 +- Source/StrongGrid/Resources/Blocks.cs | 24 ++- Source/StrongGrid/Resources/Bounces.cs | 29 +++- Source/StrongGrid/Resources/Campaigns.cs | 61 +++---- Source/StrongGrid/Resources/Categories.cs | 6 +- Source/StrongGrid/Resources/Contacts.cs | 77 ++++++++- Source/StrongGrid/Resources/CustomFields.cs | 38 ++++- .../Resources/GlobalSuppressions.cs | 18 ++- Source/StrongGrid/Resources/InvalidEmails.cs | 24 ++- Source/StrongGrid/Resources/Lists.cs | 74 ++++++++- Source/StrongGrid/Resources/Mail.cs | 72 ++++++++- Source/StrongGrid/Resources/Segments.cs | 52 +++++- .../StrongGrid/Resources/SenderIdentities.cs | 61 ++++++- Source/StrongGrid/Resources/Settings.cs | 152 ++++++++++++++---- Source/StrongGrid/Resources/SpamReports.cs | 24 ++- Source/StrongGrid/Resources/Statistics.cs | 17 +- Source/StrongGrid/Resources/Suppressions.cs | 139 ++++++++-------- Source/StrongGrid/Resources/Templates.cs | 83 +++++++++- .../StrongGrid/Resources/UnsubscribeGroups.cs | 26 ++- Source/StrongGrid/Resources/User.cs | 50 ++++-- Source/StrongGrid/Resources/Whitelabel.cs | 102 ++++++++++-- Source/StrongGrid/Utilities/Extensions.cs | 17 ++ 25 files changed, 1053 insertions(+), 253 deletions(-) diff --git a/Source/StrongGrid/Client.cs b/Source/StrongGrid/Client.cs index f454623e..9a883a46 100644 --- a/Source/StrongGrid/Client.cs +++ b/Source/StrongGrid/Client.cs @@ -42,116 +42,185 @@ private enum Methods /// /// Gets the Alerts resource which allows you to receive notifications regarding your email usage or statistics. /// + /// + /// The alerts. + /// public Alerts Alerts { get; private set; } /// /// Gets the API Keys resource which allows you to manage your API Keys. /// + /// + /// The API keys. + /// public ApiKeys ApiKeys { get; private set; } /// /// Gets the Batches resource. /// + /// + /// The batches. + /// public Batches Batches { get; private set; } /// /// Gets the Blocks resource which allows you to manage blacked email addresses. /// + /// + /// The blocks. + /// public Blocks Blocks { get; private set; } /// /// Gets the Campaigns resource which allows you to manage your campaigns. /// + /// + /// The campaigns. + /// public Campaigns Campaigns { get; private set; } /// /// Gets the Categories resource which allows you to manages your categories. /// + /// + /// The categories. + /// public Categories Categories { get; private set; } /// /// Gets the Contacts resource which allows you to manage your contacts (also sometimes refered to as 'recipients'). /// + /// + /// The contacts. + /// public Contacts Contacts { get; private set; } /// /// Gets the CustomFields resource which allows you to manage your custom fields. /// + /// + /// The custom fields. + /// public CustomFields CustomFields { get; private set; } /// /// Gets the GlobalSuppressions resource. /// + /// + /// The global suppressions. + /// public GlobalSuppressions GlobalSuppressions { get; private set; } /// /// Gets the InvalidEmails resource. /// + /// + /// The invalid emails. + /// public InvalidEmails InvalidEmails { get; private set; } /// /// Gets the Lists resource. /// + /// + /// The lists. + /// public Lists Lists { get; private set; } /// /// Gets the Mail resource. /// + /// + /// The mail. + /// public Mail Mail { get; private set; } /// /// Gets the Segments resource. /// + /// + /// The segments. + /// public Segments Segments { get; private set; } /// /// Gets the SenderIdentities resource. /// + /// + /// The sender identities. + /// public SenderIdentities SenderIdentities { get; private set; } /// /// Gets the Settings resource. /// + /// + /// The settings. + /// public Settings Settings { get; private set; } /// /// Gets the SpamReports resource. /// + /// + /// The spam reports. + /// public SpamReports SpamReports { get; private set; } /// /// Gets the Statistics resource. /// + /// + /// The statistics. + /// public Statistics Statistics { get; private set; } /// /// Gets the Suppressions resource. /// + /// + /// The suppressions. + /// public Suppressions Suppressions { get; private set; } /// /// Gets the Templates resource. /// + /// + /// The templates. + /// public Templates Templates { get; private set; } /// /// Gets the UnsubscribeGroups resource. /// + /// + /// The unsubscribe groups. + /// public UnsubscribeGroups UnsubscribeGroups { get; private set; } /// /// Gets the User resource. /// + /// + /// The user. + /// public User User { get; private set; } /// /// Gets the Version. /// + /// + /// The version. + /// public string Version { get; private set; } /// /// Gets the Whitelabel resource. /// + /// + /// The whitelabel. + /// public Whitelabel Whitelabel { get; private set; } #endregion @@ -280,7 +349,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task GetAsync(string endpoint, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.GET, endpoint, (JObject)null, cancellationToken); @@ -289,7 +358,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task PostAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.POST, endpoint, data, cancellationToken); @@ -298,7 +367,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JArray representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task PostAsync(string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.POST, endpoint, data, cancellationToken); @@ -306,7 +375,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task DeleteAsync(string endpoint, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.DELETE, endpoint, (JObject)null, cancellationToken); @@ -315,7 +384,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An optional JObject representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task DeleteAsync(string endpoint, JObject data = null, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.DELETE, endpoint, data, cancellationToken); @@ -324,7 +393,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An optional JArray representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task DeleteAsync(string endpoint, JArray data = null, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.DELETE, endpoint, data, cancellationToken); @@ -333,7 +402,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task PatchAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.PATCH, endpoint, data, cancellationToken); @@ -342,7 +411,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JArray representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task PatchAsync(string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.PATCH, endpoint, data, cancellationToken); @@ -351,7 +420,7 @@ private Client(string apiKey, string username, string password, string baseUri, /// Resource endpoint /// An JObject representing the resource's data /// Cancellation token - /// The resulting message from the API call + /// The response from the HTTP request public Task PutAsync(string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { return RequestAsync(Methods.PUT, endpoint, data, cancellationToken); @@ -392,7 +461,7 @@ protected virtual void Dispose(bool disposing) /// Resource endpoint /// An JObject representing the resource's data /// Cancellation token - /// An asyncronous task + /// The response from the HTTP request private Task RequestAsync(Methods method, string endpoint, JObject data, CancellationToken cancellationToken = default(CancellationToken)) { var content = data?.ToString(); @@ -406,7 +475,7 @@ protected virtual void Dispose(bool disposing) /// Resource endpoint /// An JArray representing the resource's data /// Cancellation token - /// An asyncronous task + /// The response from the HTTP request private Task RequestAsync(Methods method, string endpoint, JArray data, CancellationToken cancellationToken = default(CancellationToken)) { var content = data?.ToString(); @@ -421,7 +490,7 @@ protected virtual void Dispose(bool disposing) /// A string representing the content of the http request /// The number of retries remaining in case SendGrid responds with HTTP 429 (aka TOO MANY REQUESTS) /// Cancellation token - /// An asyncronous task + /// The response from the HTTP request private async Task RequestAsync(Methods method, string endpoint, string content, int retriesRemaining, CancellationToken cancellationToken = default(CancellationToken)) { try diff --git a/Source/StrongGrid/Resources/Alerts.cs b/Source/StrongGrid/Resources/Alerts.cs index 955d2cdf..2bd6749d 100644 --- a/Source/StrongGrid/Resources/Alerts.cs +++ b/Source/StrongGrid/Resources/Alerts.cs @@ -17,14 +17,16 @@ namespace StrongGrid.Resources /// "frequency" parameter to "daily". Stats notifications include data such as how many emails you sent each day, /// in addition to other email events such as bounces, drops, unsubscribes, etc. /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html + /// public class Alerts { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -37,7 +39,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Retrieve a specific alert. /// - /// + /// The alert identifier. /// Cancellation token /// public async Task GetAsync(long alertId, CancellationToken cancellationToken = default(CancellationToken)) @@ -69,7 +71,12 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Create a new alert /// + /// The type. + /// The email to. + /// The frequency. + /// The percentage. /// Cancellation token + /// public async Task CreateAsync(AlertType type, string emailTo = null, Frequency? frequency = null, int? percentage = null, CancellationToken cancellationToken = default(CancellationToken)) { var data = CreateJObjectForAlert(type, emailTo, frequency, percentage); @@ -84,7 +91,7 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Delete an alert. /// - /// + /// The alert identifier. /// Cancellation token /// public async Task DeleteAsync(long alertId, CancellationToken cancellationToken = default(CancellationToken)) @@ -97,7 +104,13 @@ public Alerts(IClient client, string endpoint = "/alerts") /// /// Update an alert. /// + /// The alert identifier. + /// The type. + /// The email to. + /// The frequency. + /// The percentage. /// Cancellation token + /// public async Task UpdateAsync(long alertId, AlertType? type, string emailTo = null, Frequency? frequency = null, int? percentage = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, alertId); diff --git a/Source/StrongGrid/Resources/ApiKeys.cs b/Source/StrongGrid/Resources/ApiKeys.cs index 93cb0c7e..732c1910 100644 --- a/Source/StrongGrid/Resources/ApiKeys.cs +++ b/Source/StrongGrid/Resources/ApiKeys.cs @@ -14,14 +14,16 @@ namespace StrongGrid.Resources /// API Keys allow you to generate an API Key credential which can be used for authentication /// with the SendGrid v3 Web API, the v3 Mail Send endpoint, and the v2 Mail Send endpoint. /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/index.html + /// public class ApiKeys { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/index.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -34,7 +36,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Get an existing API Key /// - /// + /// The key identifier. /// Cancellation token /// public async Task GetAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken)) @@ -50,12 +52,12 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Get all API Keys belonging to the authenticated user /// + /// Cancellation token + /// /// /// The response does not include the permissions associated with each api key. /// In order to get the permission for a given key, you need to retrieve keys one at a time. /// - /// Cancellation token - /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint, cancellationToken).ConfigureAwait(false); @@ -83,8 +85,8 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Generate a new API Key /// - /// - /// + /// The name. + /// The scopes. /// Cancellation token /// public async Task CreateAsync(string name, IEnumerable scopes = null, CancellationToken cancellationToken = default(CancellationToken)) @@ -103,7 +105,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Revoke an existing API Key /// - /// + /// The key identifier. /// Cancellation token /// public async Task DeleteAsync(string keyId, CancellationToken cancellationToken = default(CancellationToken)) @@ -115,9 +117,9 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Update an API Key /// - /// - /// - /// + /// The key identifier. + /// The name. + /// The scopes. /// Cancellation token /// public async Task UpdateAsync(string keyId, string name, IEnumerable scopes = null, CancellationToken cancellationToken = default(CancellationToken)) @@ -145,7 +147,7 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Generate a new API Key for billing /// - /// + /// The name. /// Cancellation token /// public Task CreateWithBillingPermissionsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) @@ -163,13 +165,13 @@ public ApiKeys(IClient client, string endpoint = "/api_keys") /// /// Generate a new API Key with all permissions /// - /// - /// If you specify an API Key when instanciating the , the new API Key will inherit the permissions of that API Key. - /// If you specify a username and password when instanciating the , the new API Key will inherit the permissions of that user. - /// - /// + /// The name. /// Cancellation token /// + /// + /// If you specify an API Key when instanciating the , the new API Key will inherit the permissions of that API Key. + /// If you specify a username and password when instanciating the , the new API Key will inherit the permissions of that user. + /// public async Task CreateWithAllPermissionsAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) { // Get the current user's permissions diff --git a/Source/StrongGrid/Resources/Batches.cs b/Source/StrongGrid/Resources/Batches.cs index a9d375c7..9232bfd2 100644 --- a/Source/StrongGrid/Resources/Batches.cs +++ b/Source/StrongGrid/Resources/Batches.cs @@ -13,7 +13,7 @@ public class Batches private readonly IClient _client; /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -48,7 +48,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// /// Validate whether or not a batch id is valid /// - /// + /// The batch identifier. /// Cancellation token /// public async Task ValidateBatchIdAsync(string batchId, CancellationToken cancellationToken = default(CancellationToken)) @@ -95,7 +95,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// The Cancel Scheduled Sends feature allows the customer to cancel a scheduled send based on a Batch ID. /// Scheduled sends cancelled less than 10 minutes before the scheduled time are not guaranteed to be cancelled /// - /// + /// The batch identifier. /// Cancellation token /// public async Task Cancel(string batchId, CancellationToken cancellationToken = default(CancellationToken)) @@ -112,7 +112,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// /// The Pause Scheduled Sends feature allows the customer to pause a scheduled send based on a Batch ID. /// - /// + /// The batch identifier. /// Cancellation token /// public async Task Pause(string batchId, CancellationToken cancellationToken = default(CancellationToken)) @@ -144,7 +144,7 @@ public Batches(IClient client, string endpoint = "/mail/batch") /// /// Delete the cancellation/pause of a scheduled send. /// - /// + /// The batch identifier. /// Cancellation token /// public async Task Resume(string batchId, CancellationToken cancellationToken = default(CancellationToken)) diff --git a/Source/StrongGrid/Resources/Blocks.cs b/Source/StrongGrid/Resources/Blocks.cs index cbff99a3..ee7d4a75 100644 --- a/Source/StrongGrid/Resources/Blocks.cs +++ b/Source/StrongGrid/Resources/Blocks.cs @@ -11,14 +11,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/blocks.html + /// public class Blocks { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/blocks.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -31,10 +36,10 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Retrieve all blocks. /// - /// - /// - /// - /// + /// The start date. + /// The end date. + /// The limit. + /// The offset. /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) @@ -51,7 +56,9 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Retrieve a specific block. /// + /// The email address. /// Cancellation token + /// public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); @@ -67,6 +74,7 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// Delete all blocks. /// /// Cancellation token + /// public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -80,7 +88,9 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Delete multiple blocks. /// + /// The email addresses. /// Cancellation token + /// public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -94,7 +104,9 @@ public Blocks(IClient client, string endpoint = "/suppression/blocks") /// /// Delete a specific block. /// + /// The email address. /// Cancellation token + /// public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Bounces.cs b/Source/StrongGrid/Resources/Bounces.cs index d3d00e99..4488a49b 100644 --- a/Source/StrongGrid/Resources/Bounces.cs +++ b/Source/StrongGrid/Resources/Bounces.cs @@ -9,14 +9,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// public class Bounces { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -29,7 +34,10 @@ public Bounces(IClient client, string endpoint = "/suppression/bounces") /// /// Get a list of bounces /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// The start. + /// The end. + /// The cancellation token. + /// public async Task GetAsync(DateTime? start = null, DateTime? end = null, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}?start_time={1}&end_time={2}", _endpoint, start.Value.ToUnixTime().ToString(), end.Value.ToUnixTime().ToString()); @@ -44,7 +52,9 @@ public Bounces(IClient client, string endpoint = "/suppression/bounces") /// /// Get a list of bounces for a given email address /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// The email. + /// The cancellation token. + /// public async Task GetAsync(string email, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, email), cancellationToken).ConfigureAwait(false); @@ -58,7 +68,8 @@ public Bounces(IClient client, string endpoint = "/suppression/bounces") /// /// Delete all bounces /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// The cancellation token. + /// public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(new JProperty("delete_all", true)); @@ -69,7 +80,9 @@ public Bounces(IClient client, string endpoint = "/suppression/bounces") /// /// Delete bounces for a specified group of email addresses /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// The emails. + /// The cancellation token. + /// public async Task DeleteAsync(IEnumerable emails, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(new JProperty("emails", JArray.FromObject(emails.ToArray()))); @@ -80,7 +93,9 @@ public Bounces(IClient client, string endpoint = "/suppression/bounces") /// /// Delete bounces for a specified email address /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/bounces.html + /// The email. + /// The cancellation token. + /// public async Task DeleteAsync(string email, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}", _endpoint, email), cancellationToken).ConfigureAwait(false); diff --git a/Source/StrongGrid/Resources/Campaigns.cs b/Source/StrongGrid/Resources/Campaigns.cs index b2796311..a04ce5e7 100644 --- a/Source/StrongGrid/Resources/Campaigns.cs +++ b/Source/StrongGrid/Resources/Campaigns.cs @@ -14,14 +14,16 @@ namespace StrongGrid.Resources /// you will be required to provide a subject, sender ID, content (we suggest both html /// and plain text), and at least one list or segment ID. /// + /// + /// See also: https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html + /// public class Campaigns { private string _endpoint; private IClient _client; /// - /// Initializes a new instance of the class. - /// See also: https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -34,17 +36,17 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// /// Create a campaign. /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// The title. + /// The suppression group identifier. + /// The sender identifier. + /// The subject. + /// Content of the HTML. + /// Content of the text. + /// The list ids. + /// The segment ids. + /// The categories. + /// The custom unsubscribe URL. + /// The ip pool. /// Cancellation token /// public async Task CreateAsync(string title, long suppressionGroupId, long senderId, string subject = null, string htmlContent = null, string textContent = null, IEnumerable listIds = null, IEnumerable segmentIds = null, IEnumerable categories = null, string customUnsubscribeUrl = null, string ipPool = null, CancellationToken cancellationToken = default(CancellationToken)) @@ -65,8 +67,8 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// /// Retrieve all campaigns. /// - /// - /// + /// The limit. + /// The offset. /// Cancellation token /// public async Task GetAllAsync(int limit = 10, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) @@ -144,17 +146,17 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// Update a campaign /// /// The id of the campaign - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /// The title. + /// The suppression group identifier. + /// The sender identifier. + /// The subject. + /// Content of the HTML. + /// Content of the text. + /// The list ids. + /// The segment ids. + /// The categories. + /// The custom unsubscribe URL. + /// The ip pool. /// Cancellation token /// public async Task UpdateAsync(long campaignId, string title = null, long? suppressionGroupId = null, long? senderId = null, string subject = null, string htmlContent = null, string textContent = null, IEnumerable listIds = null, IEnumerable segmentIds = null, IEnumerable categories = null, string customUnsubscribeUrl = null, string ipPool = null, CancellationToken cancellationToken = default(CancellationToken)) @@ -189,7 +191,7 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// Schedule a campaign to be sewnt at a later time. /// /// The id of the campaign - /// + /// The send on. /// Cancellation token /// public async Task ScheduleAsync(long campaignId, DateTime sendOn, CancellationToken cancellationToken = default(CancellationToken)) @@ -206,7 +208,7 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// Change the date a campaign is scheduled to be sent /// /// The id of the campaign - /// + /// The send on. /// Cancellation token /// public async Task RescheduleAsync(long campaignId, DateTime sendOn, CancellationToken cancellationToken = default(CancellationToken)) @@ -261,9 +263,10 @@ public Campaigns(IClient client, string endpoint = "/campaigns") /// Send a test campaign /// /// The id of the campaign - /// + /// The email addresses. /// Cancellation token /// + /// You must specify at least one email address public async Task SendTestAsync(long campaignId, IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { emailAddresses = emailAddresses ?? Enumerable.Empty(); diff --git a/Source/StrongGrid/Resources/Categories.cs b/Source/StrongGrid/Resources/Categories.cs index 976caca0..1bcb0c47 100644 --- a/Source/StrongGrid/Resources/Categories.cs +++ b/Source/StrongGrid/Resources/Categories.cs @@ -9,14 +9,16 @@ namespace StrongGrid.Resources /// /// Categories help organize your email analytics by enabling you to tag emails you send by topics you define. /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Categories/categories.html + /// public class Categories { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Categories/categories.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint diff --git a/Source/StrongGrid/Resources/Contacts.cs b/Source/StrongGrid/Resources/Contacts.cs index 1947e029..24c090cf 100644 --- a/Source/StrongGrid/Resources/Contacts.cs +++ b/Source/StrongGrid/Resources/Contacts.cs @@ -9,14 +9,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// public class Contacts { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -26,6 +31,16 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") _client = client; } + /// + /// Creates the asynchronous. + /// + /// The email. + /// The first name. + /// The last name. + /// The custom fields. + /// The cancellation token. + /// + /// Thrown when an exception occured while creating the contact. public async Task CreateAsync(string email, string firstName = null, string lastName = null, IEnumerable customFields = null, CancellationToken cancellationToken = default(CancellationToken)) { var contact = new Contact(email, firstName, lastName, customFields); @@ -40,6 +55,16 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return importResult.PersistedRecipients.Single(); } + /// + /// Updates the asynchronous. + /// + /// The email. + /// The first name. + /// The last name. + /// The custom fields. + /// The cancellation token. + /// + /// Thrown when an exception occured while updating the contact. public async Task UpdateAsync(string email, string firstName = null, string lastName = null, IEnumerable customFields = null, CancellationToken cancellationToken = default(CancellationToken)) { var contact = new Contact(email, firstName, lastName, customFields); @@ -57,6 +82,12 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") } } + /// + /// Imports the asynchronous. + /// + /// The contacts. + /// The cancellation token. + /// public async Task ImportAsync(IEnumerable contacts, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JArray(); @@ -73,11 +104,23 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return importResult; } + /// + /// Deletes the asynchronous. + /// + /// The contact identifier. + /// The cancellation token. + /// public Task DeleteAsync(string contactId, CancellationToken cancellationToken = default(CancellationToken)) { return DeleteAsync(new[] { contactId }, cancellationToken); } + /// + /// Deletes the asynchronous. + /// + /// The contact identifier. + /// The cancellation token. + /// public async Task DeleteAsync(IEnumerable contactId, CancellationToken cancellationToken = default(CancellationToken)) { var data = JArray.FromObject(contactId.ToArray()); @@ -85,6 +128,12 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") response.EnsureSuccess(); } + /// + /// Gets the asynchronous. + /// + /// The contact identifier. + /// The cancellation token. + /// public async Task GetAsync(string contactId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint + "/" + contactId, cancellationToken).ConfigureAwait(false); @@ -95,6 +144,13 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return contact; } + /// + /// Gets the asynchronous. + /// + /// The records per page. + /// The page. + /// The cancellation token. + /// public async Task GetAsync(int recordsPerPage = 100, int page = 1, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}?page_size={1}&page={2}", _endpoint, recordsPerPage, page), cancellationToken).ConfigureAwait(false); @@ -140,6 +196,11 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return recipients; } + /// + /// Gets the billable count asynchronous. + /// + /// The cancellation token. + /// public async Task GetBillableCountAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/billable_count", _endpoint), cancellationToken).ConfigureAwait(false); @@ -159,6 +220,11 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return count; } + /// + /// Gets the total count asynchronous. + /// + /// The cancellation token. + /// public async Task GetTotalCountAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/count", _endpoint), cancellationToken).ConfigureAwait(false); @@ -178,6 +244,13 @@ public Contacts(IClient client, string endpoint = "/contactdb/recipients") return count; } + /// + /// Searches the asynchronous. + /// + /// The conditions. + /// The list identifier. + /// The cancellation token. + /// public async Task SearchAsync(IEnumerable conditions, int? listId = null, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(); diff --git a/Source/StrongGrid/Resources/CustomFields.cs b/Source/StrongGrid/Resources/CustomFields.cs index 0d2d9c1a..e2858c99 100644 --- a/Source/StrongGrid/Resources/CustomFields.cs +++ b/Source/StrongGrid/Resources/CustomFields.cs @@ -8,14 +8,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// public class CustomFields { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -25,6 +30,13 @@ public CustomFields(IClient client, string endpoint = "/contactdb/custom_fields" _client = client; } + /// + /// Creates the asynchronous. + /// + /// The name. + /// The type. + /// The cancellation token. + /// public async Task CreateAsync(string name, FieldType type, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -40,6 +52,11 @@ public CustomFields(IClient client, string endpoint = "/contactdb/custom_fields" return field; } + /// + /// Gets all asynchronous. + /// + /// The cancellation token. + /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint, cancellationToken).ConfigureAwait(false); @@ -75,6 +92,12 @@ public CustomFields(IClient client, string endpoint = "/contactdb/custom_fields" return fields; } + /// + /// Gets the asynchronous. + /// + /// The field identifier. + /// The cancellation token. + /// public async Task GetAsync(int fieldId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, fieldId), cancellationToken).ConfigureAwait(false); @@ -85,12 +108,23 @@ public CustomFields(IClient client, string endpoint = "/contactdb/custom_fields" return field; } + /// + /// Deletes the asynchronous. + /// + /// The field identifier. + /// The cancellation token. + /// public async Task DeleteAsync(int fieldId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}", _endpoint, fieldId), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Gets the reserved fields asynchronous. + /// + /// The cancellation token. + /// public async Task GetReservedFieldsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/contactdb/reserved_fields", cancellationToken).ConfigureAwait(false); diff --git a/Source/StrongGrid/Resources/GlobalSuppressions.cs b/Source/StrongGrid/Resources/GlobalSuppressions.cs index 95480551..a7b92e66 100644 --- a/Source/StrongGrid/Resources/GlobalSuppressions.cs +++ b/Source/StrongGrid/Resources/GlobalSuppressions.cs @@ -7,14 +7,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html + /// public class GlobalSuppressions { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -28,7 +33,8 @@ public GlobalSuppressions(IClient client, string endpoint = "/asm/suppressions/g /// Check if a recipient address is in the global suppressions group. /// /// email address to check - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html + /// The cancellation token. + /// public async Task IsUnsubscribedAsync(string email, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, email), cancellationToken).ConfigureAwait(false); @@ -53,7 +59,8 @@ public GlobalSuppressions(IClient client, string endpoint = "/asm/suppressions/g /// Add recipient addresses to the global suppression group. /// /// Array of email addresses to add to the suppression group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html + /// The cancellation token. + /// public async Task AddAsync(IEnumerable emails, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject(new JProperty("recipient_emails", JArray.FromObject(emails.ToArray()))); @@ -65,7 +72,8 @@ public GlobalSuppressions(IClient client, string endpoint = "/asm/suppressions/g /// Delete a recipient email from the global suppressions group. /// /// email address to be removed from the global suppressions group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/global_suppressions.html + /// The cancellation token. + /// public async Task RemoveAsync(string email, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}", _endpoint, email), cancellationToken).ConfigureAwait(false); diff --git a/Source/StrongGrid/Resources/InvalidEmails.cs b/Source/StrongGrid/Resources/InvalidEmails.cs index 7be4df1d..9536d643 100644 --- a/Source/StrongGrid/Resources/InvalidEmails.cs +++ b/Source/StrongGrid/Resources/InvalidEmails.cs @@ -10,14 +10,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html + /// public class InvalidEmails { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/alerts.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -30,10 +35,10 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Retrieve all invalid emails. /// - /// - /// - /// - /// + /// The start date. + /// The end date. + /// The limit. + /// The offset. /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) @@ -50,7 +55,9 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Retrieve a specific invalid email. /// + /// The email address. /// Cancellation token + /// public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); @@ -66,6 +73,7 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// Delete all invalid emails. /// /// Cancellation token + /// public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -79,7 +87,9 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Delete multiple invalid emails. /// + /// The email addresses. /// Cancellation token + /// public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -93,7 +103,9 @@ public InvalidEmails(IClient client, string endpoint = "/suppression/invalid_ema /// /// Delete a specific invalid emails. /// + /// The email address. /// Cancellation token + /// public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Lists.cs b/Source/StrongGrid/Resources/Lists.cs index 233d97d0..b1079d9f 100644 --- a/Source/StrongGrid/Resources/Lists.cs +++ b/Source/StrongGrid/Resources/Lists.cs @@ -8,14 +8,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// public class Lists { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/contactdb.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -25,6 +30,12 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") _client = client; } + /// + /// Creates the asynchronous. + /// + /// The name. + /// The cancellation token. + /// public async Task CreateAsync(string name, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -39,6 +50,11 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") return bulkUpsertResult; } + /// + /// Gets all asynchronous. + /// + /// The cancellation token. + /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint, cancellationToken).ConfigureAwait(false); @@ -64,12 +80,24 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") return lists; } + /// + /// Deletes the asynchronous. + /// + /// The list identifier. + /// The cancellation token. + /// public async Task DeleteAsync(long listId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}", _endpoint, listId), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Deletes the asynchronous. + /// + /// The list ids. + /// The cancellation token. + /// public async Task DeleteAsync(IEnumerable listIds, CancellationToken cancellationToken = default(CancellationToken)) { var data = JArray.FromObject(listIds.ToArray()); @@ -77,6 +105,12 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") response.EnsureSuccess(); } + /// + /// Gets the asynchronous. + /// + /// The list identifier. + /// The cancellation token. + /// public async Task GetAsync(long listId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, listId), cancellationToken).ConfigureAwait(false); @@ -87,6 +121,13 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") return list; } + /// + /// Updates the asynchronous. + /// + /// The list identifier. + /// The name. + /// The cancellation token. + /// public async Task UpdateAsync(long listId, string name, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -97,6 +138,14 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") response.EnsureSuccess(); } + /// + /// Gets the recipients asynchronous. + /// + /// The list identifier. + /// The records per page. + /// The page. + /// The cancellation token. + /// public async Task GetRecipientsAsync(long listId, int recordsPerPage = 100, int page = 1, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}/recipients?page_size={2}&page={3}", _endpoint, listId, recordsPerPage, page); @@ -129,18 +178,39 @@ public Lists(IClient client, string endpoint = "/contactdb/lists") return recipients; } + /// + /// Adds the recipient asynchronous. + /// + /// The list identifier. + /// The contact identifier. + /// The cancellation token. + /// public async Task AddRecipientAsync(long listId, string contactId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.PostAsync(string.Format("{0}/{1}/recipients/{2}", _endpoint, listId, contactId), (JObject)null, cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Removes the recipient asynchronous. + /// + /// The list identifier. + /// The contact identifier. + /// The cancellation token. + /// public async Task RemoveRecipientAsync(long listId, string contactId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}/recipients/{2}", _endpoint, listId, contactId), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Adds the recipients asynchronous. + /// + /// The list identifier. + /// The contact ids. + /// The cancellation token. + /// public async Task AddRecipientsAsync(long listId, IEnumerable contactIds, CancellationToken cancellationToken = default(CancellationToken)) { var data = JArray.FromObject(contactIds.ToArray()); diff --git a/Source/StrongGrid/Resources/Mail.cs b/Source/StrongGrid/Resources/Mail.cs index 7495f053..3f00e251 100644 --- a/Source/StrongGrid/Resources/Mail.cs +++ b/Source/StrongGrid/Resources/Mail.cs @@ -9,14 +9,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html + /// public class Mail { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/index.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -29,9 +34,30 @@ public Mail(IClient client, string endpoint = "/mail") /// /// Send an email to a single recipient /// + /// To. + /// From. + /// The subject. + /// Content of the HTML. + /// Content of the text. + /// if set to true [track opens]. + /// if set to true [track clicks]. + /// The subscription tracking. + /// The reply to. + /// The attachments. + /// The template identifier. + /// The sections. + /// The headers. + /// The categories. + /// The send at. + /// The batch identifier. + /// The unsubscribe options. + /// Name of the ip pool. + /// The mail settings. + /// The cancellation token. + /// /// /// This is a convenience method with simplified parameters. - /// If you need more options, use the method. + /// If you need more options, use the method. /// public Task SendToSingleRecipientAsync( MailAddress to, @@ -62,9 +88,30 @@ public Task SendToSingleRecipientAsync( /// /// Send the same email to multiple recipients /// + /// The recipients. + /// From. + /// The subject. + /// Content of the HTML. + /// Content of the text. + /// if set to true [track opens]. + /// if set to true [track clicks]. + /// The subscription tracking. + /// The reply to. + /// The attachments. + /// The template identifier. + /// The sections. + /// The headers. + /// The categories. + /// The send at. + /// The batch identifier. + /// The unsubscribe options. + /// Name of the ip pool. + /// The mail settings. + /// The cancellation token. + /// /// /// This is a convenience method with simplified parameters. - /// If you need more options, use the method. + /// If you need more options, use the method. /// public Task SendToMultipleRecipientsAsync( IEnumerable recipients, @@ -112,7 +159,24 @@ public Task SendToMultipleRecipientsAsync( /// /// Send email(s) over SendGrid’s v3 Web API /// + /// The personalizations. + /// The subject. + /// The contents. + /// From. + /// The reply to. + /// The attachments. + /// The template identifier. + /// The sections. + /// The headers. + /// The categories. + /// The send at. + /// The batch identifier. + /// The unsubscribe options. + /// Name of the ip pool. + /// The mail settings. + /// The tracking settings. /// Cancellation token + /// public async Task SendAsync( IEnumerable personalizations, string subject, diff --git a/Source/StrongGrid/Resources/Segments.cs b/Source/StrongGrid/Resources/Segments.cs index 006f64cb..f5df5bdf 100644 --- a/Source/StrongGrid/Resources/Segments.cs +++ b/Source/StrongGrid/Resources/Segments.cs @@ -8,14 +8,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html + /// public class Segments { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/campaigns.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -25,6 +30,14 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") _client = client; } + /// + /// Creates the asynchronous. + /// + /// The name. + /// The list identifier. + /// The conditions. + /// The cancellation token. + /// public async Task CreateAsync(string name, long listId, IEnumerable conditions, CancellationToken cancellationToken = default(CancellationToken)) { conditions = conditions ?? Enumerable.Empty(); @@ -43,6 +56,11 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") return segment; } + /// + /// Gets all asynchronous. + /// + /// The cancellation token. + /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint, cancellationToken).ConfigureAwait(false); @@ -77,6 +95,12 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") return segments; } + /// + /// Gets the asynchronous. + /// + /// The segment identifier. + /// The cancellation token. + /// public async Task GetAsync(long segmentId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, segmentId), cancellationToken).ConfigureAwait(false); @@ -87,6 +111,15 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") return segment; } + /// + /// Updates the asynchronous. + /// + /// The segment identifier. + /// The name. + /// The list identifier. + /// The conditions. + /// The cancellation token. + /// public async Task UpdateAsync(long segmentId, string name = null, long? listId = null, IEnumerable conditions = null, CancellationToken cancellationToken = default(CancellationToken)) { conditions = conditions ?? Enumerable.Empty(); @@ -104,12 +137,27 @@ public Segments(IClient client, string endpoint = "/contactdb/segments") return segment; } + /// + /// Deletes the asynchronous. + /// + /// The segment identifier. + /// if set to true [delete matching contacts]. + /// The cancellation token. + /// public async Task DeleteAsync(long segmentId, bool deleteMatchingContacts = false, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(string.Format("{0}/{1}?delete_contacts={2}", _endpoint, segmentId, deleteMatchingContacts ? "true" : "false"), cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Gets the recipients asynchronous. + /// + /// The segment identifier. + /// The records per page. + /// The page. + /// The cancellation token. + /// public async Task GetRecipientsAsync(long segmentId, int recordsPerPage = 100, int page = 1, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}/recipients?page_size={2}&page={3}", _endpoint, segmentId, recordsPerPage, page), cancellationToken).ConfigureAwait(false); diff --git a/Source/StrongGrid/Resources/SenderIdentities.cs b/Source/StrongGrid/Resources/SenderIdentities.cs index 36be295c..604076e6 100644 --- a/Source/StrongGrid/Resources/SenderIdentities.cs +++ b/Source/StrongGrid/Resources/SenderIdentities.cs @@ -6,14 +6,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/sender_identities.html + /// public class SenderIdentities { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Marketing_Campaigns/sender_identities.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -23,6 +28,20 @@ public SenderIdentities(IClient client, string endpoint = "/senders") _client = client; } + /// + /// Creates the asynchronous. + /// + /// The nickname. + /// From. + /// The reply to. + /// The address1. + /// The address2. + /// The city. + /// The state. + /// The zip. + /// The country. + /// The cancellation token. + /// public async Task CreateAsync(string nickname, MailAddress from, MailAddress replyTo, string address1, string address2, string city, string state, string zip, string country, CancellationToken cancellationToken = default(CancellationToken)) { var data = CreateJObjectForSenderIdentity(nickname, from, replyTo, address1, address2, city, state, zip, country); @@ -35,6 +54,11 @@ public SenderIdentities(IClient client, string endpoint = "/senders") return senderIdentity; } + /// + /// Gets all asynchronous. + /// + /// The cancellation token. + /// public async Task GetAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(_endpoint, cancellationToken).ConfigureAwait(false); @@ -71,6 +95,12 @@ public SenderIdentities(IClient client, string endpoint = "/senders") return senderIdentities; } + /// + /// Gets the asynchronous. + /// + /// The sender identifier. + /// The cancellation token. + /// public async Task GetAsync(long senderId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync(string.Format("{0}/{1}", _endpoint, senderId), cancellationToken).ConfigureAwait(false); @@ -81,6 +111,21 @@ public SenderIdentities(IClient client, string endpoint = "/senders") return segment; } + /// + /// Updates the asynchronous. + /// + /// The sender identifier. + /// The nickname. + /// From. + /// The reply to. + /// The address1. + /// The address2. + /// The city. + /// The state. + /// The zip. + /// The country. + /// The cancellation token. + /// public async Task UpdateAsync(long senderId, string nickname = null, MailAddress from = null, MailAddress replyTo = null, string address1 = null, string address2 = null, string city = null, string state = null, string zip = null, string country = null, CancellationToken cancellationToken = default(CancellationToken)) { var data = CreateJObjectForSenderIdentity(nickname, from, replyTo, address1, address2, city, state, zip, country); @@ -93,12 +138,24 @@ public SenderIdentities(IClient client, string endpoint = "/senders") return segment; } + /// + /// Deletes the asynchronous. + /// + /// The sender identifier. + /// The cancellation token. + /// public async Task DeleteAsync(long senderId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.DeleteAsync(_endpoint + "/" + senderId, cancellationToken).ConfigureAwait(false); response.EnsureSuccess(); } + /// + /// Resends the verification. + /// + /// The sender identifier. + /// The cancellation token. + /// public async Task ResendVerification(long senderId, CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.PostAsync(string.Format("{0}/{1}/resend_verification", _endpoint, senderId), (JObject)null, cancellationToken).ConfigureAwait(false); diff --git a/Source/StrongGrid/Resources/Settings.cs b/Source/StrongGrid/Resources/Settings.cs index 0850f0b0..e283e92e 100644 --- a/Source/StrongGrid/Resources/Settings.cs +++ b/Source/StrongGrid/Resources/Settings.cs @@ -8,14 +8,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/index.html + /// public class Settings { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/index.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -28,7 +33,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get the current Enforced TLS settings. /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/index.html + /// The cancellation token. + /// public async Task GetEnforcedTlsSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/user/settings/enforced_tls", cancellationToken).ConfigureAwait(false); @@ -42,7 +48,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Enforced TLS settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/enforced_tls.html + /// if set to true [require TLS]. + /// if set to true [require valid cert]. + /// The cancellation token. + /// public async Task UpdateEnforcedTlsSettingsAsync(bool requireTls, bool requireValidCert, CancellationToken cancellationToken = default(CancellationToken)) { var enforcedTlsSettings = new EnforcedTlsSettings @@ -62,7 +71,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Partner Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/partners.html + /// The limit. + /// The offset. + /// The cancellation token. + /// public async Task GetAllPartnerSettingsAsync(int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("/partner_settings?limit={0}&offset={1}", limit, offset); @@ -93,7 +105,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get New Relic Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/partners.html + /// The cancellation token. + /// public async Task GetNewRelicSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/partner_settings/new_relic", cancellationToken).ConfigureAwait(false); @@ -107,7 +120,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the New Relic settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/partners.html + /// if set to true [enabled]. + /// The license key. + /// The cancellation token. + /// public async Task UpdateNewRelicSettingsAsync(bool enabled, string licenseKey, CancellationToken cancellationToken = default(CancellationToken)) { var newRelicSettings = new NewRelicSettings @@ -127,7 +143,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Tracking Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// The limit. + /// The offset. + /// The cancellation token. + /// public async Task GetAllTrackingSettingsAsync(int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("/tracking_settings?limit={0}&offset={1}", limit, offset); @@ -158,7 +177,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Click Tracking Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// The cancellation token. + /// public async Task GetClickTrackingSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/tracking_settings/click", cancellationToken).ConfigureAwait(false); @@ -184,7 +204,9 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the click tracking settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// if set to true [enabled]. + /// The cancellation token. + /// public async Task UpdateClickTrackingSettingsAsync(bool enabled, CancellationToken cancellationToken = default(CancellationToken)) { var clickTrackingSettings = new Setting @@ -211,7 +233,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Google Analytics Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// The cancellation token. + /// public async Task GetGoogleAnalyticsGlobalSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/tracking_settings/google_analytics", cancellationToken).ConfigureAwait(false); @@ -225,7 +248,14 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the New Relic settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// if set to true [enabled]. + /// The utm source. + /// The utm medium. + /// The utm term. + /// Content of the utm. + /// The utm campaign. + /// The cancellation token. + /// public async Task UpdateGoogleAnalyticsGlobalSettingsAsync(bool enabled, string utmSource, string utmMedium, string utmTerm, string utmContent, string utmCampaign, CancellationToken cancellationToken = default(CancellationToken)) { var googleAnalyticsGlobalSettings = new GoogleAnalyticsGlobalSettings @@ -249,7 +279,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Open Tracking Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// The cancellation token. + /// public async Task GetOpenTrackingSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/tracking_settings/open", cancellationToken).ConfigureAwait(false); @@ -271,7 +302,9 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the open tracking settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// if set to true [enabled]. + /// The cancellation token. + /// public async Task UpdateOpenTrackingSettingsAsync(bool enabled, CancellationToken cancellationToken = default(CancellationToken)) { var openTrackingSettings = new Setting @@ -298,7 +331,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Subscription Tracking Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// The cancellation token. + /// public async Task GetSubscriptionTrackingSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/tracking_settings/subscription", cancellationToken).ConfigureAwait(false); @@ -312,7 +346,14 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Subscription Tracking settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/tracking.html + /// if set to true [enabled]. + /// The landing page HTML. + /// The URL. + /// The replacement tag. + /// Content of the HTML. + /// Content of the text. + /// The cancellation token. + /// public async Task UpdateSubscriptionTrackingSettingsAsync(bool enabled, string landingPageHtml, string url, string replacementTag, string htmlContent, string textContent, CancellationToken cancellationToken = default(CancellationToken)) { var subscriptionTrackingSettings = new SubscriptionSettings @@ -336,7 +377,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Mail Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The limit. + /// The offset. + /// The cancellation token. + /// public async Task GetAllMailSettingsAsync(int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("/mail_settings?limit={0}&offset={1}", limit, offset); @@ -367,7 +411,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get BCC Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetBccMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/bcc", cancellationToken).ConfigureAwait(false); @@ -381,7 +426,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the BCC settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The email. + /// The cancellation token. + /// public async Task UpdateBccMailSettingsAsync(bool enabled, string email, CancellationToken cancellationToken = default(CancellationToken)) { var bccMailSettings = new EmailAddressSetting @@ -401,7 +449,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Address Whitelist Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetAddressWhitelistMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/address_whitelist", cancellationToken).ConfigureAwait(false); @@ -415,7 +464,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Address Whitelist settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The email addresses. + /// The cancellation token. + /// public async Task UpdateAddressWhitelistMailSettingsAsync(bool enabled, IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var addressWhitelistSettings = new AddressWhitelistSettings @@ -435,7 +487,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Footer Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetFooterMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/footer", cancellationToken).ConfigureAwait(false); @@ -449,7 +502,11 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Footer settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// Content of the HTML. + /// Content of the text. + /// The cancellation token. + /// public async Task UpdateFooterMailSettingsAsync(bool enabled, string htmlContent, string textContent, CancellationToken cancellationToken = default(CancellationToken)) { var footerGlobalSetting = new FooterGlobalSettings @@ -470,7 +527,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Forward Spam Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetForwardSpamMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/forward_spam", cancellationToken).ConfigureAwait(false); @@ -484,7 +542,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Forward Spam settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The email. + /// The cancellation token. + /// public async Task UpdateForwardSpamMailSettingsAsync(bool enabled, string email, CancellationToken cancellationToken = default(CancellationToken)) { var forwardSpamMailSettins = new EmailAddressSetting @@ -504,7 +565,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Plain Content Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetPlainContentMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/plain_content", cancellationToken).ConfigureAwait(false); @@ -530,7 +592,9 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Plain Content settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The cancellation token. + /// public async Task UpdatPlainContentMailSettingsAsync(bool enabled, CancellationToken cancellationToken = default(CancellationToken)) { var plainContentSettings = new Setting @@ -557,7 +621,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Spam Check Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetSpamCheckMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/spam_check", cancellationToken).ConfigureAwait(false); @@ -571,7 +636,11 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Spam Check settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The post to URL. + /// The threshold. + /// The cancellation token. + /// public async Task UpdateSpamCheckMailSettingsAsync(bool enabled, string postToUrl, int threshold, CancellationToken cancellationToken = default(CancellationToken)) { var spamCheckMailSettings = new SpamCheckSettings @@ -592,7 +661,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Template Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetTemplateMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/template", cancellationToken).ConfigureAwait(false); @@ -606,7 +676,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Template settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// Content of the HTML. + /// The cancellation token. + /// public async Task UpdateTemplateMailSettingsAsync(bool enabled, string htmlContent, CancellationToken cancellationToken = default(CancellationToken)) { var templateMailSettings = new TemplateSettings @@ -626,7 +699,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Bounce Purge Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetBouncePurgeMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/bounce_purge", cancellationToken).ConfigureAwait(false); @@ -640,7 +714,11 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Bounce Purge settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The hard bounces. + /// The soft bounces. + /// The cancellation token. + /// public async Task UpdatBouncePurgeMailSettingsAsync(bool enabled, int hardBounces, int softBounces, CancellationToken cancellationToken = default(CancellationToken)) { var bouncePurgeSettings = new BouncePurgeSettings @@ -661,7 +739,8 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Get Forward Bounce Settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// The cancellation token. + /// public async Task GetForwardBounceMailSettingsAsync(CancellationToken cancellationToken = default(CancellationToken)) { var response = await _client.GetAsync("/mail_settings/forward_bounce", cancellationToken).ConfigureAwait(false); @@ -675,7 +754,10 @@ public Settings(IClient client, string endpoint = "/settings") /// /// Change the Forward Spam settings /// - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Settings/mail.html + /// if set to true [enabled]. + /// The email. + /// The cancellation token. + /// public async Task UpdateForwardBounceMailSettingsAsync(bool enabled, string email, CancellationToken cancellationToken = default(CancellationToken)) { var forwardSpamMailSettings = new EmailAddressSetting diff --git a/Source/StrongGrid/Resources/SpamReports.cs b/Source/StrongGrid/Resources/SpamReports.cs index c66a1e75..88d3ef79 100644 --- a/Source/StrongGrid/Resources/SpamReports.cs +++ b/Source/StrongGrid/Resources/SpamReports.cs @@ -9,14 +9,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/spam_reports.html + /// public class SpamReports { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/spam_reports.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -29,7 +34,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Retrieve a specific spam report. /// - /// + /// The email address. /// Cancellation token /// public async Task GetAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) @@ -46,10 +51,10 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// List all spam reports. /// - /// - /// - /// - /// + /// The start date. + /// The end date. + /// The limit. + /// The offset. /// Cancellation token /// public async Task GetAllAsync(DateTime? startDate = null, DateTime? endDate = null, int limit = 25, int offset = 0, CancellationToken cancellationToken = default(CancellationToken)) @@ -67,6 +72,7 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// Delete all spam reports. /// /// Cancellation token + /// public async Task DeleteAllAsync(CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -80,7 +86,9 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Delete multiple spam reports. /// + /// The email addresses. /// Cancellation token + /// public async Task DeleteMultipleAsync(IEnumerable emailAddresses, CancellationToken cancellationToken = default(CancellationToken)) { var data = new JObject @@ -94,7 +102,9 @@ public SpamReports(IClient client, string endpoint = "/suppression/spam_reports" /// /// Delete a specific spam report. /// + /// The email address. /// Cancellation token + /// public async Task DeleteAsync(string emailAddress, CancellationToken cancellationToken = default(CancellationToken)) { var endpoint = string.Format("{0}/{1}", _endpoint, emailAddress); diff --git a/Source/StrongGrid/Resources/Statistics.cs b/Source/StrongGrid/Resources/Statistics.cs index e30b66ed..067354b5 100644 --- a/Source/StrongGrid/Resources/Statistics.cs +++ b/Source/StrongGrid/Resources/Statistics.cs @@ -10,14 +10,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/index.html + /// public class Statistics { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Stats/index.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -34,6 +39,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetGlobalStatisticsAsync(DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -57,6 +63,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetCategoriesStatisticsAsync(IEnumerable categories, DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -87,6 +94,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetSubusersStatisticsAsync(IEnumerable subusers, DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -117,6 +125,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetCountryStatisticsAsync(string country, DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -140,6 +149,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetDeviceTypesStatisticsAsync(DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -162,6 +172,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetClientTypesStatisticsAsync(DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -185,6 +196,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetInboxProvidersStatisticsAsync(IEnumerable providers, DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { @@ -215,6 +227,7 @@ public Statistics(IClient client, string endpoint = "/stats") /// The starting date of the statistics to retrieve. /// The end date of the statistics to retrieve. Defaults to today. /// How to group the statistics, must be day|week|month + /// The cancellation token. /// public async Task GetBrowsersStatisticsAsync(IEnumerable browsers, DateTime startDate, DateTime? endDate = null, AggregateBy aggregatedBy = AggregateBy.None, CancellationToken cancellationToken = default(CancellationToken)) { diff --git a/Source/StrongGrid/Resources/Suppressions.cs b/Source/StrongGrid/Resources/Suppressions.cs index d845f206..0c200b7f 100644 --- a/Source/StrongGrid/Resources/Suppressions.cs +++ b/Source/StrongGrid/Resources/Suppressions.cs @@ -8,76 +8,83 @@ namespace StrongGrid.Resources { - public class Suppressions - { - private readonly string _endpoint; - private readonly IClient _client; + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html + /// + public class Suppressions + { + private readonly string _endpoint; + private readonly IClient _client; - /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html - /// - /// SendGrid Web API v3 client - /// Resource endpoint - public Suppressions(IClient client, string endpoint = "/asm/groups") - { - _endpoint = endpoint; - _client = client; - } + /// + /// Initializes a new instance of the class. + /// + /// SendGrid Web API v3 client + /// Resource endpoint + public Suppressions(IClient client, string endpoint = "/asm/groups") + { + _endpoint = endpoint; + _client = client; + } - /// - /// Get suppressed addresses for a given group. - /// - /// ID of the suppression group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html - public async Task GetUnsubscribedAddressesAsync(int groupId, CancellationToken cancellationToken = default(CancellationToken)) - { - var response = await _client.GetAsync(string.Format("{0}/{1}/suppressions", _endpoint, groupId), cancellationToken).ConfigureAwait(false); - response.EnsureSuccess(); + /// + /// Get suppressed addresses for a given group. + /// + /// ID of the suppression group + /// The cancellation token. + /// + public async Task GetUnsubscribedAddressesAsync(int groupId, CancellationToken cancellationToken = default(CancellationToken)) + { + var response = await _client.GetAsync(string.Format("{0}/{1}/suppressions", _endpoint, groupId), cancellationToken).ConfigureAwait(false); + response.EnsureSuccess(); - var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); - var suppressedAddresses = JArray.Parse(responseContent).ToObject(); - return suppressedAddresses; - } + var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + var suppressedAddresses = JArray.Parse(responseContent).ToObject(); + return suppressedAddresses; + } - /// - /// Add recipient address to the suppressions list for a given group. - /// - /// If the group has been deleted, this request will add the address to the global suppression. - /// - /// ID of the suppression group - /// Email address to add to the suppression group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html - public Task AddAddressToUnsubscribeGroupAsync(int groupId, string email, CancellationToken cancellationToken = default(CancellationToken)) - { - return AddAddressToUnsubscribeGroupAsync(groupId, new[] { email }, cancellationToken); - } + /// + /// Add recipient address to the suppressions list for a given group. + /// If the group has been deleted, this request will add the address to the global suppression. + /// + /// ID of the suppression group + /// Email address to add to the suppression group + /// The cancellation token. + /// + public Task AddAddressToUnsubscribeGroupAsync(int groupId, string email, CancellationToken cancellationToken = default(CancellationToken)) + { + return AddAddressToUnsubscribeGroupAsync(groupId, new[] { email }, cancellationToken); + } - /// - /// Add recipient addresses to the suppressions list for a given group. - /// - /// If the group has been deleted, this request will add the address to the global suppression. - /// - /// ID of the suppression group - /// Email addresses to add to the suppression group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html - public async Task AddAddressToUnsubscribeGroupAsync(int groupId, IEnumerable emails, CancellationToken cancellationToken = default(CancellationToken)) - { - var data = new JObject(new JProperty("recipient_emails", JArray.FromObject(emails.ToArray()))); - var response = await _client.PostAsync(string.Format("{0}/{1}/suppressions", _endpoint, groupId), data, cancellationToken).ConfigureAwait(false); - response.EnsureSuccess(); - } + /// + /// Add recipient addresses to the suppressions list for a given group. + /// If the group has been deleted, this request will add the address to the global suppression. + /// + /// ID of the suppression group + /// Email addresses to add to the suppression group + /// The cancellation token. + /// + public async Task AddAddressToUnsubscribeGroupAsync(int groupId, IEnumerable emails, CancellationToken cancellationToken = default(CancellationToken)) + { + var data = new JObject(new JProperty("recipient_emails", JArray.FromObject(emails.ToArray()))); + var response = await _client.PostAsync(string.Format("{0}/{1}/suppressions", _endpoint, groupId), data, cancellationToken).ConfigureAwait(false); + response.EnsureSuccess(); + } - /// - /// Delete a recipient email from the suppressions list for a group. - /// - /// ID of the suppression group to delete - /// Email address to remove from the suppression group - /// https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/suppressions.html - public async Task RemoveAddressFromSuppressionGroupAsync(int groupId, string email, CancellationToken cancellationToken = default(CancellationToken)) - { - var response = await _client.DeleteAsync(string.Format("{0}/{1}/suppressions/{2}", _endpoint, groupId, email), cancellationToken).ConfigureAwait(false); - response.EnsureSuccess(); - } - } + /// + /// Delete a recipient email from the suppressions list for a group. + /// + /// ID of the suppression group to delete + /// Email address to remove from the suppression group + /// The cancellation token. + /// + public async Task RemoveAddressFromSuppressionGroupAsync(int groupId, string email, CancellationToken cancellationToken = default(CancellationToken)) + { + var response = await _client.DeleteAsync(string.Format("{0}/{1}/suppressions/{2}", _endpoint, groupId, email), cancellationToken).ConfigureAwait(false); + response.EnsureSuccess(); + } + } } diff --git a/Source/StrongGrid/Resources/Templates.cs b/Source/StrongGrid/Resources/Templates.cs index fb201b80..9c06ed22 100644 --- a/Source/StrongGrid/Resources/Templates.cs +++ b/Source/StrongGrid/Resources/Templates.cs @@ -6,14 +6,19 @@ namespace StrongGrid.Resources { + /// + /// + /// + /// + /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Transactional_Templates/templates.html + /// public class Templates { private readonly string _endpoint; private readonly IClient _client; /// - /// Initializes a new instance of the class. - /// See https://sendgrid.com/docs/API_Reference/Web_API_v3/Transactional_Templates/templates.html + /// Initializes a new instance of the class. /// /// SendGrid Web API v3 client /// Resource endpoint @@ -23,6 +28,12 @@ public Templates(IClient client, string endpoint = "/templates") _client = client; } + /// + /// Creates the asynchronous. + /// + /// The name. + /// The cancellation token. + /// public async Task