Skip to content
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

Single party session changes #288

Merged
merged 8 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Change Log
## [5.49.0](https://github.com/plivo/plivo-dotnet/tree/v5.49.0) (2024-09-10)
**Feature - Adding new param support for Number Masking session with single party **
- Added `create_session_with_single_party`, `virtual_number_cooloff_period` and `force_pin_authentication` attributes in Masking Session

## [5.48.1](https://github.com/plivo/plivo-dotnet/tree/v5.48.1) (2024-09-06)
**Feature - Adding more attribute on mdr object**
- Added `message_sent_time`, `message_updated_time` and `error-message` on get and list Message API
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.48.1
PM> Install-Package Plivo -Version 5.49.0
```

You can also use the .NET CLI to install this package as follows

```
> dotnet add package Plivo --version 5.48.1
> dotnet add package Plivo --version 5.49.0
```

## Getting started
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.48.1</ReleaseVersion>
<ReleaseVersion>5.49.0</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.48.1</version>
<version>5.49.0</version>
<title>Plivo</title>
<authors>Plivo SDKs Team</authors>
<owners>Plivo, Inc.</owners>
Expand Down
8 changes: 4 additions & 4 deletions src/Plivo/Resource/MaskingSession/MaskingSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,29 @@ public async Task<AsyncResponse> DeleteAsync(string Id)


#region Update
public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, uint? session_expiry = null, uint? call_time_limit = null,
public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, string first_party = null, string second_party = null, uint? session_expiry = null, uint? call_time_limit = null,
bool? record = null, string record_file_format = null, string recording_callback_url = null, string callback_url = null,
string callback_method = null, uint? ring_timeout = null, string first_party_play_url = null, string second_party_play_url = null,
string recording_callback_method = null, string subaccount = null, bool? geomatch = null
)
{
var updateResponse =
((MaskingSessionInterface) Interface)
.Update(Id, session_expiry, call_time_limit, record, record_file_format, recording_callback_url, callback_url,
.Update(Id, first_party, second_party, session_expiry, call_time_limit, record, record_file_format, recording_callback_url, callback_url,
callback_method, ring_timeout, first_party_play_url, second_party_play_url, recording_callback_method,
subaccount, geomatch);
return updateResponse;
}

public async Task<AsyncResponse> UpdateAsync(string sessionUuid, uint? session_expiry = null, uint? call_time_limit = null,
public async Task<AsyncResponse> UpdateAsync(string sessionUuid, string first_party = null, string second_party = null, uint? session_expiry = null, uint? call_time_limit = null,
bool? record = null, string record_file_format = null, string recording_callback_url = null, string callback_url = null,
string callback_method = null, uint? ring_timeout = null, string first_party_play_url = null, string second_party_play_url = null,
string recording_callback_method = null, string subaccount = null, bool? geomatch = null
)
{
var updateResponse = await
((MaskingSessionInterface)Interface)
.UpdateAsync(Id, session_expiry, call_time_limit, record, record_file_format, recording_callback_url, callback_url,
.UpdateAsync(Id, first_party, second_party, session_expiry, call_time_limit, record, record_file_format, recording_callback_url, callback_url,
callback_method, ring_timeout, first_party_play_url, second_party_play_url, recording_callback_method,
subaccount, geomatch);

Expand Down
34 changes: 22 additions & 12 deletions src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ public MaskingSessionInterface(HttpClient client) : base(client)

#region Create
public MaskingSessionCreateResponse Create(
string firstParty, string secondParty, uint? sessionExpiry = null, uint? callTimeLimit = null,
string firstParty = null, string secondParty = null, uint? sessionExpiry = null, uint? callTimeLimit = null,
bool? record = null, string recordFileFormat = null, string recordingCallbackUrl = null, bool? initiateCallToFirstParty = null,
string callbackUrl = null, string callbackMethod = null, uint? ringTimeout = null, string firstPartyPlayUrl = null,
string secondPartyPlayUrl = null, string recordingCallbackMethod = null, bool? isPinAuthenticationRequired = null,
bool? generatePin = null, uint? generatePinLength = null, string firstPartyPin = null, string secondPartyPin = null,
string pinPromptPlay = null, uint? pinRetry = null, uint? pinRetryWait = null, string incorrectPinPlay = null,
string unknownCallerPlay = null, string subaccount = null, bool? geomatch = null
string unknownCallerPlay = null, string subaccount = null, bool? geomatch = null, bool? forcePinAuthentication = null,
bool? createSessionWithSingleParty= null, uint? virtualNumberCooloffPeriod = 0
)
{
var mandatoryParams = new List<string> { "firstParty", "secondParty" };
var mandatoryParams = new List<string> { };
bool isVoiceRequest = true;
var data = CreateData(
mandatoryParams,
Expand Down Expand Up @@ -56,7 +57,10 @@ public MaskingSessionCreateResponse Create(
unknownCallerPlay,
subaccount,
geomatch,
isVoiceRequest
isVoiceRequest,
forcePinAuthentication,
createSessionWithSingleParty,
virtualNumberCooloffPeriod
});

return ExecuteWithExceptionUnwrap(() =>
Expand All @@ -68,16 +72,17 @@ public MaskingSessionCreateResponse Create(
}

public async Task<AsyncResponse> CreateAsync(
string firstParty, string secondParty, uint? sessionExpiry = null, uint? callTimeLimit = null,
string firstParty = null, string secondParty = null, uint? sessionExpiry = null, uint? callTimeLimit = null,
bool? record = null, string recordFileFormat = null, string recordingCallbackUrl = null, bool? initiateCallToFirstParty = null,
string callbackUrl = null, string callbackMethod = null, uint? ringTimeout = null, string firstPartyPlayUrl = null,
string secondPartyPlayUrl = null, string recordingCallbackMethod = null, bool? isPinAuthenticationRequired = null,
bool? generatePin = null, uint? generatePinLength = null, string firstPartyPin = null, string secondPartyPin = null,
string pinPromptPlay = null, uint? pinRetry = null, uint? pinRetryWait = null, string incorrectPinPlay = null,
string unknownCallerPlay = null, string subaccount = null, bool? geomatch = null
string unknownCallerPlay = null, string subaccount = null, bool? geomatch = null, bool? forcePinAuthentication = null,
bool? createSessionWithSingleParty= null, uint? virtualNumberCooloffPeriod = 0
)
{
var mandatoryParams = new List<string> { "firstParty", "secondParty" };
var mandatoryParams = new List<string> { };
bool isVoiceRequest = true;
var data = CreateData(
mandatoryParams,
Expand Down Expand Up @@ -109,7 +114,10 @@ public async Task<AsyncResponse> CreateAsync(
unknownCallerPlay,
subaccount,
geomatch,
isVoiceRequest
isVoiceRequest,
forcePinAuthentication,
createSessionWithSingleParty,
virtualNumberCooloffPeriod
});

var result = Task.Run(async () => await Client.Update<AsyncResponse>(Uri, data).ConfigureAwait(false)).Result;
Expand Down Expand Up @@ -278,7 +286,7 @@ public async Task<AsyncResponse> DeleteAsync(string sessionUuid)


#region Update
public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, uint? sessionExpiry = null, uint? callTimeLimit = null,
public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, string first_party = null, string second_party = null, uint? sessionExpiry = null, uint? callTimeLimit = null,
bool? record = null, string recordFileFormat = null, string recordingCallbackUrl = null, string callbackUrl = null,
string callbackMethod = null, uint? ringTimeout = null, string firstPartyPlayUrl = null, string secondPartyPlayUrl = null,
string recordingCallbackMethod = null, string subaccount = null, bool? geomatch = null
Expand All @@ -289,7 +297,8 @@ public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, u
var data = CreateData(
mandatoryParams,
new
{
{ first_party,
second_party,
sessionExpiry,
callTimeLimit,
record,
Expand All @@ -316,7 +325,7 @@ public MaskingSessionUpdateResponse<MaskingSession> Update(string sessionUuid, u
});
}

public async Task<AsyncResponse> UpdateAsync(string sessionUuid, uint? sessionExpiry = null, uint? callTimeLimit = null,
public async Task<AsyncResponse> UpdateAsync(string sessionUuid, string first_party = null, string second_party = null, uint? sessionExpiry = null, uint? callTimeLimit = null,
bool? record = null, string recordFileFormat = null, string recordingCallbackUrl = null, string callbackUrl = null,
string callbackMethod = null, uint? ringTimeout = null, string firstPartyPlayUrl = null, string secondPartyPlayUrl = null,
string recordingCallbackMethod = null, string subaccount = null, bool? geomatch = null
Expand All @@ -327,7 +336,8 @@ public async Task<AsyncResponse> UpdateAsync(string sessionUuid, uint? sessionEx
var data = CreateData(
mandatoryParams,
new
{
{ first_party,
second_party,
sessionExpiry,
callTimeLimit,
record,
Expand Down
7 changes: 5 additions & 2 deletions src/Plivo/Resource/ResourceInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ public static Dictionary<string, object> CreateData (List<string> propertyInfos,
var dict = new Dictionary<string, object> ();
foreach (PropertyInfo pi in data.GetType ().GetProperties ()) {
if (propertyInfos.Contains (pi.Name)) {
if (string.IsNullOrEmpty (pi.GetValue (data)))
throw new PlivoValidationException (pi.Name + " is mandatory, can not be null or empty");
var propertyValue = pi.GetValue(data);
if (pi.Name != "firstParty" && pi.Name != "secondParty" && string.IsNullOrEmpty(propertyValue))
throw new PlivoValidationException(pi.Name + " is mandatory, can not be null or empty");
JayaBharat-plivo marked this conversation as resolved.
Show resolved Hide resolved
}



if (pi.Name.Equals ("limit")) {
if (pi.GetValue (data) > 20) {
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.48.1";
public const string SdkVersion = "5.49.0";
/// <summary>
/// Plivo API version
/// </summary>
Expand Down
48 changes: 48 additions & 0 deletions tests/Plivo.Test/Mocks/maskingSessionCreateResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"api_id": "e0218e45-53f5-435b-83d2-936010e40acc",
"session_uuid": "1091db69-2290-4633-9222-c9473c4815b6",
"virtual_number": "+919988776676",
"message": "Session created",
"session": {
"first_party": "916303955747",
"second_party": "916384780853",
"virtual_number": "919988776676",
"status": "active",
"initiate_call_to_first_party": false,
"session_uuid": "1091db69-2290-4633-9222-c9473c4815b6",
"callback_url": "",
"callback_method": "POST",
"created_time": "2024-09-05 06:43:26 +0000 UTC",
"modified_time": "2024-09-05 06:43:26 +0000 UTC",
"expiry_time": "2024-09-05 06:46:46 +0000 UTC",
"duration": 200,
"amount": 0,
"call_time_limit": 14400,
"ring_timeout": 45,
"first_party_play_url": "",
"second_party_play_url": "",
"record": false,
"record_file_format": "mp3",
"recording_callback_url": "",
"recording_callback_method": "POST",
"interaction": null,
"total_call_amount": 0,
"total_call_count": 0,
"total_call_billed_duration": 0,
"total_session_amount": 0,
"last_interaction_time": "",
"unknown_caller_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"is_pin_authentication_required": true,
"generate_pin": false,
"generate_pin_length": 4,
"first_party_pin": "1234",
"second_party_pin": "4321",
"pin_prompt_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"pin_retry": 2,
"pin_retry_wait": 7,
"incorrect_pin_play": "https://file-examples.com/storage/fefda3519566d3360a0efb3/2017/11/file_example_MP3_700KB.mp3",
"create_session_with_single_party": null,
"virtual_number_cooloff_period": 3500,
"force_pin_authentication": true
}
}
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "5.48.1",
"version": "5.49.0",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/heads/v\\d+(?:\\.\\d+)?$"
Expand Down
Loading