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

Commit

Permalink
MailingType must be required when creating a Mailings
Browse files Browse the repository at this point in the history
Resolves #48
  • Loading branch information
Jericho committed Nov 19, 2017
1 parent b81f7ad commit 14ff193
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
18 changes: 0 additions & 18 deletions Source/CakeMail.RestClient.UnitTests/Resources/Mailings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,6 @@ public async Task CreateMailing_with_minimal_parameters()
result.ShouldBe(mailingId);
}

[Fact]
public async Task CreateMailing_without_type()
{
// Arrange
var name = "My new mailing";
var mailingId = 123L;
var jsonResponse = string.Format("{{\"status\":\"success\",\"data\":\"{0}\"}}", mailingId);
var mockHttp = new MockHttpMessageHandler();
mockHttp.Expect(HttpMethod.Post, Utils.GetCakeMailApiUri("Mailing/Create")).Respond("application/json", jsonResponse);

// Act
var apiClient = new CakeMailRestClient(API_KEY, httpClient: mockHttp.ToHttpClient());
var result = await apiClient.Mailings.CreateAsync(USER_KEY, name, type: null);

// Assert
result.ShouldBe(mailingId);
}

[Fact]
public async Task CreateMailing_with_campaignid()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/CakeMail.RestClient/Resources/IMailings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public interface IMailings
/// <param name="clientId">Client ID of the client in which the mailing is created.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>ID of the new mailing</returns>
Task<long> CreateAsync(string userKey, string name, long? campaignId = default(long?), MailingType? type = MailingType.Standard, long? recurringId = default(long?), MessageEncoding? encoding = default(MessageEncoding?), TransferEncoding? transferEncoding = default(TransferEncoding?), long? clientId = default(long?), CancellationToken cancellationToken = default(CancellationToken));
Task<long> CreateAsync(string userKey, string name, long? campaignId = default(long?), MailingType type = MailingType.Standard, long? recurringId = default(long?), MessageEncoding? encoding = default(MessageEncoding?), TransferEncoding? transferEncoding = default(TransferEncoding?), long? clientId = default(long?), CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Delete a mailing
Expand Down
6 changes: 3 additions & 3 deletions Source/CakeMail.RestClient/Resources/Mailings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ internal Mailings(IClient client)
/// <param name="clientId">Client ID of the client in which the mailing is created.</param>
/// <param name="cancellationToken">The cancellation token</param>
/// <returns>ID of the new mailing</returns>
public Task<long> CreateAsync(string userKey, string name, long? campaignId = null, MailingType? type = MailingType.Standard, long? recurringId = null, MessageEncoding? encoding = null, TransferEncoding? transferEncoding = null, long? clientId = null, CancellationToken cancellationToken = default(CancellationToken))
public Task<long> CreateAsync(string userKey, string name, long? campaignId = null, MailingType type = MailingType.Standard, long? recurringId = null, MessageEncoding? encoding = null, TransferEncoding? transferEncoding = null, long? clientId = null, CancellationToken cancellationToken = default(CancellationToken))
{
var parameters = new List<KeyValuePair<string, object>>
{
new KeyValuePair<string, object>("user_key", userKey),
new KeyValuePair<string, object>("name", name)
new KeyValuePair<string, object>("name", name),
new KeyValuePair<string, object>("type", type.GetEnumMemberValue())
};
if (campaignId.HasValue) parameters.Add(new KeyValuePair<string, object>("campaign_id", campaignId.Value));
if (type.HasValue) parameters.Add(new KeyValuePair<string, object>("type", type.Value.GetEnumMemberValue()));
if (recurringId.HasValue) parameters.Add(new KeyValuePair<string, object>("recurring_id", recurringId.Value));
if (encoding.HasValue) parameters.Add(new KeyValuePair<string, object>("encoding", encoding.Value.GetEnumMemberValue()));
if (transferEncoding.HasValue) parameters.Add(new KeyValuePair<string, object>("transfer_encoding", transferEncoding.Value.GetEnumMemberValue()));
Expand Down

0 comments on commit 14ff193

Please sign in to comment.