Skip to content

Add GeoPermissions exception on synchronous geo permissions error #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions src/Plivo/Exception/PlivoGeoPermissionException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Plivo.Exception
{
public class PlivoGeoPermissionException : PlivoRestException
{
public PlivoGeoPermissionException(string message, uint statusCode = 403) : base(message, statusCode)
{
}
}
}
17 changes: 17 additions & 0 deletions src/Plivo/Http/PlivoResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public class PlivoResponse<T>
/// </summary>
public PlivoRequest PlivoRequest;

private static readonly HashSet<string> GeoPermissionEndpoints = new HashSet<string>
{
"/Message/",
"/Session/",
"/Call/"
};

/// <summary>
/// Initializes a new instance of the <see cref="T:plivo.Http.PlivoResponse`1"/> class.
/// </summary>
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Plivo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard1.3</TargetFrameworks>
<ReleaseVersion>5.49.2</ReleaseVersion>
<ReleaseVersion>5.49.3</ReleaseVersion>
<Version />
<Authors>Plivo SDKs Team</Authors>
<Owners>Plivo Inc.</Owners>
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Plivo.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<summary>A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML</summary>
<description>A .NET SDK to make voice calls and send SMS using Plivo and to generate Plivo XML</description>
<id>Plivo</id>
<version>5.49.2</version>
<version>5.49.3</version>
<title>Plivo</title>
<authors>Plivo SDKs Team</authors>
<owners>Plivo, Inc.</owners>
Expand Down
2 changes: 1 addition & 1 deletion src/Plivo/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Version
/// <summary>
/// DotNet SDK version
/// </summary>
public const string SdkVersion = "5.49.2";
public const string SdkVersion = "5.49.3";
/// <summary>
/// Plivo API version
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.49.2",
"version": "5.49.3",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/v\\d+(?:\\.\\d+)?$"
Expand Down
Loading