diff --git a/client/src/main/com/sinch/sdk/domains/sms/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java index 1d0da811f..ca09e175c 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java @@ -9,6 +9,16 @@ */ public interface SMSService { + /** + * SMS Service V1 + * + * @return V1 service instance for project + * @see Documentation + * @since + */ + com.sinch.sdk.domains.sms.api.v1.SMSService v1(); + /** * Batches Service instance * diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java index 11f8f8926..07ed46fd1 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java @@ -29,6 +29,7 @@ public class SMSService implements com.sinch.sdk.domains.sms.SMSService { private final String uriUUID; private final SmsContext context; private final HttpClient httpClient; + private com.sinch.sdk.domains.sms.api.v1.SMSService v1; private BatchesService batches; private WebHooksService webHooks; private DeliveryReportsService deliveryReports; @@ -60,6 +61,10 @@ public SMSService( this.authManagers = Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, oAuthManager)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + this.v1 = + new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService( + credentials, context, oAuthServer, httpClient); } public SMSService( @@ -83,6 +88,14 @@ public SMSService( this.authManagers = Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, authManager)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + this.v1 = + new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService(credentials, context, httpClient); + } + + @Override + public com.sinch.sdk.domains.sms.api.v1.SMSService v1() { + return this.v1; } @Override diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/BatchesService.java new file mode 100644 index 000000000..c83cbcec8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/BatchesService.java @@ -0,0 +1,30 @@ +package com.sinch.sdk.domains.sms.api.v1; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse; + +public interface BatchesService { + + BatchResponse send(BatchRequest batch) throws ApiException; + + ListBatchesResponse list(ListBatchesRequest parameters) throws ApiException; + + DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchRequest batch); + + BatchResponse get(String batchId) throws ApiException; + + BatchResponse replace(String batchId, BatchRequest batch) throws ApiException; + + BatchResponse cancel(String batchId) throws ApiException; + + void sendDeliveryFeedback(String batchId, SendDeliveryFeedbackRequest recipients) + throws ApiException; + + BatchResponse update(String batchId, UpdateBatchRequest request) throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java new file mode 100644 index 000000000..b9bfd936a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java @@ -0,0 +1,6 @@ +package com.sinch.sdk.domains.sms.api.v1; + +public interface SMSService { + + BatchesService batches(); +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesService.java new file mode 100644 index 000000000..b2d4d166b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesService.java @@ -0,0 +1,89 @@ +package com.sinch.sdk.domains.sms.api.v1.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.domains.sms.api.v1.internal.BatchesApi; +import com.sinch.sdk.domains.sms.models.v1.batches.internal.SMSCursorPageNavigator; +import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList; +import com.sinch.sdk.models.SmsContext; +import java.time.Instant; +import java.util.Map; + +public class BatchesService implements com.sinch.sdk.domains.sms.api.v1.BatchesService { + + private final BatchesApi api; + + public BatchesService( + String uriUUID, + SmsContext context, + HttpClient httpClient, + Map authManagers) { + this.api = + new BatchesApi(httpClient, context.getSmsServer(), authManagers, new HttpMapper(), uriUUID); + } + + protected BatchesApi getApi() { + return this.api; + } + + public BatchResponse send(BatchRequest batch) throws ApiException { + return getApi().send(batch); + } + + public ListBatchesResponse list(ListBatchesRequest parameters) throws ApiException { + + ListBatchesRequest guardParameters = + null != parameters ? parameters : ListBatchesRequest.builder().build(); + + ApiBatchList response = + getApi() + .list( + guardParameters.getPage().orElse(null), + guardParameters.getPageSize().orElse(null), + guardParameters.getFrom().orElse(null), + guardParameters.getStartDate().map(Instant::toString).orElse(null), + guardParameters.getEndDate().map(Instant::toString).orElse(null), + guardParameters.getClientReference().orElse(null)); + + SMSCursorPageNavigator navigator = + new SMSCursorPageNavigator(response.getPage(), response.getPageSize()); + + return new ListBatchesResponse( + this, new Page<>(guardParameters, response.getBatches(), navigator)); + } + + public DryRunResponse dryRun(boolean perRecipient, int numberOfRecipient, BatchRequest batch) { + return getApi().dryRun(perRecipient, numberOfRecipient, batch); + } + + public BatchResponse get(String batchId) throws ApiException { + return getApi().get(batchId); + } + + public BatchResponse replace(String batchId, BatchRequest batch) throws ApiException { + return getApi().replace(batchId, batch); + } + + public BatchResponse cancel(String batchId) throws ApiException { + return getApi().cancel(batchId); + } + + public void sendDeliveryFeedback(String batchId, SendDeliveryFeedbackRequest request) + throws ApiException { + getApi().sendDeliveryFeedback(batchId, request); + } + + public BatchResponse update(String batchId, UpdateBatchRequest request) throws ApiException { + return getApi().update(batchId, request); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java new file mode 100644 index 000000000..84bde85fa --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java @@ -0,0 +1,88 @@ +package com.sinch.sdk.domains.sms.api.v1.adapters; + +import com.sinch.sdk.auth.adapters.BearerAuthManager; +import com.sinch.sdk.auth.adapters.OAuthManager; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.utils.StringUtil; +import com.sinch.sdk.models.SmsContext; +import com.sinch.sdk.models.SmsServicePlanCredentials; +import com.sinch.sdk.models.UnifiedCredentials; +import java.util.AbstractMap; +import java.util.Map; +import java.util.Objects; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class SMSService implements com.sinch.sdk.domains.sms.api.v1.SMSService { + + private static final Logger LOGGER = Logger.getLogger(SMSService.class.getName()); + + private static final String SECURITY_SCHEME_KEYWORD_SMS = "BearerAuth"; + private final String uriUUID; + private final SmsContext context; + private final HttpClient httpClient; + private BatchesService batches; + private final Map authManagers; + + public SMSService( + UnifiedCredentials credentials, + SmsContext context, + ServerConfiguration oAuthServer, + HttpClient httpClient) { + + Objects.requireNonNull(credentials, "Credentials must be defined"); + Objects.requireNonNull(context, "Context must be defined"); + StringUtil.requireNonEmpty(credentials.getKeyId(), "'keyId' must be defined"); + StringUtil.requireNonEmpty(credentials.getKeySecret(), "'keySecret' must be defined"); + StringUtil.requireNonEmpty(credentials.getProjectId(), "'projectId' must be defined"); + StringUtil.requireNonEmpty(context.getSmsUrl(), "'smsUrl' must be defined"); + + LOGGER.fine("Activate SMS API with server='" + context.getSmsServer().getUrl() + "'"); + + OAuthManager oAuthManager = + new OAuthManager(credentials, oAuthServer, new HttpMapper(), httpClient); + + this.uriUUID = credentials.getProjectId(); + this.context = context; + this.httpClient = httpClient; + this.authManagers = + Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, oAuthManager)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + public SMSService( + SmsServicePlanCredentials credentials, SmsContext context, HttpClient httpClient) { + + Objects.requireNonNull(credentials, "Credentials must be defined"); + Objects.requireNonNull(context, "Context must be defined"); + StringUtil.requireNonEmpty(credentials.getServicePlanId(), "'servicePlanId' must be defined"); + StringUtil.requireNonEmpty(credentials.getApiToken(), "'apiToken' must be defined"); + StringUtil.requireNonEmpty(context.getSmsUrl(), "'smsUrl' must be defined"); + + LOGGER.fine( + "Activate SMS API with service plan ID support and server='" + + context.getSmsServer().getUrl() + + "'"); + + BearerAuthManager authManager = new BearerAuthManager(credentials.getApiToken()); + + this.uriUUID = credentials.getServicePlanId(); + this.context = context; + this.httpClient = httpClient; + this.authManagers = + Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, authManager)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + @Override + public BatchesService batches() { + if (null == this.batches) { + this.batches = new BatchesService(uriUUID, context, httpClient, authManagers); + } + return this.batches; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java index b0f17ee44..a3b2ce2f6 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java @@ -112,6 +112,7 @@ private Builder() { /** * @param flashMessage If sent as a flash message, displays true. * @return current builder + * @deprecated */ public Builder setFlashMessage(boolean flashMessage) { this.flashMessage = OptionalValue.of(flashMessage); @@ -121,6 +122,7 @@ public Builder setFlashMessage(boolean flashMessage) { /** * @param truncateConcat If set to true, the message was shortened when exceeding one part. * @return current builder + * @deprecated */ public Builder setTruncateConcat(boolean truncateConcat) { this.truncateConcat = OptionalValue.of(truncateConcat); @@ -130,6 +132,7 @@ public Builder setTruncateConcat(boolean truncateConcat) { /** * @param maxNumberOfMessageParts Displays the number of message parts set in the request. * @return current builder + * @deprecated */ public Builder setMaxNumberOfMessageParts(int maxNumberOfMessageParts) { this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/internal/SMSCursorPageNavigator.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/internal/SMSCursorPageNavigator.java new file mode 100644 index 000000000..7e43e2c67 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/internal/SMSCursorPageNavigator.java @@ -0,0 +1,35 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.internal; + +import com.sinch.sdk.core.models.pagination.PageNavigator; + +public class SMSCursorPageNavigator extends PageNavigator { + + private final Integer currentPage; + private final Integer pageSize; + + public SMSCursorPageNavigator(Integer currentPage, Integer pageSize) { + super(null); + this.currentPage = currentPage; + this.pageSize = pageSize; + } + + private Integer computeNextPageCursor() { + return null == pageSize || pageSize == 0 ? null : currentPage + 1; + } + + @Override + public Integer getToken() { + return computeNextPageCursor(); + } + + @Override + public String toString() { + return "SMSCursorPageNavigator{" + + "currentPage=" + + currentPage + + ", pageSize=" + + pageSize + + "} " + + super.toString(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BatchRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BatchRequest.java new file mode 100644 index 000000000..15c37afe0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BatchRequest.java @@ -0,0 +1,3 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +public interface BatchRequest {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/ListBatchesRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/ListBatchesRequest.java new file mode 100644 index 000000000..b6415dd14 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/ListBatchesRequest.java @@ -0,0 +1,141 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.sinch.sdk.core.models.OptionalValue; +import java.time.Instant; + +public class ListBatchesRequest { + + private final OptionalValue from; + private final OptionalValue startDate; + private final OptionalValue endDate; + private final OptionalValue clientReference; + private final OptionalValue page; + private final OptionalValue pageSize; + + private ListBatchesRequest( + OptionalValue from, + OptionalValue startDate, + OptionalValue endDate, + OptionalValue clientReference, + OptionalValue page, + OptionalValue pageSize) { + this.from = from; + this.startDate = startDate; + this.endDate = endDate; + this.clientReference = clientReference; + this.page = page; + this.pageSize = pageSize; + } + + public OptionalValue getFrom() { + return from; + } + + public OptionalValue getStartDate() { + return startDate; + } + + public OptionalValue getEndDate() { + return endDate; + } + + public OptionalValue getClientReference() { + return clientReference; + } + + public OptionalValue getPage() { + return page; + } + + public OptionalValue getPageSize() { + return pageSize; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(ListBatchesRequest parameters) { + return new Builder(parameters); + } + + public static class Builder { + + OptionalValue from = OptionalValue.empty(); + OptionalValue startDate = OptionalValue.empty(); + OptionalValue endDate = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue page = OptionalValue.empty(); + OptionalValue pageSize = OptionalValue.empty(); + + private Builder() {} + + private Builder(ListBatchesRequest parameters) { + this.from = parameters.from; + this.startDate = parameters.startDate; + this.endDate = parameters.endDate; + this.clientReference = parameters.clientReference; + this.page = parameters.page; + this.pageSize = parameters.pageSize; + } + + /** + * @param from Only list messages sent from this sender number. Multiple originating numbers can + * be comma separated. Must be phone numbers or short code. + * @return current builder + */ + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + /** + * @param startDate Only list messages received at or after this date/time. + * @return current builder + */ + public Builder setStartDate(Instant startDate) { + this.startDate = OptionalValue.of(startDate); + return this; + } + + /** + * @param endDate Only list messages received before this date/time + * @return current builder + */ + public Builder setEndDate(Instant endDate) { + this.endDate = OptionalValue.of(endDate); + return this; + } + + /** + * @param clientReference Client reference to include + * @return current builder + */ + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + /** + * @param page The page number starting from 0 + * @return current builder + */ + public Builder setPage(Integer page) { + this.page = OptionalValue.of(page); + return this; + } + + /** + * @param pageSize Determines the size of a page + * @return current builder + */ + public Builder setPageSize(Integer pageSize) { + this.pageSize = OptionalValue.of(pageSize); + return this; + } + + public ListBatchesRequest build() { + return new ListBatchesRequest(from, startDate, endDate, clientReference, page, pageSize); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBatchRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBatchRequest.java new file mode 100644 index 000000000..80cd64316 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBatchRequest.java @@ -0,0 +1,3 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +public interface UpdateBatchRequest {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BatchResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BatchResponse.java new file mode 100644 index 000000000..f44bed4bd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BatchResponse.java @@ -0,0 +1,7 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.BatchResponseInternalImpl; + +@JsonDeserialize(using = BatchResponseInternalImpl.Deserializer.class) +public interface BatchResponse {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/ListBatchesResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/ListBatchesResponse.java new file mode 100644 index 000000000..20a0ce6bd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/ListBatchesResponse.java @@ -0,0 +1,51 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.sinch.sdk.core.models.pagination.ListResponse; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import java.util.Collection; +import java.util.NoSuchElementException; + +public class ListBatchesResponse extends ListResponse { + + private final Page page; + private final BatchesService service; + private ListBatchesResponse nextPage; + + public ListBatchesResponse( + BatchesService service, Page page) { + this.service = service; + this.page = page; + } + + public boolean hasNextPage() { + + if (null == nextPage) { + ListBatchesRequest.Builder newParameters = ListBatchesRequest.builder(page.getParameters()); + newParameters.setPage(page.getNextPageToken()); + nextPage = service.list(newParameters.build()); + } + return (null != nextPage.getContent() && !nextPage.getContent().isEmpty()); + } + + public ListBatchesResponse nextPage() { + + if (!hasNextPage()) { + throw new NoSuchElementException("Reached the last page of the API response"); + } + + ListBatchesResponse response = nextPage; + nextPage = null; + return response; + } + + public Collection getContent() { + return page.getEntities(); + } + + @Override + public String toString() { + return "ListBatchesResponse{" + "page=" + page + '}'; + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/BatchesServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/BatchesServiceTest.java index c1f461e02..e2b2b1ad2 100644 --- a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/BatchesServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/BatchesServiceTest.java @@ -246,25 +246,25 @@ public class BatchesServiceTest extends BaseTest { .setUdh(udh) .build(); - @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") public SendSMS201ResponseDto binaryResponseDto; - @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") SendSMS201ResponseDto mediaResponseDto; - @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") SendSMS201ResponseDto textResponseDto; - @GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") DryRun200ResponseDto dryRunResponseDto; - @GivenJsonResource("/domains/sms/v1/ListBatchesResponseDtoPage0.json") + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage0.json") ApiBatchListDto listBatchesResponseDtoPage0; - @GivenJsonResource("/domains/sms/v1/ListBatchesResponseDtoPage1.json") + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage1.json") ApiBatchListDto listBatchesResponseDtoPage1; - @GivenJsonResource("/domains/sms/v1/ListBatchesResponseDtoPage2.json") + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage2.json") ApiBatchListDto listBatchesResponseDtoPage2; @Mock SmsContext context; diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverterTest.java index b5428ace0..22ea01b7e 100644 --- a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverterTest.java @@ -27,22 +27,22 @@ @TestWithResources class BatchDtoConverterTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") public SendSMS201ResponseDto binaryResponseDto; - @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") public SendSMS201ResponseDto textResponseDto; - @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") public SendSMS201ResponseDto mediaResponseDto; - @GivenJsonResource("/domains/sms/v1/SendSMSBinaryRequestDto.json") + @GivenJsonResource("/domains/sms/v1/BinaryRequestDto.json") public SendSMSRequestDto sendBinaryRequestDto; - @GivenJsonResource("/domains/sms/v1/SendSMSTextRequestDto.json") + @GivenJsonResource("/domains/sms/v1/batches/request/TextRequestDto.json") public SendSMSRequestDto sendTextRequestDto; - @GivenJsonResource("/domains/sms/v1/SendSMSMediaRequestDto.json") + @GivenJsonResource("/domains/sms/v1/batches/request/MediaRequestDto.json") public SendSMSRequestDto sendMediaRequestDto; @GivenJsonResource("/domains/sms/v1/UpdateSMSTextRequestDto.json") diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverterTest.java index 4f53ccaa1..7b262f973 100644 --- a/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverterTest.java @@ -13,7 +13,7 @@ @TestWithResources public class DryRunDtoConverterTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") DryRun200ResponseDto loadedDto; public static DryRun dryRunClient = diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesServiceTest.java new file mode 100644 index 000000000..67189c06c --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/BatchesServiceTest.java @@ -0,0 +1,509 @@ +package com.sinch.sdk.domains.sms.api.v1.adapters; + +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.domains.sms.api.v1.internal.BatchesApi; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBodyDtoTest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.BinaryRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.MediaRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBinaryRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateMediaRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateTextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BinaryResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.MediaResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.TextResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList; +import com.sinch.sdk.models.SmsContext; +import java.time.Instant; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; + +@TestWithResources +public class BatchesServiceTest extends BaseTest { + + static final String id = "01FC66621XXXXX119Z8PMV1QPQ"; + static final List to = Arrays.asList("+15551231234", "+15551256344"); + static final String from = "+15551231234"; + static final boolean canceled = false; + static final Instant createdAt = Instant.parse("2019-08-24T14:15:22Z"); + static final Instant modifiedAt = Instant.parse("2019-08-24T14:17:22Z"); + static final DeliveryReportType deliveryReport = DeliveryReportType.NONE; + static final Instant sendAt = Instant.parse("2019-08-24T14:19:22Z"); + static final Instant expireAt = Instant.parse("2019-08-24T14:21:22Z"); + static final String callbackUrl = "callback url"; + static final String clientReference = "myReference"; + static final boolean flashMessage = true; + static final boolean feedbackEnabled = false; + static final boolean truncateConcat = true; + static final int maxNumberOfMessageParts = 1; + static final int fromTon = 6; + static final int fromNpi = 18; + static final String udh = "foo udh"; + static final String body = "Hi ${name} ({an identifier}) ! How are you?"; + public static final BinaryResponse batchBinary = + BinaryResponse.builder() + .setId(id) + .setTo(to) + .setFrom(from) + .setCanceled(canceled) + .setBody(body) + .setCreatedAt(createdAt) + .setModifiedAt(modifiedAt) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setClientReference(clientReference) + .setFeedbackEnabled(feedbackEnabled) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setUdh(udh) + .build(); + + static final Map anIdentifierParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "an identifier value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "an identifier value for 15551256344")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + static final Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "name value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "name value for 15551256344"), + new AbstractMap.SimpleEntry<>("default", "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + static final Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + public static final MediaResponse batchMedia = + MediaResponse.builder() + .setId(id) + .setTo(to) + .setFrom(from) + .setCanceled(canceled) + .setBody( + MediaBody.builder() + .setSubject("subject field") + .setUrl( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .setMessage("Hi ${name} ({an identifier}) ! How are you?") + .build()) + .setCreatedAt(Instant.parse("2019-08-24T14:14:22Z")) + .setModifiedAt(Instant.parse("2019-08-24T14:15:22Z")) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl(callbackUrl) + .setClientReference("client reference") + .setFeedbackEnabled(feedbackEnabled) + .setStrictValidation(true) + .setParameters(parameters) + .build(); + public static final TextResponse batchText = + TextResponse.builder() + .setId(id) + .setTo(to) + .setFrom(from) + .setCanceled(canceled) + .setBody(body) + .setCreatedAt(createdAt) + .setModifiedAt(modifiedAt) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setClientReference(clientReference) + .setFlashMessage(flashMessage) + .setFeedbackEnabled(feedbackEnabled) + .setTruncateConcat(truncateConcat) + .setMaxNumberOfMessageParts(maxNumberOfMessageParts) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setParameters(parameters) + .build(); + + public static final BinaryRequest sendSmsBatchBinaryRequest = + BinaryRequest.builder() + .setTo(to) + .setFrom(from) + .setBody(body) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setClientReference(clientReference) + .setFeedbackEnabled(feedbackEnabled) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setUdh(udh) + .build(); + + public static final MediaRequest sendSmsBatchMediaRequest = + MediaRequest.builder() + .setTo(to) + .setFrom(from) + .setBody( + MediaBody.builder() + .setUrl( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .setMessage("Hi ${name} ({an identifier}) ! How are you?") + .build()) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl(callbackUrl) + .setClientReference("client reference") + .setFeedbackEnabled(feedbackEnabled) + .setStrictValidation(true) + .setParameters(parameters) + .build(); + public static final TextRequest sendSmsBatchTextRequest = + TextRequest.builder() + .setTo(to) + .setFrom(from) + .setBody(body) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setClientReference(clientReference) + .setFlashMessage(flashMessage) + .setFeedbackEnabled(feedbackEnabled) + .setTruncateConcat(truncateConcat) + .setMaxNumberOfMessageParts(maxNumberOfMessageParts) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setParameters(parameters) + .build(); + + public static final UpdateTextRequest updateSmsBatchTextRequest = + UpdateTextRequest.builder() + .setToAdd(to) + .setFrom(from) + .setBody(body) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setParameters(parameters) + .build(); + + public static final UpdateMediaRequest updateSmsBatchMediaRequest = + UpdateMediaRequest.builder() + .setToRemove(to) + .setFrom(from) + .setBody(MediaBodyDtoTest.mediaBodyDto) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl(callbackUrl) + .setStrictValidation(true) + .setParameters(parameters) + .build(); + + public static final UpdateBinaryRequest updateSmsBatchBinaryRequest = + UpdateBinaryRequest.builder() + .setToAdd(Arrays.asList("+15551231234", "+15987365412")) + .setToRemove(Arrays.asList("+0123456789", "+9876543210")) + .setFrom(from) + .setBody(body) + .setDeliveryReport(DeliveryReportType.FULL) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setUdh(udh) + .build(); + + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") + public BatchResponse binaryResponseDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") + BatchResponse mediaResponseDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") + BatchResponse textResponseDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") + DryRunResponse dryRunResponseDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage0.json") + ApiBatchList listBatchesResponseDtoPage0; + + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage1.json") + ApiBatchList listBatchesResponseDtoPage1; + + @GivenJsonResource("/domains/sms/v1/batches/response/ListBatchesResponseDtoPage2.json") + ApiBatchList listBatchesResponseDtoPage2; + + @Mock SmsContext context; + @Mock HttpClient httpClient; + @Mock Map authManagers; + @Mock BatchesApi api; + BatchesService service; + String uriPartID = "foovalue"; + + @Captor ArgumentCaptor recipientsCaptor; + + @BeforeEach + public void initMocks() { + service = spy(new BatchesService(uriPartID, context, httpClient, authManagers)); + doReturn(api).when(service).getApi(); + } + + @Test + void getBinary() throws ApiException { + + when(api.get(eq("foo binary batch id"))).thenReturn(binaryResponseDto); + + BatchResponse response = service.get("foo binary batch id"); + + TestHelpers.recursiveEquals(response, batchBinary); + } + + @Test + void getMedia() throws ApiException { + + when(api.get(eq("foo media batch id"))).thenReturn(mediaResponseDto); + + BatchResponse response = service.get("foo media batch id"); + + TestHelpers.recursiveEquals(response, batchMedia); + } + + @Test + void getText() throws ApiException { + + when(api.get(eq("foo text batch id"))).thenReturn(textResponseDto); + + BatchResponse response = service.get("foo text batch id"); + + TestHelpers.recursiveEquals(response, batchText); + } + + @Test + void sendBinary() throws ApiException { + + when(api.send(sendSmsBatchBinaryRequest)).thenReturn(binaryResponseDto); + + BatchResponse response = service.send(sendSmsBatchBinaryRequest); + + TestHelpers.recursiveEquals(response, batchBinary); + } + + @Test + void sendMedia() throws ApiException { + + when(api.send(sendSmsBatchMediaRequest)).thenReturn(mediaResponseDto); + + BatchResponse response = service.send(sendSmsBatchMediaRequest); + + TestHelpers.recursiveEquals(response, batchMedia); + } + + @Test + void sendText() throws ApiException { + + when(api.send(sendSmsBatchTextRequest)).thenReturn(textResponseDto); + + BatchResponse response = service.send(sendSmsBatchTextRequest); + + TestHelpers.recursiveEquals(response, batchText); + } + + @Test + void dryRun() throws ApiException { + + when(api.dryRun(eq(true), eq(456), eq(sendSmsBatchTextRequest))).thenReturn(dryRunResponseDto); + + DryRunResponse response = service.dryRun(true, 456, sendSmsBatchTextRequest); + + TestHelpers.recursiveEquals(response, dryRunResponseDto); + } + + @Test + void list() throws ApiException { + + when(api.list(eq(null), eq(null), eq(null), eq(null), eq(null), eq(null))) + .thenReturn(listBatchesResponseDtoPage0); + when(api.list(eq(1), eq(null), eq(null), eq(null), eq(null), eq(null))) + .thenReturn(listBatchesResponseDtoPage1); + when(api.list(eq(2), eq(null), eq(null), eq(null), eq(null), eq(null))) + .thenReturn(listBatchesResponseDtoPage2); + ListBatchesResponse response = service.list(null); + + Iterator iterator = response.iterator(); + BatchResponse batch = iterator.next(); + Assertions.assertThat(iterator.hasNext()).isEqualTo(true); + TestHelpers.recursiveEquals( + batch, + BinaryResponse.builder() + .setId("01HEAWCHESCXG8SDG5R10VF8E1") + .setTo(Collections.singletonList("339876543213")) + .setFrom("33123456789") + .setCanceled(false) + .setBody("the body") + .setCreatedAt(Instant.parse("2023-11-03T15:21:21.113Z")) + .setModifiedAt(Instant.parse("2023-11-03T15:21:21.568Z")) + .setDeliveryReport(DeliveryReportType.NONE) + .setExpireAt(Instant.parse("2023-11-06T15:21:21.973Z")) + .setClientReference("a client reference") + .setFeedbackEnabled(false) + .build()); + + batch = iterator.next(); + Assertions.assertThat(iterator.hasNext()).isEqualTo(true); + TestHelpers.recursiveEquals( + batch, + TextResponse.builder() + .setId("01HEAC0AG69SVYYQ675VPYT28Q") + .setTo(Collections.singletonList("3300000000")) + .setCanceled(false) + .setBody("the body") + .setCreatedAt(Instant.parse("2023-11-03T10:35:03.558Z")) + .setModifiedAt(Instant.parse("2023-11-03T10:35:03.666Z")) + .setDeliveryReport(DeliveryReportType.NONE) + .setExpireAt(Instant.parse("2023-11-03T10:35:03.558Z")) + .setFeedbackEnabled(true) + .setFlashMessage(false) + .build()); + + batch = iterator.next(); + Assertions.assertThat(iterator.hasNext()).isEqualTo(false); + TestHelpers.recursiveEquals( + batch, + MediaResponse.builder() + .setId("01HEABZ9S80D4ENE3X6CPMATZR") + .setTo(Collections.singletonList("331111111")) + .setCanceled(false) + .setBody(MediaBody.builder().setUrl("an URL").build()) + .setCreatedAt(Instant.parse("2023-11-03T10:34:30.056Z")) + .setModifiedAt(Instant.parse("2023-11-03T10:34:30.156Z")) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setExpireAt(Instant.parse("2023-11-06T10:34:30.256Z")) + .setFeedbackEnabled(false) + .build()); + } + + @Test + void updateText() throws ApiException { + + when(api.update(eq("foo text batch id"), eq(updateSmsBatchTextRequest))) + .thenReturn(textResponseDto); + + BatchResponse response = service.update("foo text batch id", updateSmsBatchTextRequest); + + TestHelpers.recursiveEquals(response, batchText); + } + + @Test + void updateMedia() throws ApiException { + + when(api.update(eq("foo text batch id"), eq(updateSmsBatchMediaRequest))) + .thenReturn(mediaResponseDto); + + BatchResponse response = service.update("foo text batch id", updateSmsBatchMediaRequest); + + TestHelpers.recursiveEquals(response, batchMedia); + } + + @Test + void updateBinary() throws ApiException { + + when(api.update(eq("foo text batch id"), eq(updateSmsBatchBinaryRequest))) + .thenReturn(binaryResponseDto); + + BatchResponse response = service.update("foo text batch id", updateSmsBatchBinaryRequest); + + TestHelpers.recursiveEquals(response, batchBinary); + } + + @Test + void replaceBinary() throws ApiException { + + when(api.replace(eq("foo text batch id"), eq(sendSmsBatchBinaryRequest))) + .thenReturn(binaryResponseDto); + + BatchResponse response = service.replace("foo text batch id", sendSmsBatchBinaryRequest); + + TestHelpers.recursiveEquals(response, batchBinary); + } + + @Test + void replaceMedia() throws ApiException { + + when(api.replace(eq("foo text batch id"), eq(sendSmsBatchMediaRequest))) + .thenReturn(mediaResponseDto); + + BatchResponse response = service.replace("foo text batch id", sendSmsBatchMediaRequest); + + TestHelpers.recursiveEquals(response, batchMedia); + } + + @Test + void replaceText() throws ApiException { + + when(api.replace(eq("foo text batch id"), eq(sendSmsBatchTextRequest))) + .thenReturn(textResponseDto); + + BatchResponse response = service.replace("foo text batch id", sendSmsBatchTextRequest); + + TestHelpers.recursiveEquals(response, batchText); + } + + @Test + void cancelBatch() throws ApiException { + + when(api.cancel(eq("foo text batch id"))).thenReturn(textResponseDto); + + BatchResponse response = service.cancel("foo text batch id"); + + TestHelpers.recursiveEquals(response, batchText); + } + + @Test + void sendDeliveryFeedback() throws ApiException { + SendDeliveryFeedbackRequest request = + SendDeliveryFeedbackRequest.builder().setRecipients(Arrays.asList("foo", "foo2")).build(); + + service.sendDeliveryFeedback("foo text batch id", request); + + verify(api).sendDeliveryFeedback(eq("foo text batch id"), recipientsCaptor.capture()); + + SendDeliveryFeedbackRequest dto = recipientsCaptor.getValue(); + TestHelpers.recursiveEquals(dto, request); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/SMSServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/SMSServiceTest.java new file mode 100644 index 000000000..c520d8d4b --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/api/v1/adapters/SMSServiceTest.java @@ -0,0 +1,189 @@ +package com.sinch.sdk.domains.sms.api.v1.adapters; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.models.SmsContext; +import com.sinch.sdk.models.SmsServicePlanCredentials; +import com.sinch.sdk.models.UnifiedCredentials; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +class SMSServiceTest { + + @Mock HttpClient httpClient; + + @Test + void projectIdDoNotAcceptNullKey() { + UnifiedCredentials credentials = + UnifiedCredentials.builder().setKeyId(null).setKeySecret("foo").setProjectId("foo").build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> new SMSService(credentials, context, server, httpClient)); + assertTrue(exception.getMessage().contains("keyId")); + } + + @Test + void projectIdDoNotAcceptNullKeySecret() { + UnifiedCredentials credentials = + UnifiedCredentials.builder().setKeyId("foo").setKeySecret(null).setProjectId("foo").build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> new SMSService(credentials, context, server, httpClient)); + assertTrue(exception.getMessage().contains("keySecret")); + } + + @Test + void projectIdDoNotAcceptNullProject() { + UnifiedCredentials credentials = + UnifiedCredentials.builder().setKeyId("foo").setKeySecret("foo").setProjectId(null).build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> new SMSService(credentials, context, server, httpClient)); + assertTrue(exception.getMessage().contains("projectId")); + } + + @Test + void projectIdDoNotAcceptNullCredentials() { + + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + Exception exception = + assertThrows( + NullPointerException.class, () -> new SMSService(null, context, server, httpClient)); + assertTrue(exception.getMessage().contains("Credentials must be defined")); + } + + @Test + void projectIdDoNotAcceptNullContext() { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + Exception exception = + assertThrows( + NullPointerException.class, + () -> new SMSService(credentials, null, server, httpClient)); + assertTrue(exception.getMessage().contains("Context must be defined")); + } + + @Test + void projectIdDoNotAcceptNullSmsUrl() { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + SmsContext context = SmsContext.builder().setSmsUrl(null).build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> new SMSService(credentials, context, server, httpClient)); + assertTrue(exception.getMessage().contains("smsUrl")); + } + + @Test + void projectIdUsagePassed() { + + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo key ") + .setKeySecret("foo secret") + .setProjectId("foo project") + .build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); + + assertDoesNotThrow( + () -> new SMSService(credentials, context, server, httpClient), "Init passed"); + } + + @Test + void servicePlanIdDoNotAcceptNullApiToken() { + SmsServicePlanCredentials credentials = + SmsServicePlanCredentials.builder().setApiToken(null).setServicePlanId("foo plan").build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + Exception exception = + assertThrows( + IllegalArgumentException.class, () -> new SMSService(credentials, context, httpClient)); + assertTrue(exception.getMessage().contains("apiToken")); + } + + @Test + void servicePlanIdDoNotAcceptNullServicePlanId() { + SmsServicePlanCredentials credentials = + SmsServicePlanCredentials.builder().setApiToken("foo token").setServicePlanId(null).build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + Exception exception = + assertThrows( + IllegalArgumentException.class, () -> new SMSService(credentials, context, httpClient)); + assertTrue(exception.getMessage().contains("servicePlanId")); + } + + @Test + void servicePlanIdDoNotAcceptNullCredentials() { + + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + Exception exception = + assertThrows(NullPointerException.class, () -> new SMSService(null, context, httpClient)); + assertTrue(exception.getMessage().contains("Credentials must be defined")); + } + + @Test + void servicePlanIdDoNotAcceptNullContext() { + SmsServicePlanCredentials credentials = + SmsServicePlanCredentials.builder() + .setApiToken("foo token") + .setServicePlanId("foo plan") + .build(); + Exception exception = + assertThrows( + NullPointerException.class, () -> new SMSService(credentials, null, httpClient)); + assertTrue(exception.getMessage().contains("Context must be defined")); + } + + @Test + void servicePlanIdDoNotAcceptNullSmsUrl() { + SmsServicePlanCredentials credentials = + SmsServicePlanCredentials.builder() + .setApiToken("foo token") + .setServicePlanId("foo plan") + .build(); + SmsContext context = SmsContext.builder().setSmsUrl(null).build(); + Exception exception = + assertThrows( + IllegalArgumentException.class, () -> new SMSService(credentials, context, httpClient)); + assertTrue(exception.getMessage().contains("smsUrl")); + } + + @Test + void servicePlanIdUsagePassed() { + + SmsServicePlanCredentials credentials = + SmsServicePlanCredentials.builder() + .setApiToken("foo token") + .setServicePlanId("foo plan") + .build(); + SmsContext context = SmsContext.builder().setSmsUrl("https://sms.foo.url").build(); + + assertDoesNotThrow(() -> new SMSService(credentials, context, httpClient), "Init passed"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/internal/SMSCursorPageNavigatorTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/internal/SMSCursorPageNavigatorTest.java new file mode 100644 index 000000000..aafa8b01e --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/internal/SMSCursorPageNavigatorTest.java @@ -0,0 +1,26 @@ +package com.sinch.sdk.domains.sms.models.v1.internal; + +import com.sinch.sdk.domains.sms.models.v1.batches.internal.SMSCursorPageNavigator; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class SMSCursorPageNavigatorTest { + + @Test + void getTokenNullPageSize() { + SMSCursorPageNavigator cursorNavigator = new SMSCursorPageNavigator(45, null); + Assertions.assertThat(cursorNavigator.getToken()).isEqualTo(null); + } + + @Test + void getTokenZeroPageSize() { + SMSCursorPageNavigator cursorNavigator = new SMSCursorPageNavigator(45, 0); + Assertions.assertThat(cursorNavigator.getToken()).isEqualTo(null); + } + + @Test + void getToken() { + SMSCursorPageNavigator cursorNavigator = new SMSCursorPageNavigator(0, 15); + Assertions.assertThat(cursorNavigator.getToken()).isEqualTo(1); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/request/ListBatchesRequestTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/request/ListBatchesRequestTest.java new file mode 100644 index 000000000..085a39e84 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/v1/request/ListBatchesRequestTest.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.sms.models.v1.request; + +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import java.time.Instant; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ListBatchesRequestTest { + + static final String from = "foo from"; + + static Instant startDate = Instant.now(); + static Instant endDate = Instant.now(); + static String clientReference = "a client reference"; + static Integer page = 1; + static Integer pageSize = 3; + + public static final ListBatchesRequest value = + ListBatchesRequest.builder() + .setFrom(from) + .setStartDate(startDate) + .setEndDate(endDate) + .setClientReference(clientReference) + .setPage(page) + .setPageSize(pageSize) + .build(); + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom().get()).isEqualTo(from); + } + + @Test + void getStartDate() { + Assertions.assertThat(value.getStartDate().get()).isEqualTo(startDate); + } + + @Test + void getEndDate() { + Assertions.assertThat(value.getEndDate().get()).isEqualTo(endDate); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference().get()).isEqualTo(clientReference); + } + + @Test + void getPage() { + Assertions.assertThat(value.getPage().get()).isEqualTo(page); + } + + @Test + void getPageSize() { + Assertions.assertThat(value.getPageSize().get()).isEqualTo(pageSize); + } +} diff --git a/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/BatchesSteps.java b/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/BatchesSteps.java new file mode 100644 index 000000000..7d58a5f84 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/BatchesSteps.java @@ -0,0 +1,404 @@ +package com.sinch.sdk.e2e.domains.sms.v1; + +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateTextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunPerRecipientDetails; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.TextResponse; +import com.sinch.sdk.e2e.Config; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import java.time.Instant; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Collections; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.junit.jupiter.api.Assertions; + +public class BatchesSteps { + + BatchesService service; + + BatchResponse sendTextResponse; + BatchResponse sendTextWithParametersResponse; + DryRunResponse dryRunResponse; + ListBatchesResponse listOnePageResponse; + ListBatchesResponse listAllResponse; + ListBatchesResponse listAllByPageResponse; + BatchResponse getBatchResponse; + BatchResponse updateResponse; + BatchResponse replaceResponse; + BatchResponse cancelResponse; + Boolean sendDeliveryFeedbackPassed; + + @Given("^the SMS service \"Batches\" is available") + public void serviceAvailable() { + + service = Config.getSinchClient().sms().v1().batches(); + } + + @When("^I send a request to send a text message$") + public void send() { + TextRequest request = + TextRequest.builder() + .setBody("SMS body message") + .setTo(Collections.singletonList("+12017777777")) + .setFrom("+12015555555") + .setSendAt(Instant.parse("2024-06-06T09:25:00Z")) + .setDeliveryReport(DeliveryReportType.FULL) + .setFeedbackEnabled(true) + .build(); + + sendTextResponse = service.send(request); + } + + @When("^I send a request to send a text message with multiple parameters$") + public void sendWithParameters() { + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("+12017777777", "John"), + new AbstractMap.SimpleEntry<>("+12018888888", "Paul"), + new AbstractMap.SimpleEntry<>("default", "there")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map codeParameters = + Stream.of(new AbstractMap.SimpleEntry<>("+12017777777", "HALLOWEEN20 \uD83C\uDF83")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("code", codeParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + TextRequest request = + TextRequest.builder() + .setBody("Hello ${name}! Get 20% off with this discount code ${code}") + .setTo(Arrays.asList("+12017777777", "+12018888888")) + .setFrom("+12015555555") + .setParameters(parameters) + .setDeliveryReport(DeliveryReportType.FULL) + .build(); + + sendTextWithParametersResponse = service.send(request); + } + + @When("^I send a request to perform a dry run of a batch$") + public void dryRun() { + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("+12017777777", "John"), + new AbstractMap.SimpleEntry<>("default", "there")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of(new AbstractMap.SimpleEntry<>("name", nameParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + TextRequest request = + TextRequest.builder() + .setBody("Hello ${name}!") + .setTo(Arrays.asList("+12017777777", "+12018888888", "+12019999999")) + .setFrom("+12015555555") + .setParameters(parameters) + .setDeliveryReport(DeliveryReportType.NONE) + .build(); + + dryRunResponse = service.dryRun(true, 3, request); + } + + @When("^I send a request to list the SMS batches$") + public void listOnePage() { + ListBatchesRequest request = ListBatchesRequest.builder().setPageSize(2).build(); + + listOnePageResponse = service.list(request); + } + + @When("^I send a request to list all the SMS batches$") + public void listAll() { + ListBatchesRequest request = ListBatchesRequest.builder().setPageSize(2).build(); + + listAllResponse = service.list(request); + } + + @When("^I iterate manually over the SMS batches pages$") + public void listAllByPage() { + ListBatchesRequest request = ListBatchesRequest.builder().setPageSize(2).build(); + + listAllByPageResponse = service.list(request); + } + + @When("^I send a request to retrieve an SMS batch$") + public void get() { + + getBatchResponse = service.get("foo"); + } + + @When("^I send a request to update an SMS batch$") + public void update() { + + UpdateTextRequest request = + UpdateTextRequest.builder() + .setFrom("+12016666666") + .setToAdd(Collections.singletonList("01W4FFL35P4NC4K35SMSGROUP1")) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .build(); + updateResponse = service.update("foo", request); + } + + @When("^I send a request to replace an SMS batch$") + public void replace() { + + TextRequest request = + TextRequest.builder() + .setFrom("+12016666666") + .setTo(Collections.singletonList("+12018888888")) + .setBody("This is the replacement batch") + .setSendAt(Instant.parse("2024-06-06T09:35:00Z")) + .build(); + replaceResponse = service.replace("foo", request); + } + + @When("^I send a request to cancel an SMS batch$") + public void cancel() { + + cancelResponse = service.cancel("foo"); + } + + @When("^I send a request to send delivery feedbacks$") + public void sendDeliveryFeedback() { + + SendDeliveryFeedbackRequest request = + SendDeliveryFeedbackRequest.builder() + .setRecipients(Collections.singletonList("+12017777777")) + .build(); + service.sendDeliveryFeedback("foo", request); + sendDeliveryFeedbackPassed = true; + } + + @Then("the response contains the text SMS details") + public void sendResult() { + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH1") + .setTo(Collections.singletonList("12017777777")) + .setFrom("12015555555") + .setCanceled(false) + .setBody("SMS body message") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setDeliveryReport(DeliveryReportType.FULL) + .setSendAt(Instant.parse("2024-06-06T09:25:00Z")) + .setExpireAt(Instant.parse("2024-06-09T09:25:00Z")) + .setFeedbackEnabled(true) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(sendTextResponse, expected); + } + + @Then("the response contains the text SMS details with multiple parameters") + public void sendWithParametersResult() { + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("+12017777777", "John"), + new AbstractMap.SimpleEntry<>("+12018888888", "Paul"), + new AbstractMap.SimpleEntry<>("default", "there")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map codeParameters = + Stream.of(new AbstractMap.SimpleEntry<>("+12017777777", "HALLOWEEN20 \uD83C\uDF83")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("code", codeParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH2") + .setTo(Arrays.asList("12017777777", "12018888888")) + .setFrom("12015555555") + .setCanceled(false) + .setParameters(parameters) + .setBody("Hello ${name}! Get 20% off with this discount code ${code}") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setDeliveryReport(DeliveryReportType.FULL) + .setExpireAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(sendTextWithParametersResponse, expected); + } + + @Then( + "the response contains the calculated bodies and number of parts for all messages in the" + + " batch") + public void dryRunResult() { + DryRunResponse expected = + DryRunResponse.builder() + .setNumberOfRecipients(3) + .setNumberOfMessages(3) + .setPerRecipient( + Arrays.asList( + DryRunPerRecipientDetails.builder() + .setRecipient("12017777777") + .setNumberOfParts(1) + .setBody("Hello John!") + .setEncoding("text") + .build(), + DryRunPerRecipientDetails.builder() + .setRecipient("12019999999") + .setNumberOfParts(1) + .setBody("Hello there!") + .setEncoding("text") + .build(), + DryRunPerRecipientDetails.builder() + .setRecipient("12018888888") + .setNumberOfParts(1) + .setBody("Hello there!") + .setEncoding("text") + .build())) + .build(); + + TestHelpers.recursiveEquals(dryRunResponse, expected); + } + + @Then("the response contains \"{int}\" SMS batches") + public void onePageResult(int expected) { + + Assertions.assertEquals(listOnePageResponse.getContent().size(), expected); + } + + @Then("the SMS batches list contains \"{int}\" SMS batches") + public void listAllResult(int expected) { + + ListBatchesResponse response = + null != listAllResponse ? listAllResponse : listAllByPageResponse; + + AtomicInteger count = new AtomicInteger(); + response.iterator().forEachRemaining(_unused -> count.getAndIncrement()); + + Assertions.assertEquals(count.get(), expected); + } + + @Then("the SMS batches iteration result contains the data from \"{int}\" pages") + public void listAllByPageResult(int expected) { + + int count = listAllByPageResponse.getContent().isEmpty() ? 0 : 1; + while (listAllByPageResponse.hasNextPage()) { + count++; + listAllByPageResponse = listAllByPageResponse.nextPage(); + } + Assertions.assertEquals(count, expected); + } + + @Then("the response contains the SMS batch details") + public void getResult() { + + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH1") + .setTo(Collections.singletonList("12017777777")) + .setFrom("12015555555") + .setCanceled(false) + .setBody("SMS body message") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setDeliveryReport(DeliveryReportType.FULL) + .setSendAt(Instant.parse("2024-06-06T09:25:00Z")) + .setExpireAt(Instant.parse("2024-06-09T09:25:00Z")) + .setFeedbackEnabled(true) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(getBatchResponse, expected); + } + + @Then("the response contains the SMS batch details with updated data") + public void updateResult() { + + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH1") + .setTo(Arrays.asList("12017777777", "01W4FFL35P4NC4K35SMSGROUP1")) + .setFrom("12016666666") + .setCanceled(false) + .setBody("SMS body message") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:22:48.054Z")) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2024-06-06T09:25:00Z")) + .setExpireAt(Instant.parse("2024-06-09T09:25:00Z")) + .setFeedbackEnabled(true) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(updateResponse, expected); + } + + @Then("the response contains the new SMS batch details with the provided data for replacement") + public void replaceResult() { + + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH1") + .setTo(Arrays.asList("12018888888")) + .setFrom("12016666666") + .setCanceled(false) + .setBody("This is the replacement batch") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:23:32.504Z")) + .setDeliveryReport(DeliveryReportType.NONE) + .setSendAt(Instant.parse("2024-06-06T09:35:00Z")) + .setExpireAt(Instant.parse("2024-06-09T09:35:00Z")) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(replaceResponse, expected); + } + + @Then("the response contains the SMS batch details with a cancelled status") + public void cancelResult() { + + TextResponse expected = + TextResponse.builder() + .setId("01W4FFL35P4NC4K35SMSBATCH1") + .setTo(Arrays.asList("12017777777")) + .setFrom("12015555555") + .setCanceled(true) + .setBody("SMS body message") + .setCreatedAt(Instant.parse("2024-06-06T09:22:14.304Z")) + .setModifiedAt(Instant.parse("2024-06-06T09:22:29.978Z")) + .setDeliveryReport(DeliveryReportType.FULL) + .setSendAt(Instant.parse("2024-06-06T09:25:00Z")) + .setExpireAt(Instant.parse("2024-06-09T09:25:00Z")) + .setFeedbackEnabled(true) + .setFlashMessage(false) + .build(); + + TestHelpers.recursiveEquals(cancelResponse, expected); + } + + @Then("the delivery feedback response contains no data") + public void setSendDeliveryFeedbackResult() { + Assertions.assertTrue(sendDeliveryFeedbackPassed); + } +} diff --git a/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/SmsIT.java b/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/SmsIT.java new file mode 100644 index 000000000..4229a2763 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/e2e/domains/sms/v1/SmsIT.java @@ -0,0 +1,16 @@ +package com.sinch.sdk.e2e.domains.sms.v1; + +import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; + +import org.junit.platform.suite.api.ConfigurationParameter; +import org.junit.platform.suite.api.IncludeEngines; +import org.junit.platform.suite.api.SelectClasspathResource; +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; + +@Suite +@SuiteDisplayName("SMS V1") +@IncludeEngines("cucumber") +@SelectClasspathResource("features/sms/batches.feature") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.sinch.sdk.e2e.domains.sms.v1") +public class SmsIT {} diff --git a/core/src/test/java/com/sinch/sdk/core/TestHelpers.java b/core/src/test/java/com/sinch/sdk/core/TestHelpers.java index 0b965fe0b..e74f7db49 100644 --- a/core/src/test/java/com/sinch/sdk/core/TestHelpers.java +++ b/core/src/test/java/com/sinch/sdk/core/TestHelpers.java @@ -8,11 +8,11 @@ public class TestHelpers { private static final RecursiveComparisonConfiguration recursiveComparisonConfiguration = RecursiveComparisonConfiguration.builder().withStrictTypeChecking(true).build(); - public static void recursiveEquals(Object o1, Object o2) { + public static void recursiveEquals(Object actual, Object expected) { - Assertions.assertThat(o1.getClass()).isEqualTo(o2.getClass()); - Assertions.assertThat(o1) + Assertions.assertThat(actual.getClass()).isEqualTo(expected.getClass()); + Assertions.assertThat(actual) .usingRecursiveComparison(recursiveComparisonConfiguration) - .isEqualTo(o2); + .isEqualTo(expected); } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java index bd4b53145..50ee62f98 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java @@ -761,8 +761,8 @@ private HttpRequest sendSMSRequestBuilder( } /** - * Update a Batch message This operation updates all specified parameters of a batch that matches - * the provided batch ID. + * Update a BatchResponse message This operation updates all specified parameters of a batch that + * matches the provided batch ID. * * @param servicePlanId Your service plan ID. You can find this on your * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/api/v1/internal/BatchesApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/api/v1/internal/BatchesApi.java new file mode 100644 index 000000000..608bb175d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/api/v1/internal/BatchesApi.java @@ -0,0 +1,801 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.api.v1.internal; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.exceptions.ApiExceptionBuilder; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.core.http.HttpRequest; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.HttpStatus; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import com.sinch.sdk.domains.sms.models.v1.batches.response.internal.ApiBatchList; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Logger; + +public class BatchesApi { + + private static final Logger LOGGER = Logger.getLogger(BatchesApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private Map authManagersByOasSecuritySchemes; + private HttpMapper mapper; + + private final String servicePlanId; + + public BatchesApi( + HttpClient httpClient, + ServerConfiguration serverConfiguration, + Map authManagersByOasSecuritySchemes, + HttpMapper mapper, + String servicePlanId) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.authManagersByOasSecuritySchemes = authManagersByOasSecuritySchemes; + this.mapper = mapper; + this.servicePlanId = servicePlanId; + } + + /** + * Cancel a batch message 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. 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. (required) + * @return BatchResponse + * @throws ApiException if fails to make API call + */ + public BatchResponse cancel(String batchId) throws ApiException { + + LOGGER.finest( + "[cancel]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "batchId: " + + batchId); + + HttpRequest httpRequest = cancelRequestBuilder(batchId); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest cancelRequestBuilder(String batchId) throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling cancel"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException(400, "Missing the required parameter 'batchId' when calling cancel"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList(); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.DELETE, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * Dry run 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 (optional) + * @param numberOfRecipients Max number of recipients to include per recipient details for in the + * response (optional, default to 100) + * @param sendRequest (optional) + * @return DryRunResponse + * @throws ApiException if fails to make API call + */ + public DryRunResponse dryRun( + Boolean perRecipient, Integer numberOfRecipients, BatchRequest sendRequest) + throws ApiException { + + LOGGER.finest( + "[dryRun]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "perRecipient: " + + perRecipient + + ", " + + "numberOfRecipients: " + + numberOfRecipients + + ", " + + "sendRequest: " + + sendRequest); + + HttpRequest httpRequest = dryRunRequestBuilder(perRecipient, numberOfRecipients, sendRequest); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest dryRunRequestBuilder( + Boolean perRecipient, Integer numberOfRecipients, BatchRequest sendRequest) + throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling dryRun"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/dry_run" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != perRecipient) { + localVarQueryParams.add( + new URLParameter( + "per_recipient", + perRecipient, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != numberOfRecipients) { + localVarQueryParams.add( + new URLParameter( + "number_of_recipients", + numberOfRecipients, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList("application/json"); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, sendRequest); + + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * 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. (required) + * @return BatchResponse + * @throws ApiException if fails to make API call + */ + public BatchResponse get(String batchId) throws ApiException { + + LOGGER.finest( + "[get]" + " " + "this.servicePlanId: " + this.servicePlanId + ", " + "batchId: " + batchId); + + HttpRequest httpRequest = getRequestBuilder(batchId); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest getRequestBuilder(String batchId) throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling get"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException(400, "Missing the required parameter 'batchId' when calling get"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList(); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * 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 page The page number starting from 0. (optional, default to 0) + * @param pageSize Determines the size of a page. (optional, default to 30) + * @param from Only list messages sent from this sender number. Multiple originating numbers can + * be comma separated. Must be phone numbers or short code. (optional) + * @param startDate Only list messages received at or after this date/time. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * Default: Now-24 (optional) + * @param endDate Only list messages received before this date/time. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * (optional) + * @param clientReference Client reference to include (optional) + * @return ApiBatchList + * @throws ApiException if fails to make API call + */ + public ApiBatchList list( + Integer page, + Integer pageSize, + String from, + String startDate, + String endDate, + String clientReference) + throws ApiException { + + LOGGER.finest( + "[list]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "page: " + + page + + ", " + + "pageSize: " + + pageSize + + ", " + + "from: " + + from + + ", " + + "startDate: " + + startDate + + ", " + + "endDate: " + + endDate + + ", " + + "clientReference: " + + clientReference); + + HttpRequest httpRequest = + listRequestBuilder(page, pageSize, from, startDate, endDate, clientReference); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest listRequestBuilder( + Integer page, + Integer pageSize, + String from, + String startDate, + String endDate, + String clientReference) + throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling list"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != page) { + localVarQueryParams.add( + new URLParameter("page", page, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != pageSize) { + localVarQueryParams.add( + new URLParameter( + "page_size", pageSize, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != from) { + localVarQueryParams.add( + new URLParameter("from", from, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != startDate) { + localVarQueryParams.add( + new URLParameter( + "start_date", startDate, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != endDate) { + localVarQueryParams.add( + new URLParameter( + "end_date", endDate, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != clientReference) { + localVarQueryParams.add( + new URLParameter( + "client_reference", + clientReference, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList(); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * Replace a batch 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. (required) + * @param sendRequest (optional) + * @return BatchResponse + * @throws ApiException if fails to make API call + */ + public BatchResponse replace(String batchId, BatchRequest sendRequest) throws ApiException { + + LOGGER.finest( + "[replace]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "batchId: " + + batchId + + ", " + + "sendRequest: " + + sendRequest); + + HttpRequest httpRequest = replaceRequestBuilder(batchId, sendRequest); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest replaceRequestBuilder(String batchId, BatchRequest sendRequest) + throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling replace"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException(400, "Missing the required parameter 'batchId' when calling replace"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList("application/json"); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, sendRequest); + + return new HttpRequest( + localVarPath, + HttpMethod.PUT, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * Send delivery feedback for a message Send feedback if your system can confirm successful + * message delivery. Feedback can only be provided if `feedback_enabled` was set when + * batch was submitted. **Batches**: 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. **Groups**: 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. (required) + * @param sendDeliveryFeedbackRequest A list of phone numbers (MSISDNs) that successfully received + * the message. (required) + * @throws ApiException if fails to make API call + */ + public void sendDeliveryFeedback( + String batchId, SendDeliveryFeedbackRequest sendDeliveryFeedbackRequest) throws ApiException { + + LOGGER.finest( + "[sendDeliveryFeedback]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "batchId: " + + batchId + + ", " + + "sendDeliveryFeedbackRequest: " + + sendDeliveryFeedbackRequest); + + HttpRequest httpRequest = + sendDeliveryFeedbackRequestBuilder(batchId, sendDeliveryFeedbackRequest); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + return; + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest sendDeliveryFeedbackRequestBuilder( + String batchId, SendDeliveryFeedbackRequest sendDeliveryFeedbackRequest) throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'this.servicePlanId' when calling sendDeliveryFeedback"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling sendDeliveryFeedback"); + } + // verify the required parameter 'sendDeliveryFeedbackRequest' is set + if (sendDeliveryFeedbackRequest == null) { + throw new ApiException( + 400, + "Missing the required parameter 'sendDeliveryFeedbackRequest' when calling" + + " sendDeliveryFeedback"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_feedback" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList(); + + final Collection localVarContentTypes = Arrays.asList("application/json"); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = + mapper.serialize(localVarContentTypes, sendDeliveryFeedbackRequest); + + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * Send Send a message or a batch of messages. Depending on the length of the body, one message + * might be split into multiple parts and charged accordingly. 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](/docs/sms/api-reference/#base-url) in the server URL. + * + * @param sendRequest Default schema is Text if type is not specified. (optional) + * @return BatchResponse + * @throws ApiException if fails to make API call + */ + public BatchResponse send(BatchRequest sendRequest) throws ApiException { + + LOGGER.finest( + "[send]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "sendRequest: " + + sendRequest); + + HttpRequest httpRequest = sendRequestBuilder(sendRequest); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest sendRequestBuilder(BatchRequest sendRequest) throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling send"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList("application/json"); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, sendRequest); + + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + + /** + * 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. (required) + * @param updateBatchRequest (optional) + * @return BatchResponse + * @throws ApiException if fails to make API call + */ + public BatchResponse update(String batchId, UpdateBatchRequest updateBatchRequest) + throws ApiException { + + LOGGER.finest( + "[update]" + + " " + + "this.servicePlanId: " + + this.servicePlanId + + ", " + + "batchId: " + + batchId + + ", " + + "updateBatchRequest: " + + updateBatchRequest); + + HttpRequest httpRequest = updateRequestBuilder(batchId, updateBatchRequest); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest updateRequestBuilder(String batchId, UpdateBatchRequest updateBatchRequest) + throws ApiException { + // verify the required parameter 'this.servicePlanId' is set + if (this.servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'this.servicePlanId' when calling update"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException(400, "Missing the required parameter 'batchId' when calling update"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLPathUtils.encodePathSegment(this.servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = Arrays.asList("application/json"); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, updateBatchRequest); + + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/DeliveryReportType.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/DeliveryReportType.java new file mode 100644 index 000000000..e5277bedc --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/DeliveryReportType.java @@ -0,0 +1,61 @@ +package com.sinch.sdk.domains.sms.models.v1.batches; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** Kind of delivery report */ +public class DeliveryReportType extends EnumDynamic { + + /** No delivery report callback will be sent. */ + public static final DeliveryReportType NONE = new DeliveryReportType("none"); + + /** A single delivery report callback will be sent. */ + public static final DeliveryReportType SUMMARY = new DeliveryReportType("summary"); + + /** + * A single delivery report callback will be sent which includes a list of recipients per delivery + * status. + */ + public static final DeliveryReportType FULL = new DeliveryReportType("full"); + + /** + * A delivery report callback will be sent for each status change of a message. This could result + * in a lot of callbacks and should be used with caution for larger batches. + * These delivery reports also include a timestamp of when the Delivery Report originated from the + * SMSC. + */ + public static final DeliveryReportType PER_RECIPIENT = new DeliveryReportType("per_recipient"); + + /** + * A delivery report callback representing the final status of a message will be sent for each + * recipient. This will send only one callback per recipient, compared to the multiple callbacks + * sent when using per_recipient. The delivery report will also include a timestamp + * of when it originated from the SMSC. + */ + public static final DeliveryReportType PER_RECIPIENT_FINAL = + new DeliveryReportType("per_recipient_final"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + DeliveryReportType.class, + DeliveryReportType::new, + Arrays.asList(NONE, SUMMARY, FULL, PER_RECIPIENT, PER_RECIPIENT_FINAL)); + + private DeliveryReportType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static DeliveryReportType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(DeliveryReportType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBody.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBody.java new file mode 100644 index 000000000..63c078302 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBody.java @@ -0,0 +1,86 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** The message content, including a URL to the media file */ +@JsonDeserialize(builder = MediaBodyImpl.Builder.class) +public interface MediaBody { + + /** + * The subject text + * + * @return subject + */ + String getSubject(); + + /** + * The message text. Text only media messages will be rejected, please use SMS instead. + * + * @return message + */ + String getMessage(); + + /** + * URL to the media file + * + * @return url + */ + String getUrl(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new MediaBodyImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param subject see getter + * @return Current builder + * @see #getSubject + */ + Builder setSubject(String subject); + + /** + * see getter + * + * @param message see getter + * @return Current builder + * @see #getMessage + */ + Builder setMessage(String message); + + /** + * see getter + * + * @param url see getter + * @return Current builder + * @see #getUrl + */ + Builder setUrl(String url); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + MediaBody build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyImpl.java new file mode 100644 index 000000000..6294d51a1 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyImpl.java @@ -0,0 +1,145 @@ +package com.sinch.sdk.domains.sms.models.v1.batches; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import java.util.Objects; + +@JsonPropertyOrder({ + MediaBodyImpl.JSON_PROPERTY_SUBJECT, + MediaBodyImpl.JSON_PROPERTY_MESSAGE, + MediaBodyImpl.JSON_PROPERTY_URL +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class MediaBodyImpl implements MediaBody { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_SUBJECT = "subject"; + + private OptionalValue subject; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + + private OptionalValue message; + + public static final String JSON_PROPERTY_URL = "url"; + + private OptionalValue url; + + public MediaBodyImpl() {} + + protected MediaBodyImpl( + OptionalValue subject, OptionalValue message, OptionalValue url) { + this.subject = subject; + this.message = message; + this.url = url; + } + + @JsonIgnore + public String getSubject() { + return subject.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SUBJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue subject() { + return subject; + } + + @JsonIgnore + public String getMessage() { + return message.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue message() { + return message; + } + + @JsonIgnore + public String getUrl() { + return url.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue url() { + return url; + } + + /** Return true if this MediaBody object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MediaBodyImpl mediaBody = (MediaBodyImpl) o; + return Objects.equals(this.subject, mediaBody.subject) + && Objects.equals(this.message, mediaBody.message) + && Objects.equals(this.url, mediaBody.url); + } + + @Override + public int hashCode() { + return Objects.hash(subject, message, url); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MediaBodyImpl {\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements MediaBody.Builder { + OptionalValue subject = OptionalValue.empty(); + OptionalValue message = OptionalValue.empty(); + OptionalValue url = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_SUBJECT) + public Builder setSubject(String subject) { + this.subject = OptionalValue.of(subject); + return this; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + public Builder setMessage(String message) { + this.message = OptionalValue.of(message); + return this; + } + + @JsonProperty(JSON_PROPERTY_URL) + public Builder setUrl(String url) { + this.url = OptionalValue.of(url); + return this; + } + + public MediaBody build() { + return new MediaBodyImpl(subject, message, url); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.java new file mode 100644 index 000000000..0bb00c522 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.java @@ -0,0 +1,281 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +/** BinaryRequest */ +@JsonDeserialize(builder = BinaryRequestImpl.Builder.class) +public interface BinaryRequest extends BatchRequest { + + /** + * A list of phone numbers and group IDs that will receive the batch. More info. + * + * @return to + */ + List getTo(); + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + String getFrom(); + + /** + * The message content Base64 encoded. Max 140 bytes including udh. + * + * @return body + */ + String getBody(); + + /** + * The UDH header of a binary message HEX encoded. Max 140 bytes including the body. + * + * @return udh + */ + String getUdh(); + + /** + * SMS in binary + * format. + */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_BINARY = new TypeEnum("mt_binary"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_BINARY)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set in the future the message will be delayed until send_at occurs. Must be + * before expire_at. If set in the past, messages will be sent immediately. Formatted + * as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Must be after + * send_at. Default and max is 3 days after send_at. Formatted as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Must be a valid URL. Learn how to + * set a default callback URL here. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch. + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * The type of number for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new BinaryRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param udh see getter + * @return Current builder + * @see #getUdh + */ + Builder setUdh(String udh); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + BinaryRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequestImpl.java new file mode 100644 index 000000000..39fa49dd7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequestImpl.java @@ -0,0 +1,440 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({ + BinaryRequestImpl.JSON_PROPERTY_TO, + BinaryRequestImpl.JSON_PROPERTY_FROM, + BinaryRequestImpl.JSON_PROPERTY_BODY, + BinaryRequestImpl.JSON_PROPERTY_UDH, + BinaryRequestImpl.JSON_PROPERTY_TYPE, + BinaryRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + BinaryRequestImpl.JSON_PROPERTY_SEND_AT, + BinaryRequestImpl.JSON_PROPERTY_EXPIRE_AT, + BinaryRequestImpl.JSON_PROPERTY_CALLBACK_URL, + BinaryRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + BinaryRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + BinaryRequestImpl.JSON_PROPERTY_FROM_TON, + BinaryRequestImpl.JSON_PROPERTY_FROM_NPI +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class BinaryRequestImpl implements BinaryRequest, BatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_UDH = "udh"; + + private OptionalValue udh; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public BinaryRequestImpl() {} + + protected BinaryRequestImpl( + OptionalValue> to, + OptionalValue from, + OptionalValue body, + OptionalValue udh, + OptionalValue type, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue fromTon, + OptionalValue fromNpi) { + this.to = to; + this.from = from; + this.body = body; + this.udh = udh; + this.type = type; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public String getUdh() { + return udh.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue udh() { + return udh; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + /** Return true if this BinaryRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BinaryRequestImpl binaryRequest = (BinaryRequestImpl) o; + return Objects.equals(this.to, binaryRequest.to) + && Objects.equals(this.from, binaryRequest.from) + && Objects.equals(this.body, binaryRequest.body) + && Objects.equals(this.udh, binaryRequest.udh) + && Objects.equals(this.type, binaryRequest.type) + && Objects.equals(this.deliveryReport, binaryRequest.deliveryReport) + && Objects.equals(this.sendAt, binaryRequest.sendAt) + && Objects.equals(this.expireAt, binaryRequest.expireAt) + && Objects.equals(this.callbackUrl, binaryRequest.callbackUrl) + && Objects.equals(this.clientReference, binaryRequest.clientReference) + && Objects.equals(this.feedbackEnabled, binaryRequest.feedbackEnabled) + && Objects.equals(this.fromTon, binaryRequest.fromTon) + && Objects.equals(this.fromNpi, binaryRequest.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + to, + from, + body, + udh, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BinaryRequestImpl {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" udh: ").append(toIndentedString(udh)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements BinaryRequest.Builder { + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue udh = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_BINARY); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_UDH) + public Builder setUdh(String udh) { + this.udh = OptionalValue.of(udh); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + public BinaryRequest build() { + return new BinaryRequestImpl( + to, + from, + body, + udh, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + fromTon, + fromNpi); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.java new file mode 100644 index 000000000..1774aad95 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.java @@ -0,0 +1,263 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** Only available in the US. Contact your account manager if you wish to send MMS. */ +@JsonDeserialize(builder = MediaRequestImpl.Builder.class) +public interface MediaRequest extends BatchRequest { + + /** + * List of Phone numbers and group IDs that will receive the batch. More info + * + * @return to + */ + List getTo(); + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + String getFrom(); + + /** + * Get body + * + * @return body + */ + MediaBody getBody(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** MMS */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_MEDIA = new TypeEnum("mt_media"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_MEDIA)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set in the future, the message will be delayed until send_at occurs. Must be + * before expire_at. If set in the past, messages will be sent immediately. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Must be after + * send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ + * . + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Whether or not you want the media included in your message to be checked against Sinch MMS channel best practices. If set to true, your + * message will be rejected if it doesn't conform to the listed recommendations, otherwise no + * validation will be performed. + * + * @return strictValidation + */ + Boolean getStrictValidation(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new MediaRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(MediaBody body); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param strictValidation see getter + * @return Current builder + * @see #getStrictValidation + */ + Builder setStrictValidation(Boolean strictValidation); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + MediaRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequestImpl.java new file mode 100644 index 000000000..227379256 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequestImpl.java @@ -0,0 +1,413 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + MediaRequestImpl.JSON_PROPERTY_TO, + MediaRequestImpl.JSON_PROPERTY_FROM, + MediaRequestImpl.JSON_PROPERTY_BODY, + MediaRequestImpl.JSON_PROPERTY_PARAMETERS, + MediaRequestImpl.JSON_PROPERTY_TYPE, + MediaRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + MediaRequestImpl.JSON_PROPERTY_SEND_AT, + MediaRequestImpl.JSON_PROPERTY_EXPIRE_AT, + MediaRequestImpl.JSON_PROPERTY_CALLBACK_URL, + MediaRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + MediaRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + MediaRequestImpl.JSON_PROPERTY_STRICT_VALIDATION +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class MediaRequestImpl implements MediaRequest, BatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + + private OptionalValue strictValidation; + + public MediaRequestImpl() {} + + protected MediaRequestImpl( + OptionalValue> to, + OptionalValue from, + OptionalValue body, + OptionalValue>> parameters, + OptionalValue type, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue strictValidation) { + this.to = to; + this.from = from; + this.body = body; + this.parameters = parameters; + this.type = type; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.strictValidation = strictValidation; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public MediaBody getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Boolean getStrictValidation() { + return strictValidation.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue strictValidation() { + return strictValidation; + } + + /** Return true if this MediaRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MediaRequestImpl mediaRequest = (MediaRequestImpl) o; + return Objects.equals(this.to, mediaRequest.to) + && Objects.equals(this.from, mediaRequest.from) + && Objects.equals(this.body, mediaRequest.body) + && Objects.equals(this.parameters, mediaRequest.parameters) + && Objects.equals(this.type, mediaRequest.type) + && Objects.equals(this.deliveryReport, mediaRequest.deliveryReport) + && Objects.equals(this.sendAt, mediaRequest.sendAt) + && Objects.equals(this.expireAt, mediaRequest.expireAt) + && Objects.equals(this.callbackUrl, mediaRequest.callbackUrl) + && Objects.equals(this.clientReference, mediaRequest.clientReference) + && Objects.equals(this.feedbackEnabled, mediaRequest.feedbackEnabled) + && Objects.equals(this.strictValidation, mediaRequest.strictValidation); + } + + @Override + public int hashCode() { + return Objects.hash( + to, + from, + body, + parameters, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + strictValidation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MediaRequestImpl {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" strictValidation: ").append(toIndentedString(strictValidation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements MediaRequest.Builder { + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_MEDIA); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue strictValidation = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(MediaBody body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + public Builder setStrictValidation(Boolean strictValidation) { + this.strictValidation = OptionalValue.of(strictValidation); + return this; + } + + public MediaRequest build() { + return new MediaRequestImpl( + to, + from, + body, + parameters, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + strictValidation); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequest.java new file mode 100644 index 000000000..809c98a80 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequest.java @@ -0,0 +1,57 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; + +/** SendDeliveryFeedbackRequest */ +@JsonDeserialize(builder = SendDeliveryFeedbackRequestImpl.Builder.class) +public interface SendDeliveryFeedbackRequest { + + /** + * 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. + * + * @return recipients + */ + List getRecipients(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new SendDeliveryFeedbackRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param recipients see getter + * @return Current builder + * @see #getRecipients + */ + Builder setRecipients(List recipients); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + SendDeliveryFeedbackRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestImpl.java new file mode 100644 index 000000000..e9db52653 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestImpl.java @@ -0,0 +1,91 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({SendDeliveryFeedbackRequestImpl.JSON_PROPERTY_RECIPIENTS}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class SendDeliveryFeedbackRequestImpl implements SendDeliveryFeedbackRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + + private OptionalValue> recipients; + + public SendDeliveryFeedbackRequestImpl() {} + + protected SendDeliveryFeedbackRequestImpl(OptionalValue> recipients) { + this.recipients = recipients; + } + + @JsonIgnore + public List getRecipients() { + return recipients.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue> recipients() { + return recipients; + } + + /** Return true if this ApiDeliveryFeedback object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SendDeliveryFeedbackRequestImpl apiDeliveryFeedback = (SendDeliveryFeedbackRequestImpl) o; + return Objects.equals(this.recipients, apiDeliveryFeedback.recipients); + } + + @Override + public int hashCode() { + return Objects.hash(recipients); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SendDeliveryFeedbackRequestImpl {\n"); + sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements SendDeliveryFeedbackRequest.Builder { + OptionalValue> recipients = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + public Builder setRecipients(List recipients) { + this.recipients = OptionalValue.of(recipients); + return this; + } + + public SendDeliveryFeedbackRequest build() { + return new SendDeliveryFeedbackRequestImpl(recipients); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.java new file mode 100644 index 000000000..207d0746a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.java @@ -0,0 +1,332 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** TextRequest */ +@JsonDeserialize(builder = TextRequestImpl.Builder.class) +public interface TextRequest extends BatchRequest { + + /** + * List of Phone numbers and group IDs that will receive the batch. More info + * + * @return to + */ + List getTo(); + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + String getFrom(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** + * The message content + * + * @return body + */ + String getBody(); + + /** Regular SMS */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_TEXT = new TypeEnum("mt_text"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_TEXT)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set in the future, the message will be delayed until send_at occurs. Must be + * before expire_at. If set in the past, messages will be sent immediately. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Must be after + * send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ + * . + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Must be a valid URL. Learn how to + * set a default callback URL here. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + Boolean getFlashMessage(); + + /** + * If set to true the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + Boolean getTruncateConcat(); + + /** + * Message will be dispatched only if it is not split to more parts than Max Number of Message + * Parts + * + *

minimum: 1 + * + * @return maxNumberOfMessageParts + */ + Integer getMaxNumberOfMessageParts(); + + /** + * The type of number for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new TextRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param flashMessage see getter + * @return Current builder + * @see #getFlashMessage + */ + Builder setFlashMessage(Boolean flashMessage); + + /** + * see getter + * + * @param truncateConcat see getter + * @return Current builder + * @see #getTruncateConcat + */ + Builder setTruncateConcat(Boolean truncateConcat); + + /** + * see getter + * + * @param maxNumberOfMessageParts see getter + * @return Current builder + * @see #getMaxNumberOfMessageParts + */ + Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + TextRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequestImpl.java new file mode 100644 index 000000000..1cc714f5a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequestImpl.java @@ -0,0 +1,531 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + TextRequestImpl.JSON_PROPERTY_TO, + TextRequestImpl.JSON_PROPERTY_FROM, + TextRequestImpl.JSON_PROPERTY_PARAMETERS, + TextRequestImpl.JSON_PROPERTY_BODY, + TextRequestImpl.JSON_PROPERTY_TYPE, + TextRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + TextRequestImpl.JSON_PROPERTY_SEND_AT, + TextRequestImpl.JSON_PROPERTY_EXPIRE_AT, + TextRequestImpl.JSON_PROPERTY_CALLBACK_URL, + TextRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + TextRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + TextRequestImpl.JSON_PROPERTY_FLASH_MESSAGE, + TextRequestImpl.JSON_PROPERTY_TRUNCATE_CONCAT, + TextRequestImpl.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + TextRequestImpl.JSON_PROPERTY_FROM_TON, + TextRequestImpl.JSON_PROPERTY_FROM_NPI +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class TextRequestImpl implements TextRequest, BatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + + private OptionalValue flashMessage; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + + private OptionalValue truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + + private OptionalValue maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public TextRequestImpl() {} + + protected TextRequestImpl( + OptionalValue> to, + OptionalValue from, + OptionalValue>> parameters, + OptionalValue body, + OptionalValue type, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue flashMessage, + OptionalValue truncateConcat, + OptionalValue maxNumberOfMessageParts, + OptionalValue fromTon, + OptionalValue fromNpi) { + this.to = to; + this.from = from; + this.parameters = parameters; + this.body = body; + this.type = type; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.flashMessage = flashMessage; + this.truncateConcat = truncateConcat; + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Boolean getFlashMessage() { + return flashMessage.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue flashMessage() { + return flashMessage; + } + + @JsonIgnore + public Boolean getTruncateConcat() { + return truncateConcat.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue truncateConcat() { + return truncateConcat; + } + + @JsonIgnore + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue maxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + /** Return true if this TextRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextRequestImpl textRequest = (TextRequestImpl) o; + return Objects.equals(this.to, textRequest.to) + && Objects.equals(this.from, textRequest.from) + && Objects.equals(this.parameters, textRequest.parameters) + && Objects.equals(this.body, textRequest.body) + && Objects.equals(this.type, textRequest.type) + && Objects.equals(this.deliveryReport, textRequest.deliveryReport) + && Objects.equals(this.sendAt, textRequest.sendAt) + && Objects.equals(this.expireAt, textRequest.expireAt) + && Objects.equals(this.callbackUrl, textRequest.callbackUrl) + && Objects.equals(this.clientReference, textRequest.clientReference) + && Objects.equals(this.feedbackEnabled, textRequest.feedbackEnabled) + && Objects.equals(this.flashMessage, textRequest.flashMessage) + && Objects.equals(this.truncateConcat, textRequest.truncateConcat) + && Objects.equals(this.maxNumberOfMessageParts, textRequest.maxNumberOfMessageParts) + && Objects.equals(this.fromTon, textRequest.fromTon) + && Objects.equals(this.fromNpi, textRequest.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + to, + from, + parameters, + body, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TextRequestImpl {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" flashMessage: ").append(toIndentedString(flashMessage)).append("\n"); + sb.append(" truncateConcat: ").append(toIndentedString(truncateConcat)).append("\n"); + sb.append(" maxNumberOfMessageParts: ") + .append(toIndentedString(maxNumberOfMessageParts)) + .append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements TextRequest.Builder { + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_TEXT); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue flashMessage = OptionalValue.empty(); + OptionalValue truncateConcat = OptionalValue.empty(); + OptionalValue maxNumberOfMessageParts = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + public Builder setFlashMessage(Boolean flashMessage) { + this.flashMessage = OptionalValue.of(flashMessage); + return this; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + public Builder setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = OptionalValue.of(truncateConcat); + return this; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + public TextRequest build() { + return new TextRequestImpl( + to, + from, + parameters, + body, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.java new file mode 100644 index 000000000..4bfcc1c9d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.java @@ -0,0 +1,288 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +/** Update binary message */ +@JsonDeserialize(builder = UpdateBinaryRequestImpl.Builder.class) +public interface UpdateBinaryRequest extends UpdateBatchRequest { + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + String getFrom(); + + /** SMS in binary format */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_BINARY = new TypeEnum("mt_binary"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_BINARY)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + List getToAdd(); + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + List getToRemove(); + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set, in the future the message will be delayed until send_at occurs. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. Constraints: Must be before expire_at. If set in the past, + * messages will be sent immediately. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Constraints: Must be + * after send_at Default: 3 days after send_at + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * The message content Base64 encoded. Max 140 bytes together with udh. + * + * @return body + */ + String getBody(); + + /** + * The UDH header of a binary message HEX encoded. Max 140 bytes together with body. + * + * @return udh + */ + String getUdh(); + + /** + * The type of number for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new UpdateBinaryRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param toAdd see getter + * @return Current builder + * @see #getToAdd + */ + Builder setToAdd(List toAdd); + + /** + * see getter + * + * @param toRemove see getter + * @return Current builder + * @see #getToRemove + */ + Builder setToRemove(List toRemove); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param udh see getter + * @return Current builder + * @see #getUdh + */ + Builder setUdh(String udh); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + UpdateBinaryRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequestImpl.java new file mode 100644 index 000000000..0366125d0 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequestImpl.java @@ -0,0 +1,469 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({ + UpdateBinaryRequestImpl.JSON_PROPERTY_FROM, + UpdateBinaryRequestImpl.JSON_PROPERTY_TYPE, + UpdateBinaryRequestImpl.JSON_PROPERTY_TO_ADD, + UpdateBinaryRequestImpl.JSON_PROPERTY_TO_REMOVE, + UpdateBinaryRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + UpdateBinaryRequestImpl.JSON_PROPERTY_SEND_AT, + UpdateBinaryRequestImpl.JSON_PROPERTY_EXPIRE_AT, + UpdateBinaryRequestImpl.JSON_PROPERTY_CALLBACK_URL, + UpdateBinaryRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + UpdateBinaryRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + UpdateBinaryRequestImpl.JSON_PROPERTY_BODY, + UpdateBinaryRequestImpl.JSON_PROPERTY_UDH, + UpdateBinaryRequestImpl.JSON_PROPERTY_FROM_TON, + UpdateBinaryRequestImpl.JSON_PROPERTY_FROM_NPI +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class UpdateBinaryRequestImpl implements UpdateBinaryRequest, UpdateBatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + + private OptionalValue> toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + + private OptionalValue> toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_UDH = "udh"; + + private OptionalValue udh; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public UpdateBinaryRequestImpl() {} + + protected UpdateBinaryRequestImpl( + OptionalValue from, + OptionalValue type, + OptionalValue> toAdd, + OptionalValue> toRemove, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue body, + OptionalValue udh, + OptionalValue fromTon, + OptionalValue fromNpi) { + this.from = from; + this.type = type; + this.toAdd = toAdd; + this.toRemove = toRemove; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.body = body; + this.udh = udh; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public List getToAdd() { + return toAdd.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toAdd() { + return toAdd; + } + + @JsonIgnore + public List getToRemove() { + return toRemove.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toRemove() { + return toRemove; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public String getUdh() { + return udh.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue udh() { + return udh; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + /** Return true if this ApiUpdateBinaryMtMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateBinaryRequestImpl apiUpdateBinaryMtMessage = (UpdateBinaryRequestImpl) o; + return Objects.equals(this.from, apiUpdateBinaryMtMessage.from) + && Objects.equals(this.type, apiUpdateBinaryMtMessage.type) + && Objects.equals(this.toAdd, apiUpdateBinaryMtMessage.toAdd) + && Objects.equals(this.toRemove, apiUpdateBinaryMtMessage.toRemove) + && Objects.equals(this.deliveryReport, apiUpdateBinaryMtMessage.deliveryReport) + && Objects.equals(this.sendAt, apiUpdateBinaryMtMessage.sendAt) + && Objects.equals(this.expireAt, apiUpdateBinaryMtMessage.expireAt) + && Objects.equals(this.callbackUrl, apiUpdateBinaryMtMessage.callbackUrl) + && Objects.equals(this.clientReference, apiUpdateBinaryMtMessage.clientReference) + && Objects.equals(this.feedbackEnabled, apiUpdateBinaryMtMessage.feedbackEnabled) + && Objects.equals(this.body, apiUpdateBinaryMtMessage.body) + && Objects.equals(this.udh, apiUpdateBinaryMtMessage.udh) + && Objects.equals(this.fromTon, apiUpdateBinaryMtMessage.fromTon) + && Objects.equals(this.fromNpi, apiUpdateBinaryMtMessage.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + body, + udh, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateBinaryRequestImpl {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" toAdd: ").append(toIndentedString(toAdd)).append("\n"); + sb.append(" toRemove: ").append(toIndentedString(toRemove)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" udh: ").append(toIndentedString(udh)).append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements UpdateBinaryRequest.Builder { + OptionalValue from = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_BINARY); + OptionalValue> toAdd = OptionalValue.empty(); + OptionalValue> toRemove = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue udh = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + public Builder setToAdd(List toAdd) { + this.toAdd = OptionalValue.of(toAdd); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + public Builder setToRemove(List toRemove) { + this.toRemove = OptionalValue.of(toRemove); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_UDH) + public Builder setUdh(String udh) { + this.udh = OptionalValue.of(udh); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + public UpdateBinaryRequest build() { + return new UpdateBinaryRequestImpl( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + body, + udh, + fromTon, + fromNpi); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.java new file mode 100644 index 000000000..bf48b7482 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.java @@ -0,0 +1,275 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** Update media message */ +@JsonDeserialize(builder = UpdateMediaRequestImpl.Builder.class) +public interface UpdateMediaRequest extends UpdateBatchRequest { + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + String getFrom(); + + /** MMS */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_MEDIA = new TypeEnum("mt_media"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_MEDIA)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + List getToAdd(); + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + List getToRemove(); + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set, in the future the message will be delayed until send_at occurs. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. Constraints: Must be before expire_at. If set in the past, + * messages will be sent immediately. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Constraints: Must be + * after send_at Default: 3 days after send_at + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Get body + * + * @return body + */ + MediaBody getBody(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** + * Whether or not you want the media included in your message to be checked against Sinch MMS channel best practices. If set to true, your + * message will be rejected if it doesn't conform to the listed recommendations, otherwise no + * validation will be performed. + * + * @return strictValidation + */ + Boolean getStrictValidation(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new UpdateMediaRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param toAdd see getter + * @return Current builder + * @see #getToAdd + */ + Builder setToAdd(List toAdd); + + /** + * see getter + * + * @param toRemove see getter + * @return Current builder + * @see #getToRemove + */ + Builder setToRemove(List toRemove); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(MediaBody body); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param strictValidation see getter + * @return Current builder + * @see #getStrictValidation + */ + Builder setStrictValidation(Boolean strictValidation); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + UpdateMediaRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequestImpl.java new file mode 100644 index 000000000..f9a2ae49a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequestImpl.java @@ -0,0 +1,442 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + UpdateMediaRequestImpl.JSON_PROPERTY_FROM, + UpdateMediaRequestImpl.JSON_PROPERTY_TYPE, + UpdateMediaRequestImpl.JSON_PROPERTY_TO_ADD, + UpdateMediaRequestImpl.JSON_PROPERTY_TO_REMOVE, + UpdateMediaRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + UpdateMediaRequestImpl.JSON_PROPERTY_SEND_AT, + UpdateMediaRequestImpl.JSON_PROPERTY_EXPIRE_AT, + UpdateMediaRequestImpl.JSON_PROPERTY_CALLBACK_URL, + UpdateMediaRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + UpdateMediaRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + UpdateMediaRequestImpl.JSON_PROPERTY_BODY, + UpdateMediaRequestImpl.JSON_PROPERTY_PARAMETERS, + UpdateMediaRequestImpl.JSON_PROPERTY_STRICT_VALIDATION +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class UpdateMediaRequestImpl implements UpdateMediaRequest, UpdateBatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + + private OptionalValue> toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + + private OptionalValue> toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + + private OptionalValue strictValidation; + + public UpdateMediaRequestImpl() {} + + protected UpdateMediaRequestImpl( + OptionalValue from, + OptionalValue type, + OptionalValue> toAdd, + OptionalValue> toRemove, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue body, + OptionalValue>> parameters, + OptionalValue strictValidation) { + this.from = from; + this.type = type; + this.toAdd = toAdd; + this.toRemove = toRemove; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.body = body; + this.parameters = parameters; + this.strictValidation = strictValidation; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public List getToAdd() { + return toAdd.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toAdd() { + return toAdd; + } + + @JsonIgnore + public List getToRemove() { + return toRemove.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toRemove() { + return toRemove; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public MediaBody getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public Boolean getStrictValidation() { + return strictValidation.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue strictValidation() { + return strictValidation; + } + + /** Return true if this ApiUpdateMmsMtMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateMediaRequestImpl apiUpdateMmsMtMessage = (UpdateMediaRequestImpl) o; + return Objects.equals(this.from, apiUpdateMmsMtMessage.from) + && Objects.equals(this.type, apiUpdateMmsMtMessage.type) + && Objects.equals(this.toAdd, apiUpdateMmsMtMessage.toAdd) + && Objects.equals(this.toRemove, apiUpdateMmsMtMessage.toRemove) + && Objects.equals(this.deliveryReport, apiUpdateMmsMtMessage.deliveryReport) + && Objects.equals(this.sendAt, apiUpdateMmsMtMessage.sendAt) + && Objects.equals(this.expireAt, apiUpdateMmsMtMessage.expireAt) + && Objects.equals(this.callbackUrl, apiUpdateMmsMtMessage.callbackUrl) + && Objects.equals(this.clientReference, apiUpdateMmsMtMessage.clientReference) + && Objects.equals(this.feedbackEnabled, apiUpdateMmsMtMessage.feedbackEnabled) + && Objects.equals(this.body, apiUpdateMmsMtMessage.body) + && Objects.equals(this.parameters, apiUpdateMmsMtMessage.parameters) + && Objects.equals(this.strictValidation, apiUpdateMmsMtMessage.strictValidation); + } + + @Override + public int hashCode() { + return Objects.hash( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + body, + parameters, + strictValidation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateMediaRequestImpl {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" toAdd: ").append(toIndentedString(toAdd)).append("\n"); + sb.append(" toRemove: ").append(toIndentedString(toRemove)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" strictValidation: ").append(toIndentedString(strictValidation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements UpdateMediaRequest.Builder { + OptionalValue from = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_MEDIA); + OptionalValue> toAdd = OptionalValue.empty(); + OptionalValue> toRemove = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue strictValidation = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + public Builder setToAdd(List toAdd) { + this.toAdd = OptionalValue.of(toAdd); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + public Builder setToRemove(List toRemove) { + this.toRemove = OptionalValue.of(toRemove); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(MediaBody body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + public Builder setStrictValidation(Boolean strictValidation) { + this.strictValidation = OptionalValue.of(strictValidation); + return this; + } + + public UpdateMediaRequest build() { + return new UpdateMediaRequestImpl( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + body, + parameters, + strictValidation); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.java new file mode 100644 index 000000000..ca8b8a76d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.java @@ -0,0 +1,342 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** Update text message */ +@JsonDeserialize(builder = UpdateTextRequestImpl.Builder.class) +public interface UpdateTextRequest extends UpdateBatchRequest { + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + String getFrom(); + + /** Regular SMS */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_TEXT = new TypeEnum("mt_text"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_TEXT)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + List getToAdd(); + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + List getToRemove(); + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set, in the future the message will be delayed until send_at occurs. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. Constraints: Must be before expire_at. If set in the past, + * messages will be sent immediately. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Constraints: Must be + * after send_at Default: 3 days after send_at + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** + * The message content + * + * @return body + */ + String getBody(); + + /** + * The type of number for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Message will be dispatched only if it is not split to more parts than Max Number of Message + * Parts + * + *

minimum: 1 + * + * @return maxNumberOfMessageParts + */ + Integer getMaxNumberOfMessageParts(); + + /** + * If set to true the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + Boolean getTruncateConcat(); + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + Boolean getFlashMessage(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new UpdateTextRequestImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param toAdd see getter + * @return Current builder + * @see #getToAdd + */ + Builder setToAdd(List toAdd); + + /** + * see getter + * + * @param toRemove see getter + * @return Current builder + * @see #getToRemove + */ + Builder setToRemove(List toRemove); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * see getter + * + * @param maxNumberOfMessageParts see getter + * @return Current builder + * @see #getMaxNumberOfMessageParts + */ + Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts); + + /** + * see getter + * + * @param truncateConcat see getter + * @return Current builder + * @see #getTruncateConcat + */ + Builder setTruncateConcat(Boolean truncateConcat); + + /** + * see getter + * + * @param flashMessage see getter + * @return Current builder + * @see #getFlashMessage + */ + Builder setFlashMessage(Boolean flashMessage); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + UpdateTextRequest build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequestImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequestImpl.java new file mode 100644 index 000000000..bca9c48ec --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequestImpl.java @@ -0,0 +1,561 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + UpdateTextRequestImpl.JSON_PROPERTY_FROM, + UpdateTextRequestImpl.JSON_PROPERTY_TYPE, + UpdateTextRequestImpl.JSON_PROPERTY_TO_ADD, + UpdateTextRequestImpl.JSON_PROPERTY_TO_REMOVE, + UpdateTextRequestImpl.JSON_PROPERTY_DELIVERY_REPORT, + UpdateTextRequestImpl.JSON_PROPERTY_SEND_AT, + UpdateTextRequestImpl.JSON_PROPERTY_EXPIRE_AT, + UpdateTextRequestImpl.JSON_PROPERTY_CALLBACK_URL, + UpdateTextRequestImpl.JSON_PROPERTY_CLIENT_REFERENCE, + UpdateTextRequestImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + UpdateTextRequestImpl.JSON_PROPERTY_PARAMETERS, + UpdateTextRequestImpl.JSON_PROPERTY_BODY, + UpdateTextRequestImpl.JSON_PROPERTY_FROM_TON, + UpdateTextRequestImpl.JSON_PROPERTY_FROM_NPI, + UpdateTextRequestImpl.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + UpdateTextRequestImpl.JSON_PROPERTY_TRUNCATE_CONCAT, + UpdateTextRequestImpl.JSON_PROPERTY_FLASH_MESSAGE +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class UpdateTextRequestImpl implements UpdateTextRequest, UpdateBatchRequest { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + + private OptionalValue> toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + + private OptionalValue> toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + + private OptionalValue maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + + private OptionalValue truncateConcat; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + + private OptionalValue flashMessage; + + public UpdateTextRequestImpl() {} + + protected UpdateTextRequestImpl( + OptionalValue from, + OptionalValue type, + OptionalValue> toAdd, + OptionalValue> toRemove, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue>> parameters, + OptionalValue body, + OptionalValue fromTon, + OptionalValue fromNpi, + OptionalValue maxNumberOfMessageParts, + OptionalValue truncateConcat, + OptionalValue flashMessage) { + this.from = from; + this.type = type; + this.toAdd = toAdd; + this.toRemove = toRemove; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.parameters = parameters; + this.body = body; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + this.truncateConcat = truncateConcat; + this.flashMessage = flashMessage; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public List getToAdd() { + return toAdd.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toAdd() { + return toAdd; + } + + @JsonIgnore + public List getToRemove() { + return toRemove.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> toRemove() { + return toRemove; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + @JsonIgnore + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue maxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonIgnore + public Boolean getTruncateConcat() { + return truncateConcat.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue truncateConcat() { + return truncateConcat; + } + + @JsonIgnore + public Boolean getFlashMessage() { + return flashMessage.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue flashMessage() { + return flashMessage; + } + + /** Return true if this ApiUpdateTextMtMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateTextRequestImpl apiUpdateTextMtMessage = (UpdateTextRequestImpl) o; + return Objects.equals(this.from, apiUpdateTextMtMessage.from) + && Objects.equals(this.type, apiUpdateTextMtMessage.type) + && Objects.equals(this.toAdd, apiUpdateTextMtMessage.toAdd) + && Objects.equals(this.toRemove, apiUpdateTextMtMessage.toRemove) + && Objects.equals(this.deliveryReport, apiUpdateTextMtMessage.deliveryReport) + && Objects.equals(this.sendAt, apiUpdateTextMtMessage.sendAt) + && Objects.equals(this.expireAt, apiUpdateTextMtMessage.expireAt) + && Objects.equals(this.callbackUrl, apiUpdateTextMtMessage.callbackUrl) + && Objects.equals(this.clientReference, apiUpdateTextMtMessage.clientReference) + && Objects.equals(this.feedbackEnabled, apiUpdateTextMtMessage.feedbackEnabled) + && Objects.equals(this.parameters, apiUpdateTextMtMessage.parameters) + && Objects.equals(this.body, apiUpdateTextMtMessage.body) + && Objects.equals(this.fromTon, apiUpdateTextMtMessage.fromTon) + && Objects.equals(this.fromNpi, apiUpdateTextMtMessage.fromNpi) + && Objects.equals( + this.maxNumberOfMessageParts, apiUpdateTextMtMessage.maxNumberOfMessageParts) + && Objects.equals(this.truncateConcat, apiUpdateTextMtMessage.truncateConcat) + && Objects.equals(this.flashMessage, apiUpdateTextMtMessage.flashMessage); + } + + @Override + public int hashCode() { + return Objects.hash( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + parameters, + body, + fromTon, + fromNpi, + maxNumberOfMessageParts, + truncateConcat, + flashMessage); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateTextRequestImpl {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" toAdd: ").append(toIndentedString(toAdd)).append("\n"); + sb.append(" toRemove: ").append(toIndentedString(toRemove)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append(" maxNumberOfMessageParts: ") + .append(toIndentedString(maxNumberOfMessageParts)) + .append("\n"); + sb.append(" truncateConcat: ").append(toIndentedString(truncateConcat)).append("\n"); + sb.append(" flashMessage: ").append(toIndentedString(flashMessage)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements UpdateTextRequest.Builder { + OptionalValue from = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_TEXT); + OptionalValue> toAdd = OptionalValue.empty(); + OptionalValue> toRemove = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + OptionalValue maxNumberOfMessageParts = OptionalValue.empty(); + OptionalValue truncateConcat = OptionalValue.empty(); + OptionalValue flashMessage = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + public Builder setToAdd(List toAdd) { + this.toAdd = OptionalValue.of(toAdd); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + public Builder setToRemove(List toRemove) { + this.toRemove = OptionalValue.of(toRemove); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); + return this; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + public Builder setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = OptionalValue.of(truncateConcat); + return this; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + public Builder setFlashMessage(Boolean flashMessage) { + this.flashMessage = OptionalValue.of(flashMessage); + return this; + } + + public UpdateTextRequest build() { + return new UpdateTextRequestImpl( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + parameters, + body, + fromTon, + fromNpi, + maxNumberOfMessageParts, + truncateConcat, + flashMessage); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.java new file mode 100644 index 000000000..3b0db8b77 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.java @@ -0,0 +1,354 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Stream; + +/** BinaryResponse */ +@JsonDeserialize(builder = BinaryResponseImpl.Builder.class) +public interface BinaryResponse extends BatchResponse { + + /** + * Unique identifier for batch. + * + * @return id + * @readOnly This field is returned by the server and cannot be modified + */ + String getId(); + + /** + * A list of phone numbers and group IDs that have received the batch. More info. + * + * @return to + */ + List getTo(); + + /** + * The sender number provided. Required if the Automatic Default Originator is not configured. + * + * @return from + */ + String getFrom(); + + /** + * Indicates whether or not the batch has been canceled. + * + * @return canceled + * @readOnly This field is returned by the server and cannot be modified + */ + Boolean getCanceled(); + + /** + * The message content provided. Base64 encoded. + * + * @return body + */ + String getBody(); + + /** + * The UDH + * header of a binary message HEX encoded. Max 140 bytes including the body. + * + * @return udh + */ + String getUdh(); + + /** + * SMS in binary + * format. + */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_BINARY = new TypeEnum("mt_binary"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_BINARY)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Timestamp for when batch was created. Formatted as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return createdAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getCreatedAt(); + + /** + * Timestamp for when batch was last updated. Formatted as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return modifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getModifiedAt(); + + /** + * The delivery report callback option selected. Will be either none, summary + * , full, per_recipient, or per_recipient_final. + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set, the date and time the message should be delivered. Formatted as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the date and time the message will expire. Formatted as ISO-8601. For example: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * The callback URL provided in the request. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The string input to identify this batch message. If set, the identifier will be added in the + * delivery report/callback of this batch. + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * The type of number for the sender number. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new BinaryResponseImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param id see getter + * @return Current builder + * @see #getId + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setId(String id); + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param canceled see getter + * @return Current builder + * @see #getCanceled + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCanceled(Boolean canceled); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param udh see getter + * @return Current builder + * @see #getUdh + */ + Builder setUdh(String udh); + + /** + * see getter + * + * @param createdAt see getter + * @return Current builder + * @see #getCreatedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCreatedAt(Instant createdAt); + + /** + * see getter + * + * @param modifiedAt see getter + * @return Current builder + * @see #getModifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setModifiedAt(Instant modifiedAt); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + BinaryResponse build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponseImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponseImpl.java new file mode 100644 index 000000000..fafac3b55 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponseImpl.java @@ -0,0 +1,552 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({ + BinaryResponseImpl.JSON_PROPERTY_ID, + BinaryResponseImpl.JSON_PROPERTY_TO, + BinaryResponseImpl.JSON_PROPERTY_FROM, + BinaryResponseImpl.JSON_PROPERTY_CANCELED, + BinaryResponseImpl.JSON_PROPERTY_BODY, + BinaryResponseImpl.JSON_PROPERTY_UDH, + BinaryResponseImpl.JSON_PROPERTY_TYPE, + BinaryResponseImpl.JSON_PROPERTY_CREATED_AT, + BinaryResponseImpl.JSON_PROPERTY_MODIFIED_AT, + BinaryResponseImpl.JSON_PROPERTY_DELIVERY_REPORT, + BinaryResponseImpl.JSON_PROPERTY_SEND_AT, + BinaryResponseImpl.JSON_PROPERTY_EXPIRE_AT, + BinaryResponseImpl.JSON_PROPERTY_CALLBACK_URL, + BinaryResponseImpl.JSON_PROPERTY_CLIENT_REFERENCE, + BinaryResponseImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + BinaryResponseImpl.JSON_PROPERTY_FROM_TON, + BinaryResponseImpl.JSON_PROPERTY_FROM_NPI +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class BinaryResponseImpl implements BinaryResponse, BatchResponse { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + + private OptionalValue id; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + + private OptionalValue canceled; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_UDH = "udh"; + + private OptionalValue udh; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + + private OptionalValue createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + + private OptionalValue modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public BinaryResponseImpl() {} + + protected BinaryResponseImpl( + OptionalValue id, + OptionalValue> to, + OptionalValue from, + OptionalValue canceled, + OptionalValue body, + OptionalValue udh, + OptionalValue type, + OptionalValue createdAt, + OptionalValue modifiedAt, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue fromTon, + OptionalValue fromNpi) { + this.id = id; + this.to = to; + this.from = from; + this.canceled = canceled; + this.body = body; + this.udh = udh; + this.type = type; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + @JsonIgnore + public String getId() { + return id.orElse(null); + } + + @JsonIgnore + public OptionalValue id() { + return id; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public Boolean getCanceled() { + return canceled.orElse(null); + } + + @JsonIgnore + public OptionalValue canceled() { + return canceled; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public String getUdh() { + return udh.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue udh() { + return udh; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OptionalValue type() { + return type; + } + + @JsonIgnore + public Instant getCreatedAt() { + return createdAt.orElse(null); + } + + @JsonIgnore + public OptionalValue createdAt() { + return createdAt; + } + + @JsonIgnore + public Instant getModifiedAt() { + return modifiedAt.orElse(null); + } + + @JsonIgnore + public OptionalValue modifiedAt() { + return modifiedAt; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + /** Return true if this BinaryResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BinaryResponseImpl binaryResponse = (BinaryResponseImpl) o; + return Objects.equals(this.id, binaryResponse.id) + && Objects.equals(this.to, binaryResponse.to) + && Objects.equals(this.from, binaryResponse.from) + && Objects.equals(this.canceled, binaryResponse.canceled) + && Objects.equals(this.body, binaryResponse.body) + && Objects.equals(this.udh, binaryResponse.udh) + && Objects.equals(this.type, binaryResponse.type) + && Objects.equals(this.createdAt, binaryResponse.createdAt) + && Objects.equals(this.modifiedAt, binaryResponse.modifiedAt) + && Objects.equals(this.deliveryReport, binaryResponse.deliveryReport) + && Objects.equals(this.sendAt, binaryResponse.sendAt) + && Objects.equals(this.expireAt, binaryResponse.expireAt) + && Objects.equals(this.callbackUrl, binaryResponse.callbackUrl) + && Objects.equals(this.clientReference, binaryResponse.clientReference) + && Objects.equals(this.feedbackEnabled, binaryResponse.feedbackEnabled) + && Objects.equals(this.fromTon, binaryResponse.fromTon) + && Objects.equals(this.fromNpi, binaryResponse.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + to, + from, + canceled, + body, + udh, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BinaryResponseImpl {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" canceled: ").append(toIndentedString(canceled)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" udh: ").append(toIndentedString(udh)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements BinaryResponse.Builder { + OptionalValue id = OptionalValue.empty(); + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue canceled = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue udh = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_BINARY); + OptionalValue createdAt = OptionalValue.empty(); + OptionalValue modifiedAt = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_ID) + public Builder setId(String id) { + this.id = OptionalValue.of(id); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_CANCELED) + public Builder setCanceled(Boolean canceled) { + this.canceled = OptionalValue.of(canceled); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_UDH) + public Builder setUdh(String udh) { + this.udh = OptionalValue.of(udh); + return this; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + public Builder setCreatedAt(Instant createdAt) { + this.createdAt = OptionalValue.of(createdAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + public Builder setModifiedAt(Instant modifiedAt) { + this.modifiedAt = OptionalValue.of(modifiedAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + public BinaryResponse build() { + return new BinaryResponseImpl( + id, + to, + from, + canceled, + body, + udh, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + fromTon, + fromNpi); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetails.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetails.java new file mode 100644 index 000000000..740faac60 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetails.java @@ -0,0 +1,102 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +/** DryRunPerRecipientDetails */ +@JsonDeserialize(builder = DryRunPerRecipientDetailsImpl.Builder.class) +public interface DryRunPerRecipientDetails { + + /** + * Get recipient + * + * @return recipient + */ + String getRecipient(); + + /** + * Get numberOfParts + * + * @return numberOfParts + */ + Integer getNumberOfParts(); + + /** + * Get body + * + * @return body + */ + String getBody(); + + /** + * Get encoding + * + * @return encoding + */ + String getEncoding(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new DryRunPerRecipientDetailsImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param recipient see getter + * @return Current builder + * @see #getRecipient + */ + Builder setRecipient(String recipient); + + /** + * see getter + * + * @param numberOfParts see getter + * @return Current builder + * @see #getNumberOfParts + */ + Builder setNumberOfParts(Integer numberOfParts); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param encoding see getter + * @return Current builder + * @see #getEncoding + */ + Builder setEncoding(String encoding); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + DryRunPerRecipientDetails build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetailsImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetailsImpl.java new file mode 100644 index 000000000..829005398 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetailsImpl.java @@ -0,0 +1,175 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import java.util.Objects; + +@JsonPropertyOrder({ + DryRunPerRecipientDetailsImpl.JSON_PROPERTY_RECIPIENT, + DryRunPerRecipientDetailsImpl.JSON_PROPERTY_NUMBER_OF_PARTS, + DryRunPerRecipientDetailsImpl.JSON_PROPERTY_BODY, + DryRunPerRecipientDetailsImpl.JSON_PROPERTY_ENCODING +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class DryRunPerRecipientDetailsImpl implements DryRunPerRecipientDetails { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_RECIPIENT = "recipient"; + + private OptionalValue recipient; + + public static final String JSON_PROPERTY_NUMBER_OF_PARTS = "number_of_parts"; + + private OptionalValue numberOfParts; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_ENCODING = "encoding"; + + private OptionalValue encoding; + + public DryRunPerRecipientDetailsImpl() {} + + protected DryRunPerRecipientDetailsImpl( + OptionalValue recipient, + OptionalValue numberOfParts, + OptionalValue body, + OptionalValue encoding) { + this.recipient = recipient; + this.numberOfParts = numberOfParts; + this.body = body; + this.encoding = encoding; + } + + @JsonIgnore + public String getRecipient() { + return recipient.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue recipient() { + return recipient; + } + + @JsonIgnore + public Integer getNumberOfParts() { + return numberOfParts.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue numberOfParts() { + return numberOfParts; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public String getEncoding() { + return encoding.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_ENCODING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue encoding() { + return encoding; + } + + /** Return true if this DryRunResponse_per_recipient_inner object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DryRunPerRecipientDetailsImpl dryRunResponsePerRecipientInner = + (DryRunPerRecipientDetailsImpl) o; + return Objects.equals(this.recipient, dryRunResponsePerRecipientInner.recipient) + && Objects.equals(this.numberOfParts, dryRunResponsePerRecipientInner.numberOfParts) + && Objects.equals(this.body, dryRunResponsePerRecipientInner.body) + && Objects.equals(this.encoding, dryRunResponsePerRecipientInner.encoding); + } + + @Override + public int hashCode() { + return Objects.hash(recipient, numberOfParts, body, encoding); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DryRunPerRecipientDetailsImpl {\n"); + sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); + sb.append(" numberOfParts: ").append(toIndentedString(numberOfParts)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" encoding: ").append(toIndentedString(encoding)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements DryRunPerRecipientDetails.Builder { + OptionalValue recipient = OptionalValue.empty(); + OptionalValue numberOfParts = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue encoding = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_RECIPIENT) + public Builder setRecipient(String recipient) { + this.recipient = OptionalValue.of(recipient); + return this; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_PARTS) + public Builder setNumberOfParts(Integer numberOfParts) { + this.numberOfParts = OptionalValue.of(numberOfParts); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_ENCODING) + public Builder setEncoding(String encoding) { + this.encoding = OptionalValue.of(encoding); + return this; + } + + public DryRunPerRecipientDetails build() { + return new DryRunPerRecipientDetailsImpl(recipient, numberOfParts, body, encoding); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponse.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponse.java new file mode 100644 index 000000000..819875e30 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponse.java @@ -0,0 +1,88 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.List; + +/** DryRunResponse */ +@JsonDeserialize(builder = DryRunResponseImpl.Builder.class) +public interface DryRunResponse { + + /** + * The number of recipients in the batch + * + * @return numberOfRecipients + */ + Integer getNumberOfRecipients(); + + /** + * The total number of SMS message parts to be sent in the batch + * + * @return numberOfMessages + */ + Integer getNumberOfMessages(); + + /** + * The recipient, the number of message parts to this recipient, the body of the message, and the + * encoding type of each message + * + * @return perRecipient + */ + List getPerRecipient(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new DryRunResponseImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param numberOfRecipients see getter + * @return Current builder + * @see #getNumberOfRecipients + */ + Builder setNumberOfRecipients(Integer numberOfRecipients); + + /** + * see getter + * + * @param numberOfMessages see getter + * @return Current builder + * @see #getNumberOfMessages + */ + Builder setNumberOfMessages(Integer numberOfMessages); + + /** + * see getter + * + * @param perRecipient see getter + * @return Current builder + * @see #getPerRecipient + */ + Builder setPerRecipient(List perRecipient); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + DryRunResponse build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseImpl.java new file mode 100644 index 000000000..eea1b201e --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseImpl.java @@ -0,0 +1,148 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({ + DryRunResponseImpl.JSON_PROPERTY_NUMBER_OF_RECIPIENTS, + DryRunResponseImpl.JSON_PROPERTY_NUMBER_OF_MESSAGES, + DryRunResponseImpl.JSON_PROPERTY_PER_RECIPIENT +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class DryRunResponseImpl implements DryRunResponse { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_NUMBER_OF_RECIPIENTS = "number_of_recipients"; + + private OptionalValue numberOfRecipients; + + public static final String JSON_PROPERTY_NUMBER_OF_MESSAGES = "number_of_messages"; + + private OptionalValue numberOfMessages; + + public static final String JSON_PROPERTY_PER_RECIPIENT = "per_recipient"; + + private OptionalValue> perRecipient; + + public DryRunResponseImpl() {} + + protected DryRunResponseImpl( + OptionalValue numberOfRecipients, + OptionalValue numberOfMessages, + OptionalValue> perRecipient) { + this.numberOfRecipients = numberOfRecipients; + this.numberOfMessages = numberOfMessages; + this.perRecipient = perRecipient; + } + + @JsonIgnore + public Integer getNumberOfRecipients() { + return numberOfRecipients.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue numberOfRecipients() { + return numberOfRecipients; + } + + @JsonIgnore + public Integer getNumberOfMessages() { + return numberOfMessages.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue numberOfMessages() { + return numberOfMessages; + } + + @JsonIgnore + public List getPerRecipient() { + return perRecipient.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PER_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> perRecipient() { + return perRecipient; + } + + /** Return true if this DryRunResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DryRunResponseImpl dryRunResponse = (DryRunResponseImpl) o; + return Objects.equals(this.numberOfRecipients, dryRunResponse.numberOfRecipients) + && Objects.equals(this.numberOfMessages, dryRunResponse.numberOfMessages) + && Objects.equals(this.perRecipient, dryRunResponse.perRecipient); + } + + @Override + public int hashCode() { + return Objects.hash(numberOfRecipients, numberOfMessages, perRecipient); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DryRunResponseImpl {\n"); + sb.append(" numberOfRecipients: ").append(toIndentedString(numberOfRecipients)).append("\n"); + sb.append(" numberOfMessages: ").append(toIndentedString(numberOfMessages)).append("\n"); + sb.append(" perRecipient: ").append(toIndentedString(perRecipient)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements DryRunResponse.Builder { + OptionalValue numberOfRecipients = OptionalValue.empty(); + OptionalValue numberOfMessages = OptionalValue.empty(); + OptionalValue> perRecipient = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_RECIPIENTS) + public Builder setNumberOfRecipients(Integer numberOfRecipients) { + this.numberOfRecipients = OptionalValue.of(numberOfRecipients); + return this; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGES) + public Builder setNumberOfMessages(Integer numberOfMessages) { + this.numberOfMessages = OptionalValue.of(numberOfMessages); + return this; + } + + @JsonProperty(JSON_PROPERTY_PER_RECIPIENT) + public Builder setPerRecipient(List perRecipient) { + this.perRecipient = OptionalValue.of(perRecipient); + return this; + } + + public DryRunResponse build() { + return new DryRunResponseImpl(numberOfRecipients, numberOfMessages, perRecipient); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.java new file mode 100644 index 000000000..3a2fd50f4 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.java @@ -0,0 +1,331 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** MediaResponse */ +@JsonDeserialize(builder = MediaResponseImpl.Builder.class) +public interface MediaResponse extends BatchResponse { + + /** + * Unique identifier for batch + * + * @return id + * @readOnly This field is returned by the server and cannot be modified + */ + String getId(); + + /** + * List of Phone numbers and group IDs that will receive the batch. More info + * + * @return to + */ + List getTo(); + + /** + * Sender number. Required if Automatic Default Originator not configured. + * + * @return from + */ + String getFrom(); + + /** + * Indicates if the batch has been canceled or not. + * + * @return canceled + * @readOnly This field is returned by the server and cannot be modified + */ + Boolean getCanceled(); + + /** + * Get body + * + * @return body + */ + MediaBody getBody(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** Media message */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_MEDIA = new TypeEnum("mt_media"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_MEDIA)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Timestamp for when batch was created. YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return createdAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getCreatedAt(); + + /** + * Timestamp for when batch was last updated. YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return modifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getModifiedAt(); + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set in the future the message will be delayed until send_at occurs. Must be before + * expire_at. If set in the past messages will be sent immediately. + * YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set the system will stop trying to deliver the message at this point. Must be after + * send_at. Default and max is 3 days after send_at. YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Whether or not you want the media included in your message to be checked against Sinch MMS channel best practices. If set to true, your + * message will be rejected if it doesn't conform to the listed recommendations, otherwise no + * validation will be performed. + * + * @return strictValidation + */ + Boolean getStrictValidation(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new MediaResponseImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param id see getter + * @return Current builder + * @see #getId + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setId(String id); + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param canceled see getter + * @return Current builder + * @see #getCanceled + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCanceled(Boolean canceled); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(MediaBody body); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param createdAt see getter + * @return Current builder + * @see #getCreatedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCreatedAt(Instant createdAt); + + /** + * see getter + * + * @param modifiedAt see getter + * @return Current builder + * @see #getModifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setModifiedAt(Instant modifiedAt); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param strictValidation see getter + * @return Current builder + * @see #getStrictValidation + */ + Builder setStrictValidation(Boolean strictValidation); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + MediaResponse build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponseImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponseImpl.java new file mode 100644 index 000000000..cc0d03c06 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponseImpl.java @@ -0,0 +1,524 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + MediaResponseImpl.JSON_PROPERTY_ID, + MediaResponseImpl.JSON_PROPERTY_TO, + MediaResponseImpl.JSON_PROPERTY_FROM, + MediaResponseImpl.JSON_PROPERTY_CANCELED, + MediaResponseImpl.JSON_PROPERTY_BODY, + MediaResponseImpl.JSON_PROPERTY_PARAMETERS, + MediaResponseImpl.JSON_PROPERTY_TYPE, + MediaResponseImpl.JSON_PROPERTY_CREATED_AT, + MediaResponseImpl.JSON_PROPERTY_MODIFIED_AT, + MediaResponseImpl.JSON_PROPERTY_DELIVERY_REPORT, + MediaResponseImpl.JSON_PROPERTY_SEND_AT, + MediaResponseImpl.JSON_PROPERTY_EXPIRE_AT, + MediaResponseImpl.JSON_PROPERTY_CALLBACK_URL, + MediaResponseImpl.JSON_PROPERTY_CLIENT_REFERENCE, + MediaResponseImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + MediaResponseImpl.JSON_PROPERTY_STRICT_VALIDATION +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class MediaResponseImpl implements MediaResponse, BatchResponse { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + + private OptionalValue id; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + + private OptionalValue canceled; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + + private OptionalValue createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + + private OptionalValue modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + + private OptionalValue strictValidation; + + public MediaResponseImpl() {} + + protected MediaResponseImpl( + OptionalValue id, + OptionalValue> to, + OptionalValue from, + OptionalValue canceled, + OptionalValue body, + OptionalValue>> parameters, + OptionalValue type, + OptionalValue createdAt, + OptionalValue modifiedAt, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue strictValidation) { + this.id = id; + this.to = to; + this.from = from; + this.canceled = canceled; + this.body = body; + this.parameters = parameters; + this.type = type; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.strictValidation = strictValidation; + } + + @JsonIgnore + public String getId() { + return id.orElse(null); + } + + @JsonIgnore + public OptionalValue id() { + return id; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public Boolean getCanceled() { + return canceled.orElse(null); + } + + @JsonIgnore + public OptionalValue canceled() { + return canceled; + } + + @JsonIgnore + public MediaBody getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonIgnore + public OptionalValue type() { + return type; + } + + @JsonIgnore + public Instant getCreatedAt() { + return createdAt.orElse(null); + } + + @JsonIgnore + public OptionalValue createdAt() { + return createdAt; + } + + @JsonIgnore + public Instant getModifiedAt() { + return modifiedAt.orElse(null); + } + + @JsonIgnore + public OptionalValue modifiedAt() { + return modifiedAt; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Boolean getStrictValidation() { + return strictValidation.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue strictValidation() { + return strictValidation; + } + + /** Return true if this MediaResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MediaResponseImpl mediaResponse = (MediaResponseImpl) o; + return Objects.equals(this.id, mediaResponse.id) + && Objects.equals(this.to, mediaResponse.to) + && Objects.equals(this.from, mediaResponse.from) + && Objects.equals(this.canceled, mediaResponse.canceled) + && Objects.equals(this.body, mediaResponse.body) + && Objects.equals(this.parameters, mediaResponse.parameters) + && Objects.equals(this.type, mediaResponse.type) + && Objects.equals(this.createdAt, mediaResponse.createdAt) + && Objects.equals(this.modifiedAt, mediaResponse.modifiedAt) + && Objects.equals(this.deliveryReport, mediaResponse.deliveryReport) + && Objects.equals(this.sendAt, mediaResponse.sendAt) + && Objects.equals(this.expireAt, mediaResponse.expireAt) + && Objects.equals(this.callbackUrl, mediaResponse.callbackUrl) + && Objects.equals(this.clientReference, mediaResponse.clientReference) + && Objects.equals(this.feedbackEnabled, mediaResponse.feedbackEnabled) + && Objects.equals(this.strictValidation, mediaResponse.strictValidation); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + to, + from, + canceled, + body, + parameters, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + strictValidation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MediaResponseImpl {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" canceled: ").append(toIndentedString(canceled)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" strictValidation: ").append(toIndentedString(strictValidation)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements MediaResponse.Builder { + OptionalValue id = OptionalValue.empty(); + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue canceled = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_MEDIA); + OptionalValue createdAt = OptionalValue.empty(); + OptionalValue modifiedAt = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue strictValidation = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_ID) + public Builder setId(String id) { + this.id = OptionalValue.of(id); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_CANCELED) + public Builder setCanceled(Boolean canceled) { + this.canceled = OptionalValue.of(canceled); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(MediaBody body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + public Builder setCreatedAt(Instant createdAt) { + this.createdAt = OptionalValue.of(createdAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + public Builder setModifiedAt(Instant modifiedAt) { + this.modifiedAt = OptionalValue.of(modifiedAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + public Builder setStrictValidation(Boolean strictValidation) { + this.strictValidation = OptionalValue.of(strictValidation); + return this; + } + + public MediaResponse build() { + return new MediaResponseImpl( + id, + to, + from, + canceled, + body, + parameters, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + strictValidation); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.java new file mode 100644 index 000000000..5cbeac7e9 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.java @@ -0,0 +1,406 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +/** TextResponse */ +@JsonDeserialize(builder = TextResponseImpl.Builder.class) +public interface TextResponse extends BatchResponse { + + /** + * Unique identifier for batch + * + * @return id + * @readOnly This field is returned by the server and cannot be modified + */ + String getId(); + + /** + * List of Phone numbers and group IDs that will receive the batch. More info + * + * @return to + */ + List getTo(); + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + String getFrom(); + + /** + * Indicates if the batch has been canceled or not. + * + * @return canceled + * @readOnly This field is returned by the server and cannot be modified + */ + Boolean getCanceled(); + + /** + * Contains the parameters that will be used for customizing the message for each recipient. Click here to learn more about + * parameterization. + * + * @return parameters + */ + Map> getParameters(); + + /** + * The message content + * + * @return body + */ + String getBody(); + + /** Regular SMS */ + public class TypeEnum extends EnumDynamic { + public static final TypeEnum MT_TEXT = new TypeEnum("mt_text"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(TypeEnum.class, TypeEnum::new, Arrays.asList(MT_TEXT)); + + private TypeEnum(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static TypeEnum from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(TypeEnum e) { + return ENUM_SUPPORT.valueOf(e); + } + } + + /** + * Timestamp for when batch was created. Formatted as ISO-8601:YYYY-MM-DDThh:mm:ss.SSSZ + * . + * + * @return createdAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getCreatedAt(); + + /** + * Timestamp for when batch was last updated. Formatted as ISO-8601:YYYY-MM-DDThh:mm:ss.SSSZ + * . + * + * @return modifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Instant getModifiedAt(); + + /** + * Get deliveryReport + * + * @return deliveryReport + */ + DeliveryReportType getDeliveryReport(); + + /** + * If set in the future, the message will be delayed until send_at occurs. Must be + * before expire_at. If set in the past, messages will be sent immediately. Formatted + * as ISO-8601: + * YYYY-MM-DDThh:mm:ss.SSSZ. + * + * @return sendAt + */ + Instant getSendAt(); + + /** + * If set, the system will stop trying to deliver the message at this point. Must be after + * send_at. Default and max is 3 days after send_at. Formatted as ISO-8601: YYYY-MM-DDThh:mm:ss.SSSZ + * . + * + * @return expireAt + */ + Instant getExpireAt(); + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + String getCallbackUrl(); + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + String getClientReference(); + + /** + * If set to true, then feedback + * is expected after successful delivery. + * + * @return feedbackEnabled + */ + Boolean getFeedbackEnabled(); + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + Boolean getFlashMessage(); + + /** + * If set to true the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + Boolean getTruncateConcat(); + + /** + * Message will be dispatched only if it is not split to more parts than Max Number of Message + * Parts + * + *

minimum: 1 + * + * @return maxNumberOfMessageParts + */ + Integer getMaxNumberOfMessageParts(); + + /** + * The type of number for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 6 + * + * @return fromTon + */ + Integer getFromTon(); + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. + * + *

minimum: 0 maximum: 18 + * + * @return fromNpi + */ + Integer getFromNpi(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new TextResponseImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param id see getter + * @return Current builder + * @see #getId + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setId(String id); + + /** + * see getter + * + * @param to see getter + * @return Current builder + * @see #getTo + */ + Builder setTo(List to); + + /** + * see getter + * + * @param from see getter + * @return Current builder + * @see #getFrom + */ + Builder setFrom(String from); + + /** + * see getter + * + * @param canceled see getter + * @return Current builder + * @see #getCanceled + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCanceled(Boolean canceled); + + /** + * see getter + * + * @param parameters see getter + * @return Current builder + * @see #getParameters + */ + Builder setParameters(Map> parameters); + + /** + * see getter + * + * @param body see getter + * @return Current builder + * @see #getBody + */ + Builder setBody(String body); + + /** + * see getter + * + * @param createdAt see getter + * @return Current builder + * @see #getCreatedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setCreatedAt(Instant createdAt); + + /** + * see getter + * + * @param modifiedAt see getter + * @return Current builder + * @see #getModifiedAt + * @readOnly This field is returned by the server and cannot be modified + */ + Builder setModifiedAt(Instant modifiedAt); + + /** + * see getter + * + * @param deliveryReport see getter + * @return Current builder + * @see #getDeliveryReport + */ + Builder setDeliveryReport(DeliveryReportType deliveryReport); + + /** + * see getter + * + * @param sendAt see getter + * @return Current builder + * @see #getSendAt + */ + Builder setSendAt(Instant sendAt); + + /** + * see getter + * + * @param expireAt see getter + * @return Current builder + * @see #getExpireAt + */ + Builder setExpireAt(Instant expireAt); + + /** + * see getter + * + * @param callbackUrl see getter + * @return Current builder + * @see #getCallbackUrl + */ + Builder setCallbackUrl(String callbackUrl); + + /** + * see getter + * + * @param clientReference see getter + * @return Current builder + * @see #getClientReference + */ + Builder setClientReference(String clientReference); + + /** + * see getter + * + * @param feedbackEnabled see getter + * @return Current builder + * @see #getFeedbackEnabled + */ + Builder setFeedbackEnabled(Boolean feedbackEnabled); + + /** + * see getter + * + * @param flashMessage see getter + * @return Current builder + * @see #getFlashMessage + */ + Builder setFlashMessage(Boolean flashMessage); + + /** + * see getter + * + * @param truncateConcat see getter + * @return Current builder + * @see #getTruncateConcat + */ + Builder setTruncateConcat(Boolean truncateConcat); + + /** + * see getter + * + * @param maxNumberOfMessageParts see getter + * @return Current builder + * @see #getMaxNumberOfMessageParts + */ + Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts); + + /** + * see getter + * + * @param fromTon see getter + * @return Current builder + * @see #getFromTon + */ + Builder setFromTon(Integer fromTon); + + /** + * see getter + * + * @param fromNpi see getter + * @return Current builder + * @see #getFromNpi + */ + Builder setFromNpi(Integer fromNpi); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + TextResponse build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponseImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponseImpl.java new file mode 100644 index 000000000..eb8a3cc9b --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponseImpl.java @@ -0,0 +1,642 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import java.time.Instant; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@JsonPropertyOrder({ + TextResponseImpl.JSON_PROPERTY_ID, + TextResponseImpl.JSON_PROPERTY_TO, + TextResponseImpl.JSON_PROPERTY_FROM, + TextResponseImpl.JSON_PROPERTY_CANCELED, + TextResponseImpl.JSON_PROPERTY_PARAMETERS, + TextResponseImpl.JSON_PROPERTY_BODY, + TextResponseImpl.JSON_PROPERTY_TYPE, + TextResponseImpl.JSON_PROPERTY_CREATED_AT, + TextResponseImpl.JSON_PROPERTY_MODIFIED_AT, + TextResponseImpl.JSON_PROPERTY_DELIVERY_REPORT, + TextResponseImpl.JSON_PROPERTY_SEND_AT, + TextResponseImpl.JSON_PROPERTY_EXPIRE_AT, + TextResponseImpl.JSON_PROPERTY_CALLBACK_URL, + TextResponseImpl.JSON_PROPERTY_CLIENT_REFERENCE, + TextResponseImpl.JSON_PROPERTY_FEEDBACK_ENABLED, + TextResponseImpl.JSON_PROPERTY_FLASH_MESSAGE, + TextResponseImpl.JSON_PROPERTY_TRUNCATE_CONCAT, + TextResponseImpl.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + TextResponseImpl.JSON_PROPERTY_FROM_TON, + TextResponseImpl.JSON_PROPERTY_FROM_NPI +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class TextResponseImpl implements TextResponse, BatchResponse { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_ID = "id"; + + private OptionalValue id; + + public static final String JSON_PROPERTY_TO = "to"; + + private OptionalValue> to; + + public static final String JSON_PROPERTY_FROM = "from"; + + private OptionalValue from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + + private OptionalValue canceled; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + + private OptionalValue>> parameters; + + public static final String JSON_PROPERTY_BODY = "body"; + + private OptionalValue body; + + public static final String JSON_PROPERTY_TYPE = "type"; + + private OptionalValue type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + + private OptionalValue createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + + private OptionalValue modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + + private OptionalValue deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + + private OptionalValue sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + + private OptionalValue expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + + private OptionalValue callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + + private OptionalValue clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + + private OptionalValue feedbackEnabled; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + + private OptionalValue flashMessage; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + + private OptionalValue truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + + private OptionalValue maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + + private OptionalValue fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + + private OptionalValue fromNpi; + + public TextResponseImpl() {} + + protected TextResponseImpl( + OptionalValue id, + OptionalValue> to, + OptionalValue from, + OptionalValue canceled, + OptionalValue>> parameters, + OptionalValue body, + OptionalValue type, + OptionalValue createdAt, + OptionalValue modifiedAt, + OptionalValue deliveryReport, + OptionalValue sendAt, + OptionalValue expireAt, + OptionalValue callbackUrl, + OptionalValue clientReference, + OptionalValue feedbackEnabled, + OptionalValue flashMessage, + OptionalValue truncateConcat, + OptionalValue maxNumberOfMessageParts, + OptionalValue fromTon, + OptionalValue fromNpi) { + this.id = id; + this.to = to; + this.from = from; + this.canceled = canceled; + this.parameters = parameters; + this.body = body; + this.type = type; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + this.flashMessage = flashMessage; + this.truncateConcat = truncateConcat; + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + @JsonIgnore + public String getId() { + return id.orElse(null); + } + + @JsonIgnore + public OptionalValue id() { + return id; + } + + @JsonIgnore + public List getTo() { + return to.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> to() { + return to; + } + + @JsonIgnore + public String getFrom() { + return from.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue from() { + return from; + } + + @JsonIgnore + public Boolean getCanceled() { + return canceled.orElse(null); + } + + @JsonIgnore + public OptionalValue canceled() { + return canceled; + } + + @JsonIgnore + public Map> getParameters() { + return parameters.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue>> parameters() { + return parameters; + } + + @JsonIgnore + public String getBody() { + return body.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue body() { + return body; + } + + @JsonIgnore + public TypeEnum getType() { + return type.orElse(null); + } + + @JsonIgnore + public OptionalValue type() { + return type; + } + + @JsonIgnore + public Instant getCreatedAt() { + return createdAt.orElse(null); + } + + @JsonIgnore + public OptionalValue createdAt() { + return createdAt; + } + + @JsonIgnore + public Instant getModifiedAt() { + return modifiedAt.orElse(null); + } + + @JsonIgnore + public OptionalValue modifiedAt() { + return modifiedAt; + } + + @JsonIgnore + public DeliveryReportType getDeliveryReport() { + return deliveryReport.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue deliveryReport() { + return deliveryReport; + } + + @JsonIgnore + public Instant getSendAt() { + return sendAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue sendAt() { + return sendAt; + } + + @JsonIgnore + public Instant getExpireAt() { + return expireAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue expireAt() { + return expireAt; + } + + @JsonIgnore + public String getCallbackUrl() { + return callbackUrl.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue callbackUrl() { + return callbackUrl; + } + + @JsonIgnore + public String getClientReference() { + return clientReference.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue clientReference() { + return clientReference; + } + + @JsonIgnore + public Boolean getFeedbackEnabled() { + return feedbackEnabled.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue feedbackEnabled() { + return feedbackEnabled; + } + + @JsonIgnore + public Boolean getFlashMessage() { + return flashMessage.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue flashMessage() { + return flashMessage; + } + + @JsonIgnore + public Boolean getTruncateConcat() { + return truncateConcat.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue truncateConcat() { + return truncateConcat; + } + + @JsonIgnore + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue maxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonIgnore + public Integer getFromTon() { + return fromTon.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromTon() { + return fromTon; + } + + @JsonIgnore + public Integer getFromNpi() { + return fromNpi.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue fromNpi() { + return fromNpi; + } + + /** Return true if this TextResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TextResponseImpl textResponse = (TextResponseImpl) o; + return Objects.equals(this.id, textResponse.id) + && Objects.equals(this.to, textResponse.to) + && Objects.equals(this.from, textResponse.from) + && Objects.equals(this.canceled, textResponse.canceled) + && Objects.equals(this.parameters, textResponse.parameters) + && Objects.equals(this.body, textResponse.body) + && Objects.equals(this.type, textResponse.type) + && Objects.equals(this.createdAt, textResponse.createdAt) + && Objects.equals(this.modifiedAt, textResponse.modifiedAt) + && Objects.equals(this.deliveryReport, textResponse.deliveryReport) + && Objects.equals(this.sendAt, textResponse.sendAt) + && Objects.equals(this.expireAt, textResponse.expireAt) + && Objects.equals(this.callbackUrl, textResponse.callbackUrl) + && Objects.equals(this.clientReference, textResponse.clientReference) + && Objects.equals(this.feedbackEnabled, textResponse.feedbackEnabled) + && Objects.equals(this.flashMessage, textResponse.flashMessage) + && Objects.equals(this.truncateConcat, textResponse.truncateConcat) + && Objects.equals(this.maxNumberOfMessageParts, textResponse.maxNumberOfMessageParts) + && Objects.equals(this.fromTon, textResponse.fromTon) + && Objects.equals(this.fromNpi, textResponse.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + to, + from, + canceled, + parameters, + body, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TextResponseImpl {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" canceled: ").append(toIndentedString(canceled)).append("\n"); + sb.append(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" deliveryReport: ").append(toIndentedString(deliveryReport)).append("\n"); + sb.append(" sendAt: ").append(toIndentedString(sendAt)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" feedbackEnabled: ").append(toIndentedString(feedbackEnabled)).append("\n"); + sb.append(" flashMessage: ").append(toIndentedString(flashMessage)).append("\n"); + sb.append(" truncateConcat: ").append(toIndentedString(truncateConcat)).append("\n"); + sb.append(" maxNumberOfMessageParts: ") + .append(toIndentedString(maxNumberOfMessageParts)) + .append("\n"); + sb.append(" fromTon: ").append(toIndentedString(fromTon)).append("\n"); + sb.append(" fromNpi: ").append(toIndentedString(fromNpi)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements TextResponse.Builder { + OptionalValue id = OptionalValue.empty(); + OptionalValue> to = OptionalValue.empty(); + OptionalValue from = OptionalValue.empty(); + OptionalValue canceled = OptionalValue.empty(); + OptionalValue>> parameters = OptionalValue.empty(); + OptionalValue body = OptionalValue.empty(); + OptionalValue type = OptionalValue.of(TypeEnum.MT_TEXT); + OptionalValue createdAt = OptionalValue.empty(); + OptionalValue modifiedAt = OptionalValue.empty(); + OptionalValue deliveryReport = OptionalValue.empty(); + OptionalValue sendAt = OptionalValue.empty(); + OptionalValue expireAt = OptionalValue.empty(); + OptionalValue callbackUrl = OptionalValue.empty(); + OptionalValue clientReference = OptionalValue.empty(); + OptionalValue feedbackEnabled = OptionalValue.empty(); + OptionalValue flashMessage = OptionalValue.empty(); + OptionalValue truncateConcat = OptionalValue.empty(); + OptionalValue maxNumberOfMessageParts = OptionalValue.empty(); + OptionalValue fromTon = OptionalValue.empty(); + OptionalValue fromNpi = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_ID) + public Builder setId(String id) { + this.id = OptionalValue.of(id); + return this; + } + + @JsonProperty(JSON_PROPERTY_TO) + public Builder setTo(List to) { + this.to = OptionalValue.of(to); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM) + public Builder setFrom(String from) { + this.from = OptionalValue.of(from); + return this; + } + + @JsonProperty(JSON_PROPERTY_CANCELED) + public Builder setCanceled(Boolean canceled) { + this.canceled = OptionalValue.of(canceled); + return this; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + public Builder setParameters(Map> parameters) { + this.parameters = OptionalValue.of(parameters); + return this; + } + + @JsonProperty(JSON_PROPERTY_BODY) + public Builder setBody(String body) { + this.body = OptionalValue.of(body); + return this; + } + + @JsonProperty(JSON_PROPERTY_CREATED_AT) + public Builder setCreatedAt(Instant createdAt) { + this.createdAt = OptionalValue.of(createdAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + public Builder setModifiedAt(Instant modifiedAt) { + this.modifiedAt = OptionalValue.of(modifiedAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + public Builder setDeliveryReport(DeliveryReportType deliveryReport) { + this.deliveryReport = OptionalValue.of(deliveryReport); + return this; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + public Builder setSendAt(Instant sendAt) { + this.sendAt = OptionalValue.of(sendAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + public Builder setExpireAt(Instant expireAt) { + this.expireAt = OptionalValue.of(expireAt); + return this; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = OptionalValue.of(callbackUrl); + return this; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + public Builder setClientReference(String clientReference) { + this.clientReference = OptionalValue.of(clientReference); + return this; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + public Builder setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = OptionalValue.of(feedbackEnabled); + return this; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + public Builder setFlashMessage(Boolean flashMessage) { + this.flashMessage = OptionalValue.of(flashMessage); + return this; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + public Builder setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = OptionalValue.of(truncateConcat); + return this; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + public Builder setFromTon(Integer fromTon) { + this.fromTon = OptionalValue.of(fromTon); + return this; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + public Builder setFromNpi(Integer fromNpi) { + this.fromNpi = OptionalValue.of(fromNpi); + return this; + } + + public TextResponse build() { + return new TextResponseImpl( + id, + to, + from, + canceled, + parameters, + body, + type, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchList.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchList.java new file mode 100644 index 000000000..695ce3e06 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchList.java @@ -0,0 +1,104 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response.internal; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.util.List; + +/** ApiBatchList */ +@JsonDeserialize(builder = ApiBatchListImpl.Builder.class) +public interface ApiBatchList { + + /** + * The total number of entries matching the given filters. + * + * @return count + */ + Long getCount(); + + /** + * The requested page. + * + * @return page + */ + Integer getPage(); + + /** + * The page of batches matching the given filters. + * + * @return batches + */ + List getBatches(); + + /** + * The number of entries returned in this request. + * + * @return pageSize + */ + Integer getPageSize(); + + /** + * Getting builder + * + * @return New Builder instance + */ + static Builder builder() { + return new ApiBatchListImpl.Builder(); + } + + /** Dedicated Builder */ + interface Builder { + + /** + * see getter + * + * @param count see getter + * @return Current builder + * @see #getCount + */ + Builder setCount(Long count); + + /** + * see getter + * + * @param page see getter + * @return Current builder + * @see #getPage + */ + Builder setPage(Integer page); + + /** + * see getter + * + * @param batches see getter + * @return Current builder + * @see #getBatches + */ + Builder setBatches(List batches); + + /** + * see getter + * + * @param pageSize see getter + * @return Current builder + * @see #getPageSize + */ + Builder setPageSize(Integer pageSize); + + /** + * Create instance + * + * @return The instance build with current builder values + */ + ApiBatchList build(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchListImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchListImpl.java new file mode 100644 index 000000000..24da89567 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/ApiBatchListImpl.java @@ -0,0 +1,176 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response.internal; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.util.List; +import java.util.Objects; + +@JsonPropertyOrder({ + ApiBatchListImpl.JSON_PROPERTY_COUNT, + ApiBatchListImpl.JSON_PROPERTY_PAGE, + ApiBatchListImpl.JSON_PROPERTY_BATCHES, + ApiBatchListImpl.JSON_PROPERTY_PAGE_SIZE +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class ApiBatchListImpl implements ApiBatchList { + private static final long serialVersionUID = 1L; + + public static final String JSON_PROPERTY_COUNT = "count"; + + private OptionalValue count; + + public static final String JSON_PROPERTY_PAGE = "page"; + + private OptionalValue page; + + public static final String JSON_PROPERTY_BATCHES = "batches"; + + private OptionalValue> batches; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + + private OptionalValue pageSize; + + public ApiBatchListImpl() {} + + protected ApiBatchListImpl( + OptionalValue count, + OptionalValue page, + OptionalValue> batches, + OptionalValue pageSize) { + this.count = count; + this.page = page; + this.batches = batches; + this.pageSize = pageSize; + } + + @JsonIgnore + public Long getCount() { + return count.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue count() { + return count; + } + + @JsonIgnore + public Integer getPage() { + return page.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue page() { + return page; + } + + @JsonIgnore + public List getBatches() { + return batches.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_BATCHES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue> batches() { + return batches; + } + + @JsonIgnore + public Integer getPageSize() { + return pageSize.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OptionalValue pageSize() { + return pageSize; + } + + /** Return true if this ApiBatchList object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiBatchListImpl apiBatchList = (ApiBatchListImpl) o; + return Objects.equals(this.count, apiBatchList.count) + && Objects.equals(this.page, apiBatchList.page) + && Objects.equals(this.batches, apiBatchList.batches) + && Objects.equals(this.pageSize, apiBatchList.pageSize); + } + + @Override + public int hashCode() { + return Objects.hash(count, page, batches, pageSize); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiBatchListImpl {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" batches: ").append(toIndentedString(batches)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + @JsonPOJOBuilder(withPrefix = "set") + static class Builder implements ApiBatchList.Builder { + OptionalValue count = OptionalValue.empty(); + OptionalValue page = OptionalValue.empty(); + OptionalValue> batches = OptionalValue.empty(); + OptionalValue pageSize = OptionalValue.empty(); + + @JsonProperty(JSON_PROPERTY_COUNT) + public Builder setCount(Long count) { + this.count = OptionalValue.of(count); + return this; + } + + @JsonProperty(JSON_PROPERTY_PAGE) + public Builder setPage(Integer page) { + this.page = OptionalValue.of(page); + return this; + } + + @JsonProperty(JSON_PROPERTY_BATCHES) + public Builder setBatches(List batches) { + this.batches = OptionalValue.of(batches); + return this; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + public Builder setPageSize(Integer pageSize) { + this.pageSize = OptionalValue.of(pageSize); + return this; + } + + public ApiBatchList build() { + return new ApiBatchListImpl(count, page, batches, pageSize); + } + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternal.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternal.java new file mode 100644 index 000000000..c62d5fc04 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternal.java @@ -0,0 +1,16 @@ +/* + * API Overview | Sinch + * + * OpenAPI document version: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.v1.batches.response.internal; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; + +@JsonDeserialize(using = BatchResponseInternalImpl.BatchResponseInternalImplDeserializer.class) +public interface BatchResponseInternal {} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternalImpl.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternalImpl.java new file mode 100644 index 000000000..57d7e0cea --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/v1/batches/response/internal/BatchResponseInternalImpl.java @@ -0,0 +1,402 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response.internal; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import com.sinch.sdk.core.models.AbstractOpenApiSchema; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BinaryResponseImpl; +import com.sinch.sdk.domains.sms.models.v1.batches.response.MediaResponseImpl; +import com.sinch.sdk.domains.sms.models.v1.batches.response.TextResponseImpl; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@JsonDeserialize(using = BatchResponseInternalImpl.BatchResponseInternalImplDeserializer.class) +@JsonSerialize(using = BatchResponseInternalImpl.BatchResponseInternalImplSerializer.class) +public class BatchResponseInternalImpl extends AbstractOpenApiSchema + implements BatchResponseInternal { + private static final Logger log = Logger.getLogger(BatchResponseInternalImpl.class.getName()); + + public static final class BatchResponseInternalImplSerializer + extends StdSerializer { + private static final long serialVersionUID = 1L; + + public BatchResponseInternalImplSerializer(Class t) { + super(t); + } + + public BatchResponseInternalImplSerializer() { + this(null); + } + + @Override + public void serialize( + BatchResponseInternalImpl value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static final class BatchResponseInternalImplDeserializer + extends StdDeserializer { + + private static final long serialVersionUID = 1L; + + public BatchResponseInternalImplDeserializer() { + this(BatchResponseInternalImpl.class); + } + + public BatchResponseInternalImplDeserializer(Class vc) { + super(vc); + } + + @Override + public BatchResponseInternalImpl deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + BatchResponseInternalImpl newBatchResponseInternalImpl = new BatchResponseInternalImpl(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "mt_binary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + case "mt_media": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + case "mt_text": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + case "BinaryResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + case "MediaResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + case "TextResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseImpl.class); + newBatchResponseInternalImpl.setActualInstance(deserialized); + return newBatchResponseInternalImpl; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for BatchResponseInternalImpl." + + " Possible values: mt_binary mt_media mt_text BinaryResponse MediaResponse" + + " TextResponse", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize BinaryResponseImpl + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BinaryResponseImpl.class.equals(Integer.class) + || BinaryResponseImpl.class.equals(Long.class) + || BinaryResponseImpl.class.equals(Float.class) + || BinaryResponseImpl.class.equals(Double.class) + || BinaryResponseImpl.class.equals(Boolean.class) + || BinaryResponseImpl.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((BinaryResponseImpl.class.equals(Integer.class) + || BinaryResponseImpl.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((BinaryResponseImpl.class.equals(Float.class) + || BinaryResponseImpl.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (BinaryResponseImpl.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (BinaryResponseImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseImpl.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'BinaryResponseImpl'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BinaryResponseImpl'", e); + } + + // deserialize MediaResponseImpl + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MediaResponseImpl.class.equals(Integer.class) + || MediaResponseImpl.class.equals(Long.class) + || MediaResponseImpl.class.equals(Float.class) + || MediaResponseImpl.class.equals(Double.class) + || MediaResponseImpl.class.equals(Boolean.class) + || MediaResponseImpl.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MediaResponseImpl.class.equals(Integer.class) + || MediaResponseImpl.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MediaResponseImpl.class.equals(Float.class) + || MediaResponseImpl.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MediaResponseImpl.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MediaResponseImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseImpl.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'MediaResponseImpl'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MediaResponseImpl'", e); + } + + // deserialize TextResponseImpl + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (TextResponseImpl.class.equals(Integer.class) + || TextResponseImpl.class.equals(Long.class) + || TextResponseImpl.class.equals(Float.class) + || TextResponseImpl.class.equals(Double.class) + || TextResponseImpl.class.equals(Boolean.class) + || TextResponseImpl.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((TextResponseImpl.class.equals(Integer.class) + || TextResponseImpl.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((TextResponseImpl.class.equals(Float.class) + || TextResponseImpl.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (TextResponseImpl.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (TextResponseImpl.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseImpl.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'TextResponseImpl'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'TextResponseImpl'", e); + } + + if (match == 1) { + BatchResponseInternalImpl ret = new BatchResponseInternalImpl(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for BatchResponseInternalImpl: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public BatchResponseInternalImpl getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "BatchResponseInternalImpl cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public BatchResponseInternalImpl() { + super("oneOf", Boolean.FALSE); + } + + public BatchResponseInternalImpl(BinaryResponseImpl o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public BatchResponseInternalImpl(MediaResponseImpl o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public BatchResponseInternalImpl(TextResponseImpl o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("BinaryResponseImpl", BinaryResponseImpl.class); + schemas.put("MediaResponseImpl", MediaResponseImpl.class); + schemas.put("TextResponseImpl", TextResponseImpl.class); + JSONNavigator.registerDescendants( + BatchResponseInternalImpl.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("mt_binary", BinaryResponseImpl.class); + mappings.put("mt_media", MediaResponseImpl.class); + mappings.put("mt_text", TextResponseImpl.class); + mappings.put("BinaryResponse", BinaryResponseImpl.class); + mappings.put("MediaResponse", MediaResponseImpl.class); + mappings.put("TextResponse", TextResponseImpl.class); + mappings.put("Batch", BatchResponseInternalImpl.class); + JSONNavigator.registerDiscriminator(BatchResponseInternalImpl.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return BatchResponseInternalImpl.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: BinaryResponseImpl, MediaResponseImpl, TextResponseImpl + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSONNavigator.isInstanceOf(BinaryResponseImpl.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MediaResponseImpl.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(TextResponseImpl.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be BinaryResponseImpl, MediaResponseImpl, TextResponseImpl"); + } + + /** + * Get the actual instance, which can be the following: BinaryResponseImpl, MediaResponseImpl, + * TextResponseImpl + * + * @return The actual instance (BinaryResponseImpl, MediaResponseImpl, TextResponseImpl) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `BinaryResponseImpl`. If the actual instance is not + * `BinaryResponseImpl`, the ClassCastException will be thrown. + * + * @return The actual instance of `BinaryResponseImpl` + * @throws ClassCastException if the instance is not `BinaryResponseImpl` + */ + public BinaryResponseImpl getBinaryResponseImpl() throws ClassCastException { + return (BinaryResponseImpl) super.getActualInstance(); + } + + /** + * Get the actual instance of `MediaResponseImpl`. If the actual instance is not + * `MediaResponseImpl`, the ClassCastException will be thrown. + * + * @return The actual instance of `MediaResponseImpl` + * @throws ClassCastException if the instance is not `MediaResponseImpl` + */ + public MediaResponseImpl getMediaResponseImpl() throws ClassCastException { + return (MediaResponseImpl) super.getActualInstance(); + } + + /** + * Get the actual instance of `TextResponseImpl`. If the actual instance is not + * `TextResponseImpl`, the ClassCastException will be thrown. + * + * @return The actual instance of `TextResponseImpl` + * @throws ClassCastException if the instance is not `TextResponseImpl` + */ + public TextResponseImpl getTextResponseImpl() throws ClassCastException { + return (TextResponseImpl) super.getActualInstance(); + } + + public static class Deserializer + extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer( + Class vc) { + super(vc); + } + + @Override + public com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException { + + Object deserialized = jp.readValueAs(BatchResponseInternalImpl.class).getActualInstance(); + if (null == deserialized) { + return null; + } + if (!(deserialized + instanceof com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse)) { + log.log(Level.SEVERE, "Input data does not match schema ", deserialized); + return null; + } + + return (com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse) deserialized; + } + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDtoTest.java index b5d08594f..404545cf2 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDtoTest.java @@ -14,10 +14,10 @@ @TestWithResources class BinaryResponseDtoTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") BinaryResponseDto loadedDto; - @GivenTextResource("/domains/sms/v1/BinaryResponseDto.json") + @GivenTextResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") String jsonStringDto; BinaryResponseDto dto = diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/DryRunResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/DryRunResponseDtoTest.java index 5150bad2f..c17327964 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/DryRunResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/DryRunResponseDtoTest.java @@ -14,10 +14,10 @@ @TestWithResources class DryRunResponseDtoTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/DryRunResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") DryRun200ResponseDto loadedDto; - @GivenTextResource("/domains/sms/v1/DryRunResponseDto.json") + @GivenTextResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") String jsonStringDto; DryRun200ResponseDto dto = diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java index 83af2afdd..57bf262d8 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java @@ -1,9 +1,7 @@ package com.sinch.sdk.domains.sms.models.dto.v1; import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; -import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.fasterxml.jackson.core.JsonProcessingException; import com.sinch.sdk.BaseTest; import java.time.OffsetDateTime; import java.util.AbstractMap; @@ -12,19 +10,14 @@ import java.util.stream.Collectors; import java.util.stream.Stream; import org.assertj.core.api.Assertions; -import org.json.JSONException; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.skyscreamer.jsonassert.JSONAssert; @TestWithResources class MediaResponseDtoTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") MediaResponseDto loadedDto; - @GivenTextResource("/domains/sms/v1/MediaResponseDto.json") - String jsonStringDto; - ParameterObjDto parameterObjDto = new ParameterObjDto(); MediaResponseDto mediaDTO = @@ -56,14 +49,6 @@ void deserialize() { Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(mediaDTO); } - @Test - void serialize() throws JsonProcessingException, JSONException { - - String serializedString = objectMapper.writeValueAsString(mediaDTO); - - JSONAssert.assertEquals(jsonStringDto, serializedString, true); - } - @BeforeEach void setUp() { parameterObjDto.put( diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java index a1507cefa..d9caae8a5 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java @@ -16,13 +16,13 @@ @TestWithResources class SendSMSRequestDtoTest extends BaseTest { - @GivenTextResource("/domains/sms/v1/SendSMSBinaryRequestDto.json") + @GivenTextResource("/domains/sms/v1/BinaryRequestDto.json") String jsonRequestBinaryDto; - @GivenTextResource("/domains/sms/v1/SendSMSTextRequestDto.json") + @GivenTextResource("/domains/sms/v1/batches/request/TextRequestDto.json") String jsonRequestTextDto; - @GivenTextResource("/domains/sms/v1/SendSMSMediaRequestDto.json") + @GivenTextResource("/domains/sms/v1/MediaRequestDto.json") String jsonRequestMediaDto; @Test diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSResponseDtoTest.java index 63284a7df..949037f15 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSResponseDtoTest.java @@ -17,13 +17,13 @@ @TestWithResources class SendSMSResponseDtoTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") SendSMS201ResponseDto loadedBinary; - @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") SendSMS201ResponseDto loadedText; - @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") SendSMS201ResponseDto loadedMedia; ParameterObjDto parameterObjDto = new ParameterObjDto(); diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDtoTest.java index 2f14db82f..debea95fa 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDtoTest.java @@ -19,10 +19,10 @@ @TestWithResources class TextResponseDtoTest extends BaseTest { - @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") TextResponseDto loadedDto; - @GivenTextResource("/domains/sms/v1/TextResponseDto.json") + @GivenTextResource("/domains/sms/v1/batches/response/TextResponseDto.json") String jsonStringDto; ParameterObjDto parameterObjDto = new ParameterObjDto(); diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java new file mode 100644 index 000000000..de3daff13 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/MediaBodyDtoTest.java @@ -0,0 +1,41 @@ +package com.sinch.sdk.domains.sms.models.v1.batches; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class MediaBodyDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/batches/MediaBodyDto.json") + String jsonMediaBodyDto; + + @GivenJsonResource("/domains/sms/v1/batches/MediaBodyDto.json") + MediaBody loadedMediaBodyDto; + + public static final MediaBody mediaBodyDto = + MediaBody.builder() + .setSubject("subject field") + .setUrl("https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .setMessage("Hi ${name} ({an identifier}) ! How are you?") + .build(); + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(mediaBodyDto); + + JSONAssert.assertEquals(jsonMediaBodyDto, serializedString, true); + } + + @Test + void deserialize() { + + TestHelpers.recursiveEquals(loadedMediaBodyDto, mediaBodyDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestDtoTest.java new file mode 100644 index 000000000..67f4ba8b3 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendDeliveryFeedbackRequestDtoTest.java @@ -0,0 +1,29 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import java.util.Arrays; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class SendDeliveryFeedbackRequestDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/batches/request/SendDeliveryFeedbackRequestDto.json") + String jsonSendDeliveryFeedbackRequestDto; + + @Test + void sendDeliveryFeedbackRequestRequestDto() throws JsonProcessingException, JSONException { + + SendDeliveryFeedbackRequest requestDTO = + SendDeliveryFeedbackRequest.builder() + .setRecipients(Arrays.asList("+15551231234", "+15987365412")) + .build(); + + String serializedString = objectMapper.writeValueAsString(requestDTO); + + JSONAssert.assertEquals(jsonSendDeliveryFeedbackRequestDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendRequestDtoTest.java new file mode 100644 index 000000000..a614f0693 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/SendRequestDtoTest.java @@ -0,0 +1,141 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBodyDtoTest; +import java.time.Instant; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class SendRequestDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/batches/request/BinaryRequestDto.json") + String jsonRequestBinaryDto; + + @GivenTextResource("/domains/sms/v1/batches/request/TextRequestDto.json") + String jsonRequestTextDto; + + @GivenTextResource("/domains/sms/v1/batches/request/MediaRequestDto.json") + String jsonRequestMediaDto; + + @Test + void serializeBinaryRequestDto() throws JsonProcessingException, JSONException { + + BinaryRequest binaryRequestDTO = + BinaryRequest.builder() + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setUdh("foo udh") + .setFrom("+15551231234") + .setDeliveryReport(DeliveryReportType.NONE) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setCallbackUrl("callback url") + .setClientReference("myReference") + .setFeedbackEnabled(false) + .setFromTon(6) + .setFromNpi(18) + .build(); + + String serializedString = objectMapper.writeValueAsString(binaryRequestDTO); + + JSONAssert.assertEquals(jsonRequestBinaryDto, serializedString, true); + } + + @Test + void serializeTextRequestDto() throws JsonProcessingException, JSONException { + + Map anIdentifierParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "an identifier value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "an identifier value for 15551256344")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "name value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "name value for 15551256344"), + new AbstractMap.SimpleEntry<>("default", "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + TextRequest textRequestDTO = + TextRequest.builder() + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setFrom("+15551231234") + .setDeliveryReport(DeliveryReportType.NONE) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setCallbackUrl("callback url") + .setClientReference("myReference") + .setFeedbackEnabled(false) + .setFlashMessage(true) + .setTruncateConcat(true) + .setMaxNumberOfMessageParts(1) + .setFromTon(6) + .setFromNpi(18) + .setParameters(parameters) + .build(); + + String serializedString = objectMapper.writeValueAsString(textRequestDTO); + + JSONAssert.assertEquals(jsonRequestTextDto, serializedString, true); + } + + @Test + void serializeMediaRequestDto() throws JsonProcessingException, JSONException { + + Map anIdentifierParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "an identifier value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "an identifier value for 15551256344")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "name value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "name value for 15551256344"), + new AbstractMap.SimpleEntry<>("default", "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + MediaRequest mediaRequestDTO = + MediaRequest.builder() + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setBody(MediaBodyDtoTest.mediaBodyDto) + .setFrom("+15551231234") + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl("callback url") + .setClientReference("client reference") + .setFeedbackEnabled(false) + .setStrictValidation(true) + .setParameters(parameters) + .build(); + + String serializedString = objectMapper.writeValueAsString(mediaRequestDTO); + + JSONAssert.assertEquals(jsonRequestMediaDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateRequestDtoTest.java new file mode 100644 index 000000000..71c3be634 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateRequestDtoTest.java @@ -0,0 +1,130 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.request; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBody; +import java.time.Instant; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class UpdateRequestDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/batches/request/UpdateBinaryRequestDto.json") + String jsonRequestBinaryDto; + + @GivenTextResource("/domains/sms/v1/batches/request/UpdateTextRequestDto.json") + String jsonRequestTextDto; + + @GivenTextResource("/domains/sms/v1/batches/request/UpdateMediaRequestDto.json") + String jsonRequestMediaDto; + + Map anIdentifierParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "an identifier value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "an identifier value for 15551256344")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "name value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "name value for 15551256344"), + new AbstractMap.SimpleEntry<>("default", "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + @Test + void serializeBinaryRequestDto() throws JsonProcessingException, JSONException { + + UpdateBinaryRequest binaryRequestDTO = + UpdateBinaryRequest.builder() + .setFrom("+15551231234") + .setToAdd(Arrays.asList("+15551231234", "+15987365412")) + .setToRemove(Arrays.asList("+0123456789", "+9876543210")) + .setDeliveryReport(DeliveryReportType.FULL) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setCallbackUrl("callback url") + .setClientReference("a client reference") + .setFeedbackEnabled(true) + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setUdh("foo udh") + .setFromTon(3) + .setFromNpi(10) + .build(); + + String serializedString = objectMapper.writeValueAsString(binaryRequestDTO); + + JSONAssert.assertEquals(jsonRequestBinaryDto, serializedString, true); + } + + @Test + void serializeTextRequestDto() throws JsonProcessingException, JSONException { + + UpdateTextRequest textRequestDTO = + UpdateTextRequest.builder() + .setFrom("+15551231234") + .setToAdd(Arrays.asList("+15551231234", "+15551256344")) + .setToRemove(Arrays.asList("+0123456789", "+9876543210")) + .setDeliveryReport(DeliveryReportType.NONE) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setCallbackUrl("callback url") + .setClientReference("a client reference") + .setFeedbackEnabled(true) + .setParameters(parameters) + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setFromTon(3) + .setFromNpi(15) + .setMaxNumberOfMessageParts(4) + .setTruncateConcat(true) + .setFlashMessage(false) + .build(); + + String serializedString = objectMapper.writeValueAsString(textRequestDTO); + + JSONAssert.assertEquals(jsonRequestTextDto, serializedString, true); + } + + @Test + void serializeMediaRequestDto() throws JsonProcessingException, JSONException { + + UpdateMediaRequest mediaRequestDTO = + UpdateMediaRequest.builder() + .setFrom("+15551231234") + .setToAdd(Arrays.asList("+15551231234", "+15987365412")) + .setToRemove(Arrays.asList("+0123456789", "+9876543210")) + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl("callback url") + .setClientReference("a client reference") + .setFeedbackEnabled(true) + .setBody( + MediaBody.builder() + .setUrl( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .setMessage("Hi ${name} ({an identifier}) ! How are you?") + .build()) + .setParameters(parameters) + .setStrictValidation(true) + .build(); + + String serializedString = objectMapper.writeValueAsString(mediaRequestDTO); + + JSONAssert.assertEquals(jsonRequestMediaDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseDtoTest.java new file mode 100644 index 000000000..ae46b43bd --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponseDtoTest.java @@ -0,0 +1,35 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import java.util.Collections; +import org.junit.jupiter.api.Test; + +@TestWithResources +class DryRunResponseDtoTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/batches/response/DryRunResponseDto.json") + DryRunResponse loadedDto; + + DryRunResponse dto = + DryRunResponse.builder() + .setNumberOfRecipients(123) + .setNumberOfMessages(456) + .setPerRecipient( + Collections.singletonList( + DryRunPerRecipientDetails.builder() + .setRecipient("recipient string") + .setNumberOfParts(1) + .setBody("body string") + .setEncoding("encoding string") + .build())) + .build(); + + @Test + void deserialize() { + + TestHelpers.recursiveEquals(loadedDto, dto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendResponseDtoTest.java new file mode 100644 index 000000000..c40474adc --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/v1/batches/response/SendResponseDtoTest.java @@ -0,0 +1,125 @@ +package com.sinch.sdk.domains.sms.models.v1.batches.response; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.MediaBodyDtoTest; +import java.time.Instant; +import java.util.AbstractMap; +import java.util.Arrays; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.junit.jupiter.api.Test; + +@TestWithResources +class SendResponseDtoTest extends BaseTest { + @GivenJsonResource("/domains/sms/v1/batches/response/BinaryResponseDto.json") + BatchResponse loadedBinaryDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/TextResponseDto.json") + BatchResponse loadedTextDto; + + @GivenJsonResource("/domains/sms/v1/batches/response/MediaResponseDto.json") + BatchResponse loadedMediaDto; + + BinaryResponse binaryResponseDto = + BinaryResponse.builder() + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setCallbackUrl("callback url") + .setClientReference("myReference") + .setDeliveryReport(DeliveryReportType.NONE) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setFeedbackEnabled(false) + .setFrom("+15551231234") + .setFromTon(6) + .setFromNpi(18) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setUdh("foo udh") + .setCanceled(false) + .setCreatedAt(Instant.parse("2019-08-24T14:15:22Z")) + .setModifiedAt(Instant.parse("2019-08-24T14:17:22Z")) + .setId("01FC66621XXXXX119Z8PMV1QPQ") + .build(); + + Map anIdentifierParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "an identifier value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "an identifier value for 15551256344")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>("15551231234", "name value for 15551231234"), + new AbstractMap.SimpleEntry<>("15551256344", "name value for 15551256344"), + new AbstractMap.SimpleEntry<>("default", "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("an identifier", anIdentifierParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + TextResponse textResponseDto = + TextResponse.builder() + .setId("01FC66621XXXXX119Z8PMV1QPQ") + .setCreatedAt(Instant.parse("2019-08-24T14:15:22Z")) + .setCanceled(false) + .setModifiedAt(Instant.parse("2019-08-24T14:17:22Z")) + .setBody("Hi ${name} ({an identifier}) ! How are you?") + .setCallbackUrl("callback url") + .setClientReference("myReference") + .setDeliveryReport(DeliveryReportType.NONE) + .setExpireAt(Instant.parse("2019-08-24T14:21:22Z")) + .setFeedbackEnabled(false) + .setFlashMessage(true) + .setFrom("+15551231234") + .setFromTon(6) + .setFromNpi(18) + .setMaxNumberOfMessageParts(1) + .setParameters(parameters) + .setSendAt(Instant.parse("2019-08-24T14:19:22Z")) + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setTruncateConcat(true) + .build(); + + MediaResponse mediaResponseDto = + MediaResponse.builder() + .setId("01FC66621XXXXX119Z8PMV1QPQ") + .setCanceled(false) + .setCreatedAt(Instant.parse("2019-08-24T14:14:22Z")) + .setModifiedAt(Instant.parse("2019-08-24T14:15:22Z")) + .setBody(MediaBodyDtoTest.mediaBodyDto) + .setCallbackUrl("callback url") + .setClientReference("client reference") + .setDeliveryReport(DeliveryReportType.SUMMARY) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setFeedbackEnabled(false) + .setFrom("+15551231234") + .setParameters(parameters) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setTo(Arrays.asList("+15551231234", "+15551256344")) + .setStrictValidation(true) + .build(); + + @Test + void deserializeBinary() { + + TestHelpers.recursiveEquals(loadedBinaryDto, binaryResponseDto); + } + + @Test + void deserializeText() { + + TestHelpers.recursiveEquals(loadedTextDto, textResponseDto); + } + + @Test + void deserializeMedia() { + + TestHelpers.recursiveEquals(loadedMediaDto, mediaResponseDto); + } +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/SendSMSBinaryRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/BinaryRequestDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/SendSMSBinaryRequestDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/BinaryRequestDto.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/SendSMSMediaRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/MediaRequestDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/SendSMSMediaRequestDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/MediaRequestDto.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json new file mode 100644 index 000000000..22a59e621 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/MediaBodyDto.json @@ -0,0 +1,5 @@ +{ + "subject": "subject field", + "message": "Hi ${name} ({an identifier}) ! How are you?", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/BinaryRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/BinaryRequestDto.json new file mode 100644 index 000000000..caf327e09 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/BinaryRequestDto.json @@ -0,0 +1,18 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": "Hi ${name} ({an identifier}) ! How are you?", + "type": "mt_binary", + "delivery_report": "none", + "send_at": "2019-08-24T14:19:22Z", + "expire_at": "2019-08-24T14:21:22Z", + "callback_url": "callback url", + "client_reference": "myReference", + "feedback_enabled": false, + "from_ton": 6, + "from_npi": 18, + "udh": "foo udh" +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json new file mode 100644 index 000000000..d48fc1e55 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/MediaRequestDto.json @@ -0,0 +1,31 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": { + "message": "Hi ${name} ({an identifier}) ! How are you?", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png", + "subject": "subject field" + }, + "parameters": { + "name": { + "15551231234": "name value for 15551231234", + "15551256344": "name value for 15551256344", + "default": "default value" + }, + "an identifier": { + "15551231234": "an identifier value for 15551231234", + "15551256344": "an identifier value for 15551256344" + } + }, + "type": "mt_media", + "delivery_report": "summary", + "send_at": "2019-08-24T14:16:22Z", + "expire_at": "2019-08-24T14:17:22Z", + "callback_url": "callback url", + "client_reference": "client reference", + "feedback_enabled": false, + "strict_validation": true +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/SendDeliveryFeedbackRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/SendDeliveryFeedbackRequestDto.json new file mode 100644 index 000000000..cbbdfceb5 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/SendDeliveryFeedbackRequestDto.json @@ -0,0 +1,6 @@ +{ + "recipients": [ + "+15551231234", + "+15987365412" + ] +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/SendSMSTextRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/TextRequestDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/SendSMSTextRequestDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/request/TextRequestDto.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateBinaryRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateBinaryRequestDto.json new file mode 100644 index 000000000..222756713 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateBinaryRequestDto.json @@ -0,0 +1,22 @@ +{ + "to_add": [ + "+15551231234", + "+15987365412" + ], + "to_remove": [ + "+0123456789", + "+9876543210" + ], + "from": "+15551231234", + "type": "mt_binary", + "delivery_report": "full", + "send_at": "2019-08-24T14:19:22Z", + "expire_at": "2019-08-24T14:21:22Z", + "callback_url": "callback url", + "client_reference": "a client reference", + "feedback_enabled": true, + "body": "Hi ${name} ({an identifier}) ! How are you?", + "udh": "foo udh", + "from_ton": 3, + "from_npi": 10 +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateMediaRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateMediaRequestDto.json new file mode 100644 index 000000000..97595c06d --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateMediaRequestDto.json @@ -0,0 +1,34 @@ +{ + "to_add": [ + "+15551231234", + "+15987365412" + ], + "to_remove": [ + "+0123456789", + "+9876543210" + ], + "from": "+15551231234", + "body": { + "message": "Hi ${name} ({an identifier}) ! How are you?", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + }, + "parameters": { + "name": { + "15551231234": "name value for 15551231234", + "15551256344": "name value for 15551256344", + "default": "default value" + }, + "an identifier": { + "15551231234": "an identifier value for 15551231234", + "15551256344": "an identifier value for 15551256344" + } + }, + "type": "mt_media", + "delivery_report": "summary", + "send_at": "2019-08-24T14:16:22Z", + "expire_at": "2019-08-24T14:17:22Z", + "callback_url": "callback url", + "client_reference": "a client reference", + "feedback_enabled": true, + "strict_validation": true +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateTextRequestDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateTextRequestDto.json new file mode 100644 index 000000000..4576d17c7 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/request/UpdateTextRequestDto.json @@ -0,0 +1,35 @@ +{ + "to_add": [ + "+15551231234", + "+15551256344" + ], + "to_remove": [ + "+0123456789", + "+9876543210" + ], + "from": "+15551231234", + "body": "Hi ${name} ({an identifier}) ! How are you?", + "type": "mt_text", + "delivery_report": "none", + "send_at": "2019-08-24T14:19:22Z", + "expire_at": "2019-08-24T14:21:22Z", + "callback_url": "callback url", + "client_reference": "a client reference", + "feedback_enabled": true, + "from_ton": 3, + "from_npi": 15, + "flash_message": false, + "max_number_of_message_parts": 4, + "truncate_concat": true, + "parameters": { + "name": { + "15551231234": "name value for 15551231234", + "15551256344": "name value for 15551256344", + "default": "default value" + }, + "an identifier": { + "15551231234": "an identifier value for 15551231234", + "15551256344": "an identifier value for 15551256344" + } + } +} diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/BinaryResponseDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BinaryResponseDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/BinaryResponseDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/BinaryResponseDto.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/DryRunResponseDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/DryRunResponseDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/DryRunResponseDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/DryRunResponseDto.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage0.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage0.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage0.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage0.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage1.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage1.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage1.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage1.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage2.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage2.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/ListBatchesResponseDtoPage2.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/ListBatchesResponseDtoPage2.json diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/MediaResponseDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/MediaResponseDto.json similarity index 94% rename from openapi-contracts/src/test/resources/domains/sms/v1/MediaResponseDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/MediaResponseDto.json index 91949c129..7c1143b41 100644 --- a/openapi-contracts/src/test/resources/domains/sms/v1/MediaResponseDto.json +++ b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/MediaResponseDto.json @@ -8,7 +8,8 @@ "canceled": false, "body": { "message": "Hi ${name} ({an identifier}) ! How are you?", - "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png", + "subject": "subject field" }, "parameters": { "name": { diff --git a/openapi-contracts/src/test/resources/domains/sms/v1/TextResponseDto.json b/openapi-contracts/src/test/resources/domains/sms/v1/batches/response/TextResponseDto.json similarity index 100% rename from openapi-contracts/src/test/resources/domains/sms/v1/TextResponseDto.json rename to openapi-contracts/src/test/resources/domains/sms/v1/batches/response/TextResponseDto.json diff --git a/pom.xml b/pom.xml index bb8469c9b..d50d1e596 100644 --- a/pom.xml +++ b/pom.xml @@ -323,6 +323,7 @@ com.sinch.sdk.e2e.domains.conversation.ConversationIT com.sinch.sdk.e2e.domains.sms.v0.SmsIT + com.sinch.sdk.e2e.domains.sms.v1.SmsIT com.sinch.sdk.e2e.domains.voice.v0.VoiceIT com.sinch.sdk.e2e.domains.voice.v1.VoiceIT diff --git a/sample-app/src/main/java/com/sinch/sample/sms/batches/Send.java b/sample-app/src/main/java/com/sinch/sample/sms/batches/Send.java index d8f8aa072..a5d4d82f1 100644 --- a/sample-app/src/main/java/com/sinch/sample/sms/batches/Send.java +++ b/sample-app/src/main/java/com/sinch/sample/sms/batches/Send.java @@ -1,10 +1,13 @@ package com.sinch.sample.sms.batches; import com.sinch.sample.BaseApplication; +import com.sinch.sdk.core.utils.Pair; import com.sinch.sdk.domains.sms.models.BatchText; import com.sinch.sdk.domains.sms.models.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.Parameters; import com.sinch.sdk.domains.sms.models.requests.SendSmsBatchTextRequest; import java.io.IOException; +import java.util.Arrays; import java.util.Collections; import java.util.logging.Logger; @@ -29,9 +32,16 @@ public void run() { SendSmsBatchTextRequest.Builder builder = SendSmsBatchTextRequest.builder() .setTo(Collections.singletonList(phoneNumber)) - .setBody("the body") + .setBody("the body ${code}") .setClientReference("a client reference") .setFrom("+33123456789") + .setParameters( + new Parameters( + Arrays.asList( + new Parameters.Entry("name", new Pair<>("+12017777777", "John"), "there"), + new Parameters.Entry("name", new Pair<>("+12018888888", "Paul")), + new Parameters.Entry( + "code", new Pair<>(phoneNumber, "HALLOWEEN20 \uD83C\uDF83"))))) .setDeliveryReport(DeliveryReportType.FULL); // Overload default dashboard webhooks URL if defined diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Cancel.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Cancel.java new file mode 100644 index 000000000..2b7893439 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Cancel.java @@ -0,0 +1,32 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.io.IOException; +import java.util.logging.Logger; + +public class Cancel extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Cancel.class.getName()); + + public Cancel() throws IOException {} + + public static void main(String[] args) { + try { + new Cancel().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + + LOGGER.info("Cancelling batch: " + batchId); + BatchResponse value = service.cancel(batchId); + + LOGGER.info("Response: " + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Get.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Get.java new file mode 100644 index 000000000..273a98e6e --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Get.java @@ -0,0 +1,32 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.io.IOException; +import java.util.logging.Logger; + +public class Get extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Get.class.getName()); + + public Get() throws IOException {} + + public static void main(String[] args) { + try { + new Get().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + LOGGER.info("Get for :" + batchId); + + BatchResponse value = service.get(batchId); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/List.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/List.java new file mode 100644 index 000000000..6ee193456 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/List.java @@ -0,0 +1,42 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesRequest; +import java.io.IOException; +import java.util.logging.Logger; + +public class List extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(List.class.getName()); + + public List() throws IOException {} + + public static void main(String[] args) { + try { + new List().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + LOGGER.info("List batches"); + + LOGGER.info("Response:"); + service + .list( + ListBatchesRequest.builder() + // .setFrom(phoneNumber) + // .setPage(15) + .setPageSize(2) + // .setClientReference("a client reference") + // .setStartDate(Instant.now()) + .build()) + .iterator() + .forEachRemaining(f -> LOGGER.info(f.toString())); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Replace.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Replace.java new file mode 100644 index 000000000..8e64af257 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Replace.java @@ -0,0 +1,42 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.logging.Logger; + +public class Replace extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Replace.class.getName()); + + public Replace() throws IOException {} + + public static void main(String[] args) { + try { + new Replace().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + + LOGGER.info("Replace batch" + batchId); + BatchResponse value = + service.replace( + batchId, + TextRequest.builder() + .setTo(Collections.singletonList("+33745149803")) + .setBody("the body") + .setClientReference("a client reference") + .setFrom("+33123456789") + .build()); + + LOGGER.info("Response: " + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Send.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Send.java new file mode 100644 index 000000000..f3abc50a3 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Send.java @@ -0,0 +1,68 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.DeliveryReportType; +import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.Collections; +import java.util.Map; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class Send extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Send.class.getName()); + + public Send() throws IOException {} + + public static void main(String[] args) { + try { + new Send().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + + LOGGER.info("Send Text to " + phoneNumber); + + Map nameParameters = + Stream.of( + new AbstractMap.SimpleEntry<>(phoneNumber, "John"), + new AbstractMap.SimpleEntry<>("+12018888888", "Doe")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map codeParameters = + Stream.of(new AbstractMap.SimpleEntry<>(phoneNumber, "HALLOWEEN20 \uD83C\uDF83")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + Map> parameters = + Stream.of( + new AbstractMap.SimpleEntry<>("name", nameParameters), + new AbstractMap.SimpleEntry<>("code", codeParameters)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + TextRequest.Builder builder = + TextRequest.builder() + .setTo(Collections.singletonList(phoneNumber)) + .setBody("Hello ${name}, this your code: ${code}") + .setClientReference("a client reference") + .setFrom("+33123456789") + .setParameters(parameters) + .setDeliveryReport(DeliveryReportType.FULL); + + // Overload default dashboard webhooks URL if defined + webhooksSmsPath.ifPresent(builder::setCallbackUrl); + + BatchResponse value = service.send(builder.build()); + + LOGGER.info("Response: " + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/SendDeliveryFeedback.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/SendDeliveryFeedback.java new file mode 100644 index 000000000..ab89da20e --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/SendDeliveryFeedback.java @@ -0,0 +1,38 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; +import java.io.IOException; +import java.util.Arrays; +import java.util.logging.Logger; + +public class SendDeliveryFeedback extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(SendDeliveryFeedback.class.getName()); + + public SendDeliveryFeedback() throws IOException {} + + public static void main(String[] args) { + try { + new SendDeliveryFeedback().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + + LOGGER.info("Send Delivery Feedback for batch ID:" + batchId); + + SendDeliveryFeedbackRequest request = + SendDeliveryFeedbackRequest.builder() + .setRecipients(Arrays.asList("foo number 1", "foo number 2")) + .build(); + service.sendDeliveryFeedback(batchId, request); + LOGGER.info("Done"); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Update.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Update.java new file mode 100644 index 000000000..8344eaea1 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/Update.java @@ -0,0 +1,44 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateTextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.logging.Logger; + +public class Update extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Update.class.getName()); + + public Update() throws IOException {} + + public static void main(String[] args) { + try { + new Update().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + + LOGGER.info("Updating batch: " + batchId); + + UpdateTextRequest.Builder builder = + UpdateTextRequest.builder() + .setToRemove(Collections.singletonList("+33745149803")) + .setToAdd(Collections.singletonList("+33745149803")) + .setBody("the body updated") + .setFrom("+33123456789"); + + webhooksSmsPath.ifPresent(builder::setCallbackUrl); + + BatchResponse value = service.update(batchId, builder.build()); + + LOGGER.info("Response: " + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/dryRun.java b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/dryRun.java new file mode 100644 index 000000000..7fd0c48be --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/v1/batches/dryRun.java @@ -0,0 +1,42 @@ +package com.sinch.sample.sms.v1.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.api.v1.BatchesService; +import com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest; +import com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse; +import java.io.IOException; +import java.util.Collections; +import java.util.logging.Logger; + +public class dryRun extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(dryRun.class.getName()); + + public dryRun() throws IOException {} + + public static void main(String[] args) { + try { + new dryRun().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + BatchesService service = client.sms().v1().batches(); + LOGGER.info("DryRun Request"); + + DryRunResponse value = + service.dryRun( + true, + 3, + TextRequest.builder() + .setTo(Collections.singletonList(phoneNumber)) + .setBody("the body") + .build()); + + LOGGER.info("Response: " + value); + } +}