Skip to content

Commit

Permalink
Added the changes for sending null second party/first party.
Browse files Browse the repository at this point in the history
  • Loading branch information
JayaBharat-plivo committed Sep 17, 2024
1 parent 95edd57 commit dd5fd95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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,
Expand All @@ -25,7 +25,7 @@ public MaskingSessionCreateResponse Create(
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 @@ -72,7 +72,7 @@ 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,
Expand All @@ -82,7 +82,7 @@ public async Task<AsyncResponse> CreateAsync(
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
14 changes: 4 additions & 10 deletions src/Plivo/Resource/ResourceInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,17 +208,11 @@ 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(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");
}

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");
}



if (pi.Name.Equals ("limit")) {
Expand Down

0 comments on commit dd5fd95

Please sign in to comment.