Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Commit

Permalink
Change the date_field parameter on Triggers.UpdateAsync from DateTime…
Browse files Browse the repository at this point in the history
… to string

Resolves #49
  • Loading branch information
Jericho committed Nov 26, 2017
1 parent 86bac65 commit 727e213
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Source/CakeMail.RestClient.UnitTests/Resources/Triggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -553,15 +553,15 @@ public async Task UpdateTrigger_with_datefield()
{
// Arrange
var triggerId = 123L;
var date = new DateTime(2015, 12, 1, 13, 6, 6);
var dateField = "birthday";

var jsonResponse = "{\"status\":\"success\",\"data\":\"true\"}";
var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, Utils.GetCakeMailApiUri("Trigger/SetInfo")).Respond("application/json", jsonResponse);

// Act
var apiClient = new CakeMailRestClient(API_KEY, httpClient: mockHttp.ToHttpClient());
var result = await apiClient.Triggers.UpdateAsync(USER_KEY, triggerId, date: date);
var result = await apiClient.Triggers.UpdateAsync(USER_KEY, triggerId, dateField: dateField);

// Assert
result.ShouldBeTrue();
Expand Down
4 changes: 2 additions & 2 deletions Source/CakeMail.RestClient/Resources/ITriggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ public interface ITriggers
/// <param name="trackingParameters">Additional tracking parameters for links.</param>
/// <param name="delay">Delay (in seconds) to be used when the trigger is unleashed.</param>
/// <param name="status">Status of the trigger. Possible values: 'active', 'inactive'</param>
/// <param name="date">DateTime to be used for trigger with action 'specific' or 'annual'.</param>
/// <param name="dateField">DateTime field to be used for trigger with action 'specific' or 'annual'.</param>
/// <param name="clientId">Client ID of the client in which the trigger is located.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>True if the trigger was updated</returns>
Task<bool> UpdateAsync(string userKey, long triggerId, long? campaignId = default(long?), string name = null, TriggerAction? action = default(TriggerAction?), MessageEncoding? encoding = default(MessageEncoding?), TransferEncoding? transferEncoding = default(TransferEncoding?), string subject = null, string senderEmail = null, string senderName = null, string replyTo = null, string htmlContent = null, string textContent = null, bool? trackOpens = default(bool?), bool? trackClicksInHtml = default(bool?), bool? trackClicksInText = default(bool?), string trackingParameters = null, int? delay = default(int?), TriggerStatus? status = default(TriggerStatus?), DateTime? date = default(DateTime?), long? clientId = default(long?), CancellationToken cancellationToken = default(CancellationToken));
Task<bool> UpdateAsync(string userKey, long triggerId, long? campaignId = default(long?), string name = null, TriggerAction? action = default(TriggerAction?), MessageEncoding? encoding = default(MessageEncoding?), TransferEncoding? transferEncoding = default(TransferEncoding?), string subject = null, string senderEmail = null, string senderName = null, string replyTo = null, string htmlContent = null, string textContent = null, bool? trackOpens = default(bool?), bool? trackClicksInHtml = default(bool?), bool? trackClicksInText = default(bool?), string trackingParameters = null, int? delay = default(int?), TriggerStatus? status = default(TriggerStatus?), string dateField = null, long? clientId = default(long?), CancellationToken cancellationToken = default(CancellationToken));
}
}
6 changes: 3 additions & 3 deletions Source/CakeMail.RestClient/Resources/Triggers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ public Task<Trigger> GetAsync(string userKey, long triggerId, long? clientId = n
/// <param name="trackingParameters">Additional tracking parameters for links.</param>
/// <param name="delay">Delay (in seconds) to be used when the trigger is unleashed.</param>
/// <param name="status">Status of the trigger. Possible values: 'active', 'inactive'</param>
/// <param name="date">DateTime to be used for trigger with action 'specific' or 'annual'.</param>
/// <param name="dateField">DateTime field to be used for trigger with action 'specific' or 'annual'.</param>
/// <param name="clientId">Client ID of the client in which the trigger is located.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>True if the trigger was updated</returns>
public Task<bool> UpdateAsync(string userKey, long triggerId, long? campaignId = null, string name = null, TriggerAction? action = null, MessageEncoding? encoding = null, TransferEncoding? transferEncoding = null, string subject = null, string senderEmail = null, string senderName = null, string replyTo = null, string htmlContent = null, string textContent = null, bool? trackOpens = null, bool? trackClicksInHtml = null, bool? trackClicksInText = null, string trackingParameters = null, int? delay = null, TriggerStatus? status = null, DateTime? date = null, long? clientId = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<bool> UpdateAsync(string userKey, long triggerId, long? campaignId = null, string name = null, TriggerAction? action = null, MessageEncoding? encoding = null, TransferEncoding? transferEncoding = null, string subject = null, string senderEmail = null, string senderName = null, string replyTo = null, string htmlContent = null, string textContent = null, bool? trackOpens = null, bool? trackClicksInHtml = null, bool? trackClicksInText = null, string trackingParameters = null, int? delay = null, TriggerStatus? status = null, string dateField = null, long? clientId = null, CancellationToken cancellationToken = default(CancellationToken))
{
var parameters = new List<KeyValuePair<string, object>>
{
Expand All @@ -137,7 +137,7 @@ public Task<bool> UpdateAsync(string userKey, long triggerId, long? campaignId =
if (trackingParameters != null) parameters.Add(new KeyValuePair<string, object>("tracking_params", trackingParameters));
if (delay != null) parameters.Add(new KeyValuePair<string, object>("delay", delay));
if (status.HasValue) parameters.Add(new KeyValuePair<string, object>("status", status.Value.GetEnumMemberValue()));
if (date.HasValue) parameters.Add(new KeyValuePair<string, object>("date_field", date.Value.ToCakeMailString()));
if (!string.IsNullOrEmpty(dateField)) parameters.Add(new KeyValuePair<string, object>("date_field", dateField));
if (clientId.HasValue) parameters.Add(new KeyValuePair<string, object>("client_id", clientId.Value));

return _client
Expand Down

0 comments on commit 727e213

Please sign in to comment.