diff --git a/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java
index 98174434..56f83865 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java
@@ -19,8 +19,9 @@
public interface BatchesService {
/**
- * Get a batch message
- * This operation returns a specific batch that matches the provided batch ID.
+ * Get a batch message.
+ *
+ *
This operation returns a specific batch that matches the provided batch ID.
*
* @param batchId The batch ID you received from sending a message
* @param Depending on the length of the body, one message might be split into multiple parts and
+ * charged accordingly. This operation will perform a dry run of a batch which calculates the bodies and number of
* parts for all messages in the batch without actually sending any messages.
*
* @param perRecipient Whether to include per recipient details in the response
@@ -66,9 +69,10 @@ DryRun dryRun(boolean perRecipient, int numberOfRecipient, BaseBatch> batch)
throws ApiException;
/**
- * List Batches With the list operation you can list batch messages created in the last 14 days that you
+ * have created. This operation supports pagination.
*
* @param parameters Query parameters filtering returned batches
* @return Paginated list of Batches
@@ -79,8 +83,10 @@ DryRun dryRun(boolean perRecipient, int numberOfRecipient, BaseBatch> batch)
BatchesListResponse list(BatchesListRequestParameters parameters) throws ApiException;
/**
- * Update a Batch message This operation updates all specified parameters of a batch that matches the provided batch
+ * ID.
*
* @param batchId The batch ID you received from sending a message
* @param batch Batch parameters to be updated
@@ -94,9 +100,10 @@ This operation will replace all the parameters of a batch with the provided values. It is
+ * the same as cancelling a batch and sending a new one instead.
*
* @param batchId The batch ID you received from sending a message
* @param batch Batch parameters to be used
@@ -109,8 +116,9 @@ A batch can be canceled at any point. If a batch is canceled while it's currently being
* delivered some messages currently being processed might still be delivered. The delivery report
* will indicate which messages were canceled and which weren't. Send feedback if your system can confirm successful message delivery.
*
diff --git a/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java b/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java
index 49c3cd36..84879c27 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java
@@ -8,7 +8,7 @@
import com.sinch.sdk.domains.sms.models.responses.DeliveryReportsListResponse;
/**
- * Delivery reports Service
+ * Delivery reports Service.
*
* The REST API uses message statuses and error codes in delivery reports, which refer to the
* state of the batch and can be present in either
- * Delivery reports can be retrieved even if no callback was requested. The difference between a
- * summary and a full report is only that the full report contains the phone numbers in Delivery reports can be retrieved even if no callback was requested. The difference between
+ * a summary and a full report is only that the full report contains the phone numbers in E.164 format for each status
* code.
*
@@ -40,8 +41,9 @@ DeliveryReportBatch get(String batchId, DeliveryReportBatchGetRequestParameters
throws ApiException;
/**
- * Retrieve a recipient delivery report A recipient delivery report contains the message status for a single recipient phone number.
*
* @param batchId The batch ID you received from sending a message param type param status param
* code
@@ -54,8 +56,9 @@ DeliveryReportBatch get(String batchId, DeliveryReportBatchGetRequestParameters
DeliveryReportRecipient getForNumber(String batchId, String recipient) throws ApiException;
/**
- * Get a list of finished delivery reports. This operation supports pagination.
*
* @param parameters Filtering parameters
* @return Delivery report related to batchId according to filters
diff --git a/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java b/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java
index 8111bb1e..e0252a2a 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java
@@ -23,7 +23,7 @@
public interface GroupsService {
/**
- * Retrieve a group
+ * Retrieve a group.
*
* This operation retrieves a specific group with the provided group ID.
*
@@ -36,7 +36,7 @@ public interface GroupsService {
Group get(String groupId) throws ApiException;
/**
- * Create a group
+ * Create a group.
*
* A group is a set of phone numbers (MSISDNs) that can be used as a target in the An inbound message is a message sent to one of your short codes or long numbers from a
- * mobile phone. To receive inbound message callbacks, a URL needs to be added to your REST API.
- * This URL can be specified in your Dashboard.
- *
- * @param jsonPayload The incoming message to your sinch number
- * @return Decoded payload
- * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/incomingSMS
- * @since 1.0
- */
- Inbound> incomingSMS(String jsonPayload) throws ApiMappingException;
-
- /**
- * Delivery Report WebHook
- *
- * A delivery report contains the status and status code for each recipient of a batch. To get
- * a delivery report callback for a message or batch of messages, set the The following is provided so you can better understand our webhooks/callbacks. Configuration
- * of both webhooks and the type of delivery report requested happens when sending a batch.
- *
- * Callback URL
- *
- * The callback URL can either be provided for each batch or provisioned globally for your
- * account in your Sinch Customer
- * Dashboard. Learn how to configure a webhook/callback here
- *
- * Type
- *
- * The An inbound message is a message sent to one of your short codes or long numbers from a mobile
+ * phone. To receive inbound message callbacks, a URL needs to be added to your REST API.
+ *
+ * This URL can be specified in your Dashboard.
+ *
+ * See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/incomingSMS
+ *
+ * A delivery report contains the status and status code for each recipient of a batch. To get a
+ * delivery report callback for a message or batch of messages, set the The following is provided so you can better understand our webhooks/callbacks. Configuration
+ * of both webhooks and the type of delivery report requested happens when sending a batch.
+ *
+ * Callback URL
+ *
+ * The callback URL can either be provided for each batch or provisioned globally for your
+ * account in your Sinch Customer Dashboard.
+ * Learn how to configure a webhook/callback here
+ *
+ * Type
+ *
+ * The These are reports containing either
+ * a full report or summary report, depending on your selection at the time the batch was
+ * sent.
+ * These are delivery reports for recipient phone numbers. If you set
- * Depending on the length of the body, one message might be split into multiple parts and charged
- * accordingly.
+ * Send a message or a batch of messages.
+ *
+ *
* Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group
* is deleted between batch creation and scheduled date, it will be considered empty.
* Be sure to use the correct region in the server URL.
@@ -49,8 +51,9 @@ public interface BatchesService {
- * This operation will perform a dry run of a batch which calculates the bodies and number of
+ * Dry run.
+ *
+ *
- * With the list operation you can list batch messages created in the last 14 days that you have
- * created. This operation supports pagination.
+ * List Batches.
+ *
+ *
- * This operation updates all specified parameters of a batch that matches the provided batch ID.
+ * Update a Batch message.
+ *
+ *
- * This operation will replace all the parameters of a batch with the provided values. It is the
- * same as cancelling a batch and sending a new one instead.
+ * Replace a batch .
+ *
+ *
- * A batch can be canceled at any point. If a batch is canceled while it's currently being
+ * Cancel a batch message.
+ *
+ *
* Canceling a batch scheduled in the future will result in an empty delivery report while
@@ -126,7 +134,7 @@
- * A recipient delivery report contains the message status for a single recipient phone number.
+ * Retrieve a recipient delivery report.
+ *
+ *
- * This operation supports pagination.
+ * Get a list of finished delivery reports.
+ *
+ *
* send_batch_msg
operation. An MSISDN can only occur once in a group and any attempts to
@@ -50,6 +50,12 @@ public interface GroupsService {
*/
Group create(GroupCreateRequestParameters parameters) throws ApiException;
+ /**
+ * Create an unnamed and empty group
+ *
+ * @return See {@link #create(GroupCreateRequestParameters)}
+ * @since 1.0
+ */
Group create() throws ApiException;
/**
@@ -68,6 +74,12 @@ public interface GroupsService {
*/
GroupsListResponse list(GroupsListRequestParameters parameters) throws ApiException;
+ /**
+ * List groups with default parameters
+ *
+ * @return See {@link #list(GroupsListRequestParameters)}
+ * @since 1.0
+ */
GroupsListResponse list() throws ApiException;
/**
diff --git a/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java
index 185ada01..1597965f 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java
@@ -1,8 +1,7 @@
package com.sinch.sdk.domains.sms;
import com.sinch.sdk.core.exceptions.ApiMappingException;
-import com.sinch.sdk.domains.sms.models.BaseDeliveryReport;
-import com.sinch.sdk.domains.sms.models.Inbound;
+import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent;
/**
* WebHooks
@@ -41,63 +40,11 @@
public interface WebHooksService {
/**
- * Incoming SMS WebHook
+ * Parse and un-serialize incoming webhooks payload
*
- * delivery_report
- *
field accordingly when creating a batch.
- *
- * type
is the type of delivery report webhook. The response will vary
- * depending on the webhook delivery report you selected when the batch was sent, so choose the
- * appropriate selection under "One of".
- *
- *
- *
- *
- * @param jsonPayload The incoming delivery report
- * @return Decoded payload
- * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/deliveryReport
- * @since 1.0
+ * @param jsonPayload The incoming payload received onto webhooks call
+ * @return Un serialized object instance (see inherited classes) and {@link
+ * com.sinch.sdk.domains.sms.models.webhooks package documentation}
*/
- BaseDeliveryReport deliveryReport(String jsonPayload) throws ApiMappingException;
+ WebhooksEvent parse(String jsonPayload) throws ApiMappingException;
}
diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java
index 7cd2c35e..c5c64705 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java
@@ -12,55 +12,59 @@
import com.sinch.sdk.domains.sms.models.dto.v1.MOBinaryDto;
import com.sinch.sdk.domains.sms.models.dto.v1.MOTextDto;
import com.sinch.sdk.domains.sms.models.dto.v1.RecipientDeliveryReportDto;
+import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent;
import java.util.Objects;
public class WebHooksService implements com.sinch.sdk.domains.sms.WebHooksService {
- @Override
- public Inbound> incomingSMS(String jsonPayload) throws ApiMappingException {
+ public WebhooksEvent parse(String jsonPayload) throws ApiMappingException {
+
+ WebhooksEvent event;
try {
- MOBinaryDto binary = Mapper.getInstance().readValue(jsonPayload, MOBinaryDto.class);
- if (null != binary
- && (Objects.equals(binary.getType(), MOBinaryDto.TypeEnum.MO_BINARY.getValue()))) {
- return InboundsDtoConverter.convert(binary);
+ event = incomingSMS(jsonPayload);
+ if (null == event) {
+ event = deliveryReport(jsonPayload);
}
- MOTextDto text = Mapper.getInstance().readValue(jsonPayload, MOTextDto.class);
- if (null != text && (Objects.equals(text.getType(), MOTextDto.TypeEnum.MO_TEXT.getValue()))) {
- return InboundsDtoConverter.convert(text);
+ if (null == event) {
+ throw new ApiMappingException(jsonPayload, null);
}
- throw new ApiMappingException(jsonPayload, null);
-
} catch (JsonProcessingException e) {
throw new ApiMappingException(jsonPayload, e);
}
+ return event;
}
- @Override
- public BaseDeliveryReport deliveryReport(String jsonPayload) throws ApiMappingException {
- try {
- // Can we convert payload to Recipient DeliveryReport or Batch Delivery Report ?
- RecipientDeliveryReportDto recipient =
- Mapper.getInstance().readValue(jsonPayload, RecipientDeliveryReportDto.class);
- if (null != recipient
- && (Objects.equals(
- recipient.getType(), RecipientDeliveryReportDto.TypeEnum.MMS.getValue())
- || Objects.equals(
- recipient.getType(), RecipientDeliveryReportDto.TypeEnum.SMS.getValue()))) {
- return DeliveryReportDtoConverter.convert(recipient);
- }
-
- DeliveryReportDto batch =
- Mapper.getInstance().readValue(jsonPayload, DeliveryReportDto.class);
- if (null != batch
- && (Objects.equals(batch.getType(), TypeEnum.MMS.getValue())
- || Objects.equals(batch.getType(), TypeEnum.SMS.getValue()))) {
- return DeliveryReportDtoConverter.convert(batch);
- }
+ private Inbound> incomingSMS(String jsonPayload) throws JsonProcessingException {
+ MOBinaryDto binary = Mapper.getInstance().readValue(jsonPayload, MOBinaryDto.class);
+ if (null != binary
+ && (Objects.equals(binary.getType(), MOBinaryDto.TypeEnum.MO_BINARY.getValue()))) {
+ return InboundsDtoConverter.convert(binary);
+ }
+ MOTextDto text = Mapper.getInstance().readValue(jsonPayload, MOTextDto.class);
+ if (null != text && (Objects.equals(text.getType(), MOTextDto.TypeEnum.MO_TEXT.getValue()))) {
+ return InboundsDtoConverter.convert(text);
+ }
+ return null;
+ }
- throw new ApiMappingException(jsonPayload, null);
+ private BaseDeliveryReport deliveryReport(String jsonPayload) throws JsonProcessingException {
+ // Can we convert payload to Recipient DeliveryReport or Batch Delivery Report ?
+ RecipientDeliveryReportDto recipient =
+ Mapper.getInstance().readValue(jsonPayload, RecipientDeliveryReportDto.class);
+ if (null != recipient
+ && (Objects.equals(recipient.getType(), RecipientDeliveryReportDto.TypeEnum.MMS.getValue())
+ || Objects.equals(
+ recipient.getType(), RecipientDeliveryReportDto.TypeEnum.SMS.getValue()))) {
+ return DeliveryReportDtoConverter.convert(recipient);
+ }
- } catch (JsonProcessingException e) {
- throw new ApiMappingException(jsonPayload, e);
+ DeliveryReportDto deliveryReport =
+ Mapper.getInstance().readValue(jsonPayload, DeliveryReportDto.class);
+ if (null != deliveryReport
+ && (Objects.equals(deliveryReport.getType(), TypeEnum.MMS.getValue())
+ || Objects.equals(deliveryReport.getType(), TypeEnum.SMS.getValue()))) {
+ return DeliveryReportDtoConverter.convert(deliveryReport);
}
+ return null;
}
}
diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java
index 2b426013..f78640d0 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java
@@ -1,5 +1,6 @@
package com.sinch.sdk.domains.sms.models;
+import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent;
import java.util.Objects;
import java.util.Optional;
@@ -8,7 +9,7 @@
*
* @since 1.0
*/
-public abstract class BaseDeliveryReport {
+public abstract class BaseDeliveryReport implements WebhooksEvent {
private final String batchId;
private final String clientReference;
diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java b/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java
index 2c71c310..c32a37d9 100644
--- a/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java
+++ b/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java
@@ -1,5 +1,6 @@
package com.sinch.sdk.domains.sms.models;
+import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent;
import java.time.Instant;
import java.util.Optional;
@@ -9,7 +10,7 @@
* @param delivery_report_sms
and delivery_report_mms
types are
- * documented under Delivery report. These are reports containing either
- * a full report or summary report, depending on your selection at the time the batch
- * was sent.
- * recipient_delivery_report_sms
and recipient_delivery_report_mms
- *
delivery report types are documented under Recipient delivery report.
- * These are delivery reports for recipient phone numbers. If you set per_recipient
- *
for the delivery_report
parameter when sending the batch, a
- * recipient report gets sent to you for each status change for each recipient in your
- * batch. If you set per_recipient_final
, a recipient report gets sent to you
- * for the final status of each recipient in your batch.
- * Incoming SMS WebHook
+ *
+ * Delivery Report WebHook
+ *
+ * delivery_report
+ *
field accordingly when creating a batch.
+ *
+ * type
is the type of delivery report webhook. The response will vary depending
+ * on the webhook delivery report you selected when the batch was sent, so choose the appropriate
+ * selection under "One of".
+ *
+ *
+ *
+ *
+ * See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/deliveryReport
+ *
+ * @since 1.0
+ */
+package com.sinch.sdk.domains.sms.models.webhooks;
diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/WebHooksServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/WebHooksServiceTest.java
index 286a1269..afe60422 100644
--- a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/WebHooksServiceTest.java
+++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/WebHooksServiceTest.java
@@ -10,18 +10,17 @@
import com.sinch.sdk.core.exceptions.ApiMappingException;
import com.sinch.sdk.domains.sms.adapters.converters.DeliveryReportDtoConverter;
import com.sinch.sdk.domains.sms.adapters.converters.InboundsDtoConverter;
-import com.sinch.sdk.domains.sms.models.BaseDeliveryReport;
import com.sinch.sdk.domains.sms.models.DeliveryReportBatchMMS;
import com.sinch.sdk.domains.sms.models.DeliveryReportBatchSMS;
import com.sinch.sdk.domains.sms.models.DeliveryReportRecipientMMS;
import com.sinch.sdk.domains.sms.models.DeliveryReportRecipientSMS;
-import com.sinch.sdk.domains.sms.models.Inbound;
import com.sinch.sdk.domains.sms.models.InboundBinary;
import com.sinch.sdk.domains.sms.models.InboundText;
import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportBatchDtoTest;
import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportRecipientDtoTest;
import com.sinch.sdk.domains.sms.models.dto.v1.MOBinaryDtoTest;
import com.sinch.sdk.domains.sms.models.dto.v1.MOTextDtoTest;
+import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
@@ -52,7 +51,7 @@ public class WebHooksServiceTest extends BaseTest {
@Test
void incomingSMSBinary() throws ApiException {
- Inbound> response = service.incomingSMS(incomingSMSBinaryJsonString);
+ WebhooksEvent response = service.parse(incomingSMSBinaryJsonString);
Assertions.assertThat(response).isInstanceOf(InboundBinary.class);
Assertions.assertThat(response)
@@ -63,7 +62,7 @@ void incomingSMSBinary() throws ApiException {
@Test
void incomingSMSText() throws ApiException {
- Inbound> response = service.incomingSMS(incomingSMSTextJsonString);
+ WebhooksEvent response = service.parse(incomingSMSTextJsonString);
Assertions.assertThat(response).isInstanceOf(InboundText.class);
Assertions.assertThat(response)
@@ -76,14 +75,14 @@ void handleExceptionIncomingSMS() throws ApiException {
String jsonPayload = incomingSMSBinaryJsonString.replace("mo_binary", "foo type");
ApiMappingException thrown =
- assertThrows(ApiMappingException.class, () -> service.incomingSMS(jsonPayload));
+ assertThrows(ApiMappingException.class, () -> service.parse(jsonPayload));
assertTrue(thrown.getMessage().contains(jsonPayload));
}
@Test
void deliveryReportRecipientDeliveryReportSms() throws ApiException {
- BaseDeliveryReport response = service.deliveryReport(deliveryReportRecipientSMSJsonString);
+ WebhooksEvent response = service.parse(deliveryReportRecipientSMSJsonString);
Assertions.assertThat(response).isInstanceOf(DeliveryReportRecipientSMS.class);
Assertions.assertThat(response)
@@ -96,7 +95,7 @@ void deliveryReportRecipientDeliveryReportSms() throws ApiException {
@Test
void deliveryReportRecipientDeliveryReportMms() throws ApiException {
- BaseDeliveryReport response = service.deliveryReport(deliveryReportRecipientMMSJsonString);
+ WebhooksEvent response = service.parse(deliveryReportRecipientMMSJsonString);
Assertions.assertThat(response).isInstanceOf(DeliveryReportRecipientMMS.class);
Assertions.assertThat(response)
@@ -109,7 +108,7 @@ void deliveryReportRecipientDeliveryReportMms() throws ApiException {
@Test
void deliveryReportBatchDeliveryReportSms() throws ApiException {
- BaseDeliveryReport response = service.deliveryReport(deliveryReportBatchSMSJsonString);
+ WebhooksEvent response = service.parse(deliveryReportBatchSMSJsonString);
Assertions.assertThat(response).isInstanceOf(DeliveryReportBatchSMS.class);
Assertions.assertThat(response)
@@ -121,7 +120,7 @@ void deliveryReportBatchDeliveryReportSms() throws ApiException {
@Test
void deliveryReportBatchDeliveryReportMms() throws ApiException {
- BaseDeliveryReport response = service.deliveryReport(deliveryReportBatchMMSJsonString);
+ WebhooksEvent response = service.parse(deliveryReportBatchMMSJsonString);
Assertions.assertThat(response).isInstanceOf(DeliveryReportBatchMMS.class);
Assertions.assertThat(response)
@@ -136,7 +135,7 @@ void handleExceptionDeliveryReport() throws ApiException {
String jsonPayload =
deliveryReportRecipientMMSJsonString.replace("recipient_delivery_report_mms", "foo type");
ApiMappingException thrown =
- assertThrows(ApiMappingException.class, () -> service.deliveryReport(jsonPayload));
+ assertThrows(ApiMappingException.class, () -> service.parse(jsonPayload));
assertTrue(thrown.getMessage().contains(jsonPayload));
}
}
diff --git a/pom.xml b/pom.xml
index 27bf5f4c..cb1a8cf1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -297,7 +297,8 @@
delivery_report_sms
and delivery_report_mms
types are
+ * documented under Delivery report.
+ * recipient_delivery_report_sms
and recipient_delivery_report_mms
+ *
delivery report types are documented under Recipient delivery report.
+ * per_recipient
+ *
for the delivery_report
parameter when sending the batch, a recipient
+ * report gets sent to you for each status change for each recipient in your batch. If you set
+ * per_recipient_final
, a recipient report gets sent to you for the final status
+ * of each recipient in your batch.
+ *