From dd5fd95aebd71804cd8b09e2cc446191e0d976e6 Mon Sep 17 00:00:00 2001 From: JayaBharat-plivo Date: Tue, 17 Sep 2024 12:49:45 +0530 Subject: [PATCH] Added the changes for sending null second party/first party. --- .../MaskingSession/MaskingSessionInterface.cs | 8 ++++---- src/Plivo/Resource/ResourceInterface.cs | 14 ++++---------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs b/src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs index cabce3c7..ddb1646d 100644 --- a/src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs +++ b/src/Plivo/Resource/MaskingSession/MaskingSessionInterface.cs @@ -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, @@ -25,7 +25,7 @@ public MaskingSessionCreateResponse Create( bool? createSessionWithSingleParty= null, uint? virtualNumberCooloffPeriod = 0 ) { - var mandatoryParams = new List { "firstParty", "secondParty" }; + var mandatoryParams = new List { }; bool isVoiceRequest = true; var data = CreateData( mandatoryParams, @@ -72,7 +72,7 @@ public MaskingSessionCreateResponse Create( } public async Task 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, @@ -82,7 +82,7 @@ public async Task CreateAsync( bool? createSessionWithSingleParty= null, uint? virtualNumberCooloffPeriod = 0 ) { - var mandatoryParams = new List { "firstParty", "secondParty" }; + var mandatoryParams = new List { }; bool isVoiceRequest = true; var data = CreateData( mandatoryParams, diff --git a/src/Plivo/Resource/ResourceInterface.cs b/src/Plivo/Resource/ResourceInterface.cs index 108fecfa..417eeb39 100755 --- a/src/Plivo/Resource/ResourceInterface.cs +++ b/src/Plivo/Resource/ResourceInterface.cs @@ -208,17 +208,11 @@ public static Dictionary CreateData (List propertyInfos, var dict = new Dictionary (); 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")) {