forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFaxTest.java
More file actions
51 lines (43 loc) · 1.71 KB
/
FaxTest.java
File metadata and controls
51 lines (43 loc) · 1.71 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
package com.ringcentral;
import com.ringcentral.definitions.Attachment;
import com.ringcentral.definitions.CreateFaxMessageRequest;
import com.ringcentral.definitions.FaxReceiver;
import com.ringcentral.definitions.FaxResponse;
import org.junit.Test;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import static org.junit.Assert.assertNotNull;
public class FaxTest {
@Test
public void sendFax() 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"));
FaxResponse r = rc.restapi().account().extension().fax().post(
new CreateFaxMessageRequest()
.to(new FaxReceiver[]{
new FaxReceiver()
.phoneNumber(System.getenv("RINGCENTRAL_RECEIVER"))
})
.attachments(
new Attachment[]{
new Attachment()
.filename("test.txt")
.contentType("text/plain")
.content("hello world".getBytes(StandardCharsets.UTF_8)),
new Attachment()
.filename("test.png")
.contentType("image/png")
.content(Files.readAllBytes(Paths.get("./src/test/resources/test.png")))
})
);
assertNotNull(r);
assertNotNull(r.direction);
rc.revoke();
}
}