-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement GetEvents in Conversations
- Loading branch information
Showing
18 changed files
with
799 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
Vonage.Test/Conversations/GetEvents/Data/ShouldDeserialize200-response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"page_size": 10, | ||
"_links": { | ||
"first": { | ||
"href": "https://api.nexmo.com/v1/conversations/CON-123/events?page_size=10&order=asc&exclude_deleted_events=false" | ||
}, | ||
"self": { | ||
"href": "https://api.nexmo.com/v1/conversations/CON-123/events?page_size=10&order=asc&exclude_deleted_events=false" | ||
}, | ||
"next": { | ||
"href": "https://api.nexmo.com/v1/conversations/CON-123/events?page_size=10&order=asc&exclude_deleted_events=false" | ||
}, | ||
"prev": { | ||
"href": "https://api.nexmo.com/v1/conversations/CON-123/events?page_size=10&order=asc&exclude_deleted_events=false" | ||
} | ||
}, | ||
"_embedded": [ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "text", | ||
"text": "string" | ||
}, | ||
"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": { | ||
"field_1": "value_1", | ||
"field_2": "value_2" | ||
} | ||
}, | ||
"from_member": { | ||
"id": "string" | ||
} | ||
}, | ||
"_links": { | ||
"self": { | ||
"href": "https://api.nexmo.com/v1/conversations/CON-123/events/100" | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using System; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using Vonage.Conversations; | ||
using Vonage.Conversations.GetEvents; | ||
using Vonage.Test.Common.Extensions; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.Conversations.GetEvents; | ||
|
||
[Trait("Category", "E2E")] | ||
public class E2ETest : E2EBase | ||
{ | ||
public E2ETest() : base(typeof(E2ETest).Namespace) | ||
{ | ||
} | ||
|
||
[Fact] | ||
public async Task GetEventsWithDefaultRequest() | ||
{ | ||
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() | ||
.WithPath("/v1/conversations/CON-123/events") | ||
.WithParam("page_size", "10") | ||
.WithParam("order", "asc") | ||
.WithParam("exclude_deleted_events", "false") | ||
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) | ||
.UsingGet()) | ||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) | ||
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); | ||
await this.Helper.VonageClient.ConversationsClient | ||
.GetEventsAsync(GetEventsRequest.Build() | ||
.WithConversationId("CON-123") | ||
.Create()) | ||
.Should() | ||
.BeSuccessAsync(SerializationTest.VerifyExpectedResponse); | ||
} | ||
|
||
[Fact] | ||
public async Task GetEvents() | ||
{ | ||
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() | ||
.WithPath("/v1/conversations/CON-123/events") | ||
.WithParam("page_size", "50") | ||
.WithParam("order", "desc") | ||
.WithParam("exclude_deleted_events", "true") | ||
.WithParam("event_type", "submitted") | ||
.WithParam("start_id", "123") | ||
.WithParam("end_id", "456") | ||
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) | ||
.UsingGet()) | ||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) | ||
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); | ||
await this.Helper.VonageClient.ConversationsClient | ||
.GetEventsAsync(GetEventsRequest.Build() | ||
.WithConversationId("CON-123") | ||
.WithPageSize(50) | ||
.WithOrder(FetchOrder.Descending) | ||
.WithEventType("submitted") | ||
.WithStartId("123") | ||
.WithEndId("456") | ||
.ExcludeDeletedEvents() | ||
.Create()) | ||
.Should() | ||
.BeSuccessAsync(SerializationTest.VerifyExpectedResponse); | ||
} | ||
|
||
[Fact] | ||
public async Task GetEventsFromHalLink() | ||
{ | ||
this.Helper.Server.Given(WireMock.RequestBuilders.Request.Create() | ||
.WithPath("/v1/conversations/CON-123/events") | ||
.WithParam("page_size", "50") | ||
.WithParam("order", "desc") | ||
.WithParam("exclude_deleted_events", "true") | ||
.WithParam("event_type", "submitted") | ||
.WithParam("start_id", "123") | ||
.WithParam("end_id", "456") | ||
.WithParam("cursor", "7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg=") | ||
.WithHeader("Authorization", this.Helper.ExpectedAuthorizationHeaderValue) | ||
.UsingGet()) | ||
.RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK) | ||
.WithBody(this.Serialization.GetResponseJson(nameof(SerializationTest.ShouldDeserialize200)))); | ||
await this.Helper.VonageClient.ConversationsClient | ||
.GetEventsAsync(new GetEventsHalLink(new Uri( | ||
"https://api.nexmo.com/v1/conversations/CON-123/events?page_size=50&order=desc&exclude_deleted_events=true&cursor=7EjDNQrAcipmOnc0HCzpQRkhBULzY44ljGUX4lXKyUIVfiZay5pv9wg%3D&start_id=123&end_id=456&event_type=submitted")) | ||
.BuildRequest()) | ||
.Should() | ||
.BeSuccessAsync(SerializationTest.VerifyExpectedResponse); | ||
} | ||
} |
Oops, something went wrong.