From 426ef4721306da25dcab144cc8a4b560756bd71d Mon Sep 17 00:00:00 2001 From: tr00d Date: Wed, 26 Jun 2024 14:51:08 +0200 Subject: [PATCH] feat: add Context on WhatsApp messages --- ...son => SendMessageReturnsOk-response.json} | 0 ...udioAsyncReturnsOkWithContext-request.json | 13 + ...WhatsAppCustomAsyncReturnsOk-response.json | 3 - ...stomAsyncReturnsOkWithContext-request.json | 17 + ...ndWhatsAppFileAsyncReturnsOk-response.json | 3 - ...FileAsyncReturnsOkWithContext-request.json | 14 + ...dWhatsAppImageAsyncReturnsOk-response.json | 3 - ...mageAsyncReturnsOkWithContext-request.json | 14 + ...pMultipleItemsAsyncReturnsOk-response.json | 3 - ...temsAsyncReturnsOkWithContext-request.json | 50 ++ ...sAppSingleItemAsyncReturnsOk-response.json | 3 - ...ItemAsyncReturnsOkWithContext-request.json | 26 + ...rAsyncReturnsOkWithIdSticker-response.json | 3 - ...rnsOkWithIdStickerWithContext-request.json | 13 + ...AsyncReturnsOkWithUrlSticker-response.json | 3 - ...nsOkWithUrlStickerWithContext-request.json | 13 + ...atsAppTemplateAsyncReturnsOk-response.json | 3 - ...lateAsyncReturnsOkWithContext-request.json | 28 + ...ndWhatsAppTextAsyncReturnsOk-response.json | 3 - ...TextAsyncReturnsOkWithContext-request.json | 11 + ...dWhatsAppVideoAsyncReturnsOk-response.json | 3 - ...ideoAsyncReturnsOkWithContext-request.json | 14 + .../Messages/WhatsApp/WhatsAppMessagesTest.cs | 621 ++++++++++++------ Vonage.Test/Vonage.Test.csproj | 69 +- .../Messages/WhatsApp/WhatsAppAudioRequest.cs | 7 + Vonage/Messages/WhatsApp/WhatsAppContext.cs | 13 + .../WhatsApp/WhatsAppCustomRequest.cs | 7 + .../Messages/WhatsApp/WhatsAppFileRequest.cs | 7 + .../Messages/WhatsApp/WhatsAppImageRequest.cs | 7 + .../WhatsApp/WhatsAppMultipleItemsRequest.cs | 7 + .../WhatsApp/WhatsAppSingleItemRequest.cs | 7 + .../WhatsApp/WhatsAppStickerRequest.cs | 7 + .../WhatsApp/WhatsAppTemplateRequest.cs | 7 + .../Messages/WhatsApp/WhatsAppTextRequest.cs | 7 + .../Messages/WhatsApp/WhatsAppVideoRequest.cs | 7 + 35 files changed, 739 insertions(+), 277 deletions(-) rename Vonage.Test/Messages/WhatsApp/Data/{SendWhatsAppAudioAsyncReturnsOk-response.json => SendMessageReturnsOk-response.json} (100%) create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdSticker-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdStickerWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlSticker-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlStickerWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOkWithContext-request.json delete mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOk-response.json create mode 100644 Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOkWithContext-request.json create mode 100644 Vonage/Messages/WhatsApp/WhatsAppContext.cs diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendMessageReturnsOk-response.json similarity index 100% rename from Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOk-response.json rename to Vonage.Test/Messages/WhatsApp/Data/SendMessageReturnsOk-response.json diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..5d62af4ab --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppAudioAsyncReturnsOkWithContext-request.json @@ -0,0 +1,13 @@ +{ + "channel": "whatsapp", + "message_type": "audio", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "audio": { + "url": "https://test.com/voice.mp3" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..60dd82d36 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppCustomAsyncReturnsOkWithContext-request.json @@ -0,0 +1,17 @@ +{ + "channel": "whatsapp", + "message_type": "custom", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "custom": { + "type": "template", + "template": { + "something": "whatsapp:hsm:technology:nexmo", + "name": "parcel_location" + } + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..d9d6bac86 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppFileAsyncReturnsOkWithContext-request.json @@ -0,0 +1,14 @@ +{ + "channel": "whatsapp", + "message_type": "file", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "file": { + "url": "https://test.com/me.txt", + "caption": "Me" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..2fc7e7135 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppImageAsyncReturnsOkWithContext-request.json @@ -0,0 +1,14 @@ +{ + "channel": "whatsapp", + "message_type": "image", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "image": { + "url": "https://test.com/image.png", + "caption": "Testing image caption" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOk-response.json deleted file mode 100644 index 358694b35..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "d1159a25-f64a-4d0e-8cf1-9896b760f3e4" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..f1d3ab4c5 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppMultipleItemsAsyncReturnsOkWithContext-request.json @@ -0,0 +1,50 @@ +{ + "channel": "whatsapp", + "message_type": "custom", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "custom": { + "type": "interactive", + "interactive": { + "type": "product_list", + "header": { + "type": "text", + "text": "Our top products" + }, + "body": { + "text": "Check out these great products" + }, + "footer": { + "text": "Sale now on!" + }, + "action": { + "catalog_id": "catalog_1", + "sections": [ + { + "title": "Cool products", + "product_items": [ + { + "product_retailer_id": "product_1" + }, + { + "product_retailer_id": "product_2" + } + ] + }, + { + "title": "Awesome products", + "product_items": [ + { + "product_retailer_id": "product_3" + } + ] + } + ] + } + } + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOk-response.json deleted file mode 100644 index 358694b35..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "d1159a25-f64a-4d0e-8cf1-9896b760f3e4" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..3cf37eeac --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppSingleItemAsyncReturnsOkWithContext-request.json @@ -0,0 +1,26 @@ +{ + "channel": "whatsapp", + "message_type": "custom", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "custom": { + "type": "interactive", + "interactive": { + "type": "product", + "body": { + "text": "Check out this cool product" + }, + "footer": { + "text": "Sale now on!" + }, + "action": { + "catalog_id": "catalog_1", + "product_retailer_id": "product_1" + } + } + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdSticker-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdSticker-response.json deleted file mode 100644 index 358694b35..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdSticker-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "d1159a25-f64a-4d0e-8cf1-9896b760f3e4" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdStickerWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdStickerWithContext-request.json new file mode 100644 index 000000000..4aef1fb81 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithIdStickerWithContext-request.json @@ -0,0 +1,13 @@ +{ + "channel": "whatsapp", + "message_type": "sticker", + "to": "447700900000", + "from": "447700900001", + "client_ref": "string", + "sticker": { + "id": "aabb7a31-1d1f-4755-a574-2971d831cd5b" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlSticker-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlSticker-response.json deleted file mode 100644 index 358694b35..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlSticker-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "d1159a25-f64a-4d0e-8cf1-9896b760f3e4" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlStickerWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlStickerWithContext-request.json new file mode 100644 index 000000000..0ae60517b --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppStickerAsyncReturnsOkWithUrlStickerWithContext-request.json @@ -0,0 +1,13 @@ +{ + "channel": "whatsapp", + "message_type": "sticker", + "to": "447700900000", + "from": "447700900001", + "client_ref": "string", + "sticker": { + "url": "https://example.com/image.webp" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..1181ef5fc --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTemplateAsyncReturnsOkWithContext-request.json @@ -0,0 +1,28 @@ +{ + "channel": "whatsapp", + "message_type": "template", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "whatsapp": { + "policy": "deterministic", + "locale": "en-GB" + }, + "template": { + "name": "Amazing template", + "parameters": [ + { + "default": "Vonage Verification" + }, + { + "default": "64873" + }, + { + "default": "10" + } + ] + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..5ef5db6be --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppTextAsyncReturnsOkWithContext-request.json @@ -0,0 +1,11 @@ +{ + "channel": "whatsapp", + "message_type": "text", + "text": "Hello mum", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOk-response.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOk-response.json deleted file mode 100644 index d9cb11686..000000000 --- a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOk-response.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "message_uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab" -} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOkWithContext-request.json b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOkWithContext-request.json new file mode 100644 index 000000000..7227d9aa2 --- /dev/null +++ b/Vonage.Test/Messages/WhatsApp/Data/SendWhatsAppVideoAsyncReturnsOkWithContext-request.json @@ -0,0 +1,14 @@ +{ + "channel": "whatsapp", + "message_type": "video", + "to": "441234567890", + "from": "015417543010", + "client_ref": "abcdefg", + "video": { + "url": "https://test.com/me.mp4", + "caption": "Me at the zoo" + }, + "context": { + "message_uuid": "a1b2c3d4a1b2c3d4" + } +} \ No newline at end of file diff --git a/Vonage.Test/Messages/WhatsApp/WhatsAppMessagesTest.cs b/Vonage.Test/Messages/WhatsApp/WhatsAppMessagesTest.cs index 631780559..ec17b62c5 100644 --- a/Vonage.Test/Messages/WhatsApp/WhatsAppMessagesTest.cs +++ b/Vonage.Test/Messages/WhatsApp/WhatsAppMessagesTest.cs @@ -11,263 +11,456 @@ using Vonage.Test.Common; using Xunit; -namespace Vonage.Test.Messages.WhatsApp +namespace Vonage.Test.Messages.WhatsApp; + +[Trait("Category", "Legacy")] +public class WhatsAppMessagesTest : TestBase { - [Trait("Category", "Legacy")] - public class WhatsAppMessagesTest : TestBase + private const string ResponseKey = "SendMessageReturnsOk"; + private readonly string expectedResponse; + private readonly string expectedUri; + private readonly SerializationTestHelper helper; + private readonly Func> operation; + + public WhatsAppMessagesTest() { - private readonly string expectedUri; - private readonly SerializationTestHelper helper; - private readonly Func> operation; + this.expectedUri = $"{this.ApiUrl}/v1/messages"; + this.helper = new SerializationTestHelper(typeof(WhatsAppMessagesTest).Namespace, + JsonSerializerBuilder.BuildWithCamelCase()); + this.operation = request => + this.BuildVonageClient(Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey)) + .MessagesClient + .SendAsync(request); + this.expectedResponse = this.helper.GetResponseJson(ResponseKey); + } - public WhatsAppMessagesTest() + [Fact] + public async Task SendWhatsAppAudioAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppAudioRequest { - this.expectedUri = $"{this.ApiUrl}/v1/messages"; - this.helper = new SerializationTestHelper(typeof(WhatsAppMessagesTest).Namespace, - JsonSerializerBuilder.BuildWithCamelCase()); - this.operation = request => - this.BuildVonageClient(Credentials.FromAppIdAndPrivateKey(this.AppId, this.PrivateKey)) - .MessagesClient - .SendAsync(request); - } + To = "441234567890", + From = "015417543010", + Audio = new Attachment + { + Url = "https://test.com/voice.mp3", + }, + ClientRef = "abcdefg", + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppAudioAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppAudioAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppAudioRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppAudioRequest + To = "441234567890", + From = "015417543010", + Audio = new Attachment { - To = "441234567890", - From = "015417543010", - Audio = new Attachment - { - Url = "https://test.com/voice.mp3", - }, - ClientRef = "abcdefg", - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + Url = "https://test.com/voice.mp3", + }, + ClientRef = "abcdefg", + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppCustomAsyncReturnsOk() + private async Task AssertResponse(IMessage request, string expectedRequest) + { + this.Setup(this.expectedUri, this.expectedResponse, expectedRequest); + var response = await this.operation(request); + response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); + } + + [Fact] + public async Task SendWhatsAppCustomAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppCustomRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppCustomRequest + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = new { - To = "441234567890", - From = "015417543010", - ClientRef = "abcdefg", - Custom = new + type = "template", + template = new { - type = "template", - template = new - { - something = "whatsapp:hsm:technology:nexmo", - name = "parcel_location", - }, + something = "whatsapp:hsm:technology:nexmo", + name = "parcel_location", }, - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + }, + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppFileAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppCustomAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppCustomRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppFileRequest + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = new { - To = "441234567890", - From = "015417543010", - File = new CaptionedAttachment + type = "template", + template = new { - Url = "https://test.com/me.txt", - Caption = "Me", + something = "whatsapp:hsm:technology:nexmo", + name = "parcel_location", }, - ClientRef = "abcdefg", - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + }, + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppImageAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppFileAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppFileRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppImageRequest + To = "441234567890", + From = "015417543010", + File = new CaptionedAttachment { - To = "441234567890", - From = "015417543010", - Image = new CaptionedAttachment - { - Url = "https://test.com/image.png", - Caption = "Testing image caption", - }, - ClientRef = "abcdefg", - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + Url = "https://test.com/me.txt", + Caption = "Me", + }, + ClientRef = "abcdefg", + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppMultipleItemsAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppFileAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppFileRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppMultipleItemsRequest + To = "441234567890", + From = "015417543010", + File = new CaptionedAttachment { - To = "441234567890", - From = "015417543010", - ClientRef = "abcdefg", - Custom = MultipleItemsContentBuilder.Initialize() - .WithHeader("Our top products") - .WithBody("Check out these great products") - .WithFooter("Sale now on!") - .WithCatalogId("catalog_1") - .WithSection("Cool products") - .WithProductRetailer("product_1") - .WithProductRetailer("product_2") - .WithSection("Awesome products") - .WithProductRetailer("product_3") - .Build(), - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("d1159a25-f64a-4d0e-8cf1-9896b760f3e4")); - } + Url = "https://test.com/me.txt", + Caption = "Me", + }, + ClientRef = "abcdefg", + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppSingleItemAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppImageAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppImageRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppSingleProductRequest + To = "441234567890", + From = "015417543010", + Image = new CaptionedAttachment { - To = "441234567890", - From = "015417543010", - ClientRef = "abcdefg", - Custom = SingleItemContentBuilder.Initialize() - .WithBody("Check out this cool product") - .WithFooter("Sale now on!") - .WithCatalogId("catalog_1") - .WithProductRetailerId("product_1") - .Build(), - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("d1159a25-f64a-4d0e-8cf1-9896b760f3e4")); - } + Url = "https://test.com/image.png", + Caption = "Testing image caption", + }, + ClientRef = "abcdefg", + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppStickerAsyncReturnsOkWithIdSticker() + [Fact] + public async Task SendWhatsAppImageAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppImageRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppStickerRequest + To = "441234567890", + From = "015417543010", + Image = new CaptionedAttachment { - To = "447700900000", - From = "447700900001", - ClientRef = "string", - Sticker = new IdSticker(new Guid("aabb7a31-1d1f-4755-a574-2971d831cd5b")), - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("d1159a25-f64a-4d0e-8cf1-9896b760f3e4")); - } + Url = "https://test.com/image.png", + Caption = "Testing image caption", + }, + ClientRef = "abcdefg", + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppStickerAsyncReturnsOkWithUrlSticker() + [Fact] + public async Task SendWhatsAppMultipleItemsAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppMultipleItemsRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppStickerRequest - { - To = "447700900000", - From = "447700900001", - ClientRef = "string", - Sticker = new UrlSticker("https://example.com/image.webp"), - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("d1159a25-f64a-4d0e-8cf1-9896b760f3e4")); - } + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = MultipleItemsContentBuilder.Initialize() + .WithHeader("Our top products") + .WithBody("Check out these great products") + .WithFooter("Sale now on!") + .WithCatalogId("catalog_1") + .WithSection("Cool products") + .WithProductRetailer("product_1") + .WithProductRetailer("product_2") + .WithSection("Awesome products") + .WithProductRetailer("product_3") + .Build(), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppMultipleItemsAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppMultipleItemsRequest + { + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = MultipleItemsContentBuilder.Initialize() + .WithHeader("Our top products") + .WithBody("Check out these great products") + .WithFooter("Sale now on!") + .WithCatalogId("catalog_1") + .WithSection("Cool products") + .WithProductRetailer("product_1") + .WithProductRetailer("product_2") + .WithSection("Awesome products") + .WithProductRetailer("product_3") + .Build(), + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppSingleItemAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppSingleProductRequest + { + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = SingleItemContentBuilder.Initialize() + .WithBody("Check out this cool product") + .WithFooter("Sale now on!") + .WithCatalogId("catalog_1") + .WithProductRetailerId("product_1") + .Build(), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppSingleItemAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppSingleProductRequest + { + To = "441234567890", + From = "015417543010", + ClientRef = "abcdefg", + Custom = SingleItemContentBuilder.Initialize() + .WithBody("Check out this cool product") + .WithFooter("Sale now on!") + .WithCatalogId("catalog_1") + .WithProductRetailerId("product_1") + .Build(), + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppStickerAsyncReturnsOkWithIdSticker() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppStickerRequest + { + To = "447700900000", + From = "447700900001", + ClientRef = "string", + Sticker = new IdSticker(new Guid("aabb7a31-1d1f-4755-a574-2971d831cd5b")), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppStickerAsyncReturnsOkWithIdStickerWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppStickerRequest + { + To = "447700900000", + From = "447700900001", + ClientRef = "string", + Sticker = new IdSticker(new Guid("aabb7a31-1d1f-4755-a574-2971d831cd5b")), + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppTemplateAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppStickerAsyncReturnsOkWithUrlSticker() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppStickerRequest + { + To = "447700900000", + From = "447700900001", + ClientRef = "string", + Sticker = new UrlSticker("https://example.com/image.webp"), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppStickerAsyncReturnsOkWithUrlStickerWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppStickerRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppTemplateRequest + To = "447700900000", + From = "447700900001", + ClientRef = "string", + Sticker = new UrlSticker("https://example.com/image.webp"), + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppTemplateAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppTemplateRequest + { + To = "441234567890", + From = "015417543010", + Template = new MessageTemplate { - To = "441234567890", - From = "015417543010", - Template = new MessageTemplate + Name = "Amazing template", + Parameters = new List { - Name = "Amazing template", - Parameters = new List - { - new {@default = "Vonage Verification"}, - new {@default = "64873"}, - new {@default = "10"}, - }, + new {@default = "Vonage Verification"}, + new {@default = "64873"}, + new {@default = "10"}, }, - ClientRef = "abcdefg", - WhatsApp = new MessageWhatsApp + }, + ClientRef = "abcdefg", + WhatsApp = new MessageWhatsApp + { + Policy = "deterministic", + Locale = "en-GB", + }, + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppTemplateAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppTemplateRequest + { + To = "441234567890", + From = "015417543010", + Template = new MessageTemplate + { + Name = "Amazing template", + Parameters = new List { - Policy = "deterministic", - Locale = "en-GB", + new {@default = "Vonage Verification"}, + new {@default = "64873"}, + new {@default = "10"}, }, - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + }, + ClientRef = "abcdefg", + WhatsApp = new MessageWhatsApp + { + Policy = "deterministic", + Locale = "en-GB", + }, + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppTextAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppTextRequest + { + To = "441234567890", + From = "015417543010", + Text = "Hello mum", + ClientRef = "abcdefg", + }; + await this.AssertResponse(request, expectedRequest); + } + + [Fact] + public async Task SendWhatsAppTextAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppTextRequest + { + To = "441234567890", + From = "015417543010", + Text = "Hello mum", + ClientRef = "abcdefg", + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppTextAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppVideoAsyncReturnsOk() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppVideoRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppTextRequest + To = "441234567890", + From = "015417543010", + Video = new CaptionedAttachment { - To = "441234567890", - From = "015417543010", - Text = "Hello mum", - ClientRef = "abcdefg", - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + Url = "https://test.com/me.mp4", + Caption = "Me at the zoo", + }, + ClientRef = "abcdefg", + }; + await this.AssertResponse(request, expectedRequest); + } - [Fact] - public async Task SendWhatsAppVideoAsyncReturnsOk() + [Fact] + public async Task SendWhatsAppVideoAsyncReturnsOkWithContext() + { + var expectedRequest = this.helper.GetRequestJson(); + var request = new WhatsAppVideoRequest { - var expectedResponse = this.helper.GetResponseJson(); - var expectedRequest = this.helper.GetRequestJson(); - var request = new WhatsAppVideoRequest + To = "441234567890", + From = "015417543010", + Video = new CaptionedAttachment { - To = "441234567890", - From = "015417543010", - Video = new CaptionedAttachment - { - Url = "https://test.com/me.mp4", - Caption = "Me at the zoo", - }, - ClientRef = "abcdefg", - }; - this.Setup(this.expectedUri, expectedResponse, expectedRequest); - var response = await this.operation(request); - response.MessageUuid.Should().Be(new Guid("aaaaaaaa-bbbb-cccc-dddd-0123456789ab")); - } + Url = "https://test.com/me.mp4", + Caption = "Me at the zoo", + }, + ClientRef = "abcdefg", + Context = new WhatsAppContext("a1b2c3d4a1b2c3d4"), + }; + await this.AssertResponse(request, expectedRequest); } } \ No newline at end of file diff --git a/Vonage.Test/Vonage.Test.csproj b/Vonage.Test/Vonage.Test.csproj index 41a7c9994..6bd2ce384 100644 --- a/Vonage.Test/Vonage.Test.csproj +++ b/Vonage.Test/Vonage.Test.csproj @@ -344,27 +344,12 @@ PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -374,12 +359,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -408,27 +387,15 @@ PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - PreserveNewest @@ -1250,6 +1217,42 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/Vonage/Messages/WhatsApp/WhatsAppAudioRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppAudioRequest.cs index 3f8c40b0f..7f4745986 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppAudioRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppAudioRequest.cs @@ -35,4 +35,11 @@ public struct WhatsAppAudioRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppContext.cs b/Vonage/Messages/WhatsApp/WhatsAppContext.cs new file mode 100644 index 000000000..6a35dcb92 --- /dev/null +++ b/Vonage/Messages/WhatsApp/WhatsAppContext.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace Vonage.Messages.WhatsApp; + +/// +/// Represents an optional context used for quoting/replying to a specific message in a conversation. When used, the +/// WhatsApp UI will display the new message along with a contextual bubble that displays the quoted/replied to +/// message's content. +/// +/// The UUID of the message being replied to/quoted. +public record WhatsAppContext( + [property: JsonPropertyName("message_uuid")] + string MessageId); \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppCustomRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppCustomRequest.cs index 186764d1f..07554a528 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppCustomRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppCustomRequest.cs @@ -36,4 +36,11 @@ public struct WhatsAppCustomRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppFileRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppFileRequest.cs index cc8aafa5a..534e10fd4 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppFileRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppFileRequest.cs @@ -35,4 +35,11 @@ public struct WhatsAppFileRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppImageRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppImageRequest.cs index 78bc6fc4a..336dadcac 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppImageRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppImageRequest.cs @@ -35,4 +35,11 @@ public struct WhatsAppImageRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppMultipleItemsRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppMultipleItemsRequest.cs index 9c7706dc2..dfc9f1041 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppMultipleItemsRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppMultipleItemsRequest.cs @@ -37,4 +37,11 @@ public struct WhatsAppMultipleItemsRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppSingleItemRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppSingleItemRequest.cs index b9ea30f1d..602fd8c6a 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppSingleItemRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppSingleItemRequest.cs @@ -37,4 +37,11 @@ public struct WhatsAppSingleProductRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppStickerRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppStickerRequest.cs index 728aae1f1..f0b772de2 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppStickerRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppStickerRequest.cs @@ -37,6 +37,13 @@ public struct WhatsAppStickerRequest : IWhatsAppMessage /// [JsonPropertyOrder(2)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } /// diff --git a/Vonage/Messages/WhatsApp/WhatsAppTemplateRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppTemplateRequest.cs index 099c0b33b..b17cfdb78 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppTemplateRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppTemplateRequest.cs @@ -42,4 +42,11 @@ public struct WhatsAppTemplateRequest : IWhatsAppMessage [JsonPropertyName("whatsapp")] [JsonPropertyOrder(5)] public MessageWhatsApp WhatsApp { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppTextRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppTextRequest.cs index f252dd4d1..b8446c682 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppTextRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppTextRequest.cs @@ -35,4 +35,11 @@ public struct WhatsAppTextRequest : IWhatsAppMessage /// [JsonPropertyOrder(3)] public string To { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file diff --git a/Vonage/Messages/WhatsApp/WhatsAppVideoRequest.cs b/Vonage/Messages/WhatsApp/WhatsAppVideoRequest.cs index c8136e2a0..ebe3efdbc 100644 --- a/Vonage/Messages/WhatsApp/WhatsAppVideoRequest.cs +++ b/Vonage/Messages/WhatsApp/WhatsAppVideoRequest.cs @@ -35,4 +35,11 @@ public struct WhatsAppVideoRequest : IWhatsAppMessage /// [JsonPropertyOrder(5)] public CaptionedAttachment Video { get; set; } + + /// + /// An optional context used for quoting/replying to a specific message in a conversation. When used, the WhatsApp UI + /// will display the new message along with a contextual bubble that displays the quoted/replied to message's content. + /// + [JsonPropertyOrder(6)] + public WhatsAppContext Context { get; set; } } \ No newline at end of file