diff --git a/src/Resend.Webhooks/EmailEventData.cs b/src/Resend.Webhooks/EmailEventData.cs index 37bf9b1..8e33826 100644 --- a/src/Resend.Webhooks/EmailEventData.cs +++ b/src/Resend.Webhooks/EmailEventData.cs @@ -24,7 +24,7 @@ public class EmailEventData : IWebhookData /// /// - /// Only set for , otherwise is null. + /// Only set for , otherwise is null. /// [JsonPropertyName( "click" )] public EmailClickData? Click { get; set; } diff --git a/src/Resend.Webhooks/Json/WebhookEventConverter.cs b/src/Resend.Webhooks/Json/WebhookEventConverter.cs index 4e8cfc4..b16a78d 100644 --- a/src/Resend.Webhooks/Json/WebhookEventConverter.cs +++ b/src/Resend.Webhooks/Json/WebhookEventConverter.cs @@ -6,13 +6,13 @@ namespace Resend.Webhooks; /// public class WebhookEventConverter : JsonConverter { - private readonly JsonStringEnumValueConverter _wet; + private readonly JsonStringEnumValueConverter _wet; private readonly JsonUtcDateTimeConverter _utc; /// public WebhookEventConverter() { - _wet = new JsonStringEnumValueConverter(); + _wet = new JsonStringEnumValueConverter(); _utc = new JsonUtcDateTimeConverter(); } @@ -42,7 +42,7 @@ public WebhookEventConverter() throw new JsonException( "Expected 'type' property" ); reader.Read(); - value.EventType = _wet.Read( ref reader, typeof( Resend.WebhookEvent ), options ); + value.EventType = _wet.Read( ref reader, typeof( WebhookEventType ), options ); var category = value.EventType.Category(); diff --git a/src/Resend.Webhooks/WebhookEvent.cs b/src/Resend.Webhooks/WebhookEvent.cs index 1a7fbc1..a310de4 100644 --- a/src/Resend.Webhooks/WebhookEvent.cs +++ b/src/Resend.Webhooks/WebhookEvent.cs @@ -8,7 +8,7 @@ public class WebhookEvent { /// [JsonPropertyName( "type" )] - public Resend.WebhookEvent EventType { get; set; } + public WebhookEventType EventType { get; set; } /// [JsonPropertyName( "created_at" )] diff --git a/src/Resend/ResendExtensions.cs b/src/Resend/ResendExtensions.cs index a41dad0..28d86e2 100644 --- a/src/Resend/ResendExtensions.cs +++ b/src/Resend/ResendExtensions.cs @@ -6,27 +6,27 @@ public static class ResendExtensions /// /// Returns the event category for a given event type. /// - public static WebhookEventTypeCategory Category( this WebhookEvent @event ) + public static WebhookEventTypeCategory Category( this WebhookEventType @event ) { switch ( @event ) { - case WebhookEvent.DomainCreated: - case WebhookEvent.DomainUpdated: - case WebhookEvent.DomainDeleted: + case WebhookEventType.DomainCreated: + case WebhookEventType.DomainUpdated: + case WebhookEventType.DomainDeleted: return WebhookEventTypeCategory.Domain; - case WebhookEvent.ContactCreated: - case WebhookEvent.ContactUpdated: - case WebhookEvent.ContactDeleted: + case WebhookEventType.ContactCreated: + case WebhookEventType.ContactUpdated: + case WebhookEventType.ContactDeleted: return WebhookEventTypeCategory.Contact; - case WebhookEvent.EmailBounced: - case WebhookEvent.EmailClicked: - case WebhookEvent.EmailComplained: - case WebhookEvent.EmailDelivered: - case WebhookEvent.EmailDeliveryDelay: - case WebhookEvent.EmailOpened: - case WebhookEvent.EmailSent: + case WebhookEventType.EmailBounced: + case WebhookEventType.EmailClicked: + case WebhookEventType.EmailComplained: + case WebhookEventType.EmailDelivered: + case WebhookEventType.EmailDeliveryDelay: + case WebhookEventType.EmailOpened: + case WebhookEventType.EmailSent: return WebhookEventTypeCategory.Email; default: diff --git a/src/Resend/Webhook.cs b/src/Resend/Webhook.cs index a6628e6..8db0360 100644 --- a/src/Resend/Webhook.cs +++ b/src/Resend/Webhook.cs @@ -30,7 +30,7 @@ public class Webhook /// [JsonPropertyName( "events" )] - public List Events { get; set; } = default!; + public List Events { get; set; } = default!; /// /// diff --git a/src/Resend/WebhookEvent.cs b/src/Resend/WebhookEventType.cs similarity index 98% rename from src/Resend/WebhookEvent.cs rename to src/Resend/WebhookEventType.cs index 8684708..3360a45 100644 --- a/src/Resend/WebhookEvent.cs +++ b/src/Resend/WebhookEventType.cs @@ -6,8 +6,8 @@ namespace Resend; /// /// See https://www.resend.com/docs/dashboard/webhooks/event-types /// -[JsonConverter( typeof( JsonStringEnumValueConverter ) )] -public enum WebhookEvent +[JsonConverter( typeof( JsonStringEnumValueConverter ) )] +public enum WebhookEventType { /// /// The API request was successful and Resend will attempt to deliver diff --git a/tests/Resend.Webhooks.Tests/WebhookEventConverterTests.cs b/tests/Resend.Webhooks.Tests/WebhookEventConverterTests.cs index e835247..73493b3 100644 --- a/tests/Resend.Webhooks.Tests/WebhookEventConverterTests.cs +++ b/tests/Resend.Webhooks.Tests/WebhookEventConverterTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Text.Json; +using System.Text.Json; namespace Resend.Webhooks.Tests; @@ -25,7 +24,7 @@ public void EmailEventRoundtrip() expectedEmail.MomentCreated = utcNow; var expected = new WebhookEvent(); - expected.EventType = Resend.WebhookEvent.EmailSent; + expected.EventType = WebhookEventType.EmailSent; expected.MomentCreated = utcNow; expected.Data = expectedEmail; @@ -68,7 +67,7 @@ public void ContactEventRoundtrip() expectedContact.MomentCreated = utcNow; var expected = new WebhookEvent(); - expected.EventType = Resend.WebhookEvent.ContactCreated; + expected.EventType = WebhookEventType.ContactCreated; expected.MomentCreated = utcNow; expected.Data = expectedContact; @@ -114,7 +113,7 @@ public void DomainEventRoundtrip() expectedDomain.MomentCreated = utcNow; var expected = new WebhookEvent(); - expected.EventType = Resend.WebhookEvent.DomainCreated; + expected.EventType = WebhookEventType.DomainCreated; expected.MomentCreated = utcNow; expected.Data = expectedDomain;