Skip to content

Commit

Permalink
Refactor code around MessageStreams in Sending API
Browse files Browse the repository at this point in the history
  • Loading branch information
vladsandu committed Mar 18, 2020
1 parent 8d5f125 commit b784726
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/Postmark.Tests/ClientTemplateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,15 @@ public async void ClientCanUseLayoutTemplatesWhenValidating()
public async void ClientCanSendWithTemplate()
{
var template = await _client.CreateTemplateAsync("test template name", "test subject", "test html body");
var sendResult = await _client.SendEmailWithTemplateAsync(template.TemplateId, new { name = "Andrew" },
WRITE_TEST_SENDER_EMAIL_ADDRESS, WRITE_TEST_SENDER_EMAIL_ADDRESS, false, messageStream: PostmarkMessageBase.DefaultTransactionalStream);
var sendResult = await _client.SendEmailWithTemplateAsync(template.TemplateId, new { name = "Andrew" }, WRITE_TEST_SENDER_EMAIL_ADDRESS, WRITE_TEST_SENDER_EMAIL_ADDRESS, false);
Assert.NotEqual(Guid.Empty, sendResult.MessageID);
}

[Fact]
public async void ClientCanSendTemplateWithStringModel()
{
var template = await _client.CreateTemplateAsync("test template name", "test subject", "test html body");
var sendResult = await _client.SendEmailWithTemplateAsync(template.TemplateId, "{ \"name\" : \"Andrew\" }",
WRITE_TEST_SENDER_EMAIL_ADDRESS, WRITE_TEST_SENDER_EMAIL_ADDRESS, false, messageStream: PostmarkMessageBase.DefaultTransactionalStream);
var sendResult = await _client.SendEmailWithTemplateAsync(template.TemplateId, "{ \"name\" : \"Andrew\" }", WRITE_TEST_SENDER_EMAIL_ADDRESS, WRITE_TEST_SENDER_EMAIL_ADDRESS, false);
Assert.NotEqual(Guid.Empty, sendResult.MessageID);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Postmark/Model/PostmarkMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public PostmarkMessage(string from, string to, string subject, string textBody,
HtmlBody = htmlBody;
Headers = headers ?? new HeaderCollection();
Metadata = metadata;
MessageStream = messageStream ?? DefaultTransactionalStream;
MessageStream = messageStream;
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions src/Postmark/Model/PostmarkMessageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ namespace PostmarkDotNet
/// </summary>
public abstract class PostmarkMessageBase
{
/// <summary>
/// The default transactional stream available on each server.
/// </summary>
public static readonly string DefaultTransactionalStream = "outbound";

/// <summary>
/// Initializes a new instance of the <see cref = "PostmarkMessage" /> class.
/// </summary>
Expand All @@ -27,7 +22,7 @@ public PostmarkMessageBase()
/// <summary>
/// The message stream used to send this message.
/// </summary>
public string MessageStream { get; set; } = DefaultTransactionalStream;
public string MessageStream { get; set; }

/// <summary>
/// The sender's email address.
Expand Down
2 changes: 1 addition & 1 deletion src/Postmark/PostmarkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ private async Task<PostmarkResponse> InternalSendEmailWithTemplateAsync<T>(objec
email.TemplateAlias = (string)templateReference;
}
email.TemplateModel = templateModel;
email.MessageStream = messageStream ?? PostmarkMessageBase.DefaultTransactionalStream;
email.MessageStream = messageStream;
email.To = to;
email.From = from;
if (inlineCss.HasValue)
Expand Down

0 comments on commit b784726

Please sign in to comment.