From b37e25b8d0ad22d635809e4f81cae021177343cf Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Wed, 13 Sep 2023 13:02:33 +0530 Subject: [PATCH 1/3] feat: Added Enum file for contentType --- src/Twilio/EnumConstants.cs | 21 +++++++++++++++++++ .../Twilio.Test/Constant/EnumConstantsTest.cs | 20 ++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/Twilio/EnumConstants.cs create mode 100644 test/Twilio.Test/Constant/EnumConstantsTest.cs diff --git a/src/Twilio/EnumConstants.cs b/src/Twilio/EnumConstants.cs new file mode 100644 index 000000000..55b163127 --- /dev/null +++ b/src/Twilio/EnumConstants.cs @@ -0,0 +1,21 @@ +using Newtonsoft.Json; +using Twilio.Converters; +using Twilio.Types; + +namespace Twilio.Constant +{ + public class EnumConstants + { + [JsonConverter(typeof(StringEnumConverter))] + public sealed class ContentTypeEnum : StringEnum + { + private ContentTypeEnum(string value) : base(value) {} + public static implicit operator ContentTypeEnum(string value) + { + return new ContentTypeEnum(value); + } + public static readonly ContentTypeEnum JSON = new ContentTypeEnum("application/json"); + public static readonly ContentTypeEnum FORM_URLENCODED = new ContentTypeEnum("application/x-www-form-urlencoded"); + } + } +} \ No newline at end of file diff --git a/test/Twilio.Test/Constant/EnumConstantsTest.cs b/test/Twilio.Test/Constant/EnumConstantsTest.cs new file mode 100644 index 000000000..af1b70683 --- /dev/null +++ b/test/Twilio.Test/Constant/EnumConstantsTest.cs @@ -0,0 +1,20 @@ +using NUnit.Framework; +using Twilio.Constant; + +namespace Twilio.Tests.Constant +{ + [TestFixture] + public class EnumConstantsTest + { + + [Test] + public void EnumConstantComparison() + { + var jsonContentType = EnumConstants.ContentTypeEnum.JSON; + var formUrlEncodedType = EnumConstants.ContentTypeEnum.FORM_URLENCODED; + + Assert.AreEqual("application/json", jsonContentType.ToString()); + Assert.AreEqual("application/x-www-form-urlencoded", formUrlEncodedType.ToString()); + } + } +} \ No newline at end of file From 2d412f4e452f2b2c3f56079501151d05cb01d60c Mon Sep 17 00:00:00 2001 From: Shubham Tiwari Date: Wed, 13 Sep 2023 13:06:09 +0530 Subject: [PATCH 2/3] fix: refactored Enum file into Constant folder --- src/Twilio/{ => Constant}/EnumConstants.cs | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/Twilio/{ => Constant}/EnumConstants.cs (100%) diff --git a/src/Twilio/EnumConstants.cs b/src/Twilio/Constant/EnumConstants.cs similarity index 100% rename from src/Twilio/EnumConstants.cs rename to src/Twilio/Constant/EnumConstants.cs From 15c3784bdd0bab22e5c0e0979f384134a58e3416 Mon Sep 17 00:00:00 2001 From: Shubham Date: Wed, 13 Sep 2023 13:15:00 +0530 Subject: [PATCH 3/3] fix: removed unused constructor --- src/Twilio/Constant/EnumConstants.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Twilio/Constant/EnumConstants.cs b/src/Twilio/Constant/EnumConstants.cs index 55b163127..9a9332e28 100644 --- a/src/Twilio/Constant/EnumConstants.cs +++ b/src/Twilio/Constant/EnumConstants.cs @@ -10,12 +10,8 @@ public class EnumConstants public sealed class ContentTypeEnum : StringEnum { private ContentTypeEnum(string value) : base(value) {} - public static implicit operator ContentTypeEnum(string value) - { - return new ContentTypeEnum(value); - } public static readonly ContentTypeEnum JSON = new ContentTypeEnum("application/json"); public static readonly ContentTypeEnum FORM_URLENCODED = new ContentTypeEnum("application/x-www-form-urlencoded"); } } -} \ No newline at end of file +}