Skip to content

Commit 7fad9e6

Browse files
committed
feat: add missing properties to Voice Answer webhook
1 parent 3151b6c commit 7fad9e6

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

Vonage.Test/Voice/Data/Answer.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"uuid": "aaaaaaaa-bbbb-cccc-dddd-0123456789ab",
55
"conversation_uuid": "CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab",
66
"SipHeader_X-Test": "test",
7-
"SipHeader_X-Value": "value"
7+
"SipHeader_X-Value": "value",
8+
"from_user": "Karen",
9+
"endpoint_type": "sip",
10+
"region_url": "https://example.com",
11+
"custom_data": {
12+
"key": "value"
13+
}
814
}

Vonage.Test/Voice/WebhookStructsTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Newtonsoft.Json;
88
using Vonage.Voice.AnswerWebhooks;
99
using Vonage.Voice.EventWebhooks;
10+
using Vonage.Voice.Nccos.Endpoints;
1011
using Xunit;
1112
using JsonSerializer = System.Text.Json.JsonSerializer;
1213
using Record = Vonage.Voice.EventWebhooks.Record;
@@ -233,6 +234,13 @@ private static void VerifyAnswer(Answer input)
233234
{"SipHeader_X-Test", "test"},
234235
{"SipHeader_X-Value", "value"},
235236
});
237+
input.CustomData.Should().BeEquivalentTo(new Dictionary<string, string>
238+
{
239+
{"key", "value"},
240+
});
241+
input.FromUser.Should().Be("Karen");
242+
input.EndpointType.Should().Be(Endpoint.EndpointType.Sip);
243+
input.RegionUrl.Should().Be(new Uri("https://example.com"));
236244
}
237245

238246
[Theory]

Vonage/Voice/AnswerWebhooks/Answer.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#region
2+
using System;
23
using System.Collections.Generic;
34
using System.Linq;
45
using System.Text.Json;
56
using System.Text.Json.Serialization;
67
using Newtonsoft.Json;
8+
using Newtonsoft.Json.Converters;
79
using Newtonsoft.Json.Linq;
810
using Vonage.Voice.EventWebhooks;
11+
using Vonage.Voice.Nccos.Endpoints;
912
#endregion
1013

1114
namespace Vonage.Voice.AnswerWebhooks;
@@ -40,6 +43,38 @@ public class Answer : EventBase
4043
[JsonPropertyName("conversation_uuid")]
4144
public string ConversationUuid { get; set; }
4245

46+
/// <summary>
47+
/// The username that called to only if the call was made using the Client SDK. In this case, from will be absent (that
48+
/// is, from and from_user will never both be present together).
49+
/// </summary>
50+
[JsonProperty("from_user")]
51+
[JsonPropertyName("from_user")]
52+
public string FromUser { get; set; }
53+
54+
/// <summary>
55+
/// The voice channel type that answered the call. Possible values are phone, sip, websocket, app, vbc.
56+
/// </summary>
57+
[JsonProperty("endpoint_type")]
58+
[JsonPropertyName("endpoint_type")]
59+
[Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))]
60+
[System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter<Endpoint.EndpointType>))]
61+
public Endpoint.EndpointType EndpointType { get; set; }
62+
63+
/// <summary>
64+
/// Regional API endpoint which should be used to control the call with REST API.
65+
/// </summary>
66+
[JsonProperty("region_url")]
67+
[JsonPropertyName("region_url")]
68+
public Uri RegionUrl { get; set; }
69+
70+
/// <summary>
71+
/// A custom data object, optionally passed as parameter on the serverCall method when a call is initiated from an
72+
/// application using the Client SDK
73+
/// </summary>
74+
[JsonProperty("custom_data")]
75+
[JsonPropertyName("custom_data")]
76+
public Dictionary<string, string> CustomData { get; set; }
77+
4378
/// <summary>
4479
/// Captures all additional unmapped properties from the JSON payload.
4580
/// This is used internally to store extension data including SIP headers.

0 commit comments

Comments
 (0)