From bd7b72b9b6308f16913775aaae307f59bad4356d Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Wed, 27 Sep 2023 13:12:22 +0530 Subject: [PATCH 01/10] create tollfree verification api integration --- src/Plivo/PlivoApi.cs | 8 +- .../TollfreeVerification.cs | 32 ++++++++ .../TollfreeVerificationCreateResponse.cs | 20 +++++ .../TollfreeVerificationInterface.cs | 77 +++++++++++++++++++ .../tollfreeVerificationCreateResponse.json | 5 ++ .../Resources/TestTollfreeVerification.cs | 63 +++++++++++++++ 6 files changed, 204 insertions(+), 1 deletion(-) create mode 100644 src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs create mode 100644 src/Plivo/Resource/TollfreeVerification/TollfreeVerificationCreateResponse.cs create mode 100644 src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs create mode 100644 tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationCreateResponse.json create mode 100644 tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs diff --git a/src/Plivo/PlivoApi.cs b/src/Plivo/PlivoApi.cs index 3c3587bb..f94f9528 100755 --- a/src/Plivo/PlivoApi.cs +++ b/src/Plivo/PlivoApi.cs @@ -28,6 +28,7 @@ using Plivo.Resource.Campaign; using Plivo.Resource.Profile; using Plivo.Resource.Token; +using Plivo.Resource.TollfreeVerification; namespace Plivo { @@ -76,6 +77,7 @@ public class PlivoApi private readonly Lazy _complianceApplication; private readonly Lazy _multiPartyCall; + private readonly Lazy _tollfreeVerification; /// /// Gets the account. @@ -190,7 +192,10 @@ public class PlivoApi public ComplianceApplicationInterface ComplianceApplication => _complianceApplication.Value; public MultiPartyCallInterface MultiPartyCall => _multiPartyCall.Value; - + + public TollfreeVerificationInterface TollfreeVerification => _tollfreeVerification.Value; + + /// /// Initializes a new instance of the class. /// @@ -240,6 +245,7 @@ public PlivoApi( _complianceApplication = new Lazy(() => new ComplianceApplicationInterface(Client)); _multiPartyCall = new Lazy(() => new MultiPartyCallInterface(Client)); + _tollfreeVerification = new Lazy(() => new TollfreeVerificationInterface(Client)); } } } \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs new file mode 100644 index 00000000..b500b71f --- /dev/null +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs @@ -0,0 +1,32 @@ +using System; + +namespace Plivo.Resource.TollfreeVerification +{ + /// + /// TollfreeVerification. + /// + public class TollfreeVerification : Resource + { + public string Uuid { get; set; } + public string ProfileUUID { get; set; } + public string Number { get; set; } + public string Usecase { get; set; } + public string UsecaseSummary { get; set; } + public string MessageSample { get; set; } + public string OptinImageUrl { get; set; } + public string OptinType { get; set; } + public string Volume { get; set; } + public string AdditionalInformation { get; set; } + public string ExtraData { get; set; } + public string CallbackUrl { get; set; } + public string CallbackMethod { get; set; } + public string Status { get; set; } + public string RejectionReason { get; set; } + public DateTime CreatedAt { get; set; } + + public TollfreeVerification() + { + + } + } +} \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationCreateResponse.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationCreateResponse.cs new file mode 100644 index 00000000..96c3272b --- /dev/null +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationCreateResponse.cs @@ -0,0 +1,20 @@ +namespace Plivo.Resource.TollfreeVerification +{ + public class TollfreeVerificationCreateResponse : CreateResponse + { + /// + /// Gets or sets the request uuid. + /// + /// The tollfree verification request identifier. + public string Uuid { get; set; } + /// + /// Returns a that represents the current . + /// + /// A that represents the current . + public override string ToString() + { + return base.ToString() + + "UUID: " + Uuid + "\n"; + } + } +} \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs new file mode 100644 index 00000000..99fa019a --- /dev/null +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs @@ -0,0 +1,77 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Newtonsoft.Json.Linq; +using Plivo.Client; + +namespace Plivo.Resource.TollfreeVerification +{ + public class TollfreeVerificationInterface : ResourceInterface + { + /// + /// Initializes a new instance of the class. + /// + /// Client. + public TollfreeVerificationInterface(HttpClient client) : base(client) + { + Uri = "Account/" + Client.GetAuthId() + "/TollfreeVerification/"; + } + + #region create + + /// + /// Create TollfreeVerification request with the specified parameters. + /// + /// The profile UUID. + /// The toll-free number. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public TollfreeVerificationCreateResponse Create( + string profileUuid, string number, string usecase, + string usecaseSummary, string messageSample, string optinImageUrl, string optinType, + string volume, string additionalInformation=null, string extraData=null, string callbackUrl=null, + string callbackMethod=null) + { + var mandatoryParams = new List + { + "profileUuid", "usecase", "usecaseSummary", "messageSample", "optInImageUrl", "optInType", "volume", + "number" + }; + var data = CreateData( + mandatoryParams, new + { + profileUuid, + number, + usecase, + usecaseSummary, + messageSample, + optinType, + optinImageUrl, + volume, + additionalInformation, + extraData, + callbackUrl, + callbackMethod + }); + return ExecuteWithExceptionUnwrap(() => + { + var result = Task.Run(async () => + await Client.Update(Uri, data).ConfigureAwait(false)).Result; + JObject responseJson = JObject.Parse(result.Content); + result.Object.StatusCode = result.StatusCode; + result.Object.ApiId = responseJson["api_id"].ToString(); + result.Object.Message = responseJson["message"].ToString(); + return result.Object; + }); + } + + #endregion + } +} \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationCreateResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationCreateResponse.json new file mode 100644 index 00000000..20881d75 --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationCreateResponse.json @@ -0,0 +1,5 @@ +{ + "api_id": "99f9d6f6-3f08-11e7-9fd1-06660ad2b8e6", + "uuid": "28f736dc-680c-5ae4-6765-01732884e41e", + "message": "created" +} diff --git a/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs b/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs new file mode 100644 index 00000000..d05ba7d2 --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs @@ -0,0 +1,63 @@ +using Xunit; +using System.Collections.Generic; +using Plivo.Http; +using Plivo.Resource.TollfreeVerification; +using Plivo.Utilities; + +namespace Plivo.NetCore.Test.Resources +{ + public class TestTollfreeVerification : BaseTestCase + { + [Fact] + public void TestCreateTollfreeVerification() + { + var data = new Dictionary() + { + { "usecase", "HIGHER_EDUCATION,2FA" }, + { "number", "18339920058" }, + { "profile_uuid", "fb239ee1-fb5c-4dd9-b55c-5cf10170e758" }, + { "optin_type", "VERBAL" }, + { "volume", "10" }, + { "usecase_summary", "test usecase summary" }, + { "message_sample", "test message sample" }, + { "optin_image_url", "https://www.test.com" }, + { "callback_url", "https://testcallback.com" }, + { "callback_method", "GET" }, + { "additional_information", "test additional information" }, + { "extra_data", "test extradata" }, + }; + var request = + new PlivoRequest( + "POST", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/", + "", + data); + + var response = System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationCreateResponse.json" + ); + + Setup(201,response); + + Assert.Empty( + ComparisonUtilities.Compare( + response, Api.TollfreeVerification.Create( + "fb239ee1-fb5c-4dd9-b55c-5cf10170e758", + "18339920058", + "HIGHER_EDUCATION,2FA", + "test usecase summary", + "test message sample", + "https://www.test.com", + "VERBAL", + "10", + "test additional information", + "test extradata", + "https://testcallback.com", + "GET" + ) + )); + AssertRequest(request); + } + + } +} \ No newline at end of file From 5cd7f275d6f0f77b2d50e7ec60e49b87dcf5ffaa Mon Sep 17 00:00:00 2001 From: kalyan-plivo Date: Tue, 3 Oct 2023 12:56:11 +0530 Subject: [PATCH 02/10] Update unitTests.yml --- .github/workflows/unitTests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index f952f48a..2e78452c 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - dotnet-version: ['2.1.x'] + dotnet-version: ['3.1.x'] os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 @@ -22,9 +22,9 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ matrix.dotnet-version }} - - name: "Install and run tests 2.1.300" - if: ${{ matrix.dotnet-version == '2.1.x' }} + - name: "Install and run tests 3.1.22" + if: ${{ matrix.dotnet-version == '3.1.x' }} run: | dotnet test --framework netcoreapp2.0 tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj; env: - DOTNETCORE: 2 + DOTNETCORE: 3 From 55692957c65e056edf0b5f1f8d27f234a218a82d Mon Sep 17 00:00:00 2001 From: kalyan-plivo Date: Tue, 3 Oct 2023 13:01:05 +0530 Subject: [PATCH 03/10] Update unitTests.yml --- .github/workflows/unitTests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unitTests.yml b/.github/workflows/unitTests.yml index 2e78452c..f952f48a 100644 --- a/.github/workflows/unitTests.yml +++ b/.github/workflows/unitTests.yml @@ -12,7 +12,7 @@ jobs: strategy: fail-fast: false matrix: - dotnet-version: ['3.1.x'] + dotnet-version: ['2.1.x'] os: [ubuntu-18.04] steps: - uses: actions/checkout@v2 @@ -22,9 +22,9 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ matrix.dotnet-version }} - - name: "Install and run tests 3.1.22" - if: ${{ matrix.dotnet-version == '3.1.x' }} + - name: "Install and run tests 2.1.300" + if: ${{ matrix.dotnet-version == '2.1.x' }} run: | dotnet test --framework netcoreapp2.0 tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj; env: - DOTNETCORE: 3 + DOTNETCORE: 2 From a0780d562f39b964168922b1cefa7ad846960748 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Thu, 26 Oct 2023 16:21:11 +0530 Subject: [PATCH 04/10] Added support for additional tollfree verification apis --- .../TollfreeVerification/AsyncResponse.cs | 6 + .../TollfreeVerification.cs | 136 ++++++- .../TollfreeVerificationInterface.cs | 352 +++++++++++++++++- .../TollfreeVerificationListResponse.cs | 127 +++++++ .../tollfreeVerificationGetResponse.json | 19 + .../tollfreeVerificationListResponse.json | 50 +++ .../tollfreeVerificationUpdateResponse.json | 4 + .../Resources/TestTollfreeVerification.cs | 289 +++++++++++++- 8 files changed, 972 insertions(+), 11 deletions(-) create mode 100644 src/Plivo/Resource/TollfreeVerification/AsyncResponse.cs create mode 100644 src/Plivo/Resource/TollfreeVerification/TollfreeVerificationListResponse.cs create mode 100644 tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json create mode 100644 tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json create mode 100644 tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationUpdateResponse.json diff --git a/src/Plivo/Resource/TollfreeVerification/AsyncResponse.cs b/src/Plivo/Resource/TollfreeVerification/AsyncResponse.cs new file mode 100644 index 00000000..30d8cdfe --- /dev/null +++ b/src/Plivo/Resource/TollfreeVerification/AsyncResponse.cs @@ -0,0 +1,6 @@ +namespace Plivo.Resource.TollfreeVerification +{ + public class AsyncResponse : BaseResponse + { + } +} \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs index b500b71f..35212f6d 100644 --- a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs @@ -1,14 +1,15 @@ using System; +using System.Threading.Tasks; namespace Plivo.Resource.TollfreeVerification -{ +{ /// /// TollfreeVerification. /// public class TollfreeVerification : Resource { public string Uuid { get; set; } - public string ProfileUUID { get; set; } + public string ProfileUuid { get; set; } public string Number { get; set; } public string Usecase { get; set; } public string UsecaseSummary { get; set; } @@ -26,7 +27,136 @@ public class TollfreeVerification : Resource public TollfreeVerification() { - + } + + #region Delete + + /// + /// Delete this instance. + /// + /// The delete. + public DeleteResponse Delete() + { + return ((TollfreeVerificationInterface)Interface).Delete(Uuid); + } + + /// + /// Asynchronously delete this instance. + /// + /// The delete. + public async Task DeleteAsync() + { + return await ((TollfreeVerificationInterface)Interface).DeleteAsync(Uuid); + } + + #endregion + + #region Update + + /// + /// Update Tollfree Verification request with the specified profileUuid, usecase, usecaseSummary, messageSample, optinImageUrl, + /// optinType, volume, additionalInformation, extraData, callbackUrl, callbackMethod. + /// + /// The update. + /// The profile UUID. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public UpdateResponse Update( + string profileUuid = null, string usecase = null, string usecaseSummary = null, + string messageSample = null, string optinImageUrl = null, string optinType = null, string volume = null, + string additionalInformation = null, string extraData = null, string callbackUrl = null, + string callbackMethod = null) + { + var updateResponse = ((TollfreeVerificationInterface)Interface).Update( + Uuid, profileUuid, usecase, usecaseSummary, messageSample, + optinImageUrl, optinType, volume, additionalInformation, + extraData, callbackUrl, callbackMethod); + + if (profileUuid != null) ProfileUuid = profileUuid; + if (usecase != null) Usecase = usecase; + if (usecaseSummary != null) UsecaseSummary = usecaseSummary; + if (messageSample != null) MessageSample = messageSample; + if (optinImageUrl != null) OptinImageUrl = optinImageUrl; + if (optinType != null) OptinType = optinType; + if (volume != null) Volume = volume; + if (additionalInformation != null) AdditionalInformation = additionalInformation; + if (extraData != null) ExtraData = extraData; + if (callbackUrl != null) CallbackUrl = callbackUrl; + if (callbackMethod != null) CallbackMethod = callbackMethod; + + return updateResponse; + } + + /// + /// Asynchronously Update Tollfree Verification request with the specified profileUuid, usecase, usecaseSummary, messageSample, optinImageUrl, + /// optinType, volume, additionalInformation, extraData, callbackUrl, callbackMethod. + /// + /// The update. + /// The profile UUID. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public async Task UpdateAsync( + string profileUuid = null, string usecase = null, string usecaseSummary = null, + string messageSample = null, string optinImageUrl = null, string optinType = null, string volume = null, + string additionalInformation = null, string extraData = null, string callbackUrl = null, + string callbackMethod = null) + { + var updateResponse = await ((TollfreeVerificationInterface)Interface).UpdateAsync( + Uuid, profileUuid, usecase, usecaseSummary, messageSample, optinImageUrl, optinType, volume, + additionalInformation, extraData, callbackUrl, callbackMethod); + + if (profileUuid != null) ProfileUuid = profileUuid; + if (usecase != null) Usecase = usecase; + if (usecaseSummary != null) UsecaseSummary = usecaseSummary; + if (messageSample != null) MessageSample = messageSample; + if (optinImageUrl != null) OptinImageUrl = optinImageUrl; + if (optinType != null) OptinType = optinType; + if (volume != null) Volume = volume; + if (additionalInformation != null) AdditionalInformation = additionalInformation; + if (extraData != null) ExtraData = extraData; + if (callbackUrl != null) CallbackUrl = callbackUrl; + if (callbackMethod != null) CallbackMethod = callbackMethod; + + return updateResponse; + } + + #endregion + + public override string ToString() + { + return "\n" + + "UUID: " + Uuid + "\n" + + "ProfileUuid: " + ProfileUuid + "\n" + + "Number: " + Number + "\n" + + "Usecase: " + Usecase + "\n" + + "UsecaseSummary: " + UsecaseSummary + "\n" + + "MessageSample: " + MessageSample + "\n" + + "OptinImageUrl: " + OptinImageUrl + "\n" + + "OptinType: " + OptinType + "\n" + + "Volume: " + Volume + "\n" + + "AdditionalInformation: " + AdditionalInformation + "\n" + + "ExtraData: " + ExtraData + "\n" + + "CallbackUrl: " + CallbackUrl + "\n" + + "CallbackMethod: " + CallbackMethod + "\n" + + "Status: " + Status + "\n" + + "RejectionReason: " + RejectionReason + "\n" + + "CreatedAt: " + CreatedAt + "\n"; } } } \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs index 99fa019a..8cbb68a9 100644 --- a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using Newtonsoft.Json.Linq; using Plivo.Client; +using Plivo.Utilities; namespace Plivo.Resource.TollfreeVerification { @@ -36,8 +38,8 @@ public TollfreeVerificationInterface(HttpClient client) : base(client) public TollfreeVerificationCreateResponse Create( string profileUuid, string number, string usecase, string usecaseSummary, string messageSample, string optinImageUrl, string optinType, - string volume, string additionalInformation=null, string extraData=null, string callbackUrl=null, - string callbackMethod=null) + string volume, string additionalInformation = null, string extraData = null, string callbackUrl = null, + string callbackMethod = null) { var mandatoryParams = new List { @@ -68,10 +70,356 @@ public TollfreeVerificationCreateResponse Create( result.Object.StatusCode = result.StatusCode; result.Object.ApiId = responseJson["api_id"].ToString(); result.Object.Message = responseJson["message"].ToString(); + result.Object.Uuid = responseJson["uuid"].ToString(); return result.Object; }); } + /// + /// Asynchronously Create TollfreeVerification request with the specified parameters. + /// fallbackMethod, messageUrl, messageMethod, defaultNumberApp, defaultEndpointApp, subaccount and logIncomingMessages. + /// + /// The create. + /// The profile UUID. + /// The toll-free number. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public async Task CreateAsync( + string profileUuid, string number, string usecase, + string usecaseSummary, string messageSample, string optinImageUrl, string optinType, + string volume, string additionalInformation = null, string extraData = null, string callbackUrl = null, + string callbackMethod = null) + { + var mandatoryParams = new List + { + "profileUuid", "usecase", "usecaseSummary", "messageSample", "optInImageUrl", "optInType", "volume", + "number" + }; + var data = CreateData( + mandatoryParams, + new + { + profileUuid, + number, + usecase, + usecaseSummary, + messageSample, + optinType, + optinImageUrl, + volume, + additionalInformation, + extraData, + callbackUrl, + callbackMethod + }); + + + var result = Task.Run(async () => + await Client.Update(Uri, data).ConfigureAwait(false)) + .Result; + await Task.WhenAll(); + result.Object.StatusCode = result.StatusCode; + JObject responseJson = JObject.Parse(result.Content); + result.Object.ApiId = responseJson["api_id"].ToString(); + result.Object.Message = responseJson["message"].ToString(); + result.Object.Uuid = responseJson["uuid"].ToString(); + + return result.Object; + } + + #endregion + + #region Get + + /// + /// Get Tollfree Verification Request with the specified uuid. + /// + /// The get. + /// App identifier. + public TollfreeVerification Get(string uuid) + { + return ExecuteWithExceptionUnwrap(() => + { + var tfVerification = + Task.Run(async () => await GetResource(uuid).ConfigureAwait(false)).Result; + tfVerification.Interface = this; + return tfVerification; + }); + } + + /// + /// Asynchronously get Message with the specified messageUuid. + /// + /// The get. + /// TF Verification UUID. + public async Task GetAsync(string uuid) + { + var result = Task.Run(async () => await Client.Fetch( + Uri + uuid + "/").ConfigureAwait(false)).Result; + await Task.WhenAll(); + return result.Object; + } + + #endregion + + #region List + + /// + /// List TF Verification Request with the specified params, limit and offset. + /// + /// The list. + /// Limit. + /// Offset. + /// Number. + /// Status. + /// Profile UUID. + /// Created Time Greater Than. + /// Created Time Greater Than Equal. + /// Created Time Less Than. + /// Created Time Less Than Equal. + /// Usecase. + public TollfreeVerificationListResponse List( + uint? limit = null, + uint? offset = null, + string number = null, + string status = null, + string profileUuid = null, + string usecase = null, + string created_gt = null, + string created_gte = null, + string created_lt = null, + string created_lte = null + ) + { + var mandatoryParams = new List { "" }; + var data = CreateData( + mandatoryParams, new + { + limit, + offset, + number, + status, + profileUuid, + created_gt, + created_gte, + created_lt, + created_lte, + usecase + }); + + return ExecuteWithExceptionUnwrap(() => + { + var resources = Task.Run(async () => + await ListResources>(data) + .ConfigureAwait(false)).Result; + resources.Objects.ForEach( + (obj) => obj.Interface = this + ); + return resources; + }); + } + + /// + /// List TF Verification Request with the specified params, limit and offset. + /// + /// The list. + /// Limit. + /// Offset. + /// Number. + /// Status. + /// Profile UUID. + /// Created Time Greater Than. + /// Created Time Greater Than Equal. + /// Created Time Less Than. + /// Created Time Less Than Equal. + /// Usecase. + public async Task> ListAsync( + uint? limit = null, + uint? offset = null, + string number = null, + string status = null, + string profileUuid = null, + string created__gt = null, + string created__gte = null, + string created__lt = null, + string created__lte = null, + string usecase = null + ) + { + var mandatoryParams = new List { "" }; + var data = CreateData( + mandatoryParams, new + { + limit, + offset, + number, + status, + profileUuid, + created__gt, + created__gte, + created__lt, + created__lte, + usecase + }); + // var resources = await ListResources>(data); + var result = Task.Run(async () => await Client + .Fetch>( + Uri, data).ConfigureAwait(false)).Result; + await Task.WhenAll(); + return result.Object; + } + + #endregion + + #region Update + + /// + /// Update Tollfree Verification request with the specified profileUuid, usecase, usecaseSummary, messageSample, optinImageUrl, + /// optinType, volume, additionalInformation, extraData, callbackUrl, callbackMethod. + /// + /// The update. + /// The tollfree verification request UUID. + /// The profile UUID. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public UpdateResponse Update( + string uuid, string profileUuid = null, string usecase = null, string usecaseSummary = null, + string messageSample = null, + string optinImageUrl = null, string optinType = null, string volume = null, + string additionalInformation = null, + string extraData = null, string callbackUrl = null, string callbackMethod = null) + { + var mandatoryParams = new List { "" }; + var data = CreateData( + mandatoryParams, + new + { + uuid, + profileUuid, + usecase, + usecaseSummary, + messageSample, + optinType, + optinImageUrl, + volume, + additionalInformation, + extraData, + callbackUrl, + callbackMethod + }); + + return ExecuteWithExceptionUnwrap(() => + { + var result = Task.Run(async () => + await Client.Update>(Uri + uuid + "/", data) + .ConfigureAwait(false)) + .Result; + result.Object.StatusCode = result.StatusCode; + return result.Object; + }); + } + + /// + /// Asynchronously update tollfree verificartion request with the specified profileUuid, usecase, usecaseSummary, messageSample, optinImageUrl, + /// optinType, volume, additionalInformation, extraData, callbackUrl, callbackMethod. + /// + /// The update. + /// The tollfree verification request UUID. + /// The profile UUID. + /// The use case, e.g., "2FA, App Notifications". + /// The summary of the use case. + /// Sample messages associated with the use case. + /// The URL of the opt-in image. + /// The type of opt-in. + /// The message volume. + /// Additional information. + /// Extra data. + /// The callback URL. + /// The callback method. + public async Task UpdateAsync( + string uuid, string profileUuid = null, string usecase = null, string usecaseSummary = null, + string messageSample = null, + string optinImageUrl = null, string optinType = null, string volume = null, + string additionalInformation = null, + string extraData = null, string callbackUrl = null, string callbackMethod = null) + { + MpcUtils.ValidUrl("callbackUrl", callbackUrl, true); + var mandatoryParams = new List { "" }; + var data = CreateData( + mandatoryParams, + new + { + uuid, + profileUuid, + usecase, + usecaseSummary, + messageSample, + optinType, + optinImageUrl, + volume, + additionalInformation, + extraData, + callbackUrl, + callbackMethod + }); + var result = Task.Run(async () => + await Client.Update(Uri + uuid + "/", data).ConfigureAwait(false)).Result; + await Task.WhenAll(); + result.Object.StatusCode = result.StatusCode; + JObject responseJson = JObject.Parse(result.Content); + result.Object.ApiId = responseJson["api_id"].ToString(); + result.Object.Message = responseJson["message"].ToString(); + return result.Object; + } + + #endregion + + #region Delete + + /// + /// Delete Tollfree Verification Request with the specified uuid. + /// + /// The delete. + /// App identifier. + public DeleteResponse Delete(string uuid) + { + return ExecuteWithExceptionUnwrap(() => + { + return Task.Run(async () => + await DeleteResource>(uuid).ConfigureAwait(false)).Result; + }); + } + + /// + /// Asynchronously delete Application with the specified appId. + /// + /// The delete. + /// App identifier. + public async Task DeleteAsync(string uuid) + { + var result = Task.Run(async () => await Client.Delete( + Uri + uuid + "/").ConfigureAwait(false)).Result; + await Task.WhenAll(); + result.Object.StatusCode = result.StatusCode; + return result.Object; + } + #endregion } } \ No newline at end of file diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationListResponse.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationListResponse.cs new file mode 100644 index 00000000..08995d76 --- /dev/null +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationListResponse.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Plivo.Resource +{ + /// + /// Tollfree Verification List response. + /// + [JsonObject] + public class TollfreeVerificationListResponse : BaseResponse, IEnumerable + { + /// + /// Gets or sets the meta. + /// + /// The meta. + public TollfreeVerificationMeta Meta { get; set; } + /// + /// Gets or sets the objects. + /// + /// The objects. + public List Objects { get; set; } + + /// + /// Initializes a new instance of the class. + /// + public TollfreeVerificationListResponse() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Meta. + /// Objects. + public TollfreeVerificationListResponse(TollfreeVerificationMeta meta, List objects) + { + Meta = meta ?? throw new ArgumentNullException(nameof(meta)); + Objects = objects ?? throw new ArgumentNullException(nameof(objects)); + } + + /// + /// System.s the collections. IE numerable. get enumerator. + /// + /// The collections. IE numerable. get enumerator. + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + /// + /// Gets the enumerator. + /// + /// The enumerator. + public IEnumerator GetEnumerator() + { + return ((IEnumerable) Objects).GetEnumerator(); + } + + /// + /// Returns a that represents the current . + /// + /// A that represents the current . + public override string ToString() + { + return "Api Id: " + ApiId + "\n" + + "[Meta]\n" + Meta + + "StatusCode: " + StatusCode + + "[Objects]\n" + string.Join("\n", Objects); + + + + } + } + public class TollfreeVerificationMeta + { + /// + /// Gets or sets the limit. + /// + /// The limit. + public uint Limit { get; set; } + + /// + /// Gets or sets the next. + /// + /// The next. + [JsonProperty("next")] + public string Next { get; set; } + + /// + /// Gets or sets the offset. + /// + /// The offset. + [JsonProperty("offset")] + public uint Offset { get; set; } + + /// + /// Gets or sets the previous. + /// + /// The previous. + [JsonProperty("previous")] + public string Previous { get; set; } + + /// + /// Gets or sets the total_count. + /// + /// The previous. + [JsonProperty("total_count")] + public uint TotalCount { get; set; } + + + /// + /// Returns a that represents the current . + /// + /// A that represents the current . + public override string ToString() + { + return + "Limit: " + Limit + "\n" + + "Next: " + Next + "\n" + + "Offset: " + Offset + "\n" + + "Previous: " + Previous + "\n" + + "TotalCount: " + TotalCount + "\n"; + } + } +} \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json new file mode 100644 index 00000000..c07fa0e8 --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json @@ -0,0 +1,19 @@ +{ + "additional_information": "additional update1", + "api_id": "287aca86-73e9-11ee-93b2-0242ac110006", + "callback_method": "POST", + "callback_url": "https://www.callbackurl1.com", + "created_at": "2023-10-25T06:28:45.168185Z", + "extra_data": "extra updated1", + "message_sample": "sample update1", + "number": "18557312530", + "optin_image_url": "https://wwww.updatedur1.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "status": "SUBMITTED", + "updated_at": "2023-10-26T06:06:40.052089Z", + "usecase": "FRAUD_ALERT", + "usecase_summary": "summary up1", + "uuid": "28f736dc-680c-5ae4-6765-01732884e41e", + "volume": "10" +} \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json new file mode 100644 index 00000000..5ef558c9 --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json @@ -0,0 +1,50 @@ +{ + "api_id": "c25c72f8-73d5-11ee-8d5d-0242ac110006", + "meta": { + "total_count": 2, + "limit": 20, + "next": null, + "offset": 0, + "previous": null + }, + "objects": [ + { + "additional_information": "additional update1", + "callback_method": "POST", + "callback_url": "https://www.callbackurl1.com", + "created_at": "2023-10-25T06:28:45.168185Z", + "extra_data": "extra updated1", + "message_sample": "sample update1", + "number": "18557312530", + "optin_image_url": "https://wwww.updatedur1.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "rejection_reason": "", + "status": "SUBMITTED", + "updated_at": "2023-10-26T06:06:40.052089Z", + "usecase": "FRAUD_ALERT", + "usecase_summary": "summary up1", + "uuid": "aa5eab21-4931-468e-7502-2d8d18311fcc", + "volume": "10" + }, + { + "additional_information": "this is additional_information", + "callback_method": "POST", + "callback_url": "http://plivobin-prod-usw1.plivops.com/14ha4pv1", + "created_at": "2023-10-19T11:33:59.363045Z", + "extra_data": "this is extra_data", + "message_sample": "mes", + "number": "18449605287", + "optin_image_url": "https://www.aa.com,http://google.com", + "optin_type": "VERBAL", + "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", + "rejection_reason": "", + "status": "REJECTED", + "updated_at": "2023-10-19T11:33:59.362762Z", + "usecase": "2FA,FRAUD_ALERT,HIGHER_EDUCATION,PUBLIC_SERVICE_ANNOUNCEMENT", + "usecase_summary": "use ", + "uuid": "7189d4c9-78fe-4dfd-5dc4-6e68101afdb9", + "volume": "10" + } + ] +} \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationUpdateResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationUpdateResponse.json new file mode 100644 index 00000000..88ac9f05 --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationUpdateResponse.json @@ -0,0 +1,4 @@ +{ + "api_id": "dbf8f1b8-73c2-11ee-8d5d-0242ac110006", + "message": "Tollfree verification request for uuid 28f736dc-680c-5ae4-6765-01732884e41e updated successfully." +} \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs b/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs index d05ba7d2..a5900d27 100644 --- a/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs +++ b/tests_netcore/Plivo.NetCore.Test/Resources/TestTollfreeVerification.cs @@ -1,6 +1,8 @@ using Xunit; using System.Collections.Generic; +using System.Threading.Tasks; using Plivo.Http; +using Plivo.Resource; using Plivo.Resource.TollfreeVerification; using Plivo.Utilities; @@ -32,13 +34,13 @@ public void TestCreateTollfreeVerification() "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/", "", data); - + var response = System.IO.File.ReadAllText( SOURCE_DIR + @"../Mocks/tollfreeVerificationCreateResponse.json" ); - - Setup(201,response); - + + Setup(201, response); + Assert.Empty( ComparisonUtilities.Compare( response, Api.TollfreeVerification.Create( @@ -54,10 +56,285 @@ public void TestCreateTollfreeVerification() "test extradata", "https://testcallback.com", "GET" - ) - )); + ) + )); + AssertRequest(request); + } + + [Fact] + public void TestCreateTollfreeVerificationAsync() + { + var data = new Dictionary() + { + { "usecase", "HIGHER_EDUCATION,2FA" }, + { "number", "18339920058" }, + { "profile_uuid", "fb239ee1-fb5c-4dd9-b55c-5cf10170e758" }, + { "optin_type", "VERBAL" }, + { "volume", "10" }, + { "usecase_summary", "test usecase summary" }, + { "message_sample", "test message sample" }, + { "optin_image_url", "https://www.test.com" }, + { "callback_url", "https://testcallback.com" }, + { "callback_method", "POST" }, + { "additional_information", "test additional information" }, + { "extra_data", "test extradata" }, + }; + var request = + new PlivoRequest( + "POST", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/", + "", + data); + + var response = System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationCreateResponse.json" + ); + + Setup(201, response); + + Assert.Empty( + ComparisonUtilities.Compare( + response, Api.TollfreeVerification.CreateAsync( + "fb239ee1-fb5c-4dd9-b55c-5cf10170e758", + "18339920058", + "HIGHER_EDUCATION,2FA", + "test usecase summary", + "test message sample", + "https://www.test.com", + "VERBAL", + "10", + "test additional information", + "test extradata", + "https://testcallback.com", + "POST" + ).Result + )); + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationList() + { + var data = new Dictionary() + { + { "limit", 20 }, + { "offset", 0 } + }; + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/", + "", + data); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationListResponse.json" + ); + Setup>(200, response); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.List(20, 0) + ) + ); + + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationListAsync() + { + var data = new Dictionary() + { + { "limit", 20 }, + { "offset", 0 } + }; + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/", + "", + data); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationListResponse.json" + ); + Setup>(200, response); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.ListAsync(20, 0).Result + ) + ); + + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationGet() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + ""); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationGetResponse.json" + ); + Setup( + 200, + response + ); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.Get(uuid))); + + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationGetAsync() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + ""); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationGetResponse.json" + ); + Setup(200, response); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.GetAsync(uuid).Result + ) + ); + + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationUpdate() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + var data = new Dictionary() + { + { "callback_url", "http://updated.callback.url" }, + { "callback_method", "POST" }, + { "usecase", "2FA" }, + }; + + var request = + new PlivoRequest( + "POST", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + "", + data); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationUpdateResponse.json" + ); + Setup>( + 202, + response + ); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.Update(uuid, usecase: "2FA", callbackUrl: "http://updated.callback.url", + callbackMethod: "POST"))); + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationUpdateAsync() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + var data = new Dictionary() + { + { "callback_url", "http://updated.callback.url" }, + { "callback_method", "POST" }, + { "usecase", "2FA" }, + }; + + var request = + new PlivoRequest( + "POST", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + "", + data); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/tollfreeVerificationUpdateResponse.json" + ); + Setup(200, response); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.UpdateAsync(uuid, usecase: "2FA", + callbackUrl: "http://updated.callback.url", callbackMethod: "POST").Result + ) + ); AssertRequest(request); } + [Fact] + public void TestTollfreeVerificationDelete() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + var request = + new PlivoRequest( + "DELETE", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + ""); + + var response = ""; + Setup>( + 204, + response + ); + Assert.Null(Api.TollfreeVerification.Delete(uuid)); + AssertRequest(request); + } + + [Fact] + public void TestTollfreeVerificationDeleteAsync() + { + var uuid = "28f736dc-680c-5ae4-6765-01732884e41e"; + + var request = + new PlivoRequest( + "DELETE", + "Account/MAXXXXXXXXXXXXXXXXXX/TollfreeVerification/" + uuid + "/", + ""); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/asyncResponse.json" + ); + Setup(204, response); + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.TollfreeVerification.DeleteAsync(uuid).Result + ) + ); + + AssertRequest(request); + } } } \ No newline at end of file From 826a423434405c7f440446380270039398f29348 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Thu, 26 Oct 2023 18:16:23 +0530 Subject: [PATCH 05/10] Added tf verification fields in list rented numbers function --- .../Resource/RentedNumber/RentedNumber.cs | 22 ++++++++++++------- .../RentedNumber/RentedNumberInterface.cs | 4 +++- .../Mocks/numberGetResponse.json | 4 +++- .../Mocks/numberListResponse.json | 12 +++++++--- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/Plivo/Resource/RentedNumber/RentedNumber.cs b/src/Plivo/Resource/RentedNumber/RentedNumber.cs index 8a756a8d..7ff54dc3 100755 --- a/src/Plivo/Resource/RentedNumber/RentedNumber.cs +++ b/src/Plivo/Resource/RentedNumber/RentedNumber.cs @@ -29,14 +29,16 @@ public class RentedNumber : Resource public bool VoiceEnabled { get; set; } public string VoiceRate { get; set; } - public string ComplianceApplicationId {get; set;} - public string ComplianceStatus {get; set;} - public string TendlcCampaignId {get; set;} - public string TendlcRegistrationStatus {get; set;} - public string TollFreeSmsVerification {get; set;} - public string RenewalDate {get; set;} - public string CnamLookup {get; set;} - + public string ComplianceApplicationId { get; set; } + public string ComplianceStatus { get; set; } + public string TendlcCampaignId { get; set; } + public string TendlcRegistrationStatus { get; set; } + public string TollFreeSmsVerification { get; set; } + public string RenewalDate { get; set; } + public string CnamLookup { get; set; } + public string TollFreeSmsVerificationOrderStatus { get; set; } + public string TollFreeSmsVerificationId { get; set; } + public override string ToString() { if (string.Compare(Carrier, "Plivo", StringComparison.Ordinal) == 0) @@ -69,6 +71,8 @@ public override string ToString() "TendlcCampaignId: " + TendlcCampaignId + "\n" + "TendlcRegistrationStatus: " + TendlcRegistrationStatus + "\n" + "TollFreeSMSVerification: " + TollFreeSmsVerification + "\n" + + "TollFreeSmsVerificationOrderStatus: " + TollFreeSmsVerificationOrderStatus + "\n" + + "TollFreeSmsVerificationId: " + TollFreeSmsVerificationId + "\n" + "VoiceRate: " + VoiceRate + "\n"; } return @@ -92,6 +96,8 @@ public override string ToString() "TendlcCampaignId: " + TendlcCampaignId + "\n" + "TendlcRegistrationStatus: " + TendlcRegistrationStatus + "\n" + "TollFreeSMSVerification: " + TollFreeSmsVerification + "\n" + + "TollFreeSmsVerificationOrderStatus: " + TollFreeSmsVerificationOrderStatus + "\n" + + "TollFreeSmsVerificationId: " + TollFreeSmsVerificationId + "\n" + "VoiceRate: " + VoiceRate + "\n"; } diff --git a/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs b/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs index 3d1e235c..b4fa0356 100755 --- a/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs +++ b/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs @@ -72,6 +72,7 @@ public async Task GetAsync(string number) /// Renewal Date Greater Than /// Renewal Date Greater Than or Equal /// Cnam Lookup configuration + /// TollFree SMS Verification Order Status public ListResponse List( string type = null, string numberStartswith = null, string subaccount = null, string alias = null, @@ -81,7 +82,7 @@ public ListResponse List( string renewalDate = null, string renewalDate_Lt = null, string renewalDate_Lte = null, string renewalDate_Gt = null, string renewalDate_Gte = null, - string cnamLookup = null, + string cnamLookup = null, string tollFreeSmsVerificationOrderStatus = null, uint? limit = null, uint? offset = null) { var mandatoryParams = new List {""}; @@ -103,6 +104,7 @@ public ListResponse List( renewalDate_Gte, renewalDate_Gt, cnamLookup, + tollFreeSmsVerificationOrderStatus, limit, offset }); diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/numberGetResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/numberGetResponse.json index 886cc8fb..f352a418 100755 --- a/tests_netcore/Plivo.NetCore.Test/Mocks/numberGetResponse.json +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/numberGetResponse.json @@ -18,5 +18,7 @@ "tendlc_registration_status": "COMPLETED", "toll_free_sms_verification": null, "renewal_date": "2023-05-01", - "cnam_lookup": "enabled" + "cnam_lookup": "enabled", + "toll_free_sms_verification_order_status": "REJECTED", + "toll_free_sms_verification_id": "28f736dc-680c-5ae4-6765-01732884e41e" } diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/numberListResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/numberListResponse.json index 2c78e299..b831e302 100755 --- a/tests_netcore/Plivo.NetCore.Test/Mocks/numberListResponse.json +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/numberListResponse.json @@ -27,7 +27,9 @@ "tendlc_registration_status": "completed", "toll_free_sms_verification": null, "renewal_date": "2023-05-01", - "cnam_lookup": "enabled" + "cnam_lookup": "enabled", + "toll_free_sms_verification_order_status": "REJECTED", + "toll_free_sms_verification_id": "28f736dc-680c-5ae4-6765-01732884e41e" }, { "added_on": "2013-01-01", @@ -48,7 +50,9 @@ "tendlc_registration_status": "completed", "toll_free_sms_verification": null, "renewal_date": "2023-05-01", - "cnam_lookup": "enabled" + "cnam_lookup": "enabled", + "toll_free_sms_verification_order_status": null, + "toll_free_sms_verification_id": null }, { "added_on": "2013-03-25", @@ -69,7 +73,9 @@ "tendlc_registration_status": null, "toll_free_sms_verification": "verified", "renewal_date": "2023-05-01", - "cnam_lookup": "enabled" + "cnam_lookup": "enabled", + "toll_free_sms_verification_order_status": null, + "toll_free_sms_verification_id": null } ] } From f2c32bdea65eae5781c353da331889c5ae68003b Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Fri, 27 Oct 2023 17:20:53 +0530 Subject: [PATCH 06/10] added updated_at in tf verification --- .../Resource/TollfreeVerification/TollfreeVerification.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs index 35212f6d..9e77ffc0 100644 --- a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs @@ -23,7 +23,8 @@ public class TollfreeVerification : Resource public string CallbackMethod { get; set; } public string Status { get; set; } public string RejectionReason { get; set; } - public DateTime CreatedAt { get; set; } + public string CreatedAt { get; set; } + public string UpdatedAt { get; set; } public TollfreeVerification() { @@ -156,7 +157,8 @@ public override string ToString() "CallbackMethod: " + CallbackMethod + "\n" + "Status: " + Status + "\n" + "RejectionReason: " + RejectionReason + "\n" + - "CreatedAt: " + CreatedAt + "\n"; + "CreatedAt: " + CreatedAt + "\n" + + "UpdatedAt: " + UpdatedAt + "\n"; } } } \ No newline at end of file From 5a44e05dec3c2754a74891ab716a203e7686451a Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Mon, 30 Oct 2023 18:34:57 +0530 Subject: [PATCH 07/10] renamed created filters --- .../RentedNumber/RentedNumberInterface.cs | 2 +- .../TollfreeVerificationInterface.cs | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs b/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs index b4fa0356..71f44dca 100755 --- a/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs +++ b/src/Plivo/Resource/RentedNumber/RentedNumberInterface.cs @@ -78,7 +78,7 @@ public ListResponse List( string subaccount = null, string alias = null, string services = null, string tendlcCampaignId = null, string tendlcRegistrationStatus = null, - PropertyInfo tollFreeSmsVerification = null, + string tollFreeSmsVerification = null, string renewalDate = null, string renewalDate_Lt = null, string renewalDate_Lte = null, string renewalDate_Gt = null, string renewalDate_Gte = null, diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs index 8cbb68a9..38ee16ca 100644 --- a/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerificationInterface.cs @@ -181,10 +181,10 @@ public async Task GetAsync(string uuid) /// Number. /// Status. /// Profile UUID. - /// Created Time Greater Than. - /// Created Time Greater Than Equal. - /// Created Time Less Than. - /// Created Time Less Than Equal. + /// Created Time Greater Than. + /// Created Time Greater Than Equal. + /// Created Time Less Than. + /// Created Time Less Than Equal. /// Usecase. public TollfreeVerificationListResponse List( uint? limit = null, @@ -193,10 +193,10 @@ public TollfreeVerificationListResponse List( string status = null, string profileUuid = null, string usecase = null, - string created_gt = null, - string created_gte = null, - string created_lt = null, - string created_lte = null + string created_Gt = null, + string created_Gte = null, + string created_Lt = null, + string created_Lte = null ) { var mandatoryParams = new List { "" }; @@ -208,10 +208,10 @@ public TollfreeVerificationListResponse List( number, status, profileUuid, - created_gt, - created_gte, - created_lt, - created_lte, + created_Gt, + created_Gte, + created_Lt, + created_Lte, usecase }); From f7a623e5d88dbb2269b9675270113c855aab5f27 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Tue, 31 Oct 2023 14:40:32 +0530 Subject: [PATCH 08/10] renamed created lastmodified and error message --- src/Plivo/Client/SystemHttpClient.cs | 2 +- src/Plivo/Plivo.csproj | 3 +++ .../TollfreeVerification/TollfreeVerification.cs | 12 ++++++------ .../Mocks/tollfreeVerificationGetResponse.json | 3 ++- .../Mocks/tollfreeVerificationListResponse.json | 4 ++-- .../Plivo.NetCore.Test/Plivo.NetCore.Test.csproj | 3 +++ 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Plivo/Client/SystemHttpClient.cs b/src/Plivo/Client/SystemHttpClient.cs index 45475a56..bd06b1ba 100755 --- a/src/Plivo/Client/SystemHttpClient.cs +++ b/src/Plivo/Client/SystemHttpClient.cs @@ -112,7 +112,7 @@ public SystemHttpClient(BasicAuth basicAuth, Dictionary proxySer ); _client.DefaultRequestHeaders.Authorization = authHeader; _client.DefaultRequestHeaders.Add("User-Agent", "plivo-dotnet/" + ThisAssembly.AssemblyFileVersion); - var baseServerUri = string.IsNullOrEmpty(baseUri) ? "https://api.plivo.com/" + Version.ApiVersion : baseUri; + var baseServerUri = string.IsNullOrEmpty(baseUri) ? "https://api.numbers.plivodev.com/" + Version.ApiVersion : baseUri; _client.BaseAddress = new Uri(baseServerUri + "/"); _voiceBaseUriClient = new System.Net.Http.HttpClient(httpClientHandler); diff --git a/src/Plivo/Plivo.csproj b/src/Plivo/Plivo.csproj index 2aad58d0..e2ab39c9 100644 --- a/src/Plivo/Plivo.csproj +++ b/src/Plivo/Plivo.csproj @@ -30,6 +30,9 @@ + + 3.6.133 + diff --git a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs index 9e77ffc0..ec3cd412 100644 --- a/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs +++ b/src/Plivo/Resource/TollfreeVerification/TollfreeVerification.cs @@ -22,9 +22,9 @@ public class TollfreeVerification : Resource public string CallbackUrl { get; set; } public string CallbackMethod { get; set; } public string Status { get; set; } - public string RejectionReason { get; set; } - public string CreatedAt { get; set; } - public string UpdatedAt { get; set; } + public string ErrorMessage { get; set; } + public string Created { get; set; } + public string LastModified { get; set; } public TollfreeVerification() { @@ -156,9 +156,9 @@ public override string ToString() "CallbackUrl: " + CallbackUrl + "\n" + "CallbackMethod: " + CallbackMethod + "\n" + "Status: " + Status + "\n" + - "RejectionReason: " + RejectionReason + "\n" + - "CreatedAt: " + CreatedAt + "\n" + - "UpdatedAt: " + UpdatedAt + "\n"; + "ErrorMessage: " + ErrorMessage + "\n" + + "Created: " + Created + "\n" + + "LastModified: " + LastModified + "\n"; } } } \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json index c07fa0e8..c401c30b 100644 --- a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationGetResponse.json @@ -15,5 +15,6 @@ "usecase": "FRAUD_ALERT", "usecase_summary": "summary up1", "uuid": "28f736dc-680c-5ae4-6765-01732884e41e", - "volume": "10" + "volume": "10", + "error_message": "" } \ No newline at end of file diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json index 5ef558c9..7686d4b1 100644 --- a/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/tollfreeVerificationListResponse.json @@ -19,7 +19,7 @@ "optin_image_url": "https://wwww.updatedur1.com", "optin_type": "VERBAL", "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", - "rejection_reason": "", + "error_message": "", "status": "SUBMITTED", "updated_at": "2023-10-26T06:06:40.052089Z", "usecase": "FRAUD_ALERT", @@ -38,7 +38,7 @@ "optin_image_url": "https://www.aa.com,http://google.com", "optin_type": "VERBAL", "profile_uuid": "fb239ee1-fb5c-4dd9-b55c-5cf10170e756", - "rejection_reason": "", + "error_message": "", "status": "REJECTED", "updated_at": "2023-10-19T11:33:59.362762Z", "usecase": "2FA,FRAUD_ALERT,HIGHER_EDUCATION,PUBLIC_SERVICE_ANNOUNCEMENT", diff --git a/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj b/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj index bc06909a..5ab76283 100755 --- a/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj +++ b/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj @@ -17,6 +17,9 @@ runtime; build; native; contentfiles; analyzers + + 3.6.133 + From 381eb0f9fa37f21de183c5a35a4a6fb3495690e7 Mon Sep 17 00:00:00 2001 From: kapilp93 Date: Tue, 31 Oct 2023 15:58:03 +0530 Subject: [PATCH 09/10] reverted local changes --- src/Plivo/Client/SystemHttpClient.cs | 2 +- src/Plivo/Plivo.csproj | 3 --- tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj | 3 --- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Plivo/Client/SystemHttpClient.cs b/src/Plivo/Client/SystemHttpClient.cs index bd06b1ba..45475a56 100755 --- a/src/Plivo/Client/SystemHttpClient.cs +++ b/src/Plivo/Client/SystemHttpClient.cs @@ -112,7 +112,7 @@ public SystemHttpClient(BasicAuth basicAuth, Dictionary proxySer ); _client.DefaultRequestHeaders.Authorization = authHeader; _client.DefaultRequestHeaders.Add("User-Agent", "plivo-dotnet/" + ThisAssembly.AssemblyFileVersion); - var baseServerUri = string.IsNullOrEmpty(baseUri) ? "https://api.numbers.plivodev.com/" + Version.ApiVersion : baseUri; + var baseServerUri = string.IsNullOrEmpty(baseUri) ? "https://api.plivo.com/" + Version.ApiVersion : baseUri; _client.BaseAddress = new Uri(baseServerUri + "/"); _voiceBaseUriClient = new System.Net.Http.HttpClient(httpClientHandler); diff --git a/src/Plivo/Plivo.csproj b/src/Plivo/Plivo.csproj index e2ab39c9..2aad58d0 100644 --- a/src/Plivo/Plivo.csproj +++ b/src/Plivo/Plivo.csproj @@ -30,9 +30,6 @@ - - 3.6.133 - diff --git a/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj b/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj index 5ab76283..bc06909a 100755 --- a/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj +++ b/tests_netcore/Plivo.NetCore.Test/Plivo.NetCore.Test.csproj @@ -17,9 +17,6 @@ runtime; build; native; contentfiles; analyzers - - 3.6.133 - From dec371e8a2ab49e976eba5c198860ce4f7ccfbc4 Mon Sep 17 00:00:00 2001 From: kalyan-plivo Date: Tue, 31 Oct 2023 20:27:44 +0530 Subject: [PATCH 10/10] bump version --- CHANGELOG.md | 6 ++++++ README.md | 4 ++-- src/Plivo/Plivo.csproj | 2 +- src/Plivo/Plivo.nuspec | 1 + src/Plivo/Version.cs | 2 +- version.json | 2 +- 6 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bbcfbe2..1132a6b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [5.37.0](https://github.com/plivo/plivo-dotnet/tree/v5.37.0) (2023-10-31) +**Feature - TollFree Verification API Support** +- API support for Create, Update, Get, Delete and List Tollfree Verification. +- Added New Param `toll_free_sms_verification_id` and `toll_free_sms_verification_order_status `in to the response of the [list all numbers API], [list single number API] +- Added `toll_free_sms_verification_order_status` filter to AccountPhoneNumber - list all my numbers API. + ## [5.36.0](https://github.com/plivo/plivo-dotnet/tree/v5.36.0) (2023-10-20) **Feature - campaign_source field** - Added new param `campaign_source` in LIST / GET Campaign APIs diff --git a/README.md b/README.md index 98764d87..1c3ab7c0 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ You can install this SDK either by referencing the .dll file or using NuGet. Use the following line to install the latest SDK using the NuGet CLI. ``` -PM> Install-Package Plivo -Version 5.36.0 +PM> Install-Package Plivo -Version 5.37.0 ``` You can also use the .NET CLI to install this package as follows ``` -> dotnet add package Plivo --version 5.36.0 +> dotnet add package Plivo --version 5.37.0 ``` ## Getting started diff --git a/src/Plivo/Plivo.csproj b/src/Plivo/Plivo.csproj index 000489bb..231d5668 100644 --- a/src/Plivo/Plivo.csproj +++ b/src/Plivo/Plivo.csproj @@ -1,7 +1,7 @@ netstandard2.0;netstandard1.3 - 5.36.0 + 5.37.0 Plivo SDKs Team Plivo Inc. diff --git a/src/Plivo/Plivo.nuspec b/src/Plivo/Plivo.nuspec index e2181317..c6f0d15b 100644 --- a/src/Plivo/Plivo.nuspec +++ b/src/Plivo/Plivo.nuspec @@ -12,6 +12,7 @@ http://github.com/plivo/plivo-dotnet false + * 5.37.0 API support for Create, Update, Get, Delete and List Tollfree Verification. * 5.36.0 Added New Params `campaign_source`. * 5.35.0 Fixes for Campaign services list API meta data. * 5.34.0 Added new params `template`, `template_json_string` and message_type `whatsapp`in send message API. Added new `message_state` (`read`), `message_type` (`whatsapp`), `conversation_id`, `conversation_origin`, `conversation_expiration_timestamp` in List Message and Get Message APIs. diff --git a/src/Plivo/Version.cs b/src/Plivo/Version.cs index fac6e4b1..2b5f773c 100644 --- a/src/Plivo/Version.cs +++ b/src/Plivo/Version.cs @@ -10,7 +10,7 @@ public class Version /// /// DotNet SDK version /// - public const string SdkVersion = "5.36.0"; + public const string SdkVersion = "5.37.0"; /// /// Plivo API version /// diff --git a/version.json b/version.json index 248ed26f..bd12c89f 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "5.36.0", + "version": "5.37.0", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v\\d+(?:\\.\\d+)?$"