From 834dee05042d15a634ef164ab2cc362aa48d686a Mon Sep 17 00:00:00 2001 From: Gabriel Odero Date: Wed, 4 Oct 2023 16:32:43 +0300 Subject: [PATCH] Authentication template message fix --- .../AuthenticationTemplateMessageRequest.cs | 21 +++++++++++++++++++ .../WhatsappBusiness.CloudApi.csproj | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/WhatsappBusiness.CloudApi/Messages/Requests/AuthenticationTemplateMessageRequest.cs b/WhatsappBusiness.CloudApi/Messages/Requests/AuthenticationTemplateMessageRequest.cs index fd5b3e1..a9d8d28 100644 --- a/WhatsappBusiness.CloudApi/Messages/Requests/AuthenticationTemplateMessageRequest.cs +++ b/WhatsappBusiness.CloudApi/Messages/Requests/AuthenticationTemplateMessageRequest.cs @@ -38,9 +38,15 @@ public class AuthenticationMessageComponent [JsonProperty("type")] public string Type { get; set; } + /// + /// Only to be used for template creation do not set this property when sending auth template messages + /// [JsonProperty("add_security_recommendation", NullValueHandling = NullValueHandling.Ignore)] public bool AddSecurityRecommendation { get; set; } + /// + /// Only to be used for template creation do not set this property when sending auth template messages + /// [JsonProperty("code_expiration_minutes", NullValueHandling = NullValueHandling.Ignore)] public int CodeExpirationMinutes { get; set; } @@ -52,6 +58,21 @@ public class AuthenticationMessageComponent [JsonProperty("index", NullValueHandling = NullValueHandling.Ignore)] public long? Index { get; set; } + + [JsonIgnore] + public bool IsTemplateCreation { get; set; } + + public bool ShouldSerializeCodeExpirationMinutes() + { + // Only to be used for template creation do not set this property when sending auth template messages + return CodeExpirationMinutes > 0; + } + + public bool ShouldSerializeAddSecurityRecommendation() + { + // Only to be used for template creation do not set this property when sending auth template messages + return (IsTemplateCreation) ? AddSecurityRecommendation : false; + } } public class AuthenticationMessageParameter diff --git a/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj b/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj index 25f9ce8..905f2b9 100644 --- a/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj +++ b/WhatsappBusiness.CloudApi/WhatsappBusiness.CloudApi.csproj @@ -12,7 +12,7 @@ https://github.com/gabrieldwight/Whatsapp-Business-Cloud-Api-Net enable latest - 1.0.21 + 1.0.22