From 94deee5a6d360a5bcebadd8f02531cdfbf8ad541 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:07:44 +0200 Subject: [PATCH 01/36] [2.5.1] Replace newtonsoft.json with system.text.json --- CHANGELOG.md | 3 + .../BusinessMessaging/BusinessMessagingApi.cs | 15 +---- CM.Text/BusinessMessaging/MessageBuilder.cs | 2 +- CM.Text/BusinessMessaging/Model/Body.cs | 9 +-- CM.Text/BusinessMessaging/Model/Message.cs | 45 +++++++------ .../MultiChannel/ApplePayConfiguration.cs | 25 +++---- .../Model/MultiChannel/ApplePayRequest.cs | 4 +- .../Model/MultiChannel/CalendarOptions.cs | 10 +-- .../Model/MultiChannel/CalendarSuggestion.cs | 8 +-- .../Model/MultiChannel/Carousel.cs | 8 +-- .../Model/MultiChannel/CarouselCardWidth.cs | 7 +- .../Model/MultiChannel/CarouselMessage.cs | 6 +- .../Model/MultiChannel/ContactMessage.cs | 66 +++++++++---------- .../Model/MultiChannel/Dial.cs | 6 +- .../Model/MultiChannel/DialSuggestion.cs | 8 +-- .../Model/MultiChannel/LineItem.cs | 11 ++-- .../Model/MultiChannel/LocationPushMessage.cs | 6 +- .../Model/MultiChannel/MediaContent.cs | 10 +-- .../Model/MultiChannel/MediaMessage.cs | 6 +- .../Model/MultiChannel/OpenUrlSuggestion.cs | 8 +-- .../Model/MultiChannel/ReplySuggestion.cs | 10 +-- .../Model/MultiChannel/RichCard.cs | 8 +-- .../Model/MultiChannel/RichContent.cs | 6 +- .../Model/MultiChannel/SuggestionBase.cs | 10 +-- .../Model/MultiChannel/TemplateMessage.cs | 6 +- .../MultiChannel/TemplateMessageContent.cs | 6 +- .../Model/MultiChannel/TextMessage.cs | 10 +-- .../Model/MultiChannel/ViewLocationOptions.cs | 14 ++-- .../MultiChannel/ViewLocationSuggestion.cs | 8 +-- .../WhatsAppInteractiveMessage.cs | 54 +++++++-------- .../Model/MultiChannel/WhatsAppTemplate.cs | 60 ++++++++--------- CM.Text/BusinessMessaging/Model/Recipient.cs | 6 +- CM.Text/BusinessMessaging/Model/Request.cs | 8 +-- CM.Text/BusinessMessaging/Model/Response.cs | 20 +++--- CM.Text/CM.Text.csproj | 10 +-- CM.Text/TextClientMessageDetail.cs | 12 ++-- CM.Text/TextClientResult.cs | 8 +-- 37 files changed, 261 insertions(+), 258 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a83b99..7633d16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2.5.1] - 2022-07-04 +- Replace Newtsonsoft.Json with System.Text + ## [2.5.0] - 2022-06-17 - Add Telegram diff --git a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs index 315360b..d585801 100644 --- a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs +++ b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs @@ -1,8 +1,8 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json; using CM.Text.BusinessMessaging.Model; -using Newtonsoft.Json; namespace CM.Text.BusinessMessaging { @@ -37,7 +37,7 @@ internal static string GetHttpPostBody( /// internal static string GetHttpPostBody(Guid apiKey, Message message) { - return JsonConvert.SerializeObject( + return JsonSerializer.Serialize( new { messages = new Request.MessagesEnvelope @@ -56,7 +56,7 @@ internal static string GetHttpPostBody(Guid apiKey, Message message) /// internal static TextClientResult GetTextApiResult(string requestResultContent) { - var deserializedResponse = JsonConvert.DeserializeObject(requestResultContent); + var deserializedResponse = JsonSerializer.Deserialize(requestResultContent); return new TextClientResult { @@ -75,14 +75,5 @@ internal static TextClientResult GetTextApiResult(string requestResultContent) .ToArray() }; } - - internal static class Constant - { - internal const string BusinessMessagingGatewayJsonEndpoint = "https://gw.cmtelecom.com/v1.0/message"; - internal const string BusinessMessagingGatewayMediaTypeJson = "application/json"; - internal const string BusinessMessagingBodyTypeAuto = "AUTO"; - internal const int BusinessMessagingMessagePartsMinDefault = 1; - internal const int BusinessMessagingMessagePartsMaxDefault = 8; - } } } diff --git a/CM.Text/BusinessMessaging/MessageBuilder.cs b/CM.Text/BusinessMessaging/MessageBuilder.cs index c8afd60..7beaf1f 100644 --- a/CM.Text/BusinessMessaging/MessageBuilder.cs +++ b/CM.Text/BusinessMessaging/MessageBuilder.cs @@ -34,7 +34,7 @@ public MessageBuilder(string messageText, string from, params string[] to) Recipients = to.Select(toEntry => new Recipient { Number = toEntry }) .ToArray(), From = from, - CustomGrouping3 = Constant.TextSdkReference + CustomGrouping3 = Configuration.TextSdkReference }; } diff --git a/CM.Text/BusinessMessaging/Model/Body.cs b/CM.Text/BusinessMessaging/Model/Body.cs index df34309..bd2fcf3 100644 --- a/CM.Text/BusinessMessaging/Model/Body.cs +++ b/CM.Text/BusinessMessaging/Model/Body.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model { @@ -22,7 +22,7 @@ public class Body /// Another note is that not all operators in the world are able to handle Unicode messages, so you will need to test /// for which operators it works. /// - [JsonProperty("content")] + [JsonPropertyName("content")] public string Content { get; set; } /// @@ -34,7 +34,8 @@ public class Body /// You can limit the number of parts by setting the maximum number of message parts. /// /// - [JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)] + [JsonPropertyName("type")] + [JsonIgnore] public string Type { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/Message.cs b/CM.Text/BusinessMessaging/Model/Message.cs index 38346e8..118f3eb 100644 --- a/CM.Text/BusinessMessaging/Model/Message.cs +++ b/CM.Text/BusinessMessaging/Model/Message.cs @@ -1,8 +1,7 @@ using System; +using System.Text.Json.Serialization; using CM.Text.BusinessMessaging.Model.MultiChannel; using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; namespace CM.Text.BusinessMessaging.Model { @@ -21,17 +20,15 @@ public class Message /// Note that for channels other than SMS, CM needs to configure the out going flows. /// For those flows to work, we need to be contacted. /// - [JsonProperty( - DefaultValueHandling = DefaultValueHandling.Ignore, - PropertyName = "allowedChannels", - ItemConverterType = typeof(StringEnumConverter) - )] + [JsonPropertyName("allowedChannels")] + [JsonIgnore] + [JsonConverter(typeof(JsonStringEnumConverter))] public Channel[] AllowedChannels { get; set; } /// /// Required: The actual text body of the message. /// - [JsonProperty("body")] + [JsonPropertyName("body")] public Body Body { get; set; } /// @@ -43,7 +40,8 @@ public class Message /// It’s recommended to limit the number of unique custom groupings to 1000. /// Please contact support in case you would like to exceed this number. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "customGrouping")] + [JsonPropertyName("customGrouping")] + [JsonIgnore] public string CustomGrouping { get; set; } /// @@ -56,7 +54,8 @@ public class Message /// It’s recommended to limit the number of unique custom groupings to 1000. /// Please contact support in case you would like to exceed this number. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "customGrouping2")] + [JsonPropertyName("customGrouping2")] + [JsonIgnore] public string CustomGrouping2 { get; set; } /// @@ -70,21 +69,24 @@ public class Message /// Please contact support in case you would like to exceed this number. /// /// Default value within this SDK is - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "customGrouping3")] + [JsonPropertyName("customGrouping3")] + [JsonIgnore] public string CustomGrouping3 { get; set; } /// /// Required: This is the sender name. /// The maximum length is 11 alphanumerical characters or 16 digits. Example: 'MyCompany' /// - [JsonProperty("from")] + [JsonPropertyName("from")] + [JsonIgnore] public string From { get; set; } /// /// Used for Hybrid messaging, see https://docs.cmtelecom.com/en/hybrid-messaging/v2.0.0 for more information /// Messages will be sent over the channel. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "appKey")] + [JsonPropertyName("appKey")] + [JsonIgnore] public Guid? HybridAppKey { get; set; } /// @@ -95,7 +97,8 @@ public class Message /// Technically the gateway will first check if a message is larger than 160 characters, if so, the /// message will be cut into multiple 153 characters parts limited by these parameters. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "maximumNumberOfMessageParts")] + [JsonPropertyName("maximumNumberOfMessageParts")] + [JsonIgnore] public int? MaximumNumberOfMessageParts { get; set; } /// @@ -106,7 +109,8 @@ public class Message /// Technically the gateway will first check if a message is larger than 160 characters, if so, the /// message will be cut into multiple 153 characters parts limited by these parameters. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "minimumNumberOfMessageParts")] + [JsonPropertyName("minimumNumberOfMessageParts")] + [JsonIgnore] public int? MinimumNumberOfMessageParts { get; set; } /// @@ -114,7 +118,7 @@ public class Message /// This value should be in international format. /// A single mobile number per request. Example: '00447911123456' /// - [JsonProperty("to")] + [JsonPropertyName("to")] public Recipient[] Recipients { get; set; } /// @@ -125,14 +129,16 @@ public class Message /// https://docs.cmtelecom.com/business-messaging/v1.0#/status_report_webhook /// The given reference must be between 1 - 32 alphanumeric characters, and will not work using demo accounts. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "reference")] + [JsonPropertyName("reference")] + [JsonIgnore] public string Reference { get; set; } /// /// Can be used by channels that support rich content (all channels except , /// and at this moment) /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "richContent")] + [JsonPropertyName("richContent")] + [JsonIgnore] public RichContent RichContent { get; set; } /// @@ -157,7 +163,8 @@ public class Message /// 30m /// You can set the validity in either hours or minutes. A combination of both is not supported. /// - [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore, PropertyName = "validity")] + [JsonPropertyName("validity")] + [JsonIgnore] public string Validity { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayConfiguration.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayConfiguration.cs index 0049ace..bd7471d 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayConfiguration.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayConfiguration.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; + +using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -10,17 +11,17 @@ public class ApplePayConfiguration /// /// (Required) A unique identifier that represents a merchant for Apple Pay. /// - [JsonProperty("merchantName")] + [JsonPropertyName("merchantName")] public string MerchantName { get; set; } /// /// (Required) Description of the item being bought. /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// (Required) A unique identifier that represents a order /// - [JsonProperty("orderReference")] + [JsonPropertyName("orderReference")] public string OrderReference { get; set; } /// @@ -28,7 +29,7 @@ public class ApplePayConfiguration /// /// Line items are not required. However, the array cannot be empty if the lineItems key is present. /// - [JsonProperty("lineItems")] + [JsonPropertyName("lineItems")] public LineItem[] LineItems { get; set; } /// @@ -36,44 +37,44 @@ public class ApplePayConfiguration /// /// The total amount must be greater than zero to pass validation. /// - [JsonProperty("total")] + [JsonPropertyName("total")] public decimal Total { get; set; } /// /// Email address of the Apple Pay contact. /// - [JsonProperty("recipientEmail")] + [JsonPropertyName("recipientEmail")] public string RecipientEmail { get; set; } /// /// Value indicating the currency code of the apple pay request /// /// Value must be in upper case. /// - [JsonProperty("currencyCode")] + [JsonPropertyName("currencyCode")] public string CurrencyCode { get; set; } /// /// Country of the Apple Pay contact. /// /// Value must be in upper case. /// - [JsonProperty("recipientCountryCode")] + [JsonPropertyName("recipientCountryCode")] public string RecipientCountryCode { get; set; } /// /// The Language of the Country of the Apple Pay Contact /// /// Value must be in lower case. /// - [JsonProperty("languageCountryCode")] + [JsonPropertyName("languageCountryCode")] public string languageCountryCode { get; set; } /// /// Value indicating that a billing address is required /// - [JsonProperty("billingAddressRequired")] + [JsonPropertyName("billingAddressRequired")] public bool BillingAddressRequired { get; set; } /// /// Value indicating that a shipping contact is required /// - [JsonProperty("shippingContactRequired")] + [JsonPropertyName("shippingContactRequired")] public bool ShippingContactRequired { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayRequest.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayRequest.cs index c3d2e17..26e35f1 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayRequest.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ApplePayRequest.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -10,7 +10,7 @@ public class ApplePayRequest : IRichMessage /// /// Gets or sets the apple pay configuration. /// - [JsonProperty("payment")] + [JsonPropertyName("payment")] public ApplePayConfiguration ApplePayConfiguration { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarOptions.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarOptions.cs index a630246..0e7744f 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarOptions.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarOptions.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Serialization; using JetBrains.Annotations; -using Newtonsoft.Json; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -13,23 +13,23 @@ public class CalendarOptions /// /// The end of the appointment. /// - [JsonProperty("endTime")] public DateTime EndTime; + [JsonPropertyName("endTime")] public DateTime EndTime; /// /// The start of the appointment. /// - [JsonProperty("startTime")] public DateTime StartTime; + [JsonPropertyName("startTime")] public DateTime StartTime; /// /// The description which will appear in the calendar app /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// /// The title of the appointment which will appear in the calendar app /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarSuggestion.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarSuggestion.cs index 75d904f..c8768b2 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarSuggestion.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/CalendarSuggestion.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -14,13 +14,13 @@ public class CalendarSuggestion : SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public override string Action => "CreateCalendarEvent"; /// /// The options of the agenda item /// - [JsonProperty("calendar")] + [JsonPropertyName("calendar")] public CalendarOptions Calendar { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/Carousel.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/Carousel.cs index 2f200b0..f8ba3b3 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/Carousel.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/Carousel.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,13 +12,13 @@ public class Carousel /// /// The cards of the carousel /// - [JsonProperty("cards")] + [JsonPropertyName("cards")] public RichCard[] Cards { get; set; } /// /// The width for the items of the carousel /// - [JsonProperty("cardWidth")] + [JsonPropertyName("cardWidth")] public CarouselCardWidth CarouselCardWidth { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselCardWidth.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselCardWidth.cs index b90a5de..ae93dc5 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselCardWidth.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselCardWidth.cs @@ -1,6 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -8,7 +7,7 @@ namespace CM.Text.BusinessMessaging.Model.MultiChannel /// Used by a to set the width /// [PublicAPI] - [JsonConverter(typeof(StringEnumConverter))] + [JsonConverter(typeof(JsonStringEnumConverter))] public enum CarouselCardWidth { /// diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselMessage.cs index a627b74..3bb3d03 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/CarouselMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -13,7 +13,7 @@ public class CarouselMessage : IRichMessage /// /// Contains the rich cards /// - [JsonProperty("carousel")] + [JsonPropertyName("carousel")] public Carousel Carousel { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ContactMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ContactMessage.cs index cdcba88..f40046c 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ContactMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ContactMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -16,7 +16,7 @@ public class ContactMessage : IRichMessage /// /// See also https://developers.facebook.com/docs/whatsapp/api/messages/others#contacts /// - [JsonProperty("contacts")] + [JsonPropertyName("contacts")] public Contact[] Contacts { get; set; } } @@ -29,43 +29,43 @@ public class Contact /// /// Full contact address(es) /// - [JsonProperty("addresses")] + [JsonPropertyName("addresses")] public ContactAddress[] ContactAddresses { get; set; } /// /// YYYY-MM-DD formatted string of the birthday of the contact /// - [JsonProperty("birthday")] + [JsonPropertyName("birthday")] public string Birthday { get; set; } /// /// Contact email address(es) /// - [JsonProperty("emails")] + [JsonPropertyName("emails")] public ContactEmail[] EmailAddresses { get; set; } /// /// Full contact name /// - [JsonProperty("name")] + [JsonPropertyName("name")] public ContactName Name { get; set; } /// /// Contact organization information /// - [JsonProperty("org")] + [JsonPropertyName("org")] public ContactOrganization Organization { get; set; } /// /// Contact phone number(s) /// - [JsonProperty("phones")] + [JsonPropertyName("phones")] public ContactPhoneNumber[] PhoneNumbers { get; set; } /// /// Contact URL(s) /// - [JsonProperty("urls")] + [JsonPropertyName("urls")] public ContactUrl[] Urls { get; set; } } @@ -78,37 +78,37 @@ public class ContactAddress /// /// City name /// - [JsonProperty("city")] + [JsonPropertyName("city")] public string City { get; set; } /// /// Full country name /// - [JsonProperty("country")] + [JsonPropertyName("country")] public string Country { get; set; } /// /// Two-letter country abbreviation /// - [JsonProperty("country_code")] + [JsonPropertyName("country_code")] public string CountryCode { get; set; } /// /// State abbreviation /// - [JsonProperty("state")] + [JsonPropertyName("state")] public string State { get; set; } /// /// Street number and name /// - [JsonProperty("street")] + [JsonPropertyName("street")] public string Street { get; set; } /// /// Standard Values: HOME, WORK /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// ZIP code /// - [JsonProperty("zip")] + [JsonPropertyName("zip")] public string ZipCode { get; set; } } @@ -121,12 +121,12 @@ public class ContactEmail /// /// Email address /// - [JsonProperty("email")] + [JsonPropertyName("email")] public string EmailAddress { get; set; } /// /// Standard Values: HOME, WORK /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } } @@ -139,32 +139,32 @@ public class ContactName /// /// First name /// - [JsonProperty("first_name")] + [JsonPropertyName("first_name")] public string FirstName { get; set; } /// /// Last name /// - [JsonProperty("last_name")] + [JsonPropertyName("last_name")] public string LastName { get; set; } /// /// Middle name /// - [JsonProperty("middle_name")] + [JsonPropertyName("middle_name")] public string MiddleName { get; set; } /// /// Name prefix /// - [JsonProperty("name_prefix")] + [JsonPropertyName("name_prefix")] public string NamePrefix { get; set; } /// /// Name suffix /// - [JsonProperty("name_suffix")] + [JsonPropertyName("name_suffix")] public string NameSuffix { get; set; } /// /// Full name as it normally appears /// - [JsonProperty("formatted_name")] + [JsonPropertyName("formatted_name")] public string FormattedName { get; set; } } /// @@ -176,17 +176,17 @@ public class ContactOrganization /// /// Name of the contact's company /// - [JsonProperty("company")] + [JsonPropertyName("company")] public string Company { get; set; } /// /// Name of the contact's department /// - [JsonProperty("department")] + [JsonPropertyName("department")] public string Department { get; set; } /// /// Contact's business title /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } } @@ -198,12 +198,12 @@ public class ContactPhoneNumber /// /// The phone number of the contact /// - [JsonProperty("phone")] + [JsonPropertyName("phone")] public string Phone { get; set; } /// /// Standard Values: CELL, MAIN, IPHONE, HOME, WORK /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } } @@ -216,12 +216,12 @@ public class ContactUrl /// /// URL /// - [JsonProperty("url")] + [JsonPropertyName("url")] public string Url { get; set; } /// /// Standard Values: HOME, WORK /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } } -} \ No newline at end of file +} diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/Dial.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/Dial.cs index 63d46db..c11101a 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/Dial.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/Dial.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,7 +12,7 @@ public class Dial /// /// The number to call (in international format) /// - [JsonProperty("phoneNumber")] + [JsonPropertyName("phoneNumber")] public string PhoneNumber { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/DialSuggestion.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/DialSuggestion.cs index 1ad89ad..2508ae3 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/DialSuggestion.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/DialSuggestion.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -14,13 +14,13 @@ public class DialSuggestion : SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public override string Action => "Dial"; /// /// The dial options /// - [JsonProperty("dial")] + [JsonPropertyName("dial")] public Dial Dial { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/LineItem.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/LineItem.cs index e036f90..ded2ff9 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/LineItem.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/LineItem.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; + +using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -10,17 +11,17 @@ public class LineItem /// /// (Required) A short, localized description of the line item. /// - [JsonProperty("label")] + [JsonPropertyName("label")] public string Label { get; set; } /// /// A value that indicates whether the line item is final or pending. /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// (Required) The monetary amount of the line item. /// - [JsonProperty("amount")] + [JsonPropertyName("amount")] public decimal Amount { get; set; } } -} \ No newline at end of file +} diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/LocationPushMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/LocationPushMessage.cs index a899e1c..6193596 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/LocationPushMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/LocationPushMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -13,7 +13,7 @@ public class LocationPushMessage : IRichMessage /// /// The location options to send. /// - [JsonProperty("location")] + [JsonPropertyName("location")] public ViewLocationOptions Location { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/MediaContent.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/MediaContent.cs index 32bdd52..8a43784 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/MediaContent.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/MediaContent.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -32,19 +32,19 @@ public MediaContent(string mediaName, string mediaUri, string mimeType) /// /// The name of the image, audio or video. /// - [JsonProperty("mediaName")] + [JsonPropertyName("mediaName")] public string MediaName { get; set; } /// /// The location of the image, audio or video. /// - [JsonProperty("mediaUri")] + [JsonPropertyName("mediaUri")] public string MediaUri { get; set; } /// /// The mimetype of the image, audio or video. /// - [JsonProperty("mimeType")] + [JsonPropertyName("mimeType")] public string MimeType { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/MediaMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/MediaMessage.cs index eaa97ec..6a14e04 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/MediaMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/MediaMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -31,7 +31,7 @@ public MediaMessage(string mediaName, string mediaUri, string mimeType) /// /// The image or video of the message. /// - [JsonProperty("media")] + [JsonPropertyName("media")] public MediaContent Media { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/OpenUrlSuggestion.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/OpenUrlSuggestion.cs index a1b94ce..267dd0a 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/OpenUrlSuggestion.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/OpenUrlSuggestion.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -16,7 +16,7 @@ public class OpenUrlSuggestion : SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public override string Action => "openUrl"; /// @@ -26,7 +26,7 @@ public class OpenUrlSuggestion : SuggestionBase /// For this can be an in-app link, /// which will only be shown when the app is installed. /// - [JsonProperty("url")] + [JsonPropertyName("url")] public string Url { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ReplySuggestion.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ReplySuggestion.cs index 6a23f4a..d101b5f 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ReplySuggestion.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ReplySuggestion.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,7 +12,7 @@ public class ReplySuggestion : SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public override string Action => "reply"; /// @@ -21,7 +21,7 @@ public class ReplySuggestion : SuggestionBase /// /// For /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } /// @@ -30,7 +30,7 @@ public class ReplySuggestion : SuggestionBase /// /// For /// - [JsonProperty("media")] + [JsonPropertyName("media")] public MediaContent Media { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/RichCard.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/RichCard.cs index c4c4437..323e7e2 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/RichCard.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/RichCard.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,13 +12,13 @@ public class RichCard : TextMessage /// /// Optional: the header for a rich card /// - [JsonProperty("header")] + [JsonPropertyName("header")] public string Header { get; set; } /// /// The image or video of the card. /// - [JsonProperty("media")] + [JsonPropertyName("media")] public MediaContent Media { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/RichContent.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/RichContent.cs index 5017409..3018429 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/RichContent.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/RichContent.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Serialization; using JetBrains.Annotations; -using Newtonsoft.Json; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -23,13 +23,13 @@ public RichContent() /// /// The messages. /// - [JsonProperty("conversation")] + [JsonPropertyName("conversation")] public IRichMessage[] Conversation { get; set; } /// /// The suggestions /// - [JsonProperty("suggestions")] + [JsonPropertyName("suggestions")] public SuggestionBase[] Suggestions { get; set; } /// diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/SuggestionBase.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/SuggestionBase.cs index e7740f6..865d015 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/SuggestionBase.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/SuggestionBase.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -13,20 +13,20 @@ public abstract class SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public virtual string Action { get; } /// /// The text the end user will see /// - [JsonProperty("label")] + [JsonPropertyName("label")] public string Label { get; set; } /// /// When the item is selected and the postback data is set, then the Postback data will be /// sent in a MO instead of the . /// - [JsonProperty("postbackdata")] + [JsonPropertyName("postbackdata")] public string PostbackData { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessage.cs index 04dc417..e7690f8 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -15,7 +15,7 @@ public class TemplateMessage : IRichMessage /// Templates need to be configured by CM and approved by WhatsApp before it is possible /// to send these messages. /// - [JsonProperty("template")] + [JsonPropertyName("template")] public TemplateMessageContent Content { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessageContent.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessageContent.cs index c8a6c9e..d164f95 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessageContent.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/TemplateMessageContent.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -15,7 +15,7 @@ public class TemplateMessageContent /// Templates need to be configured by CM and approved by WhatsApp before it is possible /// to send these messages. /// - [JsonProperty("whatsapp")] + [JsonPropertyName("whatsapp")] public WhatsappTemplate Whatsapp { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/TextMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/TextMessage.cs index 67d9e8f..2490384 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/TextMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/TextMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -30,19 +30,19 @@ public TextMessage(string text) /// A plain text message, when used it replaces the 'SMS' body text. /// In , when used in combination with an header and/or media this will be set as the text of a rich card. /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } /// /// Tag to send important and/or personally relevant 1:1 updates to recipients. E.g. to notify a recipient of an update on a recent purchase. /// - [JsonProperty("tag")] + [JsonPropertyName("tag")] public string Tag { get; set; } /// /// The suggestions of a text message. /// - [JsonProperty("suggestions")] + [JsonPropertyName("suggestions")] public SuggestionBase[] Suggestions { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationOptions.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationOptions.cs index e12a13e..fd5590c 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationOptions.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationOptions.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,7 +12,7 @@ public class ViewLocationOptions /// /// Optional: The label to display at the pin /// - [JsonProperty("label")] + [JsonPropertyName("label")] public string Label { get; set; } /// @@ -20,7 +20,7 @@ public class ViewLocationOptions /// /// 51.603802 /// Either Latitude and or is required - [JsonProperty("latitude")] + [JsonPropertyName("latitude")] public string Latitude { get; set; } /// @@ -28,7 +28,7 @@ public class ViewLocationOptions /// /// 4.770821 /// Either and Longitude or is required - [JsonProperty("longitude")] + [JsonPropertyName("longitude")] public string Longitude { get; set; } /// @@ -38,13 +38,13 @@ public class ViewLocationOptions /// Either and or SearchQuery is required. /// For other connections both may be required. /// - [JsonProperty("searchQuery")] + [JsonPropertyName("searchQuery")] public string SearchQuery { get; set; } /// /// Can be used in some connections to display a radius instead of only a pointer /// - [JsonProperty("radius")] + [JsonPropertyName("radius")] public int? Radius { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationSuggestion.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationSuggestion.cs index c7f02a1..df20cf5 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationSuggestion.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/ViewLocationSuggestion.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -12,13 +12,13 @@ public class ViewLocationSuggestion : SuggestionBase /// /// The action of this suggestion /// - [JsonProperty("action")] + [JsonPropertyName("action")] public override string Action => "viewLocation"; /// /// The location options /// - [JsonProperty("viewLocation")] + [JsonPropertyName("viewLocation")] public ViewLocationOptions Location { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppInteractiveMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppInteractiveMessage.cs index 9eb3902..a5be965 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppInteractiveMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppInteractiveMessage.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -14,7 +14,7 @@ public class WhatsAppInteractiveMessage : IRichMessage /// /// Gets or sets the content of the WhatsApp interactive message /// - [JsonProperty("interactive")] + [JsonPropertyName("interactive")] public WhatsAppInteractiveContent whatsAppInteractiveContent { get; set; } } @@ -31,25 +31,25 @@ public class WhatsAppInteractiveContent /// The Type that will be used, /// either list or button /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Your message’s header. /// - [JsonProperty("header")] + [JsonPropertyName("header")] public InteractiveHeader Header { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Required Your message’s body. /// - [JsonProperty("body")] + [JsonPropertyName("body")] public InteractiveBody Body { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Required Your message’s footer. /// - [JsonProperty("footer")] + [JsonPropertyName("footer")] public InteractiveFooter Footer { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages @@ -57,7 +57,7 @@ public class WhatsAppInteractiveContent ///a button field with your button’s content, and ///at least one section object (maximum of 10). /// - [JsonProperty("action")] + [JsonPropertyName("action")] public InteractiveAction Action { get; set; } } @@ -72,21 +72,21 @@ public class InteractiveHeader /// Required. The header type you would like to use.Supported values are: ///text: Used for List Messages and Reply Buttons. /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Required if type is set to text. /// Text for the header.Formatting allows emojis, but not markdown. /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Gets or sets the media. /// - [JsonProperty("media")] + [JsonPropertyName("media")] public MediaContent Media { get; set; } } @@ -102,7 +102,7 @@ public class InteractiveBody /// The body content of the message. Emojis and markdown are supported. Links are supported. /// Maximum length: 1024 characters. /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } } @@ -118,7 +118,7 @@ public class InteractiveFooter /// The footer content. Emojis and markdown are supported. Links are supported. /// Maximum length: 60 characters /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } } @@ -134,19 +134,19 @@ public class InteractiveAction /// Button content. It cannot be an empty string and must be unique within the message /// Does not allow emojis or markdown. /// - [JsonProperty("button")] + [JsonPropertyName("button")] public string Button { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Required for Reply Button Messages. /// - [JsonProperty("buttons")] + [JsonPropertyName("buttons")] public InteractiveButton[] Buttons { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Required for List Messages. /// - [JsonProperty("sections")] + [JsonPropertyName("sections")] public InteractiveSection[] Sections { get; set; } } @@ -160,27 +160,27 @@ public class InteractiveButton /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// type: only supported type is reply (for Reply Button Messages). /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Button title.It cannot be an empty string and must be unique within the message. /// Does not allow emojis or markdown. Maximum length: 20 characters. /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// id: Unique identifier for your button. This ID is returned in the webhook when the button is clicked by the user. /// Maximum length: 256 characters. /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Reply Message for your button. /// - [JsonProperty("reply")] + [JsonPropertyName("reply")] public ReplyMessage Reply { get; set; } } @@ -194,13 +194,13 @@ public class ReplyMessage /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// id: Unique identifier for your reply message. /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// title: title for your reply button. /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } } @@ -215,13 +215,13 @@ public class InteractiveSection /// Title of the section. /// Maximum length: 24 characters. /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Contains a list of rows. /// - [JsonProperty("rows")] + [JsonPropertyName("rows")] public Rows[] Rows { get; set; } } @@ -235,19 +235,19 @@ public class Rows /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Title of the row. /// - [JsonProperty("title")] + [JsonPropertyName("title")] public string Title { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Id of the row. /// - [JsonProperty("id")] + [JsonPropertyName("id")] public string Id { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/guides/interactive-messages /// Description of the row. /// - [JsonProperty("description")] + [JsonPropertyName("description")] public string Description { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppTemplate.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppTemplate.cs index 37a4f53..2db79aa 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppTemplate.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/WhatsAppTemplate.cs @@ -1,6 +1,6 @@ using System; +using System.Text.Json.Serialization; using JetBrains.Annotations; -using Newtonsoft.Json; namespace CM.Text.BusinessMessaging.Model.MultiChannel { @@ -18,14 +18,14 @@ public class WhatsappTemplate /// Source: https://developers.facebook.com/docs/whatsapp/api/messages/message-templates /// The namespace that will be used /// - [JsonProperty("namespace")] + [JsonPropertyName("namespace")] public string Namespace { get; set; } /// /// Source: https://developers.facebook.com/docs/whatsapp/api/messages/message-templates /// The element name that indicates which template to use within the namespace /// - [JsonProperty("element_name")] + [JsonPropertyName("element_name")] public string Name { get; set; } /// @@ -35,7 +35,7 @@ public class WhatsappTemplate /// The language parameter sets the language policy for an Message Template; /// you can set it to either fallback or deterministic. /// - [JsonProperty("language")] + [JsonPropertyName("language")] public Language Language { get; set; } @@ -58,7 +58,7 @@ public class LocalizableParam /// /// Default text if localization fails /// - [JsonProperty("default")] + [JsonPropertyName("default")] public string Default { get; set; } /// @@ -66,7 +66,7 @@ public class LocalizableParam /// /// If the currency object is used, it contains required parameters currency_code and amount_1000. /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public TemplateCurrency Currency { get; set; } /// @@ -74,7 +74,7 @@ public class LocalizableParam /// /// If the date_time object is used, further definition of the date and time is required. /// - [JsonProperty("date_time")] + [JsonPropertyName("date_time")] public TemplateDateTime DateTime { get; set; } } @@ -91,20 +91,20 @@ public class TemplateCurrency /// /// The Fallback amount /// - [JsonProperty("fallback_value")] + [JsonPropertyName("fallback_value")] public string FallbackValue { get; set; } /// /// Currency code, for example USD or EUR /// - [JsonProperty("code")] + [JsonPropertyName("code")] public string CurrencyCode { get; set; } /// /// Amount in currency_code times 1000 /// /// 50110 EUR becomes €50.11 in the message - [JsonProperty("amount_1000")] + [JsonPropertyName("amount_1000")] public long Amount { get; set; } } @@ -117,7 +117,7 @@ public class TemplateDateTime /// The fallback date in UTC format /// /// There will be no checking whether this is correct, - [JsonProperty("fallback_value")] + [JsonPropertyName("fallback_value")] public string FallbackValue { get; } /// @@ -127,32 +127,32 @@ public class TemplateDateTime /// /// /// There will be no checking whether this is correct, - [JsonProperty("day_of_week")] + [JsonPropertyName("day_of_week")] public int DayOfWeek { get; } /// /// The day of the month. /// - [JsonProperty("day_of_month")] + [JsonPropertyName("day_of_month")] public int DayOfMonth { get; } /// /// The year. /// - [JsonProperty("year")] + [JsonPropertyName("year")] public int Year { get; } /// /// The month. /// - [JsonProperty("month")] + [JsonPropertyName("month")] public int Month { get; } /// /// The hour (24 hour notation) /// - [JsonProperty("hour")] + [JsonPropertyName("hour")] public int Hour { get; } /// /// The minute of the hour. /// - [JsonProperty("minute")] + [JsonPropertyName("minute")] public int Minute { get; } /// @@ -183,7 +183,7 @@ public class Language /// Source: https://developers.facebook.com/docs/whatsapp/api/messages/message-templates /// The code of the language or locale to use — Accepts both language and language_locale formats (e.g., en and en_US). /// - [JsonProperty("code")] + [JsonPropertyName("code")] public string Code { get; set; } /// @@ -191,7 +191,7 @@ public class Language /// Options: fallback, deterministic /// The language policy the message should follow /// - [JsonProperty("policy")] + [JsonPropertyName("policy")] public string Policy { get; set; } } /// @@ -203,25 +203,25 @@ public class TemplateComponents /// /// Required. describes the component type. Possible values: header, content, footer. /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Can be empty. describes the Type of button being created. Possible values: quick_reply, url. /// - [JsonProperty("sub_type")] + [JsonPropertyName("sub_type")] public string SubType { get; set; } /// /// Can be empty. Position index of the button. /// You can have up to 3 buttons using index values of 0-2. /// - [JsonProperty("index")] + [JsonPropertyName("index")] public int Index { get; set; } /// /// Can be empty. Array containing the dynamic content of the message. /// - [JsonProperty("parameters")] + [JsonPropertyName("parameters")] public ComponentParameters[] ComponentParameters { get; set; } } /// @@ -233,18 +233,18 @@ public class ComponentParameters /// /// Describes the parameter type. Possible values: text, currency, date_time, image, document. /// - [JsonProperty("type")] + [JsonPropertyName("type")] public string Type { get; set; } /// /// Only to be filled in when `type` = `text`. /// - [JsonProperty("text")] + [JsonPropertyName("text")] public string Text { get; set; } /// /// Only to be filled in when `type` = `document` or `image`. /// - [JsonProperty("media")] + [JsonPropertyName("media")] public MediaContent Media { get; set; } /// @@ -252,7 +252,7 @@ public class ComponentParameters /// /// Default text if localization fails /// - [JsonProperty("default")] + [JsonPropertyName("default")] public string Default { get; set; } /// @@ -260,7 +260,7 @@ public class ComponentParameters /// /// If the currency object is used, it contains required parameters currency_code and amount_1000. /// - [JsonProperty("currency")] + [JsonPropertyName("currency")] public TemplateCurrency Currency { get; set; } /// @@ -268,14 +268,14 @@ public class ComponentParameters /// /// If the date_time object is used, further definition of the date and time is required. /// - [JsonProperty("date_time")] + [JsonPropertyName("date_time")] public TemplateDateTime DateTime { get; set; } /// /// Developer-defined payload that will be returned when the button is clicked in addition to the display text on the button /// Required for quick_reply buttons /// - [JsonProperty("payload")] + [JsonPropertyName("payload")] public string Payload { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/Recipient.cs b/CM.Text/BusinessMessaging/Model/Recipient.cs index ebac7a1..da8bb42 100644 --- a/CM.Text/BusinessMessaging/Model/Recipient.cs +++ b/CM.Text/BusinessMessaging/Model/Recipient.cs @@ -1,5 +1,5 @@ -using JetBrains.Annotations; -using Newtonsoft.Json; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model { @@ -13,7 +13,7 @@ public class Recipient /// This value should be in international format. /// A single mobile number per request. Example: '00447911123456' /// - [JsonProperty("number")] + [JsonPropertyName("number")] public string Number { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/Request.cs b/CM.Text/BusinessMessaging/Model/Request.cs index cd8cf10..263af11 100644 --- a/CM.Text/BusinessMessaging/Model/Request.cs +++ b/CM.Text/BusinessMessaging/Model/Request.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model { @@ -6,16 +6,16 @@ internal static class Request { internal class MessagesEnvelope { - [JsonProperty("authentication")] + [JsonPropertyName("authentication")] internal Authentication Authentication { get; set; } - [JsonProperty("msg")] + [JsonPropertyName("msg")] internal Message[] Messages { get; set; } } internal class Authentication { - [JsonProperty("producttoken")] + [JsonPropertyName("producttoken")] internal string ProductToken { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/Response.cs b/CM.Text/BusinessMessaging/Model/Response.cs index 7a6aa49..f92493f 100644 --- a/CM.Text/BusinessMessaging/Model/Response.cs +++ b/CM.Text/BusinessMessaging/Model/Response.cs @@ -1,5 +1,5 @@ using System.Diagnostics.CodeAnalysis; -using Newtonsoft.Json; +using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model { @@ -8,34 +8,34 @@ internal static class Response { internal class HttpResponseBody { - [JsonProperty] + [JsonInclude] internal string details { get; set; } - [JsonProperty] + [JsonInclude] internal int errorCode { get; set; } - [JsonProperty] + [JsonInclude] internal ResponseMessageDetail[] messages { get; set; } } internal class ResponseMessageDetail { - [JsonProperty] + [JsonInclude] internal string messageDetails { get; set; } - [JsonProperty] + [JsonInclude] internal string messageErrorCode { get; set; } - [JsonProperty] + [JsonInclude] internal int parts { get; set; } - [JsonProperty] + [JsonInclude] internal string reference { get; set; } - [JsonProperty] + [JsonInclude] internal string status { get; set; } - [JsonProperty] + [JsonInclude] internal string to { get; set; } } } diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 29e51f7..4582542 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -6,23 +6,23 @@ CM.com CM Text SDK A software development kit to provide ways to interact with CM.com's Text service. - messaging, text, sms, email, push, whatsapp, viber, wechat, rcs, voice, business messaging, telegram, conversational, sms chat, chat, sms 2.0, rbm, mms, rich sms, rich communication services + messaging, text, sms, email, push, whatsapp, viber, wechat, rcs, voice, business messaging, telegram, conversational, sms chat, chat, sms 2.0, rbm, mms, rich sms, rich communication services, telegram https://github.com/cmdotcom/text-sdk-dotnet Github 2020 CM.com https://mit-license.org See CHANGELOG.md for details - 2.5.0 + 2.5.1 http://static.cmtelecom.com/images/cm-nuget.png https://github.com/cmdotcom/text-sdk-dotnet en true - 2.5.0.0 - 2.5.0.0 + 2.5.1.0 + 2.5.1.0 - + diff --git a/CM.Text/TextClientMessageDetail.cs b/CM.Text/TextClientMessageDetail.cs index 892c4d4..f9161f0 100644 --- a/CM.Text/TextClientMessageDetail.cs +++ b/CM.Text/TextClientMessageDetail.cs @@ -1,6 +1,6 @@ using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; using JetBrains.Annotations; -using Newtonsoft.Json; namespace CM.Text { @@ -17,7 +17,7 @@ public class TextClientMessageDetail /// /// The details. /// - [JsonProperty(Order = 4)] + [JsonPropertyOrder(4)] public string details { get; set; } /// @@ -26,7 +26,7 @@ public class TextClientMessageDetail /// /// The parts. /// - [JsonProperty(Order = 3)] + [JsonPropertyOrder(3)] public int parts { get; set; } /// @@ -35,7 +35,7 @@ public class TextClientMessageDetail /// /// The reference. /// - [JsonProperty(Order = 0)] + [JsonPropertyOrder(0)] public string reference { get; set; } /// @@ -44,7 +44,7 @@ public class TextClientMessageDetail /// /// The status. /// - [JsonProperty(Order = 1)] + [JsonPropertyOrder(1)] public string status { get; set; } /// @@ -53,7 +53,7 @@ public class TextClientMessageDetail /// /// To. /// - [JsonProperty(Order = 2)] + [JsonPropertyOrder(2)] public string to { get; set; } } } diff --git a/CM.Text/TextClientResult.cs b/CM.Text/TextClientResult.cs index 450a748..7d434e4 100644 --- a/CM.Text/TextClientResult.cs +++ b/CM.Text/TextClientResult.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Text.Json.Serialization; using JetBrains.Annotations; -using Newtonsoft.Json; namespace CM.Text { @@ -18,7 +18,7 @@ public class TextClientResult /// /// The details. /// - [JsonProperty(Order = 2)] + [JsonPropertyOrder(2)] public IEnumerable details { get; set; } /// @@ -27,7 +27,7 @@ public class TextClientResult /// /// The status code. /// - [JsonProperty(Order = 1)] + [JsonPropertyOrder(1)] public TextClientStatusCode statusCode { get; set; } /// @@ -36,7 +36,7 @@ public class TextClientResult /// /// The status message. /// - [JsonProperty(Order = 0)] + [JsonPropertyOrder(0)] public string statusMessage { get; set; } } } From 21c81e3f7161298ef76fdce1cc331a6bed74ebb7 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:08:35 +0200 Subject: [PATCH 02/36] Update BusinessMessagingApi.cs --- CM.Text/BusinessMessaging/BusinessMessagingApi.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs index d585801..b47a4dd 100644 --- a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs +++ b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs @@ -75,5 +75,13 @@ internal static TextClientResult GetTextApiResult(string requestResultContent) .ToArray() }; } + internal static class Constant + { + internal const string BusinessMessagingGatewayJsonEndpoint = "https://gw.cmtelecom.com/v1.0/message"; + internal const string BusinessMessagingGatewayMediaTypeJson = "application/json"; + internal const string BusinessMessagingBodyTypeAuto = "AUTO"; + internal const int BusinessMessagingMessagePartsMinDefault = 1; + internal const int BusinessMessagingMessagePartsMaxDefault = 8; + } } } From 9a714972068fc8137acf5c6bc44097893e22c438 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Mon, 4 Jul 2022 22:12:03 +0200 Subject: [PATCH 03/36] Update MessageBuilder.cs --- CM.Text/BusinessMessaging/MessageBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CM.Text/BusinessMessaging/MessageBuilder.cs b/CM.Text/BusinessMessaging/MessageBuilder.cs index 7beaf1f..c8afd60 100644 --- a/CM.Text/BusinessMessaging/MessageBuilder.cs +++ b/CM.Text/BusinessMessaging/MessageBuilder.cs @@ -34,7 +34,7 @@ public MessageBuilder(string messageText, string from, params string[] to) Recipients = to.Select(toEntry => new Recipient { Number = toEntry }) .ToArray(), From = from, - CustomGrouping3 = Configuration.TextSdkReference + CustomGrouping3 = Constant.TextSdkReference }; } From f9a335bcde76f4f21885b78e0fe809e01d5def98 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Tue, 5 Jul 2022 18:33:49 +0200 Subject: [PATCH 04/36] [JsonIgnore] > [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] --- CM.Text/BusinessMessaging/Model/Body.cs | 2 +- CM.Text/BusinessMessaging/Model/Message.cs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CM.Text/BusinessMessaging/Model/Body.cs b/CM.Text/BusinessMessaging/Model/Body.cs index bd2fcf3..b2fcb24 100644 --- a/CM.Text/BusinessMessaging/Model/Body.cs +++ b/CM.Text/BusinessMessaging/Model/Body.cs @@ -35,7 +35,7 @@ public class Body /// /// [JsonPropertyName("type")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Type { get; set; } } } diff --git a/CM.Text/BusinessMessaging/Model/Message.cs b/CM.Text/BusinessMessaging/Model/Message.cs index 118f3eb..3de2e48 100644 --- a/CM.Text/BusinessMessaging/Model/Message.cs +++ b/CM.Text/BusinessMessaging/Model/Message.cs @@ -21,7 +21,7 @@ public class Message /// For those flows to work, we need to be contacted. /// [JsonPropertyName("allowedChannels")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] [JsonConverter(typeof(JsonStringEnumConverter))] public Channel[] AllowedChannels { get; set; } @@ -41,7 +41,7 @@ public class Message /// Please contact support in case you would like to exceed this number. /// [JsonPropertyName("customGrouping")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string CustomGrouping { get; set; } /// @@ -55,7 +55,7 @@ public class Message /// Please contact support in case you would like to exceed this number. /// [JsonPropertyName("customGrouping2")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string CustomGrouping2 { get; set; } /// @@ -70,7 +70,7 @@ public class Message /// /// Default value within this SDK is [JsonPropertyName("customGrouping3")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string CustomGrouping3 { get; set; } /// @@ -78,7 +78,7 @@ public class Message /// The maximum length is 11 alphanumerical characters or 16 digits. Example: 'MyCompany' /// [JsonPropertyName("from")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string From { get; set; } /// @@ -86,7 +86,7 @@ public class Message /// Messages will be sent over the channel. /// [JsonPropertyName("appKey")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public Guid? HybridAppKey { get; set; } /// @@ -98,7 +98,7 @@ public class Message /// message will be cut into multiple 153 characters parts limited by these parameters. /// [JsonPropertyName("maximumNumberOfMessageParts")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public int? MaximumNumberOfMessageParts { get; set; } /// @@ -110,7 +110,7 @@ public class Message /// message will be cut into multiple 153 characters parts limited by these parameters. /// [JsonPropertyName("minimumNumberOfMessageParts")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public int? MinimumNumberOfMessageParts { get; set; } /// @@ -130,7 +130,7 @@ public class Message /// The given reference must be between 1 - 32 alphanumeric characters, and will not work using demo accounts. /// [JsonPropertyName("reference")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Reference { get; set; } /// @@ -138,7 +138,7 @@ public class Message /// and at this moment) /// [JsonPropertyName("richContent")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public RichContent RichContent { get; set; } /// @@ -164,7 +164,7 @@ public class Message /// You can set the validity in either hours or minutes. A combination of both is not supported. /// [JsonPropertyName("validity")] - [JsonIgnore] + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Validity { get; set; } } } From ba9b688472de06bf3efeea4750dec9ccb3513fb1 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Tue, 5 Jul 2022 18:34:29 +0200 Subject: [PATCH 05/36] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7633d16..f93a077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [2.5.1] - 2022-07-04 -- Replace Newtsonsoft.Json with System.Text +## [Unreleased] +- Replace Newtsonsoft.Json with System.Text.Json ## [2.5.0] - 2022-06-17 - Add Telegram From ed99a288185be139d46bfcb6893ba92086ba9528 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Tue, 5 Jul 2022 18:35:53 +0200 Subject: [PATCH 06/36] Update changelog and enable treatwarningsaserrors --- CHANGELOG.md | 2 ++ CM.Text/CM.Text.csproj | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f93a077..0373d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - Replace Newtsonsoft.Json with System.Text.Json +- Add Telegram as tag +- Enable Treat Warnings as Errors to adhere to code guidelines ## [2.5.0] - 2022-06-17 - Add Telegram diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 4582542..0dbe4b5 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -21,6 +21,14 @@ 2.5.1.0 + + True + + + + True + + From d3fccc7f182389a5a753d7234b492c0b83fed45f Mon Sep 17 00:00:00 2001 From: Enes Keric Date: Tue, 12 Jul 2022 13:41:59 +0200 Subject: [PATCH 07/36] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0373d42..1709ea9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -- Replace Newtsonsoft.Json with System.Text.Json -- Add Telegram as tag +### Added +- System.Text.Json, replaces Newtsonsoft, possibly breaking +- Add Telegram as tag for the project +### Changed - Enable Treat Warnings as Errors to adhere to code guidelines +### Removed +- Newtsonsoft.Json dependency ## [2.5.0] - 2022-06-17 - Add Telegram From 297eb282f4c094144d39e9d7002e2b20cbce1d4e Mon Sep 17 00:00:00 2001 From: Enes Keric Date: Tue, 12 Jul 2022 14:22:09 +0200 Subject: [PATCH 08/36] Introduce unit tests --- CM.Text.Tests/BusinessMessagingApiTests.cs | 34 ++++++++++++++++++++++ CM.Text.Tests/CM.Text.Tests.csproj | 23 +++++++++++++++ CM.Text.Tests/Usings.cs | 1 + CM.Text.sln | 10 +++++-- CM.Text/BusinessMessaging/Model/Channel.cs | 2 ++ CM.Text/BusinessMessaging/Model/Message.cs | 1 - CM.Text/BusinessMessaging/Model/Request.cs | 15 ++++++---- CM.Text/CM.Text.csproj | 6 ++++ 8 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 CM.Text.Tests/BusinessMessagingApiTests.cs create mode 100644 CM.Text.Tests/CM.Text.Tests.csproj create mode 100644 CM.Text.Tests/Usings.cs diff --git a/CM.Text.Tests/BusinessMessagingApiTests.cs b/CM.Text.Tests/BusinessMessagingApiTests.cs new file mode 100644 index 0000000..60b9d5e --- /dev/null +++ b/CM.Text.Tests/BusinessMessagingApiTests.cs @@ -0,0 +1,34 @@ +using System.Text.Json; +using CM.Text.BusinessMessaging; +using CM.Text.BusinessMessaging.Model; +using FluentAssertions; + +namespace CM.Text.Tests +{ + [TestClass] + public class BusinessMessagingApiTests + { + [TestMethod] + public void TestPostBody() + { + var guid = Guid.NewGuid(); + var message = "This is a unit test"; + var sender = "CM.com"; + var reference = "ReferenceForMeToFind"; + var number1 = "0031612345678"; + var number2 = "0031612345679"; + + var data = BusinessMessagingApi.GetHttpPostBody(guid, message, sender, + new[] {number1, number2}, reference); + + data.Should().NotBeNull(); + //Simple to check if all values survived our logic + data.Should().Contain(guid.ToString()); + data.Should().Contain(message); + data.Should().Contain(sender); + data.Should().Contain(reference); + data.Should().Contain(number1); + data.Should().Contain(number2); + } + } +} diff --git a/CM.Text.Tests/CM.Text.Tests.csproj b/CM.Text.Tests/CM.Text.Tests.csproj new file mode 100644 index 0000000..218649b --- /dev/null +++ b/CM.Text.Tests/CM.Text.Tests.csproj @@ -0,0 +1,23 @@ + + + + net6.0 + enable + enable + + false + + + + + + + + + + + + + + + diff --git a/CM.Text.Tests/Usings.cs b/CM.Text.Tests/Usings.cs new file mode 100644 index 0000000..ab67c7e --- /dev/null +++ b/CM.Text.Tests/Usings.cs @@ -0,0 +1 @@ +global using Microsoft.VisualStudio.TestTools.UnitTesting; \ No newline at end of file diff --git a/CM.Text.sln b/CM.Text.sln index ccd39fc..0d0b721 100644 --- a/CM.Text.sln +++ b/CM.Text.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29102.190 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32616.157 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CM.Text", "CM.Text\CM.Text.csproj", "{1EB6D5AC-4759-4A77-8D9D-F5B23C254B7A}" EndProject @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CM.Text.Tests", "CM.Text.Tests\CM.Text.Tests.csproj", "{5389A890-EBC2-45F0-95E3-374B0BD239FF}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -22,6 +24,10 @@ Global {1EB6D5AC-4759-4A77-8D9D-F5B23C254B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {1EB6D5AC-4759-4A77-8D9D-F5B23C254B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU {1EB6D5AC-4759-4A77-8D9D-F5B23C254B7A}.Release|Any CPU.Build.0 = Release|Any CPU + {5389A890-EBC2-45F0-95E3-374B0BD239FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5389A890-EBC2-45F0-95E3-374B0BD239FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5389A890-EBC2-45F0-95E3-374B0BD239FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5389A890-EBC2-45F0-95E3-374B0BD239FF}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CM.Text/BusinessMessaging/Model/Channel.cs b/CM.Text/BusinessMessaging/Model/Channel.cs index a5d4b8e..ddd05ad 100644 --- a/CM.Text/BusinessMessaging/Model/Channel.cs +++ b/CM.Text/BusinessMessaging/Model/Channel.cs @@ -1,5 +1,6 @@ using System; using System.Runtime.Serialization; +using System.Text.Json.Serialization; using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model @@ -12,6 +13,7 @@ namespace CM.Text.BusinessMessaging.Model /// For those flows to work, we need to be contacted. /// [PublicAPI] + [JsonConverter(typeof(JsonStringEnumConverter))] public enum Channel { /// diff --git a/CM.Text/BusinessMessaging/Model/Message.cs b/CM.Text/BusinessMessaging/Model/Message.cs index 3de2e48..ccb49c8 100644 --- a/CM.Text/BusinessMessaging/Model/Message.cs +++ b/CM.Text/BusinessMessaging/Model/Message.cs @@ -22,7 +22,6 @@ public class Message /// [JsonPropertyName("allowedChannels")] [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] - [JsonConverter(typeof(JsonStringEnumConverter))] public Channel[] AllowedChannels { get; set; } /// diff --git a/CM.Text/BusinessMessaging/Model/Request.cs b/CM.Text/BusinessMessaging/Model/Request.cs index 263af11..2b13396 100644 --- a/CM.Text/BusinessMessaging/Model/Request.cs +++ b/CM.Text/BusinessMessaging/Model/Request.cs @@ -1,22 +1,25 @@ using System.Text.Json.Serialization; namespace CM.Text.BusinessMessaging.Model +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member { - internal static class Request + public class Request { - internal class MessagesEnvelope + public class MessagesEnvelope { [JsonPropertyName("authentication")] - internal Authentication Authentication { get; set; } + [JsonInclude] + public Authentication Authentication { get; set; } [JsonPropertyName("msg")] - internal Message[] Messages { get; set; } + public Message[] Messages { get; set; } } - internal class Authentication + public class Authentication { [JsonPropertyName("producttoken")] - internal string ProductToken { get; set; } + public string ProductToken { get; set; } +#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member } } } diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 0dbe4b5..fd65700 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -29,6 +29,12 @@ True + + + <_Parameter1>CM.Text.Tests + + + From 7c577ae53caecba34191c7cd0b7725642bd1330f Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 24 Aug 2022 18:49:47 +0200 Subject: [PATCH 09/36] Create validate.yml --- .github/workflows/validate.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..9f7300b --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,23 @@ +name: .NET build & tests + +on: + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From d7bbf5baaaf8ad0ecee7bc36e28cecec8f706b83 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 24 Aug 2022 19:00:17 +0200 Subject: [PATCH 10/36] Move some files around and multitarget --- CHANGELOG.md | 3 ++- .../BusinessMessagingApiTests.cs | 4 +--- .../CM.Text.NET6.Tests.csproj | 0 {CM.Text.Tests => CM.Text.NET6.Tests}/Usings.cs | 0 CM.Text.sln | 2 +- CM.Text/CM.Text.csproj | 17 +++++++++-------- 6 files changed, 13 insertions(+), 13 deletions(-) rename {CM.Text.Tests => CM.Text.NET6.Tests}/BusinessMessagingApiTests.cs (90%) rename CM.Text.Tests/CM.Text.Tests.csproj => CM.Text.NET6.Tests/CM.Text.NET6.Tests.csproj (100%) rename {CM.Text.Tests => CM.Text.NET6.Tests}/Usings.cs (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1709ea9..04252b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - System.Text.Json, replaces Newtsonsoft, possibly breaking - Add Telegram as tag for the project +- Multi target to .NET 6 and use .NET 6 included System.Text.Json ### Changed -- Enable Treat Warnings as Errors to adhere to code guidelines +- Enable "Treat Warnings as Errors" to adhere to code guidelines ### Removed - Newtsonsoft.Json dependency diff --git a/CM.Text.Tests/BusinessMessagingApiTests.cs b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs similarity index 90% rename from CM.Text.Tests/BusinessMessagingApiTests.cs rename to CM.Text.NET6.Tests/BusinessMessagingApiTests.cs index 60b9d5e..b2768bf 100644 --- a/CM.Text.Tests/BusinessMessagingApiTests.cs +++ b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs @@ -1,6 +1,4 @@ -using System.Text.Json; -using CM.Text.BusinessMessaging; -using CM.Text.BusinessMessaging.Model; +using CM.Text.BusinessMessaging; using FluentAssertions; namespace CM.Text.Tests diff --git a/CM.Text.Tests/CM.Text.Tests.csproj b/CM.Text.NET6.Tests/CM.Text.NET6.Tests.csproj similarity index 100% rename from CM.Text.Tests/CM.Text.Tests.csproj rename to CM.Text.NET6.Tests/CM.Text.NET6.Tests.csproj diff --git a/CM.Text.Tests/Usings.cs b/CM.Text.NET6.Tests/Usings.cs similarity index 100% rename from CM.Text.Tests/Usings.cs rename to CM.Text.NET6.Tests/Usings.cs diff --git a/CM.Text.sln b/CM.Text.sln index 0d0b721..3e19f91 100644 --- a/CM.Text.sln +++ b/CM.Text.sln @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CM.Text.Tests", "CM.Text.Tests\CM.Text.Tests.csproj", "{5389A890-EBC2-45F0-95E3-374B0BD239FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CM.Text.NET6.Tests", "CM.Text.NET6.Tests\CM.Text.NET6.Tests.csproj", "{5389A890-EBC2-45F0-95E3-374B0BD239FF}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index fd65700..1404fda 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -1,7 +1,7 @@  - netstandard2.0 + netstandard2.0;net6.0 CM Text CM.com CM Text SDK @@ -9,7 +9,7 @@ messaging, text, sms, email, push, whatsapp, viber, wechat, rcs, voice, business messaging, telegram, conversational, sms chat, chat, sms 2.0, rbm, mms, rich sms, rich communication services, telegram https://github.com/cmdotcom/text-sdk-dotnet Github - 2020 CM.com + 2022 CM.com https://mit-license.org See CHANGELOG.md for details 2.5.1 @@ -29,13 +29,14 @@ True - - - <_Parameter1>CM.Text.Tests - - - + + <_Parameter1>CM.Text.NET6.Tests + + + + + From ce1b7a1286fd8f3c15cf760f5b0826c20e6935a1 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 7 Sep 2022 15:01:03 +0200 Subject: [PATCH 11/36] Change to new CM documentation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9062aef..4644915 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # CM Text SDK A software development kit to provide ways to interact with CM.com's Text service. API's used: -- [Business Messaging](https://www.cm.com/en-en/app/docs/api/business-messaging-api/1.0/index) +- [Business Messaging](https://developers.cm.com/messaging/docs) # Usage From 6bf89104aa682e809498815fe4307ad3f62fbaac Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:45:15 +0200 Subject: [PATCH 12/36] Set warning levels --- CM.Text/CM.Text.csproj | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 1404fda..e04a135 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -29,6 +29,22 @@ True + + 9999 + + + + 9999 + + + + 9999 + + + + 9999 + + <_Parameter1>CM.Text.NET6.Tests From 545b79519866b684628c9f1f4f493f8114ede840 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 8 Sep 2022 08:47:57 +0200 Subject: [PATCH 13/36] Move some constants --- CM.Text/BusinessMessaging/BusinessMessagingApi.cs | 8 -------- CM.Text/BusinessMessaging/MessageBuilder.cs | 2 +- CM.Text/Common/Constant.cs | 10 +++++++--- CM.Text/TextClient.cs | 9 +++++---- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs index b47a4dd..d585801 100644 --- a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs +++ b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs @@ -75,13 +75,5 @@ internal static TextClientResult GetTextApiResult(string requestResultContent) .ToArray() }; } - internal static class Constant - { - internal const string BusinessMessagingGatewayJsonEndpoint = "https://gw.cmtelecom.com/v1.0/message"; - internal const string BusinessMessagingGatewayMediaTypeJson = "application/json"; - internal const string BusinessMessagingBodyTypeAuto = "AUTO"; - internal const int BusinessMessagingMessagePartsMinDefault = 1; - internal const int BusinessMessagingMessagePartsMaxDefault = 8; - } } } diff --git a/CM.Text/BusinessMessaging/MessageBuilder.cs b/CM.Text/BusinessMessaging/MessageBuilder.cs index c8afd60..61939c8 100644 --- a/CM.Text/BusinessMessaging/MessageBuilder.cs +++ b/CM.Text/BusinessMessaging/MessageBuilder.cs @@ -29,7 +29,7 @@ public MessageBuilder(string messageText, string from, params string[] to) Body = new Body { Content = messageText, - Type = BusinessMessagingApi.Constant.BusinessMessagingBodyTypeAuto + Type = Constant.BusinessMessagingBodyTypeAuto }, Recipients = to.Select(toEntry => new Recipient { Number = toEntry }) .ToArray(), diff --git a/CM.Text/Common/Constant.cs b/CM.Text/Common/Constant.cs index a7c8548..fd757f3 100644 --- a/CM.Text/Common/Constant.cs +++ b/CM.Text/Common/Constant.cs @@ -2,8 +2,12 @@ { internal static class Constant { - internal static readonly string TextSdkReference = "text-sdk-dotnet-" + - typeof(TextClient).Assembly.GetName() - .Version; + internal static readonly string TextSdkReference = $"text-sdk-dotnet-{typeof(TextClient).Assembly.GetName().Version}"; + + internal static readonly string BusinessMessagingGatewayJsonEndpoint = "http://gateway.staging.messaging.cmgroep.local/v1.0/message"; + internal static readonly string BusinessMessagingGatewayMediaTypeJson = "application/json"; + internal static readonly string BusinessMessagingBodyTypeAuto = "AUTO"; + internal static readonly int BusinessMessagingMessagePartsMinDefault = 1; + internal static readonly int BusinessMessagingMessagePartsMaxDefault = 8; } } diff --git a/CM.Text/TextClient.cs b/CM.Text/TextClient.cs index 6e6b9a2..f5fe137 100644 --- a/CM.Text/TextClient.cs +++ b/CM.Text/TextClient.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using CM.Text.BusinessMessaging; using CM.Text.BusinessMessaging.Model; +using CM.Text.Common; using JetBrains.Annotations; namespace CM.Text @@ -120,13 +121,13 @@ public async Task SendMessageAsync( { using (var request = new HttpRequestMessage( HttpMethod.Post, - this._endPointOverride ?? new Uri(BusinessMessagingApi.Constant.BusinessMessagingGatewayJsonEndpoint) + this._endPointOverride ?? new Uri(Constant.BusinessMessagingGatewayJsonEndpoint) )) { request.Content = new StringContent( BusinessMessagingApi.GetHttpPostBody(this._apiKey, messageText, from, to, reference), Encoding.UTF8, - BusinessMessagingApi.Constant.BusinessMessagingGatewayMediaTypeJson + Constant.BusinessMessagingGatewayMediaTypeJson ); using (var requestResult = await this._httpClient.SendAsync(request, cancellationToken) @@ -155,13 +156,13 @@ public async Task SendMessageAsync( { using (var request = new HttpRequestMessage( HttpMethod.Post, - this._endPointOverride ?? new Uri(BusinessMessagingApi.Constant.BusinessMessagingGatewayJsonEndpoint) + this._endPointOverride ?? new Uri(Constant.BusinessMessagingGatewayJsonEndpoint) )) { request.Content = new StringContent( BusinessMessagingApi.GetHttpPostBody(this._apiKey, message), Encoding.UTF8, - BusinessMessagingApi.Constant.BusinessMessagingGatewayMediaTypeJson + Constant.BusinessMessagingGatewayMediaTypeJson ); using (var requestResult = await this._httpClient.SendAsync(request, cancellationToken) From e6b748262a6dbfae1a57eeb07e82ae4de92f5ae8 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 8 Sep 2022 14:09:37 +0200 Subject: [PATCH 14/36] Update BusinessMessagingApiTests.cs --- .../BusinessMessagingApiTests.cs | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs index b2768bf..65e199d 100644 --- a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs +++ b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs @@ -1,7 +1,7 @@ using CM.Text.BusinessMessaging; using FluentAssertions; -namespace CM.Text.Tests +namespace CM.Text.NET6.Tests { [TestClass] public class BusinessMessagingApiTests @@ -28,5 +28,24 @@ public void TestPostBody() data.Should().Contain(number1); data.Should().Contain(number2); } + + + [TestMethod] + public void TestResponseBody() + { + var guid = Guid.NewGuid(); + var message = "{\r\n \"details\": \"Created 1 message(s)\",\r\n \"errorCode\": 0,\r\n \"messages\": [\r\n {\r\n \"to\": \"0031612345678\",\r\n \"status\": \"Accepted\",\r\n \"reference\": \"test-reference-1\",\r\n \"parts\": 1,\r\n \"messageDetails\": null,\r\n \"messageErrorCode\": 0\r\n }\r\n ]\r\n}"; + + var data = BusinessMessagingApi.GetTextApiResult(message); + + data.Should().NotBeNull(); + //Simple to check if all values survived our logic + data.details.Should().NotBeNull(); + data.details.First().reference.Should().Be("test-reference-1"); + data.details.First().status.Should().Be("Accepted"); + data.details.First().to.Should().Be("0031612345678"); + data.details.First().parts.Should().Be(1); + data.details.First().details.Should().BeNull(); + } } } From ace17bbf5cf3711a3e8086b4c7e4101c228f706e Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:06:46 +0200 Subject: [PATCH 15/36] Upgrade to 6.0.6 --- CM.Text/CM.Text.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 21f3b82..f418158 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -1,4 +1,4 @@ - + netstandard2.0;net6.0 @@ -52,7 +52,7 @@ - + From 8535020392450bb1e409588d8747dc432e91dbd8 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:25:06 +0200 Subject: [PATCH 16/36] Make private models public with some comments --- .../BusinessMessaging/BusinessMessagingApi.cs | 2 +- .../Model/HttpResponseBody.cs | 29 ++++++++++++ CM.Text/BusinessMessaging/Model/Response.cs | 42 ----------------- .../Model/ResponseMessageDetail.cs | 46 +++++++++++++++++++ 4 files changed, 76 insertions(+), 43 deletions(-) create mode 100644 CM.Text/BusinessMessaging/Model/HttpResponseBody.cs delete mode 100644 CM.Text/BusinessMessaging/Model/Response.cs create mode 100644 CM.Text/BusinessMessaging/Model/ResponseMessageDetail.cs diff --git a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs index d585801..1cdc7ec 100644 --- a/CM.Text/BusinessMessaging/BusinessMessagingApi.cs +++ b/CM.Text/BusinessMessaging/BusinessMessagingApi.cs @@ -56,7 +56,7 @@ internal static string GetHttpPostBody(Guid apiKey, Message message) /// internal static TextClientResult GetTextApiResult(string requestResultContent) { - var deserializedResponse = JsonSerializer.Deserialize(requestResultContent); + var deserializedResponse = JsonSerializer.Deserialize(requestResultContent); return new TextClientResult { diff --git a/CM.Text/BusinessMessaging/Model/HttpResponseBody.cs b/CM.Text/BusinessMessaging/Model/HttpResponseBody.cs new file mode 100644 index 0000000..2abfcac --- /dev/null +++ b/CM.Text/BusinessMessaging/Model/HttpResponseBody.cs @@ -0,0 +1,29 @@ +using System.Text.Json.Serialization; + +namespace CM.Text.BusinessMessaging.Model +{ + + /// + /// CM Messaging API response body containing API related info + /// + public class HttpResponseBody + { + /// + /// API Request details + /// + [JsonInclude] + public string details { get; private set; } + + /// + /// JSON POST Error codes. Full description of each code available in the development documentation + /// + [JsonInclude] + public int errorCode { get; private set; } + + /// + /// Each message that was sent in the original request + /// + [JsonInclude] + public ResponseMessageDetail[] messages { get; private set; } + } +} diff --git a/CM.Text/BusinessMessaging/Model/Response.cs b/CM.Text/BusinessMessaging/Model/Response.cs deleted file mode 100644 index f92493f..0000000 --- a/CM.Text/BusinessMessaging/Model/Response.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Text.Json.Serialization; - -namespace CM.Text.BusinessMessaging.Model -{ - [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Json interface")] - internal static class Response - { - internal class HttpResponseBody - { - [JsonInclude] - internal string details { get; set; } - - [JsonInclude] - internal int errorCode { get; set; } - - [JsonInclude] - internal ResponseMessageDetail[] messages { get; set; } - } - - internal class ResponseMessageDetail - { - [JsonInclude] - internal string messageDetails { get; set; } - - [JsonInclude] - internal string messageErrorCode { get; set; } - - [JsonInclude] - internal int parts { get; set; } - - [JsonInclude] - internal string reference { get; set; } - - [JsonInclude] - internal string status { get; set; } - - [JsonInclude] - internal string to { get; set; } - } - } -} diff --git a/CM.Text/BusinessMessaging/Model/ResponseMessageDetail.cs b/CM.Text/BusinessMessaging/Model/ResponseMessageDetail.cs new file mode 100644 index 0000000..b10613e --- /dev/null +++ b/CM.Text/BusinessMessaging/Model/ResponseMessageDetail.cs @@ -0,0 +1,46 @@ +using System.Text.Json.Serialization; + +namespace CM.Text.BusinessMessaging.Model +{ + /// + /// CM Messaging API response containing message related info + /// + public class ResponseMessageDetail + { + /// + /// Description of this message + /// + [JsonInclude] + public string messageDetails { get; private set; } + + /// + /// Error code specific to this message. + /// + [JsonInclude] + public int messageErrorCode { get; private set; } + + /// + /// How many parts this message was split in + /// + [JsonInclude] + public int parts { get; private set; } + + /// + /// The external reference sent to identify this message + /// + [JsonInclude] + public string reference { get; private set; } + + /// + /// Status of the message + /// + [JsonInclude] + public string status { get; private set; } + + /// + /// Recipient of this message + /// + [JsonInclude] + public string to { get; private set; } + } +} From 85836c3ac9ad95cf8d5c0c5d05935927201c8e89 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Wed, 12 Oct 2022 22:26:55 +0200 Subject: [PATCH 17/36] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24c9592..b9ce768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Multi target to .NET 6 and use .NET 6 included System.Text.Json ### Changed - Enable "Treat Warnings as Errors" to adhere to code guidelines +- Give internal response body messagerrorcode the correct type ### Removed - Newtsonsoft.Json dependency From 87d44793eb88158a9d2228bb8829681d75b1e00b Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 08:44:57 +0200 Subject: [PATCH 18/36] Update CM.Text.csproj --- CM.Text/CM.Text.csproj | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index f418158..83cbc36 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -44,12 +44,10 @@ 9999 - - - - <_Parameter1>CM.Text.NET6.Tests - - + + + + From f08ed17a58225e1c2dac3a34495ba611c70ca9a2 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 08:46:26 +0200 Subject: [PATCH 19/36] Update Constant.cs --- CM.Text/Common/Constant.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CM.Text/Common/Constant.cs b/CM.Text/Common/Constant.cs index fd757f3..14e53d2 100644 --- a/CM.Text/Common/Constant.cs +++ b/CM.Text/Common/Constant.cs @@ -4,7 +4,7 @@ internal static class Constant { internal static readonly string TextSdkReference = $"text-sdk-dotnet-{typeof(TextClient).Assembly.GetName().Version}"; - internal static readonly string BusinessMessagingGatewayJsonEndpoint = "http://gateway.staging.messaging.cmgroep.local/v1.0/message"; + internal const string BusinessMessagingGatewayJsonEndpoint = "https://gw.cmtelecom.com/v1.0/message"; internal static readonly string BusinessMessagingGatewayMediaTypeJson = "application/json"; internal static readonly string BusinessMessagingBodyTypeAuto = "AUTO"; internal static readonly int BusinessMessagingMessagePartsMinDefault = 1; From aac1a6ffc10b54d70d9c918202da809ea25ea134 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:02:53 +0200 Subject: [PATCH 20/36] Read changelog in csproj --- CM.Text.sln | 12 +++++++++++- CHANGELOG.md => CM.Text/CHANGELOG.md | 1 + CM.Text/CM.Text.csproj | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) rename CHANGELOG.md => CM.Text/CHANGELOG.md (99%) diff --git a/CM.Text.sln b/CM.Text.sln index 3e19f91..e84701e 100644 --- a/CM.Text.sln +++ b/CM.Text.sln @@ -8,12 +8,19 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C893F008-8E43-4C38-ABF4-FA88F5549906}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - CHANGELOG.md = CHANGELOG.md + CM.Text\CHANGELOG.md = CM.Text\CHANGELOG.md README.md = README.md EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CM.Text.NET6.Tests", "CM.Text.NET6.Tests\CM.Text.NET6.Tests.csproj", "{5389A890-EBC2-45F0-95E3-374B0BD239FF}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{8AC75C4D-CF2F-4E5F-85D2-4BB92C8ED1DE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{83568C54-6C9B-4579-BC2A-E6739DE072D5}" + ProjectSection(SolutionItems) = preProject + .github\workflows\validate.yml = .github\workflows\validate.yml + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -32,6 +39,9 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {83568C54-6C9B-4579-BC2A-E6739DE072D5} = {8AC75C4D-CF2F-4E5F-85D2-4BB92C8ED1DE} + EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {33F57A4C-CDF2-44F4-8F81-45D5C71E3DE1} EndGlobalSection diff --git a/CHANGELOG.md b/CM.Text/CHANGELOG.md similarity index 99% rename from CHANGELOG.md rename to CM.Text/CHANGELOG.md index b9ce768..322d7b4 100644 --- a/CHANGELOG.md +++ b/CM.Text/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Enable "Treat Warnings as Errors" to adhere to code guidelines - Give internal response body messagerrorcode the correct type +- Some internal refactoring ### Removed - Newtsonsoft.Json dependency diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 83cbc36..7196020 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -10,8 +10,8 @@ https://github.com/cmdotcom/text-sdk-dotnet Github 2022 CM.com + $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/CHANGELOG.md")) https://mit-license.org - See CHANGELOG.md for details 2.5.1 http://static.cmtelecom.com/images/cm-nuget.png https://github.com/cmdotcom/text-sdk-dotnet @@ -53,4 +53,10 @@ + + + PreserveNewest + + + From 259e5c4939dcef0bc4cc53339e929b33c0a5dee9 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:15:10 +0200 Subject: [PATCH 21/36] Update icon url to https version --- CM.Text/CM.Text.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 7196020..321bf21 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -13,7 +13,7 @@ $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/CHANGELOG.md")) https://mit-license.org 2.5.1 - http://static.cmtelecom.com/images/cm-nuget.png + https://static.cmtelecom.com/images/cm-nuget.png https://github.com/cmdotcom/text-sdk-dotnet en true From d7faf7935aeb8310f6ce0ddc6e2aad3c0ec24ff9 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:17:02 +0200 Subject: [PATCH 22/36] Move changelog back --- CM.Text/CHANGELOG.md => CHANGELOG.md | 0 CM.Text/CM.Text.csproj | 8 +------- 2 files changed, 1 insertion(+), 7 deletions(-) rename CM.Text/CHANGELOG.md => CHANGELOG.md (100%) diff --git a/CM.Text/CHANGELOG.md b/CHANGELOG.md similarity index 100% rename from CM.Text/CHANGELOG.md rename to CHANGELOG.md diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 321bf21..236c230 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -10,7 +10,7 @@ https://github.com/cmdotcom/text-sdk-dotnet Github 2022 CM.com - $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/CHANGELOG.md")) + $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) https://mit-license.org 2.5.1 https://static.cmtelecom.com/images/cm-nuget.png @@ -53,10 +53,4 @@ - - - PreserveNewest - - - From 8d711c5fc8619231185ab92ae92219b0803295b8 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Thu, 13 Oct 2022 09:19:40 +0200 Subject: [PATCH 23/36] Paths --- CM.Text.sln | 2 +- CM.Text/CM.Text.csproj | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CM.Text.sln b/CM.Text.sln index e84701e..226b6fe 100644 --- a/CM.Text.sln +++ b/CM.Text.sln @@ -8,7 +8,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C893F008-8E43-4C38-ABF4-FA88F5549906}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig - CM.Text\CHANGELOG.md = CM.Text\CHANGELOG.md + CHANGELOG.md = CHANGELOG.md README.md = README.md EndProjectSection EndProject diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 236c230..766832f 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -53,4 +53,10 @@ + + + PreserveNewest + + + From b52ac7aa30f1ccebca71074dcabe405e6ff04eb4 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:51:12 +0200 Subject: [PATCH 24/36] Update validate.yml --- .github/workflows/validate.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9f7300b..1f64e71 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,6 +1,8 @@ name: .NET build & tests on: + push: + branches: [ "master" ] pull_request: branches: [ "master" ] From 23103fe1045dc2dc07c65c4d1a0ba9c6458fd2eb Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:56:37 +0200 Subject: [PATCH 25/36] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4644915..bd53d2b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # CM Text SDK A software development kit to provide ways to interact with CM.com's Text service. API's used: -- [Business Messaging](https://developers.cm.com/messaging/docs) +- [Messaging](https://developers.cm.com/messaging/docs) # Usage From ab9f220859632383ddbfae6393aeabc65dddd409 Mon Sep 17 00:00:00 2001 From: Enes <9263360+EnessenE@users.noreply.github.com> Date: Fri, 14 Oct 2022 16:37:17 +0200 Subject: [PATCH 26/36] Delete validate.yml --- .github/workflows/validate.yml | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 .github/workflows/validate.yml diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml deleted file mode 100644 index 1f64e71..0000000 --- a/.github/workflows/validate.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: .NET build & tests - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Setup .NET - uses: actions/setup-dotnet@v2 - with: - dotnet-version: 6.0.x - - name: Restore dependencies - run: dotnet restore - - name: Build - run: dotnet build --no-restore - - name: Test - run: dotnet test --no-build --verbosity normal From a9a320432f6387407f202c3a05e695d59e3b1ae1 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:48:22 +0200 Subject: [PATCH 27/36] Package icon and licenses updates --- CHANGELOG.md | 1 + CM.Text/CM.Text.csproj | 10 +++++++--- icon.png | Bin 0 -> 7115 bytes 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 icon.png diff --git a/CHANGELOG.md b/CHANGELOG.md index a7ec614..672daa6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enable "Treat Warnings as Errors" to adhere to code guidelines - Give internal response body messagerrorcode the correct type - Some internal refactoring +- Changed PackageIconUrl > PackageIcon and added icon manually as it PackageIconUrl was deprecated ### Removed - Newtsonsoft.Json dependency diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 75ca550..ad40ef2 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -9,11 +9,11 @@ messaging, text, sms, email, push, whatsapp, viber, wechat, rcs, voice, business messaging, telegram, conversational, sms chat, chat, sms 2.0, rbm, mms, rich sms, rich communication services, telegram https://github.com/cmdotcom/text-sdk-dotnet Github - 2022 CM.com - https://mit-license.org + $([System.DateTime]::UtcNow.Year) CM.com + LICENSE + icon.png $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) 2.5.2 - http://static.cmtelecom.com/images/cm-nuget.png https://github.com/cmdotcom/text-sdk-dotnet en true @@ -58,6 +58,10 @@ PreserveNewest + + + + diff --git a/icon.png b/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b05878f58867e9e3cd3d8864e3036e394ea55645 GIT binary patch literal 7115 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 CMGS!e literal 0 HcmV?d00001 From ce11e3822ec902ca1b3a9d038ae9d583b5910678 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:02:32 +0200 Subject: [PATCH 28/36] Split interface --- CM.Text/CM.Text.csproj | 2 +- CM.Text/Interfaces/ITextClient.cs | 60 +++++++++++++++++++++++++++++++ CM.Text/TextClient.cs | 53 +-------------------------- CM.Text/TextClientFactory.cs | 1 + 4 files changed, 63 insertions(+), 53 deletions(-) create mode 100644 CM.Text/Interfaces/ITextClient.cs diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index ad40ef2..b4281cf 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -5,7 +5,7 @@ CM Text CM.com CM Text SDK - A software development kit to provide ways to interact with CM.com's Text service. + A software development kit to provide ways to interact with CM.com's Text/messaging service. messaging, text, sms, email, push, whatsapp, viber, wechat, rcs, voice, business messaging, telegram, conversational, sms chat, chat, sms 2.0, rbm, mms, rich sms, rich communication services, telegram https://github.com/cmdotcom/text-sdk-dotnet Github diff --git a/CM.Text/Interfaces/ITextClient.cs b/CM.Text/Interfaces/ITextClient.cs new file mode 100644 index 0000000..9c53ca6 --- /dev/null +++ b/CM.Text/Interfaces/ITextClient.cs @@ -0,0 +1,60 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using CM.Text.BusinessMessaging.Model; +using JetBrains.Annotations; + +namespace CM.Text.Interfaces +{ + /// + /// Interface to the client to send text messages. + /// + public interface ITextClient + { + /// + /// Sends a message asynchronous. + /// + /// The message text. + /// + /// This is the sender name. The maximum length is 11 alphanumerical characters or 16 digits. Example: 'MyCompany'.
+ /// For Twitter: use the Twitter Snowflake ID of the account you want to use as sender.
+ /// For MobilePush: use the app key of the account you want to use as sender.
+ /// For Facebook Messenger: use the Facebook Page ID of the account you want to use as sender.
+ /// For Google Business Messages: use the Google Business Messages agent ID of the account you want to use as sender (without dashes).
+ /// For Instagram: use the Instagram Account ID of the account you want to use as sender.
+ /// For Telegram: use the Telegram Bot ID of the account you want to use as sender. + /// + /// + /// These are the destination mobile numbers. Restrictions: this value should be in international format. + /// Example: '00447911123456'.
+ /// For Twitter: use the Twitter Snowflake ID.
+ /// For Facebook Messenger: use the Facebook Page Scoped User ID (PSID).
+ /// For Google Business Messages: use the Google Business Messages conversation ID (without dashes).
+ /// For Instagram: use the Instagram Scoped User ID (IGSID).
+ /// For Telegram: use the Telegram Chat ID. + /// + /// + /// Here you can include your message reference. This information will be returned in a status + /// report so you can match the message and it's status. Restrictions: 1 - 32 alphanumeric characters and reference + /// will not work for demo accounts. + /// + /// The cancellation token. + /// + Task SendMessageAsync( + string messageText, + string from, + IEnumerable to, + [CanBeNull] string reference, + CancellationToken cancellationToken = default); + + /// + /// Sends a message asynchronous. + /// + /// The message to send. + /// The cancellation token. + /// + Task SendMessageAsync( + Message message, + CancellationToken cancellationToken = default); + } +} diff --git a/CM.Text/TextClient.cs b/CM.Text/TextClient.cs index f5fe137..a3afb47 100644 --- a/CM.Text/TextClient.cs +++ b/CM.Text/TextClient.cs @@ -8,62 +8,11 @@ using CM.Text.BusinessMessaging; using CM.Text.BusinessMessaging.Model; using CM.Text.Common; +using CM.Text.Interfaces; using JetBrains.Annotations; namespace CM.Text { - /// - /// Interface to the client to send text messages. - /// - public interface ITextClient - { - /// - /// Sends a message asynchronous. - /// - /// The message text. - /// - /// This is the sender name. The maximum length is 11 alphanumerical characters or 16 digits. Example: 'MyCompany'.
- /// For Twitter: use the Twitter Snowflake ID of the account you want to use as sender.
- /// For MobilePush: use the app key of the account you want to use as sender.
- /// For Facebook Messenger: use the Facebook Page ID of the account you want to use as sender.
- /// For Google Business Messages: use the Google Business Messages agent ID of the account you want to use as sender (without dashes).
- /// For Instagram: use the Instagram Account ID of the account you want to use as sender.
- /// For Telegram: use the Telegram Bot ID of the account you want to use as sender. - /// - /// - /// These are the destination mobile numbers. Restrictions: this value should be in international format. - /// Example: '00447911123456'.
- /// For Twitter: use the Twitter Snowflake ID.
- /// For Facebook Messenger: use the Facebook Page Scoped User ID (PSID).
- /// For Google Business Messages: use the Google Business Messages conversation ID (without dashes).
- /// For Instagram: use the Instagram Scoped User ID (IGSID).
- /// For Telegram: use the Telegram Chat ID. - /// - /// - /// Here you can include your message reference. This information will be returned in a status - /// report so you can match the message and it's status. Restrictions: 1 - 32 alphanumeric characters and reference - /// will not work for demo accounts. - /// - /// The cancellation token. - /// - Task SendMessageAsync( - string messageText, - string from, - IEnumerable to, - [CanBeNull] string reference, - CancellationToken cancellationToken = default(CancellationToken)); - - /// - /// Sends a message asynchronous. - /// - /// The message to send. - /// The cancellation token. - /// - Task SendMessageAsync( - Message message, - CancellationToken cancellationToken = default(CancellationToken)); - } - /// /// This class provides methods to send text messages. /// diff --git a/CM.Text/TextClientFactory.cs b/CM.Text/TextClientFactory.cs index c333e0b..028c429 100644 --- a/CM.Text/TextClientFactory.cs +++ b/CM.Text/TextClientFactory.cs @@ -1,5 +1,6 @@ using System; using System.Net.Http; +using CM.Text.Interfaces; using JetBrains.Annotations; namespace CM.Text From 1d1e9bf70d454a834fe3d1268a040131ebe345ed Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Mon, 17 Oct 2022 09:08:13 +0200 Subject: [PATCH 29/36] Link to new CM docs --- CM.Text/BusinessMessaging/MessageBuilder.cs | 2 +- CM.Text/BusinessMessaging/Model/Channel.cs | 2 +- CM.Text/BusinessMessaging/Model/Message.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CM.Text/BusinessMessaging/MessageBuilder.cs b/CM.Text/BusinessMessaging/MessageBuilder.cs index 61939c8..e3b6839 100644 --- a/CM.Text/BusinessMessaging/MessageBuilder.cs +++ b/CM.Text/BusinessMessaging/MessageBuilder.cs @@ -133,7 +133,7 @@ public MessageBuilder WithSuggestions(params SuggestionBase[] suggestions) } /// - /// Used for Hybrid messaging, see https://docs.cmtelecom.com/en/hybrid-messaging/v2.0.0 for more information + /// Used for Hybrid messaging, see https://developers.cm.com/messaging/docs for more information /// Messages will be sent over the channel. /// public MessageBuilder WitHybridAppKey(Guid appKey) diff --git a/CM.Text/BusinessMessaging/Model/Channel.cs b/CM.Text/BusinessMessaging/Model/Channel.cs index ddd05ad..4c65568 100644 --- a/CM.Text/BusinessMessaging/Model/Channel.cs +++ b/CM.Text/BusinessMessaging/Model/Channel.cs @@ -31,7 +31,7 @@ public enum Channel /// /// Sends messages to push using Hybrid messages. - /// See also https://docs.cmtelecom.com/en/hybrid-messaging/v2.0.0 + /// See also https://developers.cm.com/messaging/docs /// /// Works only when is set Push, diff --git a/CM.Text/BusinessMessaging/Model/Message.cs b/CM.Text/BusinessMessaging/Model/Message.cs index ccb49c8..76ca778 100644 --- a/CM.Text/BusinessMessaging/Model/Message.cs +++ b/CM.Text/BusinessMessaging/Model/Message.cs @@ -81,7 +81,7 @@ public class Message public string From { get; set; } /// - /// Used for Hybrid messaging, see https://docs.cmtelecom.com/en/hybrid-messaging/v2.0.0 for more information + /// Used for Hybrid messaging, see https://developers.cm.com/messaging/docs for more information /// Messages will be sent over the channel. /// [JsonPropertyName("appKey")] @@ -125,7 +125,7 @@ public class Message /// The given reference will be used in the status reports and MO replies for the message, /// so you can link the messages to the sent batch. /// For more information on status reports, see: - /// https://docs.cmtelecom.com/business-messaging/v1.0#/status_report_webhook + /// https://developers.cm.com/messaging/docs/incoming-status-report /// The given reference must be between 1 - 32 alphanumeric characters, and will not work using demo accounts. ///
[JsonPropertyName("reference")] @@ -146,7 +146,7 @@ public class Message /// or a relative offset. A message is considered failed if it was not successfully delivered before that time. /// And via a Status Report we inform you this was the case. /// For more information on status reports, see: - /// https://docs.cmtelecom.com/business-messaging/v1.0#/status_report_webhook + /// https://developers.cm.com/messaging/docs/incoming-status-report /// You can supply the time zone for the validity period using either of the following formats: /// /// Absolute date and time: From 65fc5f9e3f95e2d4c4720a19978d851face633f0 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Mon, 17 Oct 2022 11:26:17 +0200 Subject: [PATCH 30/36] Json Polymorphism support --- CHANGELOG.md | 1 + CM.Text.NET6.Tests/BuilderTests.cs | 40 +++++++++++++++++++ .../BusinessMessagingApiTests.cs | 33 +++++++++++++++ .../Model/MultiChannel/IRichMessage.cs | 12 +++++- CM.Text/CM.Text.csproj | 12 +++++- 5 files changed, 95 insertions(+), 3 deletions(-) create mode 100644 CM.Text.NET6.Tests/BuilderTests.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 672daa6..99a6bd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Give internal response body messagerrorcode the correct type - Some internal refactoring - Changed PackageIconUrl > PackageIcon and added icon manually as it PackageIconUrl was deprecated +- Change RichContent interface to support derived types ### Removed - Newtsonsoft.Json dependency diff --git a/CM.Text.NET6.Tests/BuilderTests.cs b/CM.Text.NET6.Tests/BuilderTests.cs new file mode 100644 index 0000000..3fa3399 --- /dev/null +++ b/CM.Text.NET6.Tests/BuilderTests.cs @@ -0,0 +1,40 @@ +using CM.Text.BusinessMessaging; +using CM.Text.BusinessMessaging.Model; +using CM.Text.BusinessMessaging.Model.MultiChannel; +using FluentAssertions; + +namespace CM.Text.NET6.Tests +{ + [TestClass] + public class BuilderTests + { + [TestMethod] + public void BuildTest() + { + var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber"); + + var mediaName = "cm.com"; + var mediaUri = "https://avatars3.githubusercontent.com/u/8234794?s=200&v=4"; + var mediaType = "image/png"; + + builder + .WithAllowedChannels(Channel.WhatsApp) + .WithRichMessage( + new MediaMessage( + mediaName, + mediaUri, + mediaType + ) + ); + var message = builder.Build(); + + message.Should().NotBeNull(); + message.RichContent.Conversation.Should().NotBeNull(); + message.RichContent.Conversation.Length.Should().Be(1); + var media = (MediaMessage) message.RichContent.Conversation.First(); + media.Media.MediaName.Should().Be(mediaName); + media.Media.MediaUri.Should().Be(mediaUri); + media.Media.MimeType.Should().Be(mediaType); + } + } +} diff --git a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs index 65e199d..903e5ea 100644 --- a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs +++ b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs @@ -1,4 +1,6 @@ using CM.Text.BusinessMessaging; +using CM.Text.BusinessMessaging.Model; +using CM.Text.BusinessMessaging.Model.MultiChannel; using FluentAssertions; namespace CM.Text.NET6.Tests @@ -29,6 +31,37 @@ public void TestPostBody() data.Should().Contain(number2); } + [TestMethod] + public void TestRichPostBody() + { + var builder = new MessageBuilder("Message Text", "Sender_name", "Recipient_PhoneNumber"); + + var mediaName = "cm.com icon"; + var mediaUri = "https://avatars3.githubusercontent.com/u/8234794"; + var mediaType = "image/png"; + + builder + .WithAllowedChannels(Channel.WhatsApp) + .WithRichMessage( + new MediaMessage( + mediaName, + mediaUri, + mediaType + ) + ); + var message = builder.Build(); + + Guid fakeApiKey = Guid.NewGuid(); + var data = BusinessMessagingApi.GetHttpPostBody(fakeApiKey, message); + + data.Should().NotBeNull(); + //Simple to check if all values survived our logic + data.Should().Contain(fakeApiKey.ToString(), "the api key should be present in the body"); + data.Should().Contain(mediaName, "the media name needs to be sent"); + data.Should().Contain(mediaType, "the media type has to be sent"); + data.Should().Contain(mediaUri, "the media url has to be sent"); + } + [TestMethod] public void TestResponseBody() diff --git a/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs b/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs index 80a82e0..b773e05 100644 --- a/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs +++ b/CM.Text/BusinessMessaging/Model/MultiChannel/IRichMessage.cs @@ -1,11 +1,21 @@ -using JetBrains.Annotations; +using System.Text.Json.Serialization; +using JetBrains.Annotations; namespace CM.Text.BusinessMessaging.Model.MultiChannel { /// /// One element in a + /// Requires a json derived type for serialization to work /// [PublicAPI] + [JsonDerivedType(typeof(MediaMessage))] + [JsonDerivedType(typeof(ApplePayRequest))] + [JsonDerivedType(typeof(CarouselMessage))] + [JsonDerivedType(typeof(ContactMessage))] + [JsonDerivedType(typeof(LocationPushMessage))] + [JsonDerivedType(typeof(TemplateMessage))] + [JsonDerivedType(typeof(TextMessage))] + [JsonDerivedType(typeof(WhatsAppInteractiveMessage))] public interface IRichMessage { } diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index b4281cf..f92ef64 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -13,7 +13,7 @@ LICENSE icon.png $([System.IO.File]::ReadAllText("$(MSBuildProjectDirectory)/../CHANGELOG.md")) - 2.5.2 + 2.6.0-pre https://github.com/cmdotcom/text-sdk-dotnet en true @@ -32,18 +32,22 @@ 9999 + True 9999 + True 9999 + True 9999 + True @@ -51,7 +55,11 @@ - + + + + + From 528cb4b3c0793743add380eaa31906c540819db0 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Mon, 17 Oct 2022 11:26:48 +0200 Subject: [PATCH 31/36] Update CM.Text.csproj --- CM.Text/CM.Text.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index f92ef64..de40b76 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -33,6 +33,8 @@ 9999 True + 1701;1702; + From ed0f072cde44821bbc7964e4dbffade3c53f7135 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Mon, 17 Oct 2022 11:26:52 +0200 Subject: [PATCH 32/36] Update CM.Text.csproj --- CM.Text/CM.Text.csproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index de40b76..9303d9e 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -40,16 +40,22 @@ 9999 True + 1701;1702; + 9999 True + 1701;1702; + 9999 True + 1701;1702; + From fd02eee99f53c240a4f894bfc1068e0b96471f27 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Wed, 19 Oct 2022 14:08:29 +0200 Subject: [PATCH 33/36] Update BusinessMessagingApiTests.cs --- CM.Text.NET6.Tests/BusinessMessagingApiTests.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs index 903e5ea..be0833d 100644 --- a/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs +++ b/CM.Text.NET6.Tests/BusinessMessagingApiTests.cs @@ -67,7 +67,20 @@ public void TestRichPostBody() public void TestResponseBody() { var guid = Guid.NewGuid(); - var message = "{\r\n \"details\": \"Created 1 message(s)\",\r\n \"errorCode\": 0,\r\n \"messages\": [\r\n {\r\n \"to\": \"0031612345678\",\r\n \"status\": \"Accepted\",\r\n \"reference\": \"test-reference-1\",\r\n \"parts\": 1,\r\n \"messageDetails\": null,\r\n \"messageErrorCode\": 0\r\n }\r\n ]\r\n}"; + // Arrange + string message = @"{ + ""messages"": [{ + ""to"": ""0031612345678"", + ""parts"": 1, + ""status"": ""Accepted"", + ""reference"": ""test-reference-1"", + ""messageErrorCode"": 0, + ""messageDetails"": null + }], + ""details"": ""Created 1 message(s)"", + ""errorCode"": 0 + }"; + var data = BusinessMessagingApi.GetTextApiResult(message); From 822c97345daf100925e7236e18d394c4f1248166 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:26:41 +0100 Subject: [PATCH 34/36] 7.0 --- .github/workflows/main.yml | 2 +- .github/workflows/nuget.yml | 2 +- CM.Text.sln | 3 ++- CM.Text/CM.Text.csproj | 10 +++------- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f89077a..ef6de22 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index e09b4a9..07ab122 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -14,7 +14,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v3 with: - dotnet-version: 6.0.x + dotnet-version: 7.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/CM.Text.sln b/CM.Text.sln index 226b6fe..1bc20cb 100644 --- a/CM.Text.sln +++ b/CM.Text.sln @@ -18,7 +18,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{8AC7 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{83568C54-6C9B-4579-BC2A-E6739DE072D5}" ProjectSection(SolutionItems) = preProject - .github\workflows\validate.yml = .github\workflows\validate.yml + .github\workflows\main.yml = .github\workflows\main.yml + .github\workflows\nuget.yml = .github\workflows\nuget.yml EndProjectSection EndProject Global diff --git a/CM.Text/CM.Text.csproj b/CM.Text/CM.Text.csproj index 9303d9e..54db35c 100644 --- a/CM.Text/CM.Text.csproj +++ b/CM.Text/CM.Text.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0 + netstandard2.0;net7.0 CM Text CM.com CM Text SDK @@ -63,14 +63,10 @@ - - - - - + - + PreserveNewest From ab711dd90854e1a31f160c30e4559b89b9858a02 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Wed, 9 Nov 2022 10:38:51 +0100 Subject: [PATCH 35/36] Update pipes --- .github/workflows/main.yml | 4 +++- .github/workflows/nuget.yml | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef6de22..6313f0c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,9 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: 7.0.x + dotnet-version: | + 6.0.x + 7.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.github/workflows/nuget.yml b/.github/workflows/nuget.yml index 15b538c..4f10efd 100644 --- a/.github/workflows/nuget.yml +++ b/.github/workflows/nuget.yml @@ -13,8 +13,10 @@ jobs: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 - with: - dotnet-version: 7.0.x + with: + dotnet-version: | + 6.0.x + 7.0.x - name: Restore dependencies run: dotnet restore - name: Build From 77490569a5b12f9637d7d81bc30bd3796c47fc77 Mon Sep 17 00:00:00 2001 From: Enes Keric <9263360+EnessenE@users.noreply.github.com> Date: Wed, 9 Nov 2022 11:05:11 +0100 Subject: [PATCH 36/36] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 99a6bd6..07b7ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - System.Text.Json, replaces Newtsonsoft, possibly breaking - Add Telegram as tag for the project -- Multi target to .NET 6 and use .NET 6 included System.Text.Json +- Multi target to .NET 7 and use .NET 7 included System.Text.Json ### Changed - Enable "Treat Warnings as Errors" to adhere to code guidelines - Give internal response body messagerrorcode the correct type