Skip to content

Commit

Permalink
fix: add missing properties on Number
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Aug 7, 2024
1 parent bd0e9d8 commit 7062559
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
39 changes: 35 additions & 4 deletions Vonage.Test/NumbersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class NumbersTests : TestBase
public NumbersTests()
{
this.credentials = this.BuildCredentials();
this.client = this.BuildVonageClient(credentials);
this.client = this.BuildVonageClient(this.credentials);
}

[Fact]
Expand Down Expand Up @@ -91,7 +91,7 @@ public async Task FailedPurchase()
}

[Fact]
public async Task GetAvailableNumbers()
public async Task GetAvailableNumbersAsync()
{
const string expectedResponse =
@"{""count"": 1234,""numbers"": [{""country"": ""GB"",""msisdn"": ""447700900000"",""type"": ""mobile-lvn"",""cost"": ""1.25"",""features"": [""VOICE"",""SMS""]}]}";
Expand All @@ -111,10 +111,10 @@ public async Task GetAvailableNumbers()
}

[Fact]
public async Task GetAvailableNumbersAsync()
public async Task GetAvailableNumbersAsyncWithAdditionalData()
{
const string expectedResponse =
@"{""count"": 1234,""numbers"": [{""country"": ""GB"",""msisdn"": ""447700900000"",""type"": ""mobile-lvn"",""cost"": ""1.25"",""features"": [""VOICE"",""SMS""]}]}";
@"{""count"": 1234,""numbers"": [{""country"": ""GB"",""msisdn"": ""447700900000"",""type"": ""mobile-lvn"",""cost"": ""1.25"",""features"": [""VOICE"",""SMS""], ""moHttpUrl"": ""https://example.com/webhooks/inbound-sms"", ""messagesCallbackType"": ""app"", ""messagesCallbackValue"": ""aaaaaaaa-bbbb-cccc-dddd-0123456789ab"", ""voiceCallbackType"": ""app"", ""voiceCallbackValue"": ""aaaaaaaa-bbbb-cccc-dddd-0123456789ab""}]}";
var expectedUri =
$"{this.RestUrl}/number/search?country=GB&api_key={this.ApiKey}&api_secret={this.ApiSecret}&";
var request = new NumberSearchRequest {Country = "GB"};
Expand All @@ -128,6 +128,11 @@ public async Task GetAvailableNumbersAsync()
Assert.Equal("1.25", number.Cost);
Assert.Equal("VOICE", number.Features[0]);
Assert.Equal("SMS", number.Features[1]);
number.MoHttpUrl.Should().Be("https://example.com/webhooks/inbound-sms");
number.MessagesCallbackType.Should().Be("app");
number.MessagesCallbackValue.Should().Be("aaaaaaaa-bbbb-cccc-dddd-0123456789ab");
number.VoiceCallbackType.Should().Be("app");
number.VoiceCallbackValue.Should().Be("aaaaaaaa-bbbb-cccc-dddd-0123456789ab");
}

[Fact]
Expand Down Expand Up @@ -175,6 +180,32 @@ public async Task GetOwnedNumbersAsync()
number.ApplicationId.Should().BeNull();
}

[Fact]
public async Task GetOwnedNumbersAsyncWithAdditionalData()
{
const string expectedResponse =
@"{""count"": 1234,""numbers"": [{""country"": ""GB"",""msisdn"": ""447700900000"",""type"": ""mobile-lvn"",""cost"": ""1.25"",""features"": [""VOICE"",""SMS""], ""moHttpUrl"": ""https://example.com/webhooks/inbound-sms"", ""messagesCallbackType"": ""app"", ""messagesCallbackValue"": ""aaaaaaaa-bbbb-cccc-dddd-0123456789ab"", ""voiceCallbackType"": ""app"", ""voiceCallbackValue"": ""aaaaaaaa-bbbb-cccc-dddd-0123456789ab""}]}";
var expectedUri =
$"{this.RestUrl}/account/numbers?country=GB&api_key={this.ApiKey}&api_secret={this.ApiSecret}&";
var request = new NumberSearchRequest {Country = "GB"};
this.Setup(expectedUri, expectedResponse);
var response = await this.client.NumbersClient.GetOwnedNumbersAsync(request);
var number = response.Numbers[0];
Assert.Equal(1234, response.Count);
Assert.Equal("GB", number.Country);
Assert.Equal("447700900000", number.Msisdn);
Assert.Equal("mobile-lvn", number.Type);
Assert.Equal("1.25", number.Cost);
Assert.Equal("VOICE", number.Features[0]);
Assert.Equal("SMS", number.Features[1]);
number.ApplicationId.Should().BeNull();
number.MoHttpUrl.Should().Be("https://example.com/webhooks/inbound-sms");
number.MessagesCallbackType.Should().Be("app");
number.MessagesCallbackValue.Should().Be("aaaaaaaa-bbbb-cccc-dddd-0123456789ab");
number.VoiceCallbackType.Should().Be("app");
number.VoiceCallbackValue.Should().Be("aaaaaaaa-bbbb-cccc-dddd-0123456789ab");
}

[Fact]
public async Task GetOwnedNumbersAsyncWithCredentials()
{
Expand Down
30 changes: 30 additions & 0 deletions Vonage/Numbers/Number.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,34 @@ public class Number
/// </summary>
[JsonProperty("app_id")]
public string ApplicationId { get; set; }

/// <summary>
/// The URL of the webhook endpoint that handles inbound messages
/// </summary>
[JsonProperty("moHttpUrl")]
public string MoHttpUrl { get; set; }

/// <summary>
/// The messages webhook type: always app
/// </summary>
[JsonProperty("messagesCallbackType")]
public string MessagesCallbackType { get; set; }

/// <summary>
/// An Application ID
/// </summary>
[JsonProperty("messagesCallbackValue")]
public string MessagesCallbackValue { get; set; }

/// <summary>
/// The voice webhook type: sip, tel, or app
/// </summary>
[JsonProperty("voiceCallbackType")]
public string VoiceCallbackType { get; set; }

/// <summary>
/// A SIP URI, telephone number or Application ID
/// </summary>
[JsonProperty("voiceCallbackValue")]
public string VoiceCallbackValue { get; set; }
}

0 comments on commit 7062559

Please sign in to comment.