forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSmsTest.java
More file actions
64 lines (52 loc) · 2.38 KB
/
SmsTest.java
File metadata and controls
64 lines (52 loc) · 2.38 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.ringcentral;
import com.ringcentral.definitions.CreateSMSMessage;
import com.ringcentral.definitions.GetSMSMessageInfoResponse;
import com.ringcentral.definitions.MessageStoreCallerInfoRequest;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
public class SmsTest {
@Test
public void sendSms() throws IOException, RestException {
RestClient rc = new RestClient(
System.getenv("RINGCENTRAL_CLIENT_ID"),
System.getenv("RINGCENTRAL_CLIENT_SECRET"),
System.getenv("RINGCENTRAL_SERVER_URL")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));
GetSMSMessageInfoResponse response = rc.restapi().account().extension().sms().post(
new CreateSMSMessage()
.text("hello world")
.from(new MessageStoreCallerInfoRequest().phoneNumber(System.getenv("RINGCENTRAL_SENDER")))
.to(new MessageStoreCallerInfoRequest[]{
new MessageStoreCallerInfoRequest().phoneNumber(System.getenv("RINGCENTRAL_RECEIVER"))
})
);
assertNotNull(response);
assertNotNull(response.subject);
assertTrue(response.subject.contains("hello world"));
rc.revoke();
}
@Test
public void sendSms2() throws IOException, RestException {
RestClient rc = new RestClient(
System.getenv("RINGCENTRAL_CLIENT_ID"),
System.getenv("RINGCENTRAL_CLIENT_SECRET"),
System.getenv("RINGCENTRAL_SERVER_URL")
);
rc.authorize(System.getenv("RINGCENTRAL_JWT_TOKEN"));
CreateSMSMessage requestBody = new CreateSMSMessage();
requestBody.text = "hello world";
requestBody.from = new MessageStoreCallerInfoRequest();
requestBody.from.phoneNumber = System.getenv("RINGCENTRAL_SENDER");
MessageStoreCallerInfoRequest callee = new MessageStoreCallerInfoRequest();
callee.phoneNumber = System.getenv("RINGCENTRAL_RECEIVER");
requestBody.to = new MessageStoreCallerInfoRequest[]{callee};
GetSMSMessageInfoResponse response = rc.restapi().account().extension().sms().post(requestBody);
assertNotNull(response);
assertNotNull(response.subject);
assertTrue(response.subject.contains("hello world"));
rc.revoke();
}
}