Skip to content

Commit 306ab74

Browse files
Pull request #22: Pull request #21: Added support for Email Intelligence
Merge in SDK/java_telesign from developer to master * commit '657fbd541123130152c44de662b1e3b50bcc13b8': Pull request #21: Added support for Email Intelligence
2 parents 6b767f0 + 657fbd5 commit 306ab74

5 files changed

Lines changed: 118 additions & 3 deletions

File tree

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [4.1.0](http://central.maven.org/maven2/com/telesign/telesign/4.1.0) - 2026-04-29
2+
- 2026-04-29
3+
- Added support for Email Intelligence API.
4+
15
## [4.0.1](http://central.maven.org/maven2/com/telesign/telesign/4.0.1) - 2026-04-22
26
- 2026-04-22
37
- Fix style for linting.

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'com.telesign'
12-
version '4.0.1'
12+
version '4.1.0'
1313

1414
sourceCompatibility = JavaVersion.VERSION_1_8
1515
targetCompatibility = JavaVersion.VERSION_1_8
@@ -138,7 +138,7 @@ if (System.getenv('TRAVIS') == null) {
138138

139139
groupId = 'com.telesign'
140140
artifactId = 'telesign'
141-
version = '4.0.1'
141+
version = '4.1.0'
142142

143143
pom {
144144
name = 'Telesign SDK'

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import java.util.Map;
88

99
/**
10-
* Score provides risk information about a specified phone number.
10+
* Score provides risk information about a specified phone number or email address.
1111
*/
1212
public class ScoreClient extends RestClient {
1313

1414
private static final String INTELLIGENCE_SCORE_RESOURCE = "/intelligence/phone";
15+
private static final String EMAIL_INTELLIGENCE_RESOURCE = "/intelligence/email";
1516

1617
private static final String DETECT_REST_ENDPOINT = "https://detect.telesign.com";
1718

@@ -57,4 +58,20 @@ public TelesignResponse score(String phoneNumber, String accountLifecycleEvent,
5758

5859
return this.post(INTELLIGENCE_SCORE_RESOURCE, params);
5960
}
61+
62+
/**
63+
* Obtain a risk recommendation for this email address, as well as other relevant information using Telesign Cloud API.
64+
* <p>
65+
* See https://developer.telesign.com/enterprise/reference/submitemailaddressforemailintelligence for detailed API documentation.
66+
*/
67+
public TelesignResponse emailIntelligence(String emailAddress, String accountLifecycleEvent, Map<String, String> params) throws GeneralSecurityException, IOException {
68+
if (params == null) {
69+
params = new HashMap<>();
70+
}
71+
72+
params.put("email_address", emailAddress);
73+
params.put("account_lifecycle_event", accountLifecycleEvent);
74+
75+
return this.post(EMAIL_INTELLIGENCE_RESOURCE, params);
76+
}
6077
}

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,57 @@ public void testScore() throws Exception {
105105
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
106106
request.getHeader("x-ts-auth-method"));
107107
}
108+
109+
public void testEmailIntelligenceWithParams() throws Exception {
110+
HashMap<String, String> params = new HashMap<String, String>() {{
111+
put("originating_ip", "127.0.0.1");
112+
}};
113+
114+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
115+
116+
ScoreClient client = new ScoreClient(this.customerId,
117+
this.apiKey,
118+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
119+
120+
client.emailIntelligence("support@vero-finto.com", "sign-in", params);
121+
122+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
123+
124+
assertEquals("method is not as expected", "POST", request.getMethod());
125+
assertEquals("path is not as expected", "/intelligence/email", request.getPath());
126+
127+
String body = request.getBody().readUtf8();
128+
assertTrue("body does not contain email_address", body.contains("email_address=support%40vero-finto.com"));
129+
assertTrue("body does not contain originating_ip", body.contains("originating_ip=127.0.0.1"));
130+
assertTrue("body does not contain account_lifecycle_event", body.contains("account_lifecycle_event=sign-in"));
131+
132+
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
133+
request.getHeader("Content-Type"));
134+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
135+
request.getHeader("x-ts-auth-method"));
136+
}
137+
138+
public void testEmailIntelligence() throws Exception {
139+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
140+
141+
ScoreClient client = new ScoreClient(this.customerId,
142+
this.apiKey,
143+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
144+
145+
client.emailIntelligence("support@vero-finto.com", "create", null);
146+
147+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
148+
149+
assertEquals("method is not as expected", "POST", request.getMethod());
150+
assertEquals("path is not as expected", "/intelligence/email", request.getPath());
151+
152+
String body = request.getBody().readUtf8();
153+
assertTrue("body does not contain email_address", body.contains("email_address=support%40vero-finto.com"));
154+
assertTrue("body contains account_lifecycle_event", body.contains("account_lifecycle_event=create"));
155+
156+
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
157+
request.getHeader("Content-Type"));
158+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
159+
request.getHeader("x-ts-auth-method"));
160+
}
108161
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.telesign.example.score;
2+
3+
import com.google.gson.JsonObject;
4+
import com.telesign.RestClient;
5+
import com.telesign.ScoreClient;
6+
7+
public class CheckEmailIntelligenceRiskLevel {
8+
9+
public static void main(String[] args) {
10+
11+
String customerId = "ABC1DE23-A12B-1234-56AB-AB12345678900";
12+
String apiKey = "ABC12345yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
13+
14+
String emailAddress = "support@vero-finto.com";
15+
String accountLifecycleEvent = "create";
16+
17+
try {
18+
ScoreClient scoreClient = new ScoreClient(customerId, apiKey);
19+
RestClient.TelesignResponse telesignResponse = scoreClient.emailIntelligence(emailAddress, accountLifecycleEvent, null);
20+
21+
if (telesignResponse.ok) {
22+
JsonObject intelligenceDetails = telesignResponse.json.getAsJsonObject("intelligence_details");
23+
JsonObject risk = intelligenceDetails.getAsJsonObject("risk");
24+
25+
System.out.printf("Email address %s intelligence report:%n",
26+
emailAddress);
27+
System.out.printf(" Risk Level: %s%n",
28+
risk.get("level").getAsString());
29+
System.out.printf(" Risk Score: %d%n",
30+
risk.get("score").getAsInt());
31+
System.out.printf(" Recommendation: %s%n",
32+
risk.get("recommendation").getAsString());
33+
}
34+
else {
35+
System.out.println("Request failed with status: " + telesignResponse.statusCode);
36+
}
37+
} catch (Exception e) {
38+
e.printStackTrace();
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)