diff --git a/Vonage.Test/ShortCodeTests.cs b/Vonage.Test/ShortCodeTests.cs index 6bf2d7b76..8879762c4 100644 --- a/Vonage.Test/ShortCodeTests.cs +++ b/Vonage.Test/ShortCodeTests.cs @@ -10,48 +10,6 @@ namespace Vonage.Test; [Trait("Category", "Legacy")] public class ShortCodeTests : TestBase { - [Theory] - [InlineData(true, false)] - [InlineData(true, true)] - [InlineData(false, true)] - [InlineData(false, false)] - public void SendAlert(bool passCredentials, bool useAllParameters) - { - //ARRANGE - var request = new AlertRequest - { - To = "16365553226", - }; - var expectedUri = $"{this.RestUrl}/sc/us/alert/json?to={request.To}"; - if (useAllParameters) - { - request.StatusReportReq = "1"; - request.ClientRef = Guid.NewGuid().ToString(); - request.Template = "Test Template"; - request.Type = "text"; - expectedUri += - $"&status-report-req={request.StatusReportReq}&client-ref={request.ClientRef}&template={WebUtility.UrlEncode(request.Template)}&type={request.Type}"; - } - - var expectedResponseContent = this.GetResponseJson(); - expectedUri += $"&api_key={this.ApiKey}&api_secret={this.ApiSecret}&"; - this.Setup(expectedUri, expectedResponseContent); - - //ACT - var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); - var client = this.BuildVonageClient(creds); - var response = client.ShortCodesClient.SendAlert(request, passCredentials ? creds : null); - - //ASSERT - Assert.Equal("1", response.MessageCount); - Assert.NotEmpty(response.Messages); - var message = response.Messages[0]; - Assert.Equal("delivered", message.Status); - Assert.Equal("abcdefg", message.MessageId); - Assert.Equal("16365553226", message.To); - Assert.Equal("0", message.ErrorCode); - } - [Theory] [InlineData(true, false)] [InlineData(true, true)] @@ -94,33 +52,6 @@ public async Task SendAlertAsync(bool passCredentials, bool useAllParameters) Assert.Equal("0", message.ErrorCode); } - [Theory] - [InlineData(true)] - [InlineData(false)] - public void ManageOptIn(bool passCredentials) - { - //ARRANGE - var request = new OptInManageRequest - { - Msisdn = "15559301529", - }; - var expectedResponseContent = this.GetResponseJson(); - var expectedUri = - $"{this.RestUrl}/sc/us/alert/opt-in/manage/json?msisdn={request.Msisdn}&api_key={this.ApiKey}&api_secret={this.ApiSecret}&"; - this.Setup(expectedUri, expectedResponseContent); - - //ACT - var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); - var client = this.BuildVonageClient(creds); - var response = client.ShortCodesClient.ManageOptIn(request, passCredentials ? creds : null); - - //ASSERT - Assert.Equal("15559301529", response.Msisdn); - Assert.True(response.OptIn); - Assert.Equal("2014-08-21 17:34:47", response.OptInDate); - Assert.False(response.OptOut); - } - [Theory] [InlineData(true)] [InlineData(false)] @@ -148,36 +79,6 @@ public async Task ManageOptInAsync(bool passCredentials) Assert.False(response.OptOut); } - [Theory] - [InlineData(true, true)] - [InlineData(false, false)] - [InlineData(true, false)] - [InlineData(false, true)] - public void QueryOptIns(bool passCredentials, bool allParameters) - { - //ARRANGE - var request = new OptInQueryRequest(); - var expectedUri = $"{this.RestUrl}/sc/us/alert/opt-in/query/json?"; - if (allParameters) - { - request.Page = "1"; - request.PageSize = "20"; - expectedUri += $"page-size={request.PageSize}&page={request.Page}&"; - } - - var expectedResponseContent = this.GetResponseJson(); - expectedUri += $"api_key={this.ApiKey}&api_secret={this.ApiSecret}&"; - this.Setup(expectedUri, expectedResponseContent); - - //ACT - var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); - var client = this.BuildVonageClient(creds); - var response = client.ShortCodesClient.QueryOptIns(request, passCredentials ? creds : null); - - //ASSERT - Assert.Equal("3", response.OptInCount); - } - [Theory] [InlineData(true, true)] [InlineData(false, false)] @@ -208,26 +109,6 @@ public async Task QueryOptInsAsync(bool passCredentials, bool allParameters) Assert.Equal("3", response.OptInCount); } - [Theory] - [InlineData(false)] - [InlineData(true)] - public void SendTwoFactorAuth(bool passCredentials) - { - //ARRANGE - var request = new TwoFactorAuthRequest(); - var expectedUri = $"{this.RestUrl}/sc/us/2fa/json?api_key={this.ApiKey}&api_secret={this.ApiSecret}&"; - var expectedResponseContent = this.GetResponseJson(); - this.Setup(expectedUri, expectedResponseContent); - - //ACT - var creds = Credentials.FromApiKeyAndSecret(this.ApiKey, this.ApiSecret); - var client = this.BuildVonageClient(creds); - var response = client.ShortCodesClient.SendTwoFactorAuth(request, passCredentials ? creds : null); - - //ASSERT - Assert.Equal("1", response.MessageCount); - } - [Theory] [InlineData(false)] [InlineData(true)] diff --git a/Vonage/ShortCodes/IShortCodesClient.cs b/Vonage/ShortCodes/IShortCodesClient.cs index e7b439fa5..df975ec02 100644 --- a/Vonage/ShortCodes/IShortCodesClient.cs +++ b/Vonage/ShortCodes/IShortCodesClient.cs @@ -12,12 +12,4 @@ public interface IShortCodesClient Task SendAlertAsync(AlertRequest request, Credentials creds = null); Task SendTwoFactorAuthAsync(TwoFactorAuthRequest request, Credentials creds = null); - - OptInSearchResponse QueryOptIns(OptInQueryRequest request, Credentials creds = null); - - OptInRecord ManageOptIn(OptInManageRequest request, Credentials creds = null); - - AlertResponse SendAlert(AlertRequest request, Credentials creds = null); - - TwoFactorAuthResponse SendTwoFactorAuth(TwoFactorAuthRequest request, Credentials creds = null); } \ No newline at end of file diff --git a/Vonage/ShortCodes/ShortCodesClient.cs b/Vonage/ShortCodes/ShortCodesClient.cs index 05e161e76..87a701c06 100644 --- a/Vonage/ShortCodes/ShortCodesClient.cs +++ b/Vonage/ShortCodes/ShortCodesClient.cs @@ -1,4 +1,3 @@ -using System; using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; @@ -25,15 +24,6 @@ internal ShortCodesClient(Credentials credentials, Configuration configuration, public Credentials Credentials { get; set; } - /// - [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, this.configuration, "/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) @@ -42,15 +32,6 @@ public Task ManageOptInAsync(OptInManageRequest request, Credential 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, this.configuration, "/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) @@ -59,15 +40,6 @@ public Task QueryOptInsAsync(OptInQueryRequest request, Cre 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, this.configuration, "/sc/us/alert/json"), - AuthType.Query, - request); - /// public Task SendAlertAsync(AlertRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -76,15 +48,6 @@ public Task SendAlertAsync(AlertRequest request, Credentials cred 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, this.configuration, "/sc/us/2fa/json"), - AuthType.Query, - request); - /// public Task SendTwoFactorAuthAsync(TwoFactorAuthRequest request, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider)