Skip to content

Commit

Permalink
Merge pull request #7 from cmdotcom/develop
Browse files Browse the repository at this point in the history
added filter to from addresses and from domains, added google analyti…
  • Loading branch information
cmmarlou authored May 27, 2020
2 parents 5842ae1 + a2b454f commit 365bf06
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
19 changes: 13 additions & 6 deletions CM.Email.Sdk/EmailClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class EmailClient : BaseClient
/// <param name="httpClient">The HttpClient to use for sending the instruction. You should use this as a singleton for your entire application</param>
/// <param name="apiKey">Your Product token, used for authentication (Found in the EmailCampaigns app in the "API credentials" page in Settings</param>
/// <param name="baseUrl">The base URL of the CM Email Campaigns API (Optional)</param>
public EmailClient(HttpClient httpClient, Guid apiKey, string baseUrl = "https://api.cmtelecom.com") : base(httpClient, apiKey, baseUrl) { }
public EmailClient(HttpClient httpClient, Guid apiKey, string baseUrl = "https://api.cm.com") : base(httpClient, apiKey, baseUrl) { }

#region From domains

Expand All @@ -31,12 +31,13 @@ public EmailClient(HttpClient httpClient, Guid apiKey, string baseUrl = "https:/
/// <param name="take">The amount of entities to retrieve from the result (Optional)</param>
/// <param name="cancellationToken">An optional cancellation token to abort this request</param>
/// <returns></returns>
public async Task<Paginated<FromDomain>> GetFromDomainsAsync(Guid accountID, int? skip = null, int? take = null, CancellationToken cancellationToken = default)
public async Task<Paginated<FromDomain>> GetFromDomainsAsync(Guid accountID, int? skip = null, int? take = null, string filter = null, CancellationToken cancellationToken = default)
{
QueryStringBuilder query = new QueryStringBuilder($"/bulkemail/v1.0/accounts/{accountID}/fromdomains");

if (skip != default) query.Add("skip", skip);
if (take != default) query.Add("take", take);
if (filter != default) query.Add("filter", filter);

return await GetPaginatedAsync<FromDomain>(query, cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -101,12 +102,13 @@ public async Task DeleteFromDomainAsync(Guid accountID, Guid fromDomainID, Cance
/// <param name="take">The amount of entities to retrieve from the result (Optional)</param>
/// <param name="cancellationToken">An optional cancellation token to abort this request</param>
/// <returns></returns>
public async Task<Paginated<FromAddress>> GetFromAddressesAsync(Guid accountID, int? skip = null, int? take = null, CancellationToken cancellationToken = default)
public async Task<Paginated<FromAddress>> GetFromAddressesAsync(Guid accountID, int? skip = null, int? take = null, string filter = null, CancellationToken cancellationToken = default)
{
QueryStringBuilder query = new QueryStringBuilder($"/bulkemail/v1.0/accounts/{accountID}/fromaddresses");

if (skip != default) query.Add("skip", skip);
if (take != default) query.Add("take", take);
if (filter != default) query.Add("filter", filter);

return await GetPaginatedAsync<FromAddress>(query, cancellationToken).ConfigureAwait(false);
}
Expand Down Expand Up @@ -261,14 +263,15 @@ public async Task DeleteTemplateAsync(Guid accountID, Guid templateID, Cancellat
/// <param name="campaignTypeID">This is the ID of the CampaignType that you want filter the campaigns on</param>
/// <param name="cancellationToken">An optional cancellation token to abort this request</param>
/// <returns></returns>
public async Task<Paginated<Campaign>> GetCampaignsAsync(Guid accountID, int? skip = null, int? take = null, string filter = null, string campaignTypeID = null, string[] campaignTags = null, CancellationToken cancellationToken = default)
public async Task<Paginated<Campaign>> GetCampaignsAsync(Guid accountID, int? skip = null, int? take = null, string filter = null, string campaignTypeID = null, bool? includePreviewHtmlBody = null, string[] campaignTags = null, CancellationToken cancellationToken = default)
{
QueryStringBuilder query = new QueryStringBuilder($"/bulkemail/v1.0/accounts/{accountID}/campaigns");

if (skip != default) query.Add("skip", skip);
if (take != default) query.Add("take", take);
if (filter != default) query.Add("filter", filter);
if (campaignTypeID != default) query.Add("campaignTypeID", campaignTypeID);
if (includePreviewHtmlBody != default) query.Add("includePreviewHtmlBody", includePreviewHtmlBody);
if (campaignTags != default(string[])) query.AddRange("campaignTags", campaignTags);

return await GetPaginatedAsync<Campaign>(query, cancellationToken).ConfigureAwait(false);
Expand All @@ -281,9 +284,13 @@ public async Task<Paginated<Campaign>> GetCampaignsAsync(Guid accountID, int? sk
/// <param name="campaignID">This is the ID of the Campaign that you want to retrieve</param>
/// <param name="cancellationToken">An optional cancellation token to abort this request</param>
/// <returns></returns>
public async Task<Campaign> GetCampaignAsync(Guid accountID, Guid campaignID, CancellationToken cancellationToken = default)
public async Task<Campaign> GetCampaignAsync(Guid accountID, Guid campaignID, bool? includePreviewHtmlBody = null, CancellationToken cancellationToken = default)
{
return await GetAsync<Campaign>($"/bulkemail/v1.0/accounts/{accountID}/campaigns/{campaignID}", cancellationToken).ConfigureAwait(false);
QueryStringBuilder query = new QueryStringBuilder($"/bulkemail/v1.0/accounts/{accountID}/campaigns/{campaignID}");

if (includePreviewHtmlBody != default) query.Add("includePreviewHtmlBody", includePreviewHtmlBody);

return await GetAsync<Campaign>(query, cancellationToken).ConfigureAwait(false);
}

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions CM.Email.Sdk/Models/Campaign.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public class Campaign
/// </summary>
public CampaignTag[] CampaignTags { get; set; }

/// <summary>
/// The Google Analytics tracking settings for this campaign
/// </summary>
public GoogleAnalyticsTracking GoogleAnalyticsTracking { get; set; }

/// <summary>
/// When the campaign was created
/// </summary>
Expand Down
24 changes: 24 additions & 0 deletions CM.Email.Sdk/Models/GoogleAnalyticsTracking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CM.Email.Sdk.Models
{
public class GoogleAnalyticsTracking
{
/// <summary>
/// The source to put in the utm_source tag
/// </summary>
public string Source { get; set; }

/// <summary>
/// The medium to put in the utm_medium tag
/// </summary>
public string Medium { get; set; }

/// <summary>
/// The campaign to put in the utm_campaign tag
/// </summary>
public string Campaign { get; set; }
}
}

0 comments on commit 365bf06

Please sign in to comment.