Skip to content

Commit

Permalink
feat: implement CreateMember in Conversations
Browse files Browse the repository at this point in the history
  • Loading branch information
Tr00d committed Jun 3, 2024
1 parent 9ddba24 commit 5e01bf3
Show file tree
Hide file tree
Showing 21 changed files with 1,134 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"id": "MEM-63f61863-4a51-4f6b-86e1-46edebio0391",
"conversation_id": "CON-d66d47de-5bcb-4300-94f0-0c9d4b948e9a",
"_embedded": {
"user": {
"id": "USR-82e028d9-5201-4f1e-8188-604b2d3471ec",
"name": "my_user_name",
"display_name": "My User Name",
"_links": {
"self": {
"href": "https://api.nexmo.com/v1/users/USR-82e028d9-5201-4f1e-8188-604b2d3471ec"
}
}
}
},
"state": "JOINED",
"timestamp": {
"invited": "2020-01-01T14:00:00.00Z",
"joined": "2020-01-01T14:00:00.00Z",
"left": "2020-01-01T14:00:00.00Z"
},
"initiator": {
"joined": {
"is_system": true,
"user_id": "USR-82e028d9-5201-4f1e-8188-604b2d3471ec",
"member_id": "MEM-63f61863-4a51-4f6b-86e1-46edebio0391"
}
},
"channel": {
"type": "app",
"from": {
"type": "app"
},
"to": {
"type": "app",
"user": "string"
}
},
"media": {
"audio_settings": {
"enabled": true,
"earmuffed": true,
"muted": true
},
"audio": true
},
"knocking_id": "string",
"invited_by": "MEM-63f61863-4a51-4f6b-86e1-46edebio0378",
"_links": {
"href": "https://api.nexmo.com/v1/conversations/CON-63f61863-4a51-4f6b-86e1-46edebio0391/members/MEM-63f61863-4a51-4f6b-86e1-46edebio0391"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "app",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "app",
"user": "USR-123"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "messenger",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "messenger",
"id": "1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "mms",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "mms",
"number": "123456789"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "phone",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "phone",
"number": "123456789"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "sms",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "sms",
"number": "123456789"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "viber",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "viber",
"id": "1"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"state": "invited",
"user": {
"id": "USR-123",
"name": "User 123"
},
"channel": {
"type": "whatsapp",
"from": {
"type": "app,phone,sms"
},
"to": {
"type": "whatsapp",
"number": "123456789"
}
}
}
37 changes: 37 additions & 0 deletions Vonage.Test/Conversations/CreateMember/E2ETest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Net;
using System.Threading.Tasks;
using Vonage.Common.Monads;
using Vonage.Conversations.CreateMember;
using Vonage.Test.Common.Extensions;
using WireMock.ResponseBuilders;
using Xunit;

namespace Vonage.Test.Conversations.CreateMember;

[Trait("Category", "E2E")]
public class E2ETest : E2EBase
{
public E2ETest() : base(typeof(E2ETest).Namespace)
{
}

[Fact]
public Task CreateMember_WithApp() =>
this.CreateConversationAsync(this.Serialization.GetRequestJson(nameof(SerializationTest.ShouldSerializeApp)),
SerializationTest.BuildAppRequest());

private async Task CreateConversationAsync(string jsonRequest, Result<CreateMemberRequest> request)
{
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create()
.WithPath("/v1/conversations/CON-123/members")
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue)
.WithBody(jsonRequest)
.UsingPost())
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK)
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200))));
await this.Helper.VonageClient.ConversationsClient
.CreateMemberAsync(request)
.Should()
.BeSuccessAsync(SerializationTest.VerifyResponse);
}
}
Loading

0 comments on commit 5e01bf3

Please sign in to comment.