-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLookup.java
More file actions
56 lines (43 loc) · 1.83 KB
/
Copy pathLookup.java
File metadata and controls
56 lines (43 loc) · 1.83 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
/**
* Sinch Java Snippet
*
* <p>This snippet is available at https://github.com/sinch/sinch-sdk-java
*
* <p>See https://github.com/sinch/sinch-sdk-java/blob/main/examples/snippets/README.md for details
*/
package numberlookup;
import com.sinch.sdk.SinchClient;
import com.sinch.sdk.domains.numberlookup.api.v2.NumberLookupV2Service;
import com.sinch.sdk.domains.numberlookup.models.v2.request.LookupFeatureType;
import com.sinch.sdk.domains.numberlookup.models.v2.request.NumberLookupRequest;
import com.sinch.sdk.domains.numberlookup.models.v2.response.NumberLookupResponse;
import com.sinch.sdk.models.Configuration;
import java.util.Collections;
import java.util.logging.Logger;
import utils.Settings;
public class Lookup {
private static final Logger LOGGER = Logger.getLogger(Lookup.class.getName());
public static void main(String[] args) {
String projectId = Settings.getProjectId().orElse("MY_PROJECT_ID");
String keyId = Settings.getKeyId().orElse("MY_KEY_ID");
String keySecret = Settings.getKeySecret().orElse("MY_KEY_SECRET");
// The phone number you want to lookup in E.164 format
String phoneNumber = "PHONE_NUMBER";
Configuration configuration =
Configuration.builder()
.setProjectId(projectId)
.setKeyId(keyId)
.setKeySecret(keySecret)
.build();
SinchClient client = new SinchClient(configuration);
NumberLookupV2Service numberLookupService = client.lookup().v2();
NumberLookupRequest request =
NumberLookupRequest.builder()
.setNumber(phoneNumber)
.setFeatures(Collections.singletonList(LookupFeatureType.LINE_TYPE))
.build();
LOGGER.info("Lookup for: " + phoneNumber);
NumberLookupResponse response = numberLookupService.lookup(request);
LOGGER.info("Response: " + response);
}
}