Skip to content

Commit

Permalink
feat: SMS API availbility
Browse files Browse the repository at this point in the history
  • Loading branch information
JPPortier authored Nov 16, 2023
1 parent da7fd53 commit 5313997
Show file tree
Hide file tree
Showing 177 changed files with 10,296 additions and 1,234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
*
* @since 1.0
*/
public final class Capability extends EnumDynamic<Capability> {
public final class Capability extends EnumDynamic<String, Capability> {
/** The SMS product can use the number. */
public static final Capability SMS = new Capability("SMS");

/** The Voice product can use the number. */
public static final Capability VOICE = new Capability("VOICE");

private static final EnumSupportDynamic<Capability> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, Capability> ENUM_SUPPORT =
new EnumSupportDynamic<>(Capability.class, Capability::new, Arrays.asList(SMS, VOICE));

private Capability(String value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*
* @since 1.0
*/
public final class NumberType extends EnumDynamic<NumberType> {
public final class NumberType extends EnumDynamic<String, NumberType> {

/** Numbers that belong to a specific range. */
public static final NumberType MOBILE = new NumberType("MOBILE");
Expand All @@ -20,7 +20,7 @@ public final class NumberType extends EnumDynamic<NumberType> {
/** Numbers that are free of charge for the calling party but billed for all arriving calls. */
public static final NumberType TOLL_FREE = new NumberType("TOLL_FREE");

private static final EnumSupportDynamic<NumberType> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, NumberType> ENUM_SUPPORT =
new EnumSupportDynamic<>(
NumberType.class, NumberType::new, Arrays.asList(MOBILE, LOCAL, TOLL_FREE));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
*
* @since 1.0
*/
public final class OrderBy extends EnumDynamic<OrderBy> {
public final class OrderBy extends EnumDynamic<String, OrderBy> {
/** Ordering by phoneNumber */
public static final OrderBy PHONE_NUMBER = new OrderBy("phoneNumber");
/** Ordering by displayName */
public static final OrderBy DISPLAY_NAME = new OrderBy("displayName");

private static final EnumSupportDynamic<OrderBy> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, OrderBy> ENUM_SUPPORT =
new EnumSupportDynamic<>(
OrderBy.class, OrderBy::new, Arrays.asList(PHONE_NUMBER, DISPLAY_NAME));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* href="https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/">https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/</a>
* @since 1.0
*/
public final class ProvisioningStatus extends EnumDynamic<ProvisioningStatus> {
public final class ProvisioningStatus extends EnumDynamic<String, ProvisioningStatus> {

public static final ProvisioningStatus PROVISIONING_STATUS_UNSPECIFIED =
new ProvisioningStatus("PROVISIONING_STATUS_UNSPECIFIED");
Expand All @@ -22,7 +22,7 @@ public final class ProvisioningStatus extends EnumDynamic<ProvisioningStatus> {
public static final ProvisioningStatus UNKNOWN_DEFAULT_OPEN_API =
new ProvisioningStatus("UNKNOWN_DEFAULT_OPEN_API");

private static final EnumSupportDynamic<ProvisioningStatus> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, ProvisioningStatus> ENUM_SUPPORT =
new EnumSupportDynamic<>(
ProvisioningStatus.class,
ProvisioningStatus::new,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @since 1.0
*/
public final class SearchPattern extends EnumDynamic<SearchPattern> {
public final class SearchPattern extends EnumDynamic<String, SearchPattern> {
/**
* Numbers that begin with the @see NumberPattern.getPattern entered.
*
Expand All @@ -26,7 +26,7 @@ public final class SearchPattern extends EnumDynamic<SearchPattern> {
/** The number ends with the number pattern entered. */
public static final SearchPattern END = new SearchPattern("END");

private static final EnumSupportDynamic<SearchPattern> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, SearchPattern> ENUM_SUPPORT =
new EnumSupportDynamic<>(
SearchPattern.class, SearchPattern::new, Arrays.asList(START, CONTAINS, END));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* href="https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/">https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/</a>
* @since 1.0
*/
public final class SmsErrorCode extends EnumDynamic<SmsErrorCode> {
public final class SmsErrorCode extends EnumDynamic<String, SmsErrorCode> {
public static final SmsErrorCode ERROR_CODE_UNSPECIFIED =
new SmsErrorCode("ERROR_CODE_UNSPECIFIED");
public static final SmsErrorCode INTERNAL_ERROR = new SmsErrorCode("INTERNAL_ERROR");
Expand Down Expand Up @@ -42,7 +42,7 @@ public final class SmsErrorCode extends EnumDynamic<SmsErrorCode> {
public static final SmsErrorCode UNKNOWN_DEFAULT_OPEN_API =
new SmsErrorCode("UNKNOWN_DEFAULT_OPEN_API");

private static final EnumSupportDynamic<SmsErrorCode> ENUM_SUPPORT =
private static final EnumSupportDynamic<String, SmsErrorCode> ENUM_SUPPORT =
new EnumSupportDynamic<>(
SmsErrorCode.class,
SmsErrorCode::new,
Expand Down
132 changes: 131 additions & 1 deletion client/src/main/com/sinch/sdk/domains/sms/BatchesService.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
package com.sinch.sdk.domains.sms;

import com.sinch.sdk.core.exceptions.ApiException;
import com.sinch.sdk.domains.sms.models.BaseBatch;
import com.sinch.sdk.domains.sms.models.Batch;
import com.sinch.sdk.domains.sms.models.DryRun;
import com.sinch.sdk.domains.sms.models.requests.BatchesListRequestParameters;
import com.sinch.sdk.domains.sms.models.requests.UpdateBaseBatchRequest;
import com.sinch.sdk.domains.sms.models.responses.BatchesListResponse;
import java.util.Collection;

/**
* Batches Service
Expand All @@ -13,11 +19,135 @@
public interface BatchesService {

/**
* Get a batch message
* Get a batch message <br>
* This operation returns a specific batch that matches the provided batch ID.
*
* @param batchId The batch ID you received from sending a message
* @param <T> A type of Batch
* @return Batch information
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/GetBatchMessage">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/GetBatchMessage</a>
* @since 1.0
*/
<T extends Batch<?>> T get(String batchId) throws ApiException;

/**
* Send a message or a batch of messages <br>
* Depending on the length of the body, one message might be split into multiple parts and charged
* accordingly. <br>
* 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. <br>
* Be sure to use the correct region in the server URL.
*
* @param batch The batch to be created
* @param <T> A type of Batch
* @return Batch information
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/SendSMS">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/SendSMS</a>
* @since 1.0
*/
<T extends Batch<?>> T send(BaseBatch<?> batch) throws ApiException;

/**
* Dry run <br>
* 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
* @param numberOfRecipient Max number of recipients to include per recipient details for in the
* response
* @param batch The batch to be send
* @return Details about dryRun execution
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/Dry_Run">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/Dry_Run</a>
* @since 1.0
*/
DryRun dryRun(boolean perRecipient, int numberOfRecipient, BaseBatch<?> batch)
throws ApiException;

/**
* List Batches <br>
* 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
* @since 1.0
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ListBatches">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ListBatches</a>
*/
BatchesListResponse list(BatchesListRequestParameters parameters) throws ApiException;

/**
* Update a Batch message <br>
* 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
* @param <T> A type of Batch
* @return Batch information
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/UpdateBatchMessage">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/UpdateBatchMessage</a>
* @since 1.0
*/
<T extends Batch<?>> T update(String batchId, UpdateBaseBatchRequest<?> batch)
throws ApiException;

/**
* Replace a batch <br>
* 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
* @param <T> A type of Batch
* @return Batch information
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ReplaceBatch">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ReplaceBatch</a>
* @since 1.0
*/
<T extends Batch<?>> T replace(String batchId, BaseBatch<?> batch) throws ApiException;

/**
* Cancel a batch message <br>
* 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. <br>
* Canceling a batch scheduled in the future will result in an empty delivery report while
* canceling an already sent batch would result in no change to the completed delivery report.
*
* @param batchId The batch ID you received from sending a message
* @param <T> A type of Batch
* @return Batch information
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/CancelBatchMessage">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/CancelBatchMessage</a>
* @since 1.0
*/
<T extends Batch<?>> T cancel(String batchId) throws ApiException;

/**
* Send delivery feedback for a message
*
* <p>Send feedback if your system can confirm successful message delivery.
*
* <p>Feedback can only be provided if feedback_enabled was set when batch was submitted.
*
* <p><em>Batches</em>: It is possible to submit feedback multiple times for the same batch for
* different recipients. Feedback without specified recipients is treated as successful message
* delivery to all recipients referenced in the batch. Note that the recipients key is still
* required even if the value is empty.
*
* <p><em>Groups</em>: If the batch message was creating using a group ID, at least one recipient
* is required. Excluding recipients (an empty recipient list) does not work and will result in a
* failed request.
*
* @param batchId The batch ID you received from sending a message
* @param recipients A list of phone numbers (MSISDNs) that have successfully received the
* message. The key is required, however, the value can be an empty array ([]) for a batch. If
* the feedback was enabled for a group, at least one phone number is required.
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback</a>
* @since 1.0
*/
void sendDeliveryFeedback(String batchId, Collection<String> recipients) throws ApiException;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.sinch.sdk.domains.sms;

import com.sinch.sdk.core.exceptions.ApiException;
import com.sinch.sdk.domains.sms.models.DeliveryReportBatch;
import com.sinch.sdk.domains.sms.models.DeliveryReportRecipient;
import com.sinch.sdk.domains.sms.models.requests.DeliveryReportBatchGetRequestParameters;
import com.sinch.sdk.domains.sms.models.requests.DeliveryReportListRequestParameters;
import com.sinch.sdk.domains.sms.models.responses.DeliveryReportsListResponse;

/**
* Delivery reports Service
*
* <p>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 <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByBatchId">Retrieve
* a delivery report</a> or sent as a callback.
*
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports</a>
* @since 1.0
*/
public interface DeliveryReportsService {

/**
* Retrieve a batch delivery report <br>
* 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 <a
* href="https://community.sinch.com/t5/Glossary/E-164/ta-p/7537">E.164</a> format for each status
* code.
*
* @param batchId The batch ID you received from sending a message param type param status param
* code
* @param parameters Filtering parameters
* @return Delivery report related to batchId according to filters
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByBatchId">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByBatchId</a>
* @since 1.0
*/
DeliveryReportBatch get(String batchId, DeliveryReportBatchGetRequestParameters parameters)
throws ApiException;

/**
* Retrieve a recipient delivery report <br>
* 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
* @param recipient Phone number for which you to want to search
* @return Delivery report related to batchId according to filters
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByPhoneNumber">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByPhoneNumber</a>
* @since 1.0
*/
DeliveryReportRecipient getForNumber(String batchId, String recipient) throws ApiException;

/**
* Get a list of finished delivery reports.<br>
* This operation supports pagination.
*
* @param parameters Filtering parameters
* @return Delivery report related to batchId according to filters
* @see <a
* href="https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports">https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports</a>
* @since 1.0
*/
DeliveryReportsListResponse list(DeliveryReportListRequestParameters parameters)
throws ApiException;
}
Loading

0 comments on commit 5313997

Please sign in to comment.