From 090b040fe771d908bace0d56f89ec00ca4f02a1b Mon Sep 17 00:00:00 2001 From: Gabriel Odero Date: Wed, 20 Sep 2023 01:38:30 +0300 Subject: [PATCH] Additional message templates added --- .../CarouselTemplateMessageRequest.cs | 107 ++++++++++++++++++ .../Requests/CatalogMessageRequest.cs | 63 +++++++++++ .../Requests/CatalogTemplateMessageRequest.cs | 74 ++++++++++++ .../CouponCodeTemplateMessageRequest.cs | 65 +++++++++++ 4 files changed, 309 insertions(+) create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/CarouselTemplateMessageRequest.cs create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/CatalogMessageRequest.cs create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/CatalogTemplateMessageRequest.cs create mode 100644 WhatsappBusiness.CloudApi/Messages/Requests/CouponCodeTemplateMessageRequest.cs diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/CarouselTemplateMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/CarouselTemplateMessageRequest.cs new file mode 100644 index 0000000..553ec87 --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/CarouselTemplateMessageRequest.cs @@ -0,0 +1,107 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class CarouselTemplateMessageRequest + { + [JsonProperty("messaging_product")] + public string MessagingProduct { get; private set; } = "whatsapp"; + + [JsonProperty("recipient_type")] + public string RecipientType { get; private set; } = "individual"; + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; private set; } = "template"; + + [JsonProperty("template")] + public CarouselMessageTemplate Template { get; set; } + } + + public class CarouselMessageTemplate + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("language")] + public CarouselMessageLanguage Language { get; set; } + + [JsonProperty("components")] + public List Components { get; set; } + } + + public class CarouselMessageTemplateComponent + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("parameters", NullValueHandling = NullValueHandling.Ignore)] + public List Parameters { get; set; } + + [JsonProperty("cards", NullValueHandling = NullValueHandling.Ignore)] + public List Cards { get; set; } + } + + public class CarouselMessageCard + { + [JsonProperty("card_index")] + public int CardIndex { get; set; } + + [JsonProperty("components")] + public List Components { get; set; } + } + + public class CarouselCardComponent + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("parameters")] + public List Parameters { get; set; } + + [JsonProperty("sub_type", NullValueHandling = NullValueHandling.Ignore)] + public string SubType { get; set; } + + [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] + public long? Index { get; set; } + } + + public class CardMessageParameter + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("image", NullValueHandling = NullValueHandling.Ignore)] + public CardImage Image { get; set; } + + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + [JsonProperty("payload", NullValueHandling = NullValueHandling.Ignore)] + public string Payload { get; set; } + } + + public class CardImage + { + [JsonProperty("id")] + public string Id { get; set; } + } + + public partial class CarouselMessageParameter + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("text")] + public string Text { get; set; } + } + + public class CarouselMessageLanguage + { + [JsonProperty("code")] + public string Code { get; set; } + } +} diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/CatalogMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/CatalogMessageRequest.cs new file mode 100644 index 0000000..c013e04 --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/CatalogMessageRequest.cs @@ -0,0 +1,63 @@ +using Newtonsoft.Json; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class CatalogMessageRequest + { + [JsonProperty("messaging_product")] + public string MessagingProduct { get; set; } + + [JsonProperty("recipient_type")] + public string RecipientType { get; set; } + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("interactive")] + public CatalogMessageInteractive Interactive { get; set; } + } + + public class CatalogMessageInteractive + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("body")] + public CatalogMessageBody Body { get; set; } + + [JsonProperty("action")] + public CatalogMessageAction Action { get; set; } + + [JsonProperty("footer")] + public CatalogMessageFooter Footer { get; set; } + } + + public class CatalogMessageAction + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("parameters")] + public CatalogMessageParameters Parameters { get; set; } + } + + public class CatalogMessageParameters + { + [JsonProperty("thumbnail_product_retailer_id")] + public string ThumbnailProductRetailerId { get; set; } + } + + public class CatalogMessageBody + { + [JsonProperty("text")] + public string Text { get; set; } + } + + public class CatalogMessageFooter : CatalogMessageBody + { + + } +} diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/CatalogTemplateMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/CatalogTemplateMessageRequest.cs new file mode 100644 index 0000000..17383ef --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/CatalogTemplateMessageRequest.cs @@ -0,0 +1,74 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class CatalogTemplateMessageRequest + { + [JsonProperty("messaging_product")] + public string MessagingProduct { get; private set; } = "whatsapp"; + + [JsonProperty("recipient_type")] + public string RecipientType { get; private set; } = "individual"; + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; private set; } = "template"; + + [JsonProperty("template")] + public CatalogMessageTemplate Template { get; set; } + } + + public class CatalogMessageTemplate + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("language")] + public CatalogMessageLanguage Language { get; set; } + + [JsonProperty("components")] + public List Components { get; set; } + } + + public class CatalogMessageComponent + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("parameters")] + public List Parameters { get; set; } + + [JsonProperty("sub_type", NullValueHandling = NullValueHandling.Ignore)] + public string SubType { get; set; } + + [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] + public long? Index { get; set; } + } + + public class CatalogTemplateMessageParameter + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + [JsonProperty("action", NullValueHandling = NullValueHandling.Ignore)] + public CatalogTemplateMessageAction Action { get; set; } + } + + public class CatalogTemplateMessageAction + { + [JsonProperty("thumbnail_product_retailer_id")] + public string ThumbnailProductRetailerId { get; set; } + } + + public class CatalogMessageLanguage + { + [JsonProperty("code")] + public string Code { get; set; } + } +} diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/CouponCodeTemplateMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/CouponCodeTemplateMessageRequest.cs new file mode 100644 index 0000000..e79d40d --- /dev/null +++ b/WhatsappBusiness.CloudApi/Messages/Requests/CouponCodeTemplateMessageRequest.cs @@ -0,0 +1,65 @@ +using Newtonsoft.Json; +using System.Collections.Generic; + +namespace WhatsappBusiness.CloudApi.Messages.Requests +{ + public class CouponCodeTemplateMessageRequest + { + [JsonProperty("messaging_product")] + public string MessagingProduct { get; private set; } = "whatsapp"; + + [JsonProperty("to")] + public string To { get; set; } + + [JsonProperty("type")] + public string Type { get; private set; } = "template"; + + [JsonProperty("template")] + public CouponCodeMessageTemplate Template { get; set; } + } + + public class CouponCodeMessageTemplate + { + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("language")] + public CouponCodeMessageLanguage Language { get; set; } + + [JsonProperty("components")] + public List Components { get; set; } + } + + public class CouponCodeMessageComponent + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("parameters")] + public List Parameters { get; set; } + + [JsonProperty("sub_type", NullValueHandling = NullValueHandling.Ignore)] + public string SubType { get; set; } + + [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] + public int? Index { get; set; } + } + + public class CouponCodeMessageParameter + { + [JsonProperty("type")] + public string Type { get; set; } + + [JsonProperty("text", NullValueHandling = NullValueHandling.Ignore)] + public string Text { get; set; } + + [JsonProperty("coupon_code", NullValueHandling = NullValueHandling.Ignore)] + public string CouponCode { get; set; } + } + + public class CouponCodeMessageLanguage + { + [JsonProperty("code")] + public string Code { get; set; } + } +}