diff --git a/Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeRandomMessage-response.json b/Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeRandomMessage-response.json new file mode 100644 index 00000000..21304b26 --- /dev/null +++ b/Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeRandomMessage-response.json @@ -0,0 +1,26 @@ +{ + "id": 100, + "type": "message", + "from": "string", + "body": { + "message_type": "random" + }, + "timestamp": "2020-01-01T14:00:00.00Z", + "_embedded": { + "from_user": { + "id": "USR-82e028d9-5201-4f1e-8188-604b2d3471ec", + "name": "my_user_name", + "display_name": "My User Name", + "image_url": "https://example.com/image.png", + "custom_data": {} + }, + "from_member": { + "id": "string" + } + }, + "_links": { + "self": { + "href": "https://api.nexmo.com/v0.1/conversations/CON-1234/events/100" + } + } +} \ No newline at end of file diff --git a/Vonage.Test/Conversations/GetEvent/SerializationTest.cs b/Vonage.Test/Conversations/GetEvent/SerializationTest.cs index 839ec796..cac9c3a7 100644 --- a/Vonage.Test/Conversations/GetEvent/SerializationTest.cs +++ b/Vonage.Test/Conversations/GetEvent/SerializationTest.cs @@ -81,4 +81,10 @@ public void ShouldDeserializeLocationMessage() => this.helper.Serializer .Should() .BeSuccess(BuildExpectedEvent( new EventBodyLocationMessage(new EventBodyLocation("Longitude", "Latitude", "Name", "Address")))); + + [Fact] + public void ShouldDeserializeRandomMessage() => this.helper.Serializer + .DeserializeObject(this.helper.GetResponseJson()) + .Should() + .BeSuccess(BuildExpectedEvent(new EventBodyRandomMessage())); } \ No newline at end of file diff --git a/Vonage.Test/Vonage.Test.csproj b/Vonage.Test/Vonage.Test.csproj index b3b94943..8f018385 100644 --- a/Vonage.Test/Vonage.Test.csproj +++ b/Vonage.Test/Vonage.Test.csproj @@ -1224,6 +1224,9 @@ PreserveNewest + + PreserveNewest + diff --git a/Vonage/Conversations/Event.cs b/Vonage/Conversations/Event.cs index 897826c9..da54d3b0 100644 --- a/Vonage/Conversations/Event.cs +++ b/Vonage/Conversations/Event.cs @@ -43,6 +43,7 @@ public record EmbeddedEventMember(string Id); [JsonDerivedType(typeof(EventBodyCustomMessage), "custom")] [JsonDerivedType(typeof(EventBodyVcardMessage), "vcard")] [JsonDerivedType(typeof(EventBodyLocationMessage), "location")] +[JsonDerivedType(typeof(EventBodyRandomMessage), "random")] public record EventBodyBase; public record EventBodyTextMessage(string Text) : EventBodyBase; @@ -63,4 +64,5 @@ public record EventBodyCustomMessage(object Custom) : EventBodyBase; public record EventBodyVcardMessage(EventBodyVcardUrl Vcard, EventBodyImageUrl Image) : EventBodyBase; public record EventBodyVcardUrl(string Url); public record EventBodyLocationMessage(EventBodyLocation File) : EventBodyBase; -public record EventBodyLocation(string Longitude, string Latitude, string Name, string Address); \ No newline at end of file +public record EventBodyLocation(string Longitude, string Latitude, string Name, string Address); +public record EventBodyRandomMessage : EventBodyBase; \ No newline at end of file