From ea1e0697e58783f81679d4cddc6e45bfa2822532 Mon Sep 17 00:00:00 2001 From: ericthornton Date: Thu, 4 Oct 2018 00:33:40 -0400 Subject: [PATCH] Added custom headers to webhooks Addressed #158 by adding CustomHeaders to the Webhook class --- src/SparkPost.Tests/DataMapperTests.cs | 16 ++++++++++++++++ src/SparkPost/ListWebhookResponse.cs | 1 + src/SparkPost/Webhook.cs | 1 + 3 files changed, 18 insertions(+) diff --git a/src/SparkPost.Tests/DataMapperTests.cs b/src/SparkPost.Tests/DataMapperTests.cs index 3a6e54e3..da822289 100644 --- a/src/SparkPost.Tests/DataMapperTests.cs +++ b/src/SparkPost.Tests/DataMapperTests.cs @@ -884,6 +884,22 @@ public void Target() dataMapper.ToDictionary(webhook)["target"].ShouldEqual(webhook.Target); } + [Test] + public void CustomHeaders() + { + var webhook = new Webhook + { + CustomHeaders = new + { + XAPIKey = "abcd" + } + }; + + var dictionary = dataMapper.ToDictionary(webhook); + var customHeadersDetails = dictionary["custom_headers"].CastAs>(); + customHeadersDetails["x-api-key"].ShouldEqual("abcd"); + } + [Test] public void AuthType() { diff --git a/src/SparkPost/ListWebhookResponse.cs b/src/SparkPost/ListWebhookResponse.cs index 4a3a1e89..f4fd41de 100644 --- a/src/SparkPost/ListWebhookResponse.cs +++ b/src/SparkPost/ListWebhookResponse.cs @@ -31,6 +31,7 @@ internal static Webhook ConvertToAWebhook(dynamic r) Id = r.id, Name = r.name, Target = r.target, + CustomHeaders = r.custom_headers, Events = events, AuthType = r.auth_type, AuthRequestDetails = r.auth_request_details, diff --git a/src/SparkPost/Webhook.cs b/src/SparkPost/Webhook.cs index b026bf57..15fce153 100644 --- a/src/SparkPost/Webhook.cs +++ b/src/SparkPost/Webhook.cs @@ -13,6 +13,7 @@ public Webhook() public string Id { get; set; } public string Name { get; set; } public string Target { get; set; } + public object CustomHeaders { get; set; } public IList Events { get; set; } public DateTime? LastSuccessful { get; set; }