Skip to content

Commit

Permalink
Merge pull request #23 from wildbit/feature/custom-return-path-api
Browse files Browse the repository at this point in the history
Adding support for ReturnPathDomain fields from the Sender Signatures API
  • Loading branch information
Andrew Theken committed May 7, 2015
2 parents 15ee955 + fc36b86 commit 53c6a35
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
27 changes: 25 additions & 2 deletions src/Postmark.PCL.Tests/AdminClientSenderSignatureTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ public class AdminClientSenderSignatureTests : ClientBaseFixture
private string _replyToAddress;
private string _senderName;
private string _senderprefix;
private string _returnPath;

protected override async Task SetupAsync()
{
_adminClient = new PostmarkAdminClient(WRITE_ACCOUNT_TOKEN);
var id = Guid.NewGuid();
var baseEmail =
_senderprefix = "test-sender-";

_returnPath = "test." + WRITE_TEST_SENDER_SIGNATURE_PROTOTYPE.Split('@')[1];
_senderEmail = WRITE_TEST_SENDER_SIGNATURE_PROTOTYPE.Replace("[token]", String.Format(_senderprefix + "{0:n}", id));
_replyToAddress = WRITE_TEST_SENDER_SIGNATURE_PROTOTYPE.Replace("[token]", String.Format(_senderprefix + "replyto-{0:n}@example.com", id));
_senderName = String.Format("Test Sender {0}", TESTING_DATE);
Expand Down Expand Up @@ -136,6 +136,29 @@ public async void AdminClient_CanUpdateSenderSignatures()
Assert.AreEqual(prefix + signature.ReplyToEmailAddress, updatedSignature.ReplyToEmailAddress);
}

[TestCase]
public async void AdminClient_CanUpdateSenderSignatureReturnPath()
{
var signature = await _adminClient.CreateSignatureAsync(_senderEmail, _senderName, _replyToAddress, _returnPath);

var prefix = "updated-";

var updateResult = await _adminClient.UpdateSignatureAsync(signature.ID, returnPathDomain: prefix + _returnPath);

var updatedSignature = await _adminClient.GetSenderSignatureAsync(signature.ID);

Assert.AreEqual(updateResult.ReturnPathDomain, updatedSignature.ReturnPathDomain);
}


[TestCase]
public async void AdminClient_CanCreateSignatureWithReturnPath()
{

var signature = await _adminClient.CreateSignatureAsync(_senderEmail, _senderName, _replyToAddress, _returnPath);
Assert.AreEqual(_returnPath, signature.ReturnPathDomain);
}

[TestCase]
public async void AdminClient_ResendSignatureVerificationEmailAsync()
{
Expand Down
8 changes: 6 additions & 2 deletions src/Postmark.PCL/PostmarkAdminClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,15 @@ public async Task<PostmarkCompleteSenderSignature> VerifySignatureSPF(int signat
/// <param name="fromEmail"></param>
/// <param name="name"></param>
/// <param name="replyToEmail"></param>
/// <param name="returnPathDomain"></param>
/// <returns></returns>
public async Task<PostmarkCompleteSenderSignature> CreateSignatureAsync(string fromEmail, string name, string replyToEmail = null)
public async Task<PostmarkCompleteSenderSignature> CreateSignatureAsync(string fromEmail, string name, string replyToEmail = null, string returnPathDomain = null)
{
var parameters = new Dictionary<string, object>();
parameters["FromEmail"] = fromEmail;
parameters["Name"] = name;
parameters["ReplyToEmail"] = replyToEmail;
parameters["ReturnPathDomain"] = returnPathDomain;

return await this.ProcessRequestAsync<Dictionary<string, object>, PostmarkCompleteSenderSignature>
("/senders/", HttpMethod.Post, parameters);
Expand All @@ -209,13 +211,15 @@ public async Task<PostmarkCompleteSenderSignature> CreateSignatureAsync(string f
/// <param name="signatureId"></param>
/// <param name="name"></param>
/// <param name="replyToEmail"></param>
/// <param name="returnPathDomain"></param>
/// <returns></returns>
public async Task<PostmarkCompleteSenderSignature> UpdateSignatureAsync
(int signatureId, string name = null, string replyToEmail = null)
(int signatureId, string name = null, string replyToEmail = null, string returnPathDomain = null)
{
var parameters = new Dictionary<string, object>();
parameters["Name"] = name;
parameters["ReplyToEmail"] = replyToEmail;
parameters["ReturnPathDomain"] = returnPathDomain;

return await this.ProcessRequestAsync<Dictionary<string, object>, PostmarkCompleteSenderSignature>
("/senders/" + signatureId, HttpMethod.Put, parameters);
Expand Down
6 changes: 5 additions & 1 deletion src/Postmark/Model/PostmarkCompleteSenderSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public class PostmarkCompleteSenderSignature : PostmarkBaseSenderSignature
public string DKIMRevokedTextValue { get; set; }
public string DKIMUpdateStatus { get; set; }

public string ReturnPathDomain { get; set; }
public bool ReturnPathDomainVerified { get; set; }
public string ReturnPathDomainCNAMEValue { get; set; }

public bool SafeToRemoveRevokedKeyFromDNS { get; set; }
}
}
}

0 comments on commit 53c6a35

Please sign in to comment.