-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathVoiceClient.java
More file actions
72 lines (59 loc) · 2.81 KB
/
VoiceClient.java
File metadata and controls
72 lines (59 loc) · 2.81 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.telesign;
import java.io.IOException;
import java.net.Proxy;
import java.security.GeneralSecurityException;
import java.util.HashMap;
import java.util.Map;
/**
* TeleSign's Voice API allows you to easily send voice messages. You can send alerts, reminders, and notifications,
* or you can send verification messages containing time-based, one-time passcodes (TOTP).
*/
public class VoiceClient extends RestClient {
private static final String VOICE_RESOURCE = "/v1/voice";
private static final String VOICE_STATUS_RESOURCE = "/v1/voice/%s";
public VoiceClient(String customerId, String apiKey) {
super(customerId, apiKey);
}
public VoiceClient(String customerId, String apiKey, String restEndpoint) {
super(customerId, apiKey, restEndpoint);
}
public VoiceClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
}
public VoiceClient(String customerId,
String apiKey,
String restEndpoint,
Integer connectTimeout,
Integer readTimeout,
Integer writeTimeout,
Proxy proxy,
final String proxyUsername,
final String proxyPassword,
final String source,
final String sdkVersionOrigin,
final String sdkVersionDependency) {
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
}
/**
* Send a voice call to the target phone_number.
* <p>
* See https://developer.telesign.com/docs/voice-api for detailed API documentation.
*/
public TelesignResponse call(String phoneNumber, String message, String messageType, Map<String, String> params) throws IOException, GeneralSecurityException {
if (params == null) {
params = new HashMap<>();
}
params.put("phone_number", phoneNumber);
params.put("message", message);
params.put("message_type", messageType);
return this.post(VOICE_RESOURCE, params);
}
/**
* Retrieves the current status of the voice call.
* <p>
* See https://developer.telesign.com/docs/voice-api for detailed API documentation.
*/
public TelesignResponse status(String referenceId, Map<String, String> params) throws IOException, GeneralSecurityException {
return this.get(String.format(VOICE_STATUS_RESOURCE, referenceId), params);
}
}