Skip to content

Commit 5729308

Browse files
committed
Pull request #3: Added track to request
Merge in SDK/java_telesign from feature/EOA-2064-SS to developer * commit 'd51ed47420fa9d7c0c159053fda5bc45fa7da604': Uptade version Add new paremeters constructors Update unit test code Update Restclient class in contructor method
2 parents 578ad89 + d51ed47 commit 5729308

14 files changed

+105
-60
lines changed

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [2.4.0](http://central.maven.org/maven2/com/telesign/telesign/2.4.0/) - 2025-05-06
2+
- 2025-05-06
3+
- Added tracking to requests.
4+
15
## [2.3.1](http://central.maven.org/maven2/com/telesign/telesign/2.3.1/) - 2024-11-19
26
- 2024-11-19
37
- Added support for request bodies with application/json content type.

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ plugins {
88
}
99

1010
group 'com.telesign'
11-
version '2.3.1'
11+
version '2.4.0'
1212

1313
sourceCompatibility = JavaVersion.VERSION_1_8
1414
targetCompatibility = JavaVersion.VERSION_1_8
@@ -17,6 +17,12 @@ repositories {
1717
mavenCentral()
1818
}
1919

20+
jar {
21+
manifest {
22+
attributes 'Implementation-Version': project.version
23+
}
24+
}
25+
2026
dependencies {
2127
implementation 'com.squareup.okhttp3:okhttp:[4.7.0,)'
2228
implementation 'com.google.code.gson:gson:[2.7,3.0)'

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public AppVerifyClient(String customerId, String apiKey) {
1717
super(customerId, apiKey);
1818
}
1919

20-
public AppVerifyClient(String customerId, String apiKey, String restEndpoint) {
21-
super(customerId, apiKey, restEndpoint);
20+
public AppVerifyClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
21+
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
2222
}
2323

2424
public AppVerifyClient(String customerId,
@@ -29,8 +29,11 @@ public AppVerifyClient(String customerId,
2929
Integer writeTimeout,
3030
Proxy proxy,
3131
final String proxyUsername,
32-
final String proxyPassword) {
33-
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword);
32+
final String proxyPassword,
33+
final String source,
34+
final String sdkVersionOrigin,
35+
final String sdkVersionDependency) {
36+
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
3437
}
3538

3639
/**

src/main/java/com/telesign/MessagingClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public MessagingClient(String customerId, String apiKey) {
1919
super(customerId, apiKey);
2020
}
2121

22-
public MessagingClient(String customerId, String apiKey, String restEndpoint) {
23-
super(customerId, apiKey, restEndpoint);
22+
public MessagingClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
23+
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
2424
}
2525

2626
public MessagingClient(String customerId,
@@ -31,8 +31,11 @@ public MessagingClient(String customerId,
3131
Integer writeTimeout,
3232
Proxy proxy,
3333
final String proxyUsername,
34-
final String proxyPassword) {
35-
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword);
34+
final String proxyPassword,
35+
final String source,
36+
final String sdkVersionOrigin,
37+
final String sdkVersionDependency) {
38+
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
3639
}
3740

3841
/**

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public PhoneIdClient(String customerId, String apiKey) {
2727
super(customerId, apiKey);
2828
}
2929

30-
public PhoneIdClient(String customerId, String apiKey, String restEndpoint) {
31-
super(customerId, apiKey, restEndpoint);
30+
public PhoneIdClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
31+
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
3232
}
3333

3434
public PhoneIdClient(String customerId,
@@ -39,8 +39,11 @@ public PhoneIdClient(String customerId,
3939
Integer writeTimeout,
4040
Proxy proxy,
4141
final String proxyUsername,
42-
final String proxyPassword) {
43-
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword);
42+
final String proxyPassword,
43+
final String source,
44+
final String sdkVersionOrigin,
45+
final String sdkVersionDependency) {
46+
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
4447
}
4548

4649
/**

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,25 @@
2626
*/
2727
public class RestClient {
2828

29-
private static final String userAgent = String.format("TeleSignSDK/java-%s Java/%s OkHttp/%s", BuildConfig.VERSION,
30-
System.getProperty("java.version"), OkHttp.VERSION);
29+
private static final String sdkVersion = BuildConfig.VERSION;
3130

3231
public static final String URL_FORM_ENCODED_CONTENT_TYPE = "application/x-www-form-urlencoded";
3332
public static final String JSON_CONTENT_TYPE = "application/json";
3433

35-
private String customerId;
36-
private String apiKey;
34+
protected String customerId;
35+
protected String apiKey;
3736
private String restEndpoint;
3837
private OkHttpClient client;
38+
private String userAgent;
3939

4040
public RestClient(String customerId, String apiKey) {
4141

42-
this(customerId, apiKey, null, null, null, null, null, null, null);
42+
this(customerId, apiKey, null, null, null, null, null, null, null, null, null, null);
4343
}
4444

45-
public RestClient(String customerId, String apiKey, String restEndpoint) {
45+
public RestClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
4646

47-
this(customerId, apiKey, restEndpoint, null, null, null, null, null, null);
47+
this(customerId, apiKey, restEndpoint, null, null, null, null, null, null, source, sdkVersionOrigin, sdkVersionDependency);
4848
}
4949

5050
/**
@@ -75,11 +75,17 @@ public RestClient(String customerId, String apiKey, String restEndpoint) {
7575
*/
7676
public RestClient(String customerId, String apiKey, String restEndpoint, Integer connectTimeout,
7777
Integer readTimeout, Integer writeTimeout, Proxy proxy, final String proxyUsername,
78-
final String proxyPassword) {
78+
final String proxyPassword, final String source, final String sdkVersionOrigin, final String sdkVersionDependency) {
7979

8080
this.customerId = customerId;
8181
this.apiKey = apiKey;
8282

83+
this.userAgent = String.format("TeleSignSDK/java Java/%s OkHttp/%s OriginatingSDK/%s SDKVersion/%s",
84+
System.getProperty("java.version"), OkHttp.VERSION, (source == null ? "java_telesign" : source), (sdkVersionOrigin == null ? sdkVersion : sdkVersionOrigin));
85+
86+
if (!Objects.equals(source, "java_telesign") && sdkVersionDependency != null)
87+
this.userAgent += String.format(" DependencySDKVersion/%s", sdkVersionDependency);
88+
8389
if (restEndpoint == null) {
8490
this.restEndpoint = "https://rest-api.telesign.com";
8591
} else {
@@ -138,10 +144,6 @@ static byte[] parseBase64(String encoded) {
138144
return Base64.getDecoder().decode(sb.toString());
139145
}
140146

141-
public void setRestEndpoint(String baseUrl) {
142-
this.restEndpoint = baseUrl;
143-
}
144-
145147
static String encodeBase64(byte[] data) {
146148
return Base64.getEncoder().encodeToString(data);
147149
}
@@ -459,7 +461,7 @@ private TelesignResponse execute(String methodName, String resource, Map<String,
459461
}
460462

461463
Map<String, String> headers = RestClient.generateTelesignHeaders(this.customerId, this.apiKey,
462-
methodName, resource, requestParams, null, null, RestClient.userAgent, contentType, authMethod);
464+
methodName, resource, requestParams, null, null, this.userAgent, contentType, authMethod);
463465

464466
Request.Builder requestBuilder = new Request.Builder().url(httpUrl).method(methodName, requestBody);
465467
for (Map.Entry<String, String> entry : headers.entrySet()) {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ public ScoreClient(String customerId, String apiKey) {
1717
super(customerId, apiKey);
1818
}
1919

20-
public ScoreClient(String customerId, String apiKey, String restEndpoint) {
21-
super(customerId, apiKey, restEndpoint);
20+
public ScoreClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
21+
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
2222
}
2323

2424
public ScoreClient(String customerId,
@@ -29,8 +29,11 @@ public ScoreClient(String customerId,
2929
Integer writeTimeout,
3030
Proxy proxy,
3131
final String proxyUsername,
32-
final String proxyPassword) {
33-
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword);
32+
final String proxyPassword,
33+
final String source,
34+
final String sdkVersionOrigin,
35+
final String sdkVersionDependency) {
36+
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
3437
}
3538

3639
/**

src/main/java/com/telesign/VoiceClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public VoiceClient(String customerId, String apiKey) {
1919
super(customerId, apiKey);
2020
}
2121

22-
public VoiceClient(String customerId, String apiKey, String restEndpoint) {
23-
super(customerId, apiKey, restEndpoint);
22+
public VoiceClient(String customerId, String apiKey, String restEndpoint, String source, String sdkVersionOrigin, String sdkVersionDependency) {
23+
super(customerId, apiKey, restEndpoint, source, sdkVersionOrigin, sdkVersionDependency);
2424
}
2525

2626
public VoiceClient(String customerId,
@@ -31,8 +31,11 @@ public VoiceClient(String customerId,
3131
Integer writeTimeout,
3232
Proxy proxy,
3333
final String proxyUsername,
34-
final String proxyPassword) {
35-
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword);
34+
final String proxyPassword,
35+
final String source,
36+
final String sdkVersionOrigin,
37+
final String sdkVersionDependency) {
38+
super(customerId, apiKey, restEndpoint, connectTimeout, readTimeout, writeTimeout, proxy, proxyUsername, proxyPassword, source, sdkVersionOrigin, sdkVersionDependency);
3639
}
3740

3841
/**

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public void testAppVerifyClientConstructorFull() throws Exception {
5050
0,
5151
null,
5252
"",
53-
"");
53+
"",
54+
null,
55+
null,
56+
null);
5457
assertNotNull(client);
5558
}
5659

@@ -60,7 +63,7 @@ public void testAppVerifyStatus() throws Exception {
6063

6164
AppVerifyClient client = new AppVerifyClient(this.customerId,
6265
this.apiKey,
63-
this.mockServer.url("").toString().replaceAll("/$", ""));
66+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
6467

6568
client.status("FakeExternalId", null);
6669

src/test/java/com/telesign/MessagingClientTest.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public void testMessagingClientConstructorFull() throws Exception {
5050
0,
5151
null,
5252
"",
53-
"");
53+
"",
54+
null,
55+
null,
56+
null);
5457
assertNotNull(client);
5558
}
5659

@@ -65,7 +68,7 @@ public void testMessagingWithParams() throws Exception {
6568

6669
MessagingClient client = new MessagingClient(this.customerId,
6770
this.apiKey,
68-
this.mockServer.url("").toString().replaceAll("/$", ""));
71+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
6972

7073
client.message("18005555555", "Test Message Content", "MKT", params);
7174

@@ -75,7 +78,7 @@ public void testMessagingWithParams() throws Exception {
7578
assertEquals("path is not as expected", "/v1/messaging", request.getPath());
7679
assertEquals("body is not as expected",
7780
"originating_ip=127.0.0.1&account_lifecycle_event=create&phone_number=18005555555&" +
78-
"message_type=MKT&message=Test%20Message%20Content",
81+
"message_type=MKT&message=Test+Message+Content",
7982
request.getBody().readUtf8());
8083
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
8184
request.getHeader("Content-Type"));
@@ -89,15 +92,15 @@ public void testMessagingNullParams() throws Exception {
8992

9093
MessagingClient client = new MessagingClient(this.customerId,
9194
this.apiKey,
92-
this.mockServer.url("").toString().replaceAll("/$", ""));
95+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
9396

9497
client.message("18005555555", "Test Message Content", "ARN", null);
9598

9699
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
97100

98101
assertEquals("method is not as expected", "POST", request.getMethod());
99102
assertEquals("path is not as expected", "/v1/messaging", request.getPath());
100-
assertEquals("body is not as expected", "phone_number=18005555555&message_type=ARN&message=Test%20Message%20Content",
103+
assertEquals("body is not as expected", "phone_number=18005555555&message_type=ARN&message=Test+Message+Content",
101104
request.getBody().readUtf8());
102105
assertEquals("Content-Type header is not as expected", "application/x-www-form-urlencoded",
103106
request.getHeader("Content-Type"));
@@ -111,7 +114,7 @@ public void testMessagingStatus() throws Exception {
111114

112115
MessagingClient client = new MessagingClient(this.customerId,
113116
this.apiKey,
114-
this.mockServer.url("").toString().replaceAll("/$", ""));
117+
this.mockServer.url("").toString().replaceAll("/$", ""), null, null, null);
115118

116119
client.status("FakeReferenceId", null);
117120

0 commit comments

Comments
 (0)