diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsAudio-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsAudio-response.json index 4fad926d8..d453c349e 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsAudio-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsAudio-response.json @@ -7,6 +7,7 @@ "client_ref": "string", "message_type": "audio", "audio": { - "url": "https://example.com/audio.mp3" + "url": "https://example.com/audio.mp3", + "name": "audio.mp3" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsImage-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsImage-response.json index 1f0ce27d2..f6b0b599f 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsImage-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsImage-response.json @@ -7,6 +7,7 @@ "client_ref": "string", "message_type": "image", "image": { - "url": "https://example.com/image.jpg" + "url": "https://example.com/image.jpg", + "name": "image.jpg" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsText-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsText-response.json index f4c4897bf..681587876 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsText-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsText-response.json @@ -6,5 +6,8 @@ "timestamp": "2020-01-01T14:00:00.000Z", "client_ref": "string", "message_type": "text", - "text": "This is sample text." + "text": "This is sample text.", + "origin": { + "network_code": "12345" + } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVcard-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVcard-response.json index 2c90aea5d..895d3a9ce 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVcard-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVcard-response.json @@ -7,6 +7,7 @@ "client_ref": "string", "message_type": "vcard", "vcard": { - "url": "https://example.com/conatact.vcf" + "url": "https://example.com/conatact.vcf", + "name": "contact.vcf" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVideo-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVideo-response.json index 8cfe27cb3..006527358 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVideo-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeMmsVideo-response.json @@ -7,6 +7,7 @@ "client_ref": "string", "message_type": "video", "video": { - "url": "https://example.com/video.mp4" + "url": "https://example.com/video.mp4", + "name": "video.mp4" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeSms-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeSms-response.json index d662839f7..b47b7a1a2 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeSms-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeSms-response.json @@ -13,5 +13,8 @@ "usage": { "currency": "EUR", "price": "0.0333" + }, + "origin": { + "network_code": "12345" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeWhatsAppImage-response.json b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeWhatsAppImage-response.json index e7ed4e3f0..3a22e01c5 100644 --- a/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeWhatsAppImage-response.json +++ b/Vonage.Test/Messages/Webhooks/Data/ShouldDeserializeWhatsAppImage-response.json @@ -15,6 +15,7 @@ "client_ref": "string", "message_type": "image", "image": { - "url": "https://example.com/image.jpg" + "url": "https://example.com/image.jpg", + "name": "image.jpg" } } \ No newline at end of file diff --git a/Vonage.Test/Messages/Webhooks/SerializationTest.cs b/Vonage.Test/Messages/Webhooks/SerializationTest.cs index 34f3272e1..f7d2d0fab 100644 --- a/Vonage.Test/Messages/Webhooks/SerializationTest.cs +++ b/Vonage.Test/Messages/Webhooks/SerializationTest.cs @@ -147,6 +147,7 @@ public void ShouldDeserializeMmsAudio() => Audio = new UrlDetails { Url = "https://example.com/audio.mp3", + Name = "audio.mp3", }, }); @@ -167,6 +168,7 @@ public void ShouldDeserializeMmsImage() => Image = new UrlDetails { Url = "https://example.com/image.jpg", + Name = "image.jpg", }, }); @@ -185,6 +187,7 @@ public void ShouldDeserializeMmsText() => ClientReference = "string", MessageType = "text", Text = "This is sample text.", + Origin = new Origin("12345"), }); [Fact] @@ -204,6 +207,7 @@ public void ShouldDeserializeMmsVcard() => Vcard = new UrlDetails { Url = "https://example.com/conatact.vcf", + Name = "contact.vcf", }, }); @@ -224,6 +228,7 @@ public void ShouldDeserializeMmsVideo() => Video = new UrlDetails { Url = "https://example.com/video.mp4", + Name = "video.mp4", }, }); @@ -251,6 +256,7 @@ public void ShouldDeserializeSms() => Currency = "EUR", Price = "0.0333", }, + Origin = new Origin("12345"), }); [Fact] @@ -433,6 +439,7 @@ public void ShouldDeserializeWhatsAppImage() => Image = new UrlDetails { Url = "https://example.com/image.jpg", + Name = "image.jpg", }, }); diff --git a/Vonage/Messages/Webhooks/MessageWebhookResponse.cs b/Vonage/Messages/Webhooks/MessageWebhookResponse.cs index 569c1882b..5c15440d7 100644 --- a/Vonage/Messages/Webhooks/MessageWebhookResponse.cs +++ b/Vonage/Messages/Webhooks/MessageWebhookResponse.cs @@ -12,7 +12,7 @@ public struct MessageWebhookResponse /// Channel specific metadata for Audio. /// public UrlDetails? Audio { get; set; } - + /// /// The channel the message came in on. /// @@ -21,28 +21,29 @@ public struct MessageWebhookResponse /// /// Client reference of up to 100 characters. The reference will be present in every message status. /// - [JsonPropertyName("client_ref")] public string ClientReference { get; set; } + [JsonPropertyName("client_ref")] + public string ClientReference { get; set; } /// /// This is only present for the Inbound Message where the user is quoting another message. It provides information about the quoted message and/or the product message being responded to. /// public ContextDetails? Context { get; set; } - + /// /// Channel specific metadata for File. /// public UrlDetails? File { get; set; } - + /// /// The phone number of the message sender in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, for example, 447700900000. For SMS in certain localities alpha-numeric sender id's will work as well, see Global Messaging for more details. /// public string From { get; set; } - + /// /// Channel specific metadata for Image. /// public UrlDetails? Image { get; set; } - + /// /// Channel specific metadata for Location. /// @@ -51,18 +52,20 @@ public struct MessageWebhookResponse /// /// The type of message to send. You must provide text in this field. /// - [JsonPropertyName("message_type")] public string MessageType { get; set; } + [JsonPropertyName("message_type")] + public string MessageType { get; set; } /// /// The UUID of the message. /// - [JsonPropertyName("message_uuid")] public Guid MessageUuid { get; set; } + [JsonPropertyName("message_uuid")] + public Guid MessageUuid { get; set; } /// /// Channel specific metadata for Order. /// public OrderDetails? Order { get; set; } - + /// /// Represents the profile details. /// @@ -71,28 +74,29 @@ public struct MessageWebhookResponse /// /// A message from the channel provider, which may contain a description, error codes or other information. /// - [JsonPropertyName("provider_message")] public string ProviderMessage { get; set; } + [JsonPropertyName("provider_message")] + public string ProviderMessage { get; set; } /// /// Channel specific metadata for Reply. /// public ReplyDetails? Reply { get; set; } - + /// /// Channel specific metadata for SMS. /// public SmsDetails? Sms { get; set; } - + /// /// Channel specific metadata for Sticker. /// public UrlDetails? Sticker { get; set; } - + /// /// The UTF-8 encoded text of the inbound message. /// public string Text { get; set; } - + /// /// The datetime of when the event occurred, in ISO 8601 format. /// @@ -102,21 +106,25 @@ public struct MessageWebhookResponse /// The phone number of the message recipient in the E.164 format. Don't use a leading + or 00 when entering a phone number, start with the country code, for example, 447700900000. /// public string To { get; set; } - + /// /// Represents details about message usage. /// public UsageDetails? Usage { get; set; } - + /// /// Channel specific metadata for Vcard. /// public UrlDetails? Vcard { get; set; } - + /// /// Channel specific metadata for Video. /// public UrlDetails? Video { get; set; } + + /// + /// + public Origin Origin { get; set; } } /// @@ -127,12 +135,14 @@ public struct OrderDetails /// /// The ID of the catalog containing the products in this order. /// - [JsonPropertyName("catalog_id")] public string CatalogId { get; set; } + [JsonPropertyName("catalog_id")] + public string CatalogId { get; set; } /// /// The list of items. /// - [JsonPropertyName("product_items")] public ProductItem[] ProductItems { get; set; } + [JsonPropertyName("product_items")] + public ProductItem[] ProductItems { get; set; } } /// @@ -148,7 +158,8 @@ public struct ProductItem /// /// The unit price for this specific item. /// - [JsonPropertyName("item_price")] public string ItemPrice { get; set; } + [JsonPropertyName("item_price")] + public string ItemPrice { get; set; } /// /// The ID of the specific product being ordered. @@ -175,12 +186,14 @@ public struct LocationDetails /// /// Latitude of the location. /// - [JsonPropertyName("lat")] public decimal Latitude { get; set; } + [JsonPropertyName("lat")] + public decimal Latitude { get; set; } /// /// Longitude of the location. /// - [JsonPropertyName("long")] public decimal Longitude { get; set; } + [JsonPropertyName("long")] + public decimal Longitude { get; set; } /// /// Name of the location. @@ -197,12 +210,12 @@ public struct ReplyDetails /// A description that may be added to the interactive options presented (available only on interactive lists). /// public string Description { get; set; } - + /// /// An identifier to help identify the exact interactive message response. /// public string Id { get; set; } - + /// /// The title displayed on the interactive option chosen. /// @@ -222,12 +235,14 @@ public struct SmsDetails /// /// The number of inbound SMS messages concatenated together to comprise this message. SMS messages are 160 characters, if an inbound message exceeds that size they are concatenated together to forma single message. This number indicates how many messages formed this webhook. /// - [JsonPropertyName("num_messages")] public string MessagesCount { get; set; } + [JsonPropertyName("num_messages")] + public string MessagesCount { get; set; } /// /// The number of inbound SMS messages concatenated together to comprise this message. SMS messages are 160 characters, if an inbound message exceeds that size they are concatenated together to forma single message. This number indicates how many messages formed this webhook. /// - [JsonPropertyName("total_count")] public string TotalCount { get; set; } + [JsonPropertyName("total_count")] + public string TotalCount { get; set; } } /// @@ -239,7 +254,7 @@ public struct UsageDetails /// The charge currency in ISO 4217 format. /// public string Currency { get; set; } - + /// /// The charge amount as a stringified number. /// @@ -255,6 +270,14 @@ public struct UrlDetails /// The publicly accessible URL of the attachment. /// public string Url { get; set; } + + /// + /// + public string Name { get; set; } + + /// + /// + public string Caption { get; set; } } /// @@ -276,12 +299,14 @@ public struct ContextDetails /// /// The phone number of the original sender of the message being quoted in the E.164 format. /// - [JsonPropertyName("message_from")] public string MessageFrom { get; set; } + [JsonPropertyName("message_from")] + public string MessageFrom { get; set; } /// /// The UUID of the message being quoted. /// - [JsonPropertyName("message_uuid")] public string MessageUuid { get; set; } + [JsonPropertyName("message_uuid")] + public string MessageUuid { get; set; } /// /// An object containing details of a product from a product message being quoted or replied to using the 'Message Business' option. @@ -298,11 +323,19 @@ public struct WhatsAppReferredProduct /// /// The ID of the catalog associated with the product from the product message being quoted or replied to using the 'Message Business' option. /// - [JsonPropertyName("catalog_id")] public string CatalogId { get; set; } + [JsonPropertyName("catalog_id")] + public string CatalogId { get; set; } /// /// The ID of the product from the product message being quoted or replied to using the 'Message Business' option. /// [JsonPropertyName("product_retailer_id")] public string ProductRetailerId { get; set; } -} \ No newline at end of file +} + +/// +/// +/// +public record Origin( + [property: JsonPropertyName("network_code")] + string NetworkCode); \ No newline at end of file