diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs index e04692e6..84d8fcfb 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/IRichMessage.cs @@ -1,12 +1,15 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging; public interface IRichMessage { [JsonPropertyName("text")] + [JsonProperty("text")] string Text { get; set; } [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] string RichType => RichTypeEnum.Text; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/ITemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/ITemplateMessage.cs index 63890240..7c9ccadf 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/ITemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/ITemplateMessage.cs @@ -1,7 +1,10 @@ +using Newtonsoft.Json; + namespace BotSharp.Abstraction.Messaging; public interface ITemplateMessage { [JsonPropertyName("template_type")] + [JsonProperty("template_type")] string TemplateType => string.Empty; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementAction.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementAction.cs index 5a2682bd..39d03e86 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementAction.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementAction.cs @@ -1,3 +1,6 @@ +using Newtonsoft.Json; +using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute; + namespace BotSharp.Abstraction.Messaging.Models.RichContent; public class ElementAction @@ -8,6 +11,7 @@ public class ElementAction public string Url { get; set; } [JsonPropertyName("webview_height_ratio")] + [JsonProperty("webview_height_ratio")] public string WebViewHeightRatio { get; set; } [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs index 294b1835..47e7cc9a 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/ElementButton.cs @@ -1,3 +1,6 @@ +using Newtonsoft.Json; +using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute; + namespace BotSharp.Abstraction.Messaging.Models.RichContent; /// @@ -16,11 +19,14 @@ public class ElementButton public string Payload { get; set; } [JsonPropertyName("is_primary")] + [JsonProperty("is_primary")] public bool IsPrimary { get; set; } [JsonPropertyName("is_secondary")] + [JsonProperty("is_secondary")] public bool IsSecondary { get; set; } [JsonPropertyName("post_action_disclaimer")] + [JsonProperty("post_action_disclaimer")] public string? PostActionDisclaimer { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs index 4ad88ab9..583cf966 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyElement.cs @@ -1,3 +1,6 @@ +using Newtonsoft.Json; +using JsonIgnoreAttribute = System.Text.Json.Serialization.JsonIgnoreAttribute; + namespace BotSharp.Abstraction.Messaging.Models.RichContent; public class QuickReplyElement @@ -9,6 +12,7 @@ public class QuickReplyElement public string? Payload { get; set; } [JsonPropertyName("image_url")] + [JsonProperty("image_url")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)] public string? ImageUrl { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs index efb177f0..73690649 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/QuickReplyMessage.cs @@ -1,13 +1,16 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent; public class QuickReplyMessage : IRichMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.QuickReply; public string Text { get; set; } = string.Empty; [JsonPropertyName("quick_replies")] + [JsonProperty("quick_replies")] public List QuickReplies { get; set; } = new List(); } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs index 32ad73e2..ce8a5a93 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ButtonTemplateMessage.cs @@ -1,4 +1,5 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; @@ -8,17 +9,22 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; public class ButtonTemplateMessage : IRichMessage, ITemplateMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.ButtonTemplate; [JsonPropertyName("text")] + [JsonProperty("text")] public string Text { get; set; } = string.Empty; [JsonPropertyName("template_type")] + [JsonProperty("template_type")] public string TemplateType => TemplateTypeEnum.Button; [JsonPropertyName("buttons")] + [JsonProperty("buttons")] public ElementButton[] Buttons { get; set; } = new ElementButton[0]; [JsonPropertyName("is_horizontal")] + [JsonProperty("is_horizontal")] public bool IsHorizontal { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CouponTemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CouponTemplateMessage.cs index 1ca47b5b..171947ab 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CouponTemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/CouponTemplateMessage.cs @@ -1,4 +1,5 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; @@ -9,30 +10,40 @@ namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; public class CouponTemplateMessage : IRichMessage, ITemplateMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.CouponTemplate; + [JsonPropertyName("text")] + [JsonProperty("text")] public string Text { get; set; } public string Title { get; set; } public string Subtitle { get; set; } [JsonPropertyName("template_type")] + [JsonProperty("template_type")] public string TemplateType => TemplateTypeEnum.Coupon; [JsonPropertyName("coupon_code")] + [JsonProperty("coupon_code")] public string CouponCode { get; set; } [JsonPropertyName("coupon_url")] + [JsonProperty("coupon_url")] public string CouponUrl { get; set; } [JsonPropertyName("coupon_url_button_title")] + [JsonProperty("coupon_url_button_title")] public string CouponUrlButtonTitle { get; set; } = "Shop now"; [JsonPropertyName("coupon_pre_message")] + [JsonProperty("coupon_pre_message")] public string CouponPreMessage { get; set; } = "Here's a deal just for you!"; [JsonPropertyName("image_url")] + [JsonProperty("image_url")] public string ImageUrl { get; set; } [JsonPropertyName("payload")] + [JsonProperty("payload")] public string Payload { get; set; } } \ No newline at end of file diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/GenericTemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/GenericTemplateMessage.cs index 6578b363..c846e4ea 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/GenericTemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/GenericTemplateMessage.cs @@ -1,28 +1,36 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; public class GenericTemplateMessage : IRichMessage, ITemplateMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.GenericTemplate; [JsonPropertyName("text")] + [JsonProperty("text")] public string Text { get; set; } = string.Empty; [JsonPropertyName("template_type")] + [JsonProperty("template_type")] public virtual string TemplateType { get; set; } = TemplateTypeEnum.Generic; [JsonPropertyName("elements")] + [JsonProperty("elements")] public List Elements { get; set; } = new List(); [JsonPropertyName("is_horizontal")] + [JsonProperty("is_horizontal")] public bool IsHorizontal { get; set; } [JsonPropertyName("is_popup")] + [JsonProperty("is_popup")] public bool IsPopup { get; set; } [JsonPropertyName("element_type")] + [JsonProperty("element_type")] public string ElementType => typeof(T).Name; } @@ -30,9 +38,13 @@ public class GenericElement { public string Title { get; set; } public string Subtitle { get; set; } + [JsonPropertyName("image_url")] + [JsonProperty("image_url")] public string ImageUrl { get; set; } + [JsonPropertyName("default_action")] + [JsonProperty("default_action")] public ElementAction DefaultAction { get; set; } public ElementButton[] Buttons { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/MultiSelectTemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/MultiSelectTemplateMessage.cs index 6919a1a4..c57f144a 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/MultiSelectTemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/MultiSelectTemplateMessage.cs @@ -1,21 +1,28 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; public class MultiSelectTemplateMessage : IRichMessage, ITemplateMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.MultiSelectTemplate; + [JsonPropertyName("text")] + [JsonProperty("text")] public string Text { get; set; } = string.Empty; [JsonPropertyName("template_type")] + [JsonProperty("template_type")] public string TemplateType => TemplateTypeEnum.MultiSelect; [JsonPropertyName("options")] + [JsonProperty("options")] public List Options { get; set; } = new List(); [JsonPropertyName("is_horizontal")] + [JsonProperty("is_horizontal")] public bool IsHorizontal { get; set; } } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ProductTemplateMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ProductTemplateMessage.cs index 59a1e911..61d22dcc 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ProductTemplateMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/Template/ProductTemplateMessage.cs @@ -1,16 +1,20 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent.Template; public class ProductTemplateMessage : IRichMessage, ITemplateMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.GenericTemplate; [JsonPropertyName("text")] + [JsonProperty("text")] public string Text { get; set; } = string.Empty; [JsonPropertyName("template_type")] + [JsonProperty("template_type")] public string TemplateType => TemplateTypeEnum.Product; } diff --git a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs index 899a9265..d2639ef7 100644 --- a/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs +++ b/src/Infrastructure/BotSharp.Abstraction/Messaging/Models/RichContent/TextMessage.cs @@ -1,10 +1,12 @@ using BotSharp.Abstraction.Messaging.Enums; +using Newtonsoft.Json; namespace BotSharp.Abstraction.Messaging.Models.RichContent; public class TextMessage : IRichMessage { [JsonPropertyName("rich_type")] + [JsonProperty("rich_type")] public string RichType => RichTypeEnum.Text; public string Text { get; set; } = string.Empty; diff --git a/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs b/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs index 72d55b45..f6de19ac 100644 --- a/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs +++ b/src/Infrastructure/BotSharp.Core/Plugins/PluginLoader.cs @@ -5,7 +5,6 @@ using System.Drawing; using System.IO; using System.Reflection; using System.Xml; -using BotSharp.Abstraction.Repositories; namespace BotSharp.Core.Plugins;