Skip to content

Commit

Permalink
Added changes for single party session
Browse files Browse the repository at this point in the history
  • Loading branch information
JayaBharat-plivo committed Sep 12, 2024
1 parent 8efb708 commit 836290e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
16 changes: 12 additions & 4 deletions src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public MaskingSessionCreateResponse Create(
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" };
Expand Down Expand Up @@ -56,7 +57,10 @@ public MaskingSessionCreateResponse Create(
unknownCallerPlay,
subaccount,
geomatch,
isVoiceRequest
isVoiceRequest,
forcePinAuthentication,
createSessionWithSingleParty,
virtualNumberCooloffPeriod
});

return ExecuteWithExceptionUnwrap(() =>
Expand All @@ -74,7 +78,8 @@ public async Task<AsyncResponse> CreateAsync(
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" };
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
13 changes: 11 additions & 2 deletions src/Plivo/Resource/ResourceInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,19 @@ 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");
if(pi.Name == "firstParty" || pi.Name == "secondParty"){
if(pi.GetValue (data) == null){
throw new PlivoValidationException (pi.Name + "can not be null");
}
}
else{
if (string.IsNullOrEmpty (pi.GetValue (data)))
throw new PlivoValidationException (pi.Name + " is mandatory, can not be null or empty");
}

}


if (pi.Name.Equals ("limit")) {
if (pi.GetValue (data) > 20) {
throw new PlivoValidationException ("limit:" + pi.GetValue (data) + " is out of range [0,20]");
Expand Down

0 comments on commit 836290e

Please sign in to comment.