From 0c853b950bc3ce1dc3e4032e3c09f56addfb1a74 Mon Sep 17 00:00:00 2001 From: mohsin-plivo Date: Tue, 18 Feb 2025 11:50:40 +0530 Subject: [PATCH] Add GeoPermissions exception on synchronous geo permissions error from server --- CHANGELOG.md | 3 +++ README.md | 4 ++-- .../Exception/PlivoGeoPermissionException.cs | 9 +++++++++ src/Plivo/Http/PlivoResponse.cs | 17 +++++++++++++++++ src/Plivo/Plivo.csproj | 2 +- src/Plivo/Plivo.nuspec | 2 +- src/Plivo/Version.cs | 2 +- version.json | 2 +- 8 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 src/Plivo/Exception/PlivoGeoPermissionException.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 0eda40a3..bb511dc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Change Log +## [5.49.3](https://github.com/plivo/plivo-dotnet/tree/v5.49.3) (2025-02-18) +**Feature - Throw PlivoGeoPermissionException on synchronous geopermissions error** + ## [5.49.2](https://github.com/plivo/plivo-dotnet/tree/v5.49.2) (2024-10-23) **Feature - FraudCheck param in Create, Get and List Session** - Support for the `fraud_check` parameter in sms verify session request diff --git a/README.md b/README.md index 111c945f..f731f3a7 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.49.2 +PM> Install-Package Plivo -Version 5.49.3 ``` You can also use the .NET CLI to install this package as follows ``` -> dotnet add package Plivo --version 5.49.2 +> dotnet add package Plivo --version 5.49.3 ``` ## Getting started diff --git a/src/Plivo/Exception/PlivoGeoPermissionException.cs b/src/Plivo/Exception/PlivoGeoPermissionException.cs new file mode 100644 index 00000000..660620d3 --- /dev/null +++ b/src/Plivo/Exception/PlivoGeoPermissionException.cs @@ -0,0 +1,9 @@ +namespace Plivo.Exception +{ + public class PlivoGeoPermissionException : PlivoRestException + { + public PlivoGeoPermissionException(string message, uint statusCode = 403) : base(message, statusCode) + { + } + } +} \ No newline at end of file diff --git a/src/Plivo/Http/PlivoResponse.cs b/src/Plivo/Http/PlivoResponse.cs index b1cb2408..e4765064 100755 --- a/src/Plivo/Http/PlivoResponse.cs +++ b/src/Plivo/Http/PlivoResponse.cs @@ -37,6 +37,13 @@ public class PlivoResponse /// public PlivoRequest PlivoRequest; + private static readonly HashSet GeoPermissionEndpoints = new HashSet + { + "/Message/", + "/Session/", + "/Call/" + }; + /// /// Initializes a new instance of the class. /// @@ -89,6 +96,16 @@ private void ThrowException(string message) throw new PlivoValidationException(message); case 401: throw new PlivoAuthenticationException(message); + case 403: + if (PlivoRequest.Method == "POST" && + GeoPermissionEndpoints.Any(endpoint => PlivoRequest.Uri.EndsWith(endpoint))) + { + throw new PlivoGeoPermissionException(message); + } + else + { + throw new PlivoRestException(message, StatusCode); + } case 404: throw new PlivoNotFoundException(message); case 405: diff --git a/src/Plivo/Plivo.csproj b/src/Plivo/Plivo.csproj index d0dc9437..90df7977 100644 --- a/src/Plivo/Plivo.csproj +++ b/src/Plivo/Plivo.csproj @@ -1,7 +1,7 @@ netstandard2.0;netstandard1.3 - 5.49.2 + 5.49.3 Plivo SDKs Team Plivo Inc. diff --git a/src/Plivo/Plivo.nuspec b/src/Plivo/Plivo.nuspec index 583e9c3a..6a608366 100644 --- a/src/Plivo/Plivo.nuspec +++ b/src/Plivo/Plivo.nuspec @@ -4,7 +4,7 @@ A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML Plivo - 5.49.2 + 5.49.3 Plivo Plivo SDKs Team Plivo, Inc. diff --git a/src/Plivo/Version.cs b/src/Plivo/Version.cs index f5039a24..9cfed20b 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.49.2"; + public const string SdkVersion = "5.49.3"; /// /// Plivo API version /// diff --git a/version.json b/version.json index 62216821..314e6e29 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { - "version": "5.49.2", + "version": "5.49.3", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v\\d+(?:\\.\\d+)?$"