Skip to content

Commit fd6db1b

Browse files
Pull request #40: Add remaining Messaging actions
Merge in SDK/java_telesign_enterprise from feature/EOA8407 to developer Squashed commit of the following: commit f84d7ad1a9beddddc98d61ed777a8ea9e968aa95 Author: Juan Camilo Martinez <jmartinez@telesign.com> Date: Thu Mar 12 09:11:59 2026 -0500 Add remaining Messaging actions
1 parent 7aa7ba1 commit fd6db1b

File tree

4 files changed

+306
-2
lines changed

4 files changed

+306
-2
lines changed

RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
4.1.0
2+
- Add remaining Messaging actions.
3+
14
4.0.1
25
- Fix endpoint for making requests in ScoreClient
36

build.gradle

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

99
group = 'com.telesign.enterprise'
10-
version = '4.0.1'
10+
version = '4.1.0'
1111

1212
sourceCompatibility = JavaVersion.VERSION_1_8
1313
targetCompatibility = JavaVersion.VERSION_1_8
@@ -120,7 +120,7 @@ publishing {
120120

121121
groupId = 'com.telesign.enterprise'
122122
artifactId = 'telesignenterprise'
123-
version = '4.0.1'
123+
version = '4.1.0'
124124

125125
pom {
126126
name = 'TeleSign Enterprise SDK'

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

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
import java.net.Proxy;
55
import java.security.GeneralSecurityException;
66
import java.util.Map;
7+
import java.util.HashMap;
78

89
public class MessagingClient extends com.telesign.MessagingClient {
910

1011
private static final String OMNI_MESSAGING_RESOURCE = "/v1/omnichannel";
12+
private static final String TEMPLATES_RESOURCE = OMNI_MESSAGING_RESOURCE + "/templates";
13+
private static final String CAPABILITY_RESOURCE = "/capability";
1114
private static final String SDK_VERSION = MessagingClient.class.getPackage().getImplementationVersion();
1215
private static final String SDK_SOURCE = "java_telesign_enterprise";
1316
private static final String SDK_VERSION_DEPENDENCY = com.telesign.RestClient.class.getPackage().getImplementationVersion();
@@ -43,4 +46,94 @@ public MessagingClient(String customerId,
4346
public TelesignResponse omniMessage(Map<String, Object> params) throws IOException, GeneralSecurityException {
4447
return this.post(OMNI_MESSAGING_RESOURCE, params, JSON_CONTENT_TYPE);
4548
}
49+
50+
/**
51+
* Use this action to check capability of a phone number to use the specified channel.
52+
* <p>
53+
* See https://developer.telesign.com/enterprise/reference/checkphonenumberchannelcapability for detailed API documentation.
54+
* </p>
55+
*/
56+
public TelesignResponse checkChannelCapability(String channel, String phoneNumber) throws IOException, GeneralSecurityException {
57+
return this.get(CAPABILITY_RESOURCE + "/"+ channel +"/"+ phoneNumber, new HashMap<>());
58+
}
59+
60+
/**
61+
* Use this action to check capability of a phone number to receive messages from the specified RBM agent.
62+
* <p>
63+
* See https://developer.telesign.com/enterprise/reference/checkphonenumberrbmcapability for detailed API documentation.
64+
* </p>
65+
*/
66+
public TelesignResponse checkCapabilityRBMAgent(String phoneNumber, String agentId) throws IOException, GeneralSecurityException {
67+
return this.get(CAPABILITY_RESOURCE + "/rcs/" + phoneNumber + "/" + agentId, new HashMap<>());
68+
}
69+
70+
/**
71+
*
72+
* Get delivery status and other details for a Telesign Messaging transaction that you have created.
73+
* Get transaction status can be used for all Messaging API transactions.
74+
* Also use this endpoint to complete verification, if Telesign generated your code.
75+
* <p>
76+
* See https://developer.telesign.com/enterprise/reference/getmessagingstatus for detailed API documentation.
77+
* </p>
78+
*/
79+
public TelesignResponse getMsgStatus(String referenceId) throws IOException, GeneralSecurityException {
80+
return getMsgStatus(referenceId, null);
81+
}
82+
83+
84+
public TelesignResponse getMsgStatus(String referenceId, String verifyCode) throws IOException, GeneralSecurityException {
85+
StringBuilder url = new StringBuilder(OMNI_MESSAGING_RESOURCE).append("/").append(referenceId);
86+
87+
if (verifyCode != null && !verifyCode.trim().isEmpty()) {
88+
url.append("?verify_code=").append(verifyCode);
89+
}
90+
return this.get(url.toString(), new HashMap<>());
91+
}
92+
93+
/**
94+
*
95+
* Use this action to create a Telesign Messaging template.
96+
* <p>
97+
* See https://developer.telesign.com/enterprise/reference/createmsgtemplate for detailed API documentation.
98+
* </p>
99+
*/
100+
public TelesignResponse createMsgTemplate(Map<String, Object> params) throws IOException, GeneralSecurityException {
101+
return this.post(TEMPLATES_RESOURCE, params, JSON_CONTENT_TYPE);
102+
}
103+
104+
/**
105+
*
106+
* Use this action to get details for the specified Telesign Messaging template.
107+
*
108+
* <p>
109+
* See https://developer.telesign.com/enterprise/reference/getmsgtemplate for detailed API documentation.
110+
* </p>
111+
*/
112+
public TelesignResponse getMsgTemplate(String channel, String templateName) throws IOException, GeneralSecurityException {
113+
return this.get(TEMPLATES_RESOURCE + "/" + channel + "/" + templateName, new HashMap<>());
114+
}
115+
116+
/**
117+
*
118+
* Use this action to get details for all Telesign Messaging templates associated with this Customer ID.
119+
*
120+
* <p>
121+
* See https://developer.telesign.com/enterprise/reference/getallmsgtemplates for detailed API documentation.
122+
* </p>
123+
*/
124+
public TelesignResponse getAllMsgTemplates() throws IOException, GeneralSecurityException {
125+
return this.get(TEMPLATES_RESOURCE, new HashMap<>());
126+
}
127+
128+
/**
129+
*
130+
* Use this action to delete a Telesign Messaging template.
131+
*
132+
* <p>
133+
* See https://developer.telesign.com/enterprise/reference/deletemsgtemplate for detailed API documentation.
134+
* </p>
135+
*/
136+
public TelesignResponse deleteMsgTemplate(String channel, String templateName) throws IOException, GeneralSecurityException {
137+
return this.delete(TEMPLATES_RESOURCE + "/" + channel + "/" + templateName, new HashMap<>());
138+
}
46139
}

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

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import java.text.SimpleDateFormat;
99
import java.util.ArrayList;
1010
import java.util.HashMap;
11+
import java.util.List;
12+
import java.util.Map;
1113
import java.util.concurrent.TimeUnit;
1214

1315
public class MessagingClientTest extends TestCase {
@@ -16,6 +18,7 @@ public class MessagingClientTest extends TestCase {
1618

1719
private String customerId;
1820
private String apiKey;
21+
private String phoneNumber;
1922

2023
private SimpleDateFormat rfc2616 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss 'GMT'");
2124

@@ -25,13 +28,17 @@ public void setUp() throws Exception {
2528

2629
this.customerId = System.getenv("CUSTOMER_ID");
2730
this.apiKey = System.getenv("API_KEY");
31+
this.phoneNumber = System.getenv("PHONE_NUMBER");
2832

2933
if (this.customerId == null) {
3034
this.customerId = "FFFFFFFF-EEEE-DDDD-1234-AB1234567890";
3135
}
3236
if (this.apiKey == null) {
3337
this.apiKey = "EXAMPLE----TE8sTgg45yusumoN6BYsBVkh+yRJ5czgsnCehZaOYldPJdmFh6NeX8kunZ2zU1YWaUw/0wV6xfw==";
3438
}
39+
if (this.phoneNumber == null) {
40+
this.phoneNumber = "11234567890";
41+
}
3542

3643
mockServer = new MockWebServer();
3744
mockServer.start();
@@ -222,6 +229,207 @@ public void testMessagingStatus() throws Exception {
222229
request.getHeader("x-ts-auth-method"));
223230
}
224231

232+
public void testCheckChannelCapability() throws Exception {
233+
234+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
235+
236+
MessagingClient client = new MessagingClient(this.customerId,
237+
this.apiKey,
238+
this.mockServer.url("").toString().replaceAll("/$", ""));
239+
240+
String channel = "rcs";
241+
client.checkChannelCapability(channel, phoneNumber);
242+
243+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
244+
245+
assertEquals("method is not as expected", "GET", request.getMethod());
246+
assertEquals("path is not as expected", "/capability/" + channel + "/" + this.phoneNumber, request.getPath());
247+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
248+
assertEquals("Content-Type header is not as expected", "",
249+
request.getHeader("Content-Type"));
250+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
251+
request.getHeader("x-ts-auth-method"));
252+
}
253+
254+
public void testCheckCapabilityRBMAgent() throws Exception {
255+
256+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
257+
258+
MessagingClient client = new MessagingClient(this.customerId,
259+
this.apiKey,
260+
this.mockServer.url("").toString().replaceAll("/$", ""));
261+
262+
client.checkCapabilityRBMAgent(phoneNumber, "my_rbm_id");
263+
264+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
265+
266+
assertEquals("method is not as expected", "GET", request.getMethod());
267+
assertEquals("path is not as expected", "/capability/rcs/" + this.phoneNumber + "/my_rbm_id", request.getPath());
268+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
269+
assertEquals("Content-Type header is not as expected", "",
270+
request.getHeader("Content-Type"));
271+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
272+
request.getHeader("x-ts-auth-method"));
273+
}
274+
275+
276+
public void testGetMsgStatus() throws Exception {
277+
278+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
279+
280+
MessagingClient client = new MessagingClient(this.customerId,
281+
this.apiKey,
282+
this.mockServer.url("").toString().replaceAll("/$", ""));
283+
284+
String referenceId = "FakeReferenceId";
285+
String verifyCode = "123456";
286+
287+
client.getMsgStatus(referenceId, verifyCode);
288+
289+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
290+
291+
assertEquals("method is not as expected", "GET", request.getMethod());
292+
assertEquals("path is not as expected", "/v1/omnichannel/" + referenceId + "?verify_code=" + verifyCode, request.getPath());
293+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
294+
assertEquals("Content-Type header is not as expected", "",
295+
request.getHeader("Content-Type"));
296+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
297+
request.getHeader("x-ts-auth-method"));
298+
}
299+
300+
public void testGetMsgStatusWithoutVerifyCode() throws Exception {
301+
302+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
303+
304+
MessagingClient client = new MessagingClient(this.customerId,
305+
this.apiKey,
306+
this.mockServer.url("").toString().replaceAll("/$", ""));
307+
308+
String referenceId = "FakeReferenceId";
309+
310+
client.getMsgStatus(referenceId);
311+
312+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
313+
314+
assertEquals("method is not as expected", "GET", request.getMethod());
315+
assertEquals("path is not as expected", "/v1/omnichannel/" + referenceId, request.getPath());
316+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
317+
assertEquals("Content-Type header is not as expected", "",
318+
request.getHeader("Content-Type"));
319+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
320+
request.getHeader("x-ts-auth-method"));
321+
}
322+
323+
public void testCreateMsgTemplate() throws Exception {
324+
325+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
326+
327+
MessagingClient client = new MessagingClient(this.customerId,
328+
this.apiKey,
329+
this.mockServer.url("").toString().replaceAll("/$", ""));
330+
331+
Map<String, Object> params = new HashMap<>();
332+
333+
params.put("type", "standard");
334+
params.put("channel", "whatsapp");
335+
params.put("name", "wa_bogo");
336+
337+
// body map
338+
Map<String, Object> body = new HashMap<>();
339+
body.put("type", "text");
340+
body.put("text", "Buy one get one free!");
341+
342+
// content item
343+
Map<String, Object> contentItem = new HashMap<>();
344+
contentItem.put("body", body);
345+
346+
// content list
347+
List<Map<String, Object>> content = new ArrayList<>();
348+
content.add(contentItem);
349+
350+
params.put("content", content);
351+
352+
client.createMsgTemplate(params);
353+
354+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
355+
356+
assertEquals("method is not as expected", "POST", request.getMethod());
357+
assertEquals("path is not as expected", "/v1/omnichannel/templates", request.getPath());
358+
assertEquals("body is not as expected", "{\"channel\":\"whatsapp\",\"name\":\"wa_bogo\",\"type\":\"standard\",\"content\":[{\"body\":{\"text\":\"Buy one get one free!\",\"type\":\"text\"}}]}", request.getBody().readUtf8());
359+
assertEquals("Content-Type header is not as expected", "application/json",
360+
request.getHeader("Content-Type"));
361+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
362+
request.getHeader("x-ts-auth-method"));
363+
}
364+
365+
public void testGetMsgTemplate() throws Exception {
366+
367+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
368+
369+
MessagingClient client = new MessagingClient(this.customerId,
370+
this.apiKey,
371+
this.mockServer.url("").toString().replaceAll("/$", ""));
372+
373+
String channel = "whatsapp";
374+
String templateName = "wa_bogo";
375+
376+
client.getMsgTemplate(channel, templateName);
377+
378+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
379+
380+
assertEquals("method is not as expected", "GET", request.getMethod());
381+
assertEquals("path is not as expected", "/v1/omnichannel/templates/" + channel + "/" + templateName, request.getPath());
382+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
383+
assertEquals("Content-Type header is not as expected", "",
384+
request.getHeader("Content-Type"));
385+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
386+
request.getHeader("x-ts-auth-method"));
387+
}
388+
389+
public void testGetAllMsgTemplates() throws Exception {
390+
391+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
392+
393+
MessagingClient client = new MessagingClient(this.customerId,
394+
this.apiKey,
395+
this.mockServer.url("").toString().replaceAll("/$", ""));
396+
397+
client.getAllMsgTemplates();
398+
399+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
400+
401+
assertEquals("method is not as expected", "GET", request.getMethod());
402+
assertEquals("path is not as expected", "/v1/omnichannel/templates", request.getPath());
403+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
404+
assertEquals("Content-Type header is not as expected", "",
405+
request.getHeader("Content-Type"));
406+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
407+
request.getHeader("x-ts-auth-method"));
408+
}
409+
410+
public void testDeleteMsgTemplate() throws Exception {
411+
412+
this.mockServer.enqueue(new MockResponse().setBody("{}"));
413+
414+
MessagingClient client = new MessagingClient(this.customerId,
415+
this.apiKey,
416+
this.mockServer.url("").toString().replaceAll("/$", ""));
417+
418+
String channel = "whatsapp";
419+
String templateName = "wa_bogo";
420+
421+
client.deleteMsgTemplate(channel, templateName);
422+
423+
RecordedRequest request = this.mockServer.takeRequest(1, TimeUnit.SECONDS);
424+
425+
assertEquals("method is not as expected", "DELETE", request.getMethod());
426+
assertEquals("path is not as expected", "/v1/omnichannel/templates/" + channel + "/" + templateName, request.getPath());
427+
assertEquals("body is not as expected", "", request.getBody().readUtf8());
428+
assertEquals("Content-Type header is not as expected", "",
429+
request.getHeader("Content-Type"));
430+
assertEquals("x-ts-auth-method header is not as expected", "HMAC-SHA256",
431+
request.getHeader("x-ts-auth-method"));
432+
}
225433

226434
}
227435

0 commit comments

Comments
 (0)