diff --git a/README.md b/README.md index cfd725a..7222f94 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ var mergeData = new Dictionary { { "gender", "Male" } }; -var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "recipient@example.com", subject, html, text, "you@yourcompany.com", "Your name", mergeData, null, null, clientId).ConfigureAwait(false); +var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "recipient@example.com", subject, html, text, "you@yourcompany.com", "Your name", mergeData, null, null, clientId, cancellationToken).ConfigureAwait(false); ``` + **7.0** @@ -68,7 +68,7 @@ var mergeData = new Dictionary { "firstname", "Bob" }, { "lastname", "Smith" } }; -var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "recipient@example.com", subject, html, text, "you@yourcompany.com", "Your name", mergeData, null, null, clientId).ConfigureAwait(false); +var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "recipient@example.com", subject, html, text, "you@yourcompany.com", "Your name", mergeData, null, null, clientId, cancellationToken).ConfigureAwait(false); ``` + **6.0** diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/CampaignsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/CampaignsTests.cs index 4b363d5..69371a0 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/CampaignsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/CampaignsTests.cs @@ -12,22 +12,22 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** CAMPAIGNS *****").ConfigureAwait(false); - var campaigns = await client.Campaigns.GetListAsync(userKey, CampaignStatus.Ongoing, null, CampaignsSortBy.Name, SortDirection.Ascending, null, null, clientId).ConfigureAwait(false); + var campaigns = await client.Campaigns.GetListAsync(userKey, CampaignStatus.Ongoing, null, CampaignsSortBy.Name, SortDirection.Ascending, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All campaigns retrieved. Count = {campaigns.Count()}").ConfigureAwait(false); - var campaignsCount = await client.Campaigns.GetCountAsync(userKey, CampaignStatus.Ongoing, null, clientId).ConfigureAwait(false); + var campaignsCount = await client.Campaigns.GetCountAsync(userKey, CampaignStatus.Ongoing, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Campaigns count = {campaignsCount}").ConfigureAwait(false); - var campaignId = await client.Campaigns.CreateAsync(userKey, "Dummy campaign", clientId).ConfigureAwait(false); + var campaignId = await client.Campaigns.CreateAsync(userKey, "Dummy campaign", clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New campaign created. Id: {campaignId}").ConfigureAwait(false); - var updated = await client.Campaigns.UpdateAsync(userKey, campaignId, CampaignStatus.Ongoing, "Updated name", clientId).ConfigureAwait(false); + var updated = await client.Campaigns.UpdateAsync(userKey, campaignId, CampaignStatus.Ongoing, "Updated name", clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Campaign updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var campaign = await client.Campaigns.GetAsync(userKey, campaignId, clientId).ConfigureAwait(false); + var campaign = await client.Campaigns.GetAsync(userKey, campaignId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Campaign retrieved: Name = {campaign.Name}").ConfigureAwait(false); - var deleted = await client.Campaigns.DeleteAsync(userKey, campaignId, clientId).ConfigureAwait(false); + var deleted = await client.Campaigns.DeleteAsync(userKey, campaignId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Campaign deleted: {(deleted ? "success" : "failed")}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/ClientsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/ClientsTests.cs index 69a2b42..af21a20 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/ClientsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/ClientsTests.cs @@ -15,35 +15,35 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** CLIENT *****").ConfigureAwait(false); - var clientsCount = await client.Clients.GetCountAsync(userKey, null, null, clientId).ConfigureAwait(false); + var clientsCount = await client.Clients.GetCountAsync(userKey, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Clients count = {clientsCount}").ConfigureAwait(false); var adminEmail = string.Format("admin{0:00}+{1:0000}@integrationtesting.com", clientsCount, (new Random()).Next(9999)); - var confirmation = await client.Clients.CreateAsync(clientId, "_Integration Testing", "123 1st Street", "Suite 123", "Atlanta", "GA", "12345", "us", "www.company.com", "1-888-myphone", "1-888myfax", adminEmail, "Admin", "Integration Testing", "Super Administrator", "1-888-AdminPhone", "1-888-AdminMobile", "en_US", UTC_TIMEZONE_ID, "adminpassword", true).ConfigureAwait(false); + var confirmation = await client.Clients.CreateAsync(clientId, "_Integration Testing", "123 1st Street", "Suite 123", "Atlanta", "GA", "12345", "us", "www.company.com", "1-888-myphone", "1-888myfax", adminEmail, "Admin", "Integration Testing", "Super Administrator", "1-888-AdminPhone", "1-888-AdminMobile", "en_US", UTC_TIMEZONE_ID, "adminpassword", true, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New client created. Confirmation code: {confirmation}").ConfigureAwait(false); - var unconfirmedClient = await client.Clients.GetAsync(userKey, confirmation).ConfigureAwait(false); + var unconfirmedClient = await client.Clients.GetAsync(userKey, confirmation, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Information about this unconfirmed client: Name = {unconfirmedClient.Name}").ConfigureAwait(false); - var registrationInfo = await client.Clients.ConfirmAsync(confirmation).ConfigureAwait(false); + var registrationInfo = await client.Clients.ConfirmAsync(confirmation, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client has been confirmed. Id = {registrationInfo.ClientId}").ConfigureAwait(false); - var clients = await client.Clients.GetListAsync(userKey, null, null, ClientsSortBy.CompanyName, SortDirection.Ascending, null, null, clientId).ConfigureAwait(false); + var clients = await client.Clients.GetListAsync(userKey, null, null, ClientsSortBy.CompanyName, SortDirection.Ascending, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All clients retrieved. Count = {clients.Count()}").ConfigureAwait(false); - var updated = await client.Clients.UpdateAsync(userKey, registrationInfo.ClientId, name: "Fictitious Company").ConfigureAwait(false); + var updated = await client.Clients.UpdateAsync(userKey, registrationInfo.ClientId, name: "Fictitious Company", cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var myClient = await client.Clients.GetAsync(userKey, registrationInfo.ClientId).ConfigureAwait(false); + var myClient = await client.Clients.GetAsync(userKey, registrationInfo.ClientId, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client retrieved: Name = {myClient.Name}").ConfigureAwait(false); - var suspended = await client.Clients.SuspendAsync(userKey, myClient.Id).ConfigureAwait(false); + var suspended = await client.Clients.SuspendAsync(userKey, myClient.Id, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client suspended: {(suspended ? "success" : "failed")}").ConfigureAwait(false); - var reactivated = await client.Clients.ActivateAsync(userKey, myClient.Id).ConfigureAwait(false); + var reactivated = await client.Clients.ActivateAsync(userKey, myClient.Id, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client re-activated: {(reactivated ? "success" : "failed")}").ConfigureAwait(false); - var deleted = await client.Clients.DeleteAsync(userKey, myClient.Id).ConfigureAwait(false); + var deleted = await client.Clients.DeleteAsync(userKey, myClient.Id, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Client deleted: {(deleted ? "success" : "failed")}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/CountriesTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/CountriesTests.cs index b5e4e88..21679fb 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/CountriesTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/CountriesTests.cs @@ -11,13 +11,13 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** COUNTRIES *****").ConfigureAwait(false); - var countries = await client.Countries.GetListAsync().ConfigureAwait(false); + var countries = await client.Countries.GetListAsync(cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Retrieved all countries. There are {countries.Count()} countries.").ConfigureAwait(false); var canada = countries.Single(country => country.EnglishName == "Canada"); await log.WriteLineAsync($"Canada --> Id: {canada.Id}").ConfigureAwait(false); - var canadianProvinces = await client.Countries.GetProvincesAsync(canada.Id).ConfigureAwait(false); + var canadianProvinces = await client.Countries.GetProvincesAsync(canada.Id, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"There are {canadianProvinces.Count()} canadian provinces/territories/etc.").ConfigureAwait(false); var quebec = canadianProvinces.Single(province => province.EnglishName == "Quebec"); @@ -26,7 +26,7 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us var usa = countries.Single(country => country.EnglishName == "United States"); await log.WriteLineAsync($"USA --> Id: {usa.Id}").ConfigureAwait(false); - var americanStates = await client.Countries.GetProvincesAsync(usa.Id).ConfigureAwait(false); + var americanStates = await client.Countries.GetProvincesAsync(usa.Id, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"There are {americanStates.Count()} american states/territories/etc.").ConfigureAwait(false); var georgia = americanStates.Single(province => province.EnglishName == "Georgia"); diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/ListsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/ListsTests.cs index 2185cb3..9cd7bb8 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/ListsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/ListsTests.cs @@ -14,28 +14,28 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** LISTS *****").ConfigureAwait(false); - var lists = await client.Lists.GetListsAsync(userKey, ListStatus.Active, null, ListsSortBy.Name, SortDirection.Descending, null, null, clientId).ConfigureAwait(false); + var lists = await client.Lists.GetListsAsync(userKey, ListStatus.Active, null, ListsSortBy.Name, SortDirection.Descending, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All lists retrieved. Count = {lists.Count()}").ConfigureAwait(false); - var listsCount = await client.Lists.GetCountAsync(userKey, ListStatus.Active, null, clientId).ConfigureAwait(false); + var listsCount = await client.Lists.GetCountAsync(userKey, ListStatus.Active, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Lists count = {listsCount}").ConfigureAwait(false); - var listId = await client.Lists.CreateAsync(userKey, "Dummy list", "Bob Smith", "bobsmith@fictitiouscomapny.com", true, clientId).ConfigureAwait(false); + var listId = await client.Lists.CreateAsync(userKey, "Dummy list", "Bob Smith", "bobsmith@fictitiouscomapny.com", true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New list created. Id: {listId}").ConfigureAwait(false); - var updated = await client.Lists.UpdateAsync(userKey, listId, name: "Updated name", clientId: clientId).ConfigureAwait(false); + var updated = await client.Lists.UpdateAsync(userKey, listId, name: "Updated name", clientId: clientId, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var list = await client.Lists.GetAsync(userKey, listId, false, false, clientId).ConfigureAwait(false); + var list = await client.Lists.GetAsync(userKey, listId, false, false, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List retrieved: Name = {list.Name}").ConfigureAwait(false); - await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField1", FieldType.Integer, clientId).ConfigureAwait(false); - await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField2", FieldType.DateTime, clientId).ConfigureAwait(false); - await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField3", FieldType.Text, clientId).ConfigureAwait(false); - await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField4", FieldType.Memo, clientId).ConfigureAwait(false); + await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField1", FieldType.Integer, clientId, cancellationToken).ConfigureAwait(false); + await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField2", FieldType.DateTime, clientId, cancellationToken).ConfigureAwait(false); + await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField3", FieldType.Text, clientId, cancellationToken).ConfigureAwait(false); + await client.Lists.AddFieldAsync(userKey, listId, "MyCustomField4", FieldType.Memo, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Custom fields added to the list").ConfigureAwait(false); - var fields = await client.Lists.GetFieldsAsync(userKey, listId, clientId).ConfigureAwait(false); + var fields = await client.Lists.GetFieldsAsync(userKey, listId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List contains the following fields: {string.Join(", ", fields.Select(f => f.Name))}").ConfigureAwait(false); var subscriberCustomFields = new Dictionary() @@ -44,14 +44,14 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "MyCustomField2", DateTime.UtcNow }, { "MyCustomField3", "qwerty" } }; - var listMemberId = await client.Lists.SubscribeAsync(userKey, listId, "integration@testing.com", true, true, subscriberCustomFields, clientId).ConfigureAwait(false); + var listMemberId = await client.Lists.SubscribeAsync(userKey, listId, "integration@testing.com", true, true, subscriberCustomFields, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("One member added to the list").ConfigureAwait(false); var query = "`email`=\"integration@testing.com\""; - var subscribers = await client.Lists.GetMembersAsync(userKey, listId, query: query, clientId: clientId).ConfigureAwait(false); + var subscribers = await client.Lists.GetMembersAsync(userKey, listId, query: query, clientId: clientId, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Subscribers retrieved: {subscribers.Count()}").ConfigureAwait(false); - var subscriber = await client.Lists.GetMemberAsync(userKey, listId, listMemberId, clientId).ConfigureAwait(false); + var subscriber = await client.Lists.GetMemberAsync(userKey, listId, listMemberId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Subscriber retrieved: {subscriber.Email}").ConfigureAwait(false); var member1 = new ListMember @@ -74,13 +74,13 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "MyCustomField3", "azerty" } } }; - var importResult = await client.Lists.ImportAsync(userKey, listId, new[] { member1, member2 }, false, false, clientId).ConfigureAwait(false); + var importResult = await client.Lists.ImportAsync(userKey, listId, new[] { member1, member2 }, false, false, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("Two members imported into the list").ConfigureAwait(false); - var members = await client.Lists.GetMembersAsync(userKey, listId, null, null, null, null, null, null, clientId).ConfigureAwait(false); + var members = await client.Lists.GetMembersAsync(userKey, listId, null, null, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All list members retrieved. Count = {members.Count()}").ConfigureAwait(false); - var membersCount = await client.Lists.GetMembersCountAsync(userKey, listId, null, clientId).ConfigureAwait(false); + var membersCount = await client.Lists.GetMembersCountAsync(userKey, listId, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Members count = {membersCount}").ConfigureAwait(false); var customFieldsToUpdate = new Dictionary @@ -88,26 +88,26 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "MyCustomField1", 555555 }, { "MyCustomField3", "zzzzzzzzzzzzzzzzzzzzzzzzzz" } }; - var memberUpdated = await client.Lists.UpdateMemberAsync(userKey, listId, 1, customFieldsToUpdate, clientId).ConfigureAwait(false); + var memberUpdated = await client.Lists.UpdateMemberAsync(userKey, listId, 1, customFieldsToUpdate, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Member updated: {(memberUpdated ? "success" : "failed")}").ConfigureAwait(false); - var logs = await client.Lists.GetLogsAsync(userKey, listId, LogType.Open, false, false, null, null, null, null, clientId).ConfigureAwait(false); + var logs = await client.Lists.GetLogsAsync(userKey, listId, LogType.Open, false, false, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Retrieved 'Opens'. Count = {logs.Count()}").ConfigureAwait(false); - var firstSegmentId = await client.Segments.CreateAsync(userKey, listId, "Segment #1", "(`email` LIKE \"aa%\")", clientId).ConfigureAwait(false); - var secondSegmentId = await client.Segments.CreateAsync(userKey, listId, "Segment #2", "(`email` LIKE \"bb%\")", clientId).ConfigureAwait(false); + var firstSegmentId = await client.Segments.CreateAsync(userKey, listId, "Segment #1", "(`email` LIKE \"aa%\")", clientId, cancellationToken).ConfigureAwait(false); + var secondSegmentId = await client.Segments.CreateAsync(userKey, listId, "Segment #2", "(`email` LIKE \"bb%\")", clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("Two segments created").ConfigureAwait(false); - var segments = await client.Segments.GetSegmentsAsync(userKey, listId, 0, 0, true, clientId).ConfigureAwait(false); + var segments = await client.Segments.GetSegmentsAsync(userKey, listId, 0, 0, true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Segments retrieved. Count = {segments.Count()}").ConfigureAwait(false); - var firstSegmentDeleted = await client.Segments.DeleteAsync(userKey, firstSegmentId, clientId).ConfigureAwait(false); + var firstSegmentDeleted = await client.Segments.DeleteAsync(userKey, firstSegmentId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("First segment deleted").ConfigureAwait(false); - var secondSegmentDeleted = await client.Segments.DeleteAsync(userKey, secondSegmentId, clientId).ConfigureAwait(false); + var secondSegmentDeleted = await client.Segments.DeleteAsync(userKey, secondSegmentId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("Second segment deleted").ConfigureAwait(false); - var deleted = await client.Lists.DeleteAsync(userKey, listId, clientId).ConfigureAwait(false); + var deleted = await client.Lists.DeleteAsync(userKey, listId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List deleted: {(deleted ? "success" : "failed")}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/MailingsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/MailingsTests.cs index c0be885..b3c86a6 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/MailingsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/MailingsTests.cs @@ -1,4 +1,4 @@ -using CakeMail.RestClient.Models; +using CakeMail.RestClient.Models; using System; using System.IO; using System.Linq; @@ -13,42 +13,42 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** MAILINGS *****").ConfigureAwait(false); - var mailings = await client.Mailings.GetMailingsAsync(userKey, null, MailingType.Standard, null, null, null, null, null, null, MailingsSortBy.Name, SortDirection.Descending, null, null, clientId).ConfigureAwait(false); + var mailings = await client.Mailings.GetMailingsAsync(userKey, null, MailingType.Standard, null, null, null, null, null, null, MailingsSortBy.Name, SortDirection.Descending, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All mailings retrieved. Count = {mailings.Count()}").ConfigureAwait(false); - var mailingsCount = await client.Mailings.GetCountAsync(userKey, null, MailingType.Standard, null, null, null, null, null, null, clientId).ConfigureAwait(false); + var mailingsCount = await client.Mailings.GetCountAsync(userKey, null, MailingType.Standard, null, null, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailings count = {mailingsCount}").ConfigureAwait(false); - var mailingId = await client.Mailings.CreateAsync(userKey, "Integration Testing", clientId: clientId).ConfigureAwait(false); + var mailingId = await client.Mailings.CreateAsync(userKey, "Integration Testing", clientId: clientId, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New mailing created. Id: {mailingId}").ConfigureAwait(false); - var lists = await client.Lists.GetListsAsync(userKey, ListStatus.Active, null, ListsSortBy.Name, SortDirection.Descending, 1, 0, clientId).ConfigureAwait(false); + var lists = await client.Lists.GetListsAsync(userKey, ListStatus.Active, null, ListsSortBy.Name, SortDirection.Descending, 1, 0, clientId, cancellationToken).ConfigureAwait(false); var list = lists.First(); - var updated = await client.Mailings.UpdateAsync(userKey, mailingId, name: "UPDATED Integration Test", listId: list.Id, htmlContent: "Hello World in HTML. CakeMail web site", textContent: "Hello World in text", subject: "This is a test", clientId: clientId).ConfigureAwait(false); + var updated = await client.Mailings.UpdateAsync(userKey, mailingId, name: "UPDATED Integration Test", listId: list.Id, htmlContent: "Hello World in HTML. CakeMail web site", textContent: "Hello World in text", subject: "This is a test", clientId: clientId, cancellationToken: cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var mailing = await client.Mailings.GetAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var mailing = await client.Mailings.GetAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing retrieved: Name = {mailing.Name}").ConfigureAwait(false); - var testSent = await client.Mailings.SendTestEmailAsync(userKey, mailingId, "integration@testing.com", true, clientId).ConfigureAwait(false); + var testSent = await client.Mailings.SendTestEmailAsync(userKey, mailingId, "integration@testing.com", true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Test sent: {(testSent ? "success" : "failed")}").ConfigureAwait(false); - var rawEmail = await client.Mailings.GetRawEmailMessageAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var rawEmail = await client.Mailings.GetRawEmailMessageAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing raw email: {rawEmail.Message}").ConfigureAwait(false); - var rawHtml = await client.Mailings.GetRawHtmlAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var rawHtml = await client.Mailings.GetRawHtmlAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing raw html: {rawHtml}").ConfigureAwait(false); - var rawText = await client.Mailings.GetRawTextAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var rawText = await client.Mailings.GetRawTextAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing raw text: {rawText}").ConfigureAwait(false); - var scheduled = await client.Mailings.ScheduleAsync(userKey, mailingId, DateTime.UtcNow.AddDays(2), clientId).ConfigureAwait(false); + var scheduled = await client.Mailings.ScheduleAsync(userKey, mailingId, DateTime.UtcNow.AddDays(2), clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing scheduled: {(scheduled ? "success" : "failed")}").ConfigureAwait(false); - var unscheduled = await client.Mailings.UnscheduleAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var unscheduled = await client.Mailings.UnscheduleAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing unscheduled: {(unscheduled ? "success" : "failed")}").ConfigureAwait(false); - var deleted = await client.Mailings.DeleteAsync(userKey, mailingId, clientId).ConfigureAwait(false); + var deleted = await client.Mailings.DeleteAsync(userKey, mailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing deleted: {(deleted ? "success" : "failed")}").ConfigureAwait(false); var sentMailings = mailings.Where(m => m.Status == MailingStatus.Delivered); @@ -56,19 +56,19 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { var sentMailingId = sentMailings.First().Id; - var logs = await client.Mailings.GetLogsAsync(userKey, sentMailingId, null, null, false, false, null, null, 25, 0, clientId).ConfigureAwait(false); + var logs = await client.Mailings.GetLogsAsync(userKey, sentMailingId, null, null, false, false, null, null, 25, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing logs retrieved. Count = {logs.Count()}").ConfigureAwait(false); - var links = await client.Mailings.GetLinksAsync(userKey, sentMailingId, null, null, clientId).ConfigureAwait(false); + var links = await client.Mailings.GetLinksAsync(userKey, sentMailingId, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing links retrieved. Count = {links.Count()}").ConfigureAwait(false); - var linksCount = await client.Mailings.GetLinksCountAsync(userKey, sentMailingId, clientId).ConfigureAwait(false); + var linksCount = await client.Mailings.GetLinksCountAsync(userKey, sentMailingId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing links count = {linksCount}").ConfigureAwait(false); - var linksStats = await client.Mailings.GetLinksWithStatsAsync(userKey, sentMailingId, null, null, null, null, clientId).ConfigureAwait(false); + var linksStats = await client.Mailings.GetLinksWithStatsAsync(userKey, sentMailingId, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing links stats retrieved. Count = {linksStats}").ConfigureAwait(false); - var linksStatsCount = await client.Mailings.GetLinksWithStatsCountAsync(userKey, sentMailingId, null, null, null, null, clientId).ConfigureAwait(false); + var linksStatsCount = await client.Mailings.GetLinksWithStatsCountAsync(userKey, sentMailingId, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Mailing links stats count = {linksStatsCount}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/PermissionsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/PermissionsTests.cs index 53bbef3..15f3917 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/PermissionsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/PermissionsTests.cs @@ -12,22 +12,22 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** PERMISSIONS *****").ConfigureAwait(false); - var users = await client.Users.GetUsersAsync(userKey, UserStatus.Active, null, null, clientId).ConfigureAwait(false); + var users = await client.Users.GetUsersAsync(userKey, UserStatus.Active, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync("All users retrieved").ConfigureAwait(false); var user = users.First(); await log.WriteLineAsync($"For testing purposes, we selected {user.FirstName} {user.LastName}").ConfigureAwait(false); - var originalUserPermissions = await client.Permissions.GetUserPermissionsAsync(userKey, user.Id, clientId).ConfigureAwait(false); + var originalUserPermissions = await client.Permissions.GetUserPermissionsAsync(userKey, user.Id, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Current user permissions: {string.Join(", ", originalUserPermissions)}").ConfigureAwait(false); - var updated = await client.Permissions.SetUserPermissionsAsync(userKey, user.Id, new[] { "admin_settings" }, clientId).ConfigureAwait(false); + var updated = await client.Permissions.SetUserPermissionsAsync(userKey, user.Id, new[] { "admin_settings" }, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Permissions updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var newUserPermissions = await client.Permissions.GetUserPermissionsAsync(userKey, user.Id, clientId).ConfigureAwait(false); + var newUserPermissions = await client.Permissions.GetUserPermissionsAsync(userKey, user.Id, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New user permissions: {string.Join(", ", newUserPermissions)}").ConfigureAwait(false); - updated = await client.Permissions.SetUserPermissionsAsync(userKey, user.Id, originalUserPermissions, clientId).ConfigureAwait(false); + updated = await client.Permissions.SetUserPermissionsAsync(userKey, user.Id, originalUserPermissions, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Permissions reset to original values: {(updated ? "success" : "failed")}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/RelaysTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/RelaysTests.cs index ce09809..9e9d28a 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/RelaysTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/RelaysTests.cs @@ -11,10 +11,10 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** RELAYS *****").ConfigureAwait(false); - var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "integration@testing.com", "Sent from integration test", "Sent from integration test (HTML)", "Sent from integration test (TEXT)", "sender@integrationtesting.com", "Integration Testing", null, null, clientId).ConfigureAwait(false); + var sent = await client.Relays.SendWithoutTrackingAsync(userKey, "integration@testing.com", "Sent from integration test", "Sent from integration test (HTML)", "Sent from integration test (TEXT)", "sender@integrationtesting.com", "Integration Testing", null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Relay sent: {(sent ? "success" : "failed")}").ConfigureAwait(false); - var sentLogs = await client.Relays.GetSentLogsAsync(userKey, null, null, null, null, null, clientId).ConfigureAwait(false); + var sentLogs = await client.Relays.GetSentLogsAsync(userKey, null, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Sent Logs: {sentLogs.Count()}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/SuppressionListsTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/SuppressionListsTests.cs index 4c53e87..1fc0a3f 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/SuppressionListsTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/SuppressionListsTests.cs @@ -11,22 +11,22 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** SUPPRESSION LISTS *****").ConfigureAwait(false); - var suppressEmailsResult = await client.SuppressionLists.AddEmailAddressesAsync(userKey, new string[] { "qwerty@azerty.com", "azerty@qwerty.com" }, clientId).ConfigureAwait(false); + var suppressEmailsResult = await client.SuppressionLists.AddEmailAddressesAsync(userKey, new string[] { "qwerty@azerty.com", "azerty@qwerty.com" }, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Email addresses suppressed: {string.Join(", ", suppressEmailsResult.Select(r => string.Format("{0}={1}", r.Email, string.IsNullOrEmpty(r.ErrorMessage) ? "success" : r.ErrorMessage)))}").ConfigureAwait(false); - var suppressedDomainResult = await client.SuppressionLists.AddDomainsAsync(userKey, new[] { "qwerty.com", "azerty.com" }, clientId).ConfigureAwait(false); + var suppressedDomainResult = await client.SuppressionLists.AddDomainsAsync(userKey, new[] { "qwerty.com", "azerty.com" }, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Email domains suppressed: {string.Join(", ", suppressedDomainResult.Select(r => string.Format("{0}={1}", r.Domain, string.IsNullOrEmpty(r.ErrorMessage) ? "success" : r.ErrorMessage)))}").ConfigureAwait(false); - var suppressedLocalPartsResult = await client.SuppressionLists.AddLocalPartsAsync(userKey, new[] { "qwerty", "azerty" }, clientId).ConfigureAwait(false); + var suppressedLocalPartsResult = await client.SuppressionLists.AddLocalPartsAsync(userKey, new[] { "qwerty", "azerty" }, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Email localparts suppressed: {string.Join(", ", suppressedLocalPartsResult.Select(r => string.Format("{0}={1}", r.LocalPart, string.IsNullOrEmpty(r.ErrorMessage) ? "success" : r.ErrorMessage)))}").ConfigureAwait(false); - var suppressedEmails = await client.SuppressionLists.GetEmailAddressesAsync(userKey, 0, 0, clientId).ConfigureAwait(false); + var suppressedEmails = await client.SuppressionLists.GetEmailAddressesAsync(userKey, 0, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Retrieved suppressed email addresses: {string.Join(", ", suppressedEmails.Select(r => r.Email))}").ConfigureAwait(false); - var suppressedDomains = await client.SuppressionLists.GetDomainsAsync(userKey, 0, 0, clientId).ConfigureAwait(false); + var suppressedDomains = await client.SuppressionLists.GetDomainsAsync(userKey, 0, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Retrieved suppressed email domains: {string.Join(", ", suppressedDomains)}").ConfigureAwait(false); - var suppressedLocalParts = await client.SuppressionLists.GetLocalPartsAsync(userKey, 0, 0, clientId).ConfigureAwait(false); + var suppressedLocalParts = await client.SuppressionLists.GetLocalPartsAsync(userKey, 0, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Retrieved suppressed localparts: {string.Join(", ", suppressedLocalParts)}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/TemplatesTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/TemplatesTests.cs index 5ac454b..9f3ad55 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/TemplatesTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/TemplatesTests.cs @@ -17,10 +17,10 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "en_US", "My Category" }, { "fr_FR", "Ma Catégorie" } }; - var categoryId = await client.Templates.CreateCategoryAsync(userKey, categoryLabels, true, true, clientId).ConfigureAwait(false); + var categoryId = await client.Templates.CreateCategoryAsync(userKey, categoryLabels, true, true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New template category created. Id: {categoryId}").ConfigureAwait(false); - var category = await client.Templates.GetCategoryAsync(userKey, categoryId, clientId).ConfigureAwait(false); + var category = await client.Templates.GetCategoryAsync(userKey, categoryId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template category retrieved: Name = {category.Name}").ConfigureAwait(false); categoryLabels = new Dictionary @@ -28,22 +28,22 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "en_US", "My Category UPDATED" }, { "fr_FR", "Ma Catégorie UPDATED" } }; - var categoryUpdated = await client.Templates.UpdateCategoryAsync(userKey, categoryId, categoryLabels, true, true, clientId).ConfigureAwait(false); + var categoryUpdated = await client.Templates.UpdateCategoryAsync(userKey, categoryId, categoryLabels, true, true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template category updated. Id: {categoryId}").ConfigureAwait(false); - var categories = await client.Templates.GetCategoriesAsync(userKey, 0, 0, clientId).ConfigureAwait(false); + var categories = await client.Templates.GetCategoriesAsync(userKey, 0, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All Template categories retrieved. Count = {categories.Count()}").ConfigureAwait(false); - var categoriesCount = await client.Templates.GetCategoriesCountAsync(userKey, clientId).ConfigureAwait(false); + var categoriesCount = await client.Templates.GetCategoriesCountAsync(userKey, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template categories count = {categoriesCount}").ConfigureAwait(false); - var permissions = await client.Templates.GetCategoryVisibilityAsync(userKey, categoryId, null, null, clientId).ConfigureAwait(false); + var permissions = await client.Templates.GetCategoryVisibilityAsync(userKey, categoryId, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template category permissions: {string.Join(", ", permissions.Select(p => string.Format("{0}={1}", p.CompanyName, p.Visible)))}").ConfigureAwait(false); if (permissions.Any()) { var newPermissions = permissions.ToDictionary(p => p.ClientId, p => false); - var permissionsRevoked = await client.Templates.SetCategoryVisibilityAsync(userKey, categoryId, newPermissions, clientId).ConfigureAwait(false); + var permissionsRevoked = await client.Templates.SetCategoryVisibilityAsync(userKey, categoryId, newPermissions, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template category permissions revoked: {(permissionsRevoked ? "success" : "failed")}").ConfigureAwait(false); } @@ -53,7 +53,7 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "fr_FR", "Mon Modèle" } }; var templateContent = "Hello World"; - var templateId = await client.Templates.CreateAsync(userKey, templateLabels, templateContent, categoryId, clientId).ConfigureAwait(false); + var templateId = await client.Templates.CreateAsync(userKey, templateLabels, templateContent, categoryId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template created. Id = {templateId}").ConfigureAwait(false); templateLabels = new Dictionary @@ -61,19 +61,19 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { "en_US", "My Template UPDATED" }, { "fr_FR", "Ma Modèle UPDATED" } }; - var templateUpdated = await client.Templates.UpdateAsync(userKey, templateId, templateLabels, templateContent, categoryId, clientId).ConfigureAwait(false); + var templateUpdated = await client.Templates.UpdateAsync(userKey, templateId, templateLabels, templateContent, categoryId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template updated. Id: {templateId}").ConfigureAwait(false); - var templates = await client.Templates.GetTemplatesAsync(userKey, categoryId, null, null, clientId).ConfigureAwait(false); + var templates = await client.Templates.GetTemplatesAsync(userKey, categoryId, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All Templates retrieved. Count = {templates.Count()}").ConfigureAwait(false); - var template = await client.Templates.GetAsync(userKey, templateId, clientId).ConfigureAwait(false); + var template = await client.Templates.GetAsync(userKey, templateId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template retrieved: Name = {template.Name}").ConfigureAwait(false); - var templateDeleted = await client.Templates.DeleteAsync(userKey, templateId, clientId).ConfigureAwait(false); + var templateDeleted = await client.Templates.DeleteAsync(userKey, templateId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template deleted: {(templateDeleted ? "success" : "failed")}").ConfigureAwait(false); - var categoryDeleted = await client.Templates.DeleteCategoryAsync(userKey, categoryId, clientId).ConfigureAwait(false); + var categoryDeleted = await client.Templates.DeleteCategoryAsync(userKey, categoryId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Template category deleted: {(categoryDeleted ? "success" : "failed")}").ConfigureAwait(false); } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/TriggersTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/TriggersTests.cs index 61aefe6..fcdd31c 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/TriggersTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/TriggersTests.cs @@ -1,4 +1,4 @@ -using CakeMail.RestClient.Models; +using CakeMail.RestClient.Models; using System.IO; using System.Linq; using System.Threading; @@ -12,72 +12,75 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** TRIGGERS *****").ConfigureAwait(false); - var listId = await client.Lists.CreateAsync(userKey, "INTEGRATION TESTING list for trigger", "Bob Smith", "bobsmith@fictitiouscomapny.com", true, clientId).ConfigureAwait(false); + var listId = await client.Lists.CreateAsync(userKey, "INTEGRATION TESTING list for trigger", "Bob Smith", "bobsmith@fictitiouscomapny.com", true, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New list created. Id: {listId}").ConfigureAwait(false); - var listMemberId = await client.Lists.SubscribeAsync(userKey, listId, "recipient@destination.com", true, true, null, clientId).ConfigureAwait(false); + var listMemberId = await client.Lists.SubscribeAsync(userKey, listId, "recipient@destination.com", true, true, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New member subscribed to the list. Id: {listMemberId}").ConfigureAwait(false); - var campaignId = await client.Campaigns.CreateAsync(userKey, "INTEGRATION TESTING campaign for trigger", clientId).ConfigureAwait(false); + var campaignId = await client.Campaigns.CreateAsync(userKey, "INTEGRATION TESTING campaign for trigger", clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New campaign created. Id: {campaignId}").ConfigureAwait(false); - var triggers = await client.Triggers.GetTriggersAsync(userKey, TriggerStatus.Active, null, null, null, null, null, clientId).ConfigureAwait(false); + var triggers = await client.Triggers.GetTriggersAsync(userKey, TriggerStatus.Active, null, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Active triggers retrieved. Count = {triggers.Count()}").ConfigureAwait(false); - var triggersCount = await client.Triggers.GetCountAsync(userKey, TriggerStatus.Active, null, null, null, clientId).ConfigureAwait(false); + var triggersCount = await client.Triggers.GetCountAsync(userKey, TriggerStatus.Active, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Active triggers count = {triggersCount}").ConfigureAwait(false); - var triggerId = await client.Triggers.CreateAsync(userKey, "Integration Testing: trigger", listId, campaignId, null, null, clientId).ConfigureAwait(false); + var triggerId = await client.Triggers.CreateAsync(userKey, "Integration Testing: trigger", listId, campaignId, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New trigger created. Id: {triggerId}").ConfigureAwait(false); - var trigger = await client.Triggers.GetAsync(userKey, triggerId, clientId).ConfigureAwait(false); + var trigger = await client.Triggers.GetAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger retrieved: Name = {trigger.Name}").ConfigureAwait(false); - var updated = await client.Triggers.UpdateAsync(userKey, triggerId, name: "UPDATED INTEGRATION TEST: trigger", htmlContent: "Hello World in HTML. CakeMail web site", textContent: "Hello World in text", subject: "This is a test", trackClicksInHtml: true, trackClicksInText: true, trackOpens: true, clientId: clientId).ConfigureAwait(false); + var updated = await client.Triggers.UpdateAsync(userKey, triggerId, action: TriggerAction.OptIn, name: "UPDATED INTEGRATION TEST: trigger", htmlContent: "Hello World in HTML. CakeMail web site", textContent: "Hello World in text", subject: "This is a test", trackClicksInHtml: true, trackClicksInText: true, trackOpens: true, clientId: clientId).ConfigureAwait(false); await log.WriteLineAsync($"Trigger updated: {(updated ? "success" : "failed")}").ConfigureAwait(false); - var rawEmail = await client.Triggers.GetRawEmailMessageAsync(userKey, triggerId, clientId).ConfigureAwait(false); + var rawEmail = await client.Triggers.GetRawEmailMessageAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger raw email: {rawEmail.Message}").ConfigureAwait(false); - var rawHtml = await client.Triggers.GetRawHtmlAsync(userKey, triggerId, clientId).ConfigureAwait(false); + var rawHtml = await client.Triggers.GetRawHtmlAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger raw html: {rawHtml}").ConfigureAwait(false); - var rawText = await client.Triggers.GetRawTextAsync(userKey, triggerId, clientId).ConfigureAwait(false); + var rawText = await client.Triggers.GetRawTextAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger raw text: {rawText}").ConfigureAwait(false); - var unleashed = await client.Triggers.UnleashAsync(userKey, triggerId, listMemberId, clientId).ConfigureAwait(false); + var unleashed = await client.Triggers.UnleashAsync(userKey, triggerId, listMemberId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger unleashed: {(unleashed ? "success" : "failed")}").ConfigureAwait(false); // Short pause to allow CakeMail to send the trigger await Task.Delay(2000).ConfigureAwait(false); - var logs = await client.Triggers.GetLogsAsync(userKey, triggerId, null, null, false, false, null, null, null, null, clientId).ConfigureAwait(false); + var logs = await client.Triggers.GetLogsAsync(userKey, triggerId, null, null, false, false, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger logs retrieved. Count = {logs.Count()}").ConfigureAwait(false); - var links = await client.Triggers.GetLinksAsync(userKey, triggerId, 0, 0, clientId).ConfigureAwait(false); + var links = await client.Triggers.GetLinksAsync(userKey, triggerId, 0, 0, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger links retrieved. Count = {links.Count()}").ConfigureAwait(false); - var linksCount = await client.Triggers.GetLinksCountAsync(userKey, triggerId, clientId).ConfigureAwait(false); + var linksCount = await client.Triggers.GetLinksCountAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger links count = {linksCount}").ConfigureAwait(false); - var linksStats = await client.Triggers.GetLinksWithStatsAsync(userKey, triggerId, null, null, null, null, clientId).ConfigureAwait(false); + var linksStats = await client.Triggers.GetLinksWithStatsAsync(userKey, triggerId, null, null, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger links stats retrieved. Count = {linksStats.Count()}").ConfigureAwait(false); - var linksStatsCount = await client.Triggers.GetLinksWithStatsCountAsync(userKey, triggerId, null, null, clientId).ConfigureAwait(false); + var linksStatsCount = await client.Triggers.GetLinksWithStatsCountAsync(userKey, triggerId, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Trigger links stats count = {linksStatsCount}").ConfigureAwait(false); if (links.Any()) { // As of May 2015, CakeMail has not implemented despite documenting in on their web site - //var link = client.Triggers.GetLink(userKey, links.First().Id, clientId); + //var link = client.Triggers.GetLink(userKey, links.First().Id, clientId, cancellationToken); //await log.WriteLineAsync($"Trigger link retrieved. URI = {0}", link.Uri).ConfigureAwait(false); } - var listDeleted = await client.Lists.DeleteAsync(userKey, listId, clientId).ConfigureAwait(false); + var listDeleted = await client.Lists.DeleteAsync(userKey, listId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List deleted: {(listDeleted ? "success" : "failed")}").ConfigureAwait(false); - var campaignDeleted = await client.Campaigns.DeleteAsync(userKey, campaignId, clientId).ConfigureAwait(false); + var campaignDeleted = await client.Campaigns.DeleteAsync(userKey, campaignId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"List deleted: {(campaignDeleted ? "success" : "failed")}").ConfigureAwait(false); + + var triggerDeleted = await client.Triggers.DeleteAsync(userKey, triggerId, clientId, cancellationToken).ConfigureAwait(false); + await log.WriteLineAsync($"Trigger deleted: {(triggerDeleted ? "success" : "failed")}").ConfigureAwait(false); } } } diff --git a/Source/CakeMail.RestClient.IntegrationTests/Tests/UsersTests.cs b/Source/CakeMail.RestClient.IntegrationTests/Tests/UsersTests.cs index 51fd2c9..b2ad981 100644 --- a/Source/CakeMail.RestClient.IntegrationTests/Tests/UsersTests.cs +++ b/Source/CakeMail.RestClient.IntegrationTests/Tests/UsersTests.cs @@ -12,22 +12,22 @@ public static async Task ExecuteAllMethods(ICakeMailRestClient client, string us { await log.WriteLineAsync("\n***** USERS *****").ConfigureAwait(false); - var users = await client.Users.GetUsersAsync(userKey, UserStatus.Active, null, null, clientId).ConfigureAwait(false); + var users = await client.Users.GetUsersAsync(userKey, UserStatus.Active, null, null, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"All users retrieved. Count = {users.Count()}").ConfigureAwait(false); - var usersCount = await client.Users.GetCountAsync(userKey, UserStatus.Active, clientId).ConfigureAwait(false); + var usersCount = await client.Users.GetCountAsync(userKey, UserStatus.Active, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"Users count = {usersCount}").ConfigureAwait(false); - var userId = await client.Users.CreateAsync(userKey, string.Format("bogus{0:00}@dummy.com", usersCount), "Integration", "Testing", "Test", "4045555555", "7701234567", "en_US", "dummy_password", 542, clientId).ConfigureAwait(false); + var userId = await client.Users.CreateAsync(userKey, string.Format("bogus{0:00}@dummy.com", usersCount), "Integration", "Testing", "Test", "4045555555", "7701234567", "en_US", "dummy_password", 542, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"New user created. Id: {userId}").ConfigureAwait(false); - var user = await client.Users.GetAsync(userKey, userId, clientId).ConfigureAwait(false); + var user = await client.Users.GetAsync(userKey, userId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"User retrieved: Name = {user.FirstName} {user.LastName}").ConfigureAwait(false); - var deactivated = await client.Users.DeactivateAsync(userKey, userId, clientId).ConfigureAwait(false); + var deactivated = await client.Users.DeactivateAsync(userKey, userId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"User deactivate: {(deactivated ? "success" : "failed")}").ConfigureAwait(false); - var deleted = await client.Users.DeleteAsync(userKey, userId, clientId).ConfigureAwait(false); + var deleted = await client.Users.DeleteAsync(userKey, userId, clientId, cancellationToken).ConfigureAwait(false); await log.WriteLineAsync($"User deleted: {(deleted ? "success" : "failed")}").ConfigureAwait(false); } }