forked from ringcentral/ringcentral-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProvisionExtensionsTest.java
More file actions
41 lines (32 loc) · 1.49 KB
/
ProvisionExtensionsTest.java
File metadata and controls
41 lines (32 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
package com.ringcentral;
import com.ringcentral.definitions.ContactInfoCreationRequest;
import com.ringcentral.definitions.ExtensionCreationRequest;
import com.ringcentral.definitions.ExtensionCreationResponse;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertNotNull;
public class ProvisionExtensionsTest {
@Test
public void CreateAndDeleteExtension() 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.httpEventListeners.add((response, request) -> {
String message = Utils.formatHttpMessage(response, request);
});
ExtensionCreationResponse extensionCreationResponse = rc.restapi().account().extension().post(new ExtensionCreationRequest()
.extensionNumber("11808").contact(new ContactInfoCreationRequest()
.email("a1b23c4d@example.com").firstName("First").lastName("Last")
)
.type("User")
);
assertNotNull(extensionCreationResponse);
// delete endpoint is deprecated, so we have to type string endpoint instead
String str = rc.delete("/restapi/v1.0/account/~/extension/" + extensionCreationResponse.id.toString()).string();
assertNotNull(str);
rc.revoke();
}
}