Skip to content

Commit 0ec3aa9

Browse files
Pull request #17: Developer
Merge in SDK/java_telesign from developer to master * commit '3318e5e67125f60095062ef486e61e5ee3003c6d': Pull request #18: Fix details version Pull request #14: feature/EOA-5901-SS-Intellegence-Cloud-Api Pull request #16: [PD-102707] Adding checkstyle and unittest tasks and fixes
2 parents 51e61ea + 3318e5e commit 0ec3aa9

11 files changed

Lines changed: 134 additions & 47 deletions

File tree

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,19 @@ Follow these steps to add this SDK as a dependency to your project.
5050
```
5151
implementation("com.google.code.gson:gson:2.+")
5252
implementation ("com.squareup.okio:okio:2.+")
53-
implementation("com.telesign:telesign:3.+")
53+
implementation("com.telesign:telesign:4.+")
5454
```
5555

5656
That last dependency pulls in the Telesign Self-service Java SDK.
5757

58+
## Development tasks
59+
60+
Use these Gradle tasks during development:
61+
62+
- Run unit tests: `./gradlew test`
63+
- Run linter checks: `./gradlew lint`
64+
- Run CI validation (tests + linter): `./gradlew ciTest`
65+
5866
## Authentication
5967

6068
If you use a Telesign SDK to make your request, authentication is handled behind-the-scenes for you. All you need to provide is your Customer ID and API Key. The SDKs apply Digest authentication whenever they make a request to a Telesign service where it is supported. When Digest authentication is not supported, the SDKs apply Basic authentication.

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [4.0.0](http://central.maven.org/maven2/com/telesign/telesign/4.0.0) - 2026-02-06
2+
- 2026-02-06
3+
- Added support for Intelligence Cloud to use new endpoint.
4+
15
## [3.0.1](http://central.maven.org/maven2/com/telesign/telesign/3.0.1) - 2025-09-18
26
- 2025-09-18
37
- Updated SDK install instructions on GitHub to default to latest version for Telesign SDK

build.gradle

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ plugins {
55
id 'maven-publish'
66
id 'signing'
77
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
8+
id 'checkstyle'
89
}
910

1011
group 'com.telesign'
11-
version '3.0.1'
12+
version '4.0.0'
1213

1314
sourceCompatibility = JavaVersion.VERSION_1_8
1415
targetCompatibility = JavaVersion.VERSION_1_8
@@ -17,6 +18,46 @@ repositories {
1718
mavenCentral()
1819
}
1920

21+
checkstyle {
22+
toolVersion = '10.12.5'
23+
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
24+
ignoreFailures = true
25+
}
26+
27+
// Test configuration
28+
test {
29+
useJUnit()
30+
testLogging {
31+
events "passed", "skipped", "failed"
32+
exceptionFormat "full"
33+
showStandardStreams = false
34+
}
35+
}
36+
37+
// Task for linting
38+
tasks.register('lint') {
39+
group = 'verification'
40+
description = 'Runs checkstyle linter'
41+
dependsOn 'checkstyleMain', 'checkstyleTest'
42+
}
43+
44+
// Task for CI pipeline
45+
tasks.register('ciTest') {
46+
group = 'verification'
47+
description = 'Runs tests and linter for CI/CD pipeline'
48+
dependsOn 'clean', 'test', 'lint'
49+
}
50+
51+
// Task for release validation
52+
tasks.register('validateRelease') {
53+
group = 'release'
54+
description = 'Validates code is ready for release'
55+
dependsOn 'ciTest', 'javadoc', 'sourcesJar', 'javadocJar'
56+
doLast {
57+
println "✓ Release validation completed successfully"
58+
}
59+
}
60+
2061
jar {
2162
manifest {
2263
attributes 'Implementation-Version': project.version
@@ -97,7 +138,7 @@ if (System.getenv('TRAVIS') == null) {
97138

98139
groupId = 'com.telesign'
99140
artifactId = 'telesign'
100-
version = '3.0.1'
141+
version = '4.0.0'
101142

102143
pom {
103144
name = 'Telesign SDK'

config/checkstyle/checkstyle.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<module name="Checker">
7+
<module name="TreeWalker">
8+
<!-- Import checks -->
9+
<module name="UnusedImports"/>
10+
<module name="RedundantImport"/>
11+
<module name="AvoidStarImport"/>
12+
13+
<!-- Coding checks -->
14+
<module name="EmptyStatement"/>
15+
<module name="EqualsHashCode"/>
16+
<module name="SimplifyBooleanExpression"/>
17+
<module name="SimplifyBooleanReturn"/>
18+
19+
<!-- Block checks -->
20+
<module name="NeedBraces"/>
21+
<module name="EmptyBlock"/>
22+
23+
<!-- Naming conventions -->
24+
<module name="TypeName"/>
25+
<module name="MethodName"/>
26+
<module name="ConstantName"/>
27+
</module>
28+
</module>
29+

src/main/java/com/telesign/AppVerifyClient.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package com.telesign;
22

3-
import java.io.IOException;
43
import java.net.Proxy;
5-
import java.security.GeneralSecurityException;
6-
import java.util.Map;
74

85
/**
96
* AppVerify is a secure, lightweight SDK that integrates a frictionless user verification process into existing

src/main/java/com/telesign/RestClient.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
import com.google.gson.Gson;
55
import com.google.gson.JsonParseException;
66
import com.google.gson.JsonParser;
7-
import okhttp3.*;
7+
import okhttp3.Authenticator;
8+
import okhttp3.Credentials;
9+
import okhttp3.FormBody;
10+
import okhttp3.HttpUrl;
11+
import okhttp3.MediaType;
12+
import okhttp3.OkHttp;
13+
import okhttp3.OkHttpClient;
14+
import okhttp3.Request;
15+
import okhttp3.RequestBody;
16+
import okhttp3.Response;
17+
import okhttp3.Route;
818
import okio.Buffer;
919

1020
import javax.crypto.Mac;
@@ -15,7 +25,15 @@
1525
import java.security.InvalidKeyException;
1626
import java.security.NoSuchAlgorithmException;
1727
import java.text.SimpleDateFormat;
18-
import java.util.*;
28+
import java.util.Base64;
29+
import java.util.Date;
30+
import java.util.HashMap;
31+
import java.util.List;
32+
import java.util.Locale;
33+
import java.util.Map;
34+
import java.util.Objects;
35+
import java.util.TimeZone;
36+
import java.util.UUID;
1937
import java.util.concurrent.TimeUnit;
2038

2139
/**

src/main/java/com/telesign/ScoreClient.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
*/
1212
public class ScoreClient extends RestClient {
1313

14-
private static final String SCORE_RESOURCE = "/v1/score/%s";
14+
private static final String INTELLIGENCE_SCORE_RESOURCE = "/intelligence/phone";
15+
16+
private static final String DETECT_REST_ENDPOINT = "https://detect.telesign.com";
1517

1618
public ScoreClient(String customerId, String apiKey) {
17-
super(customerId, apiKey);
19+
super(customerId, apiKey, DETECT_REST_ENDPOINT);
1820
}
1921

2022
public ScoreClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
@@ -41,19 +43,18 @@ public ScoreClient(String customerId,
4143
}
4244

4345
/**
44-
* Score is an API that delivers reputation scoring based on phone number intelligence, traffic patterns, machine
45-
* learning, and a global data consortium.
46+
*Obtain a risk recommendation for this phone number, as well as other relevant information using Telesign Cloud API.
4647
* <p>
47-
* See https://developer.telesign.com/docs/score-api for detailed API documentation.
48+
* See https://developer.telesign.com/enterprise/reference/submitphonenumberforintelligencecloud for detailed API documentation.
4849
*/
4950
public TelesignResponse score(String phoneNumber, String accountLifecycleEvent, Map<String, String> params) throws IOException, GeneralSecurityException {
50-
5151
if (params == null) {
5252
params = new HashMap<>();
5353
}
54-
54+
55+
params.put("phone_number", phoneNumber);
5556
params.put("account_lifecycle_event", accountLifecycleEvent);
5657

57-
return this.post(String.format(SCORE_RESOURCE, phoneNumber), params);
58+
return this.post(INTELLIGENCE_SCORE_RESOURCE, params);
5859
}
5960
}

src/test/java/com/telesign/AppVerifyClientTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
package com.telesign;
22

33
import junit.framework.TestCase;
4-
import okhttp3.mockwebserver.MockResponse;
54
import okhttp3.mockwebserver.MockWebServer;
6-
import okhttp3.mockwebserver.RecordedRequest;
75

86
import java.text.SimpleDateFormat;
9-
import java.util.HashMap;
10-
import java.util.concurrent.TimeUnit;
117

128
public class AppVerifyClientTest extends TestCase {
139

src/test/java/com/telesign/JsonCreateRequestBodyTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
package com.telesign;
22

33
import com.google.gson.Gson;
4-
import com.google.gson.GsonBuilder;
5-
import com.google.gson.JsonElement;
6-
import com.google.gson.JsonObject;
74
import com.google.gson.reflect.TypeToken;
85
import junit.framework.TestCase;
96
import okhttp3.RequestBody;
107
import okio.Buffer;
118

129
import java.io.IOException;
1310
import java.util.HashMap;
14-
import java.util.Map;
1511

1612
public class JsonCreateRequestBodyTest extends TestCase {
1713

src/test/java/com/telesign/ScoreClientTest.java

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package com.telesign;
22

33
import junit.framework.TestCase;
4-
import okhttp3.OkHttpClient;
54
import okhttp3.mockwebserver.MockResponse;
65
import okhttp3.mockwebserver.MockWebServer;
76
import okhttp3.mockwebserver.RecordedRequest;
87

9-
import java.text.SimpleDateFormat;
108
import java.util.HashMap;
119
import java.util.concurrent.TimeUnit;
1210

@@ -17,14 +15,11 @@ public class ScoreClientTest extends TestCase {
1715
private String customerId;
1816
private String apiKey;
1917

20-
private SimpleDateFormat rfc2616 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'");
21-
22-
2318
public void setUp() throws Exception {
2419
super.setUp();
2520

2621
customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
27-
apiKey = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
22+
apiKey = "ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
2823

2924
mockServer = new MockWebServer();
3025
mockServer.start();
@@ -41,7 +36,6 @@ public void testScoreClientConstructorMinimal() throws Exception {
4136
assertNotNull(client);
4237
}
4338

44-
4539
public void testScoreClientConstructorFull() throws Exception {
4640
ScoreClient client = new ScoreClient(customerId,
4741
apiKey,
@@ -59,7 +53,6 @@ public void testScoreClientConstructorFull() throws Exception {
5953
}
6054

6155
public void testScoreWithParams() throws Exception {
62-
6356
HashMap<String, String> params = new HashMap<String, String>() {{
6457
put("originating_ip", "127.0.0.1");
6558
put("account_lifecycle_event", "create");
@@ -71,24 +64,25 @@ public void testScoreWithParams() throws Exception {
7164
this.apiKey,
7265
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
7366

74-
client.score("18005555555", "create", params);
67+
client.score("11234567890", "create", params);
7568

7669
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
7770

7871
assertEquals("method is not as expected", "POST", request.getMethod());
79-
assertEquals("path is not as expected", "/v1/score/18005555555", request.getPath());
80-
assertEquals("body is not as expected", "originating_ip=127.0.0.1&account_lifecycle_event=create",
81-
request.getBody().readUtf8());
72+
assertEquals("path is not as expected", "/intelligence/phone", request.getPath());
73+
74+
String body = request.getBody().readUtf8();
75+
assertTrue("body does not contain phone_number", body.contains("phone_number=11234567890"));
76+
assertTrue("body does not contain originating_ip", body.contains("originating_ip=127.0.0.1"));
77+
assertTrue("body does not contain account_lifecycle_event", body.contains("account_lifecycle_event=create"));
78+
8279
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
8380
request.getHeader("Content-Type"));
8481
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
8582
request.getHeader("x-ts-auth-method"));
8683
}
8784

8885
public void testScore() throws Exception {
89-
90-
HashMap<String, Object> params = new HashMap<String, Object>();
91-
9286
this.mockServer.enqueue(new MockResponse().setBody("{}"));
9387

9488
ScoreClient client = new ScoreClient(this.customerId,
@@ -100,15 +94,15 @@ public void testScore() throws Exception {
10094
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
10195

10296
assertEquals("method is not as expected", "POST", request.getMethod());
103-
assertEquals("path is not as expected", "/v1/score/18005555555", request.getPath());
104-
assertEquals("body is not as expected", "account_lifecycle_event=create",
105-
request.getBody().readUtf8());
97+
assertEquals("path is not as expected", "/intelligence/phone", request.getPath());
98+
99+
String body = request.getBody().readUtf8();
100+
assertTrue("body does not contain phone_number", body.contains("phone_number=18005555555"));
101+
assertTrue("body contains account_lifecycle_event", body.contains("account_lifecycle_event=create"));
102+
106103
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
107104
request.getHeader("Content-Type"));
108105
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
109106
request.getHeader("x-ts-auth-method"));
110107
}
111-
112-
}
113-
114-
108+
}

0 commit comments

Comments
 (0)