diff --git a/src/Client/Webhooks/Models/eInvoicing/InboundDocumentNew.cs b/src/Client/Webhooks/Models/eInvoicing/InboundDocumentNew.cs new file mode 100644 index 0000000..33bd42e --- /dev/null +++ b/src/Client/Webhooks/Models/eInvoicing/InboundDocumentNew.cs @@ -0,0 +1,80 @@ +using System; +using System.Runtime.Serialization; + +namespace Ibanity.Apis.Client.Webhooks.Models.eInvoicing +{ + /// + /// A webhook payload delivered whenever there is a new document available. + /// +#pragma warning disable CA1711 // Identifiers should not have incorrect suffix + public class InboundDocumentNew : JsonApi.Data, IWebhookEvent +#pragma warning restore CA1711 // Identifiers should not have incorrect suffix + { + /// + /// Unique identifier of the associated document. + /// + [DataMember(Name = "documentId", EmitDefaultValue = false)] + public Guid DocumentId { get; set; } + + /// + /// Unique identifier of the associated supplier. + /// + [DataMember(Name = "supplierId", EmitDefaultValue = false)] + public Guid SupplierId { get; set; } + + /// + /// When this notification was created. + /// + [DataMember(Name = "createdAt", EmitDefaultValue = false)] + public DateTimeOffset CreatedAt { get; set; } + } + + /// + /// A webhook payload delivered whenever there is a new document available. + /// +#pragma warning disable CA1711 // Identifiers should not have incorrect suffix + public class NestedInboundDocumentNew : PayloadData +#pragma warning restore CA1711 // Identifiers should not have incorrect suffix + { + /// + public override IWebhookEvent Flatten() => + new InboundDocumentNew + { + Id = Id, + Type = Type, + DocumentId = Guid.Parse(Relationships.Document.Data.Id), + SupplierId = Guid.Parse(Relationships.Supplier.Data.Id), + CreatedAt = Attributes.CreatedAt + }; + } + + /// + /// Payload attributes delivered whenever there is a new document available. + /// + public class InboundDocumentNewAttributes + { + /// + /// When this notification was created. + /// + [DataMember(Name = "createdAt", EmitDefaultValue = false)] + public DateTimeOffset CreatedAt { get; set; } + } + + /// + /// Payload relationships delivered whenever there is a new document available. + /// + public class InboundDocumentNewRelationships + { + /// + /// A Peppol Inbound Document reference. + /// + [DataMember(Name = "document", EmitDefaultValue = false)] + public Relationship Document { get; set; } + + /// + /// A Supplier reference. + /// + [DataMember(Name = "supplier", EmitDefaultValue = false)] + public Relationship Supplier { get; set; } + } +} diff --git a/src/Client/Webhooks/Models/eInvoicing/PeppolRegistrationsUpdated.cs b/src/Client/Webhooks/Models/eInvoicing/PeppolRegistrationsUpdated.cs new file mode 100644 index 0000000..67d1a89 --- /dev/null +++ b/src/Client/Webhooks/Models/eInvoicing/PeppolRegistrationsUpdated.cs @@ -0,0 +1,63 @@ +using System; +using System.Runtime.Serialization; + +namespace Ibanity.Apis.Client.Webhooks.Models.eInvoicing +{ + /// + /// A webhook payload delivered whenever a peppol registration is updated to registered or registration-failed. + /// + public class PeppolRegistrationsUpdated : JsonApi.Data, IWebhookEvent + { + /// + /// Unique identifier of the associated supplier. + /// + [DataMember(Name = "supplierId", EmitDefaultValue = false)] + public Guid SupplierId { get; set; } + + /// + /// When this notification was created. + /// + [DataMember(Name = "createdAt", EmitDefaultValue = false)] + public DateTimeOffset CreatedAt { get; set; } + } + + /// + /// A webhook payload delivered whenever a peppol registration is updated to registered or registration-failed. + /// + public class NestedPeppolRegistrationsUpdated : PayloadData + { + /// + public override IWebhookEvent Flatten() => + new PeppolRegistrationsUpdated + { + Id = Id, + Type = Type, + SupplierId = Guid.Parse(Relationships.Supplier.Data.Id), + CreatedAt = Attributes.CreatedAt + }; + } + + /// + /// Payload attributes delivered whenever a peppol registration is updated to registered or registration-failed. + /// + public class PeppolRegistrationsUpdatedAttributes + { + /// + /// When this notification was created. + /// + [DataMember(Name = "createdAt", EmitDefaultValue = false)] + public DateTimeOffset CreatedAt { get; set; } + } + + /// + /// Payload relationships delivered whenever a peppol registration is updated to registered or registration-failed. + /// + public class PeppolRegistrationsUpdatedRelationships + { + /// + /// A Supplier reference. + /// + [DataMember(Name = "supplier", EmitDefaultValue = false)] + public Relationship Supplier { get; set; } + } +} diff --git a/src/Client/Webhooks/WebhooksService.cs b/src/Client/Webhooks/WebhooksService.cs index 7c770a6..fd72317 100644 --- a/src/Client/Webhooks/WebhooksService.cs +++ b/src/Client/Webhooks/WebhooksService.cs @@ -16,6 +16,8 @@ public class WebhooksService : IWebhooksService { private static readonly IReadOnlyDictionary Types = new Dictionary { + { "eInvoicing.inbound.document.new", typeof(Payload) }, + { "eInvoicing.peppol.registrations.updated", typeof(Payload) }, { "pontoConnect.synchronization.succeededWithoutChange", typeof(Payload) }, { "pontoConnect.synchronization.failed", typeof(Payload) }, { "pontoConnect.account.detailsUpdated", typeof(Payload) },