diff --git a/src/Moneybird.Net/Entities/Webhooks/Webhook.cs b/src/Moneybird.Net/Entities/Webhooks/Webhook.cs index a0811e7..26fe70b 100644 --- a/src/Moneybird.Net/Entities/Webhooks/Webhook.cs +++ b/src/Moneybird.Net/Entities/Webhooks/Webhook.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Text.Json.Serialization; @@ -13,9 +14,13 @@ public class Webhook : IMoneybirdEntity [JsonPropertyName("url")] public string Url { get; set; } - + + [Obsolete("Use EnabledEvents instead as this attribute will be removed from the API on 1st of January 2025.")] [JsonPropertyName("events")] public List Events { get; set; } + + [JsonPropertyName("enabled_events")] + public List EnabledEvents { get; set; } [JsonPropertyName("last_http_status")] public int? LastHttpStatus { get; set; } diff --git a/src/Moneybird.Net/Models/Webhooks/WebhookCreateOptions.cs b/src/Moneybird.Net/Models/Webhooks/WebhookCreateOptions.cs index ab52379..4ee9504 100644 --- a/src/Moneybird.Net/Models/Webhooks/WebhookCreateOptions.cs +++ b/src/Moneybird.Net/Models/Webhooks/WebhookCreateOptions.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Text.Json.Serialization; using Moneybird.Net.Endpoints.Abstractions.Options; @@ -10,7 +11,11 @@ public class WebhookCreateOptions : IMoneybirdCreateOptions [JsonPropertyName("url")] public string Url { get; set; } - [JsonPropertyName("events")] + [Obsolete("Use EnabledEvents instead as this attribute has been removed from the API.", true)] + [JsonIgnore] public List Events { get; set; } + + [JsonPropertyName("enabled_events")] + public List EnabledEvents { get; set; } } } diff --git a/tests/Moneybird.Net.Tests/Endpoints/WebhookEndpointTests.cs b/tests/Moneybird.Net.Tests/Endpoints/WebhookEndpointTests.cs index d4d7ed6..92b6fea 100644 --- a/tests/Moneybird.Net.Tests/Endpoints/WebhookEndpointTests.cs +++ b/tests/Moneybird.Net.Tests/Endpoints/WebhookEndpointTests.cs @@ -60,7 +60,7 @@ public async void CreateWebhookAsync_ByAccessToken_Returns_NewWebhook() var options = new WebhookCreateOptions { Url = "http://www.mocky.io/v2/5185415ba171ea3a00704eed", - Events = new List + EnabledEvents = new List { WebhookEvent.ContactCreated } diff --git a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/getWebhooks.json b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/getWebhooks.json index d8772fe..7956a5a 100644 --- a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/getWebhooks.json +++ b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/getWebhooks.json @@ -4,6 +4,7 @@ "administration_id": "322056713748350877", "url": "http://example.com/create_webhook", "events": [], + "enabled_events": [], "last_http_status": null, "last_http_body": null, "token": "9AqXyhfFXcqcaGHRWQZMbxuM" diff --git a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/postWebhook.json b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/postWebhook.json index fee3dbc..f0300db 100644 --- a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/postWebhook.json +++ b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/postWebhook.json @@ -2,7 +2,7 @@ "id": "392975655294207773", "administration_id": "322056713748350877", "url": "http://www.mocky.io/v2/5185415ba171ea3a00704eed", - "events": [], + "enabled_events": [], "last_http_status": null, "last_http_body": null, "token": "YTVsrb3MLhMDgkQcc81MgHvE" diff --git a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/webhookCreateOptions.json b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/webhookCreateOptions.json index 4cffcb0..6c2655c 100644 --- a/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/webhookCreateOptions.json +++ b/tests/Moneybird.Net.Tests/Responses/Endpoints/Webhooks/webhookCreateOptions.json @@ -1 +1 @@ -{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed","events":["contact_created"]} \ No newline at end of file +{"url":"http://www.mocky.io/v2/5185415ba171ea3a00704eed","enabled_events":["contact_created"]} \ No newline at end of file