Skip to content

Commit

Permalink
feat: support serialization for CreateConversation
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Dec 11, 2023
1 parent 51cddd7 commit 6e6cc78
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "customer_chat",
"display_name": "Customer Chat",
"image_url": "https://example.com/image.png",
"properties": {
"ttl": 60,
"type": "string",
"custom_sort_key": "string",
"custom_data": {
"property1": "string",
"property2": "string"
}
},
"numbers": [
{
"type": "phone",
"number": "447700900000"
},
{
"type": "sip",
"uri": "sip:+Htg:;xa",
"username": "string",
"password": "string"
},
{
"type": "app",
"user": "string"
},
{
"type": "websocket",
"uri": "ws://example.com:8080",
"content_type": "string"
},
{
"type": "vbc",
"extension": "447700900000"
}
],
"callback": {
"url": "http://example.com",
"event_mask": "string",
"params": {
"applicationId": "string",
"ncco_url": "http://example.com"
},
"method": "POST"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using FluentAssertions;
using Vonage.Common;
using Vonage.Common.Monads;
using Vonage.Common.Test;
using Vonage.Common.Test.Extensions;
using Vonage.Conversations.CreateConversation;
using Xunit;
using PhoneNumber = Vonage.Conversations.CreateConversation.PhoneNumber;

namespace Vonage.Test.Unit.Conversations.CreateConversation
{
Expand Down Expand Up @@ -64,7 +66,30 @@ public class SerializationTest
.Be(new Links(new HalLink(new Uri(
"https://api-us-3.vonage.com/v1/conversations/CON-dd7ca47d-0e2f-4118-adc4-905e96431459"))));
});


[Fact(Skip = "Not implemented")]
public void ShouldSerialize() => CreateConversationRequest.Build()
.WithName("customer_chat")
.WithDisplayName("Customer Chat")
.WithImageUrl(new Uri("https://example.com/image.png"))
.WithProperties(new Properties(60, "string",
"string", new Dictionary<string, string>
{
{"property1", "string"},
{"property2", "string"},
}))
.WithCallback(new Callback(new Uri("https://example.com"), "string",
new CallbackParameters("string", new Uri("https://example.com")), HttpMethod.Post))
.WithNumber(new PhoneNumber("447700900000"))
.WithNumber(new SipNumber("sip:+Htg;:xa", "string", "string"))
.WithNumber(new AppNumber("string"))
.WithNumber(new WebSocketNumber("ws://example.com:8080", "string"))
.WithNumber(new VbcNumber("447700900000"))
.Create()
.GetStringContent()
.Should()
.BeSuccess(this.helper.GetRequestJson());

[Fact]
public void ShouldSerializeDefault() => CreateConversationRequest.Build()
.Create()
Expand Down
3 changes: 3 additions & 0 deletions Vonage.Test.Unit/Vonage.Test.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,9 @@
<None Update="Conversations\CreateConversation\Data\ShouldSerializeDefault-request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Conversations\CreateConversation\Data\ShouldSerialize-request.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="node ../.scripts/init.js"/>
Expand Down

0 comments on commit 6e6cc78

Please sign in to comment.