Skip to content

Commit

Permalink
Merge pull request #361 from Vonage/feature/sms-dlt-fields
Browse files Browse the repository at this point in the history
Feature/sms dlt fields
  • Loading branch information
slorello89 authored Mar 11, 2021
2 parents e51ac59 + a8e15c7 commit 86cb98f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [6.2.0]
- Adding ContentId and EntityId to message class for DLT

## [6.1.0]
- Adding Language and Style to the Voice Talk Action and the Talk Request
- Marking VoiceName as Deprecated
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/vonage/client/sms/messages/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public String toString() {
private MessageClass messageClass = null;
private Long timeToLive = null;
private String callbackUrl = null;
private String entityId = null;
private String contentId = null;

protected Message(final MessageType type,
final String from,
Expand Down Expand Up @@ -148,6 +150,14 @@ public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}

public String getEntityId() { return entityId; }

public void setEntityId(String entityId){ this.entityId = entityId; }

public String getContentId() { return contentId; }

public void setContentId(String contentId) { this.contentId = contentId; }

/**
* @return get the value of the 'status-report-req' parameter.
*/
Expand Down Expand Up @@ -187,6 +197,12 @@ public void addParams(RequestBuilder request) {
if (messageClass != null) {
request.addParameter("message-class", Integer.toString(messageClass.getMessageClass()));
}
if(entityId != null){
request.addParameter("entity-id", entityId);
}
if(contentId != null){
request.addParameter("content-id", contentId);
}
}

/**
Expand Down
30 changes: 30 additions & 0 deletions src/test/java/com/vonage/client/sms/SendMessageEndpointTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,4 +284,34 @@ public void testEntityEncoding() throws Exception {
assertEquals("application/x-www-form-urlencoded; charset=UTF-8", entity.getContentType().getValue());
}
}

@Test
public void testConstructParamsContentId() throws Exception {
Message message = new TextMessage("TestSender", "not-a-number", "Test");
message.setContentId("abcd-1234");
List<NameValuePair> params = endpoint.makeRequest(message).getParameters();

assertContainsParam(params, "from", "TestSender");
assertContainsParam(params, "to", "not-a-number");
assertContainsParam(params, "type", "text");
assertMissingParam(params, "status-report-req");
assertContainsParam(params, "text", "Test");
assertContainsParam(params, "content-id","abcd-1234");
assertMissingParam(params,"entity-id");
}

@Test
public void testConstructParamsEntityId() throws Exception {
Message message = new TextMessage("TestSender", "not-a-number", "Test");
message.setEntityId("abcd-1234");
List<NameValuePair> params = endpoint.makeRequest(message).getParameters();

assertContainsParam(params, "from", "TestSender");
assertContainsParam(params, "to", "not-a-number");
assertContainsParam(params, "type", "text");
assertMissingParam(params, "status-report-req");
assertContainsParam(params, "text", "Test");
assertContainsParam(params, "entity-id","abcd-1234");
assertMissingParam(params,"content-id");
}
}

0 comments on commit 86cb98f

Please sign in to comment.