From 4d7d62f7df2fa6003225af9592c7a1a66b9103d1 Mon Sep 17 00:00:00 2001 From: Alex K Date: Fri, 21 Dec 2018 16:38:56 +0200 Subject: [PATCH 1/2] Fixed dynamic object usage with async/await statement --- src/Plivo/Client/SystemHttpClient.cs | 2 +- .../Resource/Message/MessageInterface.cs | 87 +++++++++++++++++-- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/src/Plivo/Client/SystemHttpClient.cs b/src/Plivo/Client/SystemHttpClient.cs index b463cf84..365c3175 100644 --- a/src/Plivo/Client/SystemHttpClient.cs +++ b/src/Plivo/Client/SystemHttpClient.cs @@ -208,7 +208,7 @@ public async Task> SendRequest(string method, string uri, Di response = await _client.SendAsync(request); - var responseContent = response.Content.ReadAsStringAsync().Result; + var responseContent = await response.Content.ReadAsStringAsync(); // create Plivo response object along with the deserialized object PlivoResponse plivoResponse; diff --git a/src/Plivo/Resource/Message/MessageInterface.cs b/src/Plivo/Resource/Message/MessageInterface.cs index 8154829e..8ea96d71 100644 --- a/src/Plivo/Resource/Message/MessageInterface.cs +++ b/src/Plivo/Resource/Message/MessageInterface.cs @@ -42,7 +42,7 @@ public MessageCreateResponse Create( { string _dst = string.Join("<", dst); - var data = (dynamic)null; + Dictionary data = null; var mandatoryParams = new List {""}; if (src != null && powerpack_uuid == null){ data = CreateData( @@ -83,15 +83,84 @@ public MessageCreateResponse Create( var result = Client.Update(Uri, data).Result; return result.Object; } - #endregion - #region getResponseValidation - /// - /// validation for src and powerpack id and return the repsonse. - /// - /// The get. - /// errormessagetext - private MessageCreateResponse getResponseValidation(string errorMessageText){ + /// + /// Asynchronously Create Message with the specified src, dst, text, type, url, method and log. + /// + /// The create. + /// Source. + /// Dst. + /// Text. + /// Type. + /// URL. + /// Method. + /// Log. + /// trackable. + /// powerpackUUID + public async Task CreateAsync( + List dst, string text, string src = null, string type = null, + string url = null, string method = null, bool? log = null, bool? trackable = null, string powerpack_uuid = null) + { + + string _dst = string.Join("<", dst); + Dictionary data = null; + var mandatoryParams = new List { "" }; + if (src != null && powerpack_uuid == null) + { + data = CreateData( + mandatoryParams, + new + { + src, + _dst, + text, + type, + url, + method, + log, + trackable + }); + } + else if (powerpack_uuid != null && src == null) + { + data = CreateData( + mandatoryParams, + new + { + powerpack_uuid, + _dst, + text, + type, + url, + method, + log, + trackable + }); + + + } + else if (src != null && powerpack_uuid != null) + { + return getResponseValidation("Both powerpack_uuid and src cannot be specified. Specify either powerpack_uuid or src in request params to send a message."); + } + else if (src == null && powerpack_uuid == null) + { + return getResponseValidation("Specify either powerpack_uuid or src in request params to send a message."); + } + + var result = await Client.Update(Uri, data); + return result.Object; + } + + #endregion + + #region getResponseValidation + /// + /// validation for src and powerpack id and return the repsonse. + /// + /// The get. + /// errormessagetext + private MessageCreateResponse getResponseValidation(string errorMessageText){ MessageCreateResponse notValidResponse = new MessageCreateResponse(); notValidResponse.ApiId = null; From 3786eaadfaf899d0423793e22c614aed7f5e50d6 Mon Sep 17 00:00:00 2001 From: suresach Date: Thu, 27 Dec 2018 16:33:52 +0530 Subject: [PATCH 2/2] bump version to 4.2.2 --- CHANGELOG.md | 4 ++++ src/Plivo/Plivo.csproj | 2 +- src/Plivo/Plivo.nuspec | 3 ++- src/Plivo/Version.cs | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef62891..019a346a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ + # Change Log +## [v4.2.2](https://github.com/plivo/plivo-dotnet/tree/v4.2.2) (2018-12-27) +- Fix dynamic object usage with async/await statement. + ## [v4.2.1](https://github.com/plivo/plivo-dotnet/tree/v4.2.1) (2018-12-13) - Fix Web Proxy Support. diff --git a/src/Plivo/Plivo.csproj b/src/Plivo/Plivo.csproj index 7caffb88..0059e546 100644 --- a/src/Plivo/Plivo.csproj +++ b/src/Plivo/Plivo.csproj @@ -2,7 +2,7 @@ netstandard2.0;netstandard1.3 - 4.2.1 + 4.2.2 Plivo SDKs Team Plivo Inc. diff --git a/src/Plivo/Plivo.nuspec b/src/Plivo/Plivo.nuspec index 2442551d..501bcf0c 100644 --- a/src/Plivo/Plivo.nuspec +++ b/src/Plivo/Plivo.nuspec @@ -4,7 +4,7 @@ A .NET SDK to make voice calls & send SMS using Plivo and to generate Plivo XML A .NET SDK to make voice calls & send SMS using Plivo and to generate Plivo XML Plivo - 4.2.1 + 4.2.2 Plivo Plivo SDKs Team Plivo, Inc. @@ -12,6 +12,7 @@ http://github.com/plivo/plivo-dotnet false + * 4.2.2 Fix dynamic object usage with async/await statement. * 4.2.1 Fix Web Proxy support. * 4.2.0 Changed base reference to .NET Standard 2.0 to support System.Web.Proxy. Added Strong Naming instructions * 4.1.7 Add hangup party details to CDR. CDR filtering allowed by hangup_source and hangup_cause_code. diff --git a/src/Plivo/Version.cs b/src/Plivo/Version.cs index b53c4ef2..3fd85cce 100644 --- a/src/Plivo/Version.cs +++ b/src/Plivo/Version.cs @@ -10,7 +10,7 @@ public class Version /// /// DotNet SDK version /// - public const string SdkVersion = "4.2.1"; + public const string SdkVersion = "4.2.2"; /// /// Plivo API version