Skip to content

Commit

Permalink
Merge pull request #254 from plivo/SMS-6010
Browse files Browse the repository at this point in the history
SMS-6010: Add DLT Params to Send and Get Message APIs
  • Loading branch information
renoldthomas-plivo authored Aug 3, 2023
2 parents 47dfa96 + e616ee3 commit 584b2f7
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## [5.29.0](https://github.com/plivo/plivo-java/tree/v5.29.0) (2023-08-03)
**Feature - DLT parameters**
- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the [send message API](https://www.plivo.com/docs/sms/api/message/send-a-message/)
- Added new params `DLTEntityID`, `DLTTemplateID`, `DLTTemplateCategory` to the response for the [list all messages API](https://www.plivo.com/docs/sms/api/message/list-all-messages/) and the [get message details API](https://www.plivo.com/docs/sms/api/message#retrieve-a-message)

## [5.28.0](https://github.com/plivo/plivo-java/tree/v5.28.0) (2023-06-28)
**Feature - Stream API and XML support**
- API support for starting, deleting, getting streams on a live call
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
build:
docker-compose up --build --remove-orphans

start:
docker-compose up --build --remove-orphans --detach
docker attach $(shell docker-compose ps -q javaSDK)

test:
@[ "${CONTAINER}" ] && \
docker exec -it $$CONTAINER /bin/bash -c "/usr/src/app/gradlew test" || \
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ The Plivo Java SDK makes it simpler to integrate communications into your Java a

### To Install Stable release

You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.28.0/plivo-java-5.28.0.jar).
You can use this SDK by adding it as a dependency in your dependency management tool. Alternatively, you can use the [JAR file](https://search.maven.org/remotecontent?filepath=com/plivo/plivo-java/5.29.0/plivo-java-5.29.0.jar).

If you are using Maven, use the following XML to include the Plivo SDK as a dependency.

```xml
<dependency>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.28.0</version>
<version>5.29.0</version>
</dependency>
```

If you are using Gradle, use the following line in your dependencies.
```
compile 'com.plivo:plivo-java:5.28.0'
compile 'com.plivo:plivo-java:5.29.0'
```

### To Install Beta release
Expand Down
2 changes: 1 addition & 1 deletion pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Written manually.

version=5.28.0
version=5.29.0
groupId=com.plivo
artifactId=plivo-java
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.plivo</groupId>
<artifactId>plivo-java</artifactId>
<version>5.28.0</version>
<version>5.29.0</version>
<name>plivo-java</name>
<description>A Java SDK to make voice calls &amp; send SMS using Plivo and to generate Plivo XML</description>
<licenses>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/plivo/api/models/message/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class Message extends BaseResource {
private String requesterIP;
private Boolean isDomestic;
private String replacedSender;
private String dltEntityID;
private String dltTemplateID;
private String dltTemplateCategory;

public static MessageCreator creator(String source, List<String> destination, String text) {
return new MessageCreator(source, destination, text);
Expand Down Expand Up @@ -126,6 +129,18 @@ public Boolean getIsDomestic() {
return isDomestic;
}

public String getDltEntityID() {
return dltEntityID;
}

public String getDltTemplateID() {
return dltTemplateID;
}

public String getDltTemplateCategory() {
return dltTemplateCategory;
}

@Override
public String getId() {
return getMessageUuid();
Expand Down
44 changes: 41 additions & 3 deletions src/main/java/com/plivo/api/models/message/MessageCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class MessageCreator extends Creator < MessageCreateResponse > {
private String[] media_urls = null;
private String[] media_ids = null;
private Long message_expiry;
private String dlt_entity_id;
private String dlt_template_id;
private String dlt_template_category;


/**
Expand Down Expand Up @@ -127,9 +130,21 @@ public String[] media_ids() {
return this.media_ids;
}

public Long message_expiry() {
return this.message_expiry;
}
public Long message_expiry() {
return this.message_expiry;
}

public String dlt_entity_id() {
return this.dlt_entity_id;
}

public String dlt_template_id() {
return this.dlt_template_id;
}

public String dlt_template_category() {
return this.dlt_template_category;
}

/**
* @param type Must be {@link MessageType#SMS}
Expand Down Expand Up @@ -193,6 +208,29 @@ public MessageCreator message_expiry(final Long message_expiry) {
return this;
}

/**
* @param dlt_entity_id This is the DLT entity id passed in the message request.
*/
public MessageCreator dlt_entity_id(final String dlt_entity_id) {
this.dlt_entity_id = dlt_entity_id;
return this;
}

/**
* @param dlt_template_id This is the DLT template id passed in the message request.
*/
public MessageCreator dlt_template_id(final String dlt_template_id) {
this.dlt_template_id = dlt_template_id;
return this;
}

/**
* @param dlt_template_category This is the DLT template category passed in the message request.
*/
public MessageCreator dlt_template_category(final String dlt_template_category) {
this.dlt_template_category = dlt_template_category;
return this;
}

@Override
protected Call < MessageCreateResponse > obtainCall() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/com/plivo/api/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.28.0
5.29.0
18 changes: 18 additions & 0 deletions src/test/java/com/plivo/api/MessageTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ public void messageGetShouldSucceed() throws Exception {
String fixtureName = "messageGetResponse.json";
String messageUuid = "5b40a428-bfc7-4daf-9d06-726c558bf3b8";
String requesterIP = "192.168.1.1";
String expectedDLTEntityID = "1234";
String expectedDLTTemplateID = "4567";
String expectedDLTTemplateCategory = "service_implicit";
expectResponse(fixtureName, 200);

Message message = Message.getter(messageUuid).get();
Expand All @@ -166,6 +169,9 @@ public void messageGetShouldSucceed() throws Exception {
assertRequest("GET", "Message/%s/", messageUuid);
assertEquals(messageUuid, message.getMessageUuid());
assertEquals(requesterIP, message.getRequesterIP());
assertEquals(expectedDLTEntityID, message.getDltEntityID());
assertEquals(expectedDLTTemplateID, message.getDltTemplateID());
assertEquals(expectedDLTTemplateCategory, message.getDltTemplateCategory());
}

@Test
Expand All @@ -189,6 +195,10 @@ public void messageListShouldSucceed() throws Exception {
String fixtureName = "messageListResponse.json";
String requesterIP1 = "192.168.1.1";
String requesterIP2 = "192.168.1.20";

String expectedDLTEntityID = "9596";
String expectedDLTTemplateID = "0499";
String expectedDLTTemplateCategory = "service_explicit";
expectResponse(fixtureName, 200);

ListResponse<Message> response = Message.lister()
Expand All @@ -204,6 +214,14 @@ public void messageListShouldSucceed() throws Exception {
assertRequest("GET", "Message/", params);
assertEquals(requesterIP1, response.getObjects().get(0).getRequesterIP());
assertEquals(requesterIP2, response.getObjects().get(19).getRequesterIP());

assertEquals(expectedDLTEntityID, response.getObjects().get(0).getDltEntityID());
assertEquals(expectedDLTTemplateID, response.getObjects().get(0).getDltTemplateID());
assertEquals(expectedDLTTemplateCategory, response.getObjects().get(0).getDltTemplateCategory());

assertEquals("", response.getObjects().get(19).getDltEntityID());
assertEquals("", response.getObjects().get(19).getDltTemplateID());
assertEquals("", response.getObjects().get(19).getDltTemplateCategory());
}

@Test
Expand Down
5 changes: 4 additions & 1 deletion src/test/resources/com/plivo/api/messageGetResponse.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@
"total_rate": "0.00250",
"units": 1,
"requester_ip": "192.168.1.1",
"is_domestic": false
"is_domestic": false,
"dlt_entity_id": "1234",
"dlt_template_id": "4567",
"dlt_template_category": "service_implicit"
}
Loading

0 comments on commit 584b2f7

Please sign in to comment.