Skip to content

Commit 9a7d0b3

Browse files
Pull request #15: Added methods to get information about a specified phone number
Merge in SDK/java_telesign_enterprise from feature/EOA2093 to developer Squashed commit of the following: commit 91591186ca3eef7a8ec931afd499a9cc6676f23f Author: Juan Camilo Martinez <jmartinez@telesign.com> Date: Thu Jul 3 15:01:15 2025 -0500 Usign Path base commit 02aacf99e600097a09e48ed2a62f4cc9b98a3b9c Author: Juan Camilo Martinez <jmartinez@telesign.com> Date: Wed Jul 2 17:44:55 2025 -0500 Adjust url on comment commit 0bad509bbb61d4c17a3720cbf127e7cbd6ae2c33 Author: Juan Camilo Martinez <jmartinez@telesign.com> Date: Wed Jul 2 17:38:54 2025 -0500 Added methods to get information about a specified phone number commit cf373e9 Merge: 9d99b9d 8f00211 Author: Alexander Fermin <afermin@telesign.com> Date: Fri Jun 6 18:31:27 2025 +0000 Pull request #14: Release v2.5.0 Merge in SDK/java_telesign_enterprise from developer to master * commit '8f002111aae891962b3a148d9932546d83d481fc': Updating documentation Updating dependencies Updating changelog Adding verification process update Updating version Improving following PR comments Improving following PR comments Separating OmniVerifyClient and adding retrieve method
1 parent 8f00211 commit 9a7d0b3

4 files changed

Lines changed: 105 additions & 8 deletions

File tree

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2.6.0
2+
- Added methods to get information about a specified phone number.
3+
14
2.5.0
25
- Added method to retrieve verification process.
36
- Added unit test for retrieving verification process.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group 'com.telesign.enterprise'
2-
version '2.5.0'
2+
version '2.6.0'
33

44
apply plugin: 'java'
55
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -79,7 +79,7 @@ publishing {
7979

8080
groupId = 'com.telesign.enterprise'
8181
artifactId = 'telesignenterprise'
82-
version = '2.5.0'
82+
version = '2.6.0'
8383

8484
pom {
8585
name = 'TeleSign Enterprise SDK'

src/main/java/com/telesign/enterprise/PhoneIdClient.java

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@
1616
*/
1717
public class PhoneIdClient extends com.telesign.PhoneIdClient {
1818

19-
private static final String PHONEID_STANDARD_RESOURCE = "/v1/phoneid/standard/%s";
20-
private static final String PHONEID_SCORE_RESOURCE = "/v1/phoneid/score/%s";
21-
private static final String PHONEID_CONTACT_RESOURCE = "/v1/phoneid/contact/%s";
22-
private static final String PHONEID_LIVE_RESOURCE = "/v1/phoneid/live/%s";
23-
private static final String PHONEID_NUMBER_DEACTIVATION_RESOURCE = "/v1/phoneid/number_deactivation/%s";
19+
private static final String PHONEID_RESOURCE = "/v1/phoneid";
20+
private static final String PHONEID_STANDARD_RESOURCE = PHONEID_RESOURCE + "/standard/%s";
21+
private static final String PHONEID_SCORE_RESOURCE = PHONEID_RESOURCE + "/score/%s";
22+
private static final String PHONEID_CONTACT_RESOURCE = PHONEID_RESOURCE + "/contact/%s";
23+
private static final String PHONEID_LIVE_RESOURCE = PHONEID_RESOURCE + "/live/%s";
24+
private static final String PHONEID_NUMBER_DEACTIVATION_RESOURCE = PHONEID_RESOURCE + "/number_deactivation/%s";
25+
private static final String PHONEID_GET_INFO_RESOURCE = PHONEID_RESOURCE + "/%s";
2426
private static final String sdkVersion = PhoneIdClient.class.getPackage().getImplementationVersion();
2527
private static final String sdkSource = "java_telesign_enterprise";
2628
private static final String sdkVersionDependency = com.telesign.RestClient.class.getPackage().getImplementationVersion();
@@ -127,4 +129,48 @@ public TelesignResponse numberDeactivation(String phoneNumber, String ucid, Map<
127129

128130
return this.get(String.format(PHONEID_NUMBER_DEACTIVATION_RESOURCE, phoneNumber), params);
129131
}
132+
133+
/**
134+
* Enter a phone number with country code to receive detailed information about carrier, location, and other details.
135+
* <p>
136+
* See https://developer.telesign.com/enterprise/reference/submitphonenumberforidentity for detailed API documentation.
137+
*/
138+
139+
public TelesignResponse getInfo(String phoneNumber, Map<String, Object> params) throws IOException, GeneralSecurityException {
140+
if (params == null) {
141+
params = new HashMap<>();
142+
}
143+
144+
if (!params.containsKey("consent")) {
145+
Map<String, Object> consent = new HashMap<>();
146+
consent.put("method", 1);
147+
params.put("consent", consent);
148+
}
149+
150+
String url = String.format(PHONEID_GET_INFO_RESOURCE, phoneNumber);
151+
152+
return this.post(url, params, "application/json", "Basic");
153+
}
154+
155+
/**
156+
* Enter a phone number with country code to receive detailed information about carrier, location, and other details.
157+
* <p>
158+
* See https://developer.telesign.com/enterprise/reference/submitphonenumberforidentityalt for detailed API documentation.
159+
*/
160+
161+
public TelesignResponse getInfoAlt(String phoneNumber, Map<String, Object> params) throws IOException, GeneralSecurityException {
162+
if (params == null) {
163+
params = new HashMap<>();
164+
}
165+
166+
params.put("phone_number", phoneNumber);
167+
168+
if (!params.containsKey("consent")) {
169+
Map<String, Object> consent = new HashMap<>();
170+
consent.put("method", 1);
171+
params.put("consent", consent);
172+
}
173+
174+
return this.post(PHONEID_RESOURCE, params, "application/json", "Basic");
175+
}
130176
}

src/test/java/com/telesign/enterprise/PhoneIdClientTest.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,62 @@ public void testPhoneIdStandardWithOriginatingIp() throws Exception {
133133
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
134134

135135
assertEquals("method is not as expected", "GET", request.getMethod());
136-
assertEquals("path is not as expected", "/v1/phoneid/standard/18005555555?originating_ip=127.0.0.1", request.getPath());
136+
assertEquals("path is not as expected", "/v1/phoneid/standard/18005555555", request.getPath());
137137
assertEquals("body is not as expected", "",
138138
request.getBody().readUtf8());
139139
assertEquals("Content-Type header is not as expected", "",
140140
request.getHeader("Content-Type"));
141141
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
142142
request.getHeader("x-ts-auth-method"));
143143
}
144+
145+
public void testPhoneIdGetInfo() throws Exception {
146+
147+
HashMap<String, Object> params = new HashMap<String, Object>();
148+
149+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
150+
151+
PhoneIdClient client = new PhoneIdClient(this.customerId,
152+
this.apiKey,
153+
this.mockServer.url("").toString().replaceAll("/$", ""));
154+
155+
String phone_number = "11234567890";
156+
157+
client.getInfo(phone_number, params);
158+
159+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
160+
161+
assertEquals("method is not as expected", "POST", request.getMethod());
162+
assertEquals("path is not as expected", "/v1/phoneid/" + phone_number, request.getPath());
163+
assertEquals("body is not as expected", "{\"consent\":{\"method\":1}}",
164+
request.getBody().readUtf8());
165+
assertEquals("Content-Type header is not as expected", "application/json",
166+
request.getHeader("Content-Type"));
167+
}
168+
169+
public void testPhoneIdGetInfoAlt() throws Exception {
170+
171+
HashMap<String, Object> params = new HashMap<String, Object>();
172+
173+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
174+
175+
PhoneIdClient client = new PhoneIdClient(this.customerId,
176+
this.apiKey,
177+
this.mockServer.url("").toString().replaceAll("/$", ""));
178+
179+
String phone_number = "11234567890";
180+
181+
client.getInfoAlt(phone_number, params);
182+
183+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
184+
185+
assertEquals("method is not as expected", "POST", request.getMethod());
186+
assertEquals("path is not as expected", "/v1/phoneid", request.getPath());
187+
assertEquals("body is not as expected", "{\"consent\":{\"method\":1},\"phone_number\":\"11234567890\"}",
188+
request.getBody().readUtf8());
189+
assertEquals("Content-Type header is not as expected", "application/json",
190+
request.getHeader("Content-Type"));
191+
}
144192
}
145193

146194

0 commit comments

Comments
 (0)