diff --git a/Vonage.Test/Data/VoiceTests/CreateCall-request.json b/Vonage.Test/Data/VoiceTests/CreateCallAsync-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCall-request.json rename to Vonage.Test/Data/VoiceTests/CreateCallAsync-request.json diff --git a/Vonage.Test/Data/VoiceTests/CreateCall-response.json b/Vonage.Test/Data/VoiceTests/CreateCallAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCall-response.json rename to Vonage.Test/Data/VoiceTests/CreateCallAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithRandomFromNumber-request.json b/Vonage.Test/Data/VoiceTests/CreateCallAsyncWithRandomFromNumber-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCallWithRandomFromNumber-request.json rename to Vonage.Test/Data/VoiceTests/CreateCallAsyncWithRandomFromNumber-request.json diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithRandomFromNumber-response.json b/Vonage.Test/Data/VoiceTests/CreateCallAsyncWithRandomFromNumber-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCallWithRandomFromNumber-response.json rename to Vonage.Test/Data/VoiceTests/CreateCallAsyncWithRandomFromNumber-response.json diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-request.json b/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-request.json deleted file mode 100644 index cf7be9224..000000000 --- a/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-request.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "to": [ - { - "number": "14155550100", - "type": "phone" - } - ], - "from": { - "number": "14155550100", - "type": "phone" - }, - "ncco": [ - { - "action": "talk", - "text": "Hello World" - } - ] -} \ No newline at end of file diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-response.json b/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-response.json deleted file mode 100644 index e2f19dc07..000000000 --- a/Vonage.Test/Data/VoiceTests/CreateCallWithStringParameters-response.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "uuid": "63f61863-4a51-4f6b-86e1-46edebcf9356", - "status": "started", - "direction": "outbound", - "conversation_uuid": "CON-f972836a-550f-45fa-956c-12a2ab5b7d22" -} \ No newline at end of file diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithEndpointAndNcco-request.json b/Vonage.Test/Data/VoiceTests/CreateCallWithStringParametersAsync-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCallWithEndpointAndNcco-request.json rename to Vonage.Test/Data/VoiceTests/CreateCallWithStringParametersAsync-request.json diff --git a/Vonage.Test/Data/VoiceTests/CreateCallWithEndpointAndNcco-response.json b/Vonage.Test/Data/VoiceTests/CreateCallWithStringParametersAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/CreateCallWithEndpointAndNcco-response.json rename to Vonage.Test/Data/VoiceTests/CreateCallWithStringParametersAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/GetSpecificCall-response.json b/Vonage.Test/Data/VoiceTests/GetSpecificCallAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/GetSpecificCall-response.json rename to Vonage.Test/Data/VoiceTests/GetSpecificCallAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/ListCalls-response.json b/Vonage.Test/Data/VoiceTests/ListCallsAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/ListCalls-response.json rename to Vonage.Test/Data/VoiceTests/ListCallsAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/StartDtmf-request.json b/Vonage.Test/Data/VoiceTests/StartDtmfAsync-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartDtmf-request.json rename to Vonage.Test/Data/VoiceTests/StartDtmfAsync-request.json diff --git a/Vonage.Test/Data/VoiceTests/StartDtmf-response.json b/Vonage.Test/Data/VoiceTests/StartDtmfAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartDtmf-response.json rename to Vonage.Test/Data/VoiceTests/StartDtmfAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/StartStream-request.json b/Vonage.Test/Data/VoiceTests/StartStreamAsync-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartStream-request.json rename to Vonage.Test/Data/VoiceTests/StartStreamAsync-request.json diff --git a/Vonage.Test/Data/VoiceTests/StartStream-response.json b/Vonage.Test/Data/VoiceTests/StartStreamAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartStream-response.json rename to Vonage.Test/Data/VoiceTests/StartStreamAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/StartStreamWithCredentials-request.json b/Vonage.Test/Data/VoiceTests/StartStreamAsyncWithCredentials-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartStreamWithCredentials-request.json rename to Vonage.Test/Data/VoiceTests/StartStreamAsyncWithCredentials-request.json diff --git a/Vonage.Test/Data/VoiceTests/StartTalk-request.json b/Vonage.Test/Data/VoiceTests/StartTalkAsync-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartTalk-request.json rename to Vonage.Test/Data/VoiceTests/StartTalkAsync-request.json diff --git a/Vonage.Test/Data/VoiceTests/StartTalk-response.json b/Vonage.Test/Data/VoiceTests/StartTalkAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartTalk-response.json rename to Vonage.Test/Data/VoiceTests/StartTalkAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/StartTalkWithCredentials-request.json b/Vonage.Test/Data/VoiceTests/StartTalkAsyncWithCredentials-request.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StartTalkWithCredentials-request.json rename to Vonage.Test/Data/VoiceTests/StartTalkAsyncWithCredentials-request.json diff --git a/Vonage.Test/Data/VoiceTests/StopStream-response.json b/Vonage.Test/Data/VoiceTests/StopStreamAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StopStream-response.json rename to Vonage.Test/Data/VoiceTests/StopStreamAsync-response.json diff --git a/Vonage.Test/Data/VoiceTests/StopTalk-response.json b/Vonage.Test/Data/VoiceTests/StopTalkAsync-response.json similarity index 100% rename from Vonage.Test/Data/VoiceTests/StopTalk-response.json rename to Vonage.Test/Data/VoiceTests/StopTalkAsync-response.json diff --git a/Vonage.Test/VoiceTests.cs b/Vonage.Test/VoiceTests.cs index 3227182f2..fe288fd29 100644 --- a/Vonage.Test/VoiceTests.cs +++ b/Vonage.Test/VoiceTests.cs @@ -53,23 +53,11 @@ public void AdvancedMachineDetectionProperties_ShouldThrowException_GivenBeepTim .WithMessage("Beep Timeout has a minimal value of 45, and a maximal value of 120."); } - [Fact] - public void CreateCall() - { - this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); - var request = BuildCreateCallCommand(); - var response = this.client.VoiceClient.CreateCall(request); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - [Fact] public async Task CreateCallAsync() { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCall)), - this.GetRequestJson(nameof(this.CreateCall))); + this.Setup(BaseUri, this.GetResponseJson(), + this.GetRequestJson()); var request = BuildCreateCallCommand(); var response = await this.client.VoiceClient.CreateCallAsync(request); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -81,8 +69,8 @@ public async Task CreateCallAsync() [Fact] public async Task CreateCallAsyncWithCredentials() { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCall)), - this.GetRequestJson(nameof(this.CreateCall))); + this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCallAsync)), + this.GetRequestJson(nameof(this.CreateCallAsync))); var response = await this.client.VoiceClient.CreateCallAsync(BuildCreateCallCommand(), this.BuildCredentialsForBearerAuthentication()); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -94,8 +82,7 @@ public async Task CreateCallAsyncWithCredentials() [Fact] public async Task CreateCallAsyncWithRandomFromNumber() { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCallWithRandomFromNumber)), - this.GetRequestJson(nameof(this.CreateCallWithRandomFromNumber))); + this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); var request = BuildCreateCallCommand(); request.From = null; request.AdvancedMachineDetection = null; @@ -117,81 +104,25 @@ await act.Should().ThrowExactlyAsync() .WithMessage("AppId or Private Key Path missing."); } - [Fact] - public void CreateCallWithCredentials() - { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCall)), - this.GetRequestJson(nameof(this.CreateCall))); - var response = this.client.VoiceClient.CreateCall(BuildCreateCallCommand(), - this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - - [Fact] - public void CreateCallWithEndpointAndNcco() - { - this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); - var response = this.client.VoiceClient.CreateCall( - new PhoneEndpoint {Number = "14155550100"}, "14155550100", - new Ncco(new TalkAction {Text = "Hello World"})); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - - [Fact] - public async Task CreateCallWithEndpointAndNccoAsync() - { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCallWithEndpointAndNcco)), - this.GetRequestJson(nameof(this.CreateCallWithEndpointAndNcco))); - var response = await this.client.VoiceClient.CreateCallAsync( - new PhoneEndpoint {Number = "14155550100"}, "14155550100", - new Ncco(new TalkAction {Text = "Hello World"})); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - [Fact] public async Task CreateCallWithPremiumTalkActionAsync() { this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); - var response = await this.client.VoiceClient.CreateCallAsync( - new PhoneEndpoint {Number = "14155550100"}, "14155550100", - new Ncco(new TalkAction {Text = "Hello World", Premium = true})); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - - [Fact] - public void CreateCallWithRandomFromNumber() - { - this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); - var request = BuildCreateCallCommand(); - request.From = null; - request.AdvancedMachineDetection = null; - request.RandomFromNumber = true; - this.BuildCredentialsForBearerAuthentication(); - var response = this.client.VoiceClient.CreateCall(request); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); - Assert.Equal("outbound", response.Direction); - Assert.Equal("started", response.Status); - } - - [Fact] - public void CreateCallWithStringParameters() - { - this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); - var response = this.client.VoiceClient.CreateCall("14155550100", "14155550100", - new Ncco(new TalkAction {Text = "Hello World"})); + var response = await this.client.VoiceClient.CreateCallAsync(new CallCommand + { + To = new Endpoint[] + { + new PhoneEndpoint + { + Number = "14155550100", + }, + }, + From = new PhoneEndpoint + { + Number = "14155550100", + }, + Ncco = new Ncco(new TalkAction {Text = "Hello World", Premium = true}), + }); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); Assert.Equal("outbound", response.Direction); @@ -201,10 +132,22 @@ public void CreateCallWithStringParameters() [Fact] public async Task CreateCallWithStringParametersAsync() { - this.Setup(BaseUri, this.GetResponseJson(nameof(this.CreateCallWithStringParameters)), - this.GetRequestJson(nameof(this.CreateCallWithStringParameters))); - var response = await this.client.VoiceClient.CreateCallAsync("14155550100", "14155550100", - new Ncco(new TalkAction {Text = "Hello World"})); + this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); + var response = await this.client.VoiceClient.CreateCallAsync(new CallCommand + { + To = new Endpoint[] + { + new PhoneEndpoint + { + Number = "14155550100", + }, + }, + From = new PhoneEndpoint + { + Number = "14155550100", + }, + Ncco = new Ncco(new TalkAction {Text = "Hello World"}), + }); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); Assert.Equal("outbound", response.Direction); @@ -212,12 +155,12 @@ public async Task CreateCallWithStringParametersAsync() } [Fact] - public void CreateCallWithUnicodeCharacters() + public async Task CreateCallWithUnicodeCharacters() { this.Setup(BaseUri, this.GetResponseJson(), this.GetRequestJson()); var request = BuildCreateCallCommand(); request.Ncco = new Ncco(new TalkAction {Text = "בדיקה בדיקה בדיקה"}); - var response = this.client.VoiceClient.CreateCall(request); + var response = await this.client.VoiceClient.CreateCallAsync(request); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", response.ConversationUuid); Assert.Equal("outbound", response.Direction); @@ -225,24 +168,14 @@ public void CreateCallWithUnicodeCharacters() } [Fact] - public void CreateCallWithWrongCredsThrowsAuthException() + public async Task CreateCallWithWrongCredsThrowsAuthException() { - Action act = () => this.BuildClientWithBasicAuthentication() - .VoiceClient.CreateCall(new CallCommand()); - act.Should().ThrowExactly() + var act = () => this.BuildClientWithBasicAuthentication() + .VoiceClient.CreateCallAsync(new CallCommand()); + await act.Should().ThrowExactlyAsync() .WithMessage("AppId or Private Key Path missing."); } - [Fact] - public void GetRecording() - { - var expectedUri = this.fixture.Create().ToString(); - var expectedResponse = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - this.Setup(expectedUri, expectedResponse); - var response = this.client.VoiceClient.GetRecording(expectedUri); - Assert.Equal(expectedResponse, response.ResultStream); - } - [Fact] public async Task GetRecordingsAsync() { @@ -265,47 +198,11 @@ await this.client.VoiceClient.GetRecordingAsync(expectedUri, Assert.Equal(expectedResponse, response.ResultStream); } - [Fact] - public void GetRecordingWithCredentials() - { - var expectedUri = this.fixture.Create().ToString(); - var expectedResponse = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - this.Setup(expectedUri, expectedResponse); - var response = - this.client.VoiceClient.GetRecording(expectedUri, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal(expectedResponse, response.ResultStream); - } - - [Fact] - public void GetSpecificCall() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson()); - var callRecord = this.client.VoiceClient.GetCall(uuid); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", callRecord.ConversationUuid); - Assert.Equal("447700900000", callRecord.To.Number); - Assert.Equal("phone", callRecord.To.Type); - Assert.Equal("phone", callRecord.From.Type); - Assert.Equal("447700900001", callRecord.From.Number); - Assert.Equal("started", callRecord.Status); - Assert.Equal("outbound", callRecord.Direction); - Assert.Equal("0.39", callRecord.Rate); - Assert.Equal("23.40", callRecord.Price); - Assert.Equal("60", callRecord.Duration); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.StartTime); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.EndTime); - } - [Fact] public async Task GetSpecificCallAsync() { var uuid = this.fixture.Create().ToString(); - this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson(nameof(this.GetSpecificCall))); + this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson()); var callRecord = await this.client.VoiceClient.GetCallAsync(uuid); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", callRecord.ConversationUuid); @@ -330,7 +227,7 @@ public async Task GetSpecificCallAsync() public async Task GetSpecificCallAsyncWithCredentials() { var uuid = this.fixture.Create().ToString(); - this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson(nameof(this.GetSpecificCall))); + this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson(nameof(this.GetSpecificCallAsync))); var callRecord = await this.client.VoiceClient.GetCallAsync(uuid, this.BuildCredentialsForBearerAuthentication()); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); @@ -352,67 +249,11 @@ public async Task GetSpecificCallAsyncWithCredentials() DateTimeStyles.AdjustToUniversal), callRecord.EndTime); } - [Fact] - public void GetSpecificCallWithCredentials() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}", this.GetResponseJson(nameof(this.GetSpecificCall))); - var callRecord = this.client.VoiceClient.GetCall(uuid, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", callRecord.ConversationUuid); - Assert.Equal("447700900000", callRecord.To.Number); - Assert.Equal("phone", callRecord.To.Type); - Assert.Equal("phone", callRecord.From.Type); - Assert.Equal("447700900001", callRecord.From.Number); - Assert.Equal("started", callRecord.Status); - Assert.Equal("outbound", callRecord.Direction); - Assert.Equal("0.39", callRecord.Rate); - Assert.Equal("23.40", callRecord.Price); - Assert.Equal("60", callRecord.Duration); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.StartTime); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.EndTime); - } - - [Fact] - public void ListCalls() - { - var filter = new CallSearchFilter(); - this.Setup($"{this.ApiUrl}/v1/calls", this.GetResponseJson()); - var callList = this.client.VoiceClient.GetCalls(filter); - var callRecord = callList.Embedded.Calls[0]; - Assert.True(100 == callList.Count); - Assert.True(10 == callList.PageSize); - Assert.True(0 == callList.PageIndex); - Assert.Equal("/calls?page_size=10&record_index=20&order=asc", callList.Links.Self.Href); - Assert.Equal("/calls/63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Links.Self.Href); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", callRecord.ConversationUuid); - Assert.Equal("447700900000", callRecord.To.Number); - Assert.Equal("phone", callRecord.To.Type); - Assert.Equal("phone", callRecord.From.Type); - Assert.Equal("447700900001", callRecord.From.Number); - Assert.Equal("started", callRecord.Status); - Assert.Equal("outbound", callRecord.Direction); - Assert.Equal("0.39", callRecord.Rate); - Assert.Equal("23.40", callRecord.Price); - Assert.Equal("60", callRecord.Duration); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.StartTime); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.EndTime); - } - [Fact] public async Task ListCallsAsync() { var filter = new CallSearchFilter(); - this.Setup($"{this.ApiUrl}/v1/calls", this.GetResponseJson(nameof(this.ListCalls))); + this.Setup($"{this.ApiUrl}/v1/calls", this.GetResponseJson()); var callList = await this.client.VoiceClient.GetCallsAsync(filter); var callRecord = callList.Embedded.Calls[0]; Assert.True(100 == callList.Count); @@ -454,7 +295,7 @@ public async Task ListCallsAsyncWithCredentials() }; this.Setup( $"{BaseUri}?status=started&date_start={WebUtility.UrlEncode("2016-11-14T07:45:14Z").ToUpper()}&date_end={WebUtility.UrlEncode("2016-11-14T07:45:14Z").ToUpper()}&page_size=10&record_index=0&order=asc&conversation_uuid=CON-f972836a-550f-45fa-956c-12a2ab5b7d22&", - this.GetResponseJson(nameof(this.ListCalls))); + this.GetResponseJson(nameof(this.ListCallsAsync))); var callList = await this.client.VoiceClient.GetCallsAsync(filter, this.BuildCredentialsForBearerAuthentication()); var callRecord = callList.Embedded.Calls[0]; @@ -482,66 +323,13 @@ public async Task ListCallsAsyncWithCredentials() DateTimeStyles.AdjustToUniversal), callRecord.EndTime); } - [Fact] - public void ListCallsWithCredentials() - { - var filter = new CallSearchFilter - { - ConversationUuid = "CON-f972836a-550f-45fa-956c-12a2ab5b7d22", - DateStart = DateTime.Parse("2016-11-14T07:45:14"), - DateEnd = DateTime.Parse("2016-11-14T07:45:14"), - PageSize = 10, - RecordIndex = 0, - Order = "asc", - Status = "started", - }; - this.Setup( - $"{BaseUri}?status=started&date_start={WebUtility.UrlEncode("2016-11-14T07:45:14Z").ToUpper()}&date_end={WebUtility.UrlEncode("2016-11-14T07:45:14Z").ToUpper()}&page_size=10&record_index=0&order=asc&conversation_uuid=CON-f972836a-550f-45fa-956c-12a2ab5b7d22&", - this.GetResponseJson(nameof(this.ListCalls))); - var callList = this.client.VoiceClient.GetCalls(filter, this.BuildCredentialsForBearerAuthentication()); - var callRecord = callList.Embedded.Calls[0]; - Assert.True(100 == callList.Count); - Assert.True(10 == callList.PageSize); - Assert.True(0 == callList.PageIndex); - Assert.Equal("/calls?page_size=10&record_index=20&order=asc", callList.Links.Self.Href); - Assert.Equal("/calls/63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Links.Self.Href); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", callRecord.Uuid); - Assert.Equal("CON-f972836a-550f-45fa-956c-12a2ab5b7d22", callRecord.ConversationUuid); - Assert.Equal("447700900000", callRecord.To.Number); - Assert.Equal("phone", callRecord.To.Type); - Assert.Equal("phone", callRecord.From.Type); - Assert.Equal("447700900001", callRecord.From.Number); - Assert.Equal("started", callRecord.Status); - Assert.Equal("outbound", callRecord.Direction); - Assert.Equal("0.39", callRecord.Rate); - Assert.Equal("23.40", callRecord.Price); - Assert.Equal("60", callRecord.Duration); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.StartTime); - Assert.Equal(DateTime.ParseExact("2020-01-01T12:00:00.000Z", "yyyy-MM-dd'T'HH:mm:ss.fff'Z'", - CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal | - DateTimeStyles.AdjustToUniversal), callRecord.EndTime); - } - - [Fact] - public void StartDtmf() - { - var uuid = this.fixture.Create(); - var command = new DtmfCommand {Digits = "1234"}; - this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(), this.GetRequestJson()); - var response = this.client.VoiceClient.StartDtmf(uuid, command); - Assert.Equal("DTMF sent", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task StartDtmfAsync() { var uuid = this.fixture.Create(); var command = new DtmfCommand {Digits = "1234"}; - this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(nameof(this.StartDtmf)), - this.GetRequestJson(nameof(this.StartDtmf))); + this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(), + this.GetRequestJson()); var response = await this.client.VoiceClient.StartDtmfAsync(uuid, command); Assert.Equal("DTMF sent", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -552,8 +340,8 @@ public async Task StartDtmfAsyncWithCredentials() { var uuid = this.fixture.Create(); var command = new DtmfCommand {Digits = "1234"}; - this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(nameof(this.StartDtmf)), - this.GetRequestJson(nameof(this.StartDtmf))); + this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(nameof(this.StartDtmfAsync)), + this.GetRequestJson(nameof(this.StartDtmfAsync))); var response = await this.client.VoiceClient.StartDtmfAsync(uuid, command, this.BuildCredentialsForBearerAuthentication()); @@ -561,33 +349,6 @@ await this.client.VoiceClient.StartDtmfAsync(uuid, command, Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); } - [Fact] - public void StartDtmfWithCredentials() - { - var uuid = this.fixture.Create(); - var command = new DtmfCommand {Digits = "1234"}; - this.Setup($"{BaseUri}/{uuid}/dtmf", this.GetResponseJson(nameof(this.StartDtmf)), - this.GetRequestJson(nameof(this.StartDtmf))); - var response = - this.client.VoiceClient.StartDtmf(uuid, command, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("DTMF sent", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - - [Fact] - public void StartStream() - { - var uuid = this.fixture.Create(); - var command = new StreamCommand - { - StreamUrl = new[] {"https://example.com/waiting.mp3"}, - }; - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(), this.GetRequestJson()); - var response = this.client.VoiceClient.StartStream(uuid, command); - Assert.Equal("Stream started", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task StartStreamAsync() { @@ -596,8 +357,7 @@ public async Task StartStreamAsync() { StreamUrl = new[] {"https://example.com/waiting.mp3"}, }; - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StartStream)), - this.GetRequestJson(nameof(this.StartStream))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(), this.GetRequestJson()); var response = await this.client.VoiceClient.StartStreamAsync(uuid, command); Assert.Equal("Stream started", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -613,8 +373,8 @@ public async Task StartStreamAsyncWithCredentials() Loop = 0, Level = "0.4", }; - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StartStream)), - this.GetRequestJson(nameof(this.StartStreamWithCredentials))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StartStreamAsync)), + this.GetRequestJson()); var response = await this.client.VoiceClient.StartStreamAsync(uuid, command, this.BuildCredentialsForBearerAuthentication()); @@ -622,43 +382,11 @@ await this.client.VoiceClient.StartStreamAsync(uuid, command, Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); } - [Fact] - public void StartStreamWithCredentials() - { - var uuid = this.fixture.Create(); - var command = new StreamCommand - { - StreamUrl = new[] {"https://example.com/waiting.mp3"}, - Loop = 0, - Level = "0.4", - }; - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StartStream)), - this.GetRequestJson()); - var response = - this.client.VoiceClient.StartStream(uuid, command, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("Stream started", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - - [Fact] - public void StartTalk() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(), this.GetRequestJson()); - var response = this.client.VoiceClient.StartTalk(uuid, new TalkCommand - { - Text = "Hello. How are you today?", - }); - Assert.Equal("Talk started", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task StartTalkAsync() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(nameof(this.StartTalk)), - this.GetRequestJson(nameof(this.StartTalk))); + this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(), this.GetRequestJson()); var response = await this.client.VoiceClient.StartTalkAsync(uuid, new TalkCommand { Text = "Hello. How are you today?", @@ -671,8 +399,8 @@ public async Task StartTalkAsync() public async Task StartTalkAsyncWithCredentials() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(nameof(this.StartTalk)), - this.GetRequestJson(nameof(this.StartTalk))); + this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(nameof(this.StartTalkAsync)), + this.GetRequestJson(nameof(this.StartTalkAsync))); var response = await this.client.VoiceClient.StartTalkAsync(uuid, new TalkCommand { Text = "Hello. How are you today?", @@ -681,42 +409,11 @@ public async Task StartTalkAsyncWithCredentials() Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); } - [Fact] - public void StartTalkWithCredentials() - { - var uuid = this.fixture.Create(); - var command = new TalkCommand - { - Text = "Hello. How are you today?", - Loop = 0, - Level = "0.4", - VoiceName = "salli", - Language = "en-US", - Style = 1, - Premium = true, - }; - this.Setup($"{BaseUri}/{uuid}/talk", this.GetResponseJson(nameof(this.StartTalk)), this.GetRequestJson()); - var response = - this.client.VoiceClient.StartTalk(uuid, command, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("Talk started", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - - [Fact] - public void StopStream() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson()); - var response = this.client.VoiceClient.StopStream(uuid); - Assert.Equal("Stream stopped", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task StopStreamAsync() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopStream))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson()); var response = await this.client.VoiceClient.StopStreamAsync(uuid); Assert.Equal("Stream stopped", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -726,38 +423,18 @@ public async Task StopStreamAsync() public async Task StopStreamAsyncWithCredentials() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopStream))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopStreamAsync))); var response = await this.client.VoiceClient.StopStreamAsync(uuid, this.BuildCredentialsForBearerAuthentication()); Assert.Equal("Stream stopped", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); } - [Fact] - public void StopStreamWithCredentials() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopStream))); - var response = this.client.VoiceClient.StopStream(uuid, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("Stream stopped", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - - [Fact] - public void StopTalk() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson()); - var response = this.client.VoiceClient.StopStream(uuid); - Assert.Equal("Talk stopped", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task StopTalkAsync() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopTalk))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson()); var response = await this.client.VoiceClient.StopStreamAsync(uuid); Assert.Equal("Talk stopped", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); @@ -767,23 +444,13 @@ public async Task StopTalkAsync() public async Task StopTalkAsyncWithCredentials() { var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopTalk))); + this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopTalkAsync))); var response = await this.client.VoiceClient.StopStreamAsync(uuid, this.BuildCredentialsForBearerAuthentication()); Assert.Equal("Talk stopped", response.Message); Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); } - [Fact] - public void StopTalkWithCredentials() - { - var uuid = this.fixture.Create(); - this.Setup($"{BaseUri}/{uuid}/stream", this.GetResponseJson(nameof(this.StopTalk))); - var response = this.client.VoiceClient.StopStream(uuid, this.BuildCredentialsForBearerAuthentication()); - Assert.Equal("Talk stopped", response.Message); - Assert.Equal("63f61863-4a51-4f6b-86e1-46edebcf9356", response.Uuid); - } - [Fact] public async Task UpdateCallAsync() { @@ -794,28 +461,8 @@ public async Task UpdateCallAsync() Assert.True(response); } - [Theory] - [InlineData(CallEditCommand.ActionType.hangup)] - [InlineData(CallEditCommand.ActionType.mute)] - [InlineData(CallEditCommand.ActionType.unmute)] - [InlineData(CallEditCommand.ActionType.earmuff)] - [InlineData(CallEditCommand.ActionType.unearmuff)] - [InlineData(CallEditCommand.ActionType.transfer)] - public void UpdateCallWithActionsType(CallEditCommand.ActionType actionType) - { - var uuid = this.fixture.Create().ToString(); - var expectedRequestContent = this.GetRequestJson().Replace("$action", actionType.ToString().ToLower()); - var request = new CallEditCommand - { - Destination = new Destination {Type = "ncco", Url = new[] {"https://example.com/ncco.json"}}, - Action = actionType, - }; - this.Setup($"{BaseUri}/{uuid}", string.Empty, expectedRequestContent); - Assert.True(this.client.VoiceClient.UpdateCall(uuid, request)); - } - [Fact] - public void UpdateCallWithCredentials() + public async Task UpdateCallWithCredentials() { var uuid = this.fixture.Create().ToString(); var request = new CallEditCommand @@ -825,12 +472,13 @@ public void UpdateCallWithCredentials() }; this.Setup($"{BaseUri}/{uuid}", string.Empty, this.GetRequestJson()); var response = - this.client.VoiceClient.UpdateCall(uuid, request, this.BuildCredentialsForBearerAuthentication()); + await this.client.VoiceClient.UpdateCallAsync(uuid, request, + this.BuildCredentialsForBearerAuthentication()); Assert.True(response); } [Fact] - public void UpdateCallWithInlineNcco() + public async Task UpdateCallWithInlineNcco() { var uuid = this.fixture.Create().ToString(); var request = new CallEditCommand @@ -839,7 +487,7 @@ public void UpdateCallWithInlineNcco() Action = CallEditCommand.ActionType.transfer, }; this.Setup($"{BaseUri}/{uuid}", string.Empty, this.GetRequestJson()); - Assert.True(this.client.VoiceClient.UpdateCall(uuid, request)); + Assert.True(await this.client.VoiceClient.UpdateCallAsync(uuid, request)); } private VonageClient BuildClientWithBasicAuthentication() => diff --git a/Vonage.Test/Vonage.Test.csproj b/Vonage.Test/Vonage.Test.csproj index ad73d4a78..b1b0bd07a 100644 --- a/Vonage.Test/Vonage.Test.csproj +++ b/Vonage.Test/Vonage.Test.csproj @@ -164,7 +164,7 @@ PreserveNewest - + PreserveNewest @@ -687,13 +687,7 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - - + PreserveNewest @@ -702,28 +696,28 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -732,19 +726,19 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest @@ -753,13 +747,13 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest diff --git a/Vonage/Voice/IVoiceClient.cs b/Vonage/Voice/IVoiceClient.cs index 915943040..69abaf84f 100644 --- a/Vonage/Voice/IVoiceClient.cs +++ b/Vonage/Voice/IVoiceClient.cs @@ -2,8 +2,6 @@ using Vonage.Common; using Vonage.Common.Exceptions; using Vonage.Request; -using Vonage.Voice.Nccos; -using Vonage.Voice.Nccos.Endpoints; namespace Vonage.Voice; @@ -12,35 +10,6 @@ namespace Vonage.Voice; /// public interface IVoiceClient { - /// - /// POST /v1/calls - create an outbound SIP or PSTN Call - /// - /// - /// (Optional) Overridden credentials for only this request - /// - /// thrown if an error is encountered when talking to the API - CallResponse CreateCall(CallCommand command, Credentials creds = null); - - /// - /// POST /v1/calls - create an outbound PSTN Call - /// - /// - /// - /// - /// - /// thrown if an error is encountered when talking to the API - CallResponse CreateCall(string toNumber, string fromNumber, Ncco ncco); - - /// - /// POST /v1/calls - create an outbound without PSTN Call - /// - /// - /// - /// - /// - /// thrown if an error is encountered when talking to the API - CallResponse CreateCall(Endpoint toEndPoint, string fromNumber, Ncco ncco); - /// /// POST /v1/calls - create an outbound SIP or PSTN Call /// @@ -50,34 +19,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task CreateCallAsync(CallCommand command, Credentials creds = null); - /// - /// POST /v1/calls - create an outbound PSTN Call - /// - /// - /// - /// - /// - /// thrown if an error is encountered when talking to the API - Task CreateCallAsync(string toNumber, string fromNumber, Ncco ncco); - - /// - /// POST /v1/calls - create an outbound without PSTN Call - /// - /// - /// - /// - /// - /// thrown if an error is encountered when talking to the API - Task CreateCallAsync(Endpoint toEndPoint, string fromNumber, Ncco ncco); - - /// - /// GET /v1/calls/{uuid} - retrieve information about a single Call - /// - /// id of call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallRecord GetCall(string id, Credentials creds = null); - /// /// GET /v1/calls/{uuid} - retrieve information about a single Call /// @@ -86,14 +27,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task GetCallAsync(string id, Credentials creds = null); - /// - /// GET /v1/calls - retrieve information about all your Calls - /// Filter to search calls on - /// (Optional) Overridden credentials for only this request - /// - /// thrown if an error is encountered when talking to the API - PageResponse GetCalls(CallSearchFilter filter, Credentials creds = null); - /// /// GET /v1/calls - retrieve information about all your Calls /// Filter to search calls on @@ -102,15 +35,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task> GetCallsAsync(CallSearchFilter filter, Credentials creds = null); - /// - /// GET - retrieves the recording from a call based off of the input url - /// - /// Url where the recorded call lives - /// Overridden credentials - /// thrown if an error is encountered when talking to the API - /// A response containing a byte array representing the file stream - GetRecordingResponse GetRecording(string recordingUrl, Credentials creds = null); - /// /// GET - retrieves the recording from a call based off of the input url /// @@ -120,15 +44,6 @@ public interface IVoiceClient /// A response containing a byte array representing the file stream Task GetRecordingAsync(string recordingUrl, Credentials creds = null); - /// - /// PUT /v1/calls/{uuid}/dtmf - send Dual-tone multi-frequency(DTMF) tones to an active Call - /// - /// id of call - /// Command to execute against call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallCommandResponse StartDtmf(string id, DtmfCommand cmd, Credentials creds = null); - /// /// PUT /v1/calls/{uuid}/dtmf - send Dual-tone multi-frequency(DTMF) tones to an active Call /// @@ -138,15 +53,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task StartDtmfAsync(string id, DtmfCommand cmd, Credentials creds = null); - /// - /// PUT /v1/calls/{uuid}/stream - stream an audio file to an active Call - /// - /// id of call - /// Command to execute against call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallCommandResponse StartStream(string id, StreamCommand command, Credentials creds = null); - /// /// PUT /v1/calls/{uuid}/stream - stream an audio file to an active Call /// @@ -156,15 +62,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task StartStreamAsync(string id, StreamCommand command, Credentials creds = null); - /// - /// PUT /v1/calls/{uuid}/talk - send a synthesized speech message to an active Call - /// - /// id of call - /// Command to execute against call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallCommandResponse StartTalk(string id, TalkCommand cmd, Credentials creds = null); - /// /// PUT /v1/calls/{uuid}/talk - send a synthesized speech message to an active Call /// @@ -174,14 +71,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task StartTalkAsync(string id, TalkCommand cmd, Credentials creds = null); - /// - /// DELETE /v1/calls/{uuid}/stream - stop streaming an audio file to an active Call - /// - /// id of call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallCommandResponse StopStream(string id, Credentials creds = null); - /// /// DELETE /v1/calls/{uuid}/stream - stop streaming an audio file to an active Call /// @@ -190,14 +79,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task StopStreamAsync(string id, Credentials creds = null); - /// - /// DELETE /v1/calls/{uuid}/talk - stop sending a synthesized speech message to an active Call - /// - /// id of call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - CallCommandResponse StopTalk(string id, Credentials creds = null); - /// /// DELETE /v1/calls/{uuid}/talk - stop sending a synthesized speech message to an active Call /// @@ -206,15 +87,6 @@ public interface IVoiceClient /// thrown if an error is encountered when talking to the API Task StopTalkAsync(string id, Credentials creds = null); - /// - /// PUT /v1/calls/{uuid} - modify an existing Call - /// - /// id of call - /// Command to execute against call - /// (Optional) Overridden credentials for only this request - /// thrown if an error is encountered when talking to the API - bool UpdateCall(string id, CallEditCommand command, Credentials creds = null); - /// /// PUT /v1/calls/{uuid} - modify an existing Call /// diff --git a/Vonage/Voice/VoiceClient.cs b/Vonage/Voice/VoiceClient.cs index 3c0fd818f..b7ca89137 100644 --- a/Vonage/Voice/VoiceClient.cs +++ b/Vonage/Voice/VoiceClient.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Vonage.Common; using Vonage.Request; -using Vonage.Voice.Nccos; -using Vonage.Voice.Nccos.Endpoints; namespace Vonage.Voice; @@ -34,58 +32,6 @@ internal VoiceClient(Credentials credentials, Configuration configuration, ITime this.timeProvider = timeProvider; } - /// - [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, this.configuration, CallsEndpoint), - command, - AuthType.Bearer - ); - - /// - [Obsolete("Favor 'CreateCall(CallCommand) instead.'")] - public CallResponse CreateCall(string toNumber, string fromNumber, Ncco ncco) - { - var command = new CallCommand - { - To = new Endpoint[] - { - new PhoneEndpoint - { - Number = toNumber, - }, - }, - From = new PhoneEndpoint - { - Number = fromNumber, - }, - Ncco = ncco, - }; - return this.CreateCall(command); - } - - /// - [Obsolete("Favor 'CreateCall(CallCommand) instead.'")] - public CallResponse CreateCall(Endpoint toEndPoint, string fromNumber, Ncco ncco) - { - var command = new CallCommand - { - To = new[] - { - toEndPoint, - }, - From = new PhoneEndpoint - { - Number = fromNumber, - }, - Ncco = ncco, - }; - return this.CreateCall(command); - } - /// public Task CreateCallAsync(CallCommand command, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -96,56 +42,6 @@ public Task CreateCallAsync(CallCommand command, Credentials creds AuthType.Bearer ); - /// - [Obsolete("Favor 'CreateCallAsync(CallCommand) instead.'")] - public Task CreateCallAsync(string toNumber, string fromNumber, Ncco ncco) - { - var command = new CallCommand - { - To = new Endpoint[] - { - new PhoneEndpoint - { - Number = toNumber, - }, - }, - From = new PhoneEndpoint - { - Number = fromNumber, - }, - Ncco = ncco, - }; - return this.CreateCallAsync(command); - } - - /// - [Obsolete("Favor 'CreateCallAsync(CallCommand) instead.'")] - public Task CreateCallAsync(Endpoint toEndPoint, string fromNumber, Ncco ncco) - { - var command = new CallCommand - { - To = new[] - { - toEndPoint, - }, - From = new PhoneEndpoint - { - Number = fromNumber, - }, - Ncco = ncco, - }; - return this.CreateCallAsync(command); - } - - /// - [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, this.configuration, $"{CallsEndpoint}/{id}"), - AuthType.Bearer - ); - /// public Task GetCallAsync(string id, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -154,16 +50,6 @@ public Task GetCallAsync(string id, Credentials creds = null) => 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, this.configuration, CallsEndpoint), - AuthType.Bearer, - filter - ); - /// public Task> GetCallsAsync(CallSearchFilter filter, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -173,19 +59,6 @@ public Task> GetCallsAsync(CallSearchFilter filter, Crede 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)); - return new GetRecordingResponse - { - ResultStream = ReadContent(response.Content).Result, - Status = response.StatusCode, - }; - } - /// public async Task GetRecordingAsync(string recordingUrl, Credentials creds = null) { @@ -199,17 +72,6 @@ await ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.time }; } - /// - [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, this.configuration, $"{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) @@ -220,17 +82,6 @@ public Task StartDtmfAsync(string id, DtmfCommand cmd, Cred 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, this.configuration, $"{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) @@ -241,17 +92,6 @@ public Task StartStreamAsync(string id, StreamCommand comma 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, this.configuration, $"{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) @@ -262,17 +102,6 @@ public Task StartTalkAsync(string id, TalkCommand cmd, Cred 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, this.configuration, $"{CallsEndpoint}/{id}/stream"), - new { }, - AuthType.Bearer - ); - /// public Task StopStreamAsync(string id, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -283,17 +112,6 @@ public Task StopStreamAsync(string id, Credentials creds = 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, this.configuration, $"{CallsEndpoint}/{id}/talk"), - new { }, - AuthType.Bearer - ); - /// public Task StopTalkAsync(string id, Credentials creds = null) => ApiRequest.Build(this.GetCredentials(creds), this.configuration, this.timeProvider) @@ -304,20 +122,6 @@ public Task StopTalkAsync(string id, Credentials creds = nu 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, this.configuration, $"{CallsEndpoint}/{id}"), - command, - AuthType.Bearer - ); - return true; - } - /// public async Task UpdateCallAsync(string id, CallEditCommand command, Credentials creds = null) {