-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathBatchApiTest.cs
More file actions
46 lines (40 loc) · 1.49 KB
/
BatchApiTest.cs
File metadata and controls
46 lines (40 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System.Linq;
using Newtonsoft.Json;
using Xunit;
namespace RingCentral.Tests;
// This is a class to deserialize the batch result
public class MessageStoreBatchResponse
{
public string resourceId { get; set; }
public int status { get; set; }
public GetMessageInfoResponse body { get; set; }
}
[Collection("Sequential")]
public class BatchApiTest
{
[Fact]
public async void MessageStoreBatchGet()
{
var rc = await ReusableRestClient.GetInstance();
var messages = await rc.Restapi().Account().Extension().MessageStore().List(new ListMessagesParameters
{
perPage = 2,
dateFrom = "2016-03-10T18:07:52.534Z"
});
if (messages.records.Length == 2)
{
var messageIds = string.Join(",", messages.records.Select(r => r.id.ToString()));
var endpoint = rc.Restapi().Account().Extension().MessageStore(messageIds).Path();
var restRequestConfig = new RestRequestConfig();
restRequestConfig.customHeaders.Add("Accept", "application/vnd.ringcentral.multipart+json");
var result = await rc.Get<string>(endpoint, null, restRequestConfig);
Assert.NotNull(result);
// parsing
var parsed = JsonConvert.DeserializeObject<MessageStoreBatchResponse[]>(result);
Assert.NotNull(parsed);
Assert.Equal(2, parsed.Length);
Assert.NotNull(parsed[0].body);
Assert.NotNull(parsed[1].body.id);
}
}
}