forked from ringcentral/RingCentral.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CallLogTest.cs
74 lines (68 loc) · 2.97 KB
/
CallLogTest.cs
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using Xunit;
namespace RingCentral.Tests
{
public class CallLogTest
{
[Fact]
public async void GetCallLogs()
{
using (var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
))
{
await rc.Authorize(
Environment.GetEnvironmentVariable("RINGCENTRAL_USERNAME"),
Environment.GetEnvironmentVariable("RINGCENTRAL_EXTENSION"),
Environment.GetEnvironmentVariable("RINGCENTRAL_PASSWORD")
);
var callLogResponse = await rc.Restapi().Account().CallLog().List(new ReadCompanyCallLogParameters
{
perPage = 3,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o")
});
Assert.Equal(3, callLogResponse.records.Length);
}
}
[Fact]
public async void FilterByPhoneNumber()
{
using (var rc = new RestClient(
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_ID"),
Environment.GetEnvironmentVariable("RINGCENTRAL_CLIENT_SECRET"),
Environment.GetEnvironmentVariable("RINGCENTRAL_SERVER_URL")
))
{
await rc.Authorize(
Environment.GetEnvironmentVariable("RINGCENTRAL_USERNAME"),
Environment.GetEnvironmentVariable("RINGCENTRAL_EXTENSION"),
Environment.GetEnvironmentVariable("RINGCENTRAL_PASSWORD")
);
var callLogResponse = await rc.Restapi().Account().Extension().CallLog().List(
new ReadUserCallLogParameters
{
perPage = 1,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o")
});
Assert.Single(callLogResponse.records);
var fromNumber = callLogResponse.records[0][email protected];
callLogResponse = await rc.Restapi().Account().Extension().CallLog().List(new ReadUserCallLogParameters
{
perPage = 1,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o"),
phoneNumber = fromNumber // +123456789
});
Assert.Empty(callLogResponse.records);
callLogResponse = await rc.Restapi().Account().Extension().CallLog().List(new ReadUserCallLogParameters
{
perPage = 1,
dateFrom = DateTime.UtcNow.AddMonths(-6).ToString("o"),
phoneNumber = fromNumber.TrimStart('+') // 123456789
});
Assert.Single(callLogResponse.records);
}
}
}
}