forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIVRContentTest.java
More file actions
72 lines (57 loc) · 2.43 KB
/
IVRContentTest.java
File metadata and controls
72 lines (57 loc) · 2.43 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
65
66
67
68
69
70
71
72
package com.ringcentral;
import com.ringcentral.definitions.*;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public class IVRContentTest {
@Test
public void downloadIVRPromptContent() 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"));
IvrPrompts ivrPrompts = rc.restapi().account().ivrPrompts().list();
PromptInfo promptInfo = rc.restapi().account().ivrPrompts(ivrPrompts.records[0].id).get();
Assert.assertNotNull(promptInfo.id);
Assert.assertEquals(promptInfo.id, ivrPrompts.records[0].id);
byte[] bytes = rc.get(promptInfo.contentUri).bytes();
Assert.assertTrue(bytes.length > 0);
rc.revoke();
}
@Test
public void createIVRPromptContent() 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"));
rc.restapi().account().ivrPrompts().post(new CreateIVRPromptRequest()
.name("Uploaded via API")
.attachment(new Attachment()
.contentType("audio/mpeg")
.filename("test.mp3")
.content(Files.readAllBytes(Paths.get("./src/test/resources/test.mp3")))
));
rc.revoke();
}
@Test
public void updateIVRPromptContent() 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"));
IvrPrompts ivrPrompts = rc.restapi().account().ivrPrompts().list();
PromptInfo promptInfo = rc.restapi().account().ivrPrompts(ivrPrompts.records[0].id).get();
Assert.assertNotNull(promptInfo.id);
rc.restapi().account().ivrPrompts(promptInfo.id).put(new UpdateIVRPromptRequest()
.filename("test.mp3"));
rc.revoke();
}
}