From ecccc06cbe6858494a82cf042caf14c7eef84866 Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:25:25 +0200 Subject: [PATCH 1/6] Flag sync methods as obsolete for AccountClient --- Vonage/Accounts/AccountClient.cs | 113 ++++++++++++++++++------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/Vonage/Accounts/AccountClient.cs b/Vonage/Accounts/AccountClient.cs index 0135c486e..96025c989 100644 --- a/Vonage/Accounts/AccountClient.cs +++ b/Vonage/Accounts/AccountClient.cs @@ -26,6 +26,7 @@ internal AccountClient(Credentials creds, Configuration configuration, ITimeProv } /// + [Obsolete("Favor asynchronous version instead.")] public AccountSettingsResult ChangeAccountSettings(AccountSettingsRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoPostRequestUrlContentFromObject @@ -45,23 +46,26 @@ public Task ChangeAccountSettingsAsync(AccountSettingsReq ); /// + [Obsolete("Favor asynchronous version instead.")] public Secret CreateApiSecret(CreateSecretRequest request, string apiKey = null, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), + request, + AuthType.Basic + ); /// public Task CreateApiSecretAsync(CreateSecretRequest request, string apiKey = null, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets"), + request, + AuthType.Basic + ); /// [Obsolete("Use SubAccountsClient instead.")] @@ -70,12 +74,13 @@ public SubAccount CreateSubAccount(CreateSubAccountRequest request, string apiKe { var credentials = this.GetCredentials(creds); var accountId = apiKey ?? credentials.ApiKey; - return ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{accountId}/subaccounts"), - request, - AuthType.Basic - ); + return ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{accountId}/subaccounts"), + request, + AuthType.Basic + ); } /// @@ -95,32 +100,39 @@ public Task CreateSubAccountAsync(CreateSubAccountRequest request, s } /// + [Obsolete("Favor asynchronous version instead.")] public Balance GetAccountBalance(Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUriFor("/account/get-balance"), - AuthType.Query); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUriFor("/account/get-balance"), + AuthType.Query); /// public Task GetAccountBalanceAsync(Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUriFor("/account/get-balance"), - AuthType.Query); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUriFor("/account/get-balance"), + AuthType.Query); /// + [Obsolete("Favor asynchronous version instead.")] public Secret RetrieveApiSecret(string secretId, string apiKey = null, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), + AuthType.Basic + ); /// public Task RetrieveApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), + AuthType.Basic + ); /// + [Obsolete("Favor asynchronous version instead.")] public SecretsRequestResult RetrieveApiSecrets(string apiKey = null, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoGetRequestWithQueryParameters( @@ -164,34 +176,39 @@ public Task RetrieveSubAccountAsync(string subAccountKey, string api } /// + [Obsolete("Favor asynchronous version instead.")] public bool RevokeApiSecret(string secretId, string apiKey = null, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoDeleteRequestWithUrlContent( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), - null, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoDeleteRequestWithUrlContent( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), + null, + AuthType.Basic + ); return true; } - + /// public async Task RevokeApiSecretAsync(string secretId, string apiKey = null, Credentials creds = null) { - await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoDeleteRequestWithUrlContentAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), - null, - AuthType.Basic - ); + await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoDeleteRequestWithUrlContentAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/accounts/{apiKey}/secrets/{secretId}"), + null, + AuthType.Basic + ); return true; } /// + [Obsolete("Favor asynchronous version instead.")] public TopUpResult TopUpAccountBalance(TopUpRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUriFor("/account/top-up"), - AuthType.Query, - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUriFor("/account/top-up"), + AuthType.Query, + request + ); /// public Task TopUpAccountBalanceAsync(TopUpRequest request, Credentials creds = null) => From 67f749f7c26502b312c5b47bf245aa0a079104f2 Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:28:22 +0200 Subject: [PATCH 2/6] Flag sync methods (and CreateApplication typo) as obsolete for ApplicationClient --- Vonage/Applications/ApplicationClient.cs | 100 ++++++++++++++-------- Vonage/Applications/IApplicationClient.cs | 52 ++++++----- 2 files changed, 92 insertions(+), 60 deletions(-) diff --git a/Vonage/Applications/ApplicationClient.cs b/Vonage/Applications/ApplicationClient.cs index 5b8426bd9..5ab685d85 100644 --- a/Vonage/Applications/ApplicationClient.cs +++ b/Vonage/Applications/ApplicationClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Threading.Tasks; using Vonage.Common; @@ -25,51 +26,70 @@ internal ApplicationClient(Credentials credentials, Configuration configuration, } /// + [Obsolete("Favor asynchronous version instead.")] public Application CreateApplicaiton(CreateApplicationRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v2/applications"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v2/applications"), + request, + AuthType.Basic + ); /// + [Obsolete("Favor typo-free method instead.")] public Task CreateApplicaitonAsync(CreateApplicationRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v2/applications"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v2/applications"), + request, + AuthType.Basic + ); + + /// + public Task CreateApplicationAsync(CreateApplicationRequest request, Credentials creds = null) => + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v2/applications"), + request, + AuthType.Basic + ); /// + [Obsolete("Favor asynchronous version instead.")] public bool DeleteApplication(string id, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoDeleteRequestWithUrlContent( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), - null, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoDeleteRequestWithUrlContent( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), + null, + AuthType.Basic + ); return true; } /// public async Task DeleteApplicationAsync(string id, Credentials creds = null) { - await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoDeleteRequestWithUrlContentAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), - null, - AuthType.Basic - ); + await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoDeleteRequestWithUrlContentAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), + null, + AuthType.Basic + ); return true; } /// + [Obsolete("Favor asynchronous version instead.")] public Application GetApplication(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), + AuthType.Basic + ); /// public Task GetApplicationAsync(string id, Credentials creds = null) => @@ -80,6 +100,7 @@ public Task GetApplicationAsync(string id, Credentials creds = null ); /// + [Obsolete("Favor asynchronous version instead.")] public ApplicationPage ListApplications(ListApplicationsRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoGetRequestWithQueryParameters( @@ -98,23 +119,26 @@ public Task ListApplicationsAsync(ListApplicationsRequest reque ); /// + [Obsolete("Favor asynchronous version instead.")] public Application UpdateApplication(string id, CreateApplicationRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), + request, + AuthType.Basic + ); /// public Task UpdateApplicationAsync(string id, CreateApplicationRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"/v2/applications/{id}"), + request, + AuthType.Basic + ); private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; } \ No newline at end of file diff --git a/Vonage/Applications/IApplicationClient.cs b/Vonage/Applications/IApplicationClient.cs index 6166457b3..93cfaf463 100644 --- a/Vonage/Applications/IApplicationClient.cs +++ b/Vonage/Applications/IApplicationClient.cs @@ -11,32 +11,31 @@ public interface IApplicationClient /// /// /// - Task CreateApplicaitonAsync(CreateApplicationRequest request, Credentials creds = null); + Application CreateApplicaiton(CreateApplicationRequest request, Credentials creds = null); /// - /// List applications + /// Application Name /// /// /// /// - Task ListApplicationsAsync(ListApplicationsRequest request, Credentials creds = null); + Task CreateApplicaitonAsync(CreateApplicationRequest request, Credentials creds = null); /// - /// Retrieves information about an application + /// Creates a new application. /// - /// Id of the application to be retrieved - /// - /// - Task GetApplicationAsync(string id, Credentials creds = null); + /// The request. + /// Optional credentials. + /// The application. + Task CreateApplicationAsync(CreateApplicationRequest request, Credentials creds = null); /// - /// Updates an Application + /// Deletes an application: Cannot be undone /// - /// Id of the application to be updated - /// + /// Id of the application to be deleted /// /// - Task UpdateApplicationAsync(string id, CreateApplicationRequest request, Credentials creds = null); + bool DeleteApplication(string id, Credentials creds = null); /// /// Deletes an application: Cannot be undone @@ -44,15 +43,23 @@ public interface IApplicationClient /// Id of the application to be deleted /// /// - Task DeleteApplicationAsync(string id, Credentials creds = null); + Task DeleteApplicationAsync(string id, Credentials creds = null); /// - /// Application Name + /// Retrieves information about an application /// - /// + /// Id of the application to be retrieved /// /// - Application CreateApplicaiton(CreateApplicationRequest request, Credentials creds = null); + Application GetApplication(string id, Credentials creds = null); + + /// + /// Retrieves information about an application + /// + /// Id of the application to be retrieved + /// + /// + Task GetApplicationAsync(string id, Credentials creds = null); /// /// List applications @@ -63,12 +70,12 @@ public interface IApplicationClient ApplicationPage ListApplications(ListApplicationsRequest request, Credentials creds = null); /// - /// Retrieves information about an application + /// List applications /// - /// Id of the application to be retrieved + /// /// /// - Application GetApplication(string id, Credentials creds = null); + Task ListApplicationsAsync(ListApplicationsRequest request, Credentials creds = null); /// /// Updates an Application @@ -80,10 +87,11 @@ public interface IApplicationClient Application UpdateApplication(string id, CreateApplicationRequest request, Credentials creds = null); /// - /// Deletes an application: Cannot be undone + /// Updates an Application /// - /// Id of the application to be deleted + /// Id of the application to be updated + /// /// /// - bool DeleteApplication(string id, Credentials creds = null); + Task UpdateApplicationAsync(string id, CreateApplicationRequest request, Credentials creds = null); } \ No newline at end of file From 93d2102b37403a8823373f6cbda7537e987c0a4e Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:28:56 +0200 Subject: [PATCH 3/6] Flag sync methods as obsolete --- Vonage/Conversions/ConversionClient.cs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/Vonage/Conversions/ConversionClient.cs b/Vonage/Conversions/ConversionClient.cs index c6b853842..6952a5030 100644 --- a/Vonage/Conversions/ConversionClient.cs +++ b/Vonage/Conversions/ConversionClient.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -24,13 +25,15 @@ internal ConversionClient(Credentials credentials, Configuration configuration, } /// + [Obsolete("Favor asynchronous version instead.")] public bool SmsConversion(ConversionRequest request, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoPostRequestUrlContentFromObject - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/conversions/sms"), - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoPostRequestUrlContentFromObject + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/conversions/sms"), + request + ); return true; } @@ -47,13 +50,15 @@ await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.time } /// + [Obsolete("Favor asynchronous version instead.")] public bool VoiceConversion(ConversionRequest request, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoPostRequestUrlContentFromObject - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/conversions/voice"), - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoPostRequestUrlContentFromObject + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/conversions/voice"), + request + ); return true; } From 0af912e2faf645dec88d3db4d4acd4f40bdb151f Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:30:05 +0200 Subject: [PATCH 4/6] Flag sync methods as obsolete --- Vonage/Messaging/SmsClient.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Vonage/Messaging/SmsClient.cs b/Vonage/Messaging/SmsClient.cs index c6854f040..d54d616bd 100644 --- a/Vonage/Messaging/SmsClient.cs +++ b/Vonage/Messaging/SmsClient.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -24,6 +25,7 @@ internal SmsClient(Credentials credentials, Configuration configuration, ITimePr } /// + [Obsolete("Favor asynchronous version instead.")] public SendSmsResponse SendAnSms(SendSmsRequest request, Credentials creds = null) { var result = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -36,9 +38,10 @@ public SendSmsResponse SendAnSms(SendSmsRequest request, Credentials creds = nul } /// + [Obsolete("Favor asynchronous version instead.")] public SendSmsResponse SendAnSms(string from, string to, string text, SmsType type = SmsType.Text, Credentials creds = null) => - this.SendAnSms(new SendSmsRequest {From = from, To = to, Type = type, Text = text}, creds); + this.SendAnSms(new SendSmsRequest { From = from, To = to, Type = type, Text = text }, creds); /// /// Send a SMS message. @@ -61,7 +64,7 @@ public async Task SendAnSmsAsync(SendSmsRequest request, Creden /// public Task SendAnSmsAsync(string from, string to, string text, SmsType type = SmsType.Text, Credentials creds = null) => - this.SendAnSmsAsync(new SendSmsRequest {From = from, To = to, Type = type, Text = text}, creds); + this.SendAnSmsAsync(new SendSmsRequest { From = from, To = to, Type = type, Text = text }, creds); private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; @@ -76,7 +79,7 @@ private static void ValidSmsResponse(SendSmsResponse smsResponse) { throw new VonageSmsResponseException( $"SMS Request Failed with status: {smsResponse.Messages[0].Status} and error message: {smsResponse.Messages[0].ErrorText}") - {Response = smsResponse}; + { Response = smsResponse }; } } } \ No newline at end of file From 0d21dd1cc2cb6eeb854661d149d37a2c7b4b32e6 Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:31:59 +0200 Subject: [PATCH 5/6] Flag sync methods as obsolete --- Vonage/NumberInsights/NumberInsightClient.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Vonage/NumberInsights/NumberInsightClient.cs b/Vonage/NumberInsights/NumberInsightClient.cs index 1ed5b0032..642dd3127 100644 --- a/Vonage/NumberInsights/NumberInsightClient.cs +++ b/Vonage/NumberInsights/NumberInsightClient.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -24,6 +25,7 @@ internal NumberInsightClient(Credentials credentials, Configuration configuratio } /// + [Obsolete("Favor asynchronous version instead.")] public AdvancedInsightsResponse GetNumberInsightAdvanced(AdvancedNumberInsightRequest request, Credentials creds = null) { @@ -52,6 +54,7 @@ public async Task GetNumberInsightAdvancedAsync(Advanc } /// + [Obsolete("Favor asynchronous version instead.")] public AdvancedInsightsAsynchronousResponse GetNumberInsightAsynchronous( AdvancedNumberInsightAsynchronousRequest request, Credentials creds = null) { @@ -80,6 +83,7 @@ public async Task GetNumberInsightAsynchro } /// + [Obsolete("Favor asynchronous version instead.")] public BasicInsightResponse GetNumberInsightBasic(BasicNumberInsightRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -107,6 +111,7 @@ public async Task GetNumberInsightBasicAsync(BasicNumberIn } /// + [Obsolete("Favor asynchronous version instead.")] public StandardInsightResponse GetNumberInsightStandard(StandardNumberInsightRequest request, Credentials creds = null) { @@ -143,11 +148,11 @@ public void ValidateNumberInsightResponse(NumberInsightResponseBase response) case AdvancedInsightsAsynchronousResponse asyncResponse: throw new VonageNumberInsightResponseException( $"Advanced Insights Async response failed with status: {asyncResponse.Status}") - {Response = response}; + { Response = response }; case BasicInsightResponse basicInsightResponse: throw new VonageNumberInsightResponseException( $"Number insight request failed with status: {basicInsightResponse.Status} and error message: {basicInsightResponse.StatusMessage}") - {Response = response}; + { Response = response }; } } } From 23210df2c328d54799ca6e38bf47db50ea17468c Mon Sep 17 00:00:00 2001 From: Guillaume Faas Date: Tue, 17 Oct 2023 08:36:46 +0200 Subject: [PATCH 6/6] Flag sync methods as obsolete --- Vonage/Numbers/NumbersClient.cs | 7 + Vonage/Pricing/PricingClient.cs | 54 +++--- Vonage/Redaction/RedactClient.cs | 36 ++-- Vonage/ShortCodes/ShortCodesClient.cs | 81 +++++---- Vonage/Verify/VerifyClient.cs | 8 +- Vonage/Voice/VoiceClient.cs | 240 +++++++++++++++----------- 6 files changed, 247 insertions(+), 179 deletions(-) diff --git a/Vonage/Numbers/NumbersClient.cs b/Vonage/Numbers/NumbersClient.cs index b9c636a14..77aaac05c 100644 --- a/Vonage/Numbers/NumbersClient.cs +++ b/Vonage/Numbers/NumbersClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Threading.Tasks; using Vonage.Common; @@ -35,6 +36,7 @@ internal NumbersClient(Credentials credentials, Configuration configuration, ITi } /// + [Obsolete("Favor asynchronous version instead.")] public NumberTransactionResponse BuyANumber(NumberTransactionRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -64,6 +66,7 @@ public async Task BuyANumberAsync(NumberTransactionRe } /// + [Obsolete("Favor asynchronous version instead.")] public NumberTransactionResponse CancelANumber(NumberTransactionRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -93,6 +96,7 @@ public async Task CancelANumberAsync(NumberTransactio } /// + [Obsolete("Favor asynchronous version instead.")] public NumbersSearchResponse GetAvailableNumbers(NumberSearchRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoGetRequestWithQueryParameters( @@ -112,6 +116,7 @@ public Task GetAvailableNumbersAsync(NumberSearchRequest ); /// + [Obsolete("Favor asynchronous version instead.")] public NumbersSearchResponse GetOwnedNumbers(NumberSearchRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoGetRequestWithQueryParameters( @@ -131,6 +136,7 @@ public Task ); /// + [Obsolete("Favor asynchronous version instead.")] public NumberTransferResponse TransferANumber(NumberTransferRequest request, string apiKey, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -153,6 +159,7 @@ public Task TransferANumberAsync(NumberTransferRequest r ); /// + [Obsolete("Favor asynchronous version instead.")] public NumberTransactionResponse UpdateANumber(UpdateNumberRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) diff --git a/Vonage/Pricing/PricingClient.cs b/Vonage/Pricing/PricingClient.cs index cbf593233..353830024 100644 --- a/Vonage/Pricing/PricingClient.cs +++ b/Vonage/Pricing/PricingClient.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -24,13 +25,15 @@ internal PricingClient(Credentials credentials, Configuration configuration, ITi } /// + [Obsolete("Favor asynchronous version instead.")] public PricingResult RetrievePrefixPricing(string type, PricingPrefixRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-prefix-pricing/outbound/{type}"), - AuthType.Query, - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-prefix-pricing/outbound/{type}"), + AuthType.Query, + request + ); /// public Task RetrievePrefixPricingAsync(string type, PricingPrefixRequest request, @@ -44,12 +47,14 @@ public Task RetrievePrefixPricingAsync(string type, PricingPrefix ); /// + [Obsolete("Favor asynchronous version instead.")] public PricingResult RetrievePricingAllCountries(string type, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), - AuthType.Query - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), + AuthType.Query + ); /// public Task RetrievePricingAllCountriesAsync(string type, Credentials creds = null) => @@ -61,23 +66,26 @@ public Task RetrievePricingAllCountriesAsync(string type, Credent ); /// + [Obsolete("Favor asynchronous version instead.")] public Country RetrievePricingCountry(string type, PricingCountryRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), - AuthType.Query, - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), + AuthType.Query, + request + ); /// public Task RetrievePricingCountryAsync(string type, PricingCountryRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync - ( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), - AuthType.Query, - request - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync + ( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, $"/account/get-pricing/outbound/{type}"), + AuthType.Query, + request + ); private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; } \ No newline at end of file diff --git a/Vonage/Redaction/RedactClient.cs b/Vonage/Redaction/RedactClient.cs index d8e6c89c7..1a81dc24c 100644 --- a/Vonage/Redaction/RedactClient.cs +++ b/Vonage/Redaction/RedactClient.cs @@ -1,3 +1,4 @@ +using System; using System.Net.Http; using System.Threading.Tasks; using Vonage.Common; @@ -23,32 +24,35 @@ internal RedactClient(Credentials credentials, Configuration configuration, ITim this.configuration = configuration; this.timeProvider = timeProvider; } - - private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; /// + [Obsolete("Favor asynchronous version instead.")] public bool Redact(RedactRequest request, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent - ( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v1/redact/transaction"), - request, - AuthType.Basic - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent + ( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v1/redact/transaction"), + request, + AuthType.Basic + ); return true; } /// public async Task RedactAsync(RedactRequest request, Credentials creds = null) { - await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync - ( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v1/redact/transaction"), - request, - AuthType.Basic - ); + await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync + ( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, "/v1/redact/transaction"), + request, + AuthType.Basic + ); return true; } + + private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; } \ No newline at end of file diff --git a/Vonage/ShortCodes/ShortCodesClient.cs b/Vonage/ShortCodes/ShortCodesClient.cs index e508553d5..b63f3273c 100644 --- a/Vonage/ShortCodes/ShortCodesClient.cs +++ b/Vonage/ShortCodes/ShortCodesClient.cs @@ -1,3 +1,4 @@ +using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -22,62 +23,74 @@ internal ShortCodesClient(Credentials credentials, Configuration configuration, this.configuration = configuration; this.timeProvider = timeProvider; } - - private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; /// + [Obsolete("Favor asynchronous version instead.")] public OptInRecord ManageOptIn(OptInManageRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/manage/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/manage/json"), + AuthType.Query, + request); /// public Task ManageOptInAsync(OptInManageRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/manage/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/manage/json"), + AuthType.Query, + request); /// + [Obsolete("Favor asynchronous version instead.")] public OptInSearchResponse QueryOptIns(OptInQueryRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/query/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/query/json"), + AuthType.Query, + request); /// public Task QueryOptInsAsync(OptInQueryRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/query/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/opt-in/query/json"), + AuthType.Query, + request); /// + [Obsolete("Favor asynchronous version instead.")] public AlertResponse SendAlert(AlertRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/json"), + AuthType.Query, + request); /// public Task SendAlertAsync(AlertRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/alert/json"), + AuthType.Query, + request); /// + [Obsolete("Favor asynchronous version instead.")] public TwoFactorAuthResponse SendTwoFactorAuth(TwoFactorAuthRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/2fa/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/2fa/json"), + AuthType.Query, + request); /// public Task SendTwoFactorAuthAsync(TwoFactorAuthRequest request, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/2fa/json"), - AuthType.Query, - request); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Rest, "/sc/us/2fa/json"), + AuthType.Query, + request); + + private Credentials GetCredentials(Credentials overridenCredentials) => overridenCredentials ?? this.Credentials; } \ No newline at end of file diff --git a/Vonage/Verify/VerifyClient.cs b/Vonage/Verify/VerifyClient.cs index 7c552119f..1a69b0451 100644 --- a/Vonage/Verify/VerifyClient.cs +++ b/Vonage/Verify/VerifyClient.cs @@ -1,4 +1,5 @@ -using System.Threading.Tasks; +using System; +using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -34,6 +35,7 @@ public void ValidateVerifyResponse(VerifyResponseBase response) } /// + [Obsolete("Favor asynchronous version instead.")] public VerifyCheckResponse VerifyCheck(VerifyCheckRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -58,6 +60,7 @@ public async Task VerifyCheckAsync(VerifyCheckRequest reque } /// + [Obsolete("Favor asynchronous version instead.")] public VerifyControlResponse VerifyControl(VerifyControlRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -82,6 +85,7 @@ public async Task VerifyControlAsync(VerifyControlRequest } /// + [Obsolete("Favor asynchronous version instead.")] public VerifyResponse VerifyRequest(VerifyRequest request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -106,6 +110,7 @@ public async Task VerifyRequestAsync(VerifyRequest request, Cred } /// + [Obsolete("Favor asynchronous version instead.")] public VerifyResponse VerifyRequestWithPSD2(Psd2Request request, Credentials creds = null) { var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -130,6 +135,7 @@ public async Task VerifyRequestWithPSD2Async(Psd2Request request } /// + [Obsolete("Favor asynchronous version instead.")] public VerifySearchResponse VerifySearch(VerifySearchRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) .DoGetRequestWithQueryParameters( diff --git a/Vonage/Voice/VoiceClient.cs b/Vonage/Voice/VoiceClient.cs index 22f42432b..f59f2573d 100644 --- a/Vonage/Voice/VoiceClient.cs +++ b/Vonage/Voice/VoiceClient.cs @@ -13,8 +13,8 @@ namespace Vonage.Voice; public class VoiceClient : IVoiceClient { private const string CallsEndpoint = "v1/calls"; - private readonly Credentials credentials; private readonly Configuration configuration; + private readonly Credentials credentials; private readonly ITimeProvider timeProvider = new TimeProvider(); /// @@ -35,13 +35,15 @@ internal VoiceClient(Credentials credentials, Configuration configuration, ITime } /// + [Obsolete("Favor asynchronous version instead.")] public CallResponse CreateCall(CallCommand command, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), - command, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), + command, + AuthType.Bearer + ); /// [Obsolete("Favor 'CreateCall(CallCommand) instead.'")] @@ -86,12 +88,13 @@ public CallResponse CreateCall(Endpoint toEndPoint, string fromNumber, Ncco ncco /// public Task CreateCallAsync(CallCommand command, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Post, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), - command, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Post, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), + command, + AuthType.Bearer + ); /// [Obsolete("Favor 'CreateCallAsync(CallCommand) instead.'")] @@ -135,39 +138,47 @@ public Task CreateCallAsync(Endpoint toEndPoint, string fromNumber } /// + [Obsolete("Favor asynchronous version instead.")] public CallRecord GetCall(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), + AuthType.Bearer + ); /// public Task GetCallAsync(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public PageResponse GetCalls(CallSearchFilter filter, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParameters>( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), - AuthType.Bearer, - filter - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParameters>( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), + AuthType.Bearer, + filter + ); /// public Task> GetCallsAsync(CallSearchFilter filter, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithQueryParametersAsync>( - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), - AuthType.Bearer, - filter - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithQueryParametersAsync>( + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, CallsEndpoint), + AuthType.Bearer, + filter + ); /// + [Obsolete("Favor asynchronous version instead.")] public GetRecordingResponse GetRecording(string recordingUrl, Credentials creds = null) { - using var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithJwt(new Uri(recordingUrl)); + using var response = ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithJwt(new Uri(recordingUrl)); return new GetRecordingResponse { ResultStream = ReadContent(response.Content).Result, @@ -179,7 +190,8 @@ public GetRecordingResponse GetRecording(string recordingUrl, Credentials creds public async Task GetRecordingAsync(string recordingUrl, Credentials creds = null) { using var response = - await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoGetRequestWithJwtAsync(new Uri(recordingUrl)); + await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoGetRequestWithJwtAsync(new Uri(recordingUrl)); return new GetRecordingResponse { ResultStream = await ReadContent(response.Content), @@ -188,116 +200,134 @@ public async Task GetRecordingAsync(string recordingUrl, C } /// + [Obsolete("Favor asynchronous version instead.")] public CallCommandResponse StartDtmf(string id, DtmfCommand cmd, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/dtmf"), - cmd, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/dtmf"), + cmd, + AuthType.Bearer + ); /// public Task StartDtmfAsync(string id, DtmfCommand cmd, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/dtmf"), - cmd, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/dtmf"), + cmd, + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public CallCommandResponse StartStream(string id, StreamCommand command, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), - command, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), + command, + AuthType.Bearer + ); /// public Task StartStreamAsync(string id, StreamCommand command, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), - command, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), + command, + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public CallCommandResponse StartTalk(string id, TalkCommand cmd, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), - cmd, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), + cmd, + AuthType.Bearer + ); /// public Task StartTalkAsync(string id, TalkCommand cmd, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), - cmd, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), + cmd, + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public CallCommandResponse StopStream(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Delete, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), - new { }, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Delete, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), + new { }, + AuthType.Bearer + ); /// public Task StopStreamAsync(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Delete, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), - new { }, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Delete, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/stream"), + new { }, + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public CallCommandResponse StopTalk(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Delete, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), - new { }, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Delete, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), + new { }, + AuthType.Bearer + ); /// public Task StopTalkAsync(string id, Credentials creds = null) => - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Delete, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), - new { }, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Delete, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}/talk"), + new { }, + AuthType.Bearer + ); /// + [Obsolete("Favor asynchronous version instead.")] public bool UpdateCall(string id, CallEditCommand command, Credentials creds = null) { - ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContent( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), - command, - AuthType.Bearer - ); + ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContent( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), + command, + AuthType.Bearer + ); return true; } /// public async Task UpdateCallAsync(string id, CallEditCommand command, Credentials creds = null) { - await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider).DoRequestWithJsonContentAsync( - HttpMethod.Put, - ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), - command, - AuthType.Bearer - ); + await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) + .DoRequestWithJsonContentAsync( + HttpMethod.Put, + ApiRequest.GetBaseUri(ApiRequest.UriType.Api, $"{CallsEndpoint}/{id}"), + command, + AuthType.Bearer + ); return true; }