diff --git a/Vonage.Test/WebhookStructsTest.cs b/Vonage.Test/WebhookStructsTest.cs index 1f1184033..06d81330d 100644 --- a/Vonage.Test/WebhookStructsTest.cs +++ b/Vonage.Test/WebhookStructsTest.cs @@ -269,30 +269,6 @@ public void TestHumanMachine(string type) DateTimeStyles.AdjustToUniversal), humanMachineWebhook.TimeStamp); } - [Fact] - public void TestInputOld() - { - var json = @" - { - ""from"":""442079460000"", - ""to"":""447700900000"", - ""uuid"":""aaaaaaaa-bbbb-cccc-dddd-0123456789ab"", - ""conversation_uuid"":""CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab"", - ""dtmf"":""42"", - ""timed_out"":""true"", - ""timestamp"":""2020-01-01T12:00:00.000Z"" - }"; - var inputWebhook = (Input) EventBase.ParseEvent(json); - Assert.Equal("442079460000", inputWebhook.From); - Assert.Equal("447700900000", inputWebhook.To); - Assert.Equal("42", inputWebhook.Dtmf); - Assert.Equal("aaaaaaaa-bbbb-cccc-dddd-0123456789ab", inputWebhook.Uuid); - Assert.Equal("CON-aaaaaaaa-bbbb-cccc-dddd-0123456789ab", inputWebhook.ConversationUuid); - 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), inputWebhook.TimeStamp); - } - [Fact] public void TestNotifications() { diff --git a/Vonage/Voice/EventWebhooks/EventBase.cs b/Vonage/Voice/EventWebhooks/EventBase.cs index f8866bba3..fcbd53f0c 100644 --- a/Vonage/Voice/EventWebhooks/EventBase.cs +++ b/Vonage/Voice/EventWebhooks/EventBase.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; +using System; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using System; using Vonage.Serialization; namespace Vonage.Voice.EventWebhooks; @@ -15,8 +15,7 @@ public class EventBase public static EventBase ParseEvent(string json) { - var data = (JObject)JsonConvert.DeserializeObject(json); - + var data = (JObject) JsonConvert.DeserializeObject(json); if (data.Property("status") != null) { return DeserializeStatus(json, data.Property("status")); @@ -36,7 +35,7 @@ public static EventBase ParseEvent(string json) { if (data["dtmf"].Type == JTokenType.String) { - return JsonConvert.DeserializeObject(json, VonageSerialization.SerializerSettings); + return JsonConvert.DeserializeObject(json, VonageSerialization.SerializerSettings); } return JsonConvert.DeserializeObject(json, VonageSerialization.SerializerSettings); @@ -57,7 +56,7 @@ public static EventBase ParseEvent(string json) private static EventBase DeserializeStatus(string json, JProperty statusProperty) { - var status = ((string)statusProperty.Value).ToLower(); + var status = ((string) statusProperty.Value).ToLower(); switch (status) { case "started": diff --git a/Vonage/Voice/EventWebhooks/Input.cs b/Vonage/Voice/EventWebhooks/Input.cs deleted file mode 100644 index e6177cbbd..000000000 --- a/Vonage/Voice/EventWebhooks/Input.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Newtonsoft.Json; -using System; - -namespace Vonage.Voice.EventWebhooks; - -[Obsolete("This item has been rendered obsolete due to the new multi-input functionality. Please add dtmf arguments to your input action and use the MultiInput object - see: https://developer.nexmo.com/voice/voice-api/ncco-reference#dtmf-input-settings")] -public class Input : Event -{ - /// - /// The buttons pressed by the user - /// - [JsonProperty("dtmf")] - public string Dtmf { get; set; } - - /// - /// Whether the input action timed out: true if it did, false if not - /// - [JsonProperty("timed_out")] - public bool TimedOut { get; set; } - - /// - /// The unique identifier for this conversation - /// - [JsonProperty("conversation_uuid")] - public string ConversationUuid { get; set; } - - /// - /// The number the call came from - /// - [JsonProperty("from")] - public string From { get; set; } - - /// - /// The number the call was made to - /// - [JsonProperty("to")] - public string To { get; set; } -} \ No newline at end of file diff --git a/Vonage/Voice/EventWebhooks/MultiInput.cs b/Vonage/Voice/EventWebhooks/MultiInput.cs index 1cfdf86ed..f07739962 100644 --- a/Vonage/Voice/EventWebhooks/MultiInput.cs +++ b/Vonage/Voice/EventWebhooks/MultiInput.cs @@ -2,17 +2,44 @@ namespace Vonage.Voice.EventWebhooks; -public class MultiInput : Input +public class MultiInput : Event { /// /// Result of Dtmf input /// [JsonProperty("dtmf")] - public new DtmfResult Dtmf { get; set; } + public DtmfResult Dtmf { get; set; } /// /// Result of the speech recognition /// [JsonProperty("speech")] public SpeechResult Speech { get; set; } + + /// + /// The buttons pressed by the user + /// + /// + /// Whether the input action timed out: true if it did, false if not + /// + [JsonProperty("timed_out")] + public bool TimedOut { get; set; } + + /// + /// The unique identifier for this conversation + /// + [JsonProperty("conversation_uuid")] + public string ConversationUuid { get; set; } + + /// + /// The number the call came from + /// + [JsonProperty("from")] + public string From { get; set; } + + /// + /// The number the call was made to + /// + [JsonProperty("to")] + public string To { get; set; } } \ No newline at end of file