-
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 responses serialization in Conversations
- Loading branch information
Showing
20 changed files
with
588 additions
and
34 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
29 changes: 29 additions & 0 deletions
29
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeAudioMessage-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,29 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "audio", | ||
"audio": { | ||
"url": "https://example.com/audio.mp3" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeCustomMessage-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,27 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "custom", | ||
"custom": {} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeFileMessage-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,29 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "file", | ||
"file": { | ||
"url": "https://example.com/file.txt" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeImageMessage-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,29 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "image", | ||
"image": { | ||
"url": "https://example.com/image.png" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeLocationMessage-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,32 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "location", | ||
"location": { | ||
"longitude": "Longitude", | ||
"latitude": "Latitude", | ||
"name": "Name", | ||
"address": "Address" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeTemplateMessage-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,34 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "template", | ||
"template": { | ||
"name": "Template", | ||
"parameters": [], | ||
"whatsapp": { | ||
"policy": "deterministic", | ||
"locale": "en-US" | ||
} | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeTextMessage-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,27 @@ | ||
{ | ||
"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": {} | ||
}, | ||
"from_member": { | ||
"id": "string" | ||
} | ||
}, | ||
"_links": { | ||
"self": { | ||
"href": "https://api.nexmo.com/v0.1/conversations/CON-1234/events/100" | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeVcardMessage-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,32 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "vcard", | ||
"vcard": { | ||
"url": "https://example.com/file.txt" | ||
}, | ||
"image": { | ||
"url": "https://example.com/image.png" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Vonage.Test/Conversations/GetEvent/Data/ShouldDeserializeVideoMessage-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,29 @@ | ||
{ | ||
"id": 100, | ||
"type": "message", | ||
"from": "string", | ||
"body": { | ||
"message_type": "video", | ||
"video": { | ||
"url": "https://example.com/video.mkv" | ||
} | ||
}, | ||
"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" | ||
} | ||
} | ||
} |
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,48 @@ | ||
using Vonage.Conversations.GetEvent; | ||
using Vonage.Test.Common.Extensions; | ||
using Xunit; | ||
|
||
namespace Vonage.Test.Conversations.GetEvent; | ||
|
||
[Trait("Category", "Request")] | ||
public class RequestTest | ||
{ | ||
[Fact] | ||
public void GetEndpointPath_ShouldReturnApiEndpoint() => | ||
GetEventRequest.Parse("CON-123", "EVE-123") | ||
.Map(request => request.GetEndpointPath()) | ||
.Should() | ||
.BeSuccess("/v1/conversations/CON-123/events/EVE-123"); | ||
|
||
[Theory] | ||
[InlineData("")] | ||
[InlineData(" ")] | ||
[InlineData(null)] | ||
public void Parse_ShouldReturnFailure_GivenConversationIdIsEmpty(string invalidId) => | ||
GetEventRequest.Parse(invalidId, "MEM-123") | ||
.Should() | ||
.BeParsingFailure("ConversationId cannot be null or whitespace."); | ||
|
||
[Theory] | ||
[InlineData("")] | ||
[InlineData(" ")] | ||
[InlineData(null)] | ||
public void Parse_ShouldReturnFailure_GivenEventIdIsEmpty(string invalidId) => | ||
GetEventRequest.Parse("CON-123", invalidId) | ||
.Should() | ||
.BeParsingFailure("EventId cannot be null or whitespace."); | ||
|
||
[Fact] | ||
public void Parse_ShouldSetConversationId() => | ||
GetEventRequest.Parse("CON-123", "EVE-123") | ||
.Map(request => request.ConversationId) | ||
.Should() | ||
.BeSuccess("CON-123"); | ||
|
||
[Fact] | ||
public void Parse_ShouldSetMemberId() => | ||
GetEventRequest.Parse("CON-123", "EVE-123") | ||
.Map(request => request.EventId) | ||
.Should() | ||
.BeSuccess("EVE-123"); | ||
} |
Oops, something went wrong.