Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flash_message and max_number_of_message_parts properties #17

Merged
Merged
5 changes: 5 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ jobs:
distribution: 'adopt'
- name: Build with Maven
run: mvn --batch-mode --update-snapshots verify -Dgpg.skip
- run: mkdir snapshots && cp target/*.jar snapshots
- uses: actions/upload-artifact@v2
with:
name: Package
path: snapshots
23 changes: 22 additions & 1 deletion src/main/java/com/sinch/xms/api/MtBatchSmsCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public abstract class MtBatchSmsCreate {
public abstract URI callbackUrl();

/**
* The boolean value which determines if feedback is allowed to be sent
* Send feedback if your system can confirm successful message delivery. Feedback can only be
* provided if feedback_enabled was set when batch was submitted.
*
* @return boolean value
*/
Expand Down Expand Up @@ -126,6 +127,26 @@ public abstract class MtBatchSmsCreate {
@JsonProperty("client_reference")
public abstract String clientReference();

/**
* Shows message on screen without user interaction while not saving the message to the inbox.
* Defaults to false.
*
* @return boolean indicating if it's a flash message
*/
@Nullable
@JsonProperty("flash_message")
public abstract Boolean flashMessage();

/**
* Message will be dispatched only if it is not split to more parts than Max Number of Message
* Parts. Defaults to false.
*
* @return the maximum allowed number of message parts
*/
@Nullable
@JsonProperty("max_number_of_message_parts")
public abstract Integer maxNumberOfMessageParts();

/**
* The DLT principal entity identifier to attach to this message.
*
Expand Down
32 changes: 30 additions & 2 deletions src/main/java/com/sinch/xms/api/MtBatchSmsResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public abstract class MtBatchSmsResult {
/**
* The type of delivery report used for this batch.
*
* @return a type of report or <code>null</code> for the default type
* @return a type of report, <code>ReportType.NONE</code> if not provided
*/
@Nullable
@JsonProperty("delivery_report")
public abstract ReportType deliveryReport();

/**
Expand Down Expand Up @@ -137,6 +137,34 @@ public abstract class MtBatchSmsResult {
@JsonProperty("client_reference")
public abstract String clientReference();

/**
* Shows message on screen without user interaction while not saving the message to the inbox.
*
* @return boolean indicating if it's a flash message
*/
@JsonProperty("flash_message")
public abstract boolean flashMessage();

/**
* Send feedback if your system can confirm successful message delivery. Feedback can only be
* provided if feedback_enabled was set when batch was submitted.
*
* @return boolean indicating if feedback is enabled
*/
@Nullable
@JsonProperty("feedback_enabled")
public abstract Boolean feedbackEnabled();

/**
* Message will be dispatched only if it is not split to more parts than Max Number of Message
* Parts.
*
* @return the maximum allowed number of message parts
*/
@Nullable
@JsonProperty("max_number_of_message_parts")
public abstract Integer maxNumberOfMessageParts();

/**
* The DLT principal entity identifier to attach to this message.
*
Expand Down
61 changes: 59 additions & 2 deletions src/test/java/com/sinch/xms/ApiConnectionIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import com.sinch.xms.api.PagedGroupResult;
import com.sinch.xms.api.PagedInboundsResult;
import com.sinch.xms.api.RecipientDeliveryReport;
import com.sinch.xms.api.ReportType;
import com.sinch.xms.api.Tags;
import com.sinch.xms.api.TagsUpdate;
import java.io.IOException;
Expand Down Expand Up @@ -102,7 +103,7 @@ public class ApiConnectionIT {

/**
* A convenient {@link FutureCallback} for use in tests. By default all callback methods will call
* {@link #fail(String)}. Override the one that should succeed.
* {@link #failed(Exception)}. Override the one that should succeed.
*
* @param <T> the callback result type
*/
Expand Down Expand Up @@ -152,6 +153,9 @@ public void canCreateBinaryBatch() throws Exception {
.body(request.body())
.udh(request.udh())
.canceled(false)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.id(batchId)
.createdAt(time)
.modifiedAt(time)
Expand Down Expand Up @@ -194,6 +198,9 @@ public void canCreateTextBatch() throws Exception {

MtBatchTextSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender(request.sender())
.recipients(request.recipients())
.body(request.body())
Expand Down Expand Up @@ -246,6 +253,9 @@ public void canCreateTextBatchWithSubstitutions() throws Exception {

MtBatchTextSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender(request.sender())
.recipients(request.recipients())
.body(request.body())
Expand Down Expand Up @@ -533,6 +543,9 @@ public void canReplaceBinaryBatch() throws Exception {
.recipients(request.recipients())
.body(request.body())
.udh(request.udh())
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.canceled(false)
.id(batchId)
.createdAt(time)
Expand Down Expand Up @@ -576,6 +589,9 @@ public void canReplaceTextBatch() throws Exception {

MtBatchTextSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender(request.sender())
.recipients(request.recipients())
.body(request.body())
Expand Down Expand Up @@ -622,6 +638,9 @@ public void canUpdateSimpleTextBatch() throws Exception {

MtBatchTextSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender(request.sender())
.addRecipient("123")
.body(request.body())
Expand Down Expand Up @@ -675,6 +694,9 @@ public void canUpdateSimpleBinaryBatch() throws Exception {
.addRecipient("123")
.body(request.body())
.udh((byte) 1, (byte) 0xff)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.canceled(false)
.id(batchId)
.createdAt(time)
Expand Down Expand Up @@ -712,6 +734,9 @@ public void canFetchTextBatch() throws Exception {

final MtBatchSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender("12345")
.addRecipient("123456789", "987654321")
.body("Hello, world!")
Expand Down Expand Up @@ -750,6 +775,9 @@ public void canFetchTextBatchAsync() throws Exception {

final MtBatchSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender("12345")
.addRecipient("123456789", "987654321")
.body("Hello, world!")
Expand Down Expand Up @@ -801,6 +829,9 @@ public void canFetchBinaryBatch() throws Exception {
.addRecipient("123456789", "987654321")
.body((byte) 0xf0, (byte) 0x0f)
.udh((byte) 0x50, (byte) 0x05)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.canceled(false)
.id(batchId)
.createdAt(time)
Expand Down Expand Up @@ -1018,6 +1049,9 @@ public void canCancelBatch() throws Exception {

MtBatchSmsResult expected =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender("12345")
.addRecipient("123456789", "987654321")
.body("Hello, world!")
Expand Down Expand Up @@ -1058,6 +1092,9 @@ public void canCancelBatchConcurrently() throws Exception {
// Set up the first request (the one that will be delayed).
MtBatchSmsResult expected1 =
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.sender("12345")
.addRecipient("123456789", "987654321")
.body("Hello, world!")
Expand Down Expand Up @@ -1086,6 +1123,9 @@ public void canCancelBatchConcurrently() throws Exception {
.addRecipient("123456789", "987654321")
.body("Hello, world!".getBytes())
.udh((byte) 1)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.canceled(true)
.id(TestUtils.freshBatchId())
.createdAt(OffsetDateTime.now())
Expand Down Expand Up @@ -1252,6 +1292,9 @@ public void canIterateOverPages() throws Exception {
.totalSize(2)
.addContent(
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.id(TestUtils.freshBatchId())
.body("body")
.canceled(false)
Expand All @@ -1274,9 +1317,15 @@ public void canIterateOverPages() throws Exception {
.body((byte) 0)
.udh((byte) 1)
.canceled(false)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.build())
.addContent(
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.id(TestUtils.freshBatchId())
.body("body")
.canceled(false)
Expand Down Expand Up @@ -1329,6 +1378,9 @@ public void canIterateOverBatchesWithTwoPages() throws Exception {
.totalSize(3)
.addContent(
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.id(TestUtils.freshBatchId())
.body("body")
.canceled(false)
Expand All @@ -1351,9 +1403,15 @@ public void canIterateOverBatchesWithTwoPages() throws Exception {
.body((byte) 0)
.udh((byte) 1)
.canceled(false)
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.build())
.addContent(
MtBatchTextSmsResult.builder()
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.id(TestUtils.freshBatchId())
.body("body")
.canceled(false)
Expand Down Expand Up @@ -3374,7 +3432,6 @@ private void verifyGetRequest(String path) {
*
* @param response the response to give, serialized to JSON
* @param path the path on which to listen
* @param status the response HTTP status
* @throws JsonProcessingException if the given response object could not be serialized
*/
private void stubDeleteResponse(Object response, String path) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public void canSerializeMinimal() throws Exception {
" 'from': '1234',",
" 'to': [ '987654321' ],",
" 'canceled': false,",
" 'feedback_enabled': false,",
" 'flash_message': false,",
" 'delivery_report': 'none',",
" 'id': '" + input.id() + "',",
" 'body': 'SGVsbG8sIHdvcmxkIQ==',",
" 'udh': '01020304'",
Expand All @@ -69,6 +72,9 @@ private static MtBatchBinarySmsResult.Builder minimalBatchBuilder() {
return new MtBatchBinarySmsResult.Builder()
.sender("1234")
.addRecipient("987654321")
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.body("Hello, world!".getBytes(TestUtils.US_ASCII))
.udh(new byte[] {1, 2, 3, 4})
.canceled(false)
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/com/sinch/xms/api/MtBatchTextSmsResultTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public void canSerializeMinimal() throws Exception {
" 'to': [ '987654321' ],",
" 'body': 'Hello, world!',",
" 'canceled': false,",
" 'feedback_enabled': false,",
" 'flash_message': false,",
" 'delivery_report': 'none',",
" 'id': '" + input.id() + "'",
"}")
.replace('\'', '"');
Expand Down Expand Up @@ -86,6 +89,9 @@ public void canSerializeWithParameters() throws Exception {
" 'to': [ '987654321' ],",
" 'body': 'Hello, world!',",
" 'canceled': false,",
" 'flash_message': false,",
" 'feedback_enabled': false,",
" 'delivery_report': 'none',",
" 'id': '" + input.id() + "',",
" 'parameters': {",
" 'param1': {",
Expand Down Expand Up @@ -142,6 +148,9 @@ public void canSerializeWithParametersAndDefault() throws Exception {
" 'to': [ '987654321' ],",
" 'body': 'Hello, world!',",
" 'canceled': false,",
" 'feedback_enabled': false,",
" 'flash_message': false,",
" 'delivery_report': 'none',",
" 'id': '" + input.id() + "',",
" 'parameters': {",
" 'param1': {",
Expand Down Expand Up @@ -182,6 +191,9 @@ private static MtBatchTextSmsResult.Builder minimalBatchBuilder() {
return new MtBatchTextSmsResult.Builder()
.sender("1234")
.addRecipient("987654321")
.flashMessage(false)
.feedbackEnabled(false)
.deliveryReport(ReportType.NONE)
.body("Hello, world!")
.canceled(false)
.id(TestUtils.freshBatchId());
Expand Down
Loading