diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml new file mode 100644 index 00000000..ba1e89b2 --- /dev/null +++ b/.github/workflows/dependency-review.yml @@ -0,0 +1,24 @@ +# Dependency Review Action +# +# This Action will scan dependency manifest files that change as part of a Pull Request, surfacing known-vulnerable versions of the packages declared or updated in the PR. Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable packages will be blocked from merging. +# +# Source repository: https://github.com/actions/dependency-review-action +# Public documentation: https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review#dependency-review-enforcement +name: 'Dependency Review' +on: [ pull_request ] + +permissions: + contents: read + pull-requests: write +jobs: + dependency-review: + runs-on: ubuntu-latest + steps: + - name: 'Checkout Repository' + uses: actions/checkout@v3 + - name: 'Dependency Review' + uses: actions/dependency-review-action@v3 + with: + # Possible values: "critical", "high", "moderate", "low" + fail-on-severity: high + comment-summary-in-pr: always \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 00000000..8d8294e8 --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,23 @@ +name: Java CI with Maven + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + - name: Build with Maven + run: mvn -B clean package verify --file pom.xml + + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive + - name: Update dependency graph + uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..1e454e12 --- /dev/null +++ b/.gitignore @@ -0,0 +1,19 @@ +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties +# https://github.com/takari/maven-wrapper#usage-without-binary-jar +.mvn/wrapper/maven-wrapper.jar + +# Eclipse m2e generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath +.idea +*.iml \ No newline at end of file diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md new file mode 100644 index 00000000..8cc24f57 --- /dev/null +++ b/ARCHITECTURE.md @@ -0,0 +1,8 @@ +# Architecture + +This repository is composed of following directories: + +- `core`: The core definition of models (OpenAPI contracts generated sources are based onto them) +- `openapi-contracts`: Open API files and dedicated sources to implement REST API calls. Sources are generated by OpenAPI generator tool and should not be modified. +- `client`: Sinch SDK implementation +- `sample-app`: A sample application using the Sinch SDK \ No newline at end of file diff --git a/HTTP-CLIENT.md b/HTTP-CLIENT.md new file mode 100644 index 00000000..d88fb9e1 --- /dev/null +++ b/HTTP-CLIENT.md @@ -0,0 +1,2 @@ +# To be continued +Here will be details about multiple http clients usage and support \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 00000000..4af1694f --- /dev/null +++ b/README.md @@ -0,0 +1,116 @@ +# sinch-sdk-java + + +

+ +[![Sinch Logo](https://developers.sinch.com/static/logo-07afe977d6d9dcd21b066d1612978e5c.svg)](https://www.sinch.com) + +Java SDK + +[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/sinch/sinch-sdk-python/blob/main/LICENSE) + + +[![Python 3.8](https://img.shields.io/badge/Java-8-blue.svg)](https://docs.oracle.com/javase/8) + + +

+ +## Welcome to Sinch's Java SDK. + +Here you'll find documentation to start developing Java code using Sinch services. + +To use this SDK you'll need a Sinch account and API keys. Please sign up at [sinch.com](https://sinch.com) + +For more in depth version of the Sinch APIs, please refer to the official developer portal - [developers.sinch.com](https://developers.sinch.com/) + +**This SDK is currently available to selected developers for preview use only. It is being provided for the purpose of collecting feedback, and should not be used in production environments.** + +* [Installation](#installation) +* [Getting started](#getting-started) +* [Logging](#logging) +*** + +# Prerequisites + +- JDK 8 or later +- [Maven](https://maven.apache.org/) +- [Maven Central](https://mvnrepository.com/artifact/com.sinch.sdk/sinch-java-sdk) +- [Sinch account](https://dashboard.sinch.com) + +## Installation + +### Maven setup +Add to your `pom.xml` file the dependency to SDK: +```xml + + + com.sinch.sdk + sinch-java-sdk + ${sdk.version} + + ... + +``` + +## Getting started + +### Client initialization + +To initialize communication with Sinch backed, credentials obtained from Sinch portal have to be provided to the main client class of this SDK. +It's highly advised to not hardcode those credentials, but to fetch them from environment variables: + +```java +import com.sinch.sdk.SinchClient; +import com.sinch.sdk.models.Configuration; + +... +Configuration configuration = Configuration.builder().setKeyId(PARAM_KEY_ID) + .setKeySecret(PARAM_KEY_SECRET) + .setProjectId(PARAM_PROJECT_ID) + .build(); +... +SinchClient client = new SinchClient(configuration); +``` + +## Products + +Sinch client provides access to the following Sinch products: +- [Numbers](https://developers.sinch.com/docs/numbers) +- [SMS](https://developers.sinch.com/docs/sms) (WIP) + +Usage example of the `numbers` product: + +```java +AvailableNumberListResponse response = client + .numbers() + .available() + .list(AvailableNumberListAllRequestParameters.builder() + .setRegionCode("US") + .setType(NumberType.LOCAL) + .build()); +``` + +## Logging +The SDK uses the Java 8 logging feature ([java.util.logging](https://docs.oracle.com/javase/8/docs/api/java/util/logging/package-summary.html)) +Loggers and severity can be configured by using a `logging.properties` file like (see sample-app/src/main/resources/: +``` +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = INFO +com.sinch.sdk.level = INFO + +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$-7s %2$s] %5$s %n +``` + +## Examples +See [sample-app](sample-app/src/main/java/com/sinch/sample) module + +## HTTP Client +See [HTTP-CLIENT](HTTP-CLIENT.md) file + +## Architecture +See [ARCHITECTURE](ARCHITECTURE.md) file + +## License + +This project is licensed under the Apache License. See the [LICENSE](LICENSE) file for the license text. \ No newline at end of file diff --git a/client/resources/config-default.properties b/client/resources/config-default.properties new file mode 100644 index 00000000..e0c4952e --- /dev/null +++ b/client/resources/config-default.properties @@ -0,0 +1,4 @@ +oauth-url=https://auth.sinch.com/oauth2/token +numbers-server=https://numbers.api.sinch.com +sms-region=us +sms-server=https://zt.%s.sms.api.sinch.com \ No newline at end of file diff --git a/client/src/main/com/sinch/sdk/SinchClient.java b/client/src/main/com/sinch/sdk/SinchClient.java new file mode 100644 index 00000000..c4d92875 --- /dev/null +++ b/client/src/main/com/sinch/sdk/SinchClient.java @@ -0,0 +1,166 @@ +package com.sinch.sdk; + +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.auth.adapters.BasicAuthManager; +import com.sinch.sdk.auth.adapters.BearerAuthManager; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.domains.numbers.NumbersService; +import com.sinch.sdk.domains.sms.SMSService; +import com.sinch.sdk.http.HttpClientApache; +import com.sinch.sdk.models.Configuration; +import com.sinch.sdk.models.SMSRegion; +import java.io.IOException; +import java.io.InputStream; +import java.util.AbstractMap; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** Sinch Sdk Client implementation */ +public class SinchClient { + + private static final String OAUTH_URL_KEY = "oauth-url"; + private static final String NUMBERS_SERVER_KEY = "numbers-server"; + private static final String SMS_REGION_KEY = "sms-region"; + private static final String SMS_SERVER_KEY = "sms-server"; + + private static final Logger LOGGER = Logger.getLogger(SinchClient.class.getName()); + + private final Configuration configuration; + private NumbersService numbers; + + private SMSService sms; + + private HttpClientApache httpClient; + + /** + * Create a Sinch Client instance based onto configuration + * + * @param configuration Configuration to be used + * @since 1.0 + */ + public SinchClient(Configuration configuration) { + + Configuration.Builder builder = Configuration.builder(configuration); + + Properties props = handleDefaultConfigurationFile(); + if (null == configuration.getOAuthUrl() && props.containsKey(OAUTH_URL_KEY)) { + builder.setOAuthUrl(props.getProperty(OAUTH_URL_KEY)); + } + if (null == configuration.getNumbersUrl() && props.containsKey(NUMBERS_SERVER_KEY)) { + builder.setNumbersUrl(props.getProperty(NUMBERS_SERVER_KEY)); + } + if (null == configuration.getSmsUrl() && props.containsKey(SMS_SERVER_KEY)) { + builder.setSmsUrl(props.getProperty(SMS_SERVER_KEY)); + } + if (null == configuration.getSmsRegion() && props.containsKey(SMS_REGION_KEY)) { + builder.setSmsRegion(SMSRegion.from(props.getProperty(SMS_REGION_KEY))); + } + Configuration newConfiguration = builder.build(); + checkConfiguration(newConfiguration); + this.configuration = newConfiguration; + + LOGGER.fine("SinchClient started with projectId='" + configuration.getProjectId() + "'"); + } + + /** + * Get current configuration + * + * @return Current configuration in use by client + * @since 1.0 + */ + public Configuration getConfiguration() { + return this.configuration; + } + + /** + * Get Numbers domain service + * + * @return Return instance onto Numbers API service + * @see https://developers.sinch.com/docs/numbers/api-reference + * @since 1.0 + */ + public NumbersService numbers() { + if (null == numbers) { + numbers = numbersInit(); + } + return numbers; + } + + /** + * Get SMS domain service + * + * @return Return instance onto SMS API service + * @see https://developers.sinch.com/docs/sms/api-reference/ + * @since 1.0 + */ + public SMSService sms() { + if (null == sms) { + sms = smsInit(); + } + return sms; + } + + private void checkConfiguration(Configuration configuration) throws NullPointerException { + Objects.requireNonNull(configuration.getKeyId(), "'keyId' cannot be null"); + Objects.requireNonNull(configuration.getKeySecret(), "'keySecret' cannot be null"); + Objects.requireNonNull(configuration.getProjectId(), "'projectId' cannot be null"); + Objects.requireNonNull(configuration.getOAuthUrl(), "'oauthUrl' cannot be null"); + Objects.requireNonNull(configuration.getNumbersUrl(), "'numbersUrl' cannot be null"); + Objects.requireNonNull(configuration.getSmsUrl(), "'smsUrl' cannot be null"); + } + + private NumbersService numbersInit() { + LOGGER.fine( + "Activate numbers API with server='" + + getConfiguration().getNumbersServer().getUrl() + + "'"); + return new com.sinch.sdk.domains.numbers.adapters.NumbersService( + getConfiguration(), getHttpClient()); + } + + private SMSService smsInit() { + LOGGER.fine( + "Activate SMS API with server='" + getConfiguration().getSmsServer().getUrl() + "'"); + return new com.sinch.sdk.domains.sms.adapters.SMSService(getConfiguration(), getHttpClient()); + } + + private Properties handleDefaultConfigurationFile() { + + Properties prop = new Properties(); + try (InputStream is = this.getClass().getResourceAsStream("/config-default.properties")) { + prop.load(is); + } catch (IOException e) { + // NOOP + } + return prop; + } + + private HttpClientApache getHttpClient() { + if (null == httpClient || httpClient.isClosed()) { + AuthManager basicAuthManager = new BasicAuthManager(configuration); + BearerAuthManager bearerAuthManager = new BearerAuthManager(configuration, new HttpMapper()); + + Map authManagers = + Stream.of(basicAuthManager, bearerAuthManager) + .map(e -> new AbstractMap.SimpleEntry<>(e.getSchema(), e)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + // TODO: by adding a setter, we could imagine having another HTTP client provided + // programmatically or use + // configuration file referencing another class by name + this.httpClient = new HttpClientApache(authManagers); + + // Avoid multiple and costly http client creation and reuse it for authManager + bearerAuthManager.setHttpClient(this.httpClient); + + LOGGER.fine("HTTP client loaded"); + } + return this.httpClient; + } +} diff --git a/client/src/main/com/sinch/sdk/auth/AuthManager.java b/client/src/main/com/sinch/sdk/auth/AuthManager.java new file mode 100644 index 00000000..23121e63 --- /dev/null +++ b/client/src/main/com/sinch/sdk/auth/AuthManager.java @@ -0,0 +1,14 @@ +package com.sinch.sdk.auth; + +import com.sinch.sdk.core.http.HttpClient; + +public interface AuthManager { + + String getSchema(); + + void resetToken(); + + void setHttpClient(HttpClient httpClient); + + String getAuthorizationHeaderValue(); +} diff --git a/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java b/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java new file mode 100644 index 00000000..519a1b9a --- /dev/null +++ b/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.auth.adapters; + +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.models.Configuration; +import java.nio.charset.StandardCharsets; +import java.util.Base64; + +public class BasicAuthManager implements AuthManager { + public static final String BASIC_SCHEMA_KEYWORD = "BasicAuth"; + private static final String BASIC_AUTH_KEYWORD = "Basic"; + private final Configuration configuration; + + public BasicAuthManager(Configuration configuration) { + this.configuration = configuration; + } + + public String getSchema() { + return BASIC_SCHEMA_KEYWORD; + } + + @Override + public void setHttpClient(HttpClient httpClient) { + // no op + } + + @Override + public void resetToken() { + // no op + } + + @Override + public String getAuthorizationHeaderValue() { + String key = configuration.getKeyId() == null ? "" : configuration.getKeyId(); + String secret = configuration.getKeySecret() == null ? "" : configuration.getKeySecret(); + + String raw = key + ":" + secret; + + return BASIC_AUTH_KEYWORD + + " " + + Base64.getEncoder().encodeToString(raw.getBytes(StandardCharsets.UTF_8)); + } +} diff --git a/client/src/main/com/sinch/sdk/auth/adapters/BearerAuthManager.java b/client/src/main/com/sinch/sdk/auth/adapters/BearerAuthManager.java new file mode 100644 index 00000000..c2f43bc5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/auth/adapters/BearerAuthManager.java @@ -0,0 +1,93 @@ +package com.sinch.sdk.auth.adapters; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.auth.models.BearerAuthResponse; +import com.sinch.sdk.core.exceptions.ApiAuthException; +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.models.Configuration; +import java.util.Collections; +import java.util.Optional; +import java.util.logging.Logger; + +public class BearerAuthManager implements AuthManager { + public static final String BEARER_SCHEMA_KEYWORD = "BearerAuth"; + public static final String BEARER_EXPIRED_KEYWORD = "expired"; + public static final String BEARER_AUTHENTICATE_RESPONSE_HEADER_KEYWORD = "www-authenticate"; + private static final Logger LOGGER = Logger.getLogger(BearerAuthManager.class.getName()); + private static final String BEARER_AUTH_KEYWORD = "Bearer"; + private static final int maxRefreshAttempt = 5; + private final Configuration configuration; + private final HttpMapper mapper; + private HttpClient httpClient; + private String token; + + public BearerAuthManager(Configuration configuration, HttpMapper mapper) { + this.configuration = configuration; + this.mapper = mapper; + } + + public String getSchema() { + return BEARER_SCHEMA_KEYWORD; + } + + @Override + public void setHttpClient(HttpClient httpClient) { + this.httpClient = httpClient; + } + + @Override + public void resetToken() { + token = null; + } + + @Override + public String getAuthorizationHeaderValue() { + + if (token == null) { + refreshToken(); + } + return BEARER_AUTH_KEYWORD + " " + token; + } + + private void refreshToken() { + + int attempt = 0; + while (attempt < maxRefreshAttempt) { + Optional newValue = getNewToken(); + if (newValue.isPresent()) { + token = newValue.get(); + return; + } + attempt++; + } + throw new ApiAuthException("Unable to get new token"); + } + + private Optional getNewToken() { + + LOGGER.fine("Refreshing OAuth token"); + HttpRequest request = + new HttpRequest( + null, + HttpMethod.POST, + Collections.emptyList(), + "grant_type=client_credentials", + null, + null, + Collections.singletonList("application/x-www-form-urlencoded"), + Collections.singletonList(BasicAuthManager.BASIC_SCHEMA_KEYWORD)); + try { + HttpResponse httpResponse = httpClient.invokeAPI(configuration.getOAuthServer(), request); + BearerAuthResponse authResponse = + mapper.deserialize(httpResponse, new TypeReference() {}); + return Optional.ofNullable(authResponse.getAccessToken()); + } catch (Exception e) { + return Optional.empty(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/auth/models/BearerAuthResponse.java b/client/src/main/com/sinch/sdk/auth/models/BearerAuthResponse.java new file mode 100644 index 00000000..66c751e9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/auth/models/BearerAuthResponse.java @@ -0,0 +1,52 @@ +package com.sinch.sdk.auth.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class BearerAuthResponse { + @JsonProperty("access_token") + String accessToken; + + @JsonProperty("expires_in") + Integer expiresIn; + + @JsonProperty("scope") + String scope; + + @JsonProperty("token_type") + String tokenType; + + public String getAccessToken() { + return accessToken; + } + + /** @return Integer Token period expiration in seconds */ + public Integer getExpiresIn() { + return expiresIn; + } + + public String getScope() { + return scope; + } + + public String getTokenType() { + return tokenType; + } + + @Override + public String toString() { + // do not log token value + return "BearerAuthResponse{" + + "accessToken='" + + "<...>" + + '\'' + + ", expiresIn=" + + expiresIn + + ", scope='" + + scope + + '\'' + + ", tokenType='" + + tokenType + + '\'' + + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java new file mode 100644 index 00000000..7622a8e5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.numbers; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; + +/** + * Active Numbers Service + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number + * @since 1.0 + */ +public interface ActiveNumberService { + + /** + * Lists active numbers for a project + * + * @param parameters Filtering criteria + * @return List of active numbers + * @since 1.0 + */ + ActiveNumberListResponse list(ActiveNumberListRequestParameters parameters) throws ApiException; + + /** + * Get active number information by phone number + * + * @param phoneNumber Phone number + * @return Active number information + * @since 1.0 + */ + ActiveNumber get(String phoneNumber) throws ApiException; + + /** + * Release an active number from the project + * + * @param phoneNumber Phone number + * @return Released active number + * @since 1.0 + */ + ActiveNumber release(String phoneNumber) throws ApiException; + + /** + * Update an active phone number + * + * @param phoneNumber Phone number + * @param parameters Parameters to be updated + * @return Updated active number + * @since 1.0 + */ + ActiveNumber update(String phoneNumber, ActiveNumberUpdateRequestParameters parameters) + throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java new file mode 100644 index 00000000..63b628a8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java @@ -0,0 +1,77 @@ +package com.sinch.sdk.domains.numbers; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; + +/** + * Available Number Service + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number + * @since 1.0 + */ +public interface AvailableNumberService { + + /** + * Search for available phone numbers + * + *

Search for available phone numbers that are available for you to activate. You can filter by + * any property on the available number resource. + * + *

When searching, indicate the capability of the number in the array as SMS and/or VOICE. To + * search for a number capable of both, list both SMS and VOICE. + * + * @param parameters Filtering criteria + * @return List of available numbers according to search criteria + * @since 1.0 + */ + AvailableNumberListResponse list(AvailableNumberListAllRequestParameters parameters) + throws ApiException; + + /** + * Get available number information by phone number + * + * @param phoneNumber Phone number + * @return Available number information + * @since 1.0 + */ + AvailableNumber get(String phoneNumber) throws ApiException; + + /** + * Activate a new phone number + * + *

Activate a phone number to use with SMS products, Voice products, or both. + * + *

You'll use smsConfiguration to setup your number for SMS and voiceConfiguration for Voice. + * To setup for both, add both objects. See the dropdown menu (just under language selection) for + * code samples. + * + *

Note: You cannot add both objects if you only need to configure one object. For example, if + * you only need to configure smsConfiguration for SMS messaging, do not add the + * voiceConfiguration object or it will result in an error. + * + * @param phoneNumber Number to be activated + * @param parameters Activation parameters + * @return Activated number + * @since 1.0 + */ + ActiveNumber rent(String phoneNumber, AvailableNumberRentRequestParameters parameters) + throws ApiException; + + /** + * Rent any number that matches the criteria + * + *

Activates a phone number that matches the search criteria provided in the request. Currently + * the rentAny operation works only for US LOCAL numbers + * + * @param parameters Selection and activation parameters + * @return Activated number according to criteria + * @since 1.0 + */ + ActiveNumber rentAny(AvailableNumberRentAnyRequestParameters parameters) throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java b/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java new file mode 100644 index 00000000..01cdde6c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java @@ -0,0 +1,24 @@ +package com.sinch.sdk.domains.numbers; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; + +/** + * Available Region Service + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Regions + */ +public interface AvailableRegionService { + + /** + * List available regions + * + * @param parameters Filtering criteria + * @return List of available regions according to search criteria + * @since 1.0 + */ + AvailableRegionListResponse list(AvailableRegionListAllRequestParameters parameters) + throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java b/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java new file mode 100644 index 00000000..78aeab9d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java @@ -0,0 +1,32 @@ +package com.sinch.sdk.domains.numbers; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; + +/** + * Callback Configuration Service + * + * @see https://developers.sinch.com/docs/numbers/api-reference/callbacks-numbers/tag/Callback-Configuration/ + */ +public interface CallbackConfigurationService { + + /** + * Get callbacks configuration + * + * @return callbacks configuration for the project + * @since 1.0 + */ + CallbackConfiguration get() throws ApiException; + + /** + * Update callbacks configuration + * + * @param parameters Parameters to be updated + * @return Updated callbacks configuration + * @since 1.0 + */ + CallbackConfiguration update(CallbackConfigurationUpdateRequestParameters parameters) + throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java new file mode 100644 index 00000000..75a79884 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.domains.numbers; + +/** + * Numbers Service + * + * @see https://developers.sinch.com/docs/numbers/api-reference/ + * @since 1.0 + */ +public interface NumbersService { + + /** + * Available Number Service instance + * + * @return service instance for project + * @since 1.0 + */ + AvailableNumberService available(); + + /** + * Available Region Service instance + * + * @return service instance for project + * @since 1.0 + */ + AvailableRegionService regions(); + + /** + * Active Number Service instance + * + * @return service instance for project + * @since 1.0 + */ + ActiveNumberService active(); + + /** + * Callbacks Configuraiton Service instance + * + * @return service instance for project + * @since 1.0 + */ + CallbackConfigurationService callback(); +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java new file mode 100644 index 00000000..ee620631 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java @@ -0,0 +1,115 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +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.core.models.pagination.PageToken; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.numbers.adapters.api.v1.ActiveNumberApi; +import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberDtoConverter; +import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberUpdateRequestParametersDtoConverter; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; +import com.sinch.sdk.models.Configuration; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class ActiveNumberService implements com.sinch.sdk.domains.numbers.ActiveNumberService { + + private Configuration configuration; + private ActiveNumberApi api; + + public ActiveNumberService() {} + + public ActiveNumberService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.api = new ActiveNumberApi(httpClient, configuration.getNumbersServer(), new HttpMapper()); + } + + private ActiveNumberApi getApi() { + return this.api; + } + + public ActiveNumberListResponse list(ActiveNumberListRequestParameters parameters) + throws ApiException { + + String regionCode = parameters.getRegionCode(); + NumberType type = parameters.getType(); + + Optional pattern = parameters.getNumberPattern(); + String patternPattern = null; + SearchPattern searchPattern = null; + if (pattern.isPresent()) { + NumberPattern p = pattern.get(); + patternPattern = p.getPattern(); + searchPattern = p.getSearchPattern(); + } + + List capabilities = null; + if (parameters.getCapabilities().isPresent()) { + capabilities = + parameters.getCapabilities().get().stream() + .map(EnumDynamic::value) + .collect(Collectors.toList()); + } + + Integer pageSize = parameters.getPageSize().orElse(null); + + String orderBy = null; + if (parameters.getOrderBy().isPresent()) { + orderBy = parameters.getOrderBy().get().value(); + } + + String pageToken = parameters.getPageToken().orElse(null); + ActiveNumbersResponseDto response = + getApi() + .numberServiceListActiveNumbers( + configuration.getProjectId(), + regionCode, + type.value(), + patternPattern, + null != searchPattern ? searchPattern.value() : null, + capabilities, + pageSize, + pageToken, + orderBy); + Pair, PageToken> content = + ActiveNumberDtoConverter.convert(response); + return new ActiveNumberListResponse( + this, new Page<>(parameters, content.getLeft(), content.getRight())); + } + + public ActiveNumber get(String phoneNumber) throws ApiException { + ActiveNumberDto response = + getApi().numberServiceGetActiveNumber(configuration.getProjectId(), phoneNumber); + return ActiveNumberDtoConverter.convert(response); + } + + public ActiveNumber release(String phoneNumber) throws ApiException { + ActiveNumberDto response = + getApi().numberServiceReleaseNumber(configuration.getProjectId(), phoneNumber); + return ActiveNumberDtoConverter.convert(response); + } + + public ActiveNumber update(String phoneNumber, ActiveNumberUpdateRequestParameters parameters) + throws ApiException { + ActiveNumberDto response = + getApi() + .numberServiceUpdateActiveNumber( + configuration.getProjectId(), + phoneNumber, + ActiveNumberUpdateRequestParametersDtoConverter.convert(parameters)); + return ActiveNumberDtoConverter.convert(response); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java new file mode 100644 index 00000000..c5662b6b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java @@ -0,0 +1,110 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.domains.numbers.adapters.api.v1.AvailableNumberApi; +import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberDtoConverter; +import com.sinch.sdk.domains.numbers.adapters.converters.AvailableNumberDtoConverter; +import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRentAnyRequestParametersDtoConverter; +import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRentRequestParametersDtoConverter; +import com.sinch.sdk.domains.numbers.models.*; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; +import com.sinch.sdk.models.Configuration; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +public class AvailableNumberService + implements com.sinch.sdk.domains.numbers.AvailableNumberService { + + private Configuration configuration; + private AvailableNumberApi api; + + public AvailableNumberService() {} + + public AvailableNumberService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.api = + new AvailableNumberApi(httpClient, configuration.getNumbersServer(), new HttpMapper()); + } + + private AvailableNumberApi getApi() { + return this.api; + } + + public AvailableNumberListResponse list(AvailableNumberListAllRequestParameters parameters) + throws ApiException { + String regionCode = parameters.getRegionCode(); + NumberType type = parameters.getType(); + + Optional pattern = parameters.getNumberPattern(); + String patternPattern = null; + SearchPattern searchPattern = null; + if (pattern.isPresent()) { + NumberPattern p = pattern.get(); + patternPattern = p.getPattern(); + searchPattern = p.getSearchPattern(); + } + + List capabilities = null; + if (parameters.getCapabilities().isPresent()) { + capabilities = + parameters.getCapabilities().get().stream() + .map(EnumDynamic::value) + .collect(Collectors.toList()); + } + + Integer size = parameters.getSize().orElse(null); + + AvailableNumbersResponseDto response = + getApi() + .numberServiceListAvailableNumbers( + configuration.getProjectId(), + regionCode, + type.value(), + patternPattern, + null != searchPattern ? searchPattern.value() : null, + capabilities, + size); + Collection entities = AvailableNumberDtoConverter.convert(response); + + return new AvailableNumberListResponse(entities); + } + + public AvailableNumber get(String phoneNumber) throws ApiException { + AvailableNumberDto response = + getApi().numberServiceGetAvailableNumber(configuration.getProjectId(), phoneNumber); + return AvailableNumberDtoConverter.convert(response); + } + + public ActiveNumber rent(String phoneNumber, AvailableNumberRentRequestParameters parameters) + throws ApiException { + ActiveNumberDto response = + getApi() + .numberServiceRentNumber( + configuration.getProjectId(), + phoneNumber, + AvailableRentRequestParametersDtoConverter.convert(parameters)); + return ActiveNumberDtoConverter.convert(response); + } + + public ActiveNumber rentAny(AvailableNumberRentAnyRequestParameters parameters) + throws ApiException { + + ActiveNumberDto response = + getApi() + .numberServiceRentAnyNumber( + configuration.getProjectId(), + AvailableRentAnyRequestParametersDtoConverter.convert(parameters)); + return ActiveNumberDtoConverter.convert(response); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java new file mode 100644 index 00000000..77a6a988 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java @@ -0,0 +1,47 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.domains.numbers.adapters.api.v1.AvailableRegionsApi; +import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRegionsDtoConverter; +import com.sinch.sdk.domains.numbers.models.Region; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; +import com.sinch.sdk.models.Configuration; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class AvailableRegionService + implements com.sinch.sdk.domains.numbers.AvailableRegionService { + + private Configuration configuration; + private AvailableRegionsApi api; + + public AvailableRegionService() {} + + public AvailableRegionService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.api = + new AvailableRegionsApi(httpClient, configuration.getNumbersServer(), new HttpMapper()); + } + + public AvailableRegionListResponse list(AvailableRegionListAllRequestParameters parameters) + throws ApiException { + + List types = null; + if (parameters.getTypes().isPresent()) { + types = + parameters.getTypes().get().stream().map(EnumDynamic::value).collect(Collectors.toList()); + } + + ListAvailableRegionsResponseDto response = + api.numberServiceListAvailableRegions(configuration.getProjectId(), types); + Collection entities = AvailableRegionsDtoConverter.convert(response); + + return new AvailableRegionListResponse(entities); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java new file mode 100644 index 00000000..8d7542cf --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java @@ -0,0 +1,49 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.domains.numbers.adapters.api.v1.CallbackConfigurationApi; +import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationDtoConverter; +import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationUpdateRequestParametersDtoConverter; +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; +import com.sinch.sdk.models.Configuration; + +public class CallbackConfigurationService + implements com.sinch.sdk.domains.numbers.CallbackConfigurationService { + + private Configuration configuration; + private CallbackConfigurationApi api; + + public CallbackConfigurationService() {} + + public CallbackConfigurationService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.api = + new CallbackConfigurationApi( + httpClient, configuration.getNumbersServer(), new HttpMapper()); + } + + private CallbackConfigurationApi getApi() { + return this.api; + } + + public CallbackConfiguration get() throws ApiException { + CallbackConfigurationDto response = + getApi().getCallbackConfiguration(configuration.getProjectId()); + return CallbackConfigurationDtoConverter.convert(response); + } + + public CallbackConfiguration update(CallbackConfigurationUpdateRequestParameters parameters) + throws ApiException { + + CallbackConfigurationDto response = + getApi() + .updateCallbackConfiguration( + configuration.getProjectId(), + CallbackConfigurationUpdateRequestParametersDtoConverter.convert(parameters)); + return CallbackConfigurationDtoConverter.convert(response); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java new file mode 100644 index 00000000..cee4cd15 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java @@ -0,0 +1,47 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.models.Configuration; + +public class NumbersService implements com.sinch.sdk.domains.numbers.NumbersService { + + private final Configuration configuration; + private final HttpClient httpClient; + private AvailableNumberService available; + private ActiveNumberService active; + private AvailableRegionService regions; + private CallbackConfigurationService callback; + + public NumbersService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.httpClient = httpClient; + } + + public AvailableNumberService available() { + if (null == this.available) { + this.available = new AvailableNumberService(configuration, httpClient); + } + return this.available; + } + + public AvailableRegionService regions() { + if (null == this.regions) { + this.regions = new AvailableRegionService(configuration, httpClient); + } + return this.regions; + } + + public ActiveNumberService active() { + if (null == this.active) { + this.active = new ActiveNumberService(configuration, httpClient); + } + return this.active; + } + + public CallbackConfigurationService callback() { + if (null == this.callback) { + this.callback = new CallbackConfigurationService(configuration, httpClient); + } + return this.callback; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java new file mode 100644 index 00000000..a2b0104d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java @@ -0,0 +1,48 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.core.models.pagination.PageToken; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumbersResponseDto; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class ActiveNumberDtoConverter { + + public static Pair, PageToken> convert( + ActiveNumbersResponseDto dto) { + String nextPageToken = dto.getNextPageToken(); + List list = dto.getActiveNumbers(); + Collection pageContent = Collections.emptyList(); + if (null != list) { + pageContent = + list.stream().map(ActiveNumberDtoConverter::convert).collect(Collectors.toList()); + } + return new Pair<>(pageContent, new PageToken<>(nextPageToken)); + } + + public static ActiveNumber convert(ActiveNumberDto dto) { + + return new ActiveNumber( + dto.getPhoneNumber(), + dto.getProjectId(), + dto.getDisplayName(), + dto.getRegionCode(), + NumberType.from(dto.getType()), + null != dto.getCapability() + ? dto.getCapability().stream().map(Capability::from).collect(Collectors.toList()) + : null, + MoneyDtoConverter.convert(dto.getMoney()), + dto.getPaymentIntervalMonths(), + dto.getNextChargeDate().toInstant(), + null != dto.getExpireAt() ? dto.getExpireAt().toInstant() : null, + SmsConfigurationDtoConverter.convert(dto.getSmsConfiguration()), + VoiceConfigurationDtoConverter.convert(dto.getVoiceConfiguration()), + dto.getCallbackUrl()); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java new file mode 100644 index 00000000..8cca6abb --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; + +public class ActiveNumberUpdateRequestParametersDtoConverter { + + public static ActiveNumberRequestDto convert(ActiveNumberUpdateRequestParameters parameters) { + ActiveNumberRequestDto dto = new ActiveNumberRequestDto(); + parameters.getDisplayName().ifPresent(dto::setDisplayName); + parameters + .getSmsConfiguration() + .ifPresent(value -> dto.setSmsConfiguration(SmsConfigurationDtoConverter.convert(value))); + parameters + .getVoiceConfiguration() + .ifPresent( + value -> dto.setVoiceConfiguration(VoiceConfigurationDtoConverter.convert(value))); + // TODO: OAS file do not yet contains callback field + // parameters.getCallback() + // .ifPresent(value -> dto.setCallback.convert(value))); + return dto; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java new file mode 100644 index 00000000..bc144aad --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java @@ -0,0 +1,37 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumbersResponseDto; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class AvailableNumberDtoConverter { + + public static Collection convert(AvailableNumbersResponseDto dto) { + List list = dto.getAvailableNumbers(); + if (null == list) { + return Collections.emptyList(); + } + return list.stream().map(AvailableNumberDtoConverter::convert).collect(Collectors.toList()); + } + + public static AvailableNumber convert(AvailableNumberDto dto) { + + return new AvailableNumber( + dto.getPhoneNumber(), + dto.getRegionCode(), + NumberType.from(dto.getType()), + null != dto.getCapability() + ? dto.getCapability().stream().map(Capability::from).collect(Collectors.toList()) + : null, + MoneyDtoConverter.convert(dto.getSetupPrice()), + MoneyDtoConverter.convert(dto.getMonthlyPrice()), + dto.getPaymentIntervalMonths(), + dto.getSupportingDocumentationRequired()); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java new file mode 100644 index 00000000..bb6eb1a6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java @@ -0,0 +1,33 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.Region; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableRegionDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class AvailableRegionsDtoConverter { + + public static Collection convert(ListAvailableRegionsResponseDto dto) { + List list = dto.getAvailableRegions(); + if (null == list) { + return Collections.emptyList(); + } + return list.stream().map(AvailableRegionsDtoConverter::convert).collect(Collectors.toList()); + } + + public static Region convert(AvailableRegionDto dto) { + + return Region.builder() + .setRegionCode(dto.getRegionCode()) + .setRegionName(dto.getRegionName()) + .setTypes( + null != dto.getTypes() + ? dto.getTypes().stream().map(NumberType::from).collect(Collectors.toList()) + : null) + .build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java new file mode 100644 index 00000000..a1b88089 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java @@ -0,0 +1,58 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestSmsConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestVoiceConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SearchPatternDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; +import java.util.Optional; +import java.util.stream.Collectors; + +public class AvailableRentAnyRequestParametersDtoConverter { + public static RentAnyNumberRequestDto convert( + AvailableNumberRentAnyRequestParameters parameters) { + + RentAnyNumberRequestDto dto = + new RentAnyNumberRequestDto() + .regionCode(parameters.getRegionCode()) + .type(parameters.getType().value()); + + Optional pattern = parameters.getNumberPattern(); + if (pattern.isPresent()) { + NumberPattern p = pattern.get(); + String patternPattern = p.getPattern(); + String searchPattern = p.getSearchPattern().value(); + SearchPatternDto spDto = new SearchPatternDto(); + spDto.pattern(patternPattern); + spDto.searchPattern(searchPattern); + dto.numberPattern(spDto); + } + + parameters + .getCapabilities() + .ifPresent( + value -> + dto.capabilities( + value.stream().map(EnumDynamic::value).collect(Collectors.toList()))); + + parameters + .getSmsConfiguration() + .ifPresent( + value -> + dto.smsConfiguration( + new RentAnyNumberRequestSmsConfigurationDto() + .campaignId(value.getCampaignId().orElse(null)) + .servicePlanId(value.getServicePlanId()))); + parameters + .getVoiceConfiguration() + .ifPresent( + value -> + dto.voiceConfiguration( + new RentAnyNumberRequestVoiceConfigurationDto().appId(value.getAppId()))); + + parameters.getCallBackUrl().ifPresent(dto::callbackUrl); + return dto; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java new file mode 100644 index 00000000..a8e60b43 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java @@ -0,0 +1,34 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestSmsConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestVoiceConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentVoiceConfigurationRequestParameters; +import java.util.Optional; + +public class AvailableRentRequestParametersDtoConverter { + + public static RentNumberRequestDto convert(AvailableNumberRentRequestParameters parameters) { + + Optional sms = parameters.getSmsConfiguration(); + Optional voice = parameters.getVoiceConfiguration(); + Optional callbackUrl = parameters.getCallBackUrl(); + + RentNumberRequestDto dto = new RentNumberRequestDto(); + + sms.ifPresent( + value -> + dto.smsConfiguration( + new RentAnyNumberRequestSmsConfigurationDto() + .campaignId(value.getCampaignId().orElse(null)) + .servicePlanId(value.getServicePlanId()))); + voice.ifPresent( + value -> + dto.voiceConfiguration( + new RentAnyNumberRequestVoiceConfigurationDto().appId(value.getAppId()))); + callbackUrl.ifPresent(dto::callbackUrl); + return dto; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java new file mode 100644 index 00000000..aed57be6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java @@ -0,0 +1,18 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; + +public class CallbackConfigurationDtoConverter { + + public static CallbackConfiguration convert(CallbackConfigurationDto dto) { + + if (null == dto) { + return null; + } + return CallbackConfiguration.builder() + .setProjectId(dto.getProjectId()) + .setHMACSecret(dto.getHmacSecret()) + .build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java new file mode 100644 index 00000000..e2ec6c41 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java @@ -0,0 +1,16 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationUpdateDto; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; + +public class CallbackConfigurationUpdateRequestParametersDtoConverter { + + public static CallbackConfigurationUpdateDto convert( + CallbackConfigurationUpdateRequestParameters parameters) { + + if (null == parameters) { + return null; + } + return new CallbackConfigurationUpdateDto().hmacSecret(parameters.getHMACSecret()); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java new file mode 100644 index 00000000..c6681dc4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.Money; +import com.sinch.sdk.domains.numbers.models.dto.v1.MoneyDto; + +public class MoneyDtoConverter { + + public static Money convert(MoneyDto dto) { + + if (null == dto) { + return null; + } + return new Money(dto.getCurrencyCode(), Double.valueOf(dto.getAmount())); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java new file mode 100644 index 00000000..b389a964 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java @@ -0,0 +1,42 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.ProvisioningStatus; +import com.sinch.sdk.domains.numbers.models.ScheduledSmsProvisioning; +import com.sinch.sdk.domains.numbers.models.SmsErrorCode; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledProvisioningDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SmsErrorCodeDto; +import java.time.ZoneOffset; +import java.util.stream.Collectors; + +public class ScheduledSmsProvisioningDtoConverter { + + public static ScheduledSmsProvisioning convert(ScheduledProvisioningDto dto) { + + if (null == dto) { + return null; + } + return new ScheduledSmsProvisioning( + dto.getServicePlanId(), + dto.getCampaignId(), + ProvisioningStatus.from(dto.getStatus().getValue()), + dto.getLastUpdatedTime().toInstant(), + dto.getErrorCodes().stream() + .map(e -> SmsErrorCode.from(e.getValue())) + .collect(Collectors.toList())); + } + + public static ScheduledProvisioningDto convert(ScheduledSmsProvisioning provisioning) { + + if (null == provisioning) { + return null; + } + + return new ScheduledProvisioningDto( + provisioning.getServicePlanId(), + provisioning.getCampaignId(), + provisioning.getLastUpdatedTime().atOffset(ZoneOffset.UTC), + provisioning.getErrorCodes().stream() + .map(e -> SmsErrorCodeDto.fromValue(e.value())) + .collect(Collectors.toList())); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java new file mode 100644 index 00000000..c3fd3c3a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java @@ -0,0 +1,34 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.ProvisioningStatus; +import com.sinch.sdk.domains.numbers.models.ScheduledVoiceProvisioning; +import com.sinch.sdk.domains.numbers.models.dto.v1.ProvisioningStatusDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledVoiceProvisioningDto; +import java.time.ZoneOffset; + +public class ScheduledVoiceProvisioningDtoConverter { + + public static ScheduledVoiceProvisioning convert(ScheduledVoiceProvisioningDto dto) { + + if (null == dto) { + return null; + } + return new ScheduledVoiceProvisioning( + dto.getAppId(), + ProvisioningStatus.from(dto.getStatus().getValue()), + dto.getLastUpdatedTime().toInstant()); + } + + public static ScheduledVoiceProvisioningDto convert(ScheduledVoiceProvisioning provisioning) { + + if (null == provisioning) { + return null; + } + + ScheduledVoiceProvisioningDto dto = + new ScheduledVoiceProvisioningDto( + provisioning.getAppId(), provisioning.getLastUpdatedTime().atOffset(ZoneOffset.UTC)); + dto.status(ProvisioningStatusDto.fromValue(provisioning.getStatus().value())); + return dto; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java new file mode 100644 index 00000000..9bea7d38 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java @@ -0,0 +1,31 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.SMSConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.SMSConfigurationDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateSMSConfigurationRequestParameters; + +public class SmsConfigurationDtoConverter { + + public static SMSConfiguration convert(SMSConfigurationDto dto) { + + if (null == dto) { + return null; + } + return new SMSConfiguration( + dto.getServicePlanId(), + dto.getCampaignId(), + ScheduledSmsProvisioningDtoConverter.convert(dto.getScheduledProvisioning())); + } + + public static SMSConfigurationDto convert( + ActiveNumberUpdateSMSConfigurationRequestParameters configuration) { + + if (null == configuration) { + return null; + } + SMSConfigurationDto dto = new SMSConfigurationDto(); + dto.servicePlanId(configuration.getServicePlanId()); + configuration.getCampaignId().ifPresent(dto::campaignId); + return dto; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java new file mode 100644 index 00000000..9f7111f7 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java @@ -0,0 +1,29 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import com.sinch.sdk.domains.numbers.models.VoiceConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.VoiceConfigurationDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters; + +public class VoiceConfigurationDtoConverter { + + public static VoiceConfiguration convert(VoiceConfigurationDto dto) { + + if (null == dto) { + return null; + } + return new VoiceConfiguration( + dto.getAppId(), + null != dto.getLastUpdatedTime() ? dto.getLastUpdatedTime().toInstant() : null, + ScheduledVoiceProvisioningDtoConverter.convert(dto.getScheduledVoiceProvisioning())); + } + + public static VoiceConfigurationDto convert( + ActiveNumberUpdateVoiceConfigurationRequestParameters configuration) { + + if (null == configuration) { + return null; + } + + return new VoiceConfigurationDto().appId(configuration.getAppId()); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java new file mode 100644 index 00000000..854c4dcd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java @@ -0,0 +1,288 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * Active Number + * + * @since 1.0 + */ +public class ActiveNumber { + private final String phoneNumber; + + private final String projectId; + + private final String displayName; + + private final String regionCode; + + private final NumberType type; + + private final Collection capability; + + private final Money money; + + private final Integer paymentIntervalMonths; + + private final Instant nextChargeDate; + + private final Instant expireAt; + + private final SMSConfiguration smsConfiguration; + + private final VoiceConfiguration voiceConfiguration; + + private final String callbackUrl; + + /** + * @param phoneNumber The phone number in E.164 format with leading +. Example: +12025550134. + * @param projectId Project ID. Your project ID can be found on your Sinch Customer Dashboard. + * @param displayName User supplied name for the phone number. + * @param regionCode ISO 3166-1 alpha-2 country code of the phone number. Example US, UK or SE. + * @param type The number type. + * @param capability The capability of the number + * @param money An object giving details on currency code and the amount charged. + * @param paymentIntervalMonths How often the recurring price is charged in months. + * @param nextChargeDate The date of the next charge + * @param expireAt The timestamp when the subscription will expire if an expiration date has been + * set. + * @param smsConfiguration The current SMS configuration for this number. + * @param voiceConfiguration The current voice configuration for this number. + * @param callbackUrl The callback URL to be called for a rented number's provisioning / + * deprovisioning operations. + */ + public ActiveNumber( + String phoneNumber, + String projectId, + String displayName, + String regionCode, + NumberType type, + Collection capability, + Money money, + Integer paymentIntervalMonths, + Instant nextChargeDate, + Instant expireAt, + SMSConfiguration smsConfiguration, + VoiceConfiguration voiceConfiguration, + String callbackUrl) { + this.phoneNumber = phoneNumber; + this.projectId = projectId; + this.displayName = displayName; + this.regionCode = regionCode; + this.type = type; + this.capability = capability; + this.money = money; + this.paymentIntervalMonths = paymentIntervalMonths; + this.nextChargeDate = nextChargeDate; + this.expireAt = expireAt; + this.smsConfiguration = smsConfiguration; + this.voiceConfiguration = voiceConfiguration; + this.callbackUrl = callbackUrl; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public String getProjectId() { + return projectId; + } + + public String getDisplayName() { + return displayName; + } + + public String getRegionCode() { + return regionCode; + } + + public NumberType getType() { + return type; + } + + public Collection getCapability() { + return capability; + } + + public Money getMoney() { + return money; + } + + public Integer getPaymentIntervalMonths() { + return paymentIntervalMonths; + } + + public Instant getNextChargeDate() { + return nextChargeDate; + } + + public Instant getExpireAt() { + return expireAt; + } + + public SMSConfiguration getSmsConfiguration() { + return smsConfiguration; + } + + public VoiceConfiguration getVoiceConfiguration() { + return voiceConfiguration; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "ActiveNumber{" + + "phoneNumber='" + + phoneNumber + + '\'' + + ", projectId='" + + projectId + + '\'' + + ", displayName='" + + displayName + + '\'' + + ", regionCode='" + + regionCode + + '\'' + + ", type=" + + type + + ", capability=" + + capability + + ", money=" + + money + + ", paymentIntervalMonths=" + + paymentIntervalMonths + + ", nextChargeDate=" + + nextChargeDate + + ", expireAt=" + + expireAt + + ", smsConfiguration=" + + smsConfiguration + + ", voiceConfiguration=" + + voiceConfiguration + + ", callbackUrl='" + + callbackUrl + + '\'' + + '}'; + } + + public static class Builder { + private String phoneNumber; + + private String projectId; + + private String displayName; + + private String regionCode; + + private NumberType type; + + private Collection capability; + + private Money money; + + private Integer paymentIntervalMonths; + + private Instant nextChargeDate; + + private Instant expireAt; + + private SMSConfiguration smsConfiguration; + + private VoiceConfiguration voiceConfiguration; + + private String callbackUrl; + + private Builder() {} + + public ActiveNumber build() { + return new ActiveNumber( + phoneNumber, + projectId, + displayName, + regionCode, + type, + capability, + money, + paymentIntervalMonths, + nextChargeDate, + expireAt, + smsConfiguration, + voiceConfiguration, + callbackUrl); + } + + public Builder setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + public Builder setProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public Builder setDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setType(NumberType type) { + this.type = type; + return this; + } + + public Builder setCapability(Collection capability) { + this.capability = capability; + return this; + } + + public Builder setMoney(Money money) { + this.money = money; + return this; + } + + public Builder setPaymentIntervalMonths(Integer paymentIntervalMonths) { + this.paymentIntervalMonths = paymentIntervalMonths; + return this; + } + + public Builder setNextChargeDate(Instant nextChargeDate) { + this.nextChargeDate = nextChargeDate; + return this; + } + + public Builder setExpireAt(Instant expireAt) { + this.expireAt = expireAt; + return this; + } + + public Builder setSmsConfiguration(SMSConfiguration smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + public Builder setVoiceConfiguration(VoiceConfiguration voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java b/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java new file mode 100644 index 00000000..77f92940 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java @@ -0,0 +1,189 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Collection; + +/** + * Active Number + * + * @since 1.0 + */ +public class AvailableNumber { + private final String phoneNumber; + + private final String regionCode; + + private final NumberType type; + + private final Collection capability; + + private final Money setupPrice; + + private final Money monthlyPrice; + + private final Integer paymentIntervalMonths; + + private final Boolean supportingDocumentationRequired; + + /** + * @param phoneNumber The phone number in E.164 format with leading +. Example +12025550134. + * @param regionCode ISO 3166-1 alpha-2 country code of the phone number. Example: US, UK or SE. + * @param type The number type. + * @param capability The capability of the number. + * @param setupPrice An object giving details on currency code and the amount charged. + * @param monthlyPrice An object giving details on currency code and the amount charged. + * @param paymentIntervalMonths How often the recurring price is charged in months. + * @param supportingDocumentationRequired Whether or not supplementary documentation will be + * required to complete the number rental. + */ + public AvailableNumber( + String phoneNumber, + String regionCode, + NumberType type, + Collection capability, + Money setupPrice, + Money monthlyPrice, + Integer paymentIntervalMonths, + Boolean supportingDocumentationRequired) { + this.phoneNumber = phoneNumber; + this.regionCode = regionCode; + this.type = type; + this.capability = capability; + this.setupPrice = setupPrice; + this.monthlyPrice = monthlyPrice; + this.paymentIntervalMonths = paymentIntervalMonths; + this.supportingDocumentationRequired = supportingDocumentationRequired; + } + + public String getPhoneNumber() { + return phoneNumber; + } + + public String getRegionCode() { + return regionCode; + } + + public NumberType getType() { + return type; + } + + public Collection getCapability() { + return capability; + } + + public Money getSetupPrice() { + return setupPrice; + } + + public Money getMonthlyPrice() { + return monthlyPrice; + } + + public Integer getPaymentIntervalMonths() { + return paymentIntervalMonths; + } + + public Boolean getSupportingDocumentationRequired() { + return supportingDocumentationRequired; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "AvailableNumber{" + + "phoneNumber='" + + phoneNumber + + '\'' + + ", regionCode='" + + regionCode + + '\'' + + ", type='" + + type + + '\'' + + ", capability=" + + capability + + ", setupPrice=" + + setupPrice + + ", monthlyPrice=" + + monthlyPrice + + ", paymentIntervalMonths=" + + paymentIntervalMonths + + ", supportingDocumentationRequired=" + + supportingDocumentationRequired + + '}'; + } + + public static class Builder { + private String phoneNumber; + + private String regionCode; + + private NumberType type; + + private Collection capability; + + private Money setupPrice; + + private Money monthlyPrice; + + private Integer paymentIntervalMonths; + + private Boolean supportingDocumentationRequired; + + private Builder() {} + + public AvailableNumber build() { + return new AvailableNumber( + phoneNumber, + regionCode, + type, + capability, + setupPrice, + monthlyPrice, + paymentIntervalMonths, + supportingDocumentationRequired); + } + + public Builder setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setType(NumberType type) { + this.type = type; + return this; + } + + public Builder setCapability(Collection capability) { + this.capability = capability; + return this; + } + + public Builder setSetupPrice(Money setupPrice) { + this.setupPrice = setupPrice; + return this; + } + + public Builder setMonthlyPrice(Money monthlyPrice) { + this.monthlyPrice = monthlyPrice; + return this; + } + + public Builder setPaymentIntervalMonths(Integer paymentIntervalMonths) { + this.paymentIntervalMonths = paymentIntervalMonths; + return this; + } + + public Builder setSupportingDocumentationRequired(Boolean supportingDocumentationRequired) { + this.supportingDocumentationRequired = supportingDocumentationRequired; + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java new file mode 100644 index 00000000..9fc758ae --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; + +/** + * Callback configuration + * + * @since 1.0 + */ +public class CallbackConfiguration { + private final String projectId; + + private final String hmacSecret; + + /** + * @param projectId ID of the project the configuration belongs to. + * @param hmacSecret The HMAC secret used for creating the callbacks X-Sinch-Signature header. + */ + public CallbackConfiguration(String projectId, String hmacSecret) { + this.projectId = projectId; + this.hmacSecret = hmacSecret; + } + + public String getProjectId() { + return projectId; + } + + public String getHMACSecret() { + return hmacSecret; + } + + @Override + public String toString() { + // do not output secret ! + return "CallbackConfiguration{" + + "projectId='" + + projectId + + '\'' + + ", hmacSecret='" + + "..." + + '\'' + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private String projectId; + + private String hmacSecret; + + private Builder() {} + + public CallbackConfiguration build() { + return new CallbackConfiguration(projectId, hmacSecret); + } + + public Builder setProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public Builder setHMACSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java new file mode 100644 index 00000000..597999fb --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Capability of a phone number + * + * @since 1.0 + */ +public final class Capability extends EnumDynamic { + /** The SMS product can use the number. */ + public static final Capability SMS = new Capability("SMS"); + + /** The Voice product can use the number. */ + public static final Capability VOICE = new Capability("VOICE"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(Capability.class, Capability::new, Arrays.asList(SMS, VOICE)); + + private Capability(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static Capability from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(Capability e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java new file mode 100644 index 00000000..c9d63ee5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; + +/** + * An object giving details on currency code and the amount charged. + * + * @since 1.0 + */ +public class Money { + private final String currencyCode; + + private final Double amount; + + /** + * @param currencyCode The 3-letter currency code defined in ISO 4217. + * @param amount The amount. There are no guarantees on the precision unless documented by the + * message origin. The amount cannot be updated and is read-only. + */ + public Money(String currencyCode, Double amount) { + this.currencyCode = currencyCode; + this.amount = amount; + } + + public String getCurrencyCode() { + return currencyCode; + } + + public Double getAmount() { + return amount; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "Money{" + "currencyCode='" + currencyCode + '\'' + ", amount='" + amount + '\'' + '}'; + } + + public static class Builder { + private String currencyCode; + + private Double amount; + + private Builder() {} + + Builder setCurrencyCode(String value) { + this.currencyCode = value; + return this; + } + + Builder setAmount(Double value) { + this.amount = value; + return this; + } + + Money build() { + return new Money(this.currencyCode, this.amount); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java new file mode 100644 index 00000000..9505827e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java @@ -0,0 +1,69 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; + +/** + * An object enabling to identify number by pattern + * + * @since 1.0 + */ +public class NumberPattern { + + private final String pattern; + private final SearchPattern searchPattern; + + /** + * @param pattern Sequence of digits to search for. + * @param searchPattern The pattern to apply to searches + */ + public NumberPattern(String pattern, SearchPattern searchPattern) { + this.pattern = pattern; + this.searchPattern = searchPattern; + } + + public String getPattern() { + return pattern; + } + + public SearchPattern getSearchPattern() { + return searchPattern; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "NumberPattern{" + + "pattern='" + + pattern + + '\'' + + ", searchPattern='" + + searchPattern + + '\'' + + '}'; + } + + public static class Builder { + private String pattern; + + private SearchPattern searchPattern; + + private Builder() {} + + public Builder setPattern(String value) { + this.pattern = value; + return this; + } + + public Builder setSearchPattern(SearchPattern value) { + this.searchPattern = value; + return this; + } + + public NumberPattern build() { + return new NumberPattern(this.pattern, this.searchPattern); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java new file mode 100644 index 00000000..e4d58982 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java @@ -0,0 +1,42 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Type of phone number + * + * @since 1.0 + */ +public final class NumberType extends EnumDynamic { + + /** Numbers that belong to a specific range. */ + public static final NumberType MOBILE = new NumberType("MOBILE"); + /** Numbers that are assigned to a specific geographic region. */ + public static final NumberType LOCAL = new NumberType("LOCAL"); + + /** Numbers that are free of charge for the calling party but billed for all arriving calls. */ + public static final NumberType TOLL_FREE = new NumberType("TOLL_FREE"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + NumberType.class, NumberType::new, Arrays.asList(MOBILE, LOCAL, TOLL_FREE)); + + private NumberType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static NumberType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(NumberType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java b/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java new file mode 100644 index 00000000..9717c3e8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Supported fields for ordering + * + * @since 1.0 + */ +public final class OrderBy extends EnumDynamic { + /** Ordering by phoneNumber */ + public static final OrderBy PHONE_NUMBER = new OrderBy("phoneNumber"); + /** Ordering by displayName */ + public static final OrderBy DISPLAY_NAME = new OrderBy("displayName"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + OrderBy.class, OrderBy::new, Arrays.asList(PHONE_NUMBER, DISPLAY_NAME)); + + private OrderBy(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static OrderBy from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(OrderBy e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java new file mode 100644 index 00000000..4b9cd6a6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java @@ -0,0 +1,51 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Provisioning Status + * + * @see https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/ + * @since 1.0 + */ +public final class ProvisioningStatus extends EnumDynamic { + + public static final ProvisioningStatus PROVISIONING_STATUS_UNSPECIFIED = + new ProvisioningStatus("PROVISIONING_STATUS_UNSPECIFIED"); + public static final ProvisioningStatus WAITING = new ProvisioningStatus("WAITING"); + public static final ProvisioningStatus IN_PROGRESS = new ProvisioningStatus("IN_PROGRESS"); + public static final ProvisioningStatus FAILED = new ProvisioningStatus("FAILED"); + public static final ProvisioningStatus UNKNOWN_DEFAULT_OPEN_API = + new ProvisioningStatus("UNKNOWN_DEFAULT_OPEN_API"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + ProvisioningStatus.class, + ProvisioningStatus::new, + Arrays.asList( + PROVISIONING_STATUS_UNSPECIFIED, + WAITING, + IN_PROGRESS, + FAILED, + UNKNOWN_DEFAULT_OPEN_API)); + + ProvisioningStatus(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static ProvisioningStatus from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(ProvisioningStatus e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java new file mode 100644 index 00000000..c4b26ae9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java @@ -0,0 +1,89 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import java.util.Collection; + +/** + * Region information related to assigned numbers + * + * @since 1.0 + */ +public class Region { + private final String regionCode; + + private final String regionName; + + private final Collection types; + + /** + * @param regionCode ISO 3166-1 alpha-2 region code. Examples: US, UK or SE. + * @param regionName Display name of the region. Examples: United States, United Kingdom or + * Sweden. + * @param types A list of the different number types available. + */ + public Region(String regionCode, String regionName, Collection types) { + this.regionCode = regionCode; + this.regionName = regionName; + this.types = types; + } + + public String getRegionCode() { + return regionCode; + } + + public String getRegionName() { + return regionName; + } + + public Collection getTypes() { + return types; + } + + @Override + public String toString() { + return "AvailableRegion{" + + "regionCode='" + + regionCode + + '\'' + + ", regionName='" + + regionName + + '\'' + + ", types=" + + types + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + private String regionCode; + + private String regionName; + + private Collection types; + + private Builder() {} + + public Region build() { + return new Region(regionCode, regionName, types); + } + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setRegionName(String regionName) { + this.regionName = regionName; + return this; + } + + public Builder setTypes(Collection types) { + this.types = types; + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java new file mode 100644 index 00000000..678d92c7 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Optional; + +/** The SMS configuration for a number */ +public class SMSConfiguration { + private final String servicePlanId; + + private final String campaignId; + + private final ScheduledSmsProvisioning scheduledSmsProvisioning; + + /** + * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The + * service plan ID is what ties this to the configured SMS service. + * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic to + * US; click here to read more about 10DLC A2P messaging. So, it is the current campaign ID + * for this number. The campaignId is found on your TCR platform. + * @param scheduledSmsProvisioning This object is temporary and will appear while the scheduled + * provisioning for SMS is processing. Once it has successfully processed, only the ID of the + * SMS configuration will display. + */ + public SMSConfiguration( + String servicePlanId, String campaignId, ScheduledSmsProvisioning scheduledSmsProvisioning) { + this.servicePlanId = servicePlanId; + this.campaignId = campaignId; + this.scheduledSmsProvisioning = scheduledSmsProvisioning; + } + + public String getServicePlanId() { + return servicePlanId; + } + + public Optional getCampaignId() { + return Optional.ofNullable(campaignId); + } + + public Optional getScheduledSmsProvisioning() { + return Optional.ofNullable(scheduledSmsProvisioning); + } + + @Override + public String toString() { + return "SMSConfiguration{" + + "servicePlanId='" + + servicePlanId + + '\'' + + ", campaignId='" + + campaignId + + '\'' + + ", scheduledSmsProvisioning=" + + scheduledSmsProvisioning + + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java new file mode 100644 index 00000000..33f57ca0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java @@ -0,0 +1,82 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * Scheduled SMS provisioning information + * + *

This object is temporary and will appear while the scheduled provisioning for SMS is + * processing. Once it has successfully processed, only the ID of the SMS configuration will + * display. + */ +public class ScheduledSmsProvisioning { + private final String servicePlanId; + + private final String campaignId; + + private final ProvisioningStatus status; + + private final Instant lastUpdatedTime; + + private final Collection errorCodes; + + /** + * @param servicePlanId Service plan of the scheduled provisioning task. + * @param campaignId Campaign ID of the scheduled provisioning task. Note that the campaign ID is + * only for US numbers as it relates to 10DLC. + * @param status The provisioning status + * @param lastUpdatedTime when the status was last updated + * @param errorCodes The provisioning error codes + */ + public ScheduledSmsProvisioning( + String servicePlanId, + String campaignId, + ProvisioningStatus status, + Instant lastUpdatedTime, + Collection errorCodes) { + this.servicePlanId = servicePlanId; + this.campaignId = campaignId; + this.status = status; + this.lastUpdatedTime = lastUpdatedTime; + this.errorCodes = errorCodes; + } + + public String getServicePlanId() { + return servicePlanId; + } + + public String getCampaignId() { + return campaignId; + } + + public ProvisioningStatus getStatus() { + return status; + } + + public Instant getLastUpdatedTime() { + return lastUpdatedTime; + } + + public Collection getErrorCodes() { + return errorCodes; + } + + @Override + public String toString() { + return "ScheduledSmsProvisioning{" + + "servicePlanId='" + + servicePlanId + + '\'' + + ", campaignId='" + + campaignId + + '\'' + + ", status=" + + status + + ", lastUpdatedTime=" + + lastUpdatedTime + + ", errorCodes=" + + errorCodes + + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledVoiceProvisioning.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledVoiceProvisioning.java new file mode 100644 index 00000000..9f38c604 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledVoiceProvisioning.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; + +/** + * Scheduled Voice provisioning information + * + *

This object is temporary and will appear while the scheduled voice provisioning is processing. + * Once it has successfully processed, only the ID of the Voice configuration will display. + */ +public class ScheduledVoiceProvisioning { + + private final String appId; + + private final ProvisioningStatus status; + + private final Instant lastUpdatedTime; + + /** + * @param appId RTC application ID of the scheduled provisioning task. + * @param status The provisioning status + * @param lastUpdatedTime when the status was last updated + */ + public ScheduledVoiceProvisioning( + String appId, ProvisioningStatus status, Instant lastUpdatedTime) { + this.appId = appId; + this.status = status; + this.lastUpdatedTime = lastUpdatedTime; + } + + public String getAppId() { + return appId; + } + + public ProvisioningStatus getStatus() { + return status; + } + + public Instant getLastUpdatedTime() { + return lastUpdatedTime; + } + + @Override + public String toString() { + return "ScheduledVoiceProvisioning{" + + "appId='" + + appId + + '\'' + + ", status=" + + status + + ", lastUpdatedTime=" + + lastUpdatedTime + + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/SearchPattern.java b/client/src/main/com/sinch/sdk/domains/numbers/models/SearchPattern.java new file mode 100644 index 00000000..f5e2323c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/SearchPattern.java @@ -0,0 +1,36 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; + +/** + * Search pattern for numbers + * + * @since 1.0 + */ +public final class SearchPattern extends EnumDynamic { + /** + * Numbers that begin with the @see NumberPattern.getPattern entered. + * + *

Often used to search for a specific area code. When using START, a plus sign (+) must be + * included and URL encoded, so %2B. + * + *

For example, to search for area code 206 in the US, you would enter, %2b1206 + */ + public static final SearchPattern START = new SearchPattern("START"); + /** + * The number pattern entered is contained somewhere in the number, the location being undefined. + */ + public static final SearchPattern CONTAINS = new SearchPattern("CONTAINS"); + /** The number ends with the number pattern entered. */ + public static final SearchPattern END = new SearchPattern("END"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + SearchPattern.class, SearchPattern::new, Arrays.asList(START, CONTAINS, END)); + + private SearchPattern(String value) { + super(value); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java b/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java new file mode 100644 index 00000000..18007c3a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java @@ -0,0 +1,85 @@ +package com.sinch.sdk.domains.numbers.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * @see https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/ + * @since 1.0 + */ +public final class SmsErrorCode extends EnumDynamic { + public static final SmsErrorCode ERROR_CODE_UNSPECIFIED = + new SmsErrorCode("ERROR_CODE_UNSPECIFIED"); + public static final SmsErrorCode INTERNAL_ERROR = new SmsErrorCode("INTERNAL_ERROR"); + public static final SmsErrorCode SMS_PROVISIONING_FAILED = + new SmsErrorCode("SMS_PROVISIONING_FAILED"); + public static final SmsErrorCode CAMPAIGN_PROVISIONING_FAILED = + new SmsErrorCode("CAMPAIGN_PROVISIONING_FAILED"); + public static final SmsErrorCode CAMPAIGN_NOT_AVAILABLE = + new SmsErrorCode("CAMPAIGN_NOT_AVAILABLE"); + public static final SmsErrorCode EXCEEDED_10DLC_LIMIT = new SmsErrorCode("EXCEEDED_10DLC_LIMIT"); + public static final SmsErrorCode NUMBER_PROVISIONING_FAILED = + new SmsErrorCode("NUMBER_PROVISIONING_FAILED"); + public static final SmsErrorCode PARTNER_SERVICE_UNAVAILABLE = + new SmsErrorCode("PARTNER_SERVICE_UNAVAILABLE"); + public static final SmsErrorCode CAMPAIGN_PENDING_ACCEPTANCE = + new SmsErrorCode("CAMPAIGN_PENDING_ACCEPTANCE"); + public static final SmsErrorCode MNO_SHARING_ERROR = new SmsErrorCode("MNO_SHARING_ERROR"); + public static final SmsErrorCode CAMPAIGN_EXPIRED = new SmsErrorCode("CAMPAIGN_EXPIRED"); + public static final SmsErrorCode CAMPAIGN_MNO_REJECTED = + new SmsErrorCode("CAMPAIGN_MNO_REJECTED"); + public static final SmsErrorCode CAMPAIGN_MNO_SUSPENDED = + new SmsErrorCode("CAMPAIGN_MNO_SUSPENDED"); + public static final SmsErrorCode CAMPAIGN_MNO_REVIEW = new SmsErrorCode("CAMPAIGN_MNO_REVIEW"); + public static final SmsErrorCode INSUFFICIENT_BALANCE = new SmsErrorCode("INSUFFICIENT_BALANCE"); + public static final SmsErrorCode MOCK_CAMPAIGN_NOT_ALLOWED = + new SmsErrorCode("MOCK_CAMPAIGN_NOT_ALLOWED"); + public static final SmsErrorCode TFN_NOT_ALLOWED = new SmsErrorCode("TFN_NOT_ALLOWED"); + public static final SmsErrorCode INVALID_NNID = new SmsErrorCode("INVALID_NNID"); + public static final SmsErrorCode UNKNOWN_DEFAULT_OPEN_API = + new SmsErrorCode("UNKNOWN_DEFAULT_OPEN_API"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + SmsErrorCode.class, + SmsErrorCode::new, + Arrays.asList( + ERROR_CODE_UNSPECIFIED, + INTERNAL_ERROR, + SMS_PROVISIONING_FAILED, + CAMPAIGN_PROVISIONING_FAILED, + CAMPAIGN_NOT_AVAILABLE, + EXCEEDED_10DLC_LIMIT, + NUMBER_PROVISIONING_FAILED, + PARTNER_SERVICE_UNAVAILABLE, + CAMPAIGN_PENDING_ACCEPTANCE, + MNO_SHARING_ERROR, + CAMPAIGN_EXPIRED, + CAMPAIGN_MNO_REJECTED, + CAMPAIGN_MNO_SUSPENDED, + CAMPAIGN_MNO_REVIEW, + INSUFFICIENT_BALANCE, + MOCK_CAMPAIGN_NOT_ALLOWED, + TFN_NOT_ALLOWED, + INVALID_NNID, + UNKNOWN_DEFAULT_OPEN_API)); + + SmsErrorCode(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static SmsErrorCode from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(SmsErrorCode e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java new file mode 100644 index 00000000..d596c380 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java @@ -0,0 +1,59 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; +import java.util.Optional; + +/** + * The voice configuration for a number + * + * @since 1.0 + */ +public class VoiceConfiguration { + private final String appId; + + private final Instant lastUpdatedTime; + + private final ScheduledVoiceProvisioning scheduledVoiceProvisioning; + + /** + * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer + * Dashboard under Voice, then apps. + * @param lastUpdatedTime when the status was last updated + * @param scheduledVoiceProvisioning This object is temporary and will appear while the scheduled + * voice provisioning is processing. Once it has successfully processed, only the ID of the + * Voice configuration will display. + */ + public VoiceConfiguration( + String appId, + Instant lastUpdatedTime, + ScheduledVoiceProvisioning scheduledVoiceProvisioning) { + this.appId = appId; + this.lastUpdatedTime = lastUpdatedTime; + this.scheduledVoiceProvisioning = scheduledVoiceProvisioning; + } + + public String getAppId() { + return appId; + } + + public Optional getLastUpdatedTime() { + return Optional.ofNullable(lastUpdatedTime); + } + + public Optional getScheduledVoiceProvisioning() { + return Optional.ofNullable(scheduledVoiceProvisioning); + } + + @Override + public String toString() { + return "VoiceConfiguration{" + + "appId='" + + appId + + '\'' + + ", lastUpdatedTime=" + + lastUpdatedTime + + ", scheduledVoiceProvisioning=" + + scheduledVoiceProvisioning + + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/package-info.java new file mode 100644 index 00000000..e06d5c10 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers API related models + * + * @since 1.0 + */ +package com.sinch.sdk.domains.numbers.models; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java new file mode 100644 index 00000000..377f53b2 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java @@ -0,0 +1,168 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.OrderBy; +import java.util.Collection; +import java.util.Optional; + +/** + * Parameters request to list active numbers for a project + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/ + * @since 1.0 + */ +public class ActiveNumberListRequestParameters { + private final String regionCode; + private final NumberType type; + private final NumberPattern numberPattern; + private final Collection capabilities; + private final Integer pageSize; + private final String pageToken; + private final OrderBy orderBy; + + /** + * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone + * number. Example: US, GB or SE. + * @param type Number type to filter by + * @param numberPattern Pattern to search for + * @param capabilities Number capabilities to filter by + * @param pageSize The maximum number of items to return. + * @param pageToken The next page token value returned from a previous List request, if any + * @param orderBy Ordering results + */ + public ActiveNumberListRequestParameters( + String regionCode, + NumberType type, + NumberPattern numberPattern, + Collection capabilities, + Integer pageSize, + String pageToken, + OrderBy orderBy) { + this.regionCode = regionCode; + this.type = type; + this.numberPattern = numberPattern; + this.capabilities = capabilities; + this.pageSize = pageSize; + this.pageToken = pageToken; + this.orderBy = orderBy; + } + + public String getRegionCode() { + return regionCode; + } + + public NumberType getType() { + return type; + } + + public Optional getNumberPattern() { + return Optional.ofNullable(numberPattern); + } + + public Optional> getCapabilities() { + return Optional.ofNullable(capabilities); + } + + public Optional getPageSize() { + return Optional.ofNullable(pageSize); + } + + public Optional getPageToken() { + return Optional.ofNullable(pageToken); + } + + public Optional getOrderBy() { + return Optional.ofNullable(orderBy); + } + + @Override + public String toString() { + return "ActiveNumberListRequestParameters{" + + "regionCode='" + + regionCode + + '\'' + + ", type=" + + type + + ", numberPattern=" + + numberPattern + + ", capabilities=" + + capabilities + + ", pageSize=" + + pageSize + + ", pageToken=" + + pageToken + + ", orderBy=" + + orderBy + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String regionCode; + NumberType type; + NumberPattern numberPattern; + Collection capabilities; + Integer pageSize; + String pageToken; + OrderBy orderBy; + + private Builder() {} + + public Builder(ActiveNumberListRequestParameters parameters) { + this.setRegionCode(parameters.regionCode) + .setType(parameters.type) + .setNumberPattern(parameters.numberPattern) + .setCapabilities(parameters.capabilities) + .setPageSize(parameters.pageSize) + .setPageToken(parameters.pageToken) + .setOrderBy(parameters.orderBy); + } + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setType(NumberType type) { + this.type = type; + return this; + } + + public Builder setNumberPattern(NumberPattern numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + public Builder setCapabilities(Collection capabilities) { + this.capabilities = capabilities; + return this; + } + + public Builder setPageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + public Builder setPageToken(String pageToken) { + this.pageToken = pageToken; + return this; + } + + public Builder setOrderBy(OrderBy orderBy) { + this.orderBy = orderBy; + return this; + } + + public ActiveNumberListRequestParameters build() { + return new ActiveNumberListRequestParameters( + regionCode, type, numberPattern, capabilities, pageSize, pageToken, orderBy); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java new file mode 100644 index 00000000..734cb6e8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java @@ -0,0 +1,92 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import java.util.Optional; + +/** + * Parameters request to update an active number for a project + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/#tag/Active-Number/operation/NumberService_UpdateActiveNumber + * @since 1.0 + */ +public class ActiveNumberUpdateRequestParameters { + private final String displayName; + private final ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration; + private final ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration; + private final String callback; + + /** + * @param displayName User supplied name for the phone number + * @param smsConfiguration The current SMS configuration for this number + * @param voiceConfiguration The current voice configuration for this number + * @param callback The callback URL to be called for a rented number's provisioning / + * deprovisioning operations + */ + public ActiveNumberUpdateRequestParameters( + String displayName, + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration, + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration, + String callback) { + this.displayName = displayName; + this.smsConfiguration = smsConfiguration; + this.voiceConfiguration = voiceConfiguration; + this.callback = callback; + } + + public Optional getDisplayName() { + return Optional.ofNullable(displayName); + } + + public Optional getSmsConfiguration() { + return Optional.ofNullable(smsConfiguration); + } + + public Optional getVoiceConfiguration() { + return Optional.ofNullable(voiceConfiguration); + } + + public Optional getCallback() { + return Optional.ofNullable(callback); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String displayName; + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration; + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration; + String callback; + + private Builder() {} + + public Builder setDisplayName(String displayName) { + this.displayName = displayName; + return this; + } + + public Builder setSmsConfiguration( + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + public Builder setVoiceConfiguration( + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + public Builder setCallback(String callback) { + this.callback = callback; + return this; + } + + public ActiveNumberUpdateRequestParameters build() { + return new ActiveNumberUpdateRequestParameters( + displayName, smsConfiguration, voiceConfiguration, callback); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java new file mode 100644 index 00000000..93ca4008 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java @@ -0,0 +1,75 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import java.util.Optional; + +/*** + * SMS configuration parameters request to update an active number for a project + * @since 1.0 + */ +public class ActiveNumberUpdateSMSConfigurationRequestParameters { + private final String servicePlanId; + + private final String campaignId; + + /** + * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The + * service plan ID is what ties this number to the configured SMS service. + * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic to + * US; click here to read more about 10DLC A2P messaging. So, it is the current campaign ID + * for this number. The campaignId is found on your TCR platform. + */ + public ActiveNumberUpdateSMSConfigurationRequestParameters( + String servicePlanId, String campaignId) { + this.servicePlanId = servicePlanId; + this.campaignId = campaignId; + } + + public ActiveNumberUpdateSMSConfigurationRequestParameters(String servicePlanId) { + this(servicePlanId, null); + } + + public String getServicePlanId() { + return servicePlanId; + } + + public Optional getCampaignId() { + return Optional.ofNullable(campaignId); + } + + @Override + public String toString() { + return "ActiveNumberUpdateSMSConfigurationRequestParameters{" + + "servicePlanId='" + + servicePlanId + + '\'' + + ", campaignId=" + + campaignId + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String servicePlanId; + String campaignId; + + private Builder() {} + + public Builder setServicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + return this; + } + + public Builder setCampaignId(String campaignId) { + this.campaignId = campaignId; + return this; + } + + public ActiveNumberUpdateSMSConfigurationRequestParameters build() { + return new ActiveNumberUpdateSMSConfigurationRequestParameters(servicePlanId, campaignId); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java new file mode 100644 index 00000000..0989c0a6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java @@ -0,0 +1,52 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; + +/*** + * SMS configuration parameters request to update an active number for a project + * @since 1.0 + */ + +public class ActiveNumberUpdateVoiceConfigurationRequestParameters { + private final String appId; + + /** + * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer + * Dashboard under Voice, then apps. + */ + public ActiveNumberUpdateVoiceConfigurationRequestParameters(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } + + @Override + public String toString() { + return "ActiveNumberUpdateVoiceConfigurationRequestParameters{" + + "appId='" + + appId + + '\'' + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String appId; + + private Builder() {} + + public Builder setAppId(String appId) { + this.appId = appId; + return this; + } + + public ActiveNumberUpdateVoiceConfigurationRequestParameters build() { + return new ActiveNumberUpdateVoiceConfigurationRequestParameters(appId); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java new file mode 100644 index 00000000..65be9f07 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java @@ -0,0 +1,108 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.Collection; +import java.util.Optional; + +/** + * Parameters request to list available numbers for a project + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ + * @since 1.0 + */ +public class AvailableNumberListAllRequestParameters { + private final String regionCode; + private final NumberType type; + private final NumberPattern numberPattern; + private final Collection capabilities; + private final Integer size; + + /** + * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone + * number. Example: US, GB or SE. + * @param type Number type to filter by + * @param numberPattern Search pattern + * @param capabilities Capabilities to filter by + * @param size Optional. The maximum number of items to return. + */ + public AvailableNumberListAllRequestParameters( + String regionCode, + NumberType type, + NumberPattern numberPattern, + Collection capabilities, + Integer size) { + this.regionCode = regionCode; + this.type = type; + this.numberPattern = numberPattern; + this.capabilities = capabilities; + this.size = size; + } + + public String getRegionCode() { + return regionCode; + } + + public NumberType getType() { + return type; + } + + public Optional getNumberPattern() { + return Optional.ofNullable(numberPattern); + } + + public Optional> getCapabilities() { + return Optional.ofNullable(capabilities); + } + + public Optional getSize() { + return Optional.ofNullable(size); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String regionCode; + NumberType type; + NumberPattern numberPattern; + Collection capabilities; + Integer size; + + private Builder() {} + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setType(NumberType type) { + this.type = type; + return this; + } + + public Builder setNumberPattern(NumberPattern numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + public Builder setCapabilities(Collection capabilities) { + this.capabilities = capabilities; + return this; + } + + public Builder setSize(Integer size) { + this.size = size; + return this; + } + + public AvailableNumberListAllRequestParameters build() { + return new AvailableNumberListAllRequestParameters( + regionCode, type, numberPattern, capabilities, size); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java new file mode 100644 index 00000000..72235ff0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java @@ -0,0 +1,133 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.Collection; +import java.util.Optional; + +/** + * Parameters request to rent a number using criteria + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ + * @since 1.0 + */ +public class AvailableNumberRentAnyRequestParameters { + private final String regionCode; + private final NumberType type; + private final NumberPattern numberPattern; + private final Collection capabilities; + private final RentSMSConfigurationRequestParameters smsConfiguration; + private final RentVoiceConfigurationRequestParameters voiceConfiguration; + private final String callbackUrl; + + public AvailableNumberRentAnyRequestParameters( + String regionCode, + NumberType type, + NumberPattern numberPattern, + Collection capabilities, + RentSMSConfigurationRequestParameters smsConfiguration, + RentVoiceConfigurationRequestParameters voiceConfiguration, + String callbackUrl) { + this.regionCode = regionCode; + this.type = type; + this.numberPattern = numberPattern; + this.capabilities = capabilities; + this.smsConfiguration = smsConfiguration; + this.voiceConfiguration = voiceConfiguration; + this.callbackUrl = callbackUrl; + } + + public String getRegionCode() { + return regionCode; + } + + public NumberType getType() { + return type; + } + + public Optional getNumberPattern() { + return Optional.ofNullable(numberPattern); + } + + public Optional> getCapabilities() { + return Optional.ofNullable(capabilities); + } + + public Optional getSmsConfiguration() { + return Optional.ofNullable(smsConfiguration); + } + + public Optional getVoiceConfiguration() { + return Optional.ofNullable(voiceConfiguration); + } + + public Optional getCallBackUrl() { + return Optional.ofNullable(callbackUrl); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String regionCode; + NumberType type; + NumberPattern numberPattern; + Collection capabilities; + RentSMSConfigurationRequestParameters smsConfiguration; + RentVoiceConfigurationRequestParameters voiceConfiguration; + String callbackUrl; + + private Builder() {} + + public Builder setRegionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + public Builder setType(NumberType type) { + this.type = type; + return this; + } + + public Builder setNumberPattern(NumberPattern numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + public Builder setCapabilities(Collection capabilities) { + this.capabilities = capabilities; + return this; + } + + public Builder setSmsConfiguration(RentSMSConfigurationRequestParameters smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + public Builder setVoiceConfiguration( + RentVoiceConfigurationRequestParameters voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + public AvailableNumberRentAnyRequestParameters build() { + return new AvailableNumberRentAnyRequestParameters( + regionCode, + type, + numberPattern, + capabilities, + smsConfiguration, + voiceConfiguration, + callbackUrl); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java new file mode 100644 index 00000000..8227363a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java @@ -0,0 +1,81 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import java.util.Optional; + +/** + * Parameters request to rent a number + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_RentNumber + * @since 1.0 + */ +public class AvailableNumberRentRequestParameters { + private final RentSMSConfigurationRequestParameters smsConfiguration; + private final RentVoiceConfigurationRequestParameters voiceConfiguration; + private final String callbackUrl; + + /** + * @param smsConfiguration The current SMS configuration for this number + * @param voiceConfiguration The current voice configuration for this number. During scheduled + * provisioning, the app ID value may be empty in a response if it is still processing or if + * it has failed. The status of scheduled provisioning will show under a + * scheduledVoiceProvisioning object if it's still running. Once processed successfully, the + * appId sent will appear directly under the voiceConfiguration object. + * @param callbackUrl The callback URL to be called for a rented number's provisioning / + * deprovisioning operations. + */ + public AvailableNumberRentRequestParameters( + RentSMSConfigurationRequestParameters smsConfiguration, + RentVoiceConfigurationRequestParameters voiceConfiguration, + String callbackUrl) { + this.smsConfiguration = smsConfiguration; + this.voiceConfiguration = voiceConfiguration; + this.callbackUrl = callbackUrl; + } + + public Optional getSmsConfiguration() { + return Optional.of(smsConfiguration); + } + + public Optional getVoiceConfiguration() { + return Optional.of(voiceConfiguration); + } + + public Optional getCallBackUrl() { + return Optional.of(callbackUrl); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + RentSMSConfigurationRequestParameters smsConfiguration; + RentVoiceConfigurationRequestParameters voiceConfiguration; + String callbackUrl; + + private Builder() {} + + public Builder setSmsConfiguration(RentSMSConfigurationRequestParameters smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + public Builder setVoiceConfiguration( + RentVoiceConfigurationRequestParameters voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + public Builder setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + public AvailableNumberRentRequestParameters build() { + return new AvailableNumberRentRequestParameters( + smsConfiguration, voiceConfiguration, callbackUrl); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java new file mode 100644 index 00000000..543e89e4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java @@ -0,0 +1,46 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.Collection; +import java.util.Optional; + +/** + * Parameters request to list all regions by criteria + * + * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Regions/ + * @since 1.0 + */ +public class AvailableRegionListAllRequestParameters { + + private final Collection types; + + /** @param types Only return regions for which numbers are provided with the given types */ + public AvailableRegionListAllRequestParameters(Collection types) { + this.types = types; + } + + public Optional> getTypes() { + return Optional.ofNullable(types); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + Collection types; + + private Builder() {} + + public Builder setTypes(Collection types) { + this.types = types; + return this; + } + + public AvailableRegionListAllRequestParameters build() { + return new AvailableRegionListAllRequestParameters(types); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java new file mode 100644 index 00000000..3afb2f88 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; + +/** + * Parameters request to update callback configuration + * + * @see https://developers.sinch.com/docs/numbers/api-reference/callbacks-numbers/tag/Callback-Configuration/#tag/Callback-Configuration/operation/UpdateCallbackConfiguration + * @since 1.0 + */ +public class CallbackConfigurationUpdateRequestParameters { + /** */ + private final String hmacSecret; + + /** @param hmacSecret The HMAC secret to be updated for the specified project */ + public CallbackConfigurationUpdateRequestParameters(String hmacSecret) { + this.hmacSecret = hmacSecret; + } + + public String getHMACSecret() { + return hmacSecret; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String hmacSecret; + + private Builder() {} + + public Builder setHMACSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + return this; + } + + public CallbackConfigurationUpdateRequestParameters build() { + return new CallbackConfigurationUpdateRequestParameters(hmacSecret); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java new file mode 100644 index 00000000..9820089c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; +import java.util.Optional; + +/** + * SMS configuration parameters request to rent a number + * + * @since 1.0 + */ +public class RentSMSConfigurationRequestParameters { + private final String servicePlanId; + private final String campaignId; + + /** + * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The + * service plan ID is what ties this number to the configured SMS service. + * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic to + * US; click here to read more about 10DLC A2P messaging. So, it is the current campaign ID + * for this number. The campaignId is found on your TCR platform. + */ + public RentSMSConfigurationRequestParameters(String servicePlanId, String campaignId) { + this.servicePlanId = servicePlanId; + this.campaignId = campaignId; + } + + public RentSMSConfigurationRequestParameters(String servicePlanId) { + this(servicePlanId, null); + } + + public String getServicePlanId() { + return servicePlanId; + } + + public Optional getCampaignId() { + return Optional.ofNullable(this.campaignId); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String servicePlanId; + String campaignId; + + private Builder() {} + + public Builder setServicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + return this; + } + + public Builder setCampaignId(String campaignId) { + this.campaignId = campaignId; + return this; + } + + public RentSMSConfigurationRequestParameters build() { + return new RentSMSConfigurationRequestParameters(servicePlanId, campaignId); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java new file mode 100644 index 00000000..148ce6ad --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java @@ -0,0 +1,41 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +/** + * Voice configuration parameters request to rent a number + * + * @since 1.0 + */ +public class RentVoiceConfigurationRequestParameters { + private final String appId; + + /** + * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer + * Dashboard under Voice, then apps. + */ + public RentVoiceConfigurationRequestParameters(String appId) { + this.appId = appId; + } + + public String getAppId() { + return appId; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + String appId; + + private Builder() {} + + public Builder setAppId(String appId) { + this.appId = appId; + return this; + } + + public RentVoiceConfigurationRequestParameters build() { + return new RentVoiceConfigurationRequestParameters(appId); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java new file mode 100644 index 00000000..baf5491d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers API requests related models + * + * @since 1.0 + */ +package com.sinch.sdk.domains.numbers.models.requests; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java new file mode 100644 index 00000000..f2671a4b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java @@ -0,0 +1,53 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import com.sinch.sdk.core.models.pagination.ListResponse; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.core.utils.StringUtil; +import com.sinch.sdk.domains.numbers.ActiveNumberService; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import java.util.Collection; +import java.util.NoSuchElementException; + +/** + * Lists all active numbers for a project + * + * @since 1.0 + */ +public class ActiveNumberListResponse extends ListResponse { + + private final Page page; + private final ActiveNumberService service; + + public ActiveNumberListResponse( + ActiveNumberService service, + Page page) { + this.service = service; + this.page = page; + } + + public boolean hasNextPage() { + return (null != page.getNextPageToken() + && !StringUtil.isEmpty(page.getNextPageToken().getToken())); + } + + public ActiveNumberListResponse nextPage() { + if (!hasNextPage()) { + throw new NoSuchElementException("Reached the last page of the API response"); + } + ActiveNumberListRequestParameters.Builder newParameters = + new ActiveNumberListRequestParameters.Builder(page.getParameters()); + String nextToken = page.getNextPageToken().getToken(); + newParameters.setPageToken(nextToken); + return service.list(newParameters.build()); + } + + public Collection getContent() { + return page.getEntities(); + } + + @Override + public String toString() { + return "ActiveNumberListResponse{" + "page=" + page + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java new file mode 100644 index 00000000..b3310495 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java @@ -0,0 +1,37 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import com.sinch.sdk.core.models.pagination.ListResponse; +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +import java.util.Collection; +import java.util.NoSuchElementException; + +/** + * Lists all available numbers + * + * @since 1.0 + */ +public class AvailableNumberListResponse extends ListResponse { + + Collection content; + + public AvailableNumberListResponse(Collection list) { + this.content = list; + } + + public boolean hasNextPage() { + return false; + } + + public AvailableNumberListResponse nextPage() { + throw new NoSuchElementException("Reached the last page of the API response"); + } + + public Collection getContent() { + return content; + } + + @Override + public String toString() { + return "AvailableNumberListResponse{" + "content=" + content + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java new file mode 100644 index 00000000..927a6ede --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java @@ -0,0 +1,37 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import com.sinch.sdk.core.models.pagination.ListResponse; +import com.sinch.sdk.domains.numbers.models.Region; +import java.util.Collection; +import java.util.NoSuchElementException; + +/** + * Lists all regions for numbers provided for the project ID. + * + * @since 1.0 + */ +public class AvailableRegionListResponse extends ListResponse { + + Collection content; + + public AvailableRegionListResponse(Collection list) { + this.content = list; + } + + public boolean hasNextPage() { + return false; + } + + public AvailableRegionListResponse nextPage() { + throw new NoSuchElementException("Reached the last page of the API response"); + } + + public Collection getContent() { + return content; + } + + @Override + public String toString() { + return "AvailableRegionListResponse{" + "content=" + content + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java new file mode 100644 index 00000000..9fa13e9f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers API response related models + * + * @since 1.0 + */ +package com.sinch.sdk.domains.numbers.models.responses; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/package-info.java new file mode 100644 index 00000000..9944337d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers API interface + * + * @since 1.0 + */ +package com.sinch.sdk.domains.numbers; diff --git a/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java new file mode 100644 index 00000000..f6b2efe6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.sms; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.sms.models.Batch; + +/** + * Batches Service + * + * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/ + * @since 1.0 + */ +public interface BatchesService { + + /** + * Get a batch message + * + * @param batchId The batch ID you received from sending a message + * @return Batch information + * @since 1.0 + */ + > T get(String batchId) throws ApiException; +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java new file mode 100644 index 00000000..2947577e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java @@ -0,0 +1,19 @@ +package com.sinch.sdk.domains.sms; + +/** + * SMS Service + * + * @see https://developers.sinch.com/docs/sms/api-reference/ + * @since 1.0 + */ +public interface SMSService { + + /** + * Batches Service instance + * + * @return service instance for project + * @since 1.0 + */ + BatchesService batches(); +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java new file mode 100644 index 00000000..c021da1e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java @@ -0,0 +1,31 @@ +package com.sinch.sdk.domains.sms.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.domains.sms.adapters.api.v1.BatchesApi; +import com.sinch.sdk.domains.sms.adapters.converters.BatchDtoConverter; +import com.sinch.sdk.domains.sms.models.Batch; +import com.sinch.sdk.models.Configuration; + +public class BatchesService implements com.sinch.sdk.domains.sms.BatchesService { + + private Configuration configuration; + private BatchesApi api; + + public BatchesService() {} + + public BatchesService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.api = new BatchesApi(httpClient, configuration.getSmsServer(), new HttpMapper()); + } + + private BatchesApi getApi() { + return this.api; + } + + public > T get(String batchId) throws ApiException { + return BatchDtoConverter.convert( + getApi().getBatchMessage(configuration.getProjectId(), batchId)); + } +} 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 new file mode 100644 index 00000000..fd2f3a26 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java @@ -0,0 +1,26 @@ +package com.sinch.sdk.domains.sms.adapters; + +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.domains.sms.BatchesService; +import com.sinch.sdk.models.Configuration; + +public class SMSService implements com.sinch.sdk.domains.sms.SMSService { + + private final Configuration configuration; + private final HttpClient httpClient; + private BatchesService batches; + + public SMSService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.httpClient = httpClient; + } + + @Override + public BatchesService batches() { + if (null == this.batches) { + this.batches = + new com.sinch.sdk.domains.sms.adapters.BatchesService(configuration, httpClient); + } + return this.batches; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java new file mode 100644 index 00000000..d792241b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java @@ -0,0 +1,101 @@ +package com.sinch.sdk.domains.sms.adapters.converters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.sms.models.*; +import com.sinch.sdk.domains.sms.models.dto.v1.BinaryResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.MediaResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.SendSMS201ResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.TextResponseDto; + +public class BatchDtoConverter { + + public static > T convert(SendSMS201ResponseDto dto) { + Object obj = dto.getActualInstance(); + if (obj instanceof BinaryResponseDto) { + @SuppressWarnings("unchecked") + T t = (T) convertBinary(dto.getBinaryResponseDto()); + return t; + } else if (obj instanceof MediaResponseDto) { + @SuppressWarnings("unchecked") + T t = (T) convertMedia(dto.getMediaResponseDto()); + return t; + } else if (obj instanceof TextResponseDto) { + @SuppressWarnings("unchecked") + T t = (T) convertText(dto.getTextResponseDto()); + return t; + } else { + throw new ApiException("Unexpected class:" + obj.getClass().getName()); + } + } + + private static BatchBinary convertBinary(BinaryResponseDto dto) { + return BatchBinary.builder() + .setId(dto.getId()) + .setTo(dto.getTo()) + .setFrom(dto.getFrom()) + .setCanceled(dto.getCanceled()) + .setBody(dto.getBody()) + .setUdh(dto.getUdh()) + .setCreatedAt(dto.getCreatedAt().toInstant()) + .setModifiedAt(dto.getModifiedAt().toInstant()) + .setDeliveryReport(DeliveryReport.from(dto.getDeliveryReport())) + .setSendAt(dto.getSendAt().toInstant()) + .setExpireAt(dto.getExpireAt().toInstant()) + .setCallbackUrl(dto.getCallbackUrl()) + .setClientReference(dto.getClientReference()) + .setFeedbackEnabled(dto.getFeedbackEnabled()) + .setFlashMessage(dto.getFlashMessage()) + .setTruncateConcat(dto.getTruncateConcat()) + .setMaxNumberOfMessageParts(dto.getMaxNumberOfMessageParts()) + .setFromTon(dto.getFromTon()) + .setFromNpi(dto.getFromNpi()) + .build(); + } + + private static BatchMedia convertMedia(MediaResponseDto dto) { + return BatchMedia.builder() + .setId(dto.getId()) + .setTo(dto.getTo()) + .setFrom(dto.getFrom()) + .setCanceled(dto.getCanceled()) + .setBody( + MediaBody.builder() + .setMessage(dto.getBody().getMessage()) + .setUrl(dto.getBody().getUrl()) + .build()) + .setCreatedAt(dto.getCreatedAt().toInstant()) + .setModifiedAt(dto.getModifiedAt().toInstant()) + .setDeliveryReport(DeliveryReport.from(dto.getDeliveryReport())) + .setSendAt(dto.getSendAt().toInstant()) + .setExpireAt(dto.getExpireAt().toInstant()) + .setCallbackUrl(dto.getCallbackUrl()) + .setClientReference(dto.getClientReference()) + .setFeedbackEnabled(dto.getFeedbackEnabled()) + .setParameters(ParametersDtoConverter.convert(dto.getParameters())) + .build(); + } + + private static BatchText convertText(TextResponseDto dto) { + return BatchText.builder() + .setId(dto.getId()) + .setTo(dto.getTo()) + .setFrom(dto.getFrom()) + .setCanceled(dto.getCanceled()) + .setBody(dto.getBody()) + .setCreatedAt(dto.getCreatedAt().toInstant()) + .setModifiedAt(dto.getModifiedAt().toInstant()) + .setDeliveryReport(DeliveryReport.from(dto.getDeliveryReport())) + .setSendAt(dto.getSendAt().toInstant()) + .setExpireAt(dto.getExpireAt().toInstant()) + .setCallbackUrl(dto.getCallbackUrl()) + .setClientReference(dto.getClientReference()) + .setFeedbackEnabled(dto.getFeedbackEnabled()) + .setFlashMessage(dto.getFlashMessage()) + .setTruncateConcat(dto.getTruncateConcat()) + .setMaxNumberOfMessageParts(dto.getMaxNumberOfMessageParts()) + .setFromTon(dto.getFromTon()) + .setFromNpi(dto.getFromNpi()) + .setParameters(ParametersDtoConverter.convert(dto.getParameters())) + .build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java new file mode 100644 index 00000000..1d4a2bd6 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java @@ -0,0 +1,46 @@ +package com.sinch.sdk.domains.sms.adapters.converters; + +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.sms.models.Parameters; +import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjDto; +import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjParameterKeyDto; +import java.util.Map; +import java.util.stream.Collectors; + +public class ParametersDtoConverter { + + public static Parameters convert(ParameterObjDto dto) { + return new Parameters( + dto.entrySet().stream() + .map( + entry -> { + @SuppressWarnings("unchecked") + Map entryValue = (Map) entry.getValue(); + return new Parameters.Entry( + entry.getKey(), + entryValue.entrySet().stream() + .filter( + value -> + value + .getKey() + .compareTo( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT) + != 0) + .map(e -> new Pair<>(e.getKey(), e.getValue())) + .findFirst() + .orElse(null), + entryValue.entrySet().stream() + .filter( + value -> + value + .getKey() + .compareTo( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT) + == 0) + .map(Map.Entry::getValue) + .findFirst() + .orElse(null)); + }) + .collect(Collectors.toList())); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java b/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java new file mode 100644 index 00000000..9161adef --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java @@ -0,0 +1,303 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * Base class for Batch types + * + * @param Type of batch + * @since 1.0 + */ +public class Batch { + + private final String id; + + private final Collection to; + + private final String from; + + private final boolean canceled; + + private final T body; + + private final Instant createdAt; + + private final Instant modifiedAt; + + private final DeliveryReport deliveryReport; + + private final Instant sendAt; + + private final Instant expireAt; + + private final String callbackUrl; + + private final String clientReference; + + private final boolean feedbackEnabled; + + /** + * @param id Unique identifier for batch + * @param to List of Phone numbers and group IDs that will receive the batch + * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if + * Automatic Default Originator not configured. + * @param canceled Indicates if the batch has been canceled or not. + * @param body The message content + * @param createdAt when batch was created + * @param modifiedAt when batch was last updated + * @param deliveryReport Request delivery report callback. Note that delivery reports can be + * fetched from the API regardless of this setting + * @param sendAt 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 + * @param expireAt 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 + * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. + * @param clientReference The client identifier of a batch message. If set, the identifier will be + * added in the delivery report/callback of this batch + * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. + */ + public Batch( + String id, + Collection to, + String from, + boolean canceled, + T body, + Instant createdAt, + Instant modifiedAt, + DeliveryReport deliveryReport, + Instant sendAt, + Instant expireAt, + String callbackUrl, + String clientReference, + boolean feedbackEnabled) { + this.id = id; + this.to = to; + this.from = from; + this.canceled = canceled; + this.body = body; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + this.deliveryReport = deliveryReport; + this.sendAt = sendAt; + this.expireAt = expireAt; + this.callbackUrl = callbackUrl; + this.clientReference = clientReference; + this.feedbackEnabled = feedbackEnabled; + } + + public static BatchBuilder batchBuilder() { + return new BatchBuilder<>(); + } + + public String getId() { + return id; + } + + public Collection getTo() { + return to; + } + + public String getFrom() { + return from; + } + + public boolean isCanceled() { + return canceled; + } + + public T getBody() { + return body; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public Instant getModifiedAt() { + return modifiedAt; + } + + public DeliveryReport getDeliveryReport() { + return deliveryReport; + } + + public Instant getSendAt() { + return sendAt; + } + + public Instant getExpireAt() { + return expireAt; + } + + public String getCallbackUrl() { + return callbackUrl; + } + + public String getClientReference() { + return clientReference; + } + + public boolean isFeedbackEnabled() { + return feedbackEnabled; + } + + @Override + public String toString() { + return "Batch{" + + "id='" + + id + + '\'' + + ", to=" + + to + + ", from='" + + from + + '\'' + + ", canceled=" + + canceled + + ", body=" + + body + + ", createdAt=" + + createdAt + + ", modifiedAt=" + + modifiedAt + + ", deliveryReport=" + + deliveryReport + + ", sendAt=" + + sendAt + + ", expireAt=" + + expireAt + + ", callbackUrl='" + + callbackUrl + + '\'' + + ", clientReference='" + + clientReference + + '\'' + + ", feedbackEnabled=" + + feedbackEnabled + + '}'; + } + + protected static class Builder> { + + String id; + + Collection to; + + String from; + + boolean canceled; + + T body; + + Instant createdAt; + + Instant modifiedAt; + + DeliveryReport deliveryReport; + + Instant sendAt; + + Instant expireAt; + + String callbackUrl; + + String clientReference; + + boolean feedbackEnabled; + + public B setId(String id) { + this.id = id; + return self(); + } + + public B setTo(Collection to) { + this.to = to; + return self(); + } + + public B setFrom(String from) { + this.from = from; + return self(); + } + + public B setCanceled(boolean canceled) { + this.canceled = canceled; + return self(); + } + + public B setBody(T body) { + this.body = body; + return self(); + } + + public B setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + return self(); + } + + public B setModifiedAt(Instant modifiedAt) { + this.modifiedAt = modifiedAt; + return self(); + } + + public B setDeliveryReport(DeliveryReport deliveryReport) { + this.deliveryReport = deliveryReport; + return self(); + } + + public B setSendAt(Instant sendAt) { + this.sendAt = sendAt; + return self(); + } + + public B setExpireAt(Instant expireAt) { + this.expireAt = expireAt; + return self(); + } + + public B setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return self(); + } + + public B setClientReference(String clientReference) { + this.clientReference = clientReference; + return self(); + } + + public B setFeedbackEnabled(boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return self(); + } + + public Batch build() { + return new Batch<>( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } + + public static class BatchBuilder extends Batch.Builder> { + @Override + protected BatchBuilder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java new file mode 100644 index 00000000..650da72d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java @@ -0,0 +1,204 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * BatchBinary type + * + * @since 1.0 + */ +public class BatchBinary extends Batch { + private final boolean flashMessage; + private final boolean truncateConcat; + private final int maxNumberOfMessageParts; + private final int fromTon; + private final int fromNpi; + private final String udh; + + /** + * @param id Unique identifier for batch + * @param to List of Phone numbers and group IDs that will receive the batch + * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if + * Automatic Default Originator not configured. + * @param canceled Indicates if the batch has been canceled or not. + * @param body The message content + * @param createdAt when batch was created + * @param modifiedAt when batch was last updated + * @param deliveryReport Request delivery report callback. Note that delivery reports can be + * fetched from the API regardless of this setting + * @param sendAt 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 + * @param expireAt 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 + * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. + * @param clientReference The client identifier of a batch message. If set, the identifier will be + * added in the delivery report/callback of this batch + * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. * + * @param flashMessage If sent as a flash message, displays true. + * @param truncateConcat If set to true, the message was shortened when exceeding one part. + * @param maxNumberOfMessageParts Displays the number of message parts set in the request. + * @param fromTon The type of number for the sender number. + * @param fromNpi Number Plan Indicator for the sender number. + * @param udh The UDH header of a binary message HEX encoded. Max 140 bytes including the body. + */ + public BatchBinary( + String id, + Collection to, + String from, + boolean canceled, + String body, + Instant createdAt, + Instant modifiedAt, + DeliveryReport deliveryReport, + Instant sendAt, + Instant expireAt, + String callbackUrl, + String clientReference, + boolean feedbackEnabled, + boolean flashMessage, + boolean truncateConcat, + int maxNumberOfMessageParts, + int fromTon, + int fromNpi, + String udh) { + super( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled); + this.flashMessage = flashMessage; + this.truncateConcat = truncateConcat; + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + this.udh = udh; + } + + public boolean isFlashMessage() { + return flashMessage; + } + + public boolean isTruncateConcat() { + return truncateConcat; + } + + public int getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + public int getFromTon() { + return fromTon; + } + + public int getFromNpi() { + return fromNpi; + } + + public String getUdh() { + return udh; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "BatchBinary{" + + "flashMessage=" + + flashMessage + + ", truncateConcat=" + + truncateConcat + + ", maxNumberOfMessageParts=" + + maxNumberOfMessageParts + + ", fromTon=" + + fromTon + + ", fromNpi=" + + fromNpi + + ", udh='" + + udh + + '\'' + + "} " + + super.toString(); + } + + public static class Builder extends Batch.Builder { + + private boolean flashMessage; + private boolean truncateConcat; + private int maxNumberOfMessageParts; + private int fromTon; + private int fromNpi; + private String udh; + + private Builder() {} + + public Builder setFlashMessage(boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + public Builder setTruncateConcat(boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + public Builder setMaxNumberOfMessageParts(int maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + public Builder setFromTon(int fromTon) { + this.fromTon = fromTon; + return this; + } + + public Builder setFromNpi(int fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + public Builder setUdh(String udh) { + this.udh = udh; + return this; + } + + public BatchBinary build() { + return new BatchBinary( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi, + udh); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java new file mode 100644 index 00000000..75a02496 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java @@ -0,0 +1,138 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * BatchMedia type + * + * @since 1.0 + */ +public class BatchMedia extends Batch { + private final Parameters parameters; + private final boolean strictValidation; + + /** + * @param id Unique identifier for batch + * @param to List of Phone numbers and group IDs that will receive the batch + * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if + * Automatic Default Originator not configured. + * @param canceled Indicates if the batch has been canceled or not. + * @param body The message content + * @param createdAt when batch was created + * @param modifiedAt when batch was last updated + * @param deliveryReport Request delivery report callback. Note that delivery reports can be + * fetched from the API regardless of this setting + * @param sendAt 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 + * @param expireAt 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 + * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. + * @param clientReference The client identifier of a batch message. If set, the identifier will be + * added in the delivery report/callback of this batch + * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. * + * @param parameters Contains the parameters that will be used for customizing the message for + * each recipient. + * @param strictValidation 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. + */ + public BatchMedia( + String id, + Collection to, + String from, + boolean canceled, + MediaBody body, + Instant createdAt, + Instant modifiedAt, + DeliveryReport deliveryReport, + Instant sendAt, + Instant expireAt, + String callbackUrl, + String clientReference, + boolean feedbackEnabled, + Parameters parameters, + boolean strictValidation) { + super( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled); + this.parameters = parameters; + this.strictValidation = strictValidation; + } + + public Parameters getParameters() { + return parameters; + } + + public boolean isStrictValidation() { + return strictValidation; + } + + public static Builder builder() { + return new Builder(); + } + + @Override + public String toString() { + return "BatchMedia{" + + "parameters=" + + parameters + + ", strictValidation=" + + strictValidation + + "} " + + super.toString(); + } + + public static class Builder extends Batch.Builder { + private Parameters parameters; + private boolean strictValidation; + + private Builder() {} + + public Builder setParameters(Parameters parameters) { + this.parameters = parameters; + return this; + } + + public Builder setStrictValidation(boolean strictValidation) { + this.strictValidation = strictValidation; + return this; + } + + public BatchMedia build() { + return new BatchMedia( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + parameters, + strictValidation); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java new file mode 100644 index 00000000..164a7366 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java @@ -0,0 +1,203 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Collection; + +/** + * BatchText type + * + * @since 1.0 + */ +public class BatchText extends Batch { + private final boolean flashMessage; + private final Parameters parameters; + private final boolean truncateConcat; + private final int maxNumberOfMessageParts; + private final int fromTon; + private final int fromNpi; + + /** + * @param id Unique identifier for batch + * @param to List of Phone numbers and group IDs that will receive the batch + * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if + * Automatic Default Originator not configured. + * @param canceled Indicates if the batch has been canceled or not. + * @param body The message content + * @param createdAt when batch was created + * @param modifiedAt when batch was last updated + * @param deliveryReport Request delivery report callback. Note that delivery reports can be + * fetched from the API regardless of this setting + * @param sendAt 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 + * @param expireAt 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 + * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. + * @param clientReference The client identifier of a batch message. If set, the identifier will be + * added in the delivery report/callback of this batch + * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. + * @param parameters Contains the parameters that will be used for customizing the message for + * each recipient. + * @param flashMessage If sent as a flash message, displays true. + * @param truncateConcat If set to true, the message was shortened when exceeding one part. + * @param maxNumberOfMessageParts Displays the number of message parts set in the request. + * @param fromTon The type of number for the sender number. + * @param fromNpi Number Plan Indicator for the sender number. + */ + public BatchText( + String id, + Collection to, + String from, + boolean canceled, + String body, + Instant createdAt, + Instant modifiedAt, + DeliveryReport deliveryReport, + Instant sendAt, + Instant expireAt, + String callbackUrl, + String clientReference, + boolean flashMessage, + boolean feedbackEnabled, + Parameters parameters, + boolean truncateConcat, + int maxNumberOfMessageParts, + int fromTon, + int fromNpi) { + super( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled); + this.flashMessage = flashMessage; + this.parameters = parameters; + this.truncateConcat = truncateConcat; + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + this.fromTon = fromTon; + this.fromNpi = fromNpi; + } + + public Parameters getParameters() { + return parameters; + } + + public boolean isFlashMessage() { + return flashMessage; + } + + public boolean isTruncateConcat() { + return truncateConcat; + } + + public int getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + public int getFromTon() { + return fromTon; + } + + public int getFromNpi() { + return fromNpi; + } + + @Override + public String toString() { + return "BatchText{" + + "flashMessage=" + + flashMessage + + ", parameters=" + + parameters + + ", truncateConcat=" + + truncateConcat + + ", maxNumberOfMessageParts=" + + maxNumberOfMessageParts + + ", fromTon=" + + fromTon + + ", fromNpi=" + + fromNpi + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends Batch.Builder { + private boolean flashMessage; + private Parameters parameters; + private boolean truncateConcat; + private int maxNumberOfMessageParts; + private int fromTon; + private int fromNpi; + + private Builder() {} + + public Builder setFlashMessage(boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + public Builder setParameters(Parameters parameters) { + this.parameters = parameters; + return this; + } + + public Builder setTruncateConcat(boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + public Builder setMaxNumberOfMessageParts(int maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + public Builder setFromTon(int fromTon) { + this.fromTon = fromTon; + return this; + } + + public Builder setFromNpi(int fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + public BatchText build() { + return new BatchText( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + flashMessage, + feedbackEnabled, + parameters, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReport.java new file mode 100644 index 00000000..e706dafa --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReport.java @@ -0,0 +1,60 @@ +package com.sinch.sdk.domains.sms.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * DeliveryReport authorized values + * + * @since 1.0 + */ +public class DeliveryReport extends EnumDynamic { + + /** No delivery report callback will be sent. */ + public static final DeliveryReport NONE = new DeliveryReport("none"); + /** A single delivery report callback will be sent. */ + public static final DeliveryReport SUMMARY = new DeliveryReport("summary"); + /** + * A single delivery report callback will be sent which includes a list of recipients per delivery + * status. + */ + public static final DeliveryReport FULL = new DeliveryReport("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 DeliveryReport PER_RECIPIENT = new DeliveryReport("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 DeliveryReport PER_RECIPIENT_FINAl = + new DeliveryReport("per_recipient_final"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + DeliveryReport.class, + DeliveryReport::new, + Arrays.asList(NONE, SUMMARY, FULL, PER_RECIPIENT, PER_RECIPIENT_FINAl)); + + private DeliveryReport(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static DeliveryReport from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(DeliveryReport e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java b/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java new file mode 100644 index 00000000..acbc67ff --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java @@ -0,0 +1,59 @@ +package com.sinch.sdk.domains.sms.models; + +/** + * MediaBody object + * + * @since 1.0 + */ +public class MediaBody { + private final String message; + private final String url; + + /** + * @param url URL to the media file + * @param message The message text. Text only media messages will be rejected, please use SMS + * instead. + */ + public MediaBody(String url, String message) { + this.message = message; + this.url = url; + } + + public String getMessage() { + return message; + } + + public String getUrl() { + return url; + } + + @Override + public String toString() { + return "MediaBody{" + "message='" + message + '\'' + ", url='" + url + '\'' + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private String message; + private String url; + + private Builder() {} + + public Builder setMessage(String message) { + this.message = message; + return this; + } + + public Builder setUrl(String url) { + this.url = url; + return this; + } + + public MediaBody build() { + return new MediaBody(url, message); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java new file mode 100644 index 00000000..1921bb5a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.sms.models; + +import com.sinch.sdk.core.utils.Pair; +import java.util.Collection; +import java.util.HashMap; +import java.util.Optional; +import java.util.stream.Collectors; + +public class Parameters extends HashMap { + + public Parameters(Collection list) { + super(list.stream().collect(Collectors.toMap(entry -> entry.key, entry -> entry))); + } + + public static class Entry { + private final String key; + private final Pair value; + private final String defaultValue; + + public Entry(String key, Pair value, String defaultValue) { + this.key = key; + this.value = value; + this.defaultValue = defaultValue; + } + + public Entry(String key, Pair value) { + this(key, value, null); + } + + public String getKey() { + return key; + } + + public Pair getValue() { + return value; + } + + public Optional getDefaultValue() { + return Optional.ofNullable(defaultValue); + } + + @Override + public String toString() { + return "Entry{" + + "key='" + + key + + '\'' + + ", value=" + + value + + ", defaultValue=" + + defaultValue + + '}'; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/package-info.java new file mode 100644 index 00000000..dea88890 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/package-info.java @@ -0,0 +1,6 @@ +/** + * SMS API interface + * + * @since 1.0 + */ +package com.sinch.sdk.domains.sms; diff --git a/client/src/main/com/sinch/sdk/http/HttpClientApache.java b/client/src/main/com/sinch/sdk/http/HttpClientApache.java new file mode 100644 index 00000000..588ff3f4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/http/HttpClientApache.java @@ -0,0 +1,209 @@ +package com.sinch.sdk.http; + +import static com.sinch.sdk.auth.adapters.BearerAuthManager.BEARER_AUTHENTICATE_RESPONSE_HEADER_KEYWORD; +import static com.sinch.sdk.auth.adapters.BearerAuthManager.BEARER_EXPIRED_KEYWORD; +import static com.sinch.sdk.core.http.URLParameterUtils.encodeParametersAsString; + +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.auth.adapters.BearerAuthManager; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.*; +import com.sinch.sdk.core.models.ServerConfiguration; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.logging.Logger; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.apache.hc.client5.http.impl.classic.HttpClients; +import org.apache.hc.core5.http.ClassicHttpRequest; +import org.apache.hc.core5.http.ClassicHttpResponse; +import org.apache.hc.core5.http.Header; +import org.apache.hc.core5.http.HttpEntity; +import org.apache.hc.core5.http.io.entity.StringEntity; +import org.apache.hc.core5.http.io.support.ClassicRequestBuilder; + +public class HttpClientApache implements com.sinch.sdk.core.http.HttpClient { + private static final Logger LOGGER = Logger.getLogger(HttpClientApache.class.getName()); + private static final String AUTHORIZATION_HEADER_KEYWORD = "Authorization"; + private final Map authManagers; + private CloseableHttpClient client; + + public HttpClientApache(Map authManagers) { + this.client = HttpClients.createDefault(); + this.authManagers = authManagers; + } + + private static HttpResponse processResponse(ClassicHttpResponse response) throws IOException { + + int statusCode = response.getCode(); + Map> headers = transformResponseHeaders(response.getHeaders()); + String message = response.getReasonPhrase(); + LOGGER.finest("response: " + statusCode + ", headers:" + headers); + + if (statusCode == org.apache.hc.core5.http.HttpStatus.SC_NO_CONTENT) { + return new HttpResponse(statusCode, message, headers, null); + } + + HttpEntity entity = response.getEntity(); + Scanner s = new Scanner(entity.getContent()).useDelimiter("\\A"); + String content = (s.hasNext() ? s.next() : ""); + + return new HttpResponse(statusCode, message, headers, content.getBytes(StandardCharsets.UTF_8)); + } + + private static Map> transformResponseHeaders(Header[] headers) { + Map> headersMap = new HashMap<>(); + for (Header header : headers) { + List valuesList = headersMap.get(header.getName()); + if (valuesList != null) { + valuesList.add(header.getValue()); + } else { + valuesList = new ArrayList<>(); + valuesList.add(header.getValue()); + headersMap.put(header.getName(), valuesList); + } + } + return headersMap; + } + + @Override + public HttpResponse invokeAPI(ServerConfiguration serverConfiguration, HttpRequest httpRequest) + throws ApiException { + + try { + String path = serverConfiguration.getUrl() + httpRequest.getPath().orElse(""); + HttpMethod method = httpRequest.getMethod(); + Collection queryParameters = httpRequest.getQueryParameters(); + + String body = httpRequest.getBody(); + Map headerParams = httpRequest.getHeaderParams(); + Collection accept = httpRequest.getAccept(); + Collection contentType = httpRequest.getContentType(); + Collection authNames = httpRequest.getAuthNames(); + + LOGGER.fine("Invoke '" + method + "' onto '" + path + "'"); + LOGGER.fine("queryParameters: " + queryParameters); + LOGGER.fine("body: " + body); + LOGGER.fine("headerParams: " + headerParams); + LOGGER.fine("accept: " + accept); + LOGGER.fine("contentType: " + contentType); + LOGGER.fine("authNames: " + authNames); + + ClassicRequestBuilder requestBuilder = ClassicRequestBuilder.create(method.name()); + + setUri(requestBuilder, path, queryParameters); + + addBody(requestBuilder, body); + + addCollectionHeader(requestBuilder, "Content-Type", contentType); + addCollectionHeader(requestBuilder, "Accept", accept); + + addAuth(requestBuilder, authNames); + + ClassicHttpRequest request = requestBuilder.build(); + + HttpResponse response = processRequest(client, request); + LOGGER.finest("connection response: " + response); + + // UNAUTHORIZED (HTTP 401) error code could imply refreshing the OAuth token + if (response.getCode() == HttpStatus.UNAUTHORIZED) { + boolean couldRetryRequest = processUnauthorizedResponse(httpRequest, response); + if (couldRetryRequest) { + // refresh authorization + addAuth(requestBuilder, authNames); + request = requestBuilder.build(); + response = processRequest(client, request); + LOGGER.finest("connection response on retry: " + response); + } + } + return response; + } catch (Exception e) { + LOGGER.severe("Error:" + e); + throw new ApiException(e); + } + } + + private boolean processUnauthorizedResponse(HttpRequest request, HttpResponse response) { + + AuthManager bearerAuthManager = authManagers.get(BearerAuthManager.BEARER_SCHEMA_KEYWORD); + // is request was with Bearer authentication ? + Collection auths = request.getAuthNames(); + + if (null == bearerAuthManager || !auths.contains(BearerAuthManager.BEARER_SCHEMA_KEYWORD)) { + // not required to ask for a new token: original request is not using it + return false; + } + // looking for "expired" keyword present in "www-authenticate" header + Map> responseHeaders = response.getHeaders(); + Collection header = responseHeaders.get(BEARER_AUTHENTICATE_RESPONSE_HEADER_KEYWORD); + + boolean headerPresent = header.stream().anyMatch(e -> e.contains(BEARER_EXPIRED_KEYWORD)); + if (headerPresent) { + bearerAuthManager.resetToken(); + } + return headerPresent; + } + + private void setUri( + ClassicRequestBuilder requestBuilder, String path, Collection parameters) { + + if (null == parameters || parameters.isEmpty()) { + requestBuilder.setUri(path); + return; + } + String requestParameters = "?" + encodeParametersAsString(parameters); + LOGGER.finest("Request parameters: " + requestParameters); + requestBuilder.setUri(path + requestParameters); + } + + private void addBody(ClassicRequestBuilder requestBuilder, String body) { + if (null != body) { + requestBuilder.setEntity(new StringEntity(body)); + } + } + + private void addCollectionHeader( + ClassicRequestBuilder requestBuilder, String header, Collection values) { + if (null != values && !values.isEmpty()) { + requestBuilder.setHeader(header, String.join(",", values)); + } + } + + private void addAuth(ClassicRequestBuilder requestBuilder, Collection values) { + if (null == values || values.isEmpty()) { + return; + } + + for (String entry : values) { + if (authManagers.containsKey(entry)) { + AuthManager authManager = authManagers.get(entry); + requestBuilder.setHeader( + AUTHORIZATION_HEADER_KEYWORD, authManager.getAuthorizationHeaderValue()); + return; + } else { + LOGGER.info("Ignore unknown authentication value: '" + entry + "'"); + } + } + } + + private HttpResponse processRequest(CloseableHttpClient client, ClassicHttpRequest request) + throws IOException { + return client.execute(request, HttpClientApache::processResponse); + } + + @Override + public boolean isClosed() { + return null == client; + } + + @Override + public void close() throws Exception { + if (!isClosed()) { + try { + client.close(); + } finally { + client = null; + } + } + } +} diff --git a/client/src/main/com/sinch/sdk/models/Configuration.java b/client/src/main/com/sinch/sdk/models/Configuration.java new file mode 100644 index 00000000..dae0b99b --- /dev/null +++ b/client/src/main/com/sinch/sdk/models/Configuration.java @@ -0,0 +1,292 @@ +package com.sinch.sdk.models; + +import com.sinch.sdk.core.models.ServerConfiguration; + +/** Configuration used by Sinch Client */ +public class Configuration { + + private final String keyId; + private final String keySecret; + private final String projectId; + private final String oauthUrl; + private final String numbersUrl; + private final SMSRegion smsRegion; + private final String smsUrl; + + private Configuration( + String keyId, + String keySecret, + String projectId, + String oauthUrl, + String numbersUrl, + SMSRegion smsRegion, + String smsUrl) { + this.keyId = keyId; + this.keySecret = keySecret; + this.projectId = projectId; + this.oauthUrl = oauthUrl; + this.numbersUrl = numbersUrl; + this.smsRegion = null == smsRegion ? SMSRegion.US : smsRegion; + this.smsUrl = smsUrl; + } + + @Override + public String toString() { + // ! do not dump secret values + return "Configuration{" + + "keyId=..." + + ", keySecret=..." + + ", projectId=..." + + ", oAuthUrl='" + + oauthUrl + + '\'' + + ", numbersUrl='" + + numbersUrl + + '\'' + + ", smsRegion='" + + smsRegion + + '\'' + + ", smsUrl='" + + smsUrl + + '\'' + + "}"; + } + + /** + * Get Key ID + * + * @return key id. + * @see https://developers.sinch.com/ + * @since 1.0 + */ + public String getKeyId() { + return keyId; + } + + /** + * Get key ID + * + * @return key secret. + * @see https://developers.sinch.com/ + * @since 1.0 + */ + public String getKeySecret() { + return keySecret; + } + + /** + * Get Project ID + * + * @return Project id. + * @see https://developers.sinch.com/ + * @since 1.0 + */ + public String getProjectId() { + return projectId; + } + + /** + * OAuth server + * + * @return OAuth Server configuration to be used + * @since 1.0 + */ + public ServerConfiguration getOAuthServer() { + return new ServerConfiguration(getOAuthUrl()); + } + + /** + * OAuth URL + * + * @return OAuth Server URL + * @since 1.0 + */ + public String getOAuthUrl() { + return oauthUrl; + } + + /** + * Numbers Server Configuration + * + * @return Numbers Server configuration to be used + * @since 1.0 + */ + public ServerConfiguration getNumbersServer() { + return new ServerConfiguration(getNumbersUrl()); + } + + /** + * Numbers URL + * + * @return Numbers Server URL + * @since 1.0 + */ + public String getNumbersUrl() { + return numbersUrl; + } + + /** + * SMS Server Configuration + * + * @return SMS Server configuration to be used + * @since 1.0 + */ + public ServerConfiguration getSmsServer() { + return new ServerConfiguration(String.format(getSmsUrl(), getSmsRegion())); + } + + /** + * SMS Region + * + * @return SMS region + * @see https://developers.sinch.com/docs/sms/api-reference/#base-url/ + * @since 1.0 + */ + public SMSRegion getSmsRegion() { + return smsRegion; + } + + /** + * SMS URL + * + * @return SMS Server URL + * @since 1.0 + */ + public String getSmsUrl() { + return smsUrl; + } + + public static Builder builder() { + return new Builder(); + } + + public static Builder builder(Configuration configuration) { + return new Builder(configuration); + } + + /** Configuration builder */ + public static class Builder { + + private String keyId; + private String keySecret; + private String projectId; + private String oauthUrl; + private String numbersUrl; + private SMSRegion smsRegion; + private String smsUrl; + + protected Builder() {} + + /** + * Initialize a builder with existing configuration + * + * @param configuration Configuration to be used as initial builder state + * @since 1.0 + */ + protected Builder(Configuration configuration) { + this.keyId = configuration.getKeyId(); + this.keySecret = configuration.getKeySecret(); + this.projectId = configuration.getProjectId(); + this.oauthUrl = configuration.getOAuthUrl(); + this.numbersUrl = configuration.getNumbersUrl(); + this.smsRegion = configuration.getSmsRegion(); + this.smsUrl = configuration.getSmsUrl(); + } + + /** + * Build a Configuration instance from builder current state + * + * @return Configuration instance build from current builder state + * @since 1.0 + */ + public Configuration build() { + return new Configuration( + keyId, keySecret, projectId, oauthUrl, numbersUrl, smsRegion, smsUrl); + } + + /** + * Set key ID + * + * @param keyId key ID + * @return Current builder + * @since 1.0 + */ + public Builder setKeyId(String keyId) { + this.keyId = keyId; + return this; + } + + /** + * Set key secret + * + * @param keySecret key secret + * @return Current builder + * @since 1.0 + */ + public Builder setKeySecret(String keySecret) { + this.keySecret = keySecret; + return this; + } + + /** + * Set Project ID + * + * @param projectId Project ID + * @return Current builder + * @since 1.0 + */ + public Builder setProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Set OAuth URL + * + * @param oauthUrl OAuth URL + * @return Current builder + * @since 1.0 + */ + public Builder setOAuthUrl(String oauthUrl) { + this.oauthUrl = oauthUrl; + return this; + } + + /** + * Set Numbers API URL + * + * @param numbersUrl Numbers API URL + * @return Current builder + * @since 1.0 + */ + public Builder setNumbersUrl(String numbersUrl) { + this.numbersUrl = numbersUrl; + return this; + } + + /** + * Set SMS region + * + * @param smsRegion SMS region + * @return Current builder + * @since 1.0 + */ + public Builder setSmsRegion(SMSRegion smsRegion) { + this.smsRegion = smsRegion; + return this; + } + + /** + * Set SMS API URL + * + * @param smsUrl SMS API URL + * @return Current builder + * @since 1.0 + */ + public Builder setSmsUrl(String smsUrl) { + this.smsUrl = smsUrl; + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/models/SMSRegion.java b/client/src/main/com/sinch/sdk/models/SMSRegion.java new file mode 100644 index 00000000..c198f604 --- /dev/null +++ b/client/src/main/com/sinch/sdk/models/SMSRegion.java @@ -0,0 +1,67 @@ +package com.sinch.sdk.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * SMS Region + * + *

Available SMS region Regions are tied to a specific SMS API URL + * + * @see https://developers.sinch.com/docs/sms/api-reference/#base-url/ + * @since 1.0 + */ +public class SMSRegion extends EnumDynamic { + + /** United States */ + public static final SMSRegion US = new SMSRegion("us"); + + /** European Union */ + public static final SMSRegion EU = new SMSRegion("eu"); + /** Australia */ + public static final SMSRegion AU = new SMSRegion("au"); + /** Brazil */ + public static final SMSRegion BR = new SMSRegion("br"); + /** Canada */ + public static final SMSRegion CA = new SMSRegion("ca"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(SMSRegion.class, SMSRegion::new, Arrays.asList(US, EU, AU, BR, CA)); + + private SMSRegion(String value) { + super(value); + } + + /** + * Get list of regions + * + * @return List of known SMS region + */ + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + /** + * Get SMS region from a String + * + * @param value String region identifier. Create an SMS Region instance if not known at + * compilation + * @return SMSRegion identified by the string + */ + public static SMSRegion from(String value) { + return ENUM_SUPPORT.from(value); + } + + /** + * Get SMS region string identifier + * + * @param value region identifier + * @return String value identifier for region + */ + public static String valueOf(SMSRegion value) { + return ENUM_SUPPORT.valueOf(value); + } +} diff --git a/client/src/main/com/sinch/sdk/models/package-info.java b/client/src/main/com/sinch/sdk/models/package-info.java new file mode 100644 index 00000000..0533af6d --- /dev/null +++ b/client/src/main/com/sinch/sdk/models/package-info.java @@ -0,0 +1,6 @@ +/** + * Common models in use with Sinch Client Library + * + * @since 1.0 + */ +package com.sinch.sdk.models; diff --git a/client/src/main/com/sinch/sdk/package-info.java b/client/src/main/com/sinch/sdk/package-info.java new file mode 100644 index 00000000..1da0e66f --- /dev/null +++ b/client/src/main/com/sinch/sdk/package-info.java @@ -0,0 +1,16 @@ +/** + * Sinch Java SDK for Numbers & SMS + * + *

Provides the client necessary to interface with Sinch APIS + * + *

The client involve different layers: + * + *

    + *
  • configuration with unified identifier to connect to APIS + *
  • client handling underline communication with APIS + *
+ * + * @see https://developers.sinch.com/ + * @since 1.0 + */ +package com.sinch.sdk; diff --git a/client/src/test/java/com/sinch/sdk/SinchClientTest.java b/client/src/test/java/com/sinch/sdk/SinchClientTest.java new file mode 100644 index 00000000..693ac834 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/SinchClientTest.java @@ -0,0 +1,60 @@ +package com.sinch.sdk; + +import static org.junit.jupiter.api.Assertions.*; + +import com.sinch.sdk.models.Configuration; +import org.junit.jupiter.api.Test; + +class SinchClientTest { + + @Test + void doNotAcceptNullKey() { + Configuration configuration = + Configuration.builder().setKeyId(null).setKeySecret("foo").setProjectId("foo").build(); + Exception exception = + assertThrows(NullPointerException.class, () -> new SinchClient(configuration)); + assertTrue(exception.getMessage().contains("keyId")); + } + + @Test + void doNotAcceptNullKeySecret() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret(null).setProjectId("foo").build(); + Exception exception = + assertThrows(NullPointerException.class, () -> new SinchClient(configuration)); + assertTrue(exception.getMessage().contains("keySecret")); + } + + @Test + void doNotAcceptNullProject() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId(null).build(); + Exception exception = + assertThrows(NullPointerException.class, () -> new SinchClient(configuration)); + assertTrue(exception.getMessage().contains("projectId")); + } + + @Test + void defaultOAuthUrlAvailable() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId("foo").build(); + SinchClient client = new SinchClient(configuration); + assertNotNull(client.getConfiguration().getOAuthUrl()); + } + + @Test + void defaultNumbersUrlAvailable() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId("foo").build(); + SinchClient client = new SinchClient(configuration); + assertNotNull(client.getConfiguration().getNumbersUrl()); + } + + @Test + void defaultSmsUrlAvailable() { + Configuration configuration = + Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId("foo").build(); + SinchClient client = new SinchClient(configuration); + assertNotNull(client.getConfiguration().getSmsUrl()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/auth/adapters/BasicAuthManagerTest.java b/client/src/test/java/com/sinch/sdk/auth/adapters/BasicAuthManagerTest.java new file mode 100644 index 00000000..b0269728 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/auth/adapters/BasicAuthManagerTest.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.auth.adapters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.models.Configuration; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import org.junit.jupiter.api.Test; + +class BasicAuthManagerTest { + + static final String KEY = "fooKey"; + static final String SECRET = "fooSecret"; + static final String PROJECT = "fooProject"; + + Configuration configuration = + Configuration.builder().setKeyId(KEY).setKeySecret(SECRET).setProjectId(PROJECT).build(); + + AuthManager authManager = new BasicAuthManager(configuration); + + @Test + void getSchema() { + assertEquals("BasicAuth", authManager.getSchema()); + } + + @Test + void getAuthorizationHeaderValue() { + + String expectedToken = + "Basic " + + Base64.getEncoder() + .encodeToString( + (configuration.getKeyId() + ":" + configuration.getKeySecret()) + .getBytes(StandardCharsets.UTF_8)); + assertEquals(expectedToken, authManager.getAuthorizationHeaderValue()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java b/client/src/test/java/com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java new file mode 100644 index 00000000..3584ffc8 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java @@ -0,0 +1,111 @@ +package com.sinch.sdk.auth.adapters; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.core.exceptions.ApiAuthException; +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.models.ServerConfiguration; +import com.sinch.sdk.models.Configuration; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.Mock; + +@TestWithResources +public class BearerAuthManagerTest extends BaseTest { + static final String KEY = "fooKey"; + static final String SECRET = "fooSecret"; + static final String PROJECT = "fooProject"; + + @GivenTextResource("/client/auth/BearerAuthResponse.json") + String jsonResponse; + + @Mock HttpClient httpClient; + @Captor ArgumentCaptor serverConfigurationCaptor; + @Captor ArgumentCaptor httpRequestCaptor; + Configuration configuration = + Configuration.builder() + .setKeyId(KEY) + .setKeySecret(SECRET) + .setProjectId(PROJECT) + .setOAuthUrl("OAuth url") + .build(); + + AuthManager authManager = new BearerAuthManager(configuration, new HttpMapper()); + + @Test + void getSchema() { + assertEquals("BearerAuth", authManager.getSchema()); + } + + @Test + void getAuthorizationHeaderValue() { + String expectedToken = "Bearer token value"; + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); + authManager.setHttpClient(httpClient); + + String token = authManager.getAuthorizationHeaderValue(); + + assertEquals(expectedToken, token); + } + + @Test + void callToOAuthServer() { + when(httpClient.invokeAPI(serverConfigurationCaptor.capture(), httpRequestCaptor.capture())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); + authManager.setHttpClient(httpClient); + + authManager.getAuthorizationHeaderValue(); + + ServerConfiguration serverConfigurationValue = serverConfigurationCaptor.getValue(); + assertEquals("OAuth url", serverConfigurationValue.getUrl()); + + HttpRequest httpRequestCaptorValue = httpRequestCaptor.getValue(); + assertEquals(HttpMethod.POST, httpRequestCaptorValue.getMethod()); + assertTrue(httpRequestCaptorValue.getAuthNames().stream().anyMatch(e -> e.equals("BasicAuth"))); + assertTrue( + httpRequestCaptorValue.getContentType().stream() + .anyMatch(e -> e.equals("application/x-www-form-urlencoded"))); + assertEquals("grant_type=client_credentials", httpRequestCaptorValue.getBody()); + } + + @Test + void resetToken() { + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); + authManager.setHttpClient(httpClient); + + authManager.resetToken(); + authManager.getAuthorizationHeaderValue(); + + verify(httpClient, times(1)).invokeAPI(any(), any()); + } + + @Test + void noInfiniteLoopAndException() { + authManager.setHttpClient(httpClient); + + ApiAuthException exception = + assertThrows(ApiAuthException.class, authManager::getAuthorizationHeaderValue); + assertEquals(exception.getCode(), 401); + } +} diff --git a/client/src/test/java/com/sinch/sdk/auth/models/BearerAuthResponseTest.java b/client/src/test/java/com/sinch/sdk/auth/models/BearerAuthResponseTest.java new file mode 100644 index 00000000..24800fd0 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/auth/models/BearerAuthResponseTest.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.auth.models; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class BearerAuthResponseTest extends BaseTest { + + static final String token = "token value"; + + @GivenJsonResource("/client/auth/BearerAuthResponse.json") + BearerAuthResponse response; + + @Test + void getAccessToken() { + assertEquals(token, response.getAccessToken()); + } + + @Test + void getExpiresIn() { + assertEquals(123456, response.getExpiresIn()); + } + + @Test + void getScope() { + assertEquals("scope value", response.getScope()); + } + + @Test + void getTokenType() { + assertEquals("token type value", response.getTokenType()); + } + + @Test + void to_String() { + assertFalse(response.toString().contains(token)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/core/adapters/apache/HttpClientTestIT.java b/client/src/test/java/com/sinch/sdk/core/adapters/apache/HttpClientTestIT.java new file mode 100644 index 00000000..20e94b60 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/core/adapters/apache/HttpClientTestIT.java @@ -0,0 +1,180 @@ +package com.sinch.sdk.core.adapters.apache; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.auth.AuthManager; +import com.sinch.sdk.auth.adapters.BasicAuthManager; +import com.sinch.sdk.auth.adapters.BearerAuthManager; +import com.sinch.sdk.core.exceptions.ApiException; +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.HttpStatus; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.http.HttpClientApache; +import com.sinch.sdk.models.Configuration; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.Collections; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import okhttp3.mockwebserver.MockResponse; +import okhttp3.mockwebserver.MockWebServer; +import okhttp3.mockwebserver.RecordedRequest; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@TestWithResources +class HttpClientTestIT extends BaseTest { + static MockWebServer mockBackEnd; + + @GivenTextResource("/client/auth/BearerAuthResponse.json") + String jsonResponse; + + String serverUrl = String.format("http://localhost:%s", mockBackEnd.getPort()); + Configuration configuration = + Configuration.builder().setOAuthUrl(String.format("%s/auth", serverUrl)).build(); + + AuthManager basicAuthManager = new BasicAuthManager(configuration); + BearerAuthManager bearerAuthManager = new BearerAuthManager(configuration, new HttpMapper()); + + Map authManagers = + Stream.of(basicAuthManager, bearerAuthManager) + .map(e -> new AbstractMap.SimpleEntry<>(e.getSchema(), e)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + HttpClientApache httpClient = new HttpClientApache(authManagers); + + @BeforeAll + static void classSetUp() throws IOException { + mockBackEnd = new MockWebServer(); + mockBackEnd.start(); + } + + @AfterAll + static void tearDown() throws IOException { + mockBackEnd.shutdown(); + } + + @BeforeEach + void testSetUp() { + bearerAuthManager.setHttpClient(httpClient); + } + + @Test + void basicAuthorization() throws InterruptedException { + + mockBackEnd.enqueue( + new MockResponse().setBody("foo").addHeader("Content-Type", "application/json")); + httpClient.invokeAPI( + new ServerConfiguration(String.format("%s/foo", serverUrl)), + new HttpRequest( + "foo-path", + HttpMethod.GET, + null, + null, + null, + null, + null, + Collections.singletonList(BasicAuthManager.BASIC_SCHEMA_KEYWORD))); + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + + String header = recordedRequest.getHeader("Authorization"); + + assertTrue(header.startsWith("Basic ")); + } + + @Test + void initialBearerAuthorization() throws InterruptedException { + mockBackEnd.enqueue( + new MockResponse().setBody(jsonResponse).addHeader("Content-Type", "application/json")); + mockBackEnd.enqueue( + new MockResponse().setBody("foo3").addHeader("Content-Type", "application/json")); + httpClient.invokeAPI( + new ServerConfiguration(String.format("%s/foo", serverUrl)), + new HttpRequest( + "foo-path", + HttpMethod.GET, + null, + null, + null, + null, + null, + Collections.singletonList(BearerAuthManager.BEARER_SCHEMA_KEYWORD))); + + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + + String header = recordedRequest.getHeader("Authorization"); + assertTrue(header.startsWith("Basic ")); + assertEquals("/auth", recordedRequest.getPath()); + // unused for this test: but to flush mocked backend request stack and avoid cross tests issue + mockBackEnd.takeRequest(); + } + + @Test + void bearerAutoRefresh() throws InterruptedException { + // return valid token + mockBackEnd.enqueue( + new MockResponse().setBody(jsonResponse).addHeader("Content-Type", "application/json")); + // return unauthorized + mockBackEnd.enqueue( + new MockResponse() + .setResponseCode(HttpStatus.UNAUTHORIZED) + .setBody("foo2") + .addHeader("www-authenticate", "token invalid: expired") + .addHeader("Content-Type", "application/json")); + // return valid token + mockBackEnd.enqueue( + new MockResponse() + .setBody(jsonResponse.replace("token value", "another token")) + .addHeader("Content-Type", "application/json")); + // return a body + mockBackEnd.enqueue( + new MockResponse().setBody("foo3").addHeader("Content-Type", "application/json")); + try { + httpClient.invokeAPI( + new ServerConfiguration(String.format("%s/foo/", serverUrl)), + new HttpRequest( + "foo-path", + HttpMethod.GET, + null, + null, + null, + null, + null, + Collections.singletonList(BearerAuthManager.BEARER_SCHEMA_KEYWORD))); + } catch (ApiException ae) { + // noop + } + // should have requested a token (because of not yet retrieved when service is started) + RecordedRequest recordedRequest = mockBackEnd.takeRequest(); + assertEquals("/auth", recordedRequest.getPath()); + String header = recordedRequest.getHeader("Authorization"); + // auth is using Basic authentication + assertTrue(header.startsWith("Basic ")); + + // should have requested the original endpoint but with a token now + recordedRequest = mockBackEnd.takeRequest(); + assertEquals("/foo/foo-path", recordedRequest.getPath()); + header = recordedRequest.getHeader("Authorization"); + assertEquals(header, "Bearer token value"); + + // should have requested another token because the second request triggered an "expired" one + recordedRequest = mockBackEnd.takeRequest(); + assertEquals("/auth", recordedRequest.getPath()); + header = recordedRequest.getHeader("Authorization"); + assertTrue(header.startsWith("Basic ")); + + recordedRequest = mockBackEnd.takeRequest(); + assertEquals("/foo/foo-path", recordedRequest.getPath()); + header = recordedRequest.getHeader("Authorization"); + assertEquals(header, "Bearer another token"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/ActiveNumberServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/ActiveNumberServiceTest.java new file mode 100644 index 00000000..5d16f105 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/ActiveNumberServiceTest.java @@ -0,0 +1,335 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import static org.mockito.ArgumentMatchers.eq; +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.exceptions.ApiException; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.core.models.pagination.PageToken; +import com.sinch.sdk.domains.numbers.adapters.api.v1.ActiveNumberApi; +import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberUpdateRequestParametersDtoConverter; +import com.sinch.sdk.domains.numbers.models.*; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; +import com.sinch.sdk.models.Configuration; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class ActiveNumberServiceTest extends BaseTest { + + @GivenJsonResource("/domains/numbers/v1/active-numbers-list-light.json") + ActiveNumbersResponseDto activeNumbersListLightDto; + + @GivenJsonResource("/domains/numbers/v1/active-numbers-list.json") + ActiveNumbersResponseDto activeNumbersListDto; + + @GivenJsonResource("/domains/numbers/v1/active-numbers-get.json") + ActiveNumberDto activeGetResponseDto; + + @Mock Configuration configuration; + @Mock ActiveNumberApi api; + @InjectMocks ActiveNumberService service; + + @Test + void list() throws ApiException { + + when(api.numberServiceListActiveNumbers( + eq(configuration.getProjectId()), + eq("region"), + eq(NumberType.MOBILE.value()), + eq(null), + eq(null), + eq(null), + eq(null), + eq(null), + eq(null))) + .thenReturn(activeNumbersListLightDto); + + ActiveNumberListResponse response = + service.list( + ActiveNumberListRequestParameters.builder() + .setRegionCode("region") + .setType(NumberType.MOBILE) + .build()); + + Page expected = + new Page<>( + ActiveNumberListRequestParameters.builder() + .setRegionCode("region") + .setType(NumberType.MOBILE) + .build(), + Collections.singletonList( + ActiveNumber.builder() + .setPhoneNumber("+447520651116XYZ") + .setProjectId("project id") + .setRegionCode("GB") + .setType(NumberType.MOBILE) + .setCapability(Arrays.asList(Capability.SMS, Capability.VOICE)) + .setDisplayName("") + .setMoney(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z")) + .setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z")) + .setSmsConfiguration(new SMSConfiguration("service plan id", "", null)) + .setVoiceConfiguration(new VoiceConfiguration("app id", null, null)) + .setCallbackUrl("") + .build()), + new PageToken<>("")); + Assertions.assertThat(response.getContent()) + .usingRecursiveComparison() + .isEqualTo(expected.getEntities()); + } + + @Test + void listWithParameters() throws ApiException { + + when(api.numberServiceListActiveNumbers( + eq(configuration.getProjectId()), + eq("another region"), + eq(NumberType.TOLL_FREE.value()), + eq("pattern value"), + eq(SearchPattern.END.value()), + eq(Collections.singletonList(Capability.VOICE.value())), + eq(5), + eq("foo"), + eq(OrderBy.PHONE_NUMBER.value()))) + .thenReturn(activeNumbersListDto); + + ActiveNumberListRequestParameters parameters = + ActiveNumberListRequestParameters.builder() + .setRegionCode("another region") + .setType(NumberType.TOLL_FREE) + .setNumberPattern( + NumberPattern.builder() + .setPattern("pattern value") + .setSearchPattern(SearchPattern.END) + .build()) + .setCapabilities(Collections.singletonList(Capability.VOICE)) + .setPageSize(5) + .setPageToken("foo") + .setOrderBy(OrderBy.PHONE_NUMBER) + .build(); + + Page expected = + new Page<>( + ActiveNumberListRequestParameters.builder() + .setRegionCode("another region") + .setType(NumberType.TOLL_FREE) + .setNumberPattern( + NumberPattern.builder() + .setPattern("pattern value") + .setSearchPattern(SearchPattern.END) + .build()) + .setCapabilities(Collections.singletonList(Capability.VOICE)) + .setPageSize(5) + .setPageToken("foo") + .setOrderBy(OrderBy.PHONE_NUMBER) + .build(), + Collections.singletonList( + ActiveNumber.builder() + .setPhoneNumber("+447520651116XYZ") + .setProjectId("project id") + .setRegionCode("GB") + .setType(NumberType.MOBILE) + .setCapability(Arrays.asList(Capability.SMS, Capability.VOICE)) + .setDisplayName("a display") + .setMoney(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z")) + .setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z")) + .setSmsConfiguration( + new SMSConfiguration( + "service plan id", + null, + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z"), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED)))) + .setVoiceConfiguration( + new VoiceConfiguration( + "app id", + Instant.parse("2023-09-25T12:08:02.115Z"), + new ScheduledVoiceProvisioning( + "app id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z")))) + .setCallbackUrl("foo callback") + .build()), + new PageToken<>("foo")); + + ActiveNumberListResponse response = service.list(parameters); + + Assertions.assertThat(response.getContent()) + .usingRecursiveComparison() + .isEqualTo(expected.getEntities()); + } + + @Test + void get() throws ApiException { + + when(api.numberServiceGetActiveNumber(eq(configuration.getProjectId()), eq("foo phone number"))) + .thenReturn(activeGetResponseDto); + + ActiveNumber expected = + ActiveNumber.builder() + .setPhoneNumber("+447520651116XYZ") + .setProjectId("project id") + .setRegionCode("GB") + .setType(NumberType.MOBILE) + .setCapability(Arrays.asList(Capability.SMS, Capability.VOICE)) + .setDisplayName("a display") + .setMoney(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z")) + .setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z")) + .setSmsConfiguration( + new SMSConfiguration( + "service plan id", + null, + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z"), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED)))) + .setVoiceConfiguration( + new VoiceConfiguration( + "app id", + Instant.parse("2023-09-25T12:08:02.115Z"), + new ScheduledVoiceProvisioning( + "app id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z")))) + .setCallbackUrl("foo callback") + .build(); + + ActiveNumber response = service.get("foo phone number"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void release() throws ApiException { + + when(api.numberServiceReleaseNumber(eq(configuration.getProjectId()), eq("foo phone number"))) + .thenReturn(activeGetResponseDto); + + ActiveNumber expected = + ActiveNumber.builder() + .setPhoneNumber("+447520651116XYZ") + .setProjectId("project id") + .setRegionCode("GB") + .setType(NumberType.MOBILE) + .setCapability(Arrays.asList(Capability.SMS, Capability.VOICE)) + .setDisplayName("a display") + .setMoney(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z")) + .setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z")) + .setSmsConfiguration( + new SMSConfiguration( + "service plan id", + null, + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z"), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED)))) + .setVoiceConfiguration( + new VoiceConfiguration( + "app id", + Instant.parse("2023-09-25T12:08:02.115Z"), + new ScheduledVoiceProvisioning( + "app id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z")))) + .setCallbackUrl("foo callback") + .build(); + + ActiveNumber response = service.release("foo phone number"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void update() { + + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration = + ActiveNumberUpdateSMSConfigurationRequestParameters.builder() + .setServicePlanId("service plan id") + .setCampaignId("campaign id") + .build(); + + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration = + ActiveNumberUpdateVoiceConfigurationRequestParameters.builder().setAppId("app id").build(); + ActiveNumberUpdateRequestParameters parameters = + ActiveNumberUpdateRequestParameters.builder() + .setDisplayName("my display name") + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .setCallback("foo callback") + .build(); + + when(api.numberServiceUpdateActiveNumber( + eq(configuration.getProjectId()), + eq("foo phone number"), + ArgumentMatchers.eq( + ActiveNumberUpdateRequestParametersDtoConverter.convert(parameters)))) + .thenReturn(activeGetResponseDto); + + ActiveNumber expected = + ActiveNumber.builder() + .setPhoneNumber("+447520651116XYZ") + .setProjectId("project id") + .setRegionCode("GB") + .setType(NumberType.MOBILE) + .setCapability(Arrays.asList(Capability.SMS, Capability.VOICE)) + .setDisplayName("a display") + .setMoney(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setNextChargeDate(Instant.parse("2023-09-22T15:49:58.813424Z")) + .setExpireAt(Instant.parse("2023-10-06T15:49:58.813381Z")) + .setSmsConfiguration( + new SMSConfiguration( + "service plan id", + null, + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z"), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED)))) + .setVoiceConfiguration( + new VoiceConfiguration( + "app id", + Instant.parse("2023-09-25T12:08:02.115Z"), + new ScheduledVoiceProvisioning( + "app id from scheduled", + ProvisioningStatus.PROVISIONING_STATUS_UNSPECIFIED, + Instant.parse("2023-09-25T12:08:02.115Z")))) + .setCallbackUrl("foo callback") + .build(); + + ActiveNumber response = service.update("foo phone number", parameters); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/AvailableNumberServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/AvailableNumberServiceTest.java new file mode 100644 index 00000000..b4396163 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/AvailableNumberServiceTest.java @@ -0,0 +1,272 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +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.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.adapters.api.v1.AvailableNumberApi; +import com.sinch.sdk.domains.numbers.models.*; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.*; +import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; +import com.sinch.sdk.models.Configuration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collection; +import java.util.Collections; +import java.util.NoSuchElementException; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentMatchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class AvailableNumberServiceTest extends BaseTest { + + @GivenJsonResource("/domains/numbers/v1/available-numbers-list.json") + AvailableNumbersResponseDto availableNumbersListDto; + + @GivenJsonResource("/domains/numbers/v1/available-numbers-get.json") + AvailableNumberDto getNumberDto; + + @GivenJsonResource("/domains/numbers/v1/rent-response.json") + ActiveNumberDto rentNumberDto; + + @Mock Configuration configuration; + @Mock AvailableNumberApi api; + @InjectMocks AvailableNumberService service; + + @Test + void list() throws ApiException { + + when(api.numberServiceListAvailableNumbers( + eq(configuration.getProjectId()), + eq("region"), + ArgumentMatchers.eq(NumberType.MOBILE.value()), + eq(null), + eq(null), + eq(null), + eq(null))) + .thenReturn(availableNumbersListDto); + + AvailableNumberListAllRequestParameters parameters = + AvailableNumberListAllRequestParameters.builder() + .setRegionCode("region") + .setType(NumberType.MOBILE) + .build(); + + Collection expected = + Collections.singletonList( + AvailableNumber.builder() + .setPhoneNumber("+46650553763") + .setRegionCode("SE") + .setType(NumberType.LOCAL) + .setCapability(Collections.singletonList(Capability.VOICE)) + .setSetupPrice(new Money("DOLLAR", 0.57)) + .setMonthlyPrice(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setSupportingDocumentationRequired(true) + .build()); + + AvailableNumberListResponse response = service.list(parameters); + + assertFalse(response.hasNextPage(), "Has no next page"); + assertThrows(NoSuchElementException.class, response::nextPage); + Assertions.assertThat(response.getContent()).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void listWithParameters() throws ApiException { + + when(api.numberServiceListAvailableNumbers( + eq(configuration.getProjectId()), + eq("another region"), + ArgumentMatchers.eq(NumberType.TOLL_FREE.value()), + eq("pattern value"), + ArgumentMatchers.eq(SearchPattern.END.value()), + ArgumentMatchers.eq(Collections.singletonList(Capability.VOICE.value())), + eq(45))) + .thenReturn(availableNumbersListDto); + + AvailableNumberListAllRequestParameters parameters = + AvailableNumberListAllRequestParameters.builder() + .setRegionCode("another region") + .setType(NumberType.TOLL_FREE) + .setNumberPattern( + NumberPattern.builder() + .setPattern("pattern value") + .setSearchPattern(SearchPattern.END) + .build()) + .setCapabilities(Collections.singletonList(Capability.VOICE)) + .setSize(45) + .build(); + + Collection expected = + Collections.singletonList( + AvailableNumber.builder() + .setPhoneNumber("+46650553763") + .setRegionCode("SE") + .setType(NumberType.LOCAL) + .setCapability(Collections.singletonList(Capability.VOICE)) + .setSetupPrice(new Money("DOLLAR", 0.57)) + .setMonthlyPrice(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setSupportingDocumentationRequired(true) + .build()); + + AvailableNumberListResponse response = service.list(parameters); + + assertFalse(response.hasNextPage(), "Has no next page"); + assertThrows(NoSuchElementException.class, response::nextPage); + Assertions.assertThat(response.getContent()).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void get() { + + when(api.numberServiceGetAvailableNumber(eq(configuration.getProjectId()), eq("foo"))) + .thenReturn(getNumberDto); + + AvailableNumber response = service.get("foo"); + + AvailableNumber expected = + AvailableNumber.builder() + .setPhoneNumber("+46650553763") + .setRegionCode("SE") + .setType(NumberType.LOCAL) + .setCapability(Collections.singletonList(Capability.VOICE)) + .setSetupPrice(new Money("DOLLAR", 0.57)) + .setMonthlyPrice(new Money("EUR", 0.80)) + .setPaymentIntervalMonths(1) + .setSupportingDocumentationRequired(true) + .build(); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void rent() { + + when(api.numberServiceRentNumber(eq(configuration.getProjectId()), eq("foo"), any())) + .thenReturn(rentNumberDto); + + ActiveNumber response = + service.rent( + "foo", + new AvailableNumberRentRequestParameters( + new RentSMSConfigurationRequestParameters("", ""), + new RentVoiceConfigurationRequestParameters(""), + "foo")); + ActiveNumber expected = + ActiveNumber.builder() + .setRegionCode("US") + .setPaymentIntervalMonths(0) + .setNextChargeDate( + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()) + .setExpireAt( + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()) + .setPhoneNumber("+12025550134") + .setProjectId("51bc3f40-f266-4ca8-8938-a1ed0ff32b9a") + .setDisplayName("string") + .setType(NumberType.MOBILE) + .setCapability(Collections.singletonList(Capability.SMS)) + .setMoney(new Money("USD", 2.00)) + .setSmsConfiguration( + new SMSConfiguration( + "string", + "string", + new ScheduledSmsProvisioning( + "8200000f74924bd6800000b212f00000", + "string", + ProvisioningStatus.WAITING, + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant(), + Collections.emptyList()))) + .setVoiceConfiguration( + new VoiceConfiguration( + "string", + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant(), + new ScheduledVoiceProvisioning( + "string", + ProvisioningStatus.WAITING, + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()))) + .setCallbackUrl("https://www.your-callback-server.com/callback") + .build(); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void rentAny() { + + when(api.numberServiceRentAnyNumber(eq(configuration.getProjectId()), any())) + .thenReturn(rentNumberDto); + + AvailableNumberRentAnyRequestParameters parameters = + AvailableNumberRentAnyRequestParameters.builder() + .setRegionCode("foo region") + .setType(NumberType.MOBILE) + .build(); + ActiveNumber response = service.rentAny(parameters); + ActiveNumber expected = + ActiveNumber.builder() + .setRegionCode("US") + .setPaymentIntervalMonths(0) + .setNextChargeDate( + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()) + .setExpireAt( + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()) + .setPhoneNumber("+12025550134") + .setProjectId("51bc3f40-f266-4ca8-8938-a1ed0ff32b9a") + .setDisplayName("string") + .setType(NumberType.MOBILE) + .setCapability(Collections.singletonList(Capability.SMS)) + .setMoney(new Money("USD", 2.00)) + .setSmsConfiguration( + new SMSConfiguration( + "string", + "string", + new ScheduledSmsProvisioning( + "8200000f74924bd6800000b212f00000", + "string", + ProvisioningStatus.WAITING, + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant(), + Collections.emptyList()))) + .setVoiceConfiguration( + new VoiceConfiguration( + "string", + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant(), + new ScheduledVoiceProvisioning( + "string", + ProvisioningStatus.WAITING, + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME) + .toInstant()))) + .setCallbackUrl("https://www.your-callback-server.com/callback") + .build(); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationServiceTest.java new file mode 100644 index 00000000..6e76aa7f --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationServiceTest.java @@ -0,0 +1,69 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import static org.mockito.ArgumentMatchers.eq; +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.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.adapters.api.v1.CallbackConfigurationApi; +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationUpdateDto; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; +import com.sinch.sdk.models.Configuration; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class CallbackConfigurationServiceTest extends BaseTest { + + @GivenJsonResource("/domains/numbers/v1/callback-configuration.json") + CallbackConfigurationDto callbackConfigurationDto; + + @Mock Configuration configuration; + @Mock CallbackConfigurationApi api; + @InjectMocks CallbackConfigurationService service; + + @Test + void get() throws ApiException { + + when(api.getCallbackConfiguration(eq(configuration.getProjectId()))) + .thenReturn(callbackConfigurationDto); + + CallbackConfiguration response = service.get(); + + CallbackConfiguration expected = + CallbackConfiguration.builder() + .setProjectId("The project ID") + .setHMACSecret("The secret HMAC") + .build(); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void update() throws ApiException { + + CallbackConfigurationUpdateDto dtoParameters = + new CallbackConfigurationUpdateDto().hmacSecret("hmac value"); + CallbackConfigurationUpdateRequestParameters parameters = + CallbackConfigurationUpdateRequestParameters.builder().setHMACSecret("hmac value").build(); + + when(api.updateCallbackConfiguration(eq(configuration.getProjectId()), eq(dtoParameters))) + .thenReturn(callbackConfigurationDto); + + CallbackConfiguration response = service.update(parameters); + + CallbackConfiguration expected = + CallbackConfiguration.builder() + .setProjectId("The project ID") + .setHMACSecret("The secret HMAC") + .build(); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/RegionServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/RegionServiceTest.java new file mode 100644 index 00000000..dcc92687 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/RegionServiceTest.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.numbers.adapters; + +import static org.mockito.ArgumentMatchers.eq; +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.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.adapters.api.v1.AvailableRegionsApi; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.Region; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; +import com.sinch.sdk.models.Configuration; +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class RegionServiceTest extends BaseTest { + + @GivenJsonResource("/domains/numbers/v1/available-regions-list.json") + ListAvailableRegionsResponseDto availableRegionsListDto; + + @Mock Configuration configuration; + @Mock AvailableRegionsApi api; + @InjectMocks AvailableRegionService service; + + @Test + void list() throws ApiException { + + when(api.numberServiceListAvailableRegions( + eq(configuration.getProjectId()), eq(Collections.singletonList("MOBILE")))) + .thenReturn(availableRegionsListDto); + + AvailableRegionListResponse response = + service.list( + AvailableRegionListAllRequestParameters.builder() + .setTypes(Collections.singletonList(NumberType.MOBILE)) + .build()); + + Collection expected = + Collections.singletonList( + Region.builder() + .setRegionName("Australia") + .setRegionCode("AU") + .setTypes(Collections.singletonList(NumberType.MOBILE)) + .build()); + + Assertions.assertThat(response.getContent()).usingRecursiveComparison().isEqualTo(expected); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverterTest.java new file mode 100644 index 00000000..332b6360 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverterTest.java @@ -0,0 +1,72 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.core.models.pagination.PageToken; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumbersResponseDto; +import java.time.OffsetDateTime; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ActiveNumberDtoConverterTest { + + static final OffsetDateTime offset1 = OffsetDateTime.now(); + ActiveNumberDto dtoItem; + + public static void compareWithDto(ActiveNumber client, ActiveNumberDto dto) { + assertEquals(dto.getPhoneNumber(), client.getPhoneNumber()); + assertEquals(dto.getProjectId(), client.getProjectId()); + assertEquals(dto.getDisplayName(), client.getDisplayName()); + assertEquals(dto.getRegionCode(), client.getRegionCode()); + assertEquals(dto.getType(), NumberType.valueOf(client.getType())); + assertEquals( + null == dto.getCapability() ? null : dto.getCapability(), + null == client.getCapability() + ? null + : client.getCapability().stream() + .map(Capability::valueOf) + .collect(Collectors.toList())); + MoneyDtoConverterTest.compareWithDto(client.getMoney(), dto.getMoney()); + assertEquals(dto.getPaymentIntervalMonths(), client.getPaymentIntervalMonths()); + assertEquals(dto.getNextChargeDate().toInstant(), client.getNextChargeDate()); + assertEquals(dto.getExpireAt().toInstant(), client.getExpireAt()); + SmsConfigurationDtoConverterTest.compareWithDto( + client.getSmsConfiguration(), dto.getSmsConfiguration()); + VoiceConfigurationDtoConverterTest.compareWithDto( + client.getVoiceConfiguration(), dto.getVoiceConfiguration()); + assertEquals(dto.getCallbackUrl(), client.getCallbackUrl()); + } + + @Test + void convertActiveNumbersResponseDto() { + ActiveNumbersResponseDto dto = new ActiveNumbersResponseDto(); + dto.setActiveNumbers(Collections.singletonList(dtoItem)); + + Pair, PageToken> converted = + ActiveNumberDtoConverter.convert(dto); + + assertEquals(dto.getActiveNumbers().size(), converted.getLeft().size()); + assertEquals(dto.getNextPageToken(), converted.getRight().getToken()); + compareWithDto(converted.getLeft().stream().findFirst().get(), dto.getActiveNumbers().get(0)); + } + + @Test + void convertActiveNumberDto() { + ActiveNumberDto dto = dtoItem; + ActiveNumber converted = ActiveNumberDtoConverter.convert(dtoItem); + compareWithDto(converted, dto); + } + + @BeforeEach + void setUp() { + dtoItem = new ActiveNumberDto("phoneNumber", 4, offset1, OffsetDateTime.MAX); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverterTest.java new file mode 100644 index 00000000..298be9d4 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverterTest.java @@ -0,0 +1,65 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SMSConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.VoiceConfigurationDto; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class ActiveNumberUpdateRequestParametersDtoConverterTest { + + ActiveNumberUpdateRequestParameters item; + + public static void compareWithDto( + ActiveNumberUpdateSMSConfigurationRequestParameters client, SMSConfigurationDto dto) { + assertEquals(dto.getServicePlanId(), client.getServicePlanId()); + assertEquals(dto.getCampaignId(), client.getCampaignId().get()); + } + + public static void compareWithDto( + ActiveNumberUpdateVoiceConfigurationRequestParameters client, VoiceConfigurationDto dto) { + assertEquals(dto.getAppId(), client.getAppId()); + } + + public static void compareWithDto( + ActiveNumberUpdateRequestParameters client, ActiveNumberRequestDto dto) { + assertEquals(dto.getDisplayName(), client.getDisplayName().get()); + compareWithDto(client.getSmsConfiguration().get(), dto.getSmsConfiguration()); + compareWithDto(client.getVoiceConfiguration().get(), dto.getVoiceConfiguration()); + // TODO: OAS file do not yet contains callback field declaration + // assertEquals(dto.getCallback(), + // client.getCallback()); + + } + + @Test + void convert() { + ActiveNumberRequestDto converted = + ActiveNumberUpdateRequestParametersDtoConverter.convert(item); + compareWithDto(item, converted); + } + + @BeforeEach + void setUp() { + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration = + ActiveNumberUpdateSMSConfigurationRequestParameters.builder() + .setServicePlanId("service plan id") + .setCampaignId("campaign id") + .build(); + + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration = + ActiveNumberUpdateVoiceConfigurationRequestParameters.builder().setAppId("app id").build(); + item = + ActiveNumberUpdateRequestParameters.builder() + .setDisplayName("my display name") + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .setCallback("foo callback") + .build(); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverterTest.java new file mode 100644 index 00000000..c900d911 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverterTest.java @@ -0,0 +1,81 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.MoneyDto; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class AvailableNumberDtoConverterTest { + + AvailableNumberDto dtoItem; + + public static void compareWithDto(AvailableNumber client, AvailableNumberDto dto) { + assertEquals(dto.getPhoneNumber(), client.getPhoneNumber()); + assertEquals(dto.getRegionCode(), client.getRegionCode()); + assertEquals(dto.getType(), NumberType.valueOf(client.getType())); + assertEquals( + null == dto.getCapability() ? null : dto.getCapability(), + null == client.getCapability() + ? null + : client.getCapability().stream() + .map(Capability::valueOf) + .collect(Collectors.toList())); + MoneyDtoConverterTest.compareWithDto(client.getSetupPrice(), dto.getSetupPrice()); + MoneyDtoConverterTest.compareWithDto(client.getMonthlyPrice(), dto.getMonthlyPrice()); + assertEquals(dto.getPaymentIntervalMonths(), client.getPaymentIntervalMonths()); + assertEquals( + dto.getSupportingDocumentationRequired(), client.getSupportingDocumentationRequired()); + } + + @Test + void convertAvailableNumbersResponseDto() { + AvailableNumbersResponseDto dto = new AvailableNumbersResponseDto(); + dto.setAvailableNumbers(Collections.singletonList(dtoItem)); + + Collection converted = AvailableNumberDtoConverter.convert(dto); + + assertEquals(dto.getAvailableNumbers().size(), converted.size()); + } + + @Test + void convertEmptyAvailableNumbersResponseDto() { + AvailableNumbersResponseDto dto = new AvailableNumbersResponseDto(); + Collection converted = AvailableNumberDtoConverter.convert(dto); + + assertEquals(converted.size(), 0); + } + + @Test + void convertAvailableNumberDto() { + AvailableNumberDto dto = dtoItem; + AvailableNumber converted = AvailableNumberDtoConverter.convert(dtoItem); + compareWithDto(converted, dto); + } + + @Test + void convertAvailableNumberDtoWithUnknownType() { + dtoItem = + new AvailableNumberDto("phoneNumber", "regionCode", 4, true) + .type("foo") + .addCapabilityItem(Capability.SMS.value()) + .addCapabilityItem(Capability.VOICE.value()) + .setupPrice(new MoneyDto().currencyCode("EU").amount(".8")) + .monthlyPrice(new MoneyDto().currencyCode("EU").amount(".15")); + AvailableNumber converted = AvailableNumberDtoConverter.convert(dtoItem); + compareWithDto(converted, dtoItem); + } + + @BeforeEach + void setUp() { + dtoItem = new AvailableNumberDto("phoneNumber", "regionCode", 4, true); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverterTest.java new file mode 100644 index 00000000..74c0812c --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverterTest.java @@ -0,0 +1,92 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentVoiceConfigurationRequestParameters; +import java.util.Collections; +import java.util.stream.Collectors; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class AvailableRentAnyRequestParametersDtoConverterTest { + + AvailableNumberRentAnyRequestParameters item; + + public static void compareWithDto( + AvailableNumberRentAnyRequestParameters client, RentAnyNumberRequestDto dto) { + assertEquals(dto.getRegionCode(), client.getRegionCode()); + assertEquals(dto.getType(), NumberType.valueOf(client.getType())); + if (null == dto.getNumberPattern()) { + assertFalse(client.getNumberPattern().isPresent()); + } else { + assertEquals( + dto.getNumberPattern().getPattern(), client.getNumberPattern().get().getPattern()); + assertEquals( + dto.getNumberPattern().getSearchPattern(), + client.getNumberPattern().get().getSearchPattern().value()); + } + if (null == dto.getCapabilities()) { + assertFalse(client.getCapabilities().isPresent()); + } else { + assertEquals( + dto.getCapabilities(), + client.getCapabilities().get().stream() + .map(Capability::valueOf) + .collect(Collectors.toList())); + } + if (null == dto.getSmsConfiguration()) { + assertFalse(client.getSmsConfiguration().isPresent()); + } else { + assertEquals( + dto.getSmsConfiguration().getCampaignId(), + client.getSmsConfiguration().get().getCampaignId().get()); + assertEquals( + dto.getSmsConfiguration().getServicePlanId(), + client.getSmsConfiguration().get().getServicePlanId()); + } + if (null == dto.getVoiceConfiguration()) { + assertFalse(client.getVoiceConfiguration().isPresent()); + } else { + assertEquals( + dto.getVoiceConfiguration().getAppId(), client.getVoiceConfiguration().get().getAppId()); + } + if (null == dto.getCallbackUrl()) { + assertFalse(client.getCallBackUrl().isPresent()); + } else { + assertEquals(dto.getCallbackUrl(), client.getCallBackUrl().get()); + } + } + + @Test + void convert() { + RentAnyNumberRequestDto converted = AvailableRentAnyRequestParametersDtoConverter.convert(item); + compareWithDto(item, converted); + } + + @BeforeEach + void setUp() { + item = + AvailableNumberRentAnyRequestParameters.builder() + .setRegionCode("region code") + .setType(NumberType.from("foo type")) + .setNumberPattern( + NumberPattern.builder() + .setPattern("pattern") + .setSearchPattern(SearchPattern.CONTAINS) + .build()) + .setCapabilities(Collections.singletonList(Capability.SMS)) + .setSmsConfiguration( + new RentSMSConfigurationRequestParameters("campaign id", ("service plan"))) + .setVoiceConfiguration(new RentVoiceConfigurationRequestParameters("app id")) + .setCallbackUrl("callback url") + .build(); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverterTest.java new file mode 100644 index 00000000..ac75efc6 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverterTest.java @@ -0,0 +1,58 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import com.sinch.sdk.domains.numbers.models.dto.v1.RentNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentVoiceConfigurationRequestParameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class AvailableRentRequestParametersDtoConverterTest { + AvailableNumberRentRequestParameters item; + + public static void compareWithDto( + AvailableNumberRentRequestParameters client, RentNumberRequestDto dto) { + + if (null == dto.getSmsConfiguration()) { + assertFalse(client.getSmsConfiguration().isPresent()); + } else { + assertEquals( + dto.getSmsConfiguration().getCampaignId(), + client.getSmsConfiguration().get().getCampaignId().get()); + assertEquals( + dto.getSmsConfiguration().getServicePlanId(), + client.getSmsConfiguration().get().getServicePlanId()); + } + if (null == dto.getVoiceConfiguration()) { + assertFalse(client.getVoiceConfiguration().isPresent()); + } else { + assertEquals( + dto.getVoiceConfiguration().getAppId(), client.getVoiceConfiguration().get().getAppId()); + } + if (null == dto.getCallbackUrl()) { + assertFalse(client.getCallBackUrl().isPresent()); + } else { + assertEquals(dto.getCallbackUrl(), client.getCallBackUrl().get()); + } + } + + @Test + void convert() { + RentNumberRequestDto converted = AvailableRentRequestParametersDtoConverter.convert(item); + compareWithDto(item, converted); + } + + @BeforeEach + void setUp() { + item = + AvailableNumberRentRequestParameters.builder() + .setSmsConfiguration( + new RentSMSConfigurationRequestParameters("campaign id", ("service plan"))) + .setVoiceConfiguration(new RentVoiceConfigurationRequestParameters("app id")) + .setCallbackUrl("callback url") + .build(); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverterTest.java new file mode 100644 index 00000000..a7b9c8eb --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverterTest.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationDtoConverterTest { + + public static void compareWithDto(CallbackConfiguration client, CallbackConfigurationDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(dto.getProjectId(), client.getProjectId()); + assertEquals(dto.getHmacSecret(), client.getHMACSecret()); + } + + @Test + void convert() { + CallbackConfigurationDto dto = new CallbackConfigurationDto(); + dto.setProjectId("my project"); + dto.setHmacSecret("a HMAC secret"); + + CallbackConfiguration converted = CallbackConfigurationDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateParametersDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateParametersDtoConverterTest.java new file mode 100644 index 00000000..838f3c0e --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateParametersDtoConverterTest.java @@ -0,0 +1,31 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationUpdateDto; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationUpdateParametersDtoConverterTest { + + CallbackConfigurationUpdateRequestParameters item; + + public static void compareWithDto( + CallbackConfigurationUpdateRequestParameters client, CallbackConfigurationUpdateDto dto) { + assertEquals(dto.getHmacSecret(), client.getHMACSecret()); + } + + @Test + void convert() { + CallbackConfigurationUpdateDto converted = + CallbackConfigurationUpdateRequestParametersDtoConverter.convert(item); + compareWithDto(item, converted); + } + + @BeforeEach + void setUp() { + + item = CallbackConfigurationUpdateRequestParameters.builder().setHMACSecret("my HMAC").build(); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverterTest.java new file mode 100644 index 00000000..a680354c --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverterTest.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.Money; +import com.sinch.sdk.domains.numbers.models.dto.v1.MoneyDto; +import org.junit.jupiter.api.Test; + +class MoneyDtoConverterTest { + + public static void compareWithDto(Money client, MoneyDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(Double.valueOf(dto.getAmount()), client.getAmount()); + assertEquals(dto.getCurrencyCode(), client.getCurrencyCode()); + } + + @Test + void convert() { + MoneyDto dto = new MoneyDto(); + dto.setAmount("15.37"); + dto.setCurrencyCode("currency code"); + + Money converted = MoneyDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/RegionsDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/RegionsDtoConverterTest.java new file mode 100644 index 00000000..7785bd30 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/RegionsDtoConverterTest.java @@ -0,0 +1,59 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.Region; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableRegionDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.stream.Collectors; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class RegionsDtoConverterTest { + + AvailableRegionDto dtoItem; + + public static void compareWithDto(Region client, AvailableRegionDto dto) { + assertEquals(dto.getRegionCode(), client.getRegionCode()); + assertEquals(dto.getRegionName(), client.getRegionName()); + assertEquals( + null == dto.getTypes() ? null : dto.getTypes(), + null == client.getTypes() + ? null + : client.getTypes().stream().map(NumberType::valueOf).collect(Collectors.toList())); + } + + @Test + void convertListAvailableRegionsResponseDto() { + ListAvailableRegionsResponseDto dto = new ListAvailableRegionsResponseDto(); + dto.setAvailableRegions(Collections.singletonList(dtoItem)); + + Collection converted = AvailableRegionsDtoConverter.convert(dto); + + assertEquals(dto.getAvailableRegions().size(), converted.size()); + } + + @Test + void convertEmptyListAvailableRegionsResponseDto() { + ListAvailableRegionsResponseDto dto = new ListAvailableRegionsResponseDto(); + Collection converted = AvailableRegionsDtoConverter.convert(dto); + + assertEquals(converted.size(), 0); + } + + @Test + void convertAvailableNumberDto() { + AvailableRegionDto dto = dtoItem; + Region converted = AvailableRegionsDtoConverter.convert(dtoItem); + compareWithDto(converted, dto); + } + + @BeforeEach + void setUp() { + dtoItem = new AvailableRegionDto("region code", "region name", Arrays.asList("MOBILE", "foo")); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverterTest.java new file mode 100644 index 00000000..04e9666d --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverterTest.java @@ -0,0 +1,47 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.ScheduledSmsProvisioning; +import com.sinch.sdk.domains.numbers.models.SmsErrorCode; +import com.sinch.sdk.domains.numbers.models.dto.v1.ProvisioningStatusDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledProvisioningDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SmsErrorCodeDto; +import java.time.OffsetDateTime; +import java.util.Collections; +import java.util.stream.Collectors; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ScheduledSmsProvisioningDtoConverterTest { + + public static void compareWithDto(ScheduledSmsProvisioning client, ScheduledProvisioningDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(dto.getServicePlanId(), client.getServicePlanId()); + assertEquals(dto.getCampaignId(), client.getCampaignId()); + assertEquals(dto.getLastUpdatedTime().toInstant(), client.getLastUpdatedTime()); + assertEquals(dto.getStatus().getValue(), client.getStatus().value()); + Assertions.assertThat(dto.getErrorCodes().stream().map(Enum::name).collect(Collectors.toList())) + .usingRecursiveComparison() + .isEqualTo( + client.getErrorCodes().stream() + .map(SmsErrorCode::valueOf) + .collect(Collectors.toList())); + } + + @Test + void convert() { + ScheduledProvisioningDto dto = + new ScheduledProvisioningDto( + "service plan id", + "campaign id", + OffsetDateTime.now(), + Collections.singletonList(SmsErrorCodeDto.ERROR_CODE_UNSPECIFIED)) + .status(ProvisioningStatusDto.WAITING); + + ScheduledSmsProvisioning converted = ScheduledSmsProvisioningDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverterTest.java new file mode 100644 index 00000000..12259bdd --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverterTest.java @@ -0,0 +1,32 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.ScheduledVoiceProvisioning; +import com.sinch.sdk.domains.numbers.models.dto.v1.ProvisioningStatusDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledVoiceProvisioningDto; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; + +class ScheduledVoiceProvisioningDtoConverterTest { + + public static void compareWithDto( + ScheduledVoiceProvisioning client, ScheduledVoiceProvisioningDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(dto.getAppId(), client.getAppId()); + assertEquals(dto.getLastUpdatedTime().toInstant(), client.getLastUpdatedTime()); + assertEquals(dto.getStatus().getValue(), client.getStatus().value()); + } + + @Test + void convert() { + ScheduledVoiceProvisioningDto dto = + new ScheduledVoiceProvisioningDto("app id", OffsetDateTime.now()) + .status(ProvisioningStatusDto.WAITING); + + ScheduledVoiceProvisioning converted = ScheduledVoiceProvisioningDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverterTest.java new file mode 100644 index 00000000..2079b905 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverterTest.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.SMSConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.ProvisioningStatusDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SMSConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledProvisioningDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.SmsErrorCodeDto; +import java.time.OffsetDateTime; +import java.util.Collections; +import org.junit.jupiter.api.Test; + +class SmsConfigurationDtoConverterTest { + + public static void compareWithDto(SMSConfiguration client, SMSConfigurationDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(dto.getServicePlanId(), client.getServicePlanId()); + assertEquals(dto.getCampaignId(), client.getCampaignId().get()); + ScheduledSmsProvisioningDtoConverterTest.compareWithDto( + client.getScheduledSmsProvisioning().get(), dto.getScheduledProvisioning()); + } + + @Test + void convert() { + SMSConfigurationDto dto = + new SMSConfigurationDto() + .servicePlanId("service plan id") + .campaignId("campaign id") + .scheduledProvisioning( + new ScheduledProvisioningDto( + "service plan id", + "campaign id", + OffsetDateTime.now(), + Collections.singletonList(SmsErrorCodeDto.ERROR_CODE_UNSPECIFIED)) + .status(ProvisioningStatusDto.WAITING)); + + SMSConfiguration converted = SmsConfigurationDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverterTest.java new file mode 100644 index 00000000..ea1352eb --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverterTest.java @@ -0,0 +1,36 @@ +package com.sinch.sdk.domains.numbers.adapters.converters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.numbers.models.VoiceConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.ProvisioningStatusDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ScheduledVoiceProvisioningDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.VoiceConfigurationDto; +import java.time.OffsetDateTime; +import org.junit.jupiter.api.Test; + +class VoiceConfigurationDtoConverterTest { + + public static void compareWithDto(VoiceConfiguration client, VoiceConfigurationDto dto) { + if (null == client && null == dto) { + return; + } + assertEquals(dto.getAppId(), client.getAppId()); + assertEquals(dto.getLastUpdatedTime().toInstant(), client.getLastUpdatedTime().get()); + ScheduledVoiceProvisioningDtoConverterTest.compareWithDto( + client.getScheduledVoiceProvisioning().get(), dto.getScheduledVoiceProvisioning()); + } + + @Test + void convert() { + VoiceConfigurationDto dto = + new VoiceConfigurationDto(OffsetDateTime.now()) + .appId("app id") + .scheduledVoiceProvisioning( + new ScheduledVoiceProvisioningDto("app id", OffsetDateTime.now()) + .status(ProvisioningStatusDto.WAITING)); + + VoiceConfiguration converted = VoiceConfigurationDtoConverter.convert(dto); + compareWithDto(converted, dto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberBuilderTest.java new file mode 100644 index 00000000..f3b0fa6b --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberBuilderTest.java @@ -0,0 +1,126 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ActiveNumberBuilderTest { + + final String phoneNumber = "01234"; + final String projectId = "project id"; + final String displayName = "display name"; + final String regionCode = "region"; + final NumberType type = NumberType.MOBILE; + final Collection capability = Arrays.asList(Capability.VOICE, Capability.SMS); + + final Money money = new Money("foo money", 0.50); + + final Integer paymentIntervalMonths = 5; + + final Instant nextChargeDate = Instant.now(); + + final Instant expireAt = Instant.now(); + + final SMSConfiguration smsConfiguration = + new SMSConfiguration( + "service plan id", + "campaign id", + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.FAILED, + Instant.now(), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED))); + final VoiceConfiguration voiceConfiguration = + new VoiceConfiguration( + "app id", + Instant.now(), + new ScheduledVoiceProvisioning( + "app id from scheduled", ProvisioningStatus.IN_PROGRESS, Instant.now())); + + final String callbackUrl = "foo callback"; + final ActiveNumber value = + ActiveNumber.builder() + .setPhoneNumber(phoneNumber) + .setProjectId(projectId) + .setDisplayName(displayName) + .setRegionCode(regionCode) + .setType(type) + .setCapability(capability) + .setMoney(money) + .setPaymentIntervalMonths(paymentIntervalMonths) + .setNextChargeDate(nextChargeDate) + .setExpireAt(expireAt) + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .setCallbackUrl(callbackUrl) + .build(); + + @Test + void getPhoneNumber() { + Assertions.assertThat(value.getPhoneNumber()).isEqualTo(phoneNumber); + } + + @Test + void getProjectId() { + Assertions.assertThat(value.getProjectId()).isEqualTo(projectId); + } + + @Test + void getDisplayName() { + Assertions.assertThat(value.getDisplayName()).isEqualTo(displayName); + } + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getCapability() { + Assertions.assertThat(value.getCapability()).usingRecursiveComparison().isEqualTo(capability); + } + + @Test + void getMoney() { + Assertions.assertThat(value.getMoney()).isEqualTo(money); + } + + @Test + void getPaymentIntervalMonths() { + Assertions.assertThat(value.getPaymentIntervalMonths()).isEqualTo(paymentIntervalMonths); + } + + @Test + void getNextChargeDate() { + Assertions.assertThat(value.getNextChargeDate()).isEqualTo(nextChargeDate); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(smsConfiguration); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(voiceConfiguration); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberTest.java new file mode 100644 index 00000000..a598ed46 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/ActiveNumberTest.java @@ -0,0 +1,125 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ActiveNumberTest { + + final String phoneNumber = "01234"; + final String projectId = "project id"; + final String displayName = "display name"; + final String regionCode = "region"; + final NumberType type = NumberType.MOBILE; + final Collection capability = Arrays.asList(Capability.VOICE, Capability.SMS); + + final Money money = new Money("foo money", 0.50); + + final Integer paymentIntervalMonths = 5; + + final Instant nextChargeDate = Instant.now(); + + final Instant expireAt = Instant.now(); + + final SMSConfiguration smsConfiguration = + new SMSConfiguration( + "service plan id", + "campaign id", + new ScheduledSmsProvisioning( + "service plan id from scheduled", + "campaign id from scheduled", + ProvisioningStatus.FAILED, + Instant.now(), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED))); + final VoiceConfiguration voiceConfiguration = + new VoiceConfiguration( + "app id", + Instant.now(), + new ScheduledVoiceProvisioning( + "app id from scheduled", ProvisioningStatus.IN_PROGRESS, Instant.now())); + + final String callbackUrl = "foo callback"; + final ActiveNumber value = + new ActiveNumber( + phoneNumber, + projectId, + displayName, + regionCode, + type, + capability, + money, + paymentIntervalMonths, + nextChargeDate, + expireAt, + smsConfiguration, + voiceConfiguration, + callbackUrl); + + @Test + void getPhoneNumber() { + Assertions.assertThat(value.getPhoneNumber()).isEqualTo(phoneNumber); + } + + @Test + void getProjectId() { + Assertions.assertThat(value.getProjectId()).isEqualTo(projectId); + } + + @Test + void getDisplayName() { + Assertions.assertThat(value.getDisplayName()).isEqualTo(displayName); + } + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getCapability() { + Assertions.assertThat(value.getCapability()).usingRecursiveComparison().isEqualTo(capability); + } + + @Test + void getMoney() { + Assertions.assertThat(value.getMoney()).isEqualTo(money); + } + + @Test + void getPaymentIntervalMonths() { + Assertions.assertThat(value.getPaymentIntervalMonths()).isEqualTo(paymentIntervalMonths); + } + + @Test + void getNextChargeDate() { + Assertions.assertThat(value.getNextChargeDate()).isEqualTo(nextChargeDate); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(smsConfiguration); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(voiceConfiguration); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberBuilderTest.java new file mode 100644 index 00000000..c7016f86 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberBuilderTest.java @@ -0,0 +1,73 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberBuilderTest { + + final String phoneNumber = "01234"; + final String regionCode = "region"; + final NumberType type = NumberType.MOBILE; + final Collection capability = Arrays.asList(Capability.VOICE, Capability.SMS); + final Money setupPrice = new Money("setup currency", .5); + final Money monthlyPrice = new Money("monthly currency", 1.5); + final Integer paymentIntervalMonths = 23; + final Boolean supportingDocumentationRequired = true; + + final AvailableNumber value = + AvailableNumber.builder() + .setPhoneNumber(phoneNumber) + .setRegionCode(regionCode) + .setType(type) + .setCapability(capability) + .setSetupPrice(setupPrice) + .setMonthlyPrice(monthlyPrice) + .setPaymentIntervalMonths(paymentIntervalMonths) + .setSupportingDocumentationRequired(supportingDocumentationRequired) + .build(); + + @Test + void getPhoneNumber() { + Assertions.assertThat(value.getPhoneNumber()).isEqualTo(phoneNumber); + } + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getCapability() { + Assertions.assertThat(value.getCapability()).usingRecursiveComparison().isEqualTo(capability); + } + + @Test + void getSetupPrice() { + Assertions.assertThat(value.getSetupPrice()).usingRecursiveComparison().isEqualTo(setupPrice); + } + + @Test + void getMonthlyPrice() { + Assertions.assertThat(value.getMonthlyPrice()) + .usingRecursiveComparison() + .isEqualTo(monthlyPrice); + } + + @Test + void getPaymentIntervalMonths() { + Assertions.assertThat(value.getPaymentIntervalMonths()).isEqualTo(paymentIntervalMonths); + } + + @Test + void getSupportingDocumentationRequired() { + Assertions.assertThat(value.getSupportingDocumentationRequired()) + .isEqualTo(supportingDocumentationRequired); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberTest.java new file mode 100644 index 00000000..a72ba19d --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/AvailableNumberTest.java @@ -0,0 +1,72 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberTest { + + final String phoneNumber = "01234"; + final String regionCode = "region"; + final NumberType type = NumberType.MOBILE; + final Collection capability = Arrays.asList(Capability.VOICE, Capability.SMS); + final Money setupPrice = new Money("setup currency", .5); + final Money monthlyPrice = new Money("monthly currency", 1.5); + final Integer paymentIntervalMonths = 23; + final Boolean supportingDocumentationRequired = true; + + final AvailableNumber value = + new AvailableNumber( + phoneNumber, + regionCode, + type, + capability, + setupPrice, + monthlyPrice, + paymentIntervalMonths, + supportingDocumentationRequired); + + @Test + void getPhoneNumber() { + Assertions.assertThat(value.getPhoneNumber()).isEqualTo(phoneNumber); + } + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getCapability() { + Assertions.assertThat(value.getCapability()).usingRecursiveComparison().isEqualTo(capability); + } + + @Test + void getSetupPrice() { + Assertions.assertThat(value.getSetupPrice()).usingRecursiveComparison().isEqualTo(setupPrice); + } + + @Test + void getMonthlyPrice() { + Assertions.assertThat(value.getMonthlyPrice()) + .usingRecursiveComparison() + .isEqualTo(monthlyPrice); + } + + @Test + void getPaymentIntervalMonths() { + Assertions.assertThat(value.getPaymentIntervalMonths()).isEqualTo(paymentIntervalMonths); + } + + @Test + void getSupportingDocumentationRequired() { + Assertions.assertThat(value.getSupportingDocumentationRequired()) + .isEqualTo(supportingDocumentationRequired); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationBuilderTest.java new file mode 100644 index 00000000..cd4d0c32 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationBuilderTest.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationBuilderTest { + + final CallbackConfiguration value = + CallbackConfiguration.builder() + .setProjectId("project id") + .setHMACSecret("a HMAC secret") + .build(); + + @Test + void getProjectId() { + Assertions.assertThat(value.getProjectId()).isEqualTo("project id"); + } + + @Test + void getHMACSecret() { + Assertions.assertThat(value.getHMACSecret()).isEqualTo("a HMAC secret"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationTest.java new file mode 100644 index 00000000..85153ff6 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CallbackConfigurationTest.java @@ -0,0 +1,20 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationTest { + + final CallbackConfiguration value = + new CallbackConfiguration("the project id", "the secret HMAC"); + + @Test + void getProjectId() { + Assertions.assertThat(value.getProjectId()).isEqualTo("the project id"); + } + + @Test + void getHMACSecret() { + Assertions.assertThat(value.getHMACSecret()).isEqualTo("the secret HMAC"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/CapabilityTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CapabilityTest.java new file mode 100644 index 00000000..6aa0a3a3 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/CapabilityTest.java @@ -0,0 +1,30 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class CapabilityTest { + + final Capability newDefinedValue = Capability.from("foo"); + + @Test + void values() { + Assertions.assertThat(Capability.values()).contains(Capability.SMS); + } + + @Test + void fromDefined() { + Assertions.assertThat(Capability.from("SMS")).isEqualTo(Capability.SMS); + } + + @Test + void fromUndefined() { + Assertions.assertThat(newDefinedValue.value()).isEqualTo("foo"); + Assertions.assertThat(Capability.values()).contains(newDefinedValue); + } + + @Test + void valueOf() { + Assertions.assertThat(Capability.valueOf(newDefinedValue)).isEqualTo("foo"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyBuilderTest.java new file mode 100644 index 00000000..8a9822d4 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyBuilderTest.java @@ -0,0 +1,19 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class MoneyBuilderTest { + + final Money value = Money.builder().setAmount(.9).setCurrencyCode("currency").build(); + + @Test + void getCurrencyCode() { + Assertions.assertThat(value.getCurrencyCode()).isEqualTo("currency"); + } + + @Test + void getAmount() { + Assertions.assertThat(value.getAmount()).isEqualTo(.9); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyTest.java new file mode 100644 index 00000000..0b93a741 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/MoneyTest.java @@ -0,0 +1,19 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class MoneyTest { + + final Money value = new Money("currency", .9); + + @Test + void getCurrencyCode() { + Assertions.assertThat(value.getCurrencyCode()).isEqualTo("currency"); + } + + @Test + void getAmount() { + Assertions.assertThat(value.getAmount()).isEqualTo(.9); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternBuilderTest.java new file mode 100644 index 00000000..c0217d77 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternBuilderTest.java @@ -0,0 +1,22 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class NumberPatternBuilderTest { + final NumberPattern value = + NumberPattern.builder() + .setPattern("a pattern") + .setSearchPattern(SearchPattern.CONTAINS) + .build(); + + @Test + void getPattern() { + Assertions.assertThat(value.getPattern()).isEqualTo("a pattern"); + } + + @Test + void getSearchPattern() { + Assertions.assertThat(value.getSearchPattern()).isEqualTo(SearchPattern.CONTAINS); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternTest.java new file mode 100644 index 00000000..9d46994b --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberPatternTest.java @@ -0,0 +1,18 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class NumberPatternTest { + final NumberPattern value = new NumberPattern("a pattern", SearchPattern.CONTAINS); + + @Test + void getPattern() { + Assertions.assertThat(value.getPattern()).isEqualTo("a pattern"); + } + + @Test + void getSearchPattern() { + Assertions.assertThat(value.getSearchPattern()).isEqualTo(SearchPattern.CONTAINS); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberTypeTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberTypeTest.java new file mode 100644 index 00000000..5b9f5bd9 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/NumberTypeTest.java @@ -0,0 +1,29 @@ +package com.sinch.sdk.domains.numbers.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class NumberTypeTest { + final NumberType newDefinedValue = NumberType.from("foo"); + + @Test + void values() { + Assertions.assertThat(NumberType.values()).contains(NumberType.LOCAL); + } + + @Test + void fromDefined() { + Assertions.assertThat(NumberType.from("LOCAL")).isEqualTo(NumberType.LOCAL); + } + + @Test + void fromUndefined() { + Assertions.assertThat(newDefinedValue.value()).isEqualTo("foo"); + Assertions.assertThat(NumberType.values()).contains(newDefinedValue); + } + + @Test + void valueOf() { + Assertions.assertThat(NumberType.valueOf(newDefinedValue)).isEqualTo("foo"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionBuilderTest.java new file mode 100644 index 00000000..852e46d0 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionBuilderTest.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RegionBuilderTest { + + Collection types = Collections.singletonList(NumberType.TOLL_FREE); + final Region value = + Region.builder().setRegionCode("foo code").setRegionName("foo name").setTypes(types).build(); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo("foo code"); + } + + @Test + void getRegionName() { + Assertions.assertThat(value.getRegionName()).isEqualTo("foo name"); + } + + @Test + void getTypes() { + Assertions.assertThat(value.getTypes()).usingRecursiveComparison().isEqualTo(types); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionTest.java new file mode 100644 index 00000000..de19a947 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/RegionTest.java @@ -0,0 +1,27 @@ +package com.sinch.sdk.domains.numbers.models; + +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RegionTest { + + Collection types = Collections.singletonList(NumberType.TOLL_FREE); + final Region value = new Region("foo code", "foo name", types); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo("foo code"); + } + + @Test + void getRegionName() { + Assertions.assertThat(value.getRegionName()).isEqualTo("foo name"); + } + + @Test + void getTypes() { + Assertions.assertThat(value.getTypes()).usingRecursiveComparison().isEqualTo(types); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersBuilderTest.java new file mode 100644 index 00000000..3254ae4a --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersBuilderTest.java @@ -0,0 +1,70 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.*; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ActiveNumberListRequestParametersBuilderTest { + + final String regionCode = "foo region"; + final NumberType type = NumberType.MOBILE; + final NumberPattern numberPattern = + NumberPattern.builder().setPattern("a pattern").setSearchPattern(SearchPattern.END).build(); + final Collection capabilities = Arrays.asList(Capability.VOICE, Capability.SMS); + final Integer pageSize = 45; + + final String pageToken = "page token"; + + final OrderBy orderBy = OrderBy.PHONE_NUMBER; + final ActiveNumberListRequestParameters value = + ActiveNumberListRequestParameters.builder() + .setRegionCode(regionCode) + .setType(type) + .setNumberPattern(numberPattern) + .setCapabilities(capabilities) + .setPageSize(pageSize) + .setPageToken(pageToken) + .setOrderBy(orderBy) + .build(); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern().get()) + .usingRecursiveComparison() + .isEqualTo(numberPattern); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities().get()) + .usingRecursiveComparison() + .isEqualTo(capabilities); + } + + @Test + void getPageSize() { + Assertions.assertThat(value.getPageSize().get()).isEqualTo(pageSize); + } + + @Test + void getPageToken() { + Assertions.assertThat(value.getPageToken().get()).isEqualTo(pageToken); + } + + @Test + void getOrderBy() { + Assertions.assertThat(value.getOrderBy().get()).isEqualTo(orderBy); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersTest.java new file mode 100644 index 00000000..eb7fe1df --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParametersTest.java @@ -0,0 +1,64 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.*; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +public class ActiveNumberListRequestParametersTest { + + static final String regionCode = "foo region"; + static final NumberType type = NumberType.MOBILE; + static final NumberPattern numberPattern = new NumberPattern("a pattern", SearchPattern.END); + static final Collection capabilities = + Arrays.asList(Capability.VOICE, Capability.SMS); + static final Integer pageSize = 45; + + static final String pageToken = "page token"; + + static final OrderBy orderBy = OrderBy.PHONE_NUMBER; + + public static final ActiveNumberListRequestParameters value = + new ActiveNumberListRequestParameters( + regionCode, type, numberPattern, capabilities, pageSize, pageToken, orderBy); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern().get()) + .usingRecursiveComparison() + .isEqualTo(numberPattern); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities().get()) + .usingRecursiveComparison() + .isEqualTo(capabilities); + } + + @Test + void getPageSize() { + Assertions.assertThat(value.getPageSize().get()).isEqualTo(pageSize); + } + + @Test + void getPageToken() { + Assertions.assertThat(value.getPageToken().get()).isEqualTo(pageToken); + } + + @Test + void getOrderBy() { + Assertions.assertThat(value.getOrderBy().get()).isEqualTo(orderBy); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersBuilderTest.java new file mode 100644 index 00000000..b210d89a --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersBuilderTest.java @@ -0,0 +1,58 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberListAllRequestParametersBuilderTest { + + final String regionCode = "foo region"; + final NumberType type = NumberType.MOBILE; + final NumberPattern numberPattern = + NumberPattern.builder().setPattern("a pattern").setSearchPattern(SearchPattern.END).build(); + final Collection capabilities = Arrays.asList(Capability.VOICE, Capability.SMS); + final Integer size = 145; + + final AvailableNumberListAllRequestParameters value = + AvailableNumberListAllRequestParameters.builder() + .setRegionCode(regionCode) + .setType(type) + .setNumberPattern(numberPattern) + .setCapabilities(capabilities) + .setSize(size) + .build(); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern().get()) + .usingRecursiveComparison() + .isEqualTo(numberPattern); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities().get()) + .usingRecursiveComparison() + .isEqualTo(capabilities); + } + + @Test + void getSize() { + Assertions.assertThat(value.getSize().get()).isEqualTo(size); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersTest.java new file mode 100644 index 00000000..267e8f09 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParametersTest.java @@ -0,0 +1,52 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberListAllRequestParametersTest { + + final String regionCode = "foo region"; + final NumberType type = NumberType.MOBILE; + final NumberPattern numberPattern = new NumberPattern("a pattern", SearchPattern.END); + final Collection capabilities = Arrays.asList(Capability.VOICE, Capability.SMS); + final Integer size = 145; + + final AvailableNumberListAllRequestParameters value = + new AvailableNumberListAllRequestParameters( + regionCode, type, numberPattern, capabilities, size); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).usingRecursiveComparison().isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern().get()) + .usingRecursiveComparison() + .isEqualTo(numberPattern); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities().get()) + .usingRecursiveComparison() + .isEqualTo(capabilities); + } + + @Test + void getSize() { + Assertions.assertThat(value.getSize().get()).isEqualTo(size); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyBuilderTest.java new file mode 100644 index 00000000..619565df --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyBuilderTest.java @@ -0,0 +1,76 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import java.util.Arrays; +import java.util.Collection; +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberRentRequestParametersAnyBuilderTest { + + final String regionCode = "foo region"; + final NumberType type = NumberType.MOBILE; + final NumberPattern numberPattern = + NumberPattern.builder().setPattern("a pattern").setSearchPattern(SearchPattern.END).build(); + final Collection capabilities = Arrays.asList(Capability.VOICE, Capability.SMS); + + final RentSMSConfigurationRequestParameters smsConfiguration = + RentSMSConfigurationRequestParameters.builder() + .setServicePlanId("plan id") + .setCampaignId("campaign id") + .build(); + + final RentVoiceConfigurationRequestParameters voiceConfiguration = + RentVoiceConfigurationRequestParameters.builder().setAppId("app id").build(); + final String callbackUrl = " the callback"; + + final AvailableNumberRentAnyRequestParameters value = + AvailableNumberRentAnyRequestParameters.builder() + .setRegionCode(regionCode) + .setType(type) + .setNumberPattern(numberPattern) + .setCapabilities(capabilities) + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .setCallbackUrl(callbackUrl) + .build(); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern()).isEqualTo(Optional.of(numberPattern)); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities()).isEqualTo(Optional.of(capabilities)); + } + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(Optional.of(smsConfiguration)); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(Optional.of(voiceConfiguration)); + } + + @Test + void getCallBackUrl() { + Assertions.assertThat(value.getCallBackUrl()).isEqualTo(Optional.of(callbackUrl)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyTest.java new file mode 100644 index 00000000..56618791 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersAnyTest.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import java.util.Arrays; +import java.util.Collection; +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberRentRequestParametersAnyTest { + + final String regionCode = "foo region"; + final NumberType type = NumberType.MOBILE; + final NumberPattern numberPattern = new NumberPattern("a pattern", SearchPattern.END); + final Collection capabilities = Arrays.asList(Capability.VOICE, Capability.SMS); + + final RentSMSConfigurationRequestParameters smsConfiguration = + new RentSMSConfigurationRequestParameters("plan id", "campaign id"); + + final RentVoiceConfigurationRequestParameters voiceConfiguration = + new RentVoiceConfigurationRequestParameters("app id"); + final String callbackUrl = " the callback"; + + final AvailableNumberRentAnyRequestParameters value = + new AvailableNumberRentAnyRequestParameters( + regionCode, + type, + numberPattern, + capabilities, + smsConfiguration, + voiceConfiguration, + callbackUrl); + + @Test + void getRegionCode() { + Assertions.assertThat(value.getRegionCode()).isEqualTo(regionCode); + } + + @Test + void getType() { + Assertions.assertThat(value.getType()).isEqualTo(type); + } + + @Test + void getNumberPattern() { + Assertions.assertThat(value.getNumberPattern()).isEqualTo(Optional.of(numberPattern)); + } + + @Test + void getCapabilities() { + Assertions.assertThat(value.getCapabilities()).isEqualTo(Optional.of(capabilities)); + } + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(Optional.of(smsConfiguration)); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(Optional.of(voiceConfiguration)); + } + + @Test + void getCallBackUrl() { + Assertions.assertThat(value.getCallBackUrl()).isEqualTo(Optional.of(callbackUrl)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersBuilderTest.java new file mode 100644 index 00000000..85f4d8b1 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersBuilderTest.java @@ -0,0 +1,40 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberRentRequestParametersBuilderTest { + + RentSMSConfigurationRequestParameters smsConfiguration = + RentSMSConfigurationRequestParameters.builder() + .setServicePlanId("plan id") + .setCampaignId("campaign id") + .build(); + + RentVoiceConfigurationRequestParameters voiceConfiguration = + RentVoiceConfigurationRequestParameters.builder().setAppId("app id").build(); + String callbackUrl = "the callback"; + + final AvailableNumberRentRequestParameters value = + AvailableNumberRentRequestParameters.builder() + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .setCallbackUrl(callbackUrl) + .build(); + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(Optional.of(smsConfiguration)); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(Optional.of(voiceConfiguration)); + } + + @Test + void getCallBackUrl() { + Assertions.assertThat(value.getCallBackUrl()).isEqualTo(Optional.of(callbackUrl)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersTest.java new file mode 100644 index 00000000..4ee7d1fe --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParametersTest.java @@ -0,0 +1,33 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberRentRequestParametersTest { + + RentSMSConfigurationRequestParameters smsConfiguration = + new RentSMSConfigurationRequestParameters("plan id", "campaign id"); + + RentVoiceConfigurationRequestParameters voiceConfiguration = + new RentVoiceConfigurationRequestParameters("app id"); + String callbackUrl = "the callback"; + + final AvailableNumberRentRequestParameters value = + new AvailableNumberRentRequestParameters(smsConfiguration, voiceConfiguration, callbackUrl); + + @Test + void getSmsConfiguration() { + Assertions.assertThat(value.getSmsConfiguration()).isEqualTo(Optional.of(smsConfiguration)); + } + + @Test + void getVoiceConfiguration() { + Assertions.assertThat(value.getVoiceConfiguration()).isEqualTo(Optional.of(voiceConfiguration)); + } + + @Test + void getCallBackUrl() { + Assertions.assertThat(value.getCallBackUrl()).isEqualTo(Optional.of(callbackUrl)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersBuilderTest.java new file mode 100644 index 00000000..2edc31e6 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersBuilderTest.java @@ -0,0 +1,20 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableRegionListAllRequestParametersBuilderTest { + + final Collection types = Arrays.asList(NumberType.MOBILE, NumberType.TOLL_FREE); + + final AvailableRegionListAllRequestParameters value = + AvailableRegionListAllRequestParameters.builder().setTypes(types).build(); + + @Test + void getTypes() { + Assertions.assertThat(value.getTypes().get()).usingRecursiveComparison().isEqualTo(types); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersTest.java new file mode 100644 index 00000000..be0185be --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParametersTest.java @@ -0,0 +1,20 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableRegionListAllRequestParametersTest { + + final Collection types = Arrays.asList(NumberType.MOBILE, NumberType.TOLL_FREE); + + final AvailableRegionListAllRequestParameters value = + new AvailableRegionListAllRequestParameters(types); + + @Test + void getTypes() { + Assertions.assertThat(value.getTypes().get()).usingRecursiveComparison().isEqualTo(types); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersBuilderTest.java new file mode 100644 index 00000000..9cd046a8 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersBuilderTest.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationUpdateRequestParametersBuilderTest { + + final CallbackConfigurationUpdateRequestParameters value = + CallbackConfigurationUpdateRequestParameters.builder().setHMACSecret("hmac value").build(); + + @Test + void getHMACSecret() { + Assertions.assertThat(value.getHMACSecret()).isEqualTo("hmac value"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersTest.java new file mode 100644 index 00000000..b315a5c6 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParametersTest.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class CallbackConfigurationUpdateRequestParametersTest { + + final CallbackConfigurationUpdateRequestParameters value = + new CallbackConfigurationUpdateRequestParameters("hmac value"); + + @Test + void getHMACSecret() { + Assertions.assertThat(value.getHMACSecret()).isEqualTo("hmac value"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersBuilderTest.java new file mode 100644 index 00000000..33a8f53f --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersBuilderTest.java @@ -0,0 +1,31 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RentSMSConfigurationRequestParametersBuilderTest { + RentSMSConfigurationRequestParameters value = + RentSMSConfigurationRequestParameters.builder() + .setServicePlanId("plan id") + .setCampaignId("campaign id") + .build(); + + RentSMSConfigurationRequestParameters valueNoCampaign = + RentSMSConfigurationRequestParameters.builder().setServicePlanId("plan id").build(); + + @Test + void getServicePlanId() { + Assertions.assertThat(value.getServicePlanId()).isEqualTo("plan id"); + } + + @Test + void getCampaignId() { + Assertions.assertThat(value.getCampaignId()).isEqualTo(Optional.of("campaign id")); + } + + @Test + void geCampaignIdEmpty() { + Assertions.assertThat(valueNoCampaign.getCampaignId()).isEqualTo(Optional.empty()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersTest.java new file mode 100644 index 00000000..fb1c1a1b --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParametersTest.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import java.util.Optional; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RentSMSConfigurationRequestParametersTest { + RentSMSConfigurationRequestParameters value = + new RentSMSConfigurationRequestParameters("plan id", "campaign id"); + + RentSMSConfigurationRequestParameters valueNoCampaign = + new RentSMSConfigurationRequestParameters("plan id"); + + @Test + void getServicePlanId() { + Assertions.assertThat(value.getServicePlanId()).isEqualTo("plan id"); + } + + @Test + void getCampaignId() { + Assertions.assertThat(value.getCampaignId()).isEqualTo(Optional.of("campaign id")); + } + + @Test + void geCampaignIdEmpty() { + Assertions.assertThat(valueNoCampaign.getCampaignId()).isEqualTo(Optional.empty()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersBuilderTest.java new file mode 100644 index 00000000..dca37cbd --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersBuilderTest.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RentVoiceConfigurationRequestParametersBuilderTest { + + RentVoiceConfigurationRequestParameters value = + RentVoiceConfigurationRequestParameters.builder().setAppId("app id").build(); + + @Test + void getAppId() { + Assertions.assertThat(value.getAppId()).isEqualTo("app id"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersTest.java new file mode 100644 index 00000000..73205ac0 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParametersTest.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.domains.numbers.models.requests; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class RentVoiceConfigurationRequestParametersTest { + + RentVoiceConfigurationRequestParameters value = + new RentVoiceConfigurationRequestParameters("app id"); + + @Test + void getAppId() { + Assertions.assertThat(value.getAppId()).isEqualTo("app id"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponseTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponseTest.java new file mode 100644 index 00000000..e1525191 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponseTest.java @@ -0,0 +1,153 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.core.models.pagination.PageToken; +import com.sinch.sdk.domains.numbers.ActiveNumberService; +import com.sinch.sdk.domains.numbers.models.*; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParametersTest; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +class ActiveNumberListResponseTest extends BaseTest { + @Mock ActiveNumberService service; + + List list = + Stream.generate( + () -> + ActiveNumber.builder() + .setPhoneNumber(String.valueOf(Math.random())) + .setProjectId(String.valueOf(Math.random())) + .setDisplayName(String.valueOf(Math.random())) + .setRegionCode(String.valueOf(Math.random())) + .setType(NumberType.from(String.valueOf(Math.random()))) + .setCapability(Arrays.asList(Capability.VOICE, Capability.SMS)) + .setMoney(new Money(String.valueOf(Math.random()), Math.random())) + .setPaymentIntervalMonths((int) (Math.random() * 12)) + .setNextChargeDate( + Instant.ofEpochMilli(ThreadLocalRandom.current().nextLong())) + .setExpireAt(Instant.ofEpochMilli(ThreadLocalRandom.current().nextLong())) + .setSmsConfiguration( + new SMSConfiguration( + String.valueOf(Math.random()), + String.valueOf(Math.random()), + new ScheduledSmsProvisioning( + String.valueOf(Math.random()), + String.valueOf(Math.random()), + ProvisioningStatus.FAILED, + Instant.ofEpochMilli(ThreadLocalRandom.current().nextLong()), + Collections.singletonList(SmsErrorCode.ERROR_CODE_UNSPECIFIED)))) + .setVoiceConfiguration( + new VoiceConfiguration( + String.valueOf(Math.random()), + Instant.ofEpochMilli(ThreadLocalRandom.current().nextLong()), + new ScheduledVoiceProvisioning( + String.valueOf(Math.random()), + ProvisioningStatus.IN_PROGRESS, + Instant.ofEpochMilli(ThreadLocalRandom.current().nextLong())))) + .setCallbackUrl(String.valueOf(Math.random())) + .build()) + .limit(13) + .collect(Collectors.toList()); + + List> pages = + Arrays.asList( + new Page<>( + ActiveNumberListRequestParametersTest.value, + list.stream().limit(5).collect(Collectors.toList()), + new PageToken<>("foo page2")), + new Page<>( + ActiveNumberListRequestParametersTest.value, + list.stream().skip(5).limit(5).collect(Collectors.toList()), + new PageToken<>("foo page3")), + new Page<>( + ActiveNumberListRequestParametersTest.value, + list.stream().skip(10).collect(Collectors.toList()), + null)); + + @Test + void autoPageIter() { + setupMockedService(); + AtomicInteger count = new AtomicInteger(); + ActiveNumberListResponse response = new ActiveNumberListResponse(service, pages.get(0)); + response + .autoPageIter() + .forEachRemaining( + value -> { + Assertions.assertThat(value) + .usingRecursiveComparison() + .isEqualTo(list.get(count.get())); + count.getAndIncrement(); + }); + assertEquals(count.get(), list.size()); + } + + @Test + void hasNextPage() { + + ActiveNumberListResponse response = new ActiveNumberListResponse(service, pages.get(0)); + assertTrue(response.hasNextPage()); + response = new ActiveNumberListResponse(service, pages.get(1)); + assertTrue(response.hasNextPage()); + response = new ActiveNumberListResponse(service, pages.get(2)); + assertFalse(response.hasNextPage()); + } + + @Test + void nextPage() { + + setupMockedService(); + ActiveNumberListResponse response = new ActiveNumberListResponse(service, pages.get(0)); + int page = 1; + while (response.hasNextPage()) { + response = response.nextPage(); + Assertions.assertThat(response.getContent()) + .usingRecursiveComparison() + .isEqualTo(pages.get(page).getEntities()); + page++; + } + assertThrows(NoSuchElementException.class, response::nextPage); + } + + @Test + void getContent() { + + for (Page page : pages) { + ActiveNumberListResponse response = new ActiveNumberListResponse(service, page); + Assertions.assertThat(response.getContent()) + .usingRecursiveComparison() + .isEqualTo(page.getEntities()); + } + } + + void setupMockedService() { + when(service.list(any(ActiveNumberListRequestParameters.class))) + .thenAnswer( + invocation -> { + ActiveNumberListRequestParameters parameters = + invocation.getArgument(0, ActiveNumberListRequestParameters.class); + switch (parameters.getPageToken().get()) { + case "foo page2": + return new ActiveNumberListResponse(service, pages.get(1)); + case "foo page3": + return new ActiveNumberListResponse(service, pages.get(2)); + } + return null; + }); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponseTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponseTest.java new file mode 100644 index 00000000..40baa359 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponseTest.java @@ -0,0 +1,69 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import static java.lang.String.valueOf; +import static org.junit.jupiter.api.Assertions.*; + +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.Money; +import com.sinch.sdk.domains.numbers.models.NumberType; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableNumberListResponseTest { + + List list = + Stream.generate( + () -> + AvailableNumber.builder() + .setPhoneNumber(valueOf(Math.random())) + .setRegionCode(valueOf(Math.random())) + .setType(NumberType.LOCAL) + .setCapability(Collections.singletonList(Capability.VOICE)) + .setSetupPrice(new Money(valueOf(Math.random()), Math.random() * 100)) + .setMonthlyPrice(new Money(valueOf(Math.random()), Math.random() * 100)) + .setPaymentIntervalMonths((int) (Math.random() * 12)) + .setSupportingDocumentationRequired(true) + .build()) + .limit(15) + .collect(Collectors.toList()); + + AvailableNumberListResponse response = new AvailableNumberListResponse(new ArrayList<>(list)); + + @Test + void autoPageIter() { + AtomicInteger count = new AtomicInteger(); + response + .autoPageIter() + .forEachRemaining( + value -> { + Assertions.assertThat(value) + .usingRecursiveComparison() + .isEqualTo(list.get(count.get())); + count.getAndIncrement(); + }); + assertEquals(count.get(), list.size()); + } + + @Test + void hasNextPage() { + assertFalse(response.hasNextPage(), "Has no next page"); + } + + @Test + void nextPage() { + assertThrows(NoSuchElementException.class, response::nextPage); + } + + @Test + void getContent() { + Assertions.assertThat(response.getContent()).usingRecursiveComparison().isEqualTo(list); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponseTest.java b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponseTest.java new file mode 100644 index 00000000..ff4e04b7 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponseTest.java @@ -0,0 +1,61 @@ +package com.sinch.sdk.domains.numbers.models.responses; + +import static org.junit.jupiter.api.Assertions.*; + +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.Region; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class AvailableRegionListResponseTest { + + List list = + Stream.generate( + () -> + Region.builder() + .setRegionCode(String.valueOf(Math.random())) + .setRegionName(String.valueOf(Math.random())) + .setTypes(Collections.singletonList(NumberType.TOLL_FREE)) + .build()) + .limit(15) + .collect(Collectors.toList()); + + AvailableRegionListResponse response = new AvailableRegionListResponse(new ArrayList<>(list)); + + @Test + void autoPageIter() { + AtomicInteger count = new AtomicInteger(); + response + .autoPageIter() + .forEachRemaining( + value -> { + Assertions.assertThat(value) + .usingRecursiveComparison() + .isEqualTo(list.get(count.get())); + count.getAndIncrement(); + }); + assertEquals(count.get(), list.size()); + } + + @Test + void hasNextPage() { + assertFalse(response.hasNextPage(), "Has no next page"); + } + + @Test + void nextPage() { + assertThrows(NoSuchElementException.class, response::nextPage); + } + + @Test + void getContent() { + Assertions.assertThat(response.getContent()).usingRecursiveComparison().isEqualTo(list); + } +} 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 new file mode 100644 index 00000000..4a9ed4e0 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/BatchesServiceTest.java @@ -0,0 +1,169 @@ +package com.sinch.sdk.domains.sms.adapters; + +import static org.mockito.ArgumentMatchers.eq; +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.exceptions.ApiException; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.sms.adapters.api.v1.BatchesApi; +import com.sinch.sdk.domains.sms.models.*; +import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjDto; +import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjParameterKeyDto; +import com.sinch.sdk.domains.sms.models.dto.v1.SendSMS201ResponseDto; +import com.sinch.sdk.models.Configuration; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +public class BatchesServiceTest extends BaseTest { + + final String id = "01FC66621XXXXX119Z8PMV1QPQ"; + final Collection to = Arrays.asList("+15551231234", "+15551256344"); + final String from = "+15551231234"; + final boolean canceled = false; + final Instant createdAt = Instant.parse("2019-08-24T14:15:22Z"); + final Instant modifiedAt = Instant.parse("2019-08-24T14:17:22Z"); + final DeliveryReport deliveryReport = DeliveryReport.NONE; + final Instant sendAt = Instant.parse("2019-08-24T14:19:22Z"); + final Instant expireAt = Instant.parse("2019-08-24T14:21:22Z"); + final String callbackUrl = "callback url"; + final String clientReference = "myReference"; + final boolean flashMessage = true; + final boolean feedbackEnabled = false; + final boolean truncateConcat = true; + final int maxNumberOfMessageParts = 1; + final int fromTon = 6; + final int fromNpi = 18; + final String udh = "foo udh"; + final String body = "Hi ${name}! How are you?"; + public final BatchBinary batchBinary = + BatchBinary.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) + .setUdh(udh) + .build(); + final Parameters parameters = + new Parameters( + Arrays.asList( + new Parameters.Entry("an identifier", new Pair<>("a key", "a value")), + new Parameters.Entry( + ParameterObjDto + .JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET, + new Pair<>( + ParameterObjParameterKeyDto + .JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET, + "msisdn value"), + "default value"))); + public final BatchMedia batchMedia = + BatchMedia.builder() + .setId(id) + .setTo(to) + .setFrom(from) + .setCanceled(canceled) + .setBody( + new MediaBody( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png", + "Media message from Sinch!")) + .setCreatedAt(Instant.parse("2019-08-24T14:14:22Z")) + .setModifiedAt(Instant.parse("2019-08-24T14:15:22Z")) + .setDeliveryReport(DeliveryReport.SUMMARY) + .setSendAt(Instant.parse("2019-08-24T14:16:22Z")) + .setExpireAt(Instant.parse("2019-08-24T14:17:22Z")) + .setCallbackUrl(callbackUrl) + .setClientReference("client reference") + .setFeedbackEnabled(feedbackEnabled) + .setParameters(parameters) + .build(); + public final BatchText batchText = + BatchText.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(); + + @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + public SendSMS201ResponseDto binaryResponseDto; + + @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + SendSMS201ResponseDto mediaResponseDto; + + @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + SendSMS201ResponseDto textResponseDto; + + @Mock Configuration configuration; + @Mock BatchesApi api; + @InjectMocks BatchesService service; + + @Test + void getBinary() throws ApiException { + + when(api.getBatchMessage(eq(configuration.getProjectId()), eq("foo binary batch id"))) + .thenReturn(binaryResponseDto); + + Batch response = service.get("foo binary batch id"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(batchBinary); + } + + @Test + void getMedia() throws ApiException { + + when(api.getBatchMessage(eq(configuration.getProjectId()), eq("foo media batch id"))) + .thenReturn(mediaResponseDto); + + Batch response = service.get("foo media batch id"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(batchMedia); + } + + @Test + void getText() throws ApiException { + + when(api.getBatchMessage(eq(configuration.getProjectId()), eq("foo text batch id"))) + .thenReturn(textResponseDto); + + Batch response = service.get("foo text batch id"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(batchText); + } +} 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 new file mode 100644 index 00000000..ded49e62 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverterTest.java @@ -0,0 +1,145 @@ +package com.sinch.sdk.domains.sms.adapters.converters; + +import static org.junit.jupiter.api.Assertions.*; + +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.utils.Pair; +import com.sinch.sdk.domains.sms.models.*; +import com.sinch.sdk.domains.sms.models.dto.v1.*; +import java.util.Collection; +import java.util.Map; +import java.util.Optional; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +class BatchDtoConverterTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + public SendSMS201ResponseDto binaryResponseDto; + + @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + public SendSMS201ResponseDto textResponseDto; + + @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + public SendSMS201ResponseDto mediaResponseDto; + + public static void compareWithDto(Batch client, SendSMS201ResponseDto dto) { + Object obj = dto.getActualInstance(); + if (obj instanceof BinaryResponseDto) { + assertInstanceOf(BatchBinary.class, client); + compareBinary((BatchBinary) client, dto.getBinaryResponseDto()); + } else if (obj instanceof MediaResponseDto) { + assertInstanceOf(BatchMedia.class, client); + compareMedia((BatchMedia) client, dto.getMediaResponseDto()); + } else if (obj instanceof TextResponseDto) { + assertInstanceOf(BatchText.class, client); + compareText((BatchText) client, dto.getTextResponseDto()); + } else { + fail("Unexpected class:" + obj.getClass().getName()); + } + } + + private static void compareBinary(BatchBinary client, BinaryResponseDto dto) { + assertEquals(dto.getId(), client.getId()); + assertEquals(dto.getTo(), client.getTo()); + assertEquals(dto.getFrom(), client.getFrom()); + assertEquals(dto.getCanceled(), client.isCanceled()); + assertEquals(dto.getBody(), client.getBody()); + assertEquals(dto.getUdh(), client.getUdh()); + assertEquals(dto.getType(), BinaryResponseDto.TypeEnum.MT_BINARY.getValue()); + assertEquals(dto.getCreatedAt().toInstant(), client.getCreatedAt()); + assertEquals(dto.getModifiedAt().toInstant(), client.getModifiedAt()); + Assertions.assertEquals(dto.getDeliveryReport(), client.getDeliveryReport().value()); + assertEquals(dto.getSendAt().toInstant(), client.getSendAt()); + assertEquals(dto.getExpireAt().toInstant(), client.getExpireAt()); + assertEquals(dto.getCallbackUrl(), client.getCallbackUrl()); + assertEquals(dto.getClientReference(), client.getClientReference()); + assertEquals(dto.getFeedbackEnabled(), client.isFeedbackEnabled()); + assertEquals(dto.getFlashMessage(), client.isFlashMessage()); + assertEquals(dto.getTruncateConcat(), client.isTruncateConcat()); + assertEquals(dto.getMaxNumberOfMessageParts(), client.getMaxNumberOfMessageParts()); + assertEquals(dto.getFromTon(), client.getFromTon()); + assertEquals(dto.getFromNpi(), client.getFromNpi()); + } + + private static void compareMedia(BatchMedia client, MediaResponseDto dto) { + assertEquals(dto.getId(), client.getId()); + assertEquals(dto.getTo(), client.getTo()); + assertEquals(dto.getFrom(), client.getFrom()); + assertEquals(dto.getCanceled(), client.isCanceled()); + assertEquals(dto.getBody().getMessage(), client.getBody().getMessage()); + assertEquals(dto.getBody().getUrl(), client.getBody().getUrl()); + assertEquals(dto.getType(), MediaResponseDto.TypeEnum.MT_MEDIA.getValue()); + assertEquals(dto.getCreatedAt().toInstant(), client.getCreatedAt()); + assertEquals(dto.getModifiedAt().toInstant(), client.getModifiedAt()); + Assertions.assertEquals(dto.getDeliveryReport(), client.getDeliveryReport().value()); + assertEquals(dto.getSendAt().toInstant(), client.getSendAt()); + assertEquals(dto.getExpireAt().toInstant(), client.getExpireAt()); + compareParameters(client.getParameters(), dto.getParameters()); + assertEquals(dto.getCallbackUrl(), client.getCallbackUrl()); + assertEquals(dto.getClientReference(), client.getClientReference()); + assertEquals(dto.getFeedbackEnabled(), client.isFeedbackEnabled()); + } + + private static void compareText(BatchText client, TextResponseDto dto) { + assertEquals(dto.getId(), client.getId()); + assertEquals(dto.getTo(), client.getTo()); + assertEquals(dto.getFrom(), client.getFrom()); + assertEquals(dto.getCanceled(), client.isCanceled()); + assertEquals(dto.getBody(), client.getBody()); + assertEquals(dto.getType(), TextResponseDto.TypeEnum.MT_TEXT.getValue()); + assertEquals(dto.getCreatedAt().toInstant(), client.getCreatedAt()); + assertEquals(dto.getModifiedAt().toInstant(), client.getModifiedAt()); + Assertions.assertEquals(dto.getDeliveryReport(), client.getDeliveryReport().value()); + assertEquals(dto.getSendAt().toInstant(), client.getSendAt()); + assertEquals(dto.getExpireAt().toInstant(), client.getExpireAt()); + assertEquals(dto.getCallbackUrl(), client.getCallbackUrl()); + assertEquals(dto.getClientReference(), client.getClientReference()); + assertEquals(dto.getFeedbackEnabled(), client.isFeedbackEnabled()); + assertEquals(dto.getFlashMessage(), client.isFlashMessage()); + assertEquals(dto.getTruncateConcat(), client.isTruncateConcat()); + compareParameters(client.getParameters(), dto.getParameters()); + assertEquals(dto.getMaxNumberOfMessageParts(), client.getMaxNumberOfMessageParts()); + assertEquals(dto.getFromTon(), client.getFromTon()); + assertEquals(dto.getFromNpi(), client.getFromNpi()); + } + + private static void compareParameters(Parameters client, ParameterObjDto dto) { + assertEquals(dto.size(), client.size()); + Collection values = client.values(); + values.forEach( + e -> { + Pair clientItem = e.getValue(); + assertTrue(dto.containsKey(e.getKey())); + @SuppressWarnings("unchecked") + Map dtoItem = (Map) dto.get(e.getKey()); + assertTrue(dtoItem.containsKey(clientItem.getLeft())); + assertEquals(dtoItem.get(clientItem.getLeft()), clientItem.getRight()); + Optional defaultValue = e.getDefaultValue(); + if (defaultValue.isPresent()) { + assertEquals( + dtoItem.get(ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT), defaultValue.get()); + } else { + assertNull(dtoItem.get(ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT)); + } + }); + } + + @Test + void convertBinary() { + compareWithDto(BatchDtoConverter.convert(binaryResponseDto), binaryResponseDto); + } + + @Test + void convertMedia() { + compareWithDto(BatchDtoConverter.convert(mediaResponseDto), mediaResponseDto); + } + + @Test + void convertText() { + compareWithDto(BatchDtoConverter.convert(textResponseDto), textResponseDto); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryBuilderTest.java new file mode 100644 index 00000000..4ad146da --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryBuilderTest.java @@ -0,0 +1,143 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchBinaryBuilderTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean feedbackEnabled = false; + final boolean truncateConcat = true; + final int maxNumberOfMessageParts = 23; + final int fromTon = 1234; + final int fromNpi = 567; + final String udh = "udh value"; + final String body = "body content"; + final BatchBinary value = + BatchBinary.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) + .setTruncateConcat(truncateConcat) + .setMaxNumberOfMessageParts(maxNumberOfMessageParts) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setUdh(udh) + .build(); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isTruncateConcat() { + Assertions.assertThat(value.isTruncateConcat()).isEqualTo(truncateConcat); + } + + @Test + void getMaxNumberOfMessageParts() { + Assertions.assertThat(value.getMaxNumberOfMessageParts()).isEqualTo(maxNumberOfMessageParts); + } + + @Test + void getFromTon() { + Assertions.assertThat(value.getFromTon()).isEqualTo(fromTon); + } + + @Test + void getFromNpi() { + Assertions.assertThat(value.getFromNpi()).isEqualTo(fromNpi); + } + + @Test + void getUdh() { + Assertions.assertThat(value.getUdh()).isEqualTo(udh); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryTest.java new file mode 100644 index 00000000..2f782047 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBinaryTest.java @@ -0,0 +1,144 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchBinaryTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean flashMessage = true; + final boolean feedbackEnabled = false; + final boolean truncateConcat = true; + final int maxNumberOfMessageParts = 23; + final int fromTon = 1234; + final int fromNpi = 567; + final String udh = "udh value"; + final String body = "body content"; + final BatchBinary value = + new BatchBinary( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi, + udh); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isTruncateConcat() { + Assertions.assertThat(value.isTruncateConcat()).isEqualTo(truncateConcat); + } + + @Test + void getMaxNumberOfMessageParts() { + Assertions.assertThat(value.getMaxNumberOfMessageParts()).isEqualTo(maxNumberOfMessageParts); + } + + @Test + void getFromTon() { + Assertions.assertThat(value.getFromTon()).isEqualTo(fromTon); + } + + @Test + void getFromNpi() { + Assertions.assertThat(value.getFromNpi()).isEqualTo(fromNpi); + } + + @Test + void getUdh() { + Assertions.assertThat(value.getUdh()).isEqualTo(udh); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBuilderTest.java new file mode 100644 index 00000000..5a8927c9 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchBuilderTest.java @@ -0,0 +1,118 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchBuilderTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + + final Integer body = -45; + + final Instant createdAt = Instant.now(); + + final Instant modifiedAt = Instant.now(); + + final DeliveryReport deliveryReport = DeliveryReport.FULL; + + final Instant sendAt = Instant.now(); + + final Instant expireAt = Instant.now(); + + final String callbackUrl = "callback value"; + + final String clientReference = " client reference"; + + final boolean feedbackEnabled = false; + + final Batch value = + Batch.batchBuilder() + .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) + .build(); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaBuilderTest.java new file mode 100644 index 00000000..a7692241 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaBuilderTest.java @@ -0,0 +1,124 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchMediaBuilderTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Parameters parameters = null; + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean feedbackEnabled = false; + + final MediaBody body = new MediaBody("body message", "url value"); + final boolean strictValidation = true; + + final BatchMedia value = + BatchMedia.builder() + .setId(id) + .setTo(to) + .setFrom(from) + .setCanceled(canceled) + .setBody(body) + .setParameters(parameters) + .setCreatedAt(createdAt) + .setModifiedAt(modifiedAt) + .setDeliveryReport(deliveryReport) + .setSendAt(sendAt) + .setExpireAt(expireAt) + .setCallbackUrl(callbackUrl) + .setClientReference(clientReference) + .setFeedbackEnabled(feedbackEnabled) + .setStrictValidation(strictValidation) + .build(); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getParameters() { + Assertions.assertThat(value.getParameters()).isEqualTo(parameters); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isStrictValidation() { + Assertions.assertThat(value.isStrictValidation()).isEqualTo(strictValidation); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaTest.java new file mode 100644 index 00000000..2d11b321 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchMediaTest.java @@ -0,0 +1,126 @@ +package com.sinch.sdk.domains.sms.models; + +import com.sinch.sdk.core.utils.Pair; +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchMediaTest { + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Parameters parameters = + new Parameters( + Arrays.asList( + new Parameters.Entry("key 1", new Pair<>("value identifier1", "value 1")), + new Parameters.Entry( + "key 2", new Pair<>("value identifier2", "value 2"), "default value for "))); + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean feedbackEnabled = false; + final MediaBody body = new MediaBody("url value", "body message"); + final boolean strictValidation = true; + final BatchMedia value = + new BatchMedia( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + parameters, + strictValidation); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getParameters() { + Assertions.assertThat(value.getParameters()).usingRecursiveComparison().isEqualTo(parameters); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isStrictValidation() { + Assertions.assertThat(value.isStrictValidation()).isEqualTo(strictValidation); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTest.java new file mode 100644 index 00000000..5cd68c60 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTest.java @@ -0,0 +1,117 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + + final Integer body = -45; + + final Instant createdAt = Instant.now(); + + final Instant modifiedAt = Instant.now(); + + final DeliveryReport deliveryReport = DeliveryReport.FULL; + + final Instant sendAt = Instant.now(); + + final Instant expireAt = Instant.now(); + + final String callbackUrl = "callback value"; + + final String clientReference = " client reference"; + + final boolean feedbackEnabled = false; + + final Batch value = + new Batch<>( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextBuilderTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextBuilderTest.java new file mode 100644 index 00000000..2d5ff3fa --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextBuilderTest.java @@ -0,0 +1,143 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchTextBuilderTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Parameters parameters = null; + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean feedbackEnabled = false; + final boolean truncateConcat = true; + final int maxNumberOfMessageParts = 23; + final int fromTon = 1234; + final int fromNpi = 567; + final String body = "body content"; + final BatchText value = + BatchText.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) + .setTruncateConcat(truncateConcat) + .setMaxNumberOfMessageParts(maxNumberOfMessageParts) + .setFromTon(fromTon) + .setFromNpi(fromNpi) + .setParameters(parameters) + .build(); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getParameters() { + Assertions.assertThat(value.getParameters()).isEqualTo(parameters); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isTruncateConcat() { + Assertions.assertThat(value.isTruncateConcat()).isEqualTo(truncateConcat); + } + + @Test + void getMaxNumberOfMessageParts() { + Assertions.assertThat(value.getMaxNumberOfMessageParts()).isEqualTo(maxNumberOfMessageParts); + } + + @Test + void getFromTon() { + Assertions.assertThat(value.getFromTon()).isEqualTo(fromTon); + } + + @Test + void getFromNpi() { + Assertions.assertThat(value.getFromNpi()).isEqualTo(fromNpi); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextTest.java new file mode 100644 index 00000000..89847d15 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/BatchTextTest.java @@ -0,0 +1,144 @@ +package com.sinch.sdk.domains.sms.models; + +import java.time.Instant; +import java.util.Arrays; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class BatchTextTest { + + final String id = "an id"; + + final Collection to = Arrays.asList("to1", "to2"); + + final String from = "from value"; + + final boolean canceled = true; + final Parameters parameters = null; + final Instant createdAt = Instant.now(); + final Instant modifiedAt = Instant.now(); + final DeliveryReport deliveryReport = DeliveryReport.FULL; + final Instant sendAt = Instant.now(); + final Instant expireAt = Instant.now(); + final String callbackUrl = "callback value"; + final String clientReference = " client reference"; + final boolean flashMessage = true; + final boolean feedbackEnabled = false; + final boolean truncateConcat = true; + final int maxNumberOfMessageParts = 23; + final int fromTon = 1234; + final int fromNpi = 567; + final String body = "body content"; + final BatchText value = + new BatchText( + id, + to, + from, + canceled, + body, + createdAt, + modifiedAt, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + flashMessage, + feedbackEnabled, + parameters, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + + @Test + void getId() { + Assertions.assertThat(value.getId()).isEqualTo(id); + } + + @Test + void getTo() { + Assertions.assertThat(value.getTo()).usingRecursiveComparison().isEqualTo(to); + } + + @Test + void getFrom() { + Assertions.assertThat(value.getFrom()).isEqualTo(from); + } + + @Test + void isCanceled() { + Assertions.assertThat(value.isCanceled()).isEqualTo(canceled); + } + + @Test + void getBody() { + Assertions.assertThat(value.getBody()).isEqualTo(body); + } + + @Test + void getParameters() { + Assertions.assertThat(value.getParameters()).isEqualTo(parameters); + } + + @Test + void getExpireAt() { + Assertions.assertThat(value.getExpireAt()).isEqualTo(expireAt); + } + + @Test + void getCreatedAt() { + Assertions.assertThat(value.getCreatedAt()).isEqualTo(createdAt); + } + + @Test + void getModifiedAt() { + Assertions.assertThat(value.getModifiedAt()).isEqualTo(modifiedAt); + } + + @Test + void getDeliveryReport() { + Assertions.assertThat(value.getDeliveryReport()).isEqualTo(deliveryReport); + } + + @Test + void getSendAt() { + Assertions.assertThat(value.getSendAt()).isEqualTo(sendAt); + } + + @Test + void getCallbackUrl() { + Assertions.assertThat(value.getCallbackUrl()).isEqualTo(callbackUrl); + } + + @Test + void getClientReference() { + Assertions.assertThat(value.getClientReference()).isEqualTo(clientReference); + } + + @Test + void isFeedbackEnabled() { + Assertions.assertThat(value.isFeedbackEnabled()).isEqualTo(feedbackEnabled); + } + + @Test + void isTruncateConcat() { + Assertions.assertThat(value.isTruncateConcat()).isEqualTo(truncateConcat); + } + + @Test + void getMaxNumberOfMessageParts() { + Assertions.assertThat(value.getMaxNumberOfMessageParts()).isEqualTo(maxNumberOfMessageParts); + } + + @Test + void getFromTon() { + Assertions.assertThat(value.getFromTon()).isEqualTo(fromTon); + } + + @Test + void getFromNpi() { + Assertions.assertThat(value.getFromNpi()).isEqualTo(fromNpi); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/MediaBodyTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/MediaBodyTest.java new file mode 100644 index 00000000..bf1a3cd3 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/MediaBodyTest.java @@ -0,0 +1,19 @@ +package com.sinch.sdk.domains.sms.models; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class MediaBodyTest { + + final MediaBody value = new MediaBody("the url", "the message"); + + @Test + void getMessage() { + Assertions.assertThat(value.getMessage()).isEqualTo("the message"); + } + + @Test + void getUrl() { + Assertions.assertThat(value.getUrl()).isEqualTo("the url"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/sms/models/ParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/sms/models/ParametersTest.java new file mode 100644 index 00000000..638607f5 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/sms/models/ParametersTest.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.domains.sms.models; + +import com.sinch.sdk.core.utils.Pair; +import java.util.Arrays; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class ParametersTest { + final Parameters parameters = + new Parameters( + Arrays.asList( + new Parameters.Entry("key 1", new Pair<>("value identifier1", "value 1")), + new Parameters.Entry( + "key 2", new Pair<>("value identifier2", "value 2"), "default value for "))); + + @Test + void getParameters() { + Assertions.assertThat(parameters.get("key 1")) + .usingRecursiveComparison() + .isEqualTo(new Parameters.Entry("key 1", new Pair<>("value identifier1", "value 1"))); + + Assertions.assertThat(parameters.get("key 2")) + .usingRecursiveComparison() + .isEqualTo( + new Parameters.Entry( + "key 2", new Pair<>("value identifier2", "value 2"), "default value for ")); + } +} diff --git a/client/src/test/java/com/sinch/sdk/models/ConfigurationBuilderTest.java b/client/src/test/java/com/sinch/sdk/models/ConfigurationBuilderTest.java new file mode 100644 index 00000000..345f6750 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/models/ConfigurationBuilderTest.java @@ -0,0 +1,41 @@ +package com.sinch.sdk.models; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class ConfigurationBuilderTest { + static final String KEY = "fooKey"; + static final String SECRET = "fooSecret"; + static final String PROJECT = "fooProject"; + static final String OAUTH_URL = "foo oauth url"; + static final String NUMBERS_SERVER = "fooNUMBERS_SERVER"; + static final SMSRegion SMS_REGION = SMSRegion.AU; + static final String SMS_SERVER = "%sfooSMS_SERVER"; + + @Test + void build() { + Configuration value = + new Configuration.Builder() + .setKeyId(KEY) + .setKeySecret(SECRET) + .setProjectId(PROJECT) + .setOAuthUrl(OAUTH_URL) + .setNumbersUrl(NUMBERS_SERVER) + .setSmsRegion(SMS_REGION) + .setSmsUrl(SMS_SERVER) + .build(); + assertEquals(KEY, value.getKeyId()); + assertEquals(SECRET, value.getKeySecret()); + assertEquals(PROJECT, value.getProjectId()); + Assertions.assertEquals(OAUTH_URL, value.getOAuthServer().getUrl()); + Assertions.assertEquals(NUMBERS_SERVER, value.getNumbersServer().getUrl()); + Assertions.assertTrue( + value.getSmsServer().getUrl().contains(SMS_REGION.value()), + "SMS Region present within SMS server URL"); + Assertions.assertTrue( + value.getSmsServer().getUrl().contains("fooSMS_SERVER"), + "SMS server present within SMS server URL"); + } +} diff --git a/client/src/test/java/com/sinch/sdk/models/ConfigurationTest.java b/client/src/test/java/com/sinch/sdk/models/ConfigurationTest.java new file mode 100644 index 00000000..aa3ee650 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/models/ConfigurationTest.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.models; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class ConfigurationTest { + static final String KEY = "fooKey"; + static final String SECRET = "fooSecret"; + static final String PROJECT = "fooProject"; + static final String OAUTH_URL = "foo oauth url"; + static final String NUMBERS_SERVER = "fooNUMBERS_SERVER"; + static final SMSRegion SMS_REGION = SMSRegion.AU; + static final String SMS_SERVER = "%sfooSMS_SERVER"; + + static final Configuration configuration = + new Configuration.Builder() + .setKeyId(KEY) + .setKeySecret(SECRET) + .setProjectId(PROJECT) + .setOAuthUrl(OAUTH_URL) + .setNumbersUrl(NUMBERS_SERVER) + .setSmsRegion(SMS_REGION) + .setSmsUrl(SMS_SERVER) + .build(); + + @Test + void testToString() { + String value = configuration.toString(); + assertFalse(value.contains(KEY), "Config should not contains 'key' value"); + assertFalse(value.contains(SECRET), "Config should not contains 'secret' value"); + assertFalse(value.contains(PROJECT), "Config should not contains 'project' value"); + } + + @Test + void getKeyId() { + assertEquals(KEY, configuration.getKeyId()); + } + + @Test + void getKeySecret() { + assertEquals(SECRET, configuration.getKeySecret()); + } + + @Test + void getProjectId() { + assertEquals(PROJECT, configuration.getProjectId()); + } + + @Test + void defaultUSForSmSRegion() { + Configuration configuration = + new Configuration.Builder() + .setKeyId(KEY) + .setKeySecret(SECRET) + .setProjectId(PROJECT) + .setOAuthUrl(OAUTH_URL) + .setNumbersUrl(NUMBERS_SERVER) + .setSmsUrl(SMS_SERVER) + .build(); + assertEquals(configuration.getSmsRegion(), SMSRegion.US); + } +} diff --git a/client/src/test/resources/client/auth/BearerAuthResponse.json b/client/src/test/resources/client/auth/BearerAuthResponse.json new file mode 100644 index 00000000..2b4acac1 --- /dev/null +++ b/client/src/test/resources/client/auth/BearerAuthResponse.json @@ -0,0 +1,6 @@ +{ + "access_token": "token value", + "expires_in": 123456, + "scope": "scope value", + "token_type": "token type value" +} diff --git a/core/src/main/com/sinch/sdk/core/exceptions/ApiAuthException.java b/core/src/main/com/sinch/sdk/core/exceptions/ApiAuthException.java new file mode 100644 index 00000000..7f202431 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/exceptions/ApiAuthException.java @@ -0,0 +1,20 @@ +package com.sinch.sdk.core.exceptions; + +import com.sinch.sdk.core.http.HttpStatus; + +public class ApiAuthException extends ApiException { + + private static final long serialVersionUID = -1L; + + public ApiAuthException(Throwable throwable) { + super(null, throwable, HttpStatus.UNAUTHORIZED); + } + + public ApiAuthException(String message) { + super(message, null, HttpStatus.UNAUTHORIZED); + } + + public ApiAuthException(int code, String message) { + super(message, null, code); + } +} diff --git a/core/src/main/com/sinch/sdk/core/exceptions/ApiException.java b/core/src/main/com/sinch/sdk/core/exceptions/ApiException.java new file mode 100644 index 00000000..d7b31989 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/exceptions/ApiException.java @@ -0,0 +1,44 @@ +package com.sinch.sdk.core.exceptions; + +public class ApiException extends RuntimeException { + + private static final long serialVersionUID = -1L; + private int code = 0; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code) { + super(message, throwable); + this.code = code; + } + + public ApiException(String message, int code) { + this(message, null, code); + } + + public ApiException(int code, String message) { + this(message, null, code); + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + @Override + public String toString() { + return "ApiException{" + "code=" + code + ", message=" + super.getMessage(); + } +} diff --git a/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java b/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java new file mode 100644 index 00000000..8f5ecccf --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.core.exceptions; + +import java.util.Map; +import java.util.Optional; + +public class ApiExceptionBuilder { + + public static ApiException build(String message, int code) { + return new ApiException(message, code); + } + + public static ApiException build(String message, int code, Map mappedResponse) { + + // Hardcoded Numbers API errors like format parsing + Optional numbersException = getExceptionFromNumbersOrSmsError(mappedResponse); + + return numbersException.orElseGet(() -> new ApiException(message, code)); + } + + private static Optional getExceptionFromNumbersOrSmsError( + Map mappedResponse) { + + if (null == mappedResponse) { + return Optional.empty(); + } + // excepted numbers API errors have following form + // "error": { + // "code": int, + // "message": string, + // "status": string, + // } + + if (null == mappedResponse || !mappedResponse.containsKey("error")) { + return Optional.empty(); + } + Object error = mappedResponse.get("error"); + if ((!(error instanceof Map))) { + return Optional.empty(); + } + + Map errorContent = (Map) error; + + Integer codeValue = null; + if (errorContent.containsKey("code")) { + codeValue = Integer.valueOf(String.valueOf(errorContent.get("code"))); + } + String messageValue = String.valueOf(errorContent.get("message")); + String statusValue = String.valueOf(errorContent.get("status")); + + if (null == codeValue || null == messageValue || null == statusValue) { + return Optional.empty(); + } + + return Optional.of( + new ApiException(String.format("%s: %s", statusValue, messageValue), codeValue)); + } +} diff --git a/core/src/main/com/sinch/sdk/core/exceptions/package-info.java b/core/src/main/com/sinch/sdk/core/exceptions/package-info.java new file mode 100644 index 00000000..af969153 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/exceptions/package-info.java @@ -0,0 +1,6 @@ +/** + * Defined exception related to Sinch API errors + * + * @since 1.0 + */ +package com.sinch.sdk.core.exceptions; diff --git a/core/src/main/com/sinch/sdk/core/http/HttpClient.java b/core/src/main/com/sinch/sdk/core/http/HttpClient.java new file mode 100644 index 00000000..def19014 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpClient.java @@ -0,0 +1,14 @@ +package com.sinch.sdk.core.http; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.models.ServerConfiguration; + +public interface HttpClient extends AutoCloseable { + + boolean isClosed(); + + void close() throws Exception; + + HttpResponse invokeAPI(ServerConfiguration serverConfiguration, HttpRequest request) + throws ApiException; +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpContentType.java b/core/src/main/com/sinch/sdk/core/http/HttpContentType.java new file mode 100644 index 00000000..d8f89155 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpContentType.java @@ -0,0 +1,20 @@ +package com.sinch.sdk.core.http; + +import java.util.Collection; + +public class HttpContentType { + + public static final String CONTENT_TYPE_HEADER = "content-type"; + public static final String APPLICATION_JSON = "application/json"; + public static final String TEXT_PLAIN = "text/plain"; + + public static boolean isMimeJson(Collection mimes) { + String jsonMime = "(?i)^(" + APPLICATION_JSON + "|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mimes.stream() + .anyMatch(mime -> mime != null && (mime.matches(jsonMime) || mime.equals("*/*"))); + } + + public static boolean isMimeTextPlain(Collection mimes) { + return mimes.stream().anyMatch(TEXT_PLAIN::equalsIgnoreCase); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpMapper.java b/core/src/main/com/sinch/sdk/core/http/HttpMapper.java new file mode 100644 index 00000000..4fa8da25 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpMapper.java @@ -0,0 +1,65 @@ +package com.sinch.sdk.core.http; + +import static com.sinch.sdk.core.http.HttpContentType.*; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.utils.databind.Mapper; +import java.io.IOException; +import java.io.InputStream; +import java.util.Collection; + +public class HttpMapper { + + public T deserialize(HttpResponse response, TypeReference valueType) throws ApiException { + if (null == valueType || null == response) { + return null; + } + + try (InputStream stream = response.getContent()) { + if (null == stream) { + return null; + } + + Collection contentType = response.getHeaders().get(CONTENT_TYPE_HEADER); + if (null == contentType || contentType.isEmpty() || isMimeJson(contentType)) { + java.util.Scanner s = new java.util.Scanner(stream).useDelimiter("\\A"); + String content = s.hasNext() ? s.next() : ""; + + if ("".equals(content)) { + return null; + } + return Mapper.getInstance().readValue(content, valueType); + } else if (isMimeTextPlain(contentType)) { + java.util.Scanner s = new java.util.Scanner(stream).useDelimiter("\\A"); + @SuppressWarnings("unchecked") + T t = (T) (s.hasNext() ? s.next() : ""); + return t; + } else { + throw new ApiException( + "Deserialization for content type '" + + contentType + + "' not supported for type '" + + valueType); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + public String serialize(Collection contentTypes, Object body) { + if (null == body) { + return null; + } + if (null == contentTypes || contentTypes.isEmpty() || isMimeJson(contentTypes)) { + try { + return Mapper.getInstance().writeValueAsString(body); + } catch (JsonProcessingException e) { + throw new ApiException(e); + } + } + throw new ApiException( + "Deserialization for content type '" + contentTypes + "' not supported "); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpMethod.java b/core/src/main/com/sinch/sdk/core/http/HttpMethod.java new file mode 100644 index 00000000..f092c090 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpMethod.java @@ -0,0 +1,9 @@ +package com.sinch.sdk.core.http; + +public enum HttpMethod { + GET, + POST, + PATCH, + PUT, + DELETE +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpRequest.java b/core/src/main/com/sinch/sdk/core/http/HttpRequest.java new file mode 100644 index 00000000..ee072887 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpRequest.java @@ -0,0 +1,68 @@ +package com.sinch.sdk.core.http; + +import java.util.Collection; +import java.util.Map; +import java.util.Optional; + +public class HttpRequest { + + private final String path; + private final HttpMethod method; + private final Collection queryParameters; + private final String body; + private final Map headerParams; + private final Collection accept; + private final Collection contentType; + private final Collection authNames; + + public HttpRequest( + String path, + HttpMethod method, + Collection queryParameters, + String body, + Map headerParams, + Collection accept, + Collection contentType, + Collection authNames) { + this.path = path; + this.method = method; + this.queryParameters = queryParameters; + this.body = body; + this.headerParams = headerParams; + this.accept = accept; + this.contentType = contentType; + this.authNames = authNames; + } + + public Optional getPath() { + return Optional.ofNullable(path); + } + + public HttpMethod getMethod() { + return method; + } + + public Collection getQueryParameters() { + return queryParameters; + } + + public String getBody() { + return body; + } + + public Map getHeaderParams() { + return headerParams; + } + + public Collection getAccept() { + return accept; + } + + public Collection getContentType() { + return contentType; + } + + public Collection getAuthNames() { + return authNames; + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpResponse.java b/core/src/main/com/sinch/sdk/core/http/HttpResponse.java new file mode 100644 index 00000000..2f97940f --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpResponse.java @@ -0,0 +1,61 @@ +package com.sinch.sdk.core.http; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class HttpResponse { + + private final int code; + + private final String message; + + private final Map> headers; + + private final byte[] buffer; + + public HttpResponse( + final int code, + final String message, + final Map> headers, + final byte[] buffer) { + this.code = code; + this.message = null != message ? message : ""; + this.headers = (null != headers) ? headers : Collections.emptyMap(); + this.buffer = null != buffer ? buffer : "".getBytes(StandardCharsets.UTF_8); + } + + public int getCode() { + return code; + } + + public String getMessage() { + return message; + } + + public Map> getHeaders() { + return headers; + } + + public InputStream getContent() { + return new ByteArrayInputStream(buffer); + } + + @Override + public String toString() { + return "HttpResponse{" + + "code=" + + code + + ", message='" + + message + + '\'' + + ", headers=" + + headers + + ", buffer=" + + new String(buffer) + + '}'; + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/HttpStatus.java b/core/src/main/com/sinch/sdk/core/http/HttpStatus.java new file mode 100644 index 00000000..56d42d05 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/HttpStatus.java @@ -0,0 +1,12 @@ +package com.sinch.sdk.core.http; + +import java.net.HttpURLConnection; + +public class HttpStatus { + + public static Integer UNAUTHORIZED = HttpURLConnection.HTTP_UNAUTHORIZED; + + public static boolean isSuccessfulStatus(int statusCode) { + return statusCode >= 200 && statusCode < 300; + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/JavaTimeFormatter.java b/core/src/main/com/sinch/sdk/core/http/JavaTimeFormatter.java new file mode 100644 index 00000000..0e30ac80 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/JavaTimeFormatter.java @@ -0,0 +1,56 @@ +package com.sinch.sdk.core.http; + +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; + +/** + * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. It's + * generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code + * java8}. + */ +public class JavaTimeFormatter { + + private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + + /** + * Get the date format used to parse/format {@code OffsetDateTime} parameters. + * + * @return DateTimeFormatter + */ + public DateTimeFormatter getOffsetDateTimeFormatter() { + return offsetDateTimeFormatter; + } + + /** + * Set the date format used to parse/format {@code OffsetDateTime} parameters. + * + * @param offsetDateTimeFormatter {@code DateTimeFormatter} + */ + public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { + this.offsetDateTimeFormatter = offsetDateTimeFormatter; + } + + /** + * Parse the given string into {@code OffsetDateTime} object. + * + * @param str String + * @return {@code OffsetDateTime} + */ + public OffsetDateTime parseOffsetDateTime(String str) { + try { + return OffsetDateTime.parse(str, offsetDateTimeFormatter); + } catch (DateTimeParseException e) { + throw new RuntimeException(e); + } + } + /** + * Format the given {@code OffsetDateTime} object into string. + * + * @param offsetDateTime {@code OffsetDateTime} + * @return {@code OffsetDateTime} in string format + */ + public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { + return offsetDateTimeFormatter.format(offsetDateTime); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/RFC3339DateFormat.java b/core/src/main/com/sinch/sdk/core/http/RFC3339DateFormat.java new file mode 100644 index 00000000..9708840d --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/RFC3339DateFormat.java @@ -0,0 +1,50 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.core.http; + +import com.fasterxml.jackson.databind.util.StdDateFormat; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.ParsePosition; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +public class RFC3339DateFormat extends DateFormat { + private static final long serialVersionUID = 1L; + private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC"); + + private final StdDateFormat fmt = + new StdDateFormat().withTimeZone(TIMEZONE_Z).withColonInTimeZone(true); + + public RFC3339DateFormat() { + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat(); + } + + @Override + public Date parse(String source) { + return parse(source, new ParsePosition(0)); + } + + @Override + public Date parse(String source, ParsePosition pos) { + return fmt.parse(source, pos); + } + + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return fmt.format(date, toAppendTo, fieldPosition); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/URLParameter.java b/core/src/main/com/sinch/sdk/core/http/URLParameter.java new file mode 100644 index 00000000..46f65593 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/URLParameter.java @@ -0,0 +1,74 @@ +package com.sinch.sdk.core.http; + +public class URLParameter { + private final String name; + private final Object value; + private final STYLE style; + private final boolean explode; + + /** + * Create a URL parameter from an object and a style: matrix, label, form, ... (see OAS + * https://spec.openapis.org/oas/latest.html#parameter-object) + * + * @param name The name of the parameter. + * @param value The value of the parameter. Could be a collection of object values for name + * @param style The style to be used for converting value to URL parameter string representation + * @param explode Is parameter have to be exploded for URL parameter string representation + */ + public URLParameter(String name, Object value, STYLE style, boolean explode) { + this.name = name; + this.value = value; + this.style = style; + this.explode = explode; + } + + public URLParameter(String name, Object value) { + this.name = name; + this.value = value; + this.style = STYLE.FORM; + this.explode = false; + } + + public String getName() { + return name; + } + + public Object getValue() { + return value; + } + + public STYLE getStyle() { + return style; + } + + public boolean isExplode() { + return explode; + } + + @Override + public String toString() { + return "URLParameter{" + + "name='" + + name + + '\'' + + ", value='" + + value + + '\'' + + ", style='" + + style + + '\'' + + ", explode=" + + explode + + '}'; + } + + public enum STYLE { + MATRIX, + LABEL, + FORM, + SIMPLE, + SPACE_DELIMITED, + PIPE_DELIMITED, + DEEP_OBJECT + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java b/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java new file mode 100644 index 00000000..3a9a1ce8 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java @@ -0,0 +1,200 @@ +package com.sinch.sdk.core.http; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.utils.StringUtil; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.InvalidParameterException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Optional; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * See https://spec.openapis.org/oas/latest.html#parameter-object for encoding and rendering details + */ +public class URLParameterUtils { + + private static final String UTF8_CHARSET = "UTF-8"; + + public static String encodeParametersAsString(Collection parameters) { + return parameters.stream() + .map(e -> URLParameterUtils.encode(e).orElse(null)) + .collect(Collectors.joining("&")); + } + + public static Optional encode(URLParameter parameter) { + + if (null == parameter + || StringUtil.isEmpty(parameter.getName()) + || null == parameter.getValue()) { + return Optional.empty(); + } + Object value = parameter.getValue(); + + if (value instanceof String || value instanceof Number) { + return encodeString(parameter.getStyle(), parameter.getName(), value.toString()); + } + + Stream stream = null; + if (parameter.getValue() instanceof Object[]) { + stream = Arrays.stream((Object[]) parameter.getValue()); + } else if (parameter.getValue() instanceof Collection) { + stream = ((Collection) parameter.getValue()).stream(); + } + if (null != stream) { + return encodeStream(parameter.getStyle(), parameter.isExplode(), parameter.getName(), stream); + } + + return encodeObject(parameter); + } + + private static Optional encodeString( + URLParameter.STYLE style, String name, String value) { + switch (style) { + case MATRIX: + return Optional.of( + String.format( + ";%s%s%s", + encodeParameterValue(name), + StringUtil.isEmpty(value) ? "" : "=", + encodeParameterValue(value))); + case LABEL: + return Optional.of(String.format(".%s", encodeParameterValue(value))); + case FORM: + return Optional.of( + String.format("%s=%s", encodeParameterValue(name), encodeParameterValue(value))); + case SIMPLE: + if (StringUtil.isEmpty(value)) { + throw new ApiException("Unexpected empty value '" + value + "'"); + } + return Optional.of(String.format("%s", encodeParameterValue(value))); + } + throw new ApiException("Unexpected style '" + style + "'"); + } + + private static Optional encodeStream( + URLParameter.STYLE style, boolean explode, String name, Stream stream) { + + switch (style) { + case MATRIX: + return encodeMatrixArray(explode, name, stream); + case LABEL: + return encodeLabelArray(name, stream); + case FORM: + return encodeFormArray(explode, name, stream); + + case SIMPLE: + return encodeSimpleArray(explode, name, stream); + case SPACE_DELIMITED: + return encodeSpaceDelimitedArray(explode, name, stream); + case PIPE_DELIMITED: + return encodePipeDelimitedArray(explode, name, stream); + } + + throw new InvalidParameterException("Invalid style='" + style + "'"); + } + + private static Optional encodeMatrixArray( + boolean explode, String name, Stream stream) { + if (explode) { + return Optional.of( + stream + .map( + e -> + String.format( + ";%s=%s", + encodeParameterValue(name), encodeParameterValue(String.valueOf(e)))) + .collect(Collectors.joining(""))); + } + + return Optional.of( + String.format( + ";%s=%s", + encodeParameterValue(name), + stream + .map(e -> encodeParameterValue(String.valueOf(e))) + .collect(Collectors.joining(",")))); + } + + private static Optional encodeLabelArray(String name, Stream stream) { + return Optional.of( + stream + .map(e -> String.format(".%s", encodeParameterValue(e.toString()))) + .collect(Collectors.joining(""))); + } + + private static Optional encodeFormArray(boolean explode, String name, Stream stream) { + if (explode) { + return Optional.of( + stream + .map( + e -> + String.format( + "%s=%s", + encodeParameterValue(name), encodeParameterValue(String.valueOf(e)))) + .collect(Collectors.joining("&"))); + } + + return Optional.of( + String.format( + "%s=%s", + encodeParameterValue(name), + stream + .map(e -> encodeParameterValue((String.valueOf(e)))) + .collect(Collectors.joining(",")))); + } + + private static Optional encodeSimpleArray( + boolean explode, String name, Stream stream) { + return Optional.of( + String.format( + "%s", + stream + .map(e -> encodeParameterValue((String.valueOf(e)))) + .collect(Collectors.joining(",")))); + } + + private static Optional encodeSpaceDelimitedArray( + boolean explode, String name, Stream stream) { + if (explode) { + throw new ApiException("Unsupported operation"); + } + + return Optional.of( + String.format( + "%s", + stream + .map(e -> encodeParameterValue((String.valueOf(e)))) + .collect(Collectors.joining("%20")))); + } + + private static Optional encodePipeDelimitedArray( + boolean explode, String name, Stream stream) { + if (explode) { + throw new ApiException("Unsupported operation"); + } + + return Optional.of( + String.format( + "%s", + stream + .map(e -> encodeParameterValue((String.valueOf(e)))) + .collect(Collectors.joining("|")))); + } + + private static Optional encodeObject(URLParameter parameter) { + + throw new ApiException("Not yet implemented '" + parameter + "'"); + } + + public static String encodeParameterValue(String value) { + + try { + return URLEncoder.encode(value, "UTF-8").replaceAll("\\.", "%2E"); + } catch (UnsupportedEncodingException e) { + return value; + } + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/AbstractOpenApiSchema.java b/core/src/main/com/sinch/sdk/core/models/AbstractOpenApiSchema.java new file mode 100644 index 00000000..37ec0576 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/AbstractOpenApiSchema.java @@ -0,0 +1,143 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.core.models; + +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/ServerConfiguration.java b/core/src/main/com/sinch/sdk/core/models/ServerConfiguration.java new file mode 100644 index 00000000..5fbd3fb1 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/ServerConfiguration.java @@ -0,0 +1,16 @@ +package com.sinch.sdk.core.models; + +/** Representing a Server configuration. */ +public class ServerConfiguration { + + public final String url; + + /** @param url A URL to the target host. */ + public ServerConfiguration(String url) { + this.url = url; + } + + public String getUrl() { + return url; + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/package-info.java b/core/src/main/com/sinch/sdk/core/models/package-info.java new file mode 100644 index 00000000..d2df6fcf --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/package-info.java @@ -0,0 +1,6 @@ +/** + * Shared models + * + * @since 1.0 + */ +package com.sinch.sdk.core.models; diff --git a/core/src/main/com/sinch/sdk/core/models/pagination/ListResponse.java b/core/src/main/com/sinch/sdk/core/models/pagination/ListResponse.java new file mode 100644 index 00000000..1e24aa49 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/pagination/ListResponse.java @@ -0,0 +1,82 @@ +package com.sinch.sdk.core.models.pagination; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * Abstract class used for handling unified paginated response + * + *

Act as an iterator over pages response and pages content. + * + * @since 1.0 + */ +public abstract class ListResponse { + /** + * Indicate if another page response is available + * + * @return Returns true if the iteration has more pages. (In other words, returns true if next() + * would return a page rather than throwing an exception.) + */ + public abstract boolean hasNextPage(); + + /** + * Get next page response if available + * + * @return Returns the next page in the pagination/iteration. Next page response. Exception is + * throw in case no page available; call hasNextPage before to ensure is page is available + * @throws NoSuchElementException if the iteration has no more pages + */ + public abstract ListResponse nextPage() throws NoSuchElementException; + + /** + * Get the page items collection content + * + * @return The items related to current page content + */ + public abstract Collection getContent(); + + /** + * Get an iterator across all items available across all page responses + * + *

Underline API (HTTP request) will be called on demand when next page content will be + * required to fulfill iterator with items for consecutive page + * + * @return Iterator onto items + */ + public Iterator autoPageIter() { + return new ItemsIterator<>(this); + } + + static class ItemsIterator implements Iterator { + + ListResponse response; + int currentIndex = 0; + ArrayList currentList; + + public ItemsIterator(ListResponse response) { + this.response = response; + syncIteratorWithCurrentPage(); + } + + private void syncIteratorWithCurrentPage() { + this.currentIndex = 0; + this.currentList = new ArrayList<>(response.getContent()); + } + + @Override + public boolean hasNext() { + return currentIndex < currentList.size() || response.hasNextPage(); + } + + @Override + public T next() { + if (currentIndex >= currentList.size()) { + response = response.nextPage(); + syncIteratorWithCurrentPage(); + } + return currentList.get(currentIndex++); + } + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/pagination/Page.java b/core/src/main/com/sinch/sdk/core/models/pagination/Page.java new file mode 100644 index 00000000..020187e5 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/pagination/Page.java @@ -0,0 +1,40 @@ +package com.sinch.sdk.core.models.pagination; + +import java.util.Collection; + +public class Page { + + private final PageToken nextPageToken; + private final P parameters; + private final Collection entities; + + public Page(P parameters, Collection entities, PageToken nextPageToken) { + this.parameters = parameters; + this.entities = entities; + this.nextPageToken = nextPageToken; + } + + public PageToken getNextPageToken() { + return nextPageToken; + } + + public P getParameters() { + return parameters; + } + + public Collection getEntities() { + return entities; + } + + @Override + public String toString() { + return "Page{" + + "nextPageToken=" + + nextPageToken + + ", parameters=" + + parameters + + ", entities=" + + entities + + '}'; + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/pagination/PageToken.java b/core/src/main/com/sinch/sdk/core/models/pagination/PageToken.java new file mode 100644 index 00000000..9a908135 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/pagination/PageToken.java @@ -0,0 +1,18 @@ +package com.sinch.sdk.core.models.pagination; + +public class PageToken { + private final T token; + + public PageToken(T token) { + this.token = token; + } + + public T getToken() { + return token; + } + + @Override + public String toString() { + return "PageToken{" + "token='" + token + '\'' + '}'; + } +} diff --git a/core/src/main/com/sinch/sdk/core/models/pagination/package-info.java b/core/src/main/com/sinch/sdk/core/models/pagination/package-info.java new file mode 100644 index 00000000..75b02a52 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/models/pagination/package-info.java @@ -0,0 +1,6 @@ +/** + * Unified way to get access to result returning a list of items across paginated response + * + * @since 1.0 + */ +package com.sinch.sdk.core.models.pagination; diff --git a/core/src/main/com/sinch/sdk/core/utils/EnumDynamic.java b/core/src/main/com/sinch/sdk/core/utils/EnumDynamic.java new file mode 100644 index 00000000..e3446a27 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/EnumDynamic.java @@ -0,0 +1,39 @@ +package com.sinch.sdk.core.utils; + +/** + * Abstract class providing common definition to extendable enums + * + * @param Enum type + */ +public abstract class EnumDynamic> { + + private final String value; + + protected EnumDynamic(String value) { + this.value = value; + } + + /** + * Get enum value as String + * + * @return Enum value + */ + public String value() { + return value; + } + + public String toString() { + return value(); + } + + public boolean equals(E o) { + if (o == this) { + return true; + } + return java.util.Objects.equals(this.value, o.value()); + } + + public int hashCode() { + return value.hashCode(); + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java b/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java new file mode 100644 index 00000000..0ceb4fe2 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java @@ -0,0 +1,113 @@ +package com.sinch.sdk.core.utils; + +import static java.lang.String.format; +import static java.util.stream.Collectors.toList; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * Utility class to manage extendable enumeration set Used to define a known set of value but enable + * to extend it dynamically Typical use case: being able to send and/or receive values not yet + * defined at SDK version release + */ +public final class EnumSupportDynamic> { + + private final Class aClass; + private final Map valueMap; + private final Function surplusFactory; + + private volatile List values; + + public EnumSupportDynamic(Class aClass, Function surplusFactory, List values) { + + this.aClass = aClass; + this.values = Collections.unmodifiableList(values); + this.valueMap = this.values.stream().collect(Collectors.toMap(EnumDynamic::value, v -> v)); + this.surplusFactory = surplusFactory; + } + + private static List createImmutableList(List values2, E newValue) { + List newValues = new ArrayList<>(values2); + newValues.add(newValue); + return Collections.unmodifiableList(newValues); + } + + public Stream values() { + return values.stream(); + } + + public String valueOf(E e) { + return e == null ? null : e.value(); + } + + public List valuesOf(Collection values) { + if (values == null) { + return null; + } + return values.stream().map(this::valueOf).collect(toList()); + } + + public List fromValues(Collection values) { + if (values == null) { + return null; + } + return values.stream().map(this::from).collect(toList()); + } + + public E from(String value) { + if (value == null) { + return null; + } + + E e = valueMap.get(value); + if (e != null) { + return e; + } + + synchronized (valueMap) { + E present = valueMap.get(value); + + if (present == null) { + E newValue = surplusFactory.apply(value); + + valueMap.put(value, newValue); + values = createImmutableList(values, newValue); + + return newValue; + } else { + // Racing conditions before entering the synchronized block. + return present; + } + } + } + + public int compare(Object o1, Object o2) { + String v1 = toComparableValue(o1); + String v2 = toComparableValue(o2); + return Objects.compare(v1, v2, String::compareTo); + } + + public String toComparableValue(Object o) { + + if (o == null) { + return null; + } + + if (o instanceof String) { + return (String) o; + } + + if (aClass.isInstance(o)) { + E obj = aClass.cast(o); + return obj.value(); + } + + throw new IllegalArgumentException( + format( + "Object %s is neither %s nor a String.", + o.getClass().getSimpleName(), aClass.getSimpleName())); + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/Pair.java b/core/src/main/com/sinch/sdk/core/utils/Pair.java new file mode 100644 index 00000000..b53460f2 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/Pair.java @@ -0,0 +1,25 @@ +package com.sinch.sdk.core.utils; + +/** Utility class to manage a pair of information (tuple) */ +public class Pair { + private final N left; + private final V right; + + public Pair(N left, V right) { + this.left = left; + this.right = right; + } + + public N getLeft() { + return this.left; + } + + public V getRight() { + return this.right; + } + + @Override + public String toString() { + return "Pair{" + "left='" + left + '\'' + ", right='" + right + '\'' + '}'; + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/StringUtil.java b/core/src/main/com/sinch/sdk/core/utils/StringUtil.java new file mode 100644 index 00000000..ae515990 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/StringUtil.java @@ -0,0 +1,16 @@ +package com.sinch.sdk.core.utils; + +/** Utility class for string */ +public class StringUtil { + + /** + * Check if a string is empty + * + * @param value String to be cheked + * @return true if String is null, empty or contains only spaces characters + * @since 1.0 + */ + public static boolean isEmpty(String value) { + return (null == value || value.trim().isEmpty()); + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/databind/JSONNavigator.java b/core/src/main/com/sinch/sdk/core/utils/databind/JSONNavigator.java new file mode 100644 index 00000000..c6c3fe19 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/databind/JSONNavigator.java @@ -0,0 +1,202 @@ +package com.sinch.sdk.core.utils.databind; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class JSONNavigator { + + /** A map of discriminators for all model classes. */ + private static final Map, ClassDiscriminatorMapping> modelDiscriminators = + new HashMap<>(); + /** A map of oneOf/anyOf descendants for each model class. */ + private static final Map, Map>> modelDescendants = new HashMap<>(); + + private static JSONNavigator jsonNavigator; + + static { + jsonNavigator = new JSONNavigator(); + } + + /** + * Returns the target model class that should be used to deserialize the input data. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param modelClass The class that contains the discriminator mappings. + * @return the target model class. + */ + public static Class getClassForElement(JsonNode node, Class modelClass) { + ClassDiscriminatorMapping cdm = modelDiscriminators.get(modelClass); + if (cdm != null) { + return cdm.getClassForElement(node, new HashSet>()); + } + return null; + } + + /** + * Returns true if inst is an instance of modelClass in the OpenAPI model hierarchy. + * + *

The Java class hierarchy is not implemented the same way as the OpenAPI model hierarchy, so + * it's not possible to use the instanceof keyword. + * + * @param modelClass A OpenAPI model class. + * @param inst The instance object. + * @param visitedClasses The set of classes that have already been visited. + * @return true if inst is an instance of modelClass in the OpenAPI model hierarchy. + */ + public static boolean isInstanceOf( + Class modelClass, Object inst, Set> visitedClasses) { + if (modelClass.isInstance(inst)) { + // This handles the 'allOf' use case with single parent inheritance. + return true; + } + if (visitedClasses.contains(modelClass)) { + // This is to prevent infinite recursion when the composed schemas have + // a circular dependency. + return false; + } + visitedClasses.add(modelClass); + + // Traverse the oneOf/anyOf composed schemas. + Map> descendants = modelDescendants.get(modelClass); + if (descendants != null) { + for (Class childType : descendants.values()) { + if (isInstanceOf(childType, inst, visitedClasses)) { + return true; + } + } + } + return false; + } + + /** + * Register a model class discriminator. + * + * @param modelClass the model class + * @param discriminatorPropertyName the name of the discriminator property + * @param mappings a map with the discriminator mappings. + */ + public static void registerDiscriminator( + Class modelClass, String discriminatorPropertyName, Map> mappings) { + ClassDiscriminatorMapping m = + new ClassDiscriminatorMapping(modelClass, discriminatorPropertyName, mappings); + modelDiscriminators.put(modelClass, m); + } + + /** + * Register the oneOf/anyOf descendants of the modelClass. + * + * @param modelClass the model class + * @param descendants a map of oneOf/anyOf descendants. + */ + public static void registerDescendants(Class modelClass, Map> descendants) { + modelDescendants.put(modelClass, descendants); + } + + /** + * Get the default JSONNavigator instance. + * + * @return the default JSONNavigator instance + */ + public static JSONNavigator getDefault() { + return jsonNavigator; + } + + /** + * Set the default JSONNavigator instance. + * + * @param jsonNavigator JSONNavigator instance to be used + */ + public static void setDefault(JSONNavigator jsonNavigator) { + JSONNavigator.jsonNavigator = jsonNavigator; + } + + /** Helper class to register the discriminator mappings. */ + private static class ClassDiscriminatorMapping { + // The model class name. + Class modelClass; + // The name of the discriminator property. + String discriminatorName; + // The discriminator mappings for a model class. + Map> discriminatorMappings; + + // Constructs a new class discriminator. + ClassDiscriminatorMapping(Class cls, String propertyName, Map> mappings) { + modelClass = cls; + discriminatorName = propertyName; + discriminatorMappings = new HashMap>(); + if (mappings != null) { + discriminatorMappings.putAll(mappings); + } + } + + // Return the name of the discriminator property for this model class. + String getDiscriminatorPropertyName() { + return discriminatorName; + } + + // Return the discriminator value or null if the discriminator is not + // present in the payload. + String getDiscriminatorValue(JsonNode node) { + // Determine the value of the discriminator property in the input data. + if (discriminatorName != null) { + // Get the value of the discriminator property, if present in the input payload. + node = node.get(discriminatorName); + if (node != null && node.isValueNode()) { + String discrValue = node.asText(); + return discrValue; + } + } + return null; + } + + /** + * Returns the target model class that should be used to deserialize the input data. This + * function can be invoked for anyOf/oneOf composed models with discriminator mappings. The + * discriminator mappings are used to determine the target model class. + * + * @param node The input data. + * @param visitedClasses The set of classes that have already been visited. + * @return the target model class. + */ + Class getClassForElement(JsonNode node, Set> visitedClasses) { + if (visitedClasses.contains(modelClass)) { + // Class has already been visited. + return null; + } + // Determine the value of the discriminator property in the input data. + String discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + return null; + } + Class cls = discriminatorMappings.get(discrValue); + // It may not be sufficient to return this cls directly because that target class + // may itself be a composed schema, possibly with its own discriminator. + visitedClasses.add(modelClass); + for (Class childClass : discriminatorMappings.values()) { + ClassDiscriminatorMapping childCdm = modelDiscriminators.get(childClass); + if (childCdm == null) { + continue; + } + if (!discriminatorName.equals(childCdm.discriminatorName)) { + discrValue = getDiscriminatorValue(node); + if (discrValue == null) { + continue; + } + } + if (childCdm != null) { + // Recursively traverse the discriminator mappings. + Class childDiscr = childCdm.getClassForElement(node, visitedClasses); + if (childDiscr != null) { + return childDiscr; + } + } + } + return cls; + } + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/databind/Mapper.java b/core/src/main/com/sinch/sdk/core/utils/databind/Mapper.java new file mode 100644 index 00000000..ca5bcc2a --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/databind/Mapper.java @@ -0,0 +1,28 @@ +package com.sinch.sdk.core.utils.databind; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; + +public class Mapper { + + private Mapper() {} + + public static ObjectMapper getInstance() { + return LazyHolder.INSTANCE; + } + + private static class LazyHolder { + public static final ObjectMapper INSTANCE = + new ObjectMapper() + .setSerializationInclusion(JsonInclude.Include.NON_NULL) + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) + .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false) + .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) + .disable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) + .enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING) + .registerModule(new JavaTimeModule()); + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/package-info.java b/core/src/main/com/sinch/sdk/core/utils/package-info.java new file mode 100644 index 00000000..339a9e73 --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/utils/package-info.java @@ -0,0 +1,6 @@ +/** + * Utility package + * + * @since 1.0 + */ +package com.sinch.sdk.core.utils; diff --git a/core/src/test/java/com/sinch/sdk/core/exceptions/ApiExceptionBuilderTest.java b/core/src/test/java/com/sinch/sdk/core/exceptions/ApiExceptionBuilderTest.java new file mode 100644 index 00000000..c1e2643c --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/exceptions/ApiExceptionBuilderTest.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.core.exceptions; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.type.TypeReference; +import com.sinch.sdk.core.utils.databind.Mapper; +import java.util.HashMap; +import org.junit.jupiter.api.Test; + +class ApiExceptionBuilderTest { + + private static final String numberErrorMocked = + "{ \"error\": {" + + "\"code\": 202," + + "\"message\": \"my error message\"," + + "\"status\": \"MY_STATUS\"" + + "}}"; + + @Test + void buildFromMessage() { + ApiException e = ApiExceptionBuilder.build("message", 202); + assertEquals("message", e.getMessage()); + assertEquals(202, e.getCode()); + } + + @Test + void buildFromObject() throws JsonProcessingException { + ApiException e = + ApiExceptionBuilder.build( + "message", + 202, + Mapper.getInstance() + .readValue(numberErrorMocked, new TypeReference>() {})); + assertEquals("MY_STATUS: my error message", e.getMessage()); + assertEquals(202, e.getCode()); + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/http/HttpMapperTest.java b/core/src/test/java/com/sinch/sdk/core/http/HttpMapperTest.java new file mode 100644 index 00000000..bcb4734d --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/http/HttpMapperTest.java @@ -0,0 +1,111 @@ +package com.sinch.sdk.core.http; + +import static com.sinch.sdk.core.http.HttpContentType.*; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.core.type.TypeReference; +import com.sinch.sdk.core.exceptions.ApiException; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class HttpMapperTest { + + final HttpMapper mapper = new HttpMapper(); + + @Test + void deserializeNullResponse() throws ApiException { + TypeReference returnType = new TypeReference() {}; + + Assertions.assertThat(mapper.deserialize(null, returnType)).isNull(); + } + + @Test + void deserializeNullReference() throws ApiException { + + HttpResponse httpResponse = new HttpResponse(-100, null, null, null); + Assertions.assertThat(mapper.deserialize(httpResponse, (TypeReference) null)).isNull(); + } + + @Test + void deserializeNoContentType() throws ApiException { + + FooSerialization value = new FooSerialization("my value"); + HttpResponse httpResponse = + new HttpResponse( + -100, "a message", null, "{\"value\": \"my value\"}".getBytes(StandardCharsets.UTF_8)); + + Assertions.assertThat( + mapper.deserialize(httpResponse, new TypeReference() {})) + .usingRecursiveComparison() + .isEqualTo(value); + } + + @Test + void deserializeJsonContentType() throws ApiException { + + FooSerialization value = new FooSerialization("my value"); + HttpResponse httpResponse = + new HttpResponse( + -100, + "a message", + Stream.of(new String[][] {{CONTENT_TYPE_HEADER, APPLICATION_JSON}}) + .collect( + Collectors.toMap(data -> data[0], data -> Collections.singletonList(data[1]))), + "{\"value\": \"my value\"}".getBytes(StandardCharsets.UTF_8)); + + Assertions.assertThat( + mapper.deserialize(httpResponse, new TypeReference() {})) + .usingRecursiveComparison() + .isEqualTo(value); + } + + @Test + void deserializeTextContentType() throws ApiException { + + HttpResponse httpResponse = + new HttpResponse( + -100, + "a message", + Stream.of(new String[][] {{CONTENT_TYPE_HEADER, TEXT_PLAIN}}) + .collect( + Collectors.toMap(data -> data[0], data -> Collections.singletonList(data[1]))), + "my text plain content".getBytes(StandardCharsets.UTF_8)); + + Assertions.assertThat(mapper.deserialize(httpResponse, new TypeReference() {})) + .isEqualTo("my text plain content"); + } + + @Test + void serializeJSON() throws ApiException { + + FooSerialization value = new FooSerialization("to deserialized"); + + Assertions.assertThat(mapper.serialize(null, value)) + .isEqualTo("{\"value\":\"to deserialized\"}"); + } + + static class FooSerialization { + public static final String JSON_PROPERTY = "value"; + private String value; + + public FooSerialization() {} + + public FooSerialization(String value) { + this.value = value; + } + + @JsonProperty(JSON_PROPERTY) + public String getValue() { + return value; + } + + @JsonProperty(JSON_PROPERTY) + public void setValue(String value) { + this.value = value; + } + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/http/HttpStatusTest.java b/core/src/test/java/com/sinch/sdk/core/http/HttpStatusTest.java new file mode 100644 index 00000000..d0a26360 --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/http/HttpStatusTest.java @@ -0,0 +1,17 @@ +package com.sinch.sdk.core.http; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class HttpStatusTest { + + @Test + void isSuccessfulStatus() { + Assertions.assertThat(HttpStatus.isSuccessfulStatus(200)).isTrue(); + } + + @Test + void isFailureStatus() { + Assertions.assertThat(HttpStatus.isSuccessfulStatus(500)).isFalse(); + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/http/URLParameterUtilsTest.java b/core/src/test/java/com/sinch/sdk/core/http/URLParameterUtilsTest.java new file mode 100644 index 00000000..25fb9423 --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/http/URLParameterUtilsTest.java @@ -0,0 +1,319 @@ +package com.sinch.sdk.core.http; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import com.sinch.sdk.core.exceptions.ApiException; +import java.util.Arrays; +import java.util.Optional; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +class URLParameterUtilsTest { + + @Test + void encodeNull() { + Assertions.assertEquals(Optional.empty(), URLParameterUtils.encode(null)); + } + + @Test + void encodeEmptyName() { + assertEquals(Optional.empty(), URLParameterUtils.encode(new URLParameter("", "foo"))); + } + + @Test + void encodeNullName() { + assertEquals(Optional.empty(), URLParameterUtils.encode(new URLParameter(null, "foo"))); + } + + @Test + void encodeFormNullValueNoExplode() { + assertEquals( + Optional.empty(), + URLParameterUtils.encode(new URLParameter("foo", null, URLParameter.STYLE.FORM, false))); + } + + @Test + void encodeFormNullValueExplode() { + assertEquals( + Optional.empty(), + URLParameterUtils.encode(new URLParameter("foo", null, URLParameter.STYLE.FORM, true))); + } + + @Test + void encodeMatrixEmptyStringNoExplode() { + assertEquals( + Optional.of(";foo"), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.MATRIX, false))); + } + + @Test + void encodeMatrixEmptyStringExplode() { + assertEquals( + Optional.of(";foo"), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.MATRIX, true))); + } + + @Test + void encodeMatrixStringNoExplode() { + assertEquals( + Optional.of(";foo=value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.MATRIX, false))); + } + + @Test + void encodeMatrixStringExplode() { + assertEquals( + Optional.of(";foo+with+space+and+%26%2C%2E=value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo with space and &,.", + "value with space and &,.", + URLParameter.STYLE.MATRIX, + true))); + } + + @Test + void encodeLabelEmptyStringNoExplode() { + assertEquals( + Optional.of("."), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.LABEL, false))); + } + + @Test + void encodeLabelEmptyStringExplode() { + assertEquals( + Optional.of("."), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.LABEL, true))); + } + + @Test + void encodeLabelStringNoExplode() { + assertEquals( + Optional.of(".value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.LABEL, false))); + } + + @Test + void encodeLabelStringExplode() { + assertEquals( + Optional.of(".value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.LABEL, true))); + } + + @Test + void encodeFormEmptyStringNoExplode() { + assertEquals( + Optional.of("foo="), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.FORM, false))); + } + + @Test + void encodeFormEmptyStringExplode() { + assertEquals( + Optional.of("foo="), + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.FORM, true))); + } + + @Test + void encodeFormStringNoExplode() { + assertEquals( + Optional.of("foo=value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.FORM, false))); + } + + @Test + void encodeFormStringExplode() { + assertEquals( + Optional.of("foo=value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.FORM, true))); + } + + @Test + void encodeSimpleEmptyStringNoExplode() { + assertThrows( + ApiException.class, + () -> + URLParameterUtils.encode( + new URLParameter("foo", "", URLParameter.STYLE.SIMPLE, false))); + } + + @Test + void encodeSimpleEmptyStringExplode() { + assertThrows( + ApiException.class, + () -> + URLParameterUtils.encode(new URLParameter("foo", "", URLParameter.STYLE.SIMPLE, true))); + } + + @Test + void encodeSimpleStringNoExplode() { + assertEquals( + Optional.of("value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo. with space and &,.", + "value with space and &,.", + URLParameter.STYLE.SIMPLE, + false))); + } + + @Test + void encodeSimpleStringExplode() { + assertEquals( + Optional.of("value+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter("foo", "value with space and &,.", URLParameter.STYLE.SIMPLE, true))); + } + + @Test + void encodeMatrixArrayNoExplode() { + assertEquals( + Optional.of(";foo=value1+with+space+and+%26%2C%2E,value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.MATRIX, + false))); + } + + @Test + void encodeMatrixArrayExplode() { + assertEquals( + Optional.of(";foo=value1+with+space+and+%26%2C%2E;foo=value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.MATRIX, + true))); + } + + @Test + void encodeLabelArrayNoExplode() { + assertEquals( + Optional.of(".value1+with+space+and+%26%2C%2E.value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.LABEL, + false))); + } + + @Test + void encodeLabelArrayExplode() { + assertEquals( + Optional.of(".value1+with+space+and+%26%2C%2E.value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.LABEL, + true))); + } + + @Test + void encodeFormArrayNoExplode() { + assertEquals( + Optional.of("foo=value1+with+space+and+%26%2C%2E,value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.FORM, + false))); + } + + @Test + void encodeFormArrayExplode() { + assertEquals( + Optional.of("foo=value1+with+space+and+%26%2C%2E&foo=value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.FORM, + true))); + } + + @Test + void encodeSimpleArrayNoExplode() { + assertEquals( + Optional.of("value1+with+space+and+%26%2C%2E,value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo with space and &,.", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.SIMPLE, + false))); + } + + @Test + void encodeSimpleArrayExplode() { + assertEquals( + Optional.of("value1+with+space+and+%26%2C%2E,value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.SIMPLE, + true))); + } + + @Test + void encodeSpaceDelimitedArrayNoExplode() { + assertEquals( + Optional.of("value1+with+space+and+%26%2C%2E%20value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo with space and &,.", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.SPACE_DELIMITED, + false))); + } + + @Test + void encodeSpaceDelimitedArrayExplode() { + assertThrows( + ApiException.class, + () -> + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.SPACE_DELIMITED, + true))); + } + + @Test + void encodePipeDelimitedArrayNoExplode() { + assertEquals( + Optional.of("value1+with+space+and+%26%2C%2E|value2+with+space+and+%26%2C%2E"), + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.PIPE_DELIMITED, + false))); + } + + @Test + void encodePipeDelimitedArrayExplode() { + assertThrows( + ApiException.class, + () -> + URLParameterUtils.encode( + new URLParameter( + "foo", + Arrays.asList("value1 with space and &,.", "value2 with space and &,."), + URLParameter.STYLE.PIPE_DELIMITED, + true))); + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/models/ServerConfigurationTest.java b/core/src/test/java/com/sinch/sdk/core/models/ServerConfigurationTest.java new file mode 100644 index 00000000..563db1fd --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/models/ServerConfigurationTest.java @@ -0,0 +1,15 @@ +package com.sinch.sdk.core.models; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class ServerConfigurationTest { + + @Test + void getUrl() { + String URL = "my url"; + ServerConfiguration configuration = new ServerConfiguration(URL); + assertEquals(URL, configuration.getUrl()); + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpRequestTest.java b/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpRequestTest.java new file mode 100644 index 00000000..a4661b87 --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpRequestTest.java @@ -0,0 +1,95 @@ +package com.sinch.sdk.core.outbound.models; + +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.core.http.HttpRequest; +import com.sinch.sdk.core.http.URLParameter; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +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.Test; + +class HttpRequestTest { + + static final String path = " a path"; + static final HttpMethod method = HttpMethod.POST; + static final Collection queryParameters = + Arrays.asList(new URLParameter("key1", "value1"), new URLParameter("key2", "value2")); + static final String body = "my body"; + static final Map headerParams = + Stream.of( + new String[][] { + {"headerKey1", "headerValue1"}, {"headerKey2", "headerValue2"}, + }) + .collect(Collectors.toMap(data -> data[0], data -> data[1])); + static final Collection accept = Arrays.asList("accept1", "accept2"); + static final Collection contentType = Arrays.asList("content1", "content2"); + static final Collection authNames = Collections.singletonList("auth1"); + final HttpRequest httpRequest = + new HttpRequest( + path, method, queryParameters, body, headerParams, accept, contentType, authNames); + + @Test + void getPath() { + Assertions.assertThat(httpRequest.getPath().get()).isEqualTo(path); + } + + @Test + void getMethod() { + Assertions.assertThat(httpRequest.getMethod()).isEqualTo(method); + } + + @Test + void getQueryParameters() { + Collection collection = + Arrays.asList(new URLParameter("key1", "value1"), new URLParameter("key2", "value2")); + + Assertions.assertThat(httpRequest.getQueryParameters()) + .usingRecursiveComparison() + .isEqualTo(collection); + } + + @Test + void getBody() { + Assertions.assertThat(httpRequest.getBody()).isEqualTo(body); + } + + @Test + void getHeaderParams() { + Map map = + Stream.of( + new String[][] { + {"headerKey1", "headerValue1"}, {"headerKey2", "headerValue2"}, + }) + .collect(Collectors.toMap(data -> data[0], data -> data[1])); + Assertions.assertThat(httpRequest.getHeaderParams()).usingRecursiveComparison().isEqualTo(map); + } + + @Test + void getAccept() { + Collection collection = Arrays.asList("accept1", "accept2"); + + Assertions.assertThat(httpRequest.getAccept()).usingRecursiveComparison().isEqualTo(collection); + } + + @Test + void getContentType() { + Collection collection = Arrays.asList("content1", "content2"); + + Assertions.assertThat(httpRequest.getContentType()) + .usingRecursiveComparison() + .isEqualTo(collection); + } + + @Test + void getAuthNames() { + Collection collection = Collections.singletonList("auth1"); + + Assertions.assertThat(httpRequest.getAuthNames()) + .usingRecursiveComparison() + .isEqualTo(collection); + } +} diff --git a/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpResponseTest.java b/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpResponseTest.java new file mode 100644 index 00000000..7a597e27 --- /dev/null +++ b/core/src/test/java/com/sinch/sdk/core/outbound/models/HttpResponseTest.java @@ -0,0 +1,51 @@ +package com.sinch.sdk.core.outbound.models; + +import com.sinch.sdk.core.http.HttpResponse; +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +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.Test; + +class HttpResponseTest { + + static final Integer code = 201; + static final String message = "my message"; + static final Map> headers = + Stream.of(new String[][] {{"headerKey1", "headerValue1"}}) + .collect(Collectors.toMap(data -> data[0], data -> Collections.singletonList(data[1]))); + + static final String responseString = "My response"; + + static final byte[] response = responseString.getBytes(StandardCharsets.UTF_8); + final HttpResponse httpResponse = new HttpResponse(code, message, headers, response); + + @Test + void getCode() { + Assertions.assertThat(httpResponse.getCode()).isEqualTo(code); + } + + @Test + void getMessage() { + Assertions.assertThat(httpResponse.getMessage()).isEqualTo(message); + } + + @Test + void getHeaders() { + Assertions.assertThat(httpResponse.getHeaders()).usingRecursiveComparison().isEqualTo(headers); + } + + @Test + void getContent() { + String result = + new BufferedReader(new InputStreamReader(httpResponse.getContent())) + .lines() + .collect(Collectors.joining("")); + Assertions.assertThat(result).isEqualTo(responseString); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApi.java new file mode 100644 index 00000000..4dce763f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApi.java @@ -0,0 +1,481 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumbersResponseDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ActiveNumberApi { + + private static final Logger LOGGER = Logger.getLogger(ActiveNumberApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public ActiveNumberApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * Get active Number Get a virtual number + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param phoneNumber Output only. The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. + * (required) + * @return ActiveNumberDto + * @throws ApiException if fails to make API call + */ + public ActiveNumberDto numberServiceGetActiveNumber(String projectId, String phoneNumber) + throws ApiException { + HttpRequest httpRequest = numberServiceGetActiveNumberRequestBuilder(projectId, phoneNumber); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceGetActiveNumberRequestBuilder( + String projectId, String phoneNumber) throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling numberServiceGetActiveNumber"); + } + // verify the required parameter 'phoneNumber' is set + if (phoneNumber == null) { + throw new ApiException( + 400, + "Missing the required parameter 'phoneNumber' when calling numberServiceGetActiveNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/activeNumbers/{phoneNumber}" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())) + .replaceAll( + "\\{" + "phoneNumber" + "\\}", + URLParameterUtils.encodeParameterValue(phoneNumber.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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * List active numbers Lists all virtual numbers for a project. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone + * number. Example: `US`, `GB` or `SE`. (required) + * @param type Number type to filter by. Options include, `MOBILE`, `LOCAL` or + * `TOLL_FREE`. (required) + * @param numberPatternPattern Sequence of digits to search for. If you prefer or need certain + * digits in sequential order, you can enter the sequence of numbers here. For example, + * `2020`. (optional) + * @param numberPatternSearchPattern Search pattern to apply. The options are, `START`, + * `CONTAIN`, and `END`. (optional) + * @param capability Number capabilities to filter by, `SMS` and/or `VOICE`. + * (optional + * @param pageSize The maximum number of items to return. (optional) + * @param pageToken The next page token value returned from a previous List request, if any. + * (optional) + * @param orderBy Supported fields for ordering by `phoneNumber` or + * `displayName`. (optional) + * @return ActiveNumbersResponseDto + * @throws ApiException if fails to make API call + */ + public ActiveNumbersResponseDto numberServiceListActiveNumbers( + String projectId, + String regionCode, + String type, + String numberPatternPattern, + String numberPatternSearchPattern, + List capability, + Integer pageSize, + String pageToken, + String orderBy) + throws ApiException { + HttpRequest httpRequest = + numberServiceListActiveNumbersRequestBuilder( + projectId, + regionCode, + type, + numberPatternPattern, + numberPatternSearchPattern, + capability, + pageSize, + pageToken, + orderBy); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceListActiveNumbersRequestBuilder( + String projectId, + String regionCode, + String type, + String numberPatternPattern, + String numberPatternSearchPattern, + List capability, + Integer pageSize, + String pageToken, + String orderBy) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling numberServiceListActiveNumbers"); + } + // verify the required parameter 'regionCode' is set + if (regionCode == null) { + throw new ApiException( + 400, + "Missing the required parameter 'regionCode' when calling" + + " numberServiceListActiveNumbers"); + } + // verify the required parameter 'type' is set + if (type == null) { + throw new ApiException( + 400, "Missing the required parameter 'type' when calling numberServiceListActiveNumbers"); + } + + String localVarPath = + "/v1/projects/{projectId}/activeNumbers" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != regionCode) { + localVarQueryParams.add( + new URLParameter( + "regionCode", regionCode, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != numberPatternPattern) { + localVarQueryParams.add( + new URLParameter( + "numberPattern.pattern", + numberPatternPattern, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != numberPatternSearchPattern) { + localVarQueryParams.add( + new URLParameter( + "numberPattern.searchPattern", + numberPatternSearchPattern, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != type) { + localVarQueryParams.add( + new URLParameter("type", type, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != capability) { + localVarQueryParams.add( + new URLParameter( + "capability", capability, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != pageSize) { + localVarQueryParams.add( + new URLParameter( + "pageSize", pageSize, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != pageToken) { + localVarQueryParams.add( + new URLParameter( + "pageToken", pageToken, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != orderBy) { + localVarQueryParams.add( + new URLParameter( + "orderBy", orderBy, 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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Release number With this endpoint, you can cancel your subscription for a specific virtual + * phone number. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param phoneNumber Output only. The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. + * (required) + * @return ActiveNumberDto + * @throws ApiException if fails to make API call + */ + public ActiveNumberDto numberServiceReleaseNumber(String projectId, String phoneNumber) + throws ApiException { + HttpRequest httpRequest = numberServiceReleaseNumberRequestBuilder(projectId, phoneNumber); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceReleaseNumberRequestBuilder(String projectId, String phoneNumber) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling numberServiceReleaseNumber"); + } + // verify the required parameter 'phoneNumber' is set + if (phoneNumber == null) { + throw new ApiException( + 400, + "Missing the required parameter 'phoneNumber' when calling numberServiceReleaseNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/activeNumbers/{phoneNumber}:release" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())) + .replaceAll( + "\\{" + "phoneNumber" + "\\}", + URLParameterUtils.encodeParameterValue(phoneNumber.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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Update active number Update a virtual phone number. For example: you can configure SMS/Voice + * services or set a friendly name. To update the name that displays, modify the + * `displayName` parameter. You'll use `smsConfiguration` to update your + * SMS configuration and `voiceConfiguration` to update the voice configuration. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param phoneNumber Output only. The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. + * (required) + * @param activeNumberRequestDto The number body to be updated. (optional) + * @return ActiveNumberDto + * @throws ApiException if fails to make API call + */ + public ActiveNumberDto numberServiceUpdateActiveNumber( + String projectId, String phoneNumber, ActiveNumberRequestDto activeNumberRequestDto) + throws ApiException { + HttpRequest httpRequest = + numberServiceUpdateActiveNumberRequestBuilder( + projectId, phoneNumber, activeNumberRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceUpdateActiveNumberRequestBuilder( + String projectId, String phoneNumber, ActiveNumberRequestDto activeNumberRequestDto) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling" + + " numberServiceUpdateActiveNumber"); + } + // verify the required parameter 'phoneNumber' is set + if (phoneNumber == null) { + throw new ApiException( + 400, + "Missing the required parameter 'phoneNumber' when calling" + + " numberServiceUpdateActiveNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/activeNumbers/{phoneNumber}" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())) + .replaceAll( + "\\{" + "phoneNumber" + "\\}", + URLParameterUtils.encodeParameterValue(phoneNumber.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("BasicAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, activeNumberRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.PATCH, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApi.java new file mode 100644 index 00000000..427e48b8 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApi.java @@ -0,0 +1,473 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.ActiveNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumberDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableNumbersResponseDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentAnyNumberRequestDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.RentNumberRequestDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AvailableNumberApi { + + private static final Logger LOGGER = Logger.getLogger(AvailableNumberApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public AvailableNumberApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * Get available number This endpoint allows you to enter a specific phone number to check if + * it's available for use. A 200 response will return the number's capability, setup + * costs, monthly costs and if supporting documentation is required. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param phoneNumber Output only. The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. + * (required) + * @return AvailableNumberDto + * @throws ApiException if fails to make API call + */ + public AvailableNumberDto numberServiceGetAvailableNumber(String projectId, String phoneNumber) + throws ApiException { + HttpRequest httpRequest = numberServiceGetAvailableNumberRequestBuilder(projectId, phoneNumber); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceGetAvailableNumberRequestBuilder( + String projectId, String phoneNumber) throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling" + + " numberServiceGetAvailableNumber"); + } + // verify the required parameter 'phoneNumber' is set + if (phoneNumber == null) { + throw new ApiException( + 400, + "Missing the required parameter 'phoneNumber' when calling" + + " numberServiceGetAvailableNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/availableNumbers/{phoneNumber}" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())) + .replaceAll( + "\\{" + "phoneNumber" + "\\}", + URLParameterUtils.encodeParameterValue(phoneNumber.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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * List available numbers Search for virtual numbers that are available for you to activate. You + * can filter by any property on the available number resource. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone + * number. Example: `US`, `GB` or `SE`. (required) + * @param type Number type to filter by. Options include, `MOBILE`, `LOCAL` or + * `TOLL_FREE`. (required) + * @param numberPatternPattern Sequence of digits to search for. If you prefer or need certain + * digits in sequential order, you can enter the sequence of numbers here. For example, + * `2020`. (optional) + * @param numberPatternSearchPattern Search pattern to apply. The options are, `START`, + * `CONTAIN`, and `END`. (optional) + * @param capabilities Number capabilities to filter by SMS and/or VOICE. When searching, indicate + * the `capabilities` of the number as `SMS` and/or `VOICE`. To + * search for a number capable of both, list both `SMS` and `VOICE`. + * (optional + * @param size Optional. The maximum number of items to return. (optional) + * @return AvailableNumbersResponseDto + * @throws ApiException if fails to make API call + */ + public AvailableNumbersResponseDto numberServiceListAvailableNumbers( + String projectId, + String regionCode, + String type, + String numberPatternPattern, + String numberPatternSearchPattern, + List capabilities, + Integer size) + throws ApiException { + HttpRequest httpRequest = + numberServiceListAvailableNumbersRequestBuilder( + projectId, + regionCode, + type, + numberPatternPattern, + numberPatternSearchPattern, + capabilities, + size); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceListAvailableNumbersRequestBuilder( + String projectId, + String regionCode, + String type, + String numberPatternPattern, + String numberPatternSearchPattern, + List capabilities, + Integer size) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling" + + " numberServiceListAvailableNumbers"); + } + // verify the required parameter 'regionCode' is set + if (regionCode == null) { + throw new ApiException( + 400, + "Missing the required parameter 'regionCode' when calling" + + " numberServiceListAvailableNumbers"); + } + // verify the required parameter 'type' is set + if (type == null) { + throw new ApiException( + 400, + "Missing the required parameter 'type' when calling numberServiceListAvailableNumbers"); + } + + String localVarPath = + "/v1/projects/{projectId}/availableNumbers" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != numberPatternPattern) { + localVarQueryParams.add( + new URLParameter( + "numberPattern.pattern", + numberPatternPattern, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != numberPatternSearchPattern) { + localVarQueryParams.add( + new URLParameter( + "numberPattern.searchPattern", + numberPatternSearchPattern, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != regionCode) { + localVarQueryParams.add( + new URLParameter( + "regionCode", regionCode, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != type) { + localVarQueryParams.add( + new URLParameter("type", type, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != capabilities) { + localVarQueryParams.add( + new URLParameter( + "capabilities", + capabilities, + URLParameter.STYLE.valueOf("form".toUpperCase()), + true)); + } + if (null != size) { + localVarQueryParams.add( + new URLParameter("size", size, 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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Rent any number that matches the criteria Search for and activate an available Sinch virtual + * number all in one API call. Currently the rentAny operation works only for US 10DLC numbers + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param rentAnyNumberRequestDto The request to search and rent a number that matches the + * criteria. (required) + * @return ActiveNumberDto + * @throws ApiException if fails to make API call + */ + public ActiveNumberDto numberServiceRentAnyNumber( + String projectId, RentAnyNumberRequestDto rentAnyNumberRequestDto) throws ApiException { + HttpRequest httpRequest = + numberServiceRentAnyNumberRequestBuilder(projectId, rentAnyNumberRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceRentAnyNumberRequestBuilder( + String projectId, RentAnyNumberRequestDto rentAnyNumberRequestDto) throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling numberServiceRentAnyNumber"); + } + // verify the required parameter 'rentAnyNumberRequestDto' is set + if (rentAnyNumberRequestDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'rentAnyNumberRequestDto' when calling" + + " numberServiceRentAnyNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/availableNumbers:rentAny" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.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("BasicAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, rentAnyNumberRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Rent an available number Activate a virtual number to use with SMS products, Voice products, or + * both. You'll use `smsConfiguration` to setup your number for SMS and + * `voiceConfiguration` for Voice. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param phoneNumber Output only. The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. + * (required) + * @param rentNumberRequestDto The request to rent a number. (required) + * @return ActiveNumberDto + * @throws ApiException if fails to make API call + */ + public ActiveNumberDto numberServiceRentNumber( + String projectId, String phoneNumber, RentNumberRequestDto rentNumberRequestDto) + throws ApiException { + HttpRequest httpRequest = + numberServiceRentNumberRequestBuilder(projectId, phoneNumber, rentNumberRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceRentNumberRequestBuilder( + String projectId, String phoneNumber, RentNumberRequestDto rentNumberRequestDto) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, "Missing the required parameter 'projectId' when calling numberServiceRentNumber"); + } + // verify the required parameter 'phoneNumber' is set + if (phoneNumber == null) { + throw new ApiException( + 400, "Missing the required parameter 'phoneNumber' when calling numberServiceRentNumber"); + } + // verify the required parameter 'rentNumberRequestDto' is set + if (rentNumberRequestDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'rentNumberRequestDto' when calling" + + " numberServiceRentNumber"); + } + + String localVarPath = + "/v1/projects/{projectId}/availableNumbers/{phoneNumber}:rent" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())) + .replaceAll( + "\\{" + "phoneNumber" + "\\}", + URLParameterUtils.encodeParameterValue(phoneNumber.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("BasicAuth"); + final String serializedBody = mapper.serialize(localVarContentTypes, rentNumberRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApi.java new file mode 100644 index 00000000..30301d15 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApi.java @@ -0,0 +1,132 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AvailableRegionsApi { + + private static final Logger LOGGER = Logger.getLogger(AvailableRegionsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public AvailableRegionsApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * List available regions Lists all regions for numbers provided for the project ID. + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param types Only returns regions for which numbers are provided with the given types v1: + * `MOBILE`, `LOCAL` or `TOLL_FREE`. However, you can indicate + * `NUMBER_TYPE_UNSPECIFIED: null` when searching. - NUMBER_TYPE_UNSPECIFIED: Null + * value - MOBILE: Numbers that belong to a specific range. - LOCAL: Numbers that are assigned + * to a specific geographic region. - TOLL_FREE: Number that are free of charge for the + * calling party but billed for all arriving calls. (optional + * @return ListAvailableRegionsResponseDto + * @throws ApiException if fails to make API call + */ + public ListAvailableRegionsResponseDto numberServiceListAvailableRegions( + String projectId, List types) throws ApiException { + HttpRequest httpRequest = numberServiceListAvailableRegionsRequestBuilder(projectId, types); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 numberServiceListAvailableRegionsRequestBuilder( + String projectId, List types) throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling" + + " numberServiceListAvailableRegions"); + } + + String localVarPath = + "/v1/projects/{projectId}/availableRegions" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != types) { + localVarQueryParams.add( + new URLParameter("types", types, 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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApi.java new file mode 100644 index 00000000..53e447e2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApi.java @@ -0,0 +1,195 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationUpdateDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CallbackConfigurationApi { + + private static final Logger LOGGER = Logger.getLogger(CallbackConfigurationApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public CallbackConfigurationApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * Get callbacks configuration Returns the callbacks configuration for the specified project + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @return CallbackConfigurationDto + * @throws ApiException if fails to make API call + */ + public CallbackConfigurationDto getCallbackConfiguration(String projectId) throws ApiException { + HttpRequest httpRequest = getCallbackConfigurationRequestBuilder(projectId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getCallbackConfigurationRequestBuilder(String projectId) throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, "Missing the required parameter 'projectId' when calling getCallbackConfiguration"); + } + + String localVarPath = + "/v1/projects/{projectId}/callbackConfiguration" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.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("BasicAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Update callback configuration Updates the callbacks configuration for the specified project + * + * @param projectId Found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. (required) + * @param callbackConfigurationUpdateDto The callback configuration details to be updated. + * (optional) + * @return CallbackConfigurationDto + * @throws ApiException if fails to make API call + */ + public CallbackConfigurationDto updateCallbackConfiguration( + String projectId, CallbackConfigurationUpdateDto callbackConfigurationUpdateDto) + throws ApiException { + HttpRequest httpRequest = + updateCallbackConfigurationRequestBuilder(projectId, callbackConfigurationUpdateDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 updateCallbackConfigurationRequestBuilder( + String projectId, CallbackConfigurationUpdateDto callbackConfigurationUpdateDto) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'projectId' when calling updateCallbackConfiguration"); + } + + String localVarPath = + "/v1/projects/{projectId}/callbackConfiguration" + .replaceAll( + "\\{" + "projectId" + "\\}", + URLParameterUtils.encodeParameterValue(projectId.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("BasicAuth"); + final String serializedBody = + mapper.serialize(localVarContentTypes, callbackConfigurationUpdateDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.PATCH, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberDto.java new file mode 100644 index 00000000..5ebebfd9 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberDto.java @@ -0,0 +1,427 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** The phone number that has been rented by a customer and assigned to a project. */ +@JsonPropertyOrder({ + ActiveNumberDto.JSON_PROPERTY_PHONE_NUMBER, + ActiveNumberDto.JSON_PROPERTY_PROJECT_ID, + ActiveNumberDto.JSON_PROPERTY_DISPLAY_NAME, + ActiveNumberDto.JSON_PROPERTY_REGION_CODE, + ActiveNumberDto.JSON_PROPERTY_TYPE, + ActiveNumberDto.JSON_PROPERTY_CAPABILITY, + ActiveNumberDto.JSON_PROPERTY_MONEY, + ActiveNumberDto.JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS, + ActiveNumberDto.JSON_PROPERTY_NEXT_CHARGE_DATE, + ActiveNumberDto.JSON_PROPERTY_EXPIRE_AT, + ActiveNumberDto.JSON_PROPERTY_SMS_CONFIGURATION, + ActiveNumberDto.JSON_PROPERTY_VOICE_CONFIGURATION, + ActiveNumberDto.JSON_PROPERTY_CALLBACK_URL +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ActiveNumberDto { + public static final String JSON_PROPERTY_PHONE_NUMBER = "phoneNumber"; + private String phoneNumber; + + public static final String JSON_PROPERTY_PROJECT_ID = "projectId"; + private String projectId; + + public static final String JSON_PROPERTY_DISPLAY_NAME = "displayName"; + private String displayName; + + public static final String JSON_PROPERTY_REGION_CODE = "regionCode"; + private String regionCode; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type = "MOBILE"; + + public static final String JSON_PROPERTY_CAPABILITY = "capability"; + private List capability; + + public static final String JSON_PROPERTY_MONEY = "money"; + private MoneyDto money; + + public static final String JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS = "paymentIntervalMonths"; + private Integer paymentIntervalMonths; + + public static final String JSON_PROPERTY_NEXT_CHARGE_DATE = "nextChargeDate"; + private OffsetDateTime nextChargeDate; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expireAt"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_SMS_CONFIGURATION = "smsConfiguration"; + private SMSConfigurationDto smsConfiguration; + + public static final String JSON_PROPERTY_VOICE_CONFIGURATION = "voiceConfiguration"; + private VoiceConfigurationDto voiceConfiguration; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callbackUrl"; + private String callbackUrl; + + public ActiveNumberDto() {} + + @JsonCreator + public ActiveNumberDto( + @JsonProperty(JSON_PROPERTY_REGION_CODE) String regionCode, + @JsonProperty(JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS) Integer paymentIntervalMonths, + @JsonProperty(JSON_PROPERTY_NEXT_CHARGE_DATE) OffsetDateTime nextChargeDate, + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) OffsetDateTime expireAt) { + this(); + this.regionCode = regionCode; + this.paymentIntervalMonths = paymentIntervalMonths; + this.nextChargeDate = nextChargeDate; + this.expireAt = expireAt; + } + + public ActiveNumberDto phoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + return this; + } + + /** + * The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. Example: + * `+12025550134`. + * + * @return phoneNumber + */ + @JsonProperty(JSON_PROPERTY_PHONE_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhoneNumber() { + return phoneNumber; + } + + @JsonProperty(JSON_PROPERTY_PHONE_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPhoneNumber(String phoneNumber) { + this.phoneNumber = phoneNumber; + } + + public ActiveNumberDto projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Project ID. Your project ID can be found on your <a + * href=\"https://dashboard.sinch.com/settings/project-management\" + * target=\"_blank\">Sinch Customer Dashboard</a>. + * + * @return projectId + */ + @JsonProperty(JSON_PROPERTY_PROJECT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getProjectId() { + return projectId; + } + + @JsonProperty(JSON_PROPERTY_PROJECT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public ActiveNumberDto displayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * User supplied name for the phone number. + * + * @return displayName + */ + @JsonProperty(JSON_PROPERTY_DISPLAY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDisplayName() { + return displayName; + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + /** + * ISO 3166-1 alpha-2 country code of the phone number. Example `US`, `GB` or + * `SE`. + * + * @return regionCode + */ + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRegionCode() { + return regionCode; + } + + public ActiveNumberDto type(String type) { + this.type = type; + return this; + } + + /** + * The number type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ActiveNumberDto capability(List capability) { + this.capability = capability; + return this; + } + + public ActiveNumberDto addCapabilityItem(String capabilityItem) { + if (this.capability == null) { + this.capability = new ArrayList<>(); + } + this.capability.add(capabilityItem); + return this; + } + + /** + * The capability of the number. + * + * @return capability + */ + @JsonProperty(JSON_PROPERTY_CAPABILITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getCapability() { + return capability; + } + + @JsonProperty(JSON_PROPERTY_CAPABILITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCapability(List capability) { + this.capability = capability; + } + + public ActiveNumberDto money(MoneyDto money) { + this.money = money; + return this; + } + + /** + * Get money + * + * @return money + */ + @JsonProperty(JSON_PROPERTY_MONEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MoneyDto getMoney() { + return money; + } + + @JsonProperty(JSON_PROPERTY_MONEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMoney(MoneyDto money) { + this.money = money; + } + + /** + * How often the recurring price is charged in months. + * + * @return paymentIntervalMonths + */ + @JsonProperty(JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPaymentIntervalMonths() { + return paymentIntervalMonths; + } + + /** + * The date of the next charge. + * + * @return nextChargeDate + */ + @JsonProperty(JSON_PROPERTY_NEXT_CHARGE_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getNextChargeDate() { + return nextChargeDate; + } + + /** + * The timestamp when the subscription will expire if an expiration date has been set. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + public ActiveNumberDto smsConfiguration(SMSConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + /** + * Get smsConfiguration + * + * @return smsConfiguration + */ + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SMSConfigurationDto getSmsConfiguration() { + return smsConfiguration; + } + + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSmsConfiguration(SMSConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + } + + public ActiveNumberDto voiceConfiguration(VoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + /** + * Get voiceConfiguration + * + * @return voiceConfiguration + */ + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VoiceConfigurationDto getVoiceConfiguration() { + return voiceConfiguration; + } + + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVoiceConfiguration(VoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + } + + public ActiveNumberDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * The active number's callback URL to be called for provisioning / deprovisioning updates + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** Return true if this ActiveNumber object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActiveNumberDto activeNumber = (ActiveNumberDto) o; + return Objects.equals(this.phoneNumber, activeNumber.phoneNumber) + && Objects.equals(this.projectId, activeNumber.projectId) + && Objects.equals(this.displayName, activeNumber.displayName) + && Objects.equals(this.regionCode, activeNumber.regionCode) + && Objects.equals(this.type, activeNumber.type) + && Objects.equals(this.capability, activeNumber.capability) + && Objects.equals(this.money, activeNumber.money) + && Objects.equals(this.paymentIntervalMonths, activeNumber.paymentIntervalMonths) + && Objects.equals(this.nextChargeDate, activeNumber.nextChargeDate) + && Objects.equals(this.expireAt, activeNumber.expireAt) + && Objects.equals(this.smsConfiguration, activeNumber.smsConfiguration) + && Objects.equals(this.voiceConfiguration, activeNumber.voiceConfiguration) + && Objects.equals(this.callbackUrl, activeNumber.callbackUrl); + } + + @Override + public int hashCode() { + return Objects.hash( + phoneNumber, + projectId, + displayName, + regionCode, + type, + capability, + money, + paymentIntervalMonths, + nextChargeDate, + expireAt, + smsConfiguration, + voiceConfiguration, + callbackUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActiveNumberDto {\n"); + sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" capability: ").append(toIndentedString(capability)).append("\n"); + sb.append(" money: ").append(toIndentedString(money)).append("\n"); + sb.append(" paymentIntervalMonths: ") + .append(toIndentedString(paymentIntervalMonths)) + .append("\n"); + sb.append(" nextChargeDate: ").append(toIndentedString(nextChargeDate)).append("\n"); + sb.append(" expireAt: ").append(toIndentedString(expireAt)).append("\n"); + sb.append(" smsConfiguration: ").append(toIndentedString(smsConfiguration)).append("\n"); + sb.append(" voiceConfiguration: ").append(toIndentedString(voiceConfiguration)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberRequestDto.java new file mode 100644 index 00000000..22264c93 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumberRequestDto.java @@ -0,0 +1,145 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** The phone number that has been rented by a customer and assigned to a project. */ +@JsonPropertyOrder({ + ActiveNumberRequestDto.JSON_PROPERTY_DISPLAY_NAME, + ActiveNumberRequestDto.JSON_PROPERTY_SMS_CONFIGURATION, + ActiveNumberRequestDto.JSON_PROPERTY_VOICE_CONFIGURATION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ActiveNumberRequestDto { + public static final String JSON_PROPERTY_DISPLAY_NAME = "displayName"; + private String displayName; + + public static final String JSON_PROPERTY_SMS_CONFIGURATION = "smsConfiguration"; + private SMSConfigurationDto smsConfiguration; + + public static final String JSON_PROPERTY_VOICE_CONFIGURATION = "voiceConfiguration"; + private VoiceConfigurationDto voiceConfiguration; + + public ActiveNumberRequestDto() {} + + public ActiveNumberRequestDto displayName(String displayName) { + this.displayName = displayName; + return this; + } + + /** + * User supplied name for the phone number. + * + * @return displayName + */ + @JsonProperty(JSON_PROPERTY_DISPLAY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDisplayName() { + return displayName; + } + + @JsonProperty(JSON_PROPERTY_DISPLAY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public ActiveNumberRequestDto smsConfiguration(SMSConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + /** + * Get smsConfiguration + * + * @return smsConfiguration + */ + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SMSConfigurationDto getSmsConfiguration() { + return smsConfiguration; + } + + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSmsConfiguration(SMSConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + } + + public ActiveNumberRequestDto voiceConfiguration(VoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + /** + * Get voiceConfiguration + * + * @return voiceConfiguration + */ + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VoiceConfigurationDto getVoiceConfiguration() { + return voiceConfiguration; + } + + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVoiceConfiguration(VoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + } + + /** Return true if this ActiveNumberRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActiveNumberRequestDto activeNumberRequest = (ActiveNumberRequestDto) o; + return Objects.equals(this.displayName, activeNumberRequest.displayName) + && Objects.equals(this.smsConfiguration, activeNumberRequest.smsConfiguration) + && Objects.equals(this.voiceConfiguration, activeNumberRequest.voiceConfiguration); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, smsConfiguration, voiceConfiguration); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActiveNumberRequestDto {\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" smsConfiguration: ").append(toIndentedString(smsConfiguration)).append("\n"); + sb.append(" voiceConfiguration: ").append(toIndentedString(voiceConfiguration)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumbersResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumbersResponseDto.java new file mode 100644 index 00000000..f7f513d9 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ActiveNumbersResponseDto.java @@ -0,0 +1,155 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Response message to list your active phone numbers. */ +@JsonPropertyOrder({ + ActiveNumbersResponseDto.JSON_PROPERTY_ACTIVE_NUMBERS, + ActiveNumbersResponseDto.JSON_PROPERTY_NEXT_PAGE_TOKEN, + ActiveNumbersResponseDto.JSON_PROPERTY_TOTAL_SIZE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ActiveNumbersResponseDto { + public static final String JSON_PROPERTY_ACTIVE_NUMBERS = "activeNumbers"; + private List activeNumbers; + + public static final String JSON_PROPERTY_NEXT_PAGE_TOKEN = "nextPageToken"; + private String nextPageToken; + + public static final String JSON_PROPERTY_TOTAL_SIZE = "totalSize"; + private Integer totalSize; + + public ActiveNumbersResponseDto() {} + + public ActiveNumbersResponseDto activeNumbers(List activeNumbers) { + this.activeNumbers = activeNumbers; + return this; + } + + public ActiveNumbersResponseDto addActiveNumbersItem(ActiveNumberDto activeNumbersItem) { + if (this.activeNumbers == null) { + this.activeNumbers = new ArrayList<>(); + } + this.activeNumbers.add(activeNumbersItem); + return this; + } + + /** + * List of numbers associated to the client project specified in `ListActiveNumbers`. + * + * @return activeNumbers + */ + @JsonProperty(JSON_PROPERTY_ACTIVE_NUMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getActiveNumbers() { + return activeNumbers; + } + + @JsonProperty(JSON_PROPERTY_ACTIVE_NUMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setActiveNumbers(List activeNumbers) { + this.activeNumbers = activeNumbers; + } + + public ActiveNumbersResponseDto nextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + /** + * Get nextPageToken + * + * @return nextPageToken + */ + @JsonProperty(JSON_PROPERTY_NEXT_PAGE_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getNextPageToken() { + return nextPageToken; + } + + @JsonProperty(JSON_PROPERTY_NEXT_PAGE_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNextPageToken(String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + public ActiveNumbersResponseDto totalSize(Integer totalSize) { + this.totalSize = totalSize; + return this; + } + + /** + * Get totalSize + * + * @return totalSize + */ + @JsonProperty(JSON_PROPERTY_TOTAL_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getTotalSize() { + return totalSize; + } + + @JsonProperty(JSON_PROPERTY_TOTAL_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTotalSize(Integer totalSize) { + this.totalSize = totalSize; + } + + /** Return true if this ActiveNumbersResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActiveNumbersResponseDto activeNumbersResponse = (ActiveNumbersResponseDto) o; + return Objects.equals(this.activeNumbers, activeNumbersResponse.activeNumbers) + && Objects.equals(this.nextPageToken, activeNumbersResponse.nextPageToken) + && Objects.equals(this.totalSize, activeNumbersResponse.totalSize); + } + + @Override + public int hashCode() { + return Objects.hash(activeNumbers, nextPageToken, totalSize); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActiveNumbersResponseDto {\n"); + sb.append(" activeNumbers: ").append(toIndentedString(activeNumbers)).append("\n"); + sb.append(" nextPageToken: ").append(toIndentedString(nextPageToken)).append("\n"); + sb.append(" totalSize: ").append(toIndentedString(totalSize)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumberDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumberDto.java new file mode 100644 index 00000000..c3294ddf --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumberDto.java @@ -0,0 +1,289 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * The phone numbers that are available to be rented in the <a + * href=\"https://dashboard.sinch.com/numbers/buy-numbers\" + * target=\"_blank\">Sinch Customer Dashboard</a> or via the public numbers + * API. + */ +@JsonPropertyOrder({ + AvailableNumberDto.JSON_PROPERTY_PHONE_NUMBER, + AvailableNumberDto.JSON_PROPERTY_REGION_CODE, + AvailableNumberDto.JSON_PROPERTY_TYPE, + AvailableNumberDto.JSON_PROPERTY_CAPABILITY, + AvailableNumberDto.JSON_PROPERTY_SETUP_PRICE, + AvailableNumberDto.JSON_PROPERTY_MONTHLY_PRICE, + AvailableNumberDto.JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS, + AvailableNumberDto.JSON_PROPERTY_SUPPORTING_DOCUMENTATION_REQUIRED +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AvailableNumberDto { + public static final String JSON_PROPERTY_PHONE_NUMBER = "phoneNumber"; + private String phoneNumber; + + public static final String JSON_PROPERTY_REGION_CODE = "regionCode"; + private String regionCode; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type = "LOCAL"; + + public static final String JSON_PROPERTY_CAPABILITY = "capability"; + private List capability; + + public static final String JSON_PROPERTY_SETUP_PRICE = "setupPrice"; + private MoneyDto setupPrice; + + public static final String JSON_PROPERTY_MONTHLY_PRICE = "monthlyPrice"; + private MoneyDto monthlyPrice; + + public static final String JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS = "paymentIntervalMonths"; + private Integer paymentIntervalMonths; + + public static final String JSON_PROPERTY_SUPPORTING_DOCUMENTATION_REQUIRED = + "supportingDocumentationRequired"; + private Boolean supportingDocumentationRequired; + + public AvailableNumberDto() {} + + @JsonCreator + public AvailableNumberDto( + @JsonProperty(JSON_PROPERTY_PHONE_NUMBER) String phoneNumber, + @JsonProperty(JSON_PROPERTY_REGION_CODE) String regionCode, + @JsonProperty(JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS) Integer paymentIntervalMonths, + @JsonProperty(JSON_PROPERTY_SUPPORTING_DOCUMENTATION_REQUIRED) + Boolean supportingDocumentationRequired) { + this(); + this.phoneNumber = phoneNumber; + this.regionCode = regionCode; + this.paymentIntervalMonths = paymentIntervalMonths; + this.supportingDocumentationRequired = supportingDocumentationRequired; + } + + /** + * The phone number in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format with leading `+`. Example + * `+12025550134`. + * + * @return phoneNumber + */ + @JsonProperty(JSON_PROPERTY_PHONE_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPhoneNumber() { + return phoneNumber; + } + + /** + * ISO 3166-1 alpha-2 country code of the phone number. Example: `US`, `GB` or + * `SE`. + * + * @return regionCode + */ + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRegionCode() { + return regionCode; + } + + public AvailableNumberDto type(String type) { + this.type = type; + return this; + } + + /** + * The number type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public AvailableNumberDto capability(List capability) { + this.capability = capability; + return this; + } + + public AvailableNumberDto addCapabilityItem(String capabilityItem) { + if (this.capability == null) { + this.capability = new ArrayList<>(); + } + this.capability.add(capabilityItem); + return this; + } + + /** + * The capability of the number. + * + * @return capability + */ + @JsonProperty(JSON_PROPERTY_CAPABILITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getCapability() { + return capability; + } + + @JsonProperty(JSON_PROPERTY_CAPABILITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCapability(List capability) { + this.capability = capability; + } + + public AvailableNumberDto setupPrice(MoneyDto setupPrice) { + this.setupPrice = setupPrice; + return this; + } + + /** + * Get setupPrice + * + * @return setupPrice + */ + @JsonProperty(JSON_PROPERTY_SETUP_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MoneyDto getSetupPrice() { + return setupPrice; + } + + @JsonProperty(JSON_PROPERTY_SETUP_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSetupPrice(MoneyDto setupPrice) { + this.setupPrice = setupPrice; + } + + public AvailableNumberDto monthlyPrice(MoneyDto monthlyPrice) { + this.monthlyPrice = monthlyPrice; + return this; + } + + /** + * Get monthlyPrice + * + * @return monthlyPrice + */ + @JsonProperty(JSON_PROPERTY_MONTHLY_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MoneyDto getMonthlyPrice() { + return monthlyPrice; + } + + @JsonProperty(JSON_PROPERTY_MONTHLY_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMonthlyPrice(MoneyDto monthlyPrice) { + this.monthlyPrice = monthlyPrice; + } + + /** + * How often the recurring price is charged in months. + * + * @return paymentIntervalMonths + */ + @JsonProperty(JSON_PROPERTY_PAYMENT_INTERVAL_MONTHS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPaymentIntervalMonths() { + return paymentIntervalMonths; + } + + /** + * Whether or not supplementary documentation will be required to complete the number rental. + * + * @return supportingDocumentationRequired + */ + @JsonProperty(JSON_PROPERTY_SUPPORTING_DOCUMENTATION_REQUIRED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getSupportingDocumentationRequired() { + return supportingDocumentationRequired; + } + + /** Return true if this AvailableNumber object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AvailableNumberDto availableNumber = (AvailableNumberDto) o; + return Objects.equals(this.phoneNumber, availableNumber.phoneNumber) + && Objects.equals(this.regionCode, availableNumber.regionCode) + && Objects.equals(this.type, availableNumber.type) + && Objects.equals(this.capability, availableNumber.capability) + && Objects.equals(this.setupPrice, availableNumber.setupPrice) + && Objects.equals(this.monthlyPrice, availableNumber.monthlyPrice) + && Objects.equals(this.paymentIntervalMonths, availableNumber.paymentIntervalMonths) + && Objects.equals( + this.supportingDocumentationRequired, availableNumber.supportingDocumentationRequired); + } + + @Override + public int hashCode() { + return Objects.hash( + phoneNumber, + regionCode, + type, + capability, + setupPrice, + monthlyPrice, + paymentIntervalMonths, + supportingDocumentationRequired); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AvailableNumberDto {\n"); + sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" capability: ").append(toIndentedString(capability)).append("\n"); + sb.append(" setupPrice: ").append(toIndentedString(setupPrice)).append("\n"); + sb.append(" monthlyPrice: ").append(toIndentedString(monthlyPrice)).append("\n"); + sb.append(" paymentIntervalMonths: ") + .append(toIndentedString(paymentIntervalMonths)) + .append("\n"); + sb.append(" supportingDocumentationRequired: ") + .append(toIndentedString(supportingDocumentationRequired)) + .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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumbersResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumbersResponseDto.java new file mode 100644 index 00000000..612739ce --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableNumbersResponseDto.java @@ -0,0 +1,98 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Response message to list available phone numbers. */ +@JsonPropertyOrder({AvailableNumbersResponseDto.JSON_PROPERTY_AVAILABLE_NUMBERS}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AvailableNumbersResponseDto { + public static final String JSON_PROPERTY_AVAILABLE_NUMBERS = "availableNumbers"; + private List availableNumbers; + + public AvailableNumbersResponseDto() {} + + public AvailableNumbersResponseDto availableNumbers(List availableNumbers) { + this.availableNumbers = availableNumbers; + return this; + } + + public AvailableNumbersResponseDto addAvailableNumbersItem( + AvailableNumberDto availableNumbersItem) { + if (this.availableNumbers == null) { + this.availableNumbers = new ArrayList<>(); + } + this.availableNumbers.add(availableNumbersItem); + return this; + } + + /** + * List of available phone numbers. + * + * @return availableNumbers + */ + @JsonProperty(JSON_PROPERTY_AVAILABLE_NUMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAvailableNumbers() { + return availableNumbers; + } + + @JsonProperty(JSON_PROPERTY_AVAILABLE_NUMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAvailableNumbers(List availableNumbers) { + this.availableNumbers = availableNumbers; + } + + /** Return true if this AvailableNumbersResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AvailableNumbersResponseDto availableNumbersResponse = (AvailableNumbersResponseDto) o; + return Objects.equals(this.availableNumbers, availableNumbersResponse.availableNumbers); + } + + @Override + public int hashCode() { + return Objects.hash(availableNumbers); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AvailableNumbersResponseDto {\n"); + sb.append(" availableNumbers: ").append(toIndentedString(availableNumbers)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableRegionDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableRegionDto.java new file mode 100644 index 00000000..d09cacf1 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/AvailableRegionDto.java @@ -0,0 +1,126 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.List; +import java.util.Objects; + +/** A region for which numbers are provided. */ +@JsonPropertyOrder({ + AvailableRegionDto.JSON_PROPERTY_REGION_CODE, + AvailableRegionDto.JSON_PROPERTY_REGION_NAME, + AvailableRegionDto.JSON_PROPERTY_TYPES +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AvailableRegionDto { + public static final String JSON_PROPERTY_REGION_CODE = "regionCode"; + private String regionCode; + + public static final String JSON_PROPERTY_REGION_NAME = "regionName"; + private String regionName; + + public static final String JSON_PROPERTY_TYPES = "types"; + private List types; + + public AvailableRegionDto() {} + + @JsonCreator + public AvailableRegionDto( + @JsonProperty(JSON_PROPERTY_REGION_CODE) String regionCode, + @JsonProperty(JSON_PROPERTY_REGION_NAME) String regionName, + @JsonProperty(JSON_PROPERTY_TYPES) List types) { + this(); + this.regionCode = regionCode; + this.regionName = regionName; + this.types = types; + } + + /** + * ISO 3166-1 alpha-2 region code. Examples: `US`, `GB` or `SE`. + * + * @return regionCode + */ + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRegionCode() { + return regionCode; + } + + /** + * Display name of the region. Examples: United States, United Kingdom or Sweden. + * + * @return regionName + */ + @JsonProperty(JSON_PROPERTY_REGION_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRegionName() { + return regionName; + } + + /** + * A list of the different number types available. Examples: `MOBILE` or + * `LOCAL`. + * + * @return types + */ + @JsonProperty(JSON_PROPERTY_TYPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTypes() { + return types; + } + + /** Return true if this AvailableRegion object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AvailableRegionDto availableRegion = (AvailableRegionDto) o; + return Objects.equals(this.regionCode, availableRegion.regionCode) + && Objects.equals(this.regionName, availableRegion.regionName) + && Objects.equals(this.types, availableRegion.types); + } + + @Override + public int hashCode() { + return Objects.hash(regionCode, regionName, types); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AvailableRegionDto {\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" regionName: ").append(toIndentedString(regionName)).append("\n"); + sb.append(" types: ").append(toIndentedString(types)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/BadRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/BadRequestDto.java new file mode 100644 index 00000000..a7e760fb --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/BadRequestDto.java @@ -0,0 +1,159 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** BadRequestDto */ +@JsonPropertyOrder({BadRequestDto.JSON_PROPERTY_TYPE, BadRequestDto.JSON_PROPERTY_FIELD_VIOLATIONS}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BadRequestDto { + /** Gets or Sets type */ + public enum TypeEnum { + BADREQUEST("BadRequest"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_FIELD_VIOLATIONS = "fieldViolations"; + private List fieldViolations; + + public BadRequestDto() {} + + public BadRequestDto type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public BadRequestDto fieldViolations(List fieldViolations) { + this.fieldViolations = fieldViolations; + return this; + } + + public BadRequestDto addFieldViolationsItem(FieldViolationDto fieldViolationsItem) { + if (this.fieldViolations == null) { + this.fieldViolations = new ArrayList<>(); + } + this.fieldViolations.add(fieldViolationsItem); + return this; + } + + /** + * Get fieldViolations + * + * @return fieldViolations + */ + @JsonProperty(JSON_PROPERTY_FIELD_VIOLATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getFieldViolations() { + return fieldViolations; + } + + @JsonProperty(JSON_PROPERTY_FIELD_VIOLATIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFieldViolations(List fieldViolations) { + this.fieldViolations = fieldViolations; + } + + /** Return true if this BadRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BadRequestDto badRequest = (BadRequestDto) o; + return Objects.equals(this.type, badRequest.type) + && Objects.equals(this.fieldViolations, badRequest.fieldViolations); + } + + @Override + public int hashCode() { + return Objects.hash(type, fieldViolations); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BadRequestDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" fieldViolations: ").append(toIndentedString(fieldViolations)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationDto.java new file mode 100644 index 00000000..1ed9e273 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationDto.java @@ -0,0 +1,117 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Response message containing the callbacks configuration for a specific project */ +@JsonPropertyOrder({ + CallbackConfigurationDto.JSON_PROPERTY_PROJECT_ID, + CallbackConfigurationDto.JSON_PROPERTY_HMAC_SECRET +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CallbackConfigurationDto { + public static final String JSON_PROPERTY_PROJECT_ID = "projectId"; + private String projectId; + + public static final String JSON_PROPERTY_HMAC_SECRET = "hmacSecret"; + private String hmacSecret; + + public CallbackConfigurationDto() {} + + public CallbackConfigurationDto projectId(String projectId) { + this.projectId = projectId; + return this; + } + + /** + * Get projectId + * + * @return projectId + */ + @JsonProperty(JSON_PROPERTY_PROJECT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getProjectId() { + return projectId; + } + + @JsonProperty(JSON_PROPERTY_PROJECT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public CallbackConfigurationDto hmacSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + return this; + } + + /** + * Get hmacSecret + * + * @return hmacSecret + */ + @JsonProperty(JSON_PROPERTY_HMAC_SECRET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getHmacSecret() { + return hmacSecret; + } + + @JsonProperty(JSON_PROPERTY_HMAC_SECRET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setHmacSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + } + + /** Return true if this CallbackConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CallbackConfigurationDto callbackConfiguration = (CallbackConfigurationDto) o; + return Objects.equals(this.projectId, callbackConfiguration.projectId) + && Objects.equals(this.hmacSecret, callbackConfiguration.hmacSecret); + } + + @Override + public int hashCode() { + return Objects.hash(projectId, hmacSecret); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CallbackConfigurationDto {\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" hmacSecret: ").append(toIndentedString(hmacSecret)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationUpdateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationUpdateDto.java new file mode 100644 index 00000000..6f8401fe --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/CallbackConfigurationUpdateDto.java @@ -0,0 +1,87 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** The request to update the callbacks configuration for the current project */ +@JsonPropertyOrder({CallbackConfigurationUpdateDto.JSON_PROPERTY_HMAC_SECRET}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CallbackConfigurationUpdateDto { + public static final String JSON_PROPERTY_HMAC_SECRET = "hmacSecret"; + private String hmacSecret; + + public CallbackConfigurationUpdateDto() {} + + public CallbackConfigurationUpdateDto hmacSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + return this; + } + + /** + * The HMAC secret to be updated for the specified project + * + * @return hmacSecret + */ + @JsonProperty(JSON_PROPERTY_HMAC_SECRET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getHmacSecret() { + return hmacSecret; + } + + @JsonProperty(JSON_PROPERTY_HMAC_SECRET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setHmacSecret(String hmacSecret) { + this.hmacSecret = hmacSecret; + } + + /** Return true if this CallbackConfigurationUpdate object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CallbackConfigurationUpdateDto callbackConfigurationUpdate = (CallbackConfigurationUpdateDto) o; + return Objects.equals(this.hmacSecret, callbackConfigurationUpdate.hmacSecret); + } + + @Override + public int hashCode() { + return Objects.hash(hmacSecret); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CallbackConfigurationUpdateDto {\n"); + sb.append(" hmacSecret: ").append(toIndentedString(hmacSecret)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/FieldViolationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/FieldViolationDto.java new file mode 100644 index 00000000..07ea0a5e --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/FieldViolationDto.java @@ -0,0 +1,117 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** FieldViolationDto */ +@JsonPropertyOrder({ + FieldViolationDto.JSON_PROPERTY_FIELD, + FieldViolationDto.JSON_PROPERTY_DESCRIPTION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FieldViolationDto { + public static final String JSON_PROPERTY_FIELD = "field"; + private String field; + + public static final String JSON_PROPERTY_DESCRIPTION = "description"; + private String description; + + public FieldViolationDto() {} + + public FieldViolationDto field(String field) { + this.field = field; + return this; + } + + /** + * Get field + * + * @return field + */ + @JsonProperty(JSON_PROPERTY_FIELD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getField() { + return field; + } + + @JsonProperty(JSON_PROPERTY_FIELD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setField(String field) { + this.field = field; + } + + public FieldViolationDto description(String description) { + this.description = description; + return this; + } + + /** + * Get description + * + * @return description + */ + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDescription() { + return description; + } + + @JsonProperty(JSON_PROPERTY_DESCRIPTION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDescription(String description) { + this.description = description; + } + + /** Return true if this FieldViolation object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FieldViolationDto fieldViolation = (FieldViolationDto) o; + return Objects.equals(this.field, fieldViolation.field) + && Objects.equals(this.description, fieldViolation.description); + } + + @Override + public int hashCode() { + return Objects.hash(field, description); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FieldViolationDto {\n"); + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorDto.java new file mode 100644 index 00000000..c9d7f455 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorDto.java @@ -0,0 +1,87 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** InternalErrorDto */ +@JsonPropertyOrder({InternalErrorDto.JSON_PROPERTY_ERROR}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InternalErrorDto { + public static final String JSON_PROPERTY_ERROR = "error"; + private InternalErrorErrorDto error; + + public InternalErrorDto() {} + + public InternalErrorDto error(InternalErrorErrorDto error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InternalErrorErrorDto getError() { + return error; + } + + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setError(InternalErrorErrorDto error) { + this.error = error; + } + + /** Return true if this InternalError object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InternalErrorDto internalError = (InternalErrorDto) o; + return Objects.equals(this.error, internalError.error); + } + + @Override + public int hashCode() { + return Objects.hash(error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InternalErrorDto {\n"); + sb.append(" error: ").append(toIndentedString(error)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorErrorDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorErrorDto.java new file mode 100644 index 00000000..bec8fa96 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InternalErrorErrorDto.java @@ -0,0 +1,253 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** InternalErrorErrorDto */ +@JsonPropertyOrder({ + InternalErrorErrorDto.JSON_PROPERTY_CODE, + InternalErrorErrorDto.JSON_PROPERTY_MESSAGE, + InternalErrorErrorDto.JSON_PROPERTY_STATUS, + InternalErrorErrorDto.JSON_PROPERTY_DETAILS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InternalErrorErrorDto { + /** Gets or Sets code */ + public enum CodeEnum { + NUMBER_500(500), + + NUMBER_unknown_default_open_api(11184809); + + private Integer value; + + CodeEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static CodeEnum fromValue(Integer value) { + for (CodeEnum b : CodeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return NUMBER_unknown_default_open_api; + } + } + + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + /** Gets or Sets status */ + public enum StatusEnum { + INTERNAL("INTERNAL"), + + UNKNOWN("UNKNOWN"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + public static final String JSON_PROPERTY_DETAILS = "details"; + private List details; + + public InternalErrorErrorDto() {} + + public InternalErrorErrorDto code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + public InternalErrorErrorDto message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + public InternalErrorErrorDto status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(String status) { + this.status = status; + } + + public InternalErrorErrorDto details(List details) { + this.details = details; + return this; + } + + public InternalErrorErrorDto addDetailsItem(Object detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * + * @return details + */ + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDetails() { + return details; + } + + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetails(List details) { + this.details = details; + } + + /** Return true if this InternalError_error object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InternalErrorErrorDto internalErrorError = (InternalErrorErrorDto) o; + return Objects.equals(this.code, internalErrorError.code) + && Objects.equals(this.message, internalErrorError.message) + && Objects.equals(this.status, internalErrorError.status) + && Objects.equals(this.details, internalErrorError.details); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, status, details); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InternalErrorErrorDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentDto.java new file mode 100644 index 00000000..a7fee3ae --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentDto.java @@ -0,0 +1,87 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** InvalidArgumentDto */ +@JsonPropertyOrder({InvalidArgumentDto.JSON_PROPERTY_ERROR}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InvalidArgumentDto { + public static final String JSON_PROPERTY_ERROR = "error"; + private InvalidArgumentErrorDto error; + + public InvalidArgumentDto() {} + + public InvalidArgumentDto error(InvalidArgumentErrorDto error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InvalidArgumentErrorDto getError() { + return error; + } + + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setError(InvalidArgumentErrorDto error) { + this.error = error; + } + + /** Return true if this InvalidArgument object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvalidArgumentDto invalidArgument = (InvalidArgumentDto) o; + return Objects.equals(this.error, invalidArgument.error); + } + + @Override + public int hashCode() { + return Objects.hash(error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InvalidArgumentDto {\n"); + sb.append(" error: ").append(toIndentedString(error)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentErrorDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentErrorDto.java new file mode 100644 index 00000000..94735f07 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/InvalidArgumentErrorDto.java @@ -0,0 +1,251 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** InvalidArgumentErrorDto */ +@JsonPropertyOrder({ + InvalidArgumentErrorDto.JSON_PROPERTY_CODE, + InvalidArgumentErrorDto.JSON_PROPERTY_MESSAGE, + InvalidArgumentErrorDto.JSON_PROPERTY_STATUS, + InvalidArgumentErrorDto.JSON_PROPERTY_DETAILS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InvalidArgumentErrorDto { + /** Gets or Sets code */ + public enum CodeEnum { + NUMBER_400(400), + + NUMBER_unknown_default_open_api(11184809); + + private Integer value; + + CodeEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static CodeEnum fromValue(Integer value) { + for (CodeEnum b : CodeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return NUMBER_unknown_default_open_api; + } + } + + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + /** Gets or Sets status */ + public enum StatusEnum { + INVALID_ARGUMENT("INVALID_ARGUMENT"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + public static final String JSON_PROPERTY_DETAILS = "details"; + private List details; + + public InvalidArgumentErrorDto() {} + + public InvalidArgumentErrorDto code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + public InvalidArgumentErrorDto message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + public InvalidArgumentErrorDto status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(String status) { + this.status = status; + } + + public InvalidArgumentErrorDto details(List details) { + this.details = details; + return this; + } + + public InvalidArgumentErrorDto addDetailsItem(BadRequestDto detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * + * @return details + */ + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDetails() { + return details; + } + + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetails(List details) { + this.details = details; + } + + /** Return true if this InvalidArgument_error object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InvalidArgumentErrorDto invalidArgumentError = (InvalidArgumentErrorDto) o; + return Objects.equals(this.code, invalidArgumentError.code) + && Objects.equals(this.message, invalidArgumentError.message) + && Objects.equals(this.status, invalidArgumentError.status) + && Objects.equals(this.details, invalidArgumentError.details); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, status, details); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InvalidArgumentErrorDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableNumberRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableNumberRequestDto.java new file mode 100644 index 00000000..03c04511 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableNumberRequestDto.java @@ -0,0 +1,218 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Available numbers schema base. */ +@JsonPropertyOrder({ + ListAvailableNumberRequestDto.JSON_PROPERTY_NUMBER_PATTERN, + ListAvailableNumberRequestDto.JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN, + ListAvailableNumberRequestDto.JSON_PROPERTY_REGION_CODE, + ListAvailableNumberRequestDto.JSON_PROPERTY_TYPE, + ListAvailableNumberRequestDto.JSON_PROPERTY_CAPABILITIES +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ListAvailableNumberRequestDto { + public static final String JSON_PROPERTY_NUMBER_PATTERN = "NumberPattern"; + private NumberPatternPatternDto numberPattern; + + public static final String JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN = + "NumberPatternSearchPattern"; + private NumberPatternSearchPatternDto numberPatternSearchPattern; + + public static final String JSON_PROPERTY_REGION_CODE = "regionCode"; + private String regionCode; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type = "MOBILE"; + + public static final String JSON_PROPERTY_CAPABILITIES = "capabilities"; + private List capabilities; + + public ListAvailableNumberRequestDto() {} + + public ListAvailableNumberRequestDto numberPattern(NumberPatternPatternDto numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + /** + * Get numberPattern + * + * @return numberPattern + */ + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NumberPatternPatternDto getNumberPattern() { + return numberPattern; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberPattern(NumberPatternPatternDto numberPattern) { + this.numberPattern = numberPattern; + } + + public ListAvailableNumberRequestDto numberPatternSearchPattern( + NumberPatternSearchPatternDto numberPatternSearchPattern) { + this.numberPatternSearchPattern = numberPatternSearchPattern; + return this; + } + + /** + * Get numberPatternSearchPattern + * + * @return numberPatternSearchPattern + */ + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NumberPatternSearchPatternDto getNumberPatternSearchPattern() { + return numberPatternSearchPattern; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberPatternSearchPattern( + NumberPatternSearchPatternDto numberPatternSearchPattern) { + this.numberPatternSearchPattern = numberPatternSearchPattern; + } + + public ListAvailableNumberRequestDto regionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + /** + * Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: + * `US`, `GB` or `SE`. + * + * @return regionCode + */ + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRegionCode() { + return regionCode; + } + + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRegionCode(String regionCode) { + this.regionCode = regionCode; + } + + public ListAvailableNumberRequestDto type(String type) { + this.type = type; + return this; + } + + /** + * Number type to filter by. `MOBILE`, `LOCAL` or `TOLL_FREE`. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ListAvailableNumberRequestDto capabilities(List capabilities) { + this.capabilities = capabilities; + return this; + } + + public ListAvailableNumberRequestDto addCapabilitiesItem(String capabilitiesItem) { + if (this.capabilities == null) { + this.capabilities = new ArrayList<>(); + } + this.capabilities.add(capabilitiesItem); + return this; + } + + /** + * Number capabilities to filter by, `SMS` and/or `VOICE`. + * + * @return capabilities + */ + @JsonProperty(JSON_PROPERTY_CAPABILITIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getCapabilities() { + return capabilities; + } + + @JsonProperty(JSON_PROPERTY_CAPABILITIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCapabilities(List capabilities) { + this.capabilities = capabilities; + } + + /** Return true if this ListAvailableNumberRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListAvailableNumberRequestDto listAvailableNumberRequest = (ListAvailableNumberRequestDto) o; + return Objects.equals(this.numberPattern, listAvailableNumberRequest.numberPattern) + && Objects.equals( + this.numberPatternSearchPattern, listAvailableNumberRequest.numberPatternSearchPattern) + && Objects.equals(this.regionCode, listAvailableNumberRequest.regionCode) + && Objects.equals(this.type, listAvailableNumberRequest.type) + && Objects.equals(this.capabilities, listAvailableNumberRequest.capabilities); + } + + @Override + public int hashCode() { + return Objects.hash(numberPattern, numberPatternSearchPattern, regionCode, type, capabilities); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListAvailableNumberRequestDto {\n"); + sb.append(" numberPattern: ").append(toIndentedString(numberPattern)).append("\n"); + sb.append(" numberPatternSearchPattern: ") + .append(toIndentedString(numberPatternSearchPattern)) + .append("\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" capabilities: ").append(toIndentedString(capabilities)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableRegionsResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableRegionsResponseDto.java new file mode 100644 index 00000000..f76c376a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ListAvailableRegionsResponseDto.java @@ -0,0 +1,96 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Response message to list regions for which numbers are provided. */ +@JsonPropertyOrder({ListAvailableRegionsResponseDto.JSON_PROPERTY_AVAILABLE_REGIONS}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ListAvailableRegionsResponseDto { + public static final String JSON_PROPERTY_AVAILABLE_REGIONS = "availableRegions"; + private List availableRegions; + + public ListAvailableRegionsResponseDto() {} + + public ListAvailableRegionsResponseDto availableRegions( + List availableRegions) { + this.availableRegions = availableRegions; + return this; + } + + public ListAvailableRegionsResponseDto addAvailableRegionsItem( + AvailableRegionDto availableRegionsItem) { + if (this.availableRegions == null) { + this.availableRegions = new ArrayList<>(); + } + this.availableRegions.add(availableRegionsItem); + return this; + } + + /** @return availableRegions */ + @JsonProperty(JSON_PROPERTY_AVAILABLE_REGIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAvailableRegions() { + return availableRegions; + } + + @JsonProperty(JSON_PROPERTY_AVAILABLE_REGIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAvailableRegions(List availableRegions) { + this.availableRegions = availableRegions; + } + + /** Return true if this ListAvailableRegionsResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListAvailableRegionsResponseDto listAvailableRegionsResponse = + (ListAvailableRegionsResponseDto) o; + return Objects.equals(this.availableRegions, listAvailableRegionsResponse.availableRegions); + } + + @Override + public int hashCode() { + return Objects.hash(availableRegions); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListAvailableRegionsResponseDto {\n"); + sb.append(" availableRegions: ").append(toIndentedString(availableRegions)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/MoneyDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/MoneyDto.java new file mode 100644 index 00000000..4352b74f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/MoneyDto.java @@ -0,0 +1,118 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** An object giving details on currency code and the amount charged. */ +@JsonPropertyOrder({MoneyDto.JSON_PROPERTY_CURRENCY_CODE, MoneyDto.JSON_PROPERTY_AMOUNT}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MoneyDto { + public static final String JSON_PROPERTY_CURRENCY_CODE = "currencyCode"; + private String currencyCode; + + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private String amount; + + public MoneyDto() {} + + public MoneyDto currencyCode(String currencyCode) { + this.currencyCode = currencyCode; + return this; + } + + /** + * The 3-letter currency code defined in <a + * href=\"https://www.iso.org/iso-4217-currency-codes.html\" + * target=\"_blank\">ISO 4217</a>. + * + * @return currencyCode + */ + @JsonProperty(JSON_PROPERTY_CURRENCY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCurrencyCode() { + return currencyCode; + } + + @JsonProperty(JSON_PROPERTY_CURRENCY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCurrencyCode(String currencyCode) { + this.currencyCode = currencyCode; + } + + public MoneyDto amount(String amount) { + this.amount = amount; + return this; + } + + /** + * The amount in decimal form. For example `2.00`. There are no guarantees on the + * precision unless documented by the message origin. The amount cannot be updated and is + * read-only. + * + * @return amount + */ + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAmount() { + return amount; + } + + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(String amount) { + this.amount = amount; + } + + /** Return true if this Money object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MoneyDto money = (MoneyDto) o; + return Objects.equals(this.currencyCode, money.currencyCode) + && Objects.equals(this.amount, money.amount); + } + + @Override + public int hashCode() { + return Objects.hash(currencyCode, amount); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MoneyDto {\n"); + sb.append(" currencyCode: ").append(toIndentedString(currencyCode)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundDto.java new file mode 100644 index 00000000..127f029d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundDto.java @@ -0,0 +1,87 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** NotFoundDto */ +@JsonPropertyOrder({NotFoundDto.JSON_PROPERTY_ERROR}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NotFoundDto { + public static final String JSON_PROPERTY_ERROR = "error"; + private NotFoundErrorDto error; + + public NotFoundDto() {} + + public NotFoundDto error(NotFoundErrorDto error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public NotFoundErrorDto getError() { + return error; + } + + @JsonProperty(JSON_PROPERTY_ERROR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setError(NotFoundErrorDto error) { + this.error = error; + } + + /** Return true if this NotFound object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotFoundDto notFound = (NotFoundDto) o; + return Objects.equals(this.error, notFound.error); + } + + @Override + public int hashCode() { + return Objects.hash(error); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotFoundDto {\n"); + sb.append(" error: ").append(toIndentedString(error)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundErrorDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundErrorDto.java new file mode 100644 index 00000000..75e7b6c5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NotFoundErrorDto.java @@ -0,0 +1,251 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** NotFoundErrorDto */ +@JsonPropertyOrder({ + NotFoundErrorDto.JSON_PROPERTY_CODE, + NotFoundErrorDto.JSON_PROPERTY_MESSAGE, + NotFoundErrorDto.JSON_PROPERTY_STATUS, + NotFoundErrorDto.JSON_PROPERTY_DETAILS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NotFoundErrorDto { + /** Gets or Sets code */ + public enum CodeEnum { + NUMBER_404(404), + + NUMBER_unknown_default_open_api(11184809); + + private Integer value; + + CodeEnum(Integer value) { + this.value = value; + } + + @JsonValue + public Integer getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static CodeEnum fromValue(Integer value) { + for (CodeEnum b : CodeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return NUMBER_unknown_default_open_api; + } + } + + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + /** Gets or Sets status */ + public enum StatusEnum { + NOT_FOUND("NOT_FOUND"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + public static final String JSON_PROPERTY_DETAILS = "details"; + private List details; + + public NotFoundErrorDto() {} + + public NotFoundErrorDto code(Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(Integer code) { + this.code = code; + } + + public NotFoundErrorDto message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + public NotFoundErrorDto status(String status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(String status) { + this.status = status; + } + + public NotFoundErrorDto details(List details) { + this.details = details; + return this; + } + + public NotFoundErrorDto addDetailsItem(Object detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * + * @return details + */ + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDetails() { + return details; + } + + @JsonProperty(JSON_PROPERTY_DETAILS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDetails(List details) { + this.details = details; + } + + /** Return true if this NotFound_error object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotFoundErrorDto notFoundError = (NotFoundErrorDto) o; + return Objects.equals(this.code, notFoundError.code) + && Objects.equals(this.message, notFoundError.message) + && Objects.equals(this.status, notFoundError.status) + && Objects.equals(this.details, notFoundError.details); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, status, details); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotFoundErrorDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternPatternDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternPatternDto.java new file mode 100644 index 00000000..d58043ce --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternPatternDto.java @@ -0,0 +1,87 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Sequence of digits to search for. */ +@JsonPropertyOrder({NumberPatternPatternDto.JSON_PROPERTY_NUMBER_PATTERN}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NumberPatternPatternDto { + public static final String JSON_PROPERTY_NUMBER_PATTERN = "NumberPattern"; + private SearchPatternDto numberPattern; + + public NumberPatternPatternDto() {} + + public NumberPatternPatternDto numberPattern(SearchPatternDto numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + /** + * Get numberPattern + * + * @return numberPattern + */ + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SearchPatternDto getNumberPattern() { + return numberPattern; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberPattern(SearchPatternDto numberPattern) { + this.numberPattern = numberPattern; + } + + /** Return true if this numberPattern.pattern object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberPatternPatternDto numberPatternPattern = (NumberPatternPatternDto) o; + return Objects.equals(this.numberPattern, numberPatternPattern.numberPattern); + } + + @Override + public int hashCode() { + return Objects.hash(numberPattern); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberPatternPatternDto {\n"); + sb.append(" numberPattern: ").append(toIndentedString(numberPattern)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternSearchPatternDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternSearchPatternDto.java new file mode 100644 index 00000000..102989df --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/NumberPatternSearchPatternDto.java @@ -0,0 +1,96 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** + * Search pattern to apply. Options include, `START`, `CONTAIN`, and + * `END`. + */ +@JsonPropertyOrder({NumberPatternSearchPatternDto.JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class NumberPatternSearchPatternDto { + public static final String JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN = + "NumberPatternSearchPattern"; + private String numberPatternSearchPattern; + + public NumberPatternSearchPatternDto() {} + + public NumberPatternSearchPatternDto numberPatternSearchPattern( + String numberPatternSearchPattern) { + this.numberPatternSearchPattern = numberPatternSearchPattern; + return this; + } + + /** + * The pattern to apply to searches. Options include, `START`, `CONTAIN`, and + * `END`. + * + * @return numberPatternSearchPattern + */ + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getNumberPatternSearchPattern() { + return numberPatternSearchPattern; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberPatternSearchPattern(String numberPatternSearchPattern) { + this.numberPatternSearchPattern = numberPatternSearchPattern; + } + + /** Return true if this numberPattern.searchPattern object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NumberPatternSearchPatternDto numberPatternSearchPattern = (NumberPatternSearchPatternDto) o; + return Objects.equals( + this.numberPatternSearchPattern, numberPatternSearchPattern.numberPatternSearchPattern); + } + + @Override + public int hashCode() { + return Objects.hash(numberPatternSearchPattern); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NumberPatternSearchPatternDto {\n"); + sb.append(" numberPatternSearchPattern: ") + .append(toIndentedString(numberPatternSearchPattern)) + .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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ProvisioningStatusDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ProvisioningStatusDto.java new file mode 100644 index 00000000..5c477592 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ProvisioningStatusDto.java @@ -0,0 +1,58 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The provisioning status. It will be either `WAITING`, `IN_PROGRESS` or + * `FAILED`. If the provisioning fails, a reason for the failure will be provided. + */ +public enum ProvisioningStatusDto { + PROVISIONING_STATUS_UNSPECIFIED("PROVISIONING_STATUS_UNSPECIFIED"), + + WAITING("WAITING"), + + IN_PROGRESS("IN_PROGRESS"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ProvisioningStatusDto(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ProvisioningStatusDto fromValue(String value) { + for (ProvisioningStatusDto b : ProvisioningStatusDto.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestDto.java new file mode 100644 index 00000000..4c8a4a44 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestDto.java @@ -0,0 +1,279 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * Request message for searching and renting in one go any number that matches the search criteria. + */ +@JsonPropertyOrder({ + RentAnyNumberRequestDto.JSON_PROPERTY_REGION_CODE, + RentAnyNumberRequestDto.JSON_PROPERTY_TYPE, + RentAnyNumberRequestDto.JSON_PROPERTY_NUMBER_PATTERN, + RentAnyNumberRequestDto.JSON_PROPERTY_CAPABILITIES, + RentAnyNumberRequestDto.JSON_PROPERTY_SMS_CONFIGURATION, + RentAnyNumberRequestDto.JSON_PROPERTY_VOICE_CONFIGURATION, + RentAnyNumberRequestDto.JSON_PROPERTY_CALLBACK_URL +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RentAnyNumberRequestDto { + public static final String JSON_PROPERTY_REGION_CODE = "regionCode"; + private String regionCode; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type = "LOCAL"; + + public static final String JSON_PROPERTY_NUMBER_PATTERN = "numberPattern"; + private SearchPatternDto numberPattern; + + public static final String JSON_PROPERTY_CAPABILITIES = "capabilities"; + private List capabilities; + + public static final String JSON_PROPERTY_SMS_CONFIGURATION = "smsConfiguration"; + private RentAnyNumberRequestSmsConfigurationDto smsConfiguration; + + public static final String JSON_PROPERTY_VOICE_CONFIGURATION = "voiceConfiguration"; + private RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callbackUrl"; + private String callbackUrl; + + public RentAnyNumberRequestDto() {} + + public RentAnyNumberRequestDto regionCode(String regionCode) { + this.regionCode = regionCode; + return this; + } + + /** + * Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: + * `US`, `GB` or `SE`. + * + * @return regionCode + */ + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRegionCode() { + return regionCode; + } + + @JsonProperty(JSON_PROPERTY_REGION_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRegionCode(String regionCode) { + this.regionCode = regionCode; + } + + public RentAnyNumberRequestDto type(String type) { + this.type = type; + return this; + } + + /** + * Number type to filter by. `MOBILE`, `LOCAL` or `TOLL_FREE`. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public RentAnyNumberRequestDto numberPattern(SearchPatternDto numberPattern) { + this.numberPattern = numberPattern; + return this; + } + + /** + * Get numberPattern + * + * @return numberPattern + */ + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public SearchPatternDto getNumberPattern() { + return numberPattern; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberPattern(SearchPatternDto numberPattern) { + this.numberPattern = numberPattern; + } + + public RentAnyNumberRequestDto capabilities(List capabilities) { + this.capabilities = capabilities; + return this; + } + + public RentAnyNumberRequestDto addCapabilitiesItem(String capabilitiesItem) { + if (this.capabilities == null) { + this.capabilities = new ArrayList<>(); + } + this.capabilities.add(capabilitiesItem); + return this; + } + + /** + * Number capabilities to filter by, `SMS` and/or `VOICE`. + * + * @return capabilities + */ + @JsonProperty(JSON_PROPERTY_CAPABILITIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getCapabilities() { + return capabilities; + } + + @JsonProperty(JSON_PROPERTY_CAPABILITIES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCapabilities(List capabilities) { + this.capabilities = capabilities; + } + + public RentAnyNumberRequestDto smsConfiguration( + RentAnyNumberRequestSmsConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + /** + * Get smsConfiguration + * + * @return smsConfiguration + */ + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RentAnyNumberRequestSmsConfigurationDto getSmsConfiguration() { + return smsConfiguration; + } + + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSmsConfiguration(RentAnyNumberRequestSmsConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + } + + public RentAnyNumberRequestDto voiceConfiguration( + RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + /** + * Get voiceConfiguration + * + * @return voiceConfiguration + */ + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RentAnyNumberRequestVoiceConfigurationDto getVoiceConfiguration() { + return voiceConfiguration; + } + + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVoiceConfiguration(RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + } + + public RentAnyNumberRequestDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Get callbackUrl + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** Return true if this RentAnyNumberRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RentAnyNumberRequestDto rentAnyNumberRequest = (RentAnyNumberRequestDto) o; + return Objects.equals(this.regionCode, rentAnyNumberRequest.regionCode) + && Objects.equals(this.type, rentAnyNumberRequest.type) + && Objects.equals(this.numberPattern, rentAnyNumberRequest.numberPattern) + && Objects.equals(this.capabilities, rentAnyNumberRequest.capabilities) + && Objects.equals(this.smsConfiguration, rentAnyNumberRequest.smsConfiguration) + && Objects.equals(this.voiceConfiguration, rentAnyNumberRequest.voiceConfiguration) + && Objects.equals(this.callbackUrl, rentAnyNumberRequest.callbackUrl); + } + + @Override + public int hashCode() { + return Objects.hash( + regionCode, + type, + numberPattern, + capabilities, + smsConfiguration, + voiceConfiguration, + callbackUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RentAnyNumberRequestDto {\n"); + sb.append(" regionCode: ").append(toIndentedString(regionCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" numberPattern: ").append(toIndentedString(numberPattern)).append("\n"); + sb.append(" capabilities: ").append(toIndentedString(capabilities)).append("\n"); + sb.append(" smsConfiguration: ").append(toIndentedString(smsConfiguration)).append("\n"); + sb.append(" voiceConfiguration: ").append(toIndentedString(voiceConfiguration)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestSmsConfigurationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestSmsConfigurationDto.java new file mode 100644 index 00000000..2bb0d1fe --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestSmsConfigurationDto.java @@ -0,0 +1,119 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** RentAnyNumberRequestSmsConfigurationDto */ +@JsonPropertyOrder({ + RentAnyNumberRequestSmsConfigurationDto.JSON_PROPERTY_SERVICE_PLAN_ID, + RentAnyNumberRequestSmsConfigurationDto.JSON_PROPERTY_CAMPAIGN_ID +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RentAnyNumberRequestSmsConfigurationDto { + public static final String JSON_PROPERTY_SERVICE_PLAN_ID = "servicePlanId"; + private String servicePlanId; + + public static final String JSON_PROPERTY_CAMPAIGN_ID = "campaignId"; + private String campaignId; + + public RentAnyNumberRequestSmsConfigurationDto() {} + + public RentAnyNumberRequestSmsConfigurationDto servicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + return this; + } + + /** + * The SMS service that the number will be linked to. The `servicePlanId` can be found + * in the [Sinch Customer Dashboard](https://dashboard.sinch.com/sms/api/rest). + * + * @return servicePlanId + */ + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getServicePlanId() { + return servicePlanId; + } + + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setServicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + } + + public RentAnyNumberRequestSmsConfigurationDto campaignId(String campaignId) { + this.campaignId = campaignId; + return this; + } + + /** + * The 10DLC campaign ID that the number will be linked to. + * + * @return campaignId + */ + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCampaignId() { + return campaignId; + } + + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCampaignId(String campaignId) { + this.campaignId = campaignId; + } + + /** Return true if this RentAnyNumberRequest_smsConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RentAnyNumberRequestSmsConfigurationDto rentAnyNumberRequestSmsConfiguration = + (RentAnyNumberRequestSmsConfigurationDto) o; + return Objects.equals(this.servicePlanId, rentAnyNumberRequestSmsConfiguration.servicePlanId) + && Objects.equals(this.campaignId, rentAnyNumberRequestSmsConfiguration.campaignId); + } + + @Override + public int hashCode() { + return Objects.hash(servicePlanId, campaignId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RentAnyNumberRequestSmsConfigurationDto {\n"); + sb.append(" servicePlanId: ").append(toIndentedString(servicePlanId)).append("\n"); + sb.append(" campaignId: ").append(toIndentedString(campaignId)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestVoiceConfigurationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestVoiceConfigurationDto.java new file mode 100644 index 00000000..7ddcb2f2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentAnyNumberRequestVoiceConfigurationDto.java @@ -0,0 +1,90 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** RentAnyNumberRequestVoiceConfigurationDto */ +@JsonPropertyOrder({RentAnyNumberRequestVoiceConfigurationDto.JSON_PROPERTY_APP_ID}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RentAnyNumberRequestVoiceConfigurationDto { + public static final String JSON_PROPERTY_APP_ID = "appId"; + private String appId; + + public RentAnyNumberRequestVoiceConfigurationDto() {} + + public RentAnyNumberRequestVoiceConfigurationDto appId(String appId) { + this.appId = appId; + return this; + } + + /** + * Your app ID for the Voice API. The `appId` can be found in your <a + * href=\"https://dashboard.sinch.com/voice/apps\" + * target=\"_blank\">Sinch Customer Dashboard</a> under Voice, then apps. + * + * @return appId + */ + @JsonProperty(JSON_PROPERTY_APP_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getAppId() { + return appId; + } + + @JsonProperty(JSON_PROPERTY_APP_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setAppId(String appId) { + this.appId = appId; + } + + /** Return true if this RentAnyNumberRequest_voiceConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RentAnyNumberRequestVoiceConfigurationDto rentAnyNumberRequestVoiceConfiguration = + (RentAnyNumberRequestVoiceConfigurationDto) o; + return Objects.equals(this.appId, rentAnyNumberRequestVoiceConfiguration.appId); + } + + @Override + public int hashCode() { + return Objects.hash(appId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RentAnyNumberRequestVoiceConfigurationDto {\n"); + sb.append(" appId: ").append(toIndentedString(appId)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentNumberRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentNumberRequestDto.java new file mode 100644 index 00000000..477a45ac --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/RentNumberRequestDto.java @@ -0,0 +1,147 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Request message for renting a phone number. */ +@JsonPropertyOrder({ + RentNumberRequestDto.JSON_PROPERTY_SMS_CONFIGURATION, + RentNumberRequestDto.JSON_PROPERTY_VOICE_CONFIGURATION, + RentNumberRequestDto.JSON_PROPERTY_CALLBACK_URL +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RentNumberRequestDto { + public static final String JSON_PROPERTY_SMS_CONFIGURATION = "smsConfiguration"; + private RentAnyNumberRequestSmsConfigurationDto smsConfiguration; + + public static final String JSON_PROPERTY_VOICE_CONFIGURATION = "voiceConfiguration"; + private RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callbackUrl"; + private String callbackUrl; + + public RentNumberRequestDto() {} + + public RentNumberRequestDto smsConfiguration( + RentAnyNumberRequestSmsConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + return this; + } + + /** + * Get smsConfiguration + * + * @return smsConfiguration + */ + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RentAnyNumberRequestSmsConfigurationDto getSmsConfiguration() { + return smsConfiguration; + } + + @JsonProperty(JSON_PROPERTY_SMS_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSmsConfiguration(RentAnyNumberRequestSmsConfigurationDto smsConfiguration) { + this.smsConfiguration = smsConfiguration; + } + + public RentNumberRequestDto voiceConfiguration( + RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + return this; + } + + /** + * Get voiceConfiguration + * + * @return voiceConfiguration + */ + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RentAnyNumberRequestVoiceConfigurationDto getVoiceConfiguration() { + return voiceConfiguration; + } + + @JsonProperty(JSON_PROPERTY_VOICE_CONFIGURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVoiceConfiguration(RentAnyNumberRequestVoiceConfigurationDto voiceConfiguration) { + this.voiceConfiguration = voiceConfiguration; + } + + public RentNumberRequestDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * The callback URL to be called for a rented number provisioning / deprovisioning operations + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** Return true if this RentNumberRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RentNumberRequestDto rentNumberRequest = (RentNumberRequestDto) o; + return Objects.equals(this.smsConfiguration, rentNumberRequest.smsConfiguration) + && Objects.equals(this.voiceConfiguration, rentNumberRequest.voiceConfiguration) + && Objects.equals(this.callbackUrl, rentNumberRequest.callbackUrl); + } + + @Override + public int hashCode() { + return Objects.hash(smsConfiguration, voiceConfiguration, callbackUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RentNumberRequestDto {\n"); + sb.append(" smsConfiguration: ").append(toIndentedString(smsConfiguration)).append("\n"); + sb.append(" voiceConfiguration: ").append(toIndentedString(voiceConfiguration)).append("\n"); + sb.append(" callbackUrl: ").append(toIndentedString(callbackUrl)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SMSConfigurationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SMSConfigurationDto.java new file mode 100644 index 00000000..a7d1842d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SMSConfigurationDto.java @@ -0,0 +1,159 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** + * The current SMS configuration for this number. Once the `servicePlanId` is sent, it + * enters scheduled provisioning. The status of scheduled provisioning will show under a + * `scheduledProvisioning` object if it's still running. Once processed successfully, + * the `servicePlanId` sent will appear directly under the `smsConfiguration` + * object. + */ +@JsonPropertyOrder({ + SMSConfigurationDto.JSON_PROPERTY_SERVICE_PLAN_ID, + SMSConfigurationDto.JSON_PROPERTY_CAMPAIGN_ID, + SMSConfigurationDto.JSON_PROPERTY_SCHEDULED_PROVISIONING +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SMSConfigurationDto { + public static final String JSON_PROPERTY_SERVICE_PLAN_ID = "servicePlanId"; + private String servicePlanId; + + public static final String JSON_PROPERTY_CAMPAIGN_ID = "campaignId"; + private String campaignId; + + public static final String JSON_PROPERTY_SCHEDULED_PROVISIONING = "scheduledProvisioning"; + private ScheduledProvisioningDto scheduledProvisioning; + + public SMSConfigurationDto() {} + + public SMSConfigurationDto servicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + return this; + } + + /** + * The `servicePlanId` can be found in the <a + * href=\"https://dashboard.sinch.com/sms/api/rest\" + * target=\"_blank\">Sinch Customer Dashboard</a>. The service plan ID is + * what ties this number to the configured SMS service. + * + * @return servicePlanId + */ + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getServicePlanId() { + return servicePlanId; + } + + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setServicePlanId(String servicePlanId) { + this.servicePlanId = servicePlanId; + } + + public SMSConfigurationDto campaignId(String campaignId) { + this.campaignId = campaignId; + return this; + } + + /** + * Only for US virtual numbers. This campaign ID relates to <a + * href=\"https://community.sinch.com/t5/10DLC/What-is-10DLC/ta-p/7845\" + * target=\"_blank\">10DLC numbers</a>. So, it is the current campaign ID + * for this number. The `campaignId` is found on your TCR platform. + * + * @return campaignId + */ + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCampaignId() { + return campaignId; + } + + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCampaignId(String campaignId) { + this.campaignId = campaignId; + } + + public SMSConfigurationDto scheduledProvisioning(ScheduledProvisioningDto scheduledProvisioning) { + this.scheduledProvisioning = scheduledProvisioning; + return this; + } + + /** + * Get scheduledProvisioning + * + * @return scheduledProvisioning + */ + @JsonProperty(JSON_PROPERTY_SCHEDULED_PROVISIONING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ScheduledProvisioningDto getScheduledProvisioning() { + return scheduledProvisioning; + } + + @JsonProperty(JSON_PROPERTY_SCHEDULED_PROVISIONING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setScheduledProvisioning(ScheduledProvisioningDto scheduledProvisioning) { + this.scheduledProvisioning = scheduledProvisioning; + } + + /** Return true if this SMSConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SMSConfigurationDto smSConfiguration = (SMSConfigurationDto) o; + return Objects.equals(this.servicePlanId, smSConfiguration.servicePlanId) + && Objects.equals(this.campaignId, smSConfiguration.campaignId) + && Objects.equals(this.scheduledProvisioning, smSConfiguration.scheduledProvisioning); + } + + @Override + public int hashCode() { + return Objects.hash(servicePlanId, campaignId, scheduledProvisioning); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SMSConfigurationDto {\n"); + sb.append(" servicePlanId: ").append(toIndentedString(servicePlanId)).append("\n"); + sb.append(" campaignId: ").append(toIndentedString(campaignId)).append("\n"); + sb.append(" scheduledProvisioning: ") + .append(toIndentedString(scheduledProvisioning)) + .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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledProvisioningDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledProvisioningDto.java new file mode 100644 index 00000000..55da275d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledProvisioningDto.java @@ -0,0 +1,176 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.List; +import java.util.Objects; + +/** + * Represents the ongoing or failed scheduled provisioning job. This field will be empty if both the + * was successfully provisioned into the SMS platform and linked to the 10DLC campaign. + */ +@JsonPropertyOrder({ + ScheduledProvisioningDto.JSON_PROPERTY_SERVICE_PLAN_ID, + ScheduledProvisioningDto.JSON_PROPERTY_CAMPAIGN_ID, + ScheduledProvisioningDto.JSON_PROPERTY_STATUS, + ScheduledProvisioningDto.JSON_PROPERTY_LAST_UPDATED_TIME, + ScheduledProvisioningDto.JSON_PROPERTY_ERROR_CODES +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ScheduledProvisioningDto { + public static final String JSON_PROPERTY_SERVICE_PLAN_ID = "servicePlanId"; + private String servicePlanId; + + public static final String JSON_PROPERTY_CAMPAIGN_ID = "campaignId"; + private String campaignId; + + public static final String JSON_PROPERTY_STATUS = "status"; + private ProvisioningStatusDto status; + + public static final String JSON_PROPERTY_LAST_UPDATED_TIME = "lastUpdatedTime"; + private OffsetDateTime lastUpdatedTime; + + public static final String JSON_PROPERTY_ERROR_CODES = "errorCodes"; + private List errorCodes; + + public ScheduledProvisioningDto() {} + + @JsonCreator + public ScheduledProvisioningDto( + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) String servicePlanId, + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) String campaignId, + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) OffsetDateTime lastUpdatedTime, + @JsonProperty(JSON_PROPERTY_ERROR_CODES) List errorCodes) { + this(); + this.servicePlanId = servicePlanId; + this.campaignId = campaignId; + this.lastUpdatedTime = lastUpdatedTime; + this.errorCodes = errorCodes; + } + + /** + * The SMS service plan that the scheduled provisioning job will configured with the number. + * + * @return servicePlanId + */ + @JsonProperty(JSON_PROPERTY_SERVICE_PLAN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getServicePlanId() { + return servicePlanId; + } + + /** + * TCR campaign ID that the scheduled provisioning job will configure with the number. + * + * @return campaignId + */ + @JsonProperty(JSON_PROPERTY_CAMPAIGN_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCampaignId() { + return campaignId; + } + + public ScheduledProvisioningDto status(ProvisioningStatusDto status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ProvisioningStatusDto getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(ProvisioningStatusDto status) { + this.status = status; + } + + /** + * Timestamp when the status was last updated. + * + * @return lastUpdatedTime + */ + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getLastUpdatedTime() { + return lastUpdatedTime; + } + + /** + * Get errorCodes + * + * @return errorCodes + */ + @JsonProperty(JSON_PROPERTY_ERROR_CODES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getErrorCodes() { + return errorCodes; + } + + /** Return true if this ScheduledProvisioning object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScheduledProvisioningDto scheduledProvisioning = (ScheduledProvisioningDto) o; + return Objects.equals(this.servicePlanId, scheduledProvisioning.servicePlanId) + && Objects.equals(this.campaignId, scheduledProvisioning.campaignId) + && Objects.equals(this.status, scheduledProvisioning.status) + && Objects.equals(this.lastUpdatedTime, scheduledProvisioning.lastUpdatedTime) + && Objects.equals(this.errorCodes, scheduledProvisioning.errorCodes); + } + + @Override + public int hashCode() { + return Objects.hash(servicePlanId, campaignId, status, lastUpdatedTime, errorCodes); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScheduledProvisioningDto {\n"); + sb.append(" servicePlanId: ").append(toIndentedString(servicePlanId)).append("\n"); + sb.append(" campaignId: ").append(toIndentedString(campaignId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" lastUpdatedTime: ").append(toIndentedString(lastUpdatedTime)).append("\n"); + sb.append(" errorCodes: ").append(toIndentedString(errorCodes)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledVoiceProvisioningDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledVoiceProvisioningDto.java new file mode 100644 index 00000000..82ffe4fe --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/ScheduledVoiceProvisioningDto.java @@ -0,0 +1,139 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * Represents the ongoing or failed scheduled voice provisioning job. This field will be empty if + * the number was successfully provisioned provisioned for voice. + */ +@JsonPropertyOrder({ + ScheduledVoiceProvisioningDto.JSON_PROPERTY_APP_ID, + ScheduledVoiceProvisioningDto.JSON_PROPERTY_STATUS, + ScheduledVoiceProvisioningDto.JSON_PROPERTY_LAST_UPDATED_TIME +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ScheduledVoiceProvisioningDto { + public static final String JSON_PROPERTY_APP_ID = "appId"; + private String appId; + + public static final String JSON_PROPERTY_STATUS = "status"; + private ProvisioningStatusDto status; + + public static final String JSON_PROPERTY_LAST_UPDATED_TIME = "lastUpdatedTime"; + private OffsetDateTime lastUpdatedTime; + + public ScheduledVoiceProvisioningDto() {} + + @JsonCreator + public ScheduledVoiceProvisioningDto( + @JsonProperty(JSON_PROPERTY_APP_ID) String appId, + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) OffsetDateTime lastUpdatedTime) { + this(); + this.appId = appId; + this.lastUpdatedTime = lastUpdatedTime; + } + + /** + * Your app ID for the Voice API. The `appId` can be found in your <a + * href=\"https://dashboard.sinch.com/voice/apps\" + * target=\"_blank\">Sinch Customer Dashboard</a> under Voice, then apps. + * + * @return appId + */ + @JsonProperty(JSON_PROPERTY_APP_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAppId() { + return appId; + } + + public ScheduledVoiceProvisioningDto status(ProvisioningStatusDto status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ProvisioningStatusDto getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStatus(ProvisioningStatusDto status) { + this.status = status; + } + + /** + * Timestamp when the status was last updated. + * + * @return lastUpdatedTime + */ + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getLastUpdatedTime() { + return lastUpdatedTime; + } + + /** Return true if this ScheduledVoiceProvisioning object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScheduledVoiceProvisioningDto scheduledVoiceProvisioning = (ScheduledVoiceProvisioningDto) o; + return Objects.equals(this.appId, scheduledVoiceProvisioning.appId) + && Objects.equals(this.status, scheduledVoiceProvisioning.status) + && Objects.equals(this.lastUpdatedTime, scheduledVoiceProvisioning.lastUpdatedTime); + } + + @Override + public int hashCode() { + return Objects.hash(appId, status, lastUpdatedTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScheduledVoiceProvisioningDto {\n"); + sb.append(" appId: ").append(toIndentedString(appId)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" lastUpdatedTime: ").append(toIndentedString(lastUpdatedTime)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SearchPatternDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SearchPatternDto.java new file mode 100644 index 00000000..9fc285f5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SearchPatternDto.java @@ -0,0 +1,117 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** SearchPatternDto */ +@JsonPropertyOrder({ + SearchPatternDto.JSON_PROPERTY_PATTERN, + SearchPatternDto.JSON_PROPERTY_SEARCH_PATTERN +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SearchPatternDto { + public static final String JSON_PROPERTY_PATTERN = "pattern"; + private String pattern; + + public static final String JSON_PROPERTY_SEARCH_PATTERN = "searchPattern"; + private String searchPattern; + + public SearchPatternDto() {} + + public SearchPatternDto pattern(String pattern) { + this.pattern = pattern; + return this; + } + + /** + * Sequence of digits to search for. + * + * @return pattern + */ + @JsonProperty(JSON_PROPERTY_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPattern() { + return pattern; + } + + @JsonProperty(JSON_PROPERTY_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public SearchPatternDto searchPattern(String searchPattern) { + this.searchPattern = searchPattern; + return this; + } + + /** + * The pattern to apply to searches. + * + * @return searchPattern + */ + @JsonProperty(JSON_PROPERTY_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSearchPattern() { + return searchPattern; + } + + @JsonProperty(JSON_PROPERTY_SEARCH_PATTERN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSearchPattern(String searchPattern) { + this.searchPattern = searchPattern; + } + + /** Return true if this SearchPattern object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchPatternDto searchPattern = (SearchPatternDto) o; + return Objects.equals(this.pattern, searchPattern.pattern) + && Objects.equals(this.searchPattern, searchPattern.searchPattern); + } + + @Override + public int hashCode() { + return Objects.hash(pattern, searchPattern); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchPatternDto {\n"); + sb.append(" pattern: ").append(toIndentedString(pattern)).append("\n"); + sb.append(" searchPattern: ").append(toIndentedString(searchPattern)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SmsErrorCodeDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SmsErrorCodeDto.java new file mode 100644 index 00000000..ed6dac8e --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/SmsErrorCodeDto.java @@ -0,0 +1,83 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** The error codes that show the reason of failure of a scheduled provisioning */ +public enum SmsErrorCodeDto { + ERROR_CODE_UNSPECIFIED("ERROR_CODE_UNSPECIFIED"), + + INTERNAL_ERROR("INTERNAL_ERROR"), + + SMS_PROVISIONING_FAILED("SMS_PROVISIONING_FAILED"), + + CAMPAIGN_PROVISIONING_FAILED("CAMPAIGN_PROVISIONING_FAILED"), + + CAMPAIGN_NOT_AVAILABLE("CAMPAIGN_NOT_AVAILABLE"), + + EXCEEDED_10DLC_LIMIT("EXCEEDED_10DLC_LIMIT"), + + NUMBER_PROVISIONING_FAILED("NUMBER_PROVISIONING_FAILED"), + + PARTNER_SERVICE_UNAVAILABLE("PARTNER_SERVICE_UNAVAILABLE"), + + CAMPAIGN_PENDING_ACCEPTANCE("CAMPAIGN_PENDING_ACCEPTANCE"), + + MNO_SHARING_ERROR("MNO_SHARING_ERROR"), + + CAMPAIGN_EXPIRED("CAMPAIGN_EXPIRED"), + + CAMPAIGN_MNO_REJECTED("CAMPAIGN_MNO_REJECTED"), + + CAMPAIGN_MNO_SUSPENDED("CAMPAIGN_MNO_SUSPENDED"), + + CAMPAIGN_MNO_REVIEW("CAMPAIGN_MNO_REVIEW"), + + INSUFFICIENT_BALANCE("INSUFFICIENT_BALANCE"), + + MOCK_CAMPAIGN_NOT_ALLOWED("MOCK_CAMPAIGN_NOT_ALLOWED"), + + TFN_NOT_ALLOWED("TFN_NOT_ALLOWED"), + + INVALID_NNID("INVALID_NNID"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + SmsErrorCodeDto(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static SmsErrorCodeDto fromValue(String value) { + for (SmsErrorCodeDto b : SmsErrorCodeDto.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/VoiceConfigurationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/VoiceConfigurationDto.java new file mode 100644 index 00000000..09837f2f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/numbers/models/dto/v1/VoiceConfigurationDto.java @@ -0,0 +1,157 @@ +/* + * Numbers | Sinch + * An API service for getting, listing and managing Sinch virtual numbers. + * + * The version of the OpenAPI document: 1.0 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.numbers.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** + * The current voice configuration for this number. During scheduled provisioning, the app ID value + * may be empty in a response if it is still processing or if it has failed. The status of scheduled + * provisioning will show under a `scheduledVoiceProvisioning` object if it's still + * running. Once processed successfully, the `appId` sent will appear directly under the + * `voiceConfiguration` object. + */ +@JsonPropertyOrder({ + VoiceConfigurationDto.JSON_PROPERTY_APP_ID, + VoiceConfigurationDto.JSON_PROPERTY_LAST_UPDATED_TIME, + VoiceConfigurationDto.JSON_PROPERTY_SCHEDULED_VOICE_PROVISIONING +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VoiceConfigurationDto { + public static final String JSON_PROPERTY_APP_ID = "appId"; + private String appId; + + public static final String JSON_PROPERTY_LAST_UPDATED_TIME = "lastUpdatedTime"; + private OffsetDateTime lastUpdatedTime; + + public static final String JSON_PROPERTY_SCHEDULED_VOICE_PROVISIONING = + "scheduledVoiceProvisioning"; + private ScheduledVoiceProvisioningDto scheduledVoiceProvisioning; + + public VoiceConfigurationDto() {} + + @JsonCreator + public VoiceConfigurationDto( + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) OffsetDateTime lastUpdatedTime) { + this(); + this.lastUpdatedTime = lastUpdatedTime; + } + + public VoiceConfigurationDto appId(String appId) { + this.appId = appId; + return this; + } + + /** + * Your app ID for the Voice API. The `appId` can be found in your <a + * href=\"https://dashboard.sinch.com/voice/apps\" + * target=\"_blank\">Sinch Customer Dashboard</a> under Voice, then apps. + * + * @return appId + */ + @JsonProperty(JSON_PROPERTY_APP_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAppId() { + return appId; + } + + @JsonProperty(JSON_PROPERTY_APP_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAppId(String appId) { + this.appId = appId; + } + + /** + * Timestamp when the status was last updated. + * + * @return lastUpdatedTime + */ + @JsonProperty(JSON_PROPERTY_LAST_UPDATED_TIME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getLastUpdatedTime() { + return lastUpdatedTime; + } + + public VoiceConfigurationDto scheduledVoiceProvisioning( + ScheduledVoiceProvisioningDto scheduledVoiceProvisioning) { + this.scheduledVoiceProvisioning = scheduledVoiceProvisioning; + return this; + } + + /** + * Get scheduledVoiceProvisioning + * + * @return scheduledVoiceProvisioning + */ + @JsonProperty(JSON_PROPERTY_SCHEDULED_VOICE_PROVISIONING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ScheduledVoiceProvisioningDto getScheduledVoiceProvisioning() { + return scheduledVoiceProvisioning; + } + + @JsonProperty(JSON_PROPERTY_SCHEDULED_VOICE_PROVISIONING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setScheduledVoiceProvisioning( + ScheduledVoiceProvisioningDto scheduledVoiceProvisioning) { + this.scheduledVoiceProvisioning = scheduledVoiceProvisioning; + } + + /** Return true if this VoiceConfiguration object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VoiceConfigurationDto voiceConfiguration = (VoiceConfigurationDto) o; + return Objects.equals(this.appId, voiceConfiguration.appId) + && Objects.equals(this.lastUpdatedTime, voiceConfiguration.lastUpdatedTime) + && Objects.equals( + this.scheduledVoiceProvisioning, voiceConfiguration.scheduledVoiceProvisioning); + } + + @Override + public int hashCode() { + return Objects.hash(appId, lastUpdatedTime, scheduledVoiceProvisioning); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VoiceConfigurationDto {\n"); + sb.append(" appId: ").append(toIndentedString(appId)).append("\n"); + sb.append(" lastUpdatedTime: ").append(toIndentedString(lastUpdatedTime)).append("\n"); + sb.append(" scheduledVoiceProvisioning: ") + .append(toIndentedString(scheduledVoiceProvisioning)) + .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 "); + } +} 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 new file mode 100644 index 00000000..993ad73e --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java @@ -0,0 +1,772 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.sms.models.dto.v1.ApiBatchListDto; +import com.sinch.sdk.domains.sms.models.dto.v1.ApiDeliveryFeedbackDto; +import com.sinch.sdk.domains.sms.models.dto.v1.DryRun200ResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.DryRunRequestDto; +import com.sinch.sdk.domains.sms.models.dto.v1.SendSMS201ResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.SendSMSRequestDto; +import com.sinch.sdk.domains.sms.models.dto.v1.UpdateBatchMessageRequestDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BatchesApi { + + private static final Logger LOGGER = Logger.getLogger(BatchesApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public BatchesApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @return SendSMS201ResponseDto + * @throws ApiException if fails to make API call + */ + public SendSMS201ResponseDto cancelBatchMessage(String servicePlanId, String batchId) + throws ApiException { + HttpRequest httpRequest = cancelBatchMessageRequestBuilder(servicePlanId, batchId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 cancelBatchMessageRequestBuilder(String servicePlanId, String batchId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling cancelBatchMessage"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling cancelBatchMessage"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.DELETE, + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @param apiDeliveryFeedbackDto A list of phone numbers (MSISDNs) that successfully received the + * message. (required) + * @throws ApiException if fails to make API call + */ + public void deliveryFeedback( + String servicePlanId, String batchId, ApiDeliveryFeedbackDto apiDeliveryFeedbackDto) + throws ApiException { + HttpRequest httpRequest = + deliveryFeedbackRequestBuilder(servicePlanId, batchId, apiDeliveryFeedbackDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 deliveryFeedbackRequestBuilder( + String servicePlanId, String batchId, ApiDeliveryFeedbackDto apiDeliveryFeedbackDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling deliveryFeedback"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling deliveryFeedback"); + } + // verify the required parameter 'apiDeliveryFeedbackDto' is set + if (apiDeliveryFeedbackDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'apiDeliveryFeedbackDto' when calling deliveryFeedback"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_feedback" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, apiDeliveryFeedbackDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @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 dryRunRequestDto (optional) + * @return DryRun200ResponseDto + * @throws ApiException if fails to make API call + */ + public DryRun200ResponseDto dryRun( + String servicePlanId, + Boolean perRecipient, + Integer numberOfRecipients, + DryRunRequestDto dryRunRequestDto) + throws ApiException { + HttpRequest httpRequest = + dryRunRequestBuilder(servicePlanId, perRecipient, numberOfRecipients, dryRunRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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( + String servicePlanId, + Boolean perRecipient, + Integer numberOfRecipients, + DryRunRequestDto dryRunRequestDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling dryRun"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/dry_run" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, dryRunRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @return SendSMS201ResponseDto + * @throws ApiException if fails to make API call + */ + public SendSMS201ResponseDto getBatchMessage(String servicePlanId, String batchId) + throws ApiException { + HttpRequest httpRequest = getBatchMessageRequestBuilder(servicePlanId, batchId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getBatchMessageRequestBuilder(String servicePlanId, String batchId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling getBatchMessage"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling getBatchMessage"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param page The page number starting from 0. (optional) + * @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 ApiBatchListDto + * @throws ApiException if fails to make API call + */ + public ApiBatchListDto listBatches( + String servicePlanId, + Integer page, + Integer pageSize, + String from, + String startDate, + String endDate, + String clientReference) + throws ApiException { + HttpRequest httpRequest = + listBatchesRequestBuilder( + servicePlanId, page, pageSize, from, startDate, endDate, clientReference); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 listBatchesRequestBuilder( + String servicePlanId, + Integer page, + Integer pageSize, + String from, + String startDate, + String endDate, + String clientReference) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling listBatches"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @param dryRunRequestDto (optional) + * @return SendSMS201ResponseDto + * @throws ApiException if fails to make API call + */ + public SendSMS201ResponseDto replaceBatch( + String servicePlanId, String batchId, DryRunRequestDto dryRunRequestDto) throws ApiException { + HttpRequest httpRequest = replaceBatchRequestBuilder(servicePlanId, batchId, dryRunRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 replaceBatchRequestBuilder( + String servicePlanId, String batchId, DryRunRequestDto dryRunRequestDto) throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling replaceBatch"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling replaceBatch"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, dryRunRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.PUT, + 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 <a + * href=\"/docs/sms/api-reference/#base-url\" + * target=\"_blank\">region</a> in the server URL. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param sendSMSRequestDto Default schema is Text if type is not specified. (optional) + * @return SendSMS201ResponseDto + * @throws ApiException if fails to make API call + */ + public SendSMS201ResponseDto sendSMS(String servicePlanId, SendSMSRequestDto sendSMSRequestDto) + throws ApiException { + HttpRequest httpRequest = sendSMSRequestBuilder(servicePlanId, sendSMSRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 sendSMSRequestBuilder( + String servicePlanId, SendSMSRequestDto sendSMSRequestDto) throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling sendSMS"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, sendSMSRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + 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 servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @param updateBatchMessageRequestDto (optional) + * @return SendSMS201ResponseDto + * @throws ApiException if fails to make API call + */ + public SendSMS201ResponseDto updateBatchMessage( + String servicePlanId, + String batchId, + UpdateBatchMessageRequestDto updateBatchMessageRequestDto) + throws ApiException { + HttpRequest httpRequest = + updateBatchMessageRequestBuilder(servicePlanId, batchId, updateBatchMessageRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 updateBatchMessageRequestBuilder( + String servicePlanId, + String batchId, + UpdateBatchMessageRequestDto updateBatchMessageRequestDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling updateBatchMessage"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling updateBatchMessage"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, updateBatchMessageRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/DeliveryReportsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/DeliveryReportsApi.java new file mode 100644 index 00000000..005fa7eb --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/DeliveryReportsApi.java @@ -0,0 +1,380 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportDto; +import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportListDto; +import com.sinch.sdk.domains.sms.models.dto.v1.RecipientDeliveryReportDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DeliveryReportsApi { + + private static final Logger LOGGER = Logger.getLogger(DeliveryReportsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public DeliveryReportsApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * Retrieve a delivery report Delivery reports can be retrieved even if no callback was requested. + * The difference between a summary and a full report is only that the full report contains the + * phone numbers in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format for each status code. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @param type The type of delivery report. - A `summary` will count the number of + * messages sent per status. - A `full` report give that of a `summary` + * report but in addition, lists phone numbers. (optional, default to summary) + * @param status Comma separated list of delivery_report_statuses to include (optional) + * @param code Comma separated list of delivery_receipt_error_codes to include\" (optional) + * @return DeliveryReportDto + * @throws ApiException if fails to make API call + */ + public DeliveryReportDto getDeliveryReportByBatchId( + String servicePlanId, String batchId, String type, String status, String code) + throws ApiException { + HttpRequest httpRequest = + getDeliveryReportByBatchIdRequestBuilder(servicePlanId, batchId, type, status, code); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getDeliveryReportByBatchIdRequestBuilder( + String servicePlanId, String batchId, String type, String status, String code) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'servicePlanId' when calling getDeliveryReportByBatchId"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, "Missing the required parameter 'batchId' when calling getDeliveryReportByBatchId"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_report" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(batchId.toString())); + + List localVarQueryParams = new ArrayList<>(); + if (null != type) { + localVarQueryParams.add( + new URLParameter("type", type, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != status) { + localVarQueryParams.add( + new URLParameter( + "status", status, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != code) { + localVarQueryParams.add( + new URLParameter("code", code, 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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Retrieve a recipient delivery report A recipient delivery report contains the message status + * for a single recipient phone number. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param batchId The batch ID you received from sending a message. (required) + * @param recipientMsisdn Phone number for which you to want to search. (required) + * @return RecipientDeliveryReportDto + * @throws ApiException if fails to make API call + */ + public RecipientDeliveryReportDto getDeliveryReportByPhoneNumber( + String servicePlanId, String batchId, String recipientMsisdn) throws ApiException { + HttpRequest httpRequest = + getDeliveryReportByPhoneNumberRequestBuilder(servicePlanId, batchId, recipientMsisdn); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getDeliveryReportByPhoneNumberRequestBuilder( + String servicePlanId, String batchId, String recipientMsisdn) throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'servicePlanId' when calling" + + " getDeliveryReportByPhoneNumber"); + } + // verify the required parameter 'batchId' is set + if (batchId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'batchId' when calling getDeliveryReportByPhoneNumber"); + } + // verify the required parameter 'recipientMsisdn' is set + if (recipientMsisdn == null) { + throw new ApiException( + 400, + "Missing the required parameter 'recipientMsisdn' when calling" + + " getDeliveryReportByPhoneNumber"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_report/{recipient_msisdn}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "batch_id" + "\\}", + URLParameterUtils.encodeParameterValue(batchId.toString())) + .replaceAll( + "\\{" + "recipient_msisdn" + "\\}", + URLParameterUtils.encodeParameterValue(recipientMsisdn.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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Retrieve a list of delivery reports Get a list of finished delivery reports. This operation + * supports pagination. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @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 startDate Only list messages received at or after this date/time. Default: 24h ago + * (optional) + * @param endDate Only list messages received before this date/time. (optional) + * @param status Comma separated list of delivery report statuses to include. (optional) + * @param code Comma separated list of delivery receipt error codes to include. (optional) + * @param clientReference Client reference to include (optional) + * @return DeliveryReportListDto + * @throws ApiException if fails to make API call + */ + public DeliveryReportListDto getDeliveryReports( + String servicePlanId, + Integer page, + Integer pageSize, + String startDate, + String endDate, + String status, + String code, + String clientReference) + throws ApiException { + HttpRequest httpRequest = + getDeliveryReportsRequestBuilder( + servicePlanId, page, pageSize, startDate, endDate, status, code, clientReference); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getDeliveryReportsRequestBuilder( + String servicePlanId, + Integer page, + Integer pageSize, + String startDate, + String endDate, + String status, + String code, + String clientReference) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling getDeliveryReports"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/delivery_reports" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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 != 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 != status) { + localVarQueryParams.add( + new URLParameter( + "status", status, URLParameter.STYLE.valueOf("form".toUpperCase()), true)); + } + if (null != code) { + localVarQueryParams.add( + new URLParameter("code", code, 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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/GroupsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/GroupsApi.java new file mode 100644 index 00000000..2d725650 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/GroupsApi.java @@ -0,0 +1,606 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.sms.models.dto.v1.CreateGroupResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.GroupObjectDto; +import com.sinch.sdk.domains.sms.models.dto.v1.ListGroups200ResponseDto; +import com.sinch.sdk.domains.sms.models.dto.v1.ReplaceGroupRequestDto; +import com.sinch.sdk.domains.sms.models.dto.v1.UpdateGroupRequestDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GroupsApi { + + private static final Logger LOGGER = Logger.getLogger(GroupsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public GroupsApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * Create a group A group is a set of phone numbers (MSISDNs) that can be used as a target in the + * `send_batch_msg` operation. An MSISDN can only occur once in a group and any attempts + * to add a duplicate would be ignored but not rejected. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupObjectDto (optional) + * @return CreateGroupResponseDto + * @throws ApiException if fails to make API call + */ + public CreateGroupResponseDto createGroup(String servicePlanId, GroupObjectDto groupObjectDto) + throws ApiException { + HttpRequest httpRequest = createGroupRequestBuilder(servicePlanId, groupObjectDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 createGroupRequestBuilder(String servicePlanId, GroupObjectDto groupObjectDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling createGroup"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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, groupObjectDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Delete a group This operation deletes the group with the provided group ID. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupId ID of a group that you are interested in getting. (required) + * @throws ApiException if fails to make API call + */ + public void deleteGroup(String servicePlanId, String groupId) throws ApiException { + HttpRequest httpRequest = deleteGroupRequestBuilder(servicePlanId, groupId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 deleteGroupRequestBuilder(String servicePlanId, String groupId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling deleteGroup"); + } + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException( + 400, "Missing the required parameter 'groupId' when calling deleteGroup"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups/{group_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "group_id" + "\\}", + URLParameterUtils.encodeParameterValue(groupId.toString())); + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList(); + + final Collection localVarContentTypes = Arrays.asList(); + + final Collection localVarAuthNames = Arrays.asList("BearerAuth"); + final String serializedBody = null; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.DELETE, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Get phone numbers for a group This operation retrieves the members of the group with the + * provided group ID. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupId ID of a group that you are interested in getting. (required) + * @return List<String> + * @throws ApiException if fails to make API call + */ + public List getMembers(String servicePlanId, String groupId) throws ApiException { + HttpRequest httpRequest = getMembersRequestBuilder(servicePlanId, groupId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 getMembersRequestBuilder(String servicePlanId, String groupId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling getMembers"); + } + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException( + 400, "Missing the required parameter 'groupId' when calling getMembers"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups/{group_id}/members" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "group_id" + "\\}", + URLParameterUtils.encodeParameterValue(groupId.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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * List Groups With the list operation you can list all groups that you have created. This + * operation supports pagination. Groups are returned in reverse chronological order. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param page The page number starting from 0. (optional, default to 0) + * @param pageSize Determines the size of a page. (optional, default to 30) + * @return ListGroups200ResponseDto + * @throws ApiException if fails to make API call + */ + public ListGroups200ResponseDto listGroups(String servicePlanId, Integer page, Integer pageSize) + throws ApiException { + HttpRequest httpRequest = listGroupsRequestBuilder(servicePlanId, page, pageSize); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 listGroupsRequestBuilder(String servicePlanId, Integer page, Integer pageSize) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling listGroups"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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)); + } + + 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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Replace a group The replace operation will replace all parameters, including members, of an + * existing group with new values. Replacing a group targeted by a batch message scheduled in the + * future is allowed and changes will be reflected when the batch is sent. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupId ID of a group that you are interested in getting. (required) + * @param replaceGroupRequestDto (optional) + * @return CreateGroupResponseDto + * @throws ApiException if fails to make API call + */ + public CreateGroupResponseDto replaceGroup( + String servicePlanId, String groupId, ReplaceGroupRequestDto replaceGroupRequestDto) + throws ApiException { + HttpRequest httpRequest = + replaceGroupRequestBuilder(servicePlanId, groupId, replaceGroupRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 replaceGroupRequestBuilder( + String servicePlanId, String groupId, ReplaceGroupRequestDto replaceGroupRequestDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling replaceGroup"); + } + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException( + 400, "Missing the required parameter 'groupId' when calling replaceGroup"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups/{group_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "group_id" + "\\}", + URLParameterUtils.encodeParameterValue(groupId.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, replaceGroupRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.PUT, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Retrieve a group This operation retrieves a specific group with the provided group ID. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupId ID of a group that you are interested in getting. (required) + * @return CreateGroupResponseDto + * @throws ApiException if fails to make API call + */ + public CreateGroupResponseDto retrieveGroup(String servicePlanId, String groupId) + throws ApiException { + HttpRequest httpRequest = retrieveGroupRequestBuilder(servicePlanId, groupId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 retrieveGroupRequestBuilder(String servicePlanId, String groupId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling retrieveGroup"); + } + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException( + 400, "Missing the required parameter 'groupId' when calling retrieveGroup"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups/{group_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "group_id" + "\\}", + URLParameterUtils.encodeParameterValue(groupId.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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Update a group With the update group operation, you can add and remove members in an existing + * group as well as rename the group. This method encompasses a few ways to update a group: 1. By + * using `add` and `remove` arrays containing phone numbers, you control the + * group movements. Any list of valid numbers in E.164 format can be added. 2. By using the + * `auto_update` object, your customer can add or remove themselves from groups. 3. You + * can also add or remove other groups into this group with `add_from_group` and + * `remove_from_group`. #### Other group update info - The request will not be rejected + * for duplicate adds or unknown removes. - The additions will be done before the deletions. If an + * phone number is on both lists, it will not be apart of the resulting group. - Updating a group + * targeted by a batch message scheduled in the future is allowed. Changes will be reflected when + * the batch is sent. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param groupId ID of a group that you are interested in getting. (required) + * @param updateGroupRequestDto (optional) + * @return CreateGroupResponseDto + * @throws ApiException if fails to make API call + */ + public CreateGroupResponseDto updateGroup( + String servicePlanId, String groupId, UpdateGroupRequestDto updateGroupRequestDto) + throws ApiException { + HttpRequest httpRequest = + updateGroupRequestBuilder(servicePlanId, groupId, updateGroupRequestDto); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 updateGroupRequestBuilder( + String servicePlanId, String groupId, UpdateGroupRequestDto updateGroupRequestDto) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling updateGroup"); + } + // verify the required parameter 'groupId' is set + if (groupId == null) { + throw new ApiException( + 400, "Missing the required parameter 'groupId' when calling updateGroup"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/groups/{group_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "group_id" + "\\}", + URLParameterUtils.encodeParameterValue(groupId.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, updateGroupRequestDto); + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/InboundsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/InboundsApi.java new file mode 100644 index 00000000..6d73d032 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/InboundsApi.java @@ -0,0 +1,267 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.adapters.api.v1; + +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.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.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.sms.models.dto.v1.ApiInboundListDto; +import com.sinch.sdk.domains.sms.models.dto.v1.RetrieveInboundMessage200ResponseDto; +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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InboundsApi { + + private static final Logger LOGGER = Logger.getLogger(InboundsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private HttpMapper mapper; + + public InboundsApi( + HttpClient httpClient, ServerConfiguration serverConfiguration, HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.mapper = mapper; + } + + /** + * List incoming messages With the list operation, you can list all inbound messages that you have + * received. This operation supports pagination. Inbounds are returned in reverse chronological + * order. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @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 to Only list messages sent to this destination. Multiple phone numbers formatted as + * either <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> or short codes can be comma separated. + * (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, default to Now-24) + * @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 Using a client reference in inbound messages requires additional setup + * on your account. Contact your <a + * href=\"https://dashboard.sinch.com/settings/account-details\" + * target=\"_blank\">account manager</a> to enable this feature. Only + * list inbound messages that are in response to messages with a previously provided client + * reference. (optional) + * @return ApiInboundListDto + * @throws ApiException if fails to make API call + */ + public ApiInboundListDto listInboundMessages( + String servicePlanId, + Integer page, + Integer pageSize, + String to, + String startDate, + String endDate, + String clientReference) + throws ApiException { + HttpRequest httpRequest = + listInboundMessagesRequestBuilder( + servicePlanId, page, pageSize, to, startDate, endDate, clientReference); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 listInboundMessagesRequestBuilder( + String servicePlanId, + Integer page, + Integer pageSize, + String to, + String startDate, + String endDate, + String clientReference) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, "Missing the required parameter 'servicePlanId' when calling listInboundMessages"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/inbounds" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(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 != to) { + localVarQueryParams.add( + new URLParameter("to", to, 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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Retrieve inbound message This operation retrieves a specific inbound message with the provided + * inbound ID. + * + * @param servicePlanId Your service plan ID. You can find this on your + * [Dashboard](https://dashboard.sinch.com/sms/api/rest). (required) + * @param inboundId The inbound ID found when listing inbound messages. (required) + * @return RetrieveInboundMessage200ResponseDto + * @throws ApiException if fails to make API call + */ + public RetrieveInboundMessage200ResponseDto retrieveInboundMessage( + String servicePlanId, String inboundId) throws ApiException { + HttpRequest httpRequest = retrieveInboundMessageRequestBuilder(servicePlanId, inboundId); + HttpResponse response = httpClient.invokeAPI(this.serverConfiguration, 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 retrieveInboundMessageRequestBuilder(String servicePlanId, String inboundId) + throws ApiException { + // verify the required parameter 'servicePlanId' is set + if (servicePlanId == null) { + throw new ApiException( + 400, + "Missing the required parameter 'servicePlanId' when calling retrieveInboundMessage"); + } + // verify the required parameter 'inboundId' is set + if (inboundId == null) { + throw new ApiException( + 400, "Missing the required parameter 'inboundId' when calling retrieveInboundMessage"); + } + + String localVarPath = + "/xms/v1/{service_plan_id}/inbounds/{inbound_id}" + .replaceAll( + "\\{" + "service_plan_id" + "\\}", + URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + .replaceAll( + "\\{" + "inbound_id" + "\\}", + URLParameterUtils.encodeParameterValue(inboundId.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; + + /*if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + }*/ + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListBatchesInnerDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListBatchesInnerDto.java new file mode 100644 index 00000000..c79e6997 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListBatchesInnerDto.java @@ -0,0 +1,378 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize(using = ApiBatchListBatchesInnerDto.ApiBatchListBatchesInnerDtoDeserializer.class) +@JsonSerialize(using = ApiBatchListBatchesInnerDto.ApiBatchListBatchesInnerDtoSerializer.class) +public class ApiBatchListBatchesInnerDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ApiBatchListBatchesInnerDto.class.getName()); + + public static class ApiBatchListBatchesInnerDtoSerializer + extends StdSerializer { + public ApiBatchListBatchesInnerDtoSerializer(Class t) { + super(t); + } + + public ApiBatchListBatchesInnerDtoSerializer() { + this(null); + } + + @Override + public void serialize( + ApiBatchListBatchesInnerDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ApiBatchListBatchesInnerDtoDeserializer + extends StdDeserializer { + public ApiBatchListBatchesInnerDtoDeserializer() { + this(ApiBatchListBatchesInnerDto.class); + } + + public ApiBatchListBatchesInnerDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public ApiBatchListBatchesInnerDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + ApiBatchListBatchesInnerDto newApiBatchListBatchesInnerDto = + new ApiBatchListBatchesInnerDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "BinaryResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + case "MediaResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + case "TextResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + case "mt_binary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + case "mt_media": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + case "mt_text": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.class); + newApiBatchListBatchesInnerDto.setActualInstance(deserialized); + return newApiBatchListBatchesInnerDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for ApiBatchListBatchesInnerDto." + + " Possible values: BinaryResponse MediaResponse TextResponse mt_binary" + + " mt_media mt_text", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize BinaryResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BinaryResponseDto.class.equals(Integer.class) + || BinaryResponseDto.class.equals(Long.class) + || BinaryResponseDto.class.equals(Float.class) + || BinaryResponseDto.class.equals(Double.class) + || BinaryResponseDto.class.equals(Boolean.class) + || BinaryResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((BinaryResponseDto.class.equals(Integer.class) + || BinaryResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((BinaryResponseDto.class.equals(Float.class) + || BinaryResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (BinaryResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (BinaryResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.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 'BinaryResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BinaryResponseDto'", e); + } + + // deserialize MediaResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MediaResponseDto.class.equals(Integer.class) + || MediaResponseDto.class.equals(Long.class) + || MediaResponseDto.class.equals(Float.class) + || MediaResponseDto.class.equals(Double.class) + || MediaResponseDto.class.equals(Boolean.class) + || MediaResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MediaResponseDto.class.equals(Integer.class) + || MediaResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MediaResponseDto.class.equals(Float.class) + || MediaResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MediaResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MediaResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.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 'MediaResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MediaResponseDto'", e); + } + + // deserialize TextResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (TextResponseDto.class.equals(Integer.class) + || TextResponseDto.class.equals(Long.class) + || TextResponseDto.class.equals(Float.class) + || TextResponseDto.class.equals(Double.class) + || TextResponseDto.class.equals(Boolean.class) + || TextResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((TextResponseDto.class.equals(Integer.class) + || TextResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((TextResponseDto.class.equals(Float.class) + || TextResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (TextResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (TextResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.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 'TextResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'TextResponseDto'", e); + } + + if (match == 1) { + ApiBatchListBatchesInnerDto ret = new ApiBatchListBatchesInnerDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for ApiBatchListBatchesInnerDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public ApiBatchListBatchesInnerDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ApiBatchListBatchesInnerDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public ApiBatchListBatchesInnerDto() { + super("oneOf", Boolean.FALSE); + } + + public ApiBatchListBatchesInnerDto(BinaryResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ApiBatchListBatchesInnerDto(MediaResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ApiBatchListBatchesInnerDto(TextResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("BinaryResponseDto", BinaryResponseDto.class); + schemas.put("MediaResponseDto", MediaResponseDto.class); + schemas.put("TextResponseDto", TextResponseDto.class); + JSONNavigator.registerDescendants( + ApiBatchListBatchesInnerDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("BinaryResponse", BinaryResponseDto.class); + mappings.put("MediaResponse", MediaResponseDto.class); + mappings.put("TextResponse", TextResponseDto.class); + mappings.put("mt_binary", BinaryResponseDto.class); + mappings.put("mt_media", MediaResponseDto.class); + mappings.put("mt_text", TextResponseDto.class); + mappings.put("ApiBatchList_batches_inner", ApiBatchListBatchesInnerDto.class); + JSONNavigator.registerDiscriminator(ApiBatchListBatchesInnerDto.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return ApiBatchListBatchesInnerDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: BinaryResponseDto, MediaResponseDto, TextResponseDto + * + *

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(BinaryResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MediaResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(TextResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be BinaryResponseDto, MediaResponseDto, TextResponseDto"); + } + + /** + * Get the actual instance, which can be the following: BinaryResponseDto, MediaResponseDto, + * TextResponseDto + * + * @return The actual instance (BinaryResponseDto, MediaResponseDto, TextResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `BinaryResponseDto`. If the actual instance is not + * `BinaryResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `BinaryResponseDto` + * @throws ClassCastException if the instance is not `BinaryResponseDto` + */ + public BinaryResponseDto getBinaryResponseDto() throws ClassCastException { + return (BinaryResponseDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MediaResponseDto`. If the actual instance is not + * `MediaResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `MediaResponseDto` + * @throws ClassCastException if the instance is not `MediaResponseDto` + */ + public MediaResponseDto getMediaResponseDto() throws ClassCastException { + return (MediaResponseDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `TextResponseDto`. If the actual instance is not `TextResponseDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TextResponseDto` + * @throws ClassCastException if the instance is not `TextResponseDto` + */ + public TextResponseDto getTextResponseDto() throws ClassCastException { + return (TextResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListDto.java new file mode 100644 index 00000000..26e903c5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiBatchListDto.java @@ -0,0 +1,183 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiBatchListDto */ +@JsonPropertyOrder({ + ApiBatchListDto.JSON_PROPERTY_COUNT, + ApiBatchListDto.JSON_PROPERTY_PAGE, + ApiBatchListDto.JSON_PROPERTY_BATCHES, + ApiBatchListDto.JSON_PROPERTY_PAGE_SIZE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiBatchListDto { + public static final String JSON_PROPERTY_COUNT = "count"; + private Long count; + + public static final String JSON_PROPERTY_PAGE = "page"; + private Integer page; + + public static final String JSON_PROPERTY_BATCHES = "batches"; + private List batches; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + private Integer pageSize; + + public ApiBatchListDto() {} + + public ApiBatchListDto count(Long count) { + this.count = count; + return this; + } + + /** + * The total number of entries matching the given filters. + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getCount() { + return count; + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCount(Long count) { + this.count = count; + } + + public ApiBatchListDto page(Integer page) { + this.page = page; + return this; + } + + /** + * The requested page. + * + * @return page + */ + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPage() { + return page; + } + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPage(Integer page) { + this.page = page; + } + + public ApiBatchListDto batches(List batches) { + this.batches = batches; + return this; + } + + public ApiBatchListDto addBatchesItem(ApiBatchListBatchesInnerDto batchesItem) { + if (this.batches == null) { + this.batches = new ArrayList<>(); + } + this.batches.add(batchesItem); + return this; + } + + /** + * The page of batches matching the given filters. + * + * @return batches + */ + @JsonProperty(JSON_PROPERTY_BATCHES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getBatches() { + return batches; + } + + @JsonProperty(JSON_PROPERTY_BATCHES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBatches(List batches) { + this.batches = batches; + } + + public ApiBatchListDto pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * The number of entries returned in this request. + * + * @return pageSize + */ + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPageSize() { + return pageSize; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPageSize(Integer pageSize) { + this.pageSize = 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; + } + ApiBatchListDto apiBatchList = (ApiBatchListDto) 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 ApiBatchListDto {\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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiDeliveryFeedbackDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiDeliveryFeedbackDto.java new file mode 100644 index 00000000..5cd2e82d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiDeliveryFeedbackDto.java @@ -0,0 +1,99 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiDeliveryFeedbackDto */ +@JsonPropertyOrder({ApiDeliveryFeedbackDto.JSON_PROPERTY_RECIPIENTS}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiDeliveryFeedbackDto { + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + private List recipients = new ArrayList<>(); + + public ApiDeliveryFeedbackDto() {} + + public ApiDeliveryFeedbackDto recipients(List recipients) { + this.recipients = recipients; + return this; + } + + public ApiDeliveryFeedbackDto addRecipientsItem(String recipientsItem) { + if (this.recipients == null) { + this.recipients = new ArrayList<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getRecipients() { + return recipients; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipients(List recipients) { + this.recipients = 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; + } + ApiDeliveryFeedbackDto apiDeliveryFeedback = (ApiDeliveryFeedbackDto) 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 ApiDeliveryFeedbackDto {\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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiGroupDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiGroupDto.java new file mode 100644 index 00000000..b40f58f4 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiGroupDto.java @@ -0,0 +1,83 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** ApiGroupDto */ +@JsonPropertyOrder({ApiGroupDto.JSON_PROPERTY_ID}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiGroupDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public ApiGroupDto() {} + + @JsonCreator + public ApiGroupDto(@JsonProperty(JSON_PROPERTY_ID) String id) { + this(); + this.id = id; + } + + /** + * Unique identifier for the group + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + /** Return true if this ApiGroup object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiGroupDto apiGroup = (ApiGroupDto) o; + return Objects.equals(this.id, apiGroup.id); + } + + @Override + public int hashCode() { + return Objects.hash(id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiGroupDto {\n"); + sb.append(" id: ").append(toIndentedString(id)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListDto.java new file mode 100644 index 00000000..bc53514a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListDto.java @@ -0,0 +1,183 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiInboundListDto */ +@JsonPropertyOrder({ + ApiInboundListDto.JSON_PROPERTY_COUNT, + ApiInboundListDto.JSON_PROPERTY_PAGE, + ApiInboundListDto.JSON_PROPERTY_INBOUNDS, + ApiInboundListDto.JSON_PROPERTY_PAGE_SIZE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiInboundListDto { + public static final String JSON_PROPERTY_COUNT = "count"; + private Long count; + + public static final String JSON_PROPERTY_PAGE = "page"; + private Integer page; + + public static final String JSON_PROPERTY_INBOUNDS = "inbounds"; + private List inbounds; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + private Integer pageSize; + + public ApiInboundListDto() {} + + public ApiInboundListDto count(Long count) { + this.count = count; + return this; + } + + /** + * The total number of inbounds matching the given filters + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getCount() { + return count; + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCount(Long count) { + this.count = count; + } + + public ApiInboundListDto page(Integer page) { + this.page = page; + return this; + } + + /** + * The requested page. + * + * @return page + */ + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPage() { + return page; + } + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPage(Integer page) { + this.page = page; + } + + public ApiInboundListDto inbounds(List inbounds) { + this.inbounds = inbounds; + return this; + } + + public ApiInboundListDto addInboundsItem(ApiInboundListInboundsInnerDto inboundsItem) { + if (this.inbounds == null) { + this.inbounds = new ArrayList<>(); + } + this.inbounds.add(inboundsItem); + return this; + } + + /** + * The page of inbounds matching the given filters. + * + * @return inbounds + */ + @JsonProperty(JSON_PROPERTY_INBOUNDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getInbounds() { + return inbounds; + } + + @JsonProperty(JSON_PROPERTY_INBOUNDS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInbounds(List inbounds) { + this.inbounds = inbounds; + } + + public ApiInboundListDto pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * The number of inbounds returned in this request. + * + * @return pageSize + */ + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPageSize() { + return pageSize; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + /** Return true if this ApiInboundList object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiInboundListDto apiInboundList = (ApiInboundListDto) o; + return Objects.equals(this.count, apiInboundList.count) + && Objects.equals(this.page, apiInboundList.page) + && Objects.equals(this.inbounds, apiInboundList.inbounds) + && Objects.equals(this.pageSize, apiInboundList.pageSize); + } + + @Override + public int hashCode() { + return Objects.hash(count, page, inbounds, pageSize); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiInboundListDto {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" inbounds: ").append(toIndentedString(inbounds)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListInboundsInnerDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListInboundsInnerDto.java new file mode 100644 index 00000000..a34412ea --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiInboundListInboundsInnerDto.java @@ -0,0 +1,292 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize( + using = ApiInboundListInboundsInnerDto.ApiInboundListInboundsInnerDtoDeserializer.class) +@JsonSerialize( + using = ApiInboundListInboundsInnerDto.ApiInboundListInboundsInnerDtoSerializer.class) +public class ApiInboundListInboundsInnerDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ApiInboundListInboundsInnerDto.class.getName()); + + public static class ApiInboundListInboundsInnerDtoSerializer + extends StdSerializer { + public ApiInboundListInboundsInnerDtoSerializer(Class t) { + super(t); + } + + public ApiInboundListInboundsInnerDtoSerializer() { + this(null); + } + + @Override + public void serialize( + ApiInboundListInboundsInnerDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ApiInboundListInboundsInnerDtoDeserializer + extends StdDeserializer { + public ApiInboundListInboundsInnerDtoDeserializer() { + this(ApiInboundListInboundsInnerDto.class); + } + + public ApiInboundListInboundsInnerDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public ApiInboundListInboundsInnerDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + ApiInboundListInboundsInnerDto newApiInboundListInboundsInnerDto = + new ApiInboundListInboundsInnerDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "MOBinary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOBinaryDto.class); + newApiInboundListInboundsInnerDto.setActualInstance(deserialized); + return newApiInboundListInboundsInnerDto; + case "MOText": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOTextDto.class); + newApiInboundListInboundsInnerDto.setActualInstance(deserialized); + return newApiInboundListInboundsInnerDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for ApiInboundListInboundsInnerDto." + + " Possible values: MOBinary MOText", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize MOBinaryDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MOBinaryDto.class.equals(Integer.class) + || MOBinaryDto.class.equals(Long.class) + || MOBinaryDto.class.equals(Float.class) + || MOBinaryDto.class.equals(Double.class) + || MOBinaryDto.class.equals(Boolean.class) + || MOBinaryDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MOBinaryDto.class.equals(Integer.class) || MOBinaryDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MOBinaryDto.class.equals(Float.class) || MOBinaryDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MOBinaryDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MOBinaryDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOBinaryDto.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 'MOBinaryDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MOBinaryDto'", e); + } + + // deserialize MOTextDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MOTextDto.class.equals(Integer.class) + || MOTextDto.class.equals(Long.class) + || MOTextDto.class.equals(Float.class) + || MOTextDto.class.equals(Double.class) + || MOTextDto.class.equals(Boolean.class) + || MOTextDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MOTextDto.class.equals(Integer.class) || MOTextDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MOTextDto.class.equals(Float.class) || MOTextDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MOTextDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MOTextDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOTextDto.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 'MOTextDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MOTextDto'", e); + } + + if (match == 1) { + ApiInboundListInboundsInnerDto ret = new ApiInboundListInboundsInnerDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for ApiInboundListInboundsInnerDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public ApiInboundListInboundsInnerDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ApiInboundListInboundsInnerDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public ApiInboundListInboundsInnerDto() { + super("oneOf", Boolean.FALSE); + } + + public ApiInboundListInboundsInnerDto(MOBinaryDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ApiInboundListInboundsInnerDto(MOTextDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MOBinaryDto", MOBinaryDto.class); + schemas.put("MOTextDto", MOTextDto.class); + JSONNavigator.registerDescendants( + ApiInboundListInboundsInnerDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("MOBinary", MOBinaryDto.class); + mappings.put("MOText", MOTextDto.class); + mappings.put("ApiInboundList_inbounds_inner", ApiInboundListInboundsInnerDto.class); + JSONNavigator.registerDiscriminator(ApiInboundListInboundsInnerDto.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return ApiInboundListInboundsInnerDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MOBinaryDto, MOTextDto + * + *

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(MOBinaryDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MOTextDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MOBinaryDto, MOTextDto"); + } + + /** + * Get the actual instance, which can be the following: MOBinaryDto, MOTextDto + * + * @return The actual instance (MOBinaryDto, MOTextDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MOBinaryDto`. If the actual instance is not `MOBinaryDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MOBinaryDto` + * @throws ClassCastException if the instance is not `MOBinaryDto` + */ + public MOBinaryDto getMOBinaryDto() throws ClassCastException { + return (MOBinaryDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MOTextDto`. If the actual instance is not `MOTextDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MOTextDto` + * @throws ClassCastException if the instance is not `MOTextDto` + */ + public MOTextDto getMOTextDto() throws ClassCastException { + return (MOTextDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiMoMessageDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiMoMessageDto.java new file mode 100644 index 00000000..2b24cb05 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiMoMessageDto.java @@ -0,0 +1,347 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** The page of inbounds matching the given filters. */ +@JsonPropertyOrder({ + ApiMoMessageDto.JSON_PROPERTY_FROM, + ApiMoMessageDto.JSON_PROPERTY_ID, + ApiMoMessageDto.JSON_PROPERTY_RECEIVED_AT, + ApiMoMessageDto.JSON_PROPERTY_TO, + ApiMoMessageDto.JSON_PROPERTY_TYPE, + ApiMoMessageDto.JSON_PROPERTY_BODY, + ApiMoMessageDto.JSON_PROPERTY_CLIENT_REFERENCE, + ApiMoMessageDto.JSON_PROPERTY_OPERATOR_ID, + ApiMoMessageDto.JSON_PROPERTY_SENT_AT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +/*@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = MOBinaryDto.class, name = "MOBinary"), + @JsonSubTypes.Type(value = MOTextDto.class, name = "MOText"), +}) +public class ApiMoMessageDto { + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RECEIVED_AT = "received_at"; + private OffsetDateTime receivedAt; + + public static final String JSON_PROPERTY_TO = "to"; + private String to; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_OPERATOR_ID = "operator_id"; + private String operatorId; + + public static final String JSON_PROPERTY_SENT_AT = "sent_at"; + private OffsetDateTime sentAt; + + public ApiMoMessageDto() {} + + @JsonCreator + public ApiMoMessageDto(@JsonProperty(JSON_PROPERTY_TYPE) String type) { + this(); + this.type = type; + } + + public ApiMoMessageDto from(String from) { + this.from = from; + return this; + } + + /** + * The phone number that sent the message. <a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">More info</a> + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setFrom(String from) { + this.from = from; + } + + public ApiMoMessageDto id(String id) { + this.id = id; + return this; + } + + /** + * The ID of this inbound message. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setId(String id) { + this.id = id; + } + + public ApiMoMessageDto receivedAt(OffsetDateTime receivedAt) { + this.receivedAt = receivedAt; + return this; + } + + /** + * When the system received the message. Formatted as <a + * href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return receivedAt + */ + @JsonProperty(JSON_PROPERTY_RECEIVED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getReceivedAt() { + return receivedAt; + } + + @JsonProperty(JSON_PROPERTY_RECEIVED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setReceivedAt(OffsetDateTime receivedAt) { + this.receivedAt = receivedAt; + } + + public ApiMoMessageDto to(String to) { + this.to = to; + return this; + } + + /** + * The Sinch phone number or short code to which the message was sent. + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTo(String to) { + this.to = to; + } + + /** + * Get type + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + public ApiMoMessageDto body(String body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + public ApiMoMessageDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * If this inbound message is in response to a previously sent message that contained a client + * reference, then this field contains *that* client reference. Utilizing this feature requires + * additional setup on your account. Contact your <a + * href=\"https://dashboard.sinch.com/settings/account-details\" + * target=\"_blank\">account manager</a> to enable this feature. + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public ApiMoMessageDto operatorId(String operatorId) { + this.operatorId = operatorId; + return this; + } + + /** + * The MCC/MNC of the sender's operator if known. + * + * @return operatorId + */ + @JsonProperty(JSON_PROPERTY_OPERATOR_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOperatorId() { + return operatorId; + } + + @JsonProperty(JSON_PROPERTY_OPERATOR_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public ApiMoMessageDto sentAt(OffsetDateTime sentAt) { + this.sentAt = sentAt; + return this; + } + + /** + * When the message left the originating device. Only available if provided by operator. Formatted + * as <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sentAt + */ + @JsonProperty(JSON_PROPERTY_SENT_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSentAt() { + return sentAt; + } + + @JsonProperty(JSON_PROPERTY_SENT_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSentAt(OffsetDateTime sentAt) { + this.sentAt = sentAt; + } + + /** Return true if this ApiMoMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiMoMessageDto apiMoMessage = (ApiMoMessageDto) o; + return Objects.equals(this.from, apiMoMessage.from) + && Objects.equals(this.id, apiMoMessage.id) + && Objects.equals(this.receivedAt, apiMoMessage.receivedAt) + && Objects.equals(this.to, apiMoMessage.to) + && Objects.equals(this.type, apiMoMessage.type) + && Objects.equals(this.body, apiMoMessage.body) + && Objects.equals(this.clientReference, apiMoMessage.clientReference) + && Objects.equals(this.operatorId, apiMoMessage.operatorId) + && Objects.equals(this.sentAt, apiMoMessage.sentAt); + } + + @Override + public int hashCode() { + return Objects.hash(from, id, receivedAt, to, type, body, clientReference, operatorId, sentAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiMoMessageDto {\n"); + sb.append(" from: ").append(toIndentedString(from)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" receivedAt: ").append(toIndentedString(receivedAt)).append("\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" operatorId: ").append(toIndentedString(operatorId)).append("\n"); + sb.append(" sentAt: ").append(toIndentedString(sentAt)).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 "); + } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("MOBinary", MOBinaryDto.class); + mappings.put("MOText", MOTextDto.class); + mappings.put("ApiMoMessage", ApiMoMessageDto.class); + JSONNavigator.registerDiscriminator(ApiMoMessageDto.class, "type", mappings); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateBinaryMtMessageDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateBinaryMtMessageDto.java new file mode 100644 index 00000000..8514c9d0 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateBinaryMtMessageDto.java @@ -0,0 +1,401 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiUpdateBinaryMtMessageDto */ +@JsonPropertyOrder({ + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_FROM, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_TYPE, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_TO_ADD, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_TO_REMOVE, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_DELIVERY_REPORT, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_SEND_AT, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_EXPIRE_AT, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_CALLBACK_URL, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_BODY, + ApiUpdateBinaryMtMessageDto.JSON_PROPERTY_UDH +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiUpdateBinaryMtMessageDto { + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + /** SMS in binary format */ + public enum TypeEnum { + MT_BINARY("mt_binary"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + private List toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + private List toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_UDH = "udh"; + private String udh; + + public ApiUpdateBinaryMtMessageDto() {} + + public ApiUpdateBinaryMtMessageDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public ApiUpdateBinaryMtMessageDto type(String type) { + this.type = type; + return this; + } + + /** + * SMS in binary format + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ApiUpdateBinaryMtMessageDto toAdd(List toAdd) { + this.toAdd = toAdd; + return this; + } + + public ApiUpdateBinaryMtMessageDto addToAddItem(String toAddItem) { + if (this.toAdd == null) { + this.toAdd = new ArrayList<>(); + } + this.toAdd.add(toAddItem); + return this; + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToAdd() { + return toAdd; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToAdd(List toAdd) { + this.toAdd = toAdd; + } + + public ApiUpdateBinaryMtMessageDto toRemove(List toRemove) { + this.toRemove = toRemove; + return this; + } + + public ApiUpdateBinaryMtMessageDto addToRemoveItem(String toRemoveItem) { + if (this.toRemove == null) { + this.toRemove = new ArrayList<>(); + } + this.toRemove.add(toRemoveItem); + return this; + } + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToRemove() { + return toRemove; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToRemove(List toRemove) { + this.toRemove = toRemove; + } + + public ApiUpdateBinaryMtMessageDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public ApiUpdateBinaryMtMessageDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * If set, in the future the message will be delayed until `send_at` occurs. Formatted + * as <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * Constraints: Must be before expire_at. If set in the past, messages will be sent immediately. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public ApiUpdateBinaryMtMessageDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public ApiUpdateBinaryMtMessageDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ApiUpdateBinaryMtMessageDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content Base64 encoded. Max 140 bytes together with udh. + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + public ApiUpdateBinaryMtMessageDto udh(String udh) { + this.udh = udh; + return this; + } + + /** + * The UDH header of a binary message HEX encoded. Max 140 bytes together with body. + * + * @return udh + */ + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUdh() { + return udh; + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUdh(String udh) { + this.udh = udh; + } + + /** 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; + } + ApiUpdateBinaryMtMessageDto apiUpdateBinaryMtMessage = (ApiUpdateBinaryMtMessageDto) 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.body, apiUpdateBinaryMtMessage.body) + && Objects.equals(this.udh, apiUpdateBinaryMtMessage.udh); + } + + @Override + public int hashCode() { + return Objects.hash( + from, type, toAdd, toRemove, deliveryReport, sendAt, expireAt, callbackUrl, body, udh); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiUpdateBinaryMtMessageDto {\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(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" udh: ").append(toIndentedString(udh)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMmsMtMessageDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMmsMtMessageDto.java new file mode 100644 index 00000000..3e37fbf0 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMmsMtMessageDto.java @@ -0,0 +1,442 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiUpdateMmsMtMessageDto */ +@JsonPropertyOrder({ + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_FROM, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_TYPE, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_TO_ADD, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_TO_REMOVE, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_DELIVERY_REPORT, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_SEND_AT, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_EXPIRE_AT, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_CALLBACK_URL, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_BODY, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_PARAMETERS, + ApiUpdateMmsMtMessageDto.JSON_PROPERTY_STRICT_VALIDATION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiUpdateMmsMtMessageDto { + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + /** MMS */ + public enum TypeEnum { + MT_MEDIA("mt_media"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + private List toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + private List toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_BODY = "body"; + private MediaBodyDto body; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + private Boolean strictValidation = false; + + public ApiUpdateMmsMtMessageDto() {} + + public ApiUpdateMmsMtMessageDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public ApiUpdateMmsMtMessageDto type(String type) { + this.type = type; + return this; + } + + /** + * MMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ApiUpdateMmsMtMessageDto toAdd(List toAdd) { + this.toAdd = toAdd; + return this; + } + + public ApiUpdateMmsMtMessageDto addToAddItem(String toAddItem) { + if (this.toAdd == null) { + this.toAdd = new ArrayList<>(); + } + this.toAdd.add(toAddItem); + return this; + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToAdd() { + return toAdd; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToAdd(List toAdd) { + this.toAdd = toAdd; + } + + public ApiUpdateMmsMtMessageDto toRemove(List toRemove) { + this.toRemove = toRemove; + return this; + } + + public ApiUpdateMmsMtMessageDto addToRemoveItem(String toRemoveItem) { + if (this.toRemove == null) { + this.toRemove = new ArrayList<>(); + } + this.toRemove.add(toRemoveItem); + return this; + } + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToRemove() { + return toRemove; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToRemove(List toRemove) { + this.toRemove = toRemove; + } + + public ApiUpdateMmsMtMessageDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public ApiUpdateMmsMtMessageDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * If set, in the future the message will be delayed until `send_at` occurs. Formatted + * as <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * Constraints: Must be before expire_at. If set in the past, messages will be sent immediately. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public ApiUpdateMmsMtMessageDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public ApiUpdateMmsMtMessageDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ApiUpdateMmsMtMessageDto body(MediaBodyDto body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MediaBodyDto getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(MediaBodyDto body) { + this.body = body; + } + + public ApiUpdateMmsMtMessageDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + public ApiUpdateMmsMtMessageDto strictValidation(Boolean strictValidation) { + this.strictValidation = strictValidation; + return this; + } + + /** + * Whether or not you want the media included in your message to be checked against [Sinch MMS + * channel best practices](/docs/mms/bestpractices/). 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 + */ + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getStrictValidation() { + return strictValidation; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStrictValidation(Boolean strictValidation) { + this.strictValidation = 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; + } + ApiUpdateMmsMtMessageDto apiUpdateMmsMtMessage = (ApiUpdateMmsMtMessageDto) 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.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, + body, + parameters, + strictValidation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiUpdateMmsMtMessageDto {\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(" 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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMtMessageDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMtMessageDto.java new file mode 100644 index 00000000..05325787 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateMtMessageDto.java @@ -0,0 +1,309 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiUpdateMtMessageDto */ +@JsonPropertyOrder({ + ApiUpdateMtMessageDto.JSON_PROPERTY_FROM, + ApiUpdateMtMessageDto.JSON_PROPERTY_TYPE, + ApiUpdateMtMessageDto.JSON_PROPERTY_TO_ADD, + ApiUpdateMtMessageDto.JSON_PROPERTY_TO_REMOVE, + ApiUpdateMtMessageDto.JSON_PROPERTY_DELIVERY_REPORT, + ApiUpdateMtMessageDto.JSON_PROPERTY_SEND_AT, + ApiUpdateMtMessageDto.JSON_PROPERTY_EXPIRE_AT, + ApiUpdateMtMessageDto.JSON_PROPERTY_CALLBACK_URL +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiUpdateMtMessageDto { + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + private List toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + private List toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public ApiUpdateMtMessageDto() {} + + public ApiUpdateMtMessageDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public ApiUpdateMtMessageDto type(String type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ApiUpdateMtMessageDto toAdd(List toAdd) { + this.toAdd = toAdd; + return this; + } + + public ApiUpdateMtMessageDto addToAddItem(String toAddItem) { + if (this.toAdd == null) { + this.toAdd = new ArrayList<>(); + } + this.toAdd.add(toAddItem); + return this; + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToAdd() { + return toAdd; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToAdd(List toAdd) { + this.toAdd = toAdd; + } + + public ApiUpdateMtMessageDto toRemove(List toRemove) { + this.toRemove = toRemove; + return this; + } + + public ApiUpdateMtMessageDto addToRemoveItem(String toRemoveItem) { + if (this.toRemove == null) { + this.toRemove = new ArrayList<>(); + } + this.toRemove.add(toRemoveItem); + return this; + } + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToRemove() { + return toRemove; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToRemove(List toRemove) { + this.toRemove = toRemove; + } + + public ApiUpdateMtMessageDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public ApiUpdateMtMessageDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * If set, in the future the message will be delayed until `send_at` occurs. Formatted + * as <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * Constraints: Must be before expire_at. If set in the past, messages will be sent immediately. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public ApiUpdateMtMessageDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public ApiUpdateMtMessageDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + /** Return true if this ApiUpdateMtMessage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ApiUpdateMtMessageDto apiUpdateMtMessage = (ApiUpdateMtMessageDto) o; + return Objects.equals(this.from, apiUpdateMtMessage.from) + && Objects.equals(this.type, apiUpdateMtMessage.type) + && Objects.equals(this.toAdd, apiUpdateMtMessage.toAdd) + && Objects.equals(this.toRemove, apiUpdateMtMessage.toRemove) + && Objects.equals(this.deliveryReport, apiUpdateMtMessage.deliveryReport) + && Objects.equals(this.sendAt, apiUpdateMtMessage.sendAt) + && Objects.equals(this.expireAt, apiUpdateMtMessage.expireAt) + && Objects.equals(this.callbackUrl, apiUpdateMtMessage.callbackUrl); + } + + @Override + public int hashCode() { + return Objects.hash(from, type, toAdd, toRemove, deliveryReport, sendAt, expireAt, callbackUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiUpdateMtMessageDto {\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("}"); + 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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateTextMtMessageDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateTextMtMessageDto.java new file mode 100644 index 00000000..677a448a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ApiUpdateTextMtMessageDto.java @@ -0,0 +1,410 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ApiUpdateTextMtMessageDto */ +@JsonPropertyOrder({ + ApiUpdateTextMtMessageDto.JSON_PROPERTY_FROM, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_TYPE, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_TO_ADD, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_TO_REMOVE, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_DELIVERY_REPORT, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_SEND_AT, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_EXPIRE_AT, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_CALLBACK_URL, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_PARAMETERS, + ApiUpdateTextMtMessageDto.JSON_PROPERTY_BODY +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ApiUpdateTextMtMessageDto { + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + /** Regular SMS */ + public enum TypeEnum { + MT_TEXT("mt_text"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_TO_ADD = "to_add"; + private List toAdd; + + public static final String JSON_PROPERTY_TO_REMOVE = "to_remove"; + private List toRemove; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public ApiUpdateTextMtMessageDto() {} + + public ApiUpdateTextMtMessageDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public ApiUpdateTextMtMessageDto type(String type) { + this.type = type; + return this; + } + + /** + * Regular SMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public ApiUpdateTextMtMessageDto toAdd(List toAdd) { + this.toAdd = toAdd; + return this; + } + + public ApiUpdateTextMtMessageDto addToAddItem(String toAddItem) { + if (this.toAdd == null) { + this.toAdd = new ArrayList<>(); + } + this.toAdd.add(toAddItem); + return this; + } + + /** + * List of phone numbers and group IDs to add to the batch. + * + * @return toAdd + */ + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToAdd() { + return toAdd; + } + + @JsonProperty(JSON_PROPERTY_TO_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToAdd(List toAdd) { + this.toAdd = toAdd; + } + + public ApiUpdateTextMtMessageDto toRemove(List toRemove) { + this.toRemove = toRemove; + return this; + } + + public ApiUpdateTextMtMessageDto addToRemoveItem(String toRemoveItem) { + if (this.toRemove == null) { + this.toRemove = new ArrayList<>(); + } + this.toRemove.add(toRemoveItem); + return this; + } + + /** + * List of phone numbers and group IDs to remove from the batch. + * + * @return toRemove + */ + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getToRemove() { + return toRemove; + } + + @JsonProperty(JSON_PROPERTY_TO_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setToRemove(List toRemove) { + this.toRemove = toRemove; + } + + public ApiUpdateTextMtMessageDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public ApiUpdateTextMtMessageDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * If set, in the future the message will be delayed until `send_at` occurs. Formatted + * as <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * Constraints: Must be before expire_at. If set in the past, messages will be sent immediately. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public ApiUpdateTextMtMessageDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public ApiUpdateTextMtMessageDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Constraints: Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public ApiUpdateTextMtMessageDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + public ApiUpdateTextMtMessageDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + /** 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; + } + ApiUpdateTextMtMessageDto apiUpdateTextMtMessage = (ApiUpdateTextMtMessageDto) 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.parameters, apiUpdateTextMtMessage.parameters) + && Objects.equals(this.body, apiUpdateTextMtMessage.body); + } + + @Override + public int hashCode() { + return Objects.hash( + from, + type, + toAdd, + toRemove, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + parameters, + body); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ApiUpdateTextMtMessageDto {\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(" parameters: ").append(toIndentedString(parameters)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryRequestDto.java new file mode 100644 index 00000000..890970e1 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryRequestDto.java @@ -0,0 +1,598 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** BinaryRequestDto */ +@JsonPropertyOrder({ + BinaryRequestDto.JSON_PROPERTY_TO, + BinaryRequestDto.JSON_PROPERTY_BODY, + BinaryRequestDto.JSON_PROPERTY_UDH, + BinaryRequestDto.JSON_PROPERTY_FROM, + BinaryRequestDto.JSON_PROPERTY_TYPE, + BinaryRequestDto.JSON_PROPERTY_DELIVERY_REPORT, + BinaryRequestDto.JSON_PROPERTY_SEND_AT, + BinaryRequestDto.JSON_PROPERTY_EXPIRE_AT, + BinaryRequestDto.JSON_PROPERTY_CALLBACK_URL, + BinaryRequestDto.JSON_PROPERTY_CLIENT_REFERENCE, + BinaryRequestDto.JSON_PROPERTY_FEEDBACK_ENABLED, + BinaryRequestDto.JSON_PROPERTY_FLASH_MESSAGE, + BinaryRequestDto.JSON_PROPERTY_TRUNCATE_CONCAT, + BinaryRequestDto.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + BinaryRequestDto.JSON_PROPERTY_FROM_TON, + BinaryRequestDto.JSON_PROPERTY_FROM_NPI +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BinaryRequestDto { + public static final String JSON_PROPERTY_TO = "to"; + private List to = new ArrayList<>(); + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_UDH = "udh"; + private String udh; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + /** + * SMS in <a + * href=\"https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470\" + * target=\"_blank\">binary</a> format. + */ + public enum TypeEnum { + MT_BINARY("mt_binary"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + private Boolean flashMessage = false; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + private Boolean truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + private Integer maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + private Integer fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + private Integer fromNpi; + + public BinaryRequestDto() {} + + public BinaryRequestDto to(List to) { + this.to = to; + return this; + } + + public BinaryRequestDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * A list of phone numbers and group IDs that will receive the batch. [More + * info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628). + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTo(List to) { + this.to = to; + } + + public BinaryRequestDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content Base64 encoded. Max 140 bytes including `udh`. + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBody(String body) { + this.body = body; + } + + public BinaryRequestDto udh(String udh) { + this.udh = udh; + return this; + } + + /** + * The UDH header of a binary message HEX encoded. Max 140 bytes including the `body`. + * + * @return udh + */ + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUdh() { + return udh; + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setUdh(String udh) { + this.udh = udh; + } + + public BinaryRequestDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public BinaryRequestDto type(String type) { + this.type = type; + return this; + } + + /** + * SMS in <a + * href=\"https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470\" + * target=\"_blank\">binary</a> format. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public BinaryRequestDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public BinaryRequestDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public BinaryRequestDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public BinaryRequestDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the *default* callback URL for this batch. Must be a valid URL. Learn how to set a + * default callback URL <a + * href=\"https://community.sinch.com/t5/SMS/How-do-I-assign-a-callback-URL-to-an-SMS-service-plan/ta-p/8414\" + * target=\"_blank\">here</a>. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public BinaryRequestDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch. + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public BinaryRequestDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to true then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public BinaryRequestDto flashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFlashMessage() { + return flashMessage; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + } + + public BinaryRequestDto truncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + /** + * If set to `true`, the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getTruncateConcat() { + return truncateConcat; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + } + + public BinaryRequestDto maxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + /** + * Message will be dispatched only if it is not split to more parts than the maximum number of + * message parts. minimum: 1 + * + * @return maxNumberOfMessageParts + */ + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + } + + public BinaryRequestDto fromTon(Integer fromTon) { + this.fromTon = fromTon; + return this; + } + + /** + * The type of number for the sender number. Use to override the automatic detection. minimum: 0 + * maximum: 6 + * + * @return fromTon + */ + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromTon() { + return fromTon; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromTon(Integer fromTon) { + this.fromTon = fromTon; + } + + public BinaryRequestDto fromNpi(Integer fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. minimum: + * 0 maximum: 18 + * + * @return fromNpi + */ + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromNpi() { + return fromNpi; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromNpi(Integer fromNpi) { + this.fromNpi = 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; + } + BinaryRequestDto binaryRequest = (BinaryRequestDto) o; + return Objects.equals(this.to, binaryRequest.to) + && Objects.equals(this.body, binaryRequest.body) + && Objects.equals(this.udh, binaryRequest.udh) + && Objects.equals(this.from, binaryRequest.from) + && 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.flashMessage, binaryRequest.flashMessage) + && Objects.equals(this.truncateConcat, binaryRequest.truncateConcat) + && Objects.equals(this.maxNumberOfMessageParts, binaryRequest.maxNumberOfMessageParts) + && Objects.equals(this.fromTon, binaryRequest.fromTon) + && Objects.equals(this.fromNpi, binaryRequest.fromNpi); + } + + @Override + public int hashCode() { + return Objects.hash( + to, + body, + udh, + from, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BinaryRequestDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" udh: ").append(toIndentedString(udh)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDto.java new file mode 100644 index 00000000..f0e4ed4d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDto.java @@ -0,0 +1,682 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** BinaryResponseDto */ +@JsonPropertyOrder({ + BinaryResponseDto.JSON_PROPERTY_ID, + BinaryResponseDto.JSON_PROPERTY_TO, + BinaryResponseDto.JSON_PROPERTY_FROM, + BinaryResponseDto.JSON_PROPERTY_CANCELED, + BinaryResponseDto.JSON_PROPERTY_BODY, + BinaryResponseDto.JSON_PROPERTY_UDH, + BinaryResponseDto.JSON_PROPERTY_TYPE, + BinaryResponseDto.JSON_PROPERTY_CREATED_AT, + BinaryResponseDto.JSON_PROPERTY_MODIFIED_AT, + BinaryResponseDto.JSON_PROPERTY_DELIVERY_REPORT, + BinaryResponseDto.JSON_PROPERTY_SEND_AT, + BinaryResponseDto.JSON_PROPERTY_EXPIRE_AT, + BinaryResponseDto.JSON_PROPERTY_CALLBACK_URL, + BinaryResponseDto.JSON_PROPERTY_CLIENT_REFERENCE, + BinaryResponseDto.JSON_PROPERTY_FEEDBACK_ENABLED, + BinaryResponseDto.JSON_PROPERTY_FLASH_MESSAGE, + BinaryResponseDto.JSON_PROPERTY_TRUNCATE_CONCAT, + BinaryResponseDto.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + BinaryResponseDto.JSON_PROPERTY_FROM_TON, + BinaryResponseDto.JSON_PROPERTY_FROM_NPI +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class BinaryResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TO = "to"; + private List to; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + private Boolean canceled = false; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_UDH = "udh"; + private String udh; + + /** + * SMS in <a + * href=\"https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470\" + * target=\"_blank\">binary</a> format. + */ + public enum TypeEnum { + MT_BINARY("mt_binary"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private OffsetDateTime modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + private Boolean flashMessage = false; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + private Boolean truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + private Integer maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + private Integer fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + private Integer fromNpi; + + public BinaryResponseDto() {} + + @JsonCreator + public BinaryResponseDto( + @JsonProperty(JSON_PROPERTY_ID) String id, + @JsonProperty(JSON_PROPERTY_CANCELED) Boolean canceled, + @JsonProperty(JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) OffsetDateTime modifiedAt) { + this(); + this.id = id; + this.canceled = canceled; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + } + + /** + * Unique identifier for batch. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public BinaryResponseDto to(List to) { + this.to = to; + return this; + } + + public BinaryResponseDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * A list of phone numbers and group IDs that have received the batch. [More + * info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628). + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTo(List to) { + this.to = to; + } + + public BinaryResponseDto from(String from) { + this.from = from; + return this; + } + + /** + * The sender number provided. Required if the Automatic Default Originator is not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + /** + * Indicates whether or not the batch has been canceled. + * + * @return canceled + */ + @JsonProperty(JSON_PROPERTY_CANCELED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getCanceled() { + return canceled; + } + + public BinaryResponseDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content provided. Base64 encoded. + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + public BinaryResponseDto udh(String udh) { + this.udh = udh; + return this; + } + + /** + * The <a + * href=\"https://community.sinch.com/t5/Glossary/UDH-User-Data-Header/ta-p/7776\" + * target=\"_blank\">UDH</a> header of a binary message HEX encoded. Max + * 140 bytes including the `body`. + * + * @return udh + */ + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getUdh() { + return udh; + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setUdh(String udh) { + this.udh = udh; + } + + public BinaryResponseDto type(String type) { + this.type = type; + return this; + } + + /** + * SMS in <a + * href=\"https://community.sinch.com/t5/Glossary/Binary-SMS/ta-p/7470\" + * target=\"_blank\">binary</a> format. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + /** + * Timestamp for when batch was created. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * Timestamp for when batch was last updated. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return modifiedAt + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getModifiedAt() { + return modifiedAt; + } + + public BinaryResponseDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * The delivery report callback option selected. Will be either `none`, + * `summary`, `full`, `per_recipient`, or + * `per_recipient_final`. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public BinaryResponseDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * If set, the date and time the message should be delivered. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public BinaryResponseDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * If set, the date and time the message will expire. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601). For example: + * `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public BinaryResponseDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * The callback URL provided in the request. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public BinaryResponseDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public BinaryResponseDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to true, then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public BinaryResponseDto flashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + /** + * If sent as a flash message, displays `true`. + * + * @return flashMessage + */ + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFlashMessage() { + return flashMessage; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + } + + public BinaryResponseDto truncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + /** + * If set to `true`, the message was shortened when exceeding one part. + * + * @return truncateConcat + */ + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getTruncateConcat() { + return truncateConcat; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + } + + public BinaryResponseDto maxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + /** + * Displays the number of message parts set in the request. minimum: 1 + * + * @return maxNumberOfMessageParts + */ + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + } + + public BinaryResponseDto fromTon(Integer fromTon) { + this.fromTon = fromTon; + return this; + } + + /** + * The type of number for the sender number. minimum: 0 maximum: 6 + * + * @return fromTon + */ + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromTon() { + return fromTon; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromTon(Integer fromTon) { + this.fromTon = fromTon; + } + + public BinaryResponseDto fromNpi(Integer fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + /** + * Number Plan Indicator for the sender number. minimum: 0 maximum: 18 + * + * @return fromNpi + */ + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromNpi() { + return fromNpi; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromNpi(Integer fromNpi) { + this.fromNpi = 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; + } + BinaryResponseDto binaryResponse = (BinaryResponseDto) 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.flashMessage, binaryResponse.flashMessage) + && Objects.equals(this.truncateConcat, binaryResponse.truncateConcat) + && Objects.equals(this.maxNumberOfMessageParts, binaryResponse.maxNumberOfMessageParts) + && 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, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BinaryResponseDto {\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(" 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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/CreateGroupResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/CreateGroupResponseDto.java new file mode 100644 index 00000000..25ac9bef --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/CreateGroupResponseDto.java @@ -0,0 +1,250 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.time.OffsetDateTime; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; + +/** CreateGroupResponseDto */ +@JsonPropertyOrder({ + CreateGroupResponseDto.JSON_PROPERTY_ID, + CreateGroupResponseDto.JSON_PROPERTY_NAME, + CreateGroupResponseDto.JSON_PROPERTY_SIZE, + CreateGroupResponseDto.JSON_PROPERTY_CREATED_AT, + CreateGroupResponseDto.JSON_PROPERTY_MODIFIED_AT, + CreateGroupResponseDto.JSON_PROPERTY_CHILD_GROUPS, + CreateGroupResponseDto.JSON_PROPERTY_AUTO_UPDATE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CreateGroupResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SIZE = "size"; + private Integer size; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private OffsetDateTime modifiedAt; + + public static final String JSON_PROPERTY_CHILD_GROUPS = "child_groups"; + private Set childGroups; + + public static final String JSON_PROPERTY_AUTO_UPDATE = "auto_update"; + private GroupAutoUpdateDto autoUpdate; + + public CreateGroupResponseDto() {} + + @JsonCreator + public CreateGroupResponseDto( + @JsonProperty(JSON_PROPERTY_SIZE) Integer size, + @JsonProperty(JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) OffsetDateTime modifiedAt) { + this(); + this.size = size; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + } + + public CreateGroupResponseDto id(String id) { + this.id = id; + return this; + } + + /** + * The ID used to reference this group. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setId(String id) { + this.id = id; + } + + public CreateGroupResponseDto name(String name) { + this.name = name; + return this; + } + + /** + * Name of group, if set. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + /** + * The number of members currently in the group. + * + * @return size + */ + @JsonProperty(JSON_PROPERTY_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getSize() { + return size; + } + + /** + * Timestamp for group creation. Format: YYYY-MM-DDThh:mm:ss.SSSZ + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * Timestamp for when the group was last updated. Format: YYYY-MM-DDThh:mm:ss.SSSZ + * + * @return modifiedAt + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getModifiedAt() { + return modifiedAt; + } + + public CreateGroupResponseDto childGroups(Set childGroups) { + this.childGroups = childGroups; + return this; + } + + public CreateGroupResponseDto addChildGroupsItem(Object childGroupsItem) { + if (this.childGroups == null) { + this.childGroups = new LinkedHashSet<>(); + } + this.childGroups.add(childGroupsItem); + return this; + } + + /** + * Phone numbers (MSISDNs) of child group will be included in this group. If present, this group + * will be auto populated. Constraints: Elements must be group IDs. + * + * @return childGroups + */ + @JsonProperty(JSON_PROPERTY_CHILD_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Set getChildGroups() { + return childGroups; + } + + @JsonDeserialize(as = LinkedHashSet.class) + @JsonProperty(JSON_PROPERTY_CHILD_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setChildGroups(Set childGroups) { + this.childGroups = childGroups; + } + + public CreateGroupResponseDto autoUpdate(GroupAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + return this; + } + + /** + * Get autoUpdate + * + * @return autoUpdate + */ + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public GroupAutoUpdateDto getAutoUpdate() { + return autoUpdate; + } + + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAutoUpdate(GroupAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + } + + /** Return true if this createGroupResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateGroupResponseDto createGroupResponse = (CreateGroupResponseDto) o; + return Objects.equals(this.id, createGroupResponse.id) + && Objects.equals(this.name, createGroupResponse.name) + && Objects.equals(this.size, createGroupResponse.size) + && Objects.equals(this.createdAt, createGroupResponse.createdAt) + && Objects.equals(this.modifiedAt, createGroupResponse.modifiedAt) + && Objects.equals(this.childGroups, createGroupResponse.childGroups) + && Objects.equals(this.autoUpdate, createGroupResponse.autoUpdate); + } + + @Override + public int hashCode() { + return Objects.hash(id, name, size, createdAt, modifiedAt, childGroups, autoUpdate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateGroupResponseDto {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" childGroups: ").append(toIndentedString(childGroups)).append("\n"); + sb.append(" autoUpdate: ").append(toIndentedString(autoUpdate)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportDto.java new file mode 100644 index 00000000..73c7465f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportDto.java @@ -0,0 +1,244 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** DeliveryReportDto */ +@JsonPropertyOrder({ + DeliveryReportDto.JSON_PROPERTY_BATCH_ID, + DeliveryReportDto.JSON_PROPERTY_STATUSES, + DeliveryReportDto.JSON_PROPERTY_TOTAL_MESSAGE_COUNT, + DeliveryReportDto.JSON_PROPERTY_TYPE, + DeliveryReportDto.JSON_PROPERTY_CLIENT_REFERENCE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DeliveryReportDto { + public static final String JSON_PROPERTY_BATCH_ID = "batch_id"; + private String batchId; + + public static final String JSON_PROPERTY_STATUSES = "statuses"; + private List statuses = new ArrayList<>(); + + public static final String JSON_PROPERTY_TOTAL_MESSAGE_COUNT = "total_message_count"; + private Integer totalMessageCount; + + /** The delivery report type. */ + public enum TypeEnum { + SMS("delivery_report_sms"), + + MMS("delivery_report_mms"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public DeliveryReportDto() {} + + @JsonCreator + public DeliveryReportDto(@JsonProperty(JSON_PROPERTY_BATCH_ID) String batchId) { + this(); + this.batchId = batchId; + } + + /** + * The ID of the batch this delivery report belongs to. + * + * @return batchId + */ + @JsonProperty(JSON_PROPERTY_BATCH_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBatchId() { + return batchId; + } + + public DeliveryReportDto statuses(List statuses) { + this.statuses = statuses; + return this; + } + + public DeliveryReportDto addStatusesItem(MessageDeliveryStatusDto statusesItem) { + if (this.statuses == null) { + this.statuses = new ArrayList<>(); + } + this.statuses.add(statusesItem); + return this; + } + + /** + * Array with status objects. Only status codes with at least one recipient will be listed. + * + * @return statuses + */ + @JsonProperty(JSON_PROPERTY_STATUSES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getStatuses() { + return statuses; + } + + @JsonProperty(JSON_PROPERTY_STATUSES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStatuses(List statuses) { + this.statuses = statuses; + } + + public DeliveryReportDto totalMessageCount(Integer totalMessageCount) { + this.totalMessageCount = totalMessageCount; + return this; + } + + /** + * The total number of messages in the batch. minimum: 0 + * + * @return totalMessageCount + */ + @JsonProperty(JSON_PROPERTY_TOTAL_MESSAGE_COUNT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getTotalMessageCount() { + return totalMessageCount; + } + + @JsonProperty(JSON_PROPERTY_TOTAL_MESSAGE_COUNT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTotalMessageCount(Integer totalMessageCount) { + this.totalMessageCount = totalMessageCount; + } + + public DeliveryReportDto type(String type) { + this.type = type; + return this; + } + + /** + * The delivery report type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public DeliveryReportDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of the batch this delivery report belongs to, if set when submitting + * batch. + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + /** Return true if this DeliveryReport object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeliveryReportDto deliveryReport = (DeliveryReportDto) o; + return Objects.equals(this.batchId, deliveryReport.batchId) + && Objects.equals(this.statuses, deliveryReport.statuses) + && Objects.equals(this.totalMessageCount, deliveryReport.totalMessageCount) + && Objects.equals(this.type, deliveryReport.type) + && Objects.equals(this.clientReference, deliveryReport.clientReference); + } + + @Override + public int hashCode() { + return Objects.hash(batchId, statuses, totalMessageCount, type, clientReference); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeliveryReportDto {\n"); + sb.append(" batchId: ").append(toIndentedString(batchId)).append("\n"); + sb.append(" statuses: ").append(toIndentedString(statuses)).append("\n"); + sb.append(" totalMessageCount: ").append(toIndentedString(totalMessageCount)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportListDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportListDto.java new file mode 100644 index 00000000..7104c459 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DeliveryReportListDto.java @@ -0,0 +1,184 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** DeliveryReportListDto */ +@JsonPropertyOrder({ + DeliveryReportListDto.JSON_PROPERTY_COUNT, + DeliveryReportListDto.JSON_PROPERTY_PAGE, + DeliveryReportListDto.JSON_PROPERTY_PAGE_SIZE, + DeliveryReportListDto.JSON_PROPERTY_DELIVERY_REPORTS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DeliveryReportListDto { + public static final String JSON_PROPERTY_COUNT = "count"; + private Long count; + + public static final String JSON_PROPERTY_PAGE = "page"; + private Integer page; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + private Integer pageSize; + + public static final String JSON_PROPERTY_DELIVERY_REPORTS = "delivery_reports"; + private List deliveryReports; + + public DeliveryReportListDto() {} + + public DeliveryReportListDto count(Long count) { + this.count = count; + return this; + } + + /** + * The total number of entries matching the given filters. + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getCount() { + return count; + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCount(Long count) { + this.count = count; + } + + public DeliveryReportListDto page(Integer page) { + this.page = page; + return this; + } + + /** + * The requested page. + * + * @return page + */ + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPage() { + return page; + } + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPage(Integer page) { + this.page = page; + } + + public DeliveryReportListDto pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * The number of entries returned in this request. + * + * @return pageSize + */ + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPageSize() { + return pageSize; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public DeliveryReportListDto deliveryReports(List deliveryReports) { + this.deliveryReports = deliveryReports; + return this; + } + + public DeliveryReportListDto addDeliveryReportsItem( + RecipientDeliveryReportDto deliveryReportsItem) { + if (this.deliveryReports == null) { + this.deliveryReports = new ArrayList<>(); + } + this.deliveryReports.add(deliveryReportsItem); + return this; + } + + /** + * The page of delivery reports matching the given filters. + * + * @return deliveryReports + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getDeliveryReports() { + return deliveryReports; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReports(List deliveryReports) { + this.deliveryReports = deliveryReports; + } + + /** Return true if this DeliveryReportList object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeliveryReportListDto deliveryReportList = (DeliveryReportListDto) o; + return Objects.equals(this.count, deliveryReportList.count) + && Objects.equals(this.page, deliveryReportList.page) + && Objects.equals(this.pageSize, deliveryReportList.pageSize) + && Objects.equals(this.deliveryReports, deliveryReportList.deliveryReports); + } + + @Override + public int hashCode() { + return Objects.hash(count, page, pageSize, deliveryReports); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeliveryReportListDto {\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" deliveryReports: ").append(toIndentedString(deliveryReports)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponseDto.java new file mode 100644 index 00000000..d02baa5d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponseDto.java @@ -0,0 +1,158 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** DryRun200ResponseDto */ +@JsonPropertyOrder({ + DryRun200ResponseDto.JSON_PROPERTY_NUMBER_OF_RECIPIENTS, + DryRun200ResponseDto.JSON_PROPERTY_NUMBER_OF_MESSAGES, + DryRun200ResponseDto.JSON_PROPERTY_PER_RECIPIENT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DryRun200ResponseDto { + public static final String JSON_PROPERTY_NUMBER_OF_RECIPIENTS = "number_of_recipients"; + private Integer numberOfRecipients; + + public static final String JSON_PROPERTY_NUMBER_OF_MESSAGES = "number_of_messages"; + private Integer numberOfMessages; + + public static final String JSON_PROPERTY_PER_RECIPIENT = "per_recipient"; + private List perRecipient; + + public DryRun200ResponseDto() {} + + public DryRun200ResponseDto numberOfRecipients(Integer numberOfRecipients) { + this.numberOfRecipients = numberOfRecipients; + return this; + } + + /** + * The number of recipients in the batch + * + * @return numberOfRecipients + */ + @JsonProperty(JSON_PROPERTY_NUMBER_OF_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getNumberOfRecipients() { + return numberOfRecipients; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberOfRecipients(Integer numberOfRecipients) { + this.numberOfRecipients = numberOfRecipients; + } + + public DryRun200ResponseDto numberOfMessages(Integer numberOfMessages) { + this.numberOfMessages = numberOfMessages; + return this; + } + + /** + * The total number of SMS message parts to be sent in the batch + * + * @return numberOfMessages + */ + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getNumberOfMessages() { + return numberOfMessages; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberOfMessages(Integer numberOfMessages) { + this.numberOfMessages = numberOfMessages; + } + + public DryRun200ResponseDto perRecipient( + List perRecipient) { + this.perRecipient = perRecipient; + return this; + } + + public DryRun200ResponseDto addPerRecipientItem( + DryRun200ResponsePerRecipientInnerDto perRecipientItem) { + if (this.perRecipient == null) { + this.perRecipient = new ArrayList<>(); + } + this.perRecipient.add(perRecipientItem); + return this; + } + + /** + * The recipient, the number of message parts to this recipient, the body of the message, and the + * encoding type of each message + * + * @return perRecipient + */ + @JsonProperty(JSON_PROPERTY_PER_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getPerRecipient() { + return perRecipient; + } + + @JsonProperty(JSON_PROPERTY_PER_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPerRecipient(List perRecipient) { + this.perRecipient = perRecipient; + } + + /** Return true if this Dry_Run_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DryRun200ResponseDto dryRun200Response = (DryRun200ResponseDto) o; + return Objects.equals(this.numberOfRecipients, dryRun200Response.numberOfRecipients) + && Objects.equals(this.numberOfMessages, dryRun200Response.numberOfMessages) + && Objects.equals(this.perRecipient, dryRun200Response.perRecipient); + } + + @Override + public int hashCode() { + return Objects.hash(numberOfRecipients, numberOfMessages, perRecipient); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DryRun200ResponseDto {\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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponsePerRecipientInnerDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponsePerRecipientInnerDto.java new file mode 100644 index 00000000..a13b62af --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRun200ResponsePerRecipientInnerDto.java @@ -0,0 +1,174 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** DryRun200ResponsePerRecipientInnerDto */ +@JsonPropertyOrder({ + DryRun200ResponsePerRecipientInnerDto.JSON_PROPERTY_RECIPIENT, + DryRun200ResponsePerRecipientInnerDto.JSON_PROPERTY_MESSAGE_PART, + DryRun200ResponsePerRecipientInnerDto.JSON_PROPERTY_BODY, + DryRun200ResponsePerRecipientInnerDto.JSON_PROPERTY_ENCODING +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class DryRun200ResponsePerRecipientInnerDto { + public static final String JSON_PROPERTY_RECIPIENT = "recipient"; + private String recipient; + + public static final String JSON_PROPERTY_MESSAGE_PART = "message_part"; + private String messagePart; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_ENCODING = "encoding"; + private String encoding; + + public DryRun200ResponsePerRecipientInnerDto() {} + + public DryRun200ResponsePerRecipientInnerDto recipient(String recipient) { + this.recipient = recipient; + return this; + } + + /** + * Get recipient + * + * @return recipient + */ + @JsonProperty(JSON_PROPERTY_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRecipient() { + return recipient; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRecipient(String recipient) { + this.recipient = recipient; + } + + public DryRun200ResponsePerRecipientInnerDto messagePart(String messagePart) { + this.messagePart = messagePart; + return this; + } + + /** + * Get messagePart + * + * @return messagePart + */ + @JsonProperty(JSON_PROPERTY_MESSAGE_PART) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessagePart() { + return messagePart; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE_PART) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessagePart(String messagePart) { + this.messagePart = messagePart; + } + + public DryRun200ResponsePerRecipientInnerDto body(String body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + public DryRun200ResponsePerRecipientInnerDto encoding(String encoding) { + this.encoding = encoding; + return this; + } + + /** + * Get encoding + * + * @return encoding + */ + @JsonProperty(JSON_PROPERTY_ENCODING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEncoding() { + return encoding; + } + + @JsonProperty(JSON_PROPERTY_ENCODING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + /** Return true if this Dry_Run_200_response_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; + } + DryRun200ResponsePerRecipientInnerDto dryRun200ResponsePerRecipientInner = + (DryRun200ResponsePerRecipientInnerDto) o; + return Objects.equals(this.recipient, dryRun200ResponsePerRecipientInner.recipient) + && Objects.equals(this.messagePart, dryRun200ResponsePerRecipientInner.messagePart) + && Objects.equals(this.body, dryRun200ResponsePerRecipientInner.body) + && Objects.equals(this.encoding, dryRun200ResponsePerRecipientInner.encoding); + } + + @Override + public int hashCode() { + return Objects.hash(recipient, messagePart, body, encoding); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DryRun200ResponsePerRecipientInnerDto {\n"); + sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); + sb.append(" messagePart: ").append(toIndentedString(messagePart)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRunRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRunRequestDto.java new file mode 100644 index 00000000..2addfefa --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/DryRunRequestDto.java @@ -0,0 +1,320 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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.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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize(using = DryRunRequestDto.DryRunRequestDtoDeserializer.class) +@JsonSerialize(using = DryRunRequestDto.DryRunRequestDtoSerializer.class) +public class DryRunRequestDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DryRunRequestDto.class.getName()); + + public static class DryRunRequestDtoSerializer extends StdSerializer { + public DryRunRequestDtoSerializer(Class t) { + super(t); + } + + public DryRunRequestDtoSerializer() { + this(null); + } + + @Override + public void serialize(DryRunRequestDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DryRunRequestDtoDeserializer extends StdDeserializer { + public DryRunRequestDtoDeserializer() { + this(DryRunRequestDto.class); + } + + public DryRunRequestDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public DryRunRequestDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize BinaryRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BinaryRequestDto.class.equals(Integer.class) + || BinaryRequestDto.class.equals(Long.class) + || BinaryRequestDto.class.equals(Float.class) + || BinaryRequestDto.class.equals(Double.class) + || BinaryRequestDto.class.equals(Boolean.class) + || BinaryRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((BinaryRequestDto.class.equals(Integer.class) + || BinaryRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((BinaryRequestDto.class.equals(Float.class) + || BinaryRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (BinaryRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (BinaryRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryRequestDto.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 'BinaryRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BinaryRequestDto'", e); + } + + // deserialize MediaRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MediaRequestDto.class.equals(Integer.class) + || MediaRequestDto.class.equals(Long.class) + || MediaRequestDto.class.equals(Float.class) + || MediaRequestDto.class.equals(Double.class) + || MediaRequestDto.class.equals(Boolean.class) + || MediaRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MediaRequestDto.class.equals(Integer.class) + || MediaRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MediaRequestDto.class.equals(Float.class) + || MediaRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MediaRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MediaRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaRequestDto.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 'MediaRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MediaRequestDto'", e); + } + + // deserialize TextRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (TextRequestDto.class.equals(Integer.class) + || TextRequestDto.class.equals(Long.class) + || TextRequestDto.class.equals(Float.class) + || TextRequestDto.class.equals(Double.class) + || TextRequestDto.class.equals(Boolean.class) + || TextRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((TextRequestDto.class.equals(Integer.class) + || TextRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((TextRequestDto.class.equals(Float.class) + || TextRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (TextRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (TextRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextRequestDto.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 'TextRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'TextRequestDto'", e); + } + + if (match == 1) { + DryRunRequestDto ret = new DryRunRequestDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for DryRunRequestDto: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public DryRunRequestDto getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DryRunRequestDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public DryRunRequestDto() { + super("oneOf", Boolean.FALSE); + } + + public DryRunRequestDto(BinaryRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DryRunRequestDto(MediaRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DryRunRequestDto(TextRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("BinaryRequestDto", BinaryRequestDto.class); + schemas.put("MediaRequestDto", MediaRequestDto.class); + schemas.put("TextRequestDto", TextRequestDto.class); + JSONNavigator.registerDescendants(DryRunRequestDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return DryRunRequestDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: BinaryRequestDto, MediaRequestDto, TextRequestDto + * + *

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(BinaryRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MediaRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(TextRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be BinaryRequestDto, MediaRequestDto, TextRequestDto"); + } + + /** + * Get the actual instance, which can be the following: BinaryRequestDto, MediaRequestDto, + * TextRequestDto + * + * @return The actual instance (BinaryRequestDto, MediaRequestDto, TextRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `BinaryRequestDto`. If the actual instance is not + * `BinaryRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `BinaryRequestDto` + * @throws ClassCastException if the instance is not `BinaryRequestDto` + */ + public BinaryRequestDto getBinaryRequestDto() throws ClassCastException { + return (BinaryRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MediaRequestDto`. If the actual instance is not `MediaRequestDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MediaRequestDto` + * @throws ClassCastException if the instance is not `MediaRequestDto` + */ + public MediaRequestDto getMediaRequestDto() throws ClassCastException { + return (MediaRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `TextRequestDto`. If the actual instance is not `TextRequestDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TextRequestDto` + * @throws ClassCastException if the instance is not `TextRequestDto` + */ + public TextRequestDto getTextRequestDto() throws ClassCastException { + return (TextRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ErrorResponseObjDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ErrorResponseObjDto.java new file mode 100644 index 00000000..d8231c65 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ErrorResponseObjDto.java @@ -0,0 +1,114 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** ErrorResponseObjDto */ +@JsonPropertyOrder({ErrorResponseObjDto.JSON_PROPERTY_CODE, ErrorResponseObjDto.JSON_PROPERTY_TEXT}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ErrorResponseObjDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_TEXT = "text"; + private String text; + + public ErrorResponseObjDto() {} + + public ErrorResponseObjDto code(String code) { + this.code = code; + return this; + } + + /** + * The error code. See [error codes](/docs/sms/api-reference/#error-codes). + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCode(String code) { + this.code = code; + } + + public ErrorResponseObjDto text(String text) { + this.text = text; + return this; + } + + /** + * The human readable description of the error. + * + * @return text + */ + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getText() { + return text; + } + + @JsonProperty(JSON_PROPERTY_TEXT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setText(String text) { + this.text = text; + } + + /** Return true if this errorResponseObj object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorResponseObjDto errorResponseObj = (ErrorResponseObjDto) o; + return Objects.equals(this.code, errorResponseObj.code) + && Objects.equals(this.text, errorResponseObj.text); + } + + @Override + public int hashCode() { + return Objects.hash(code, text); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponseObjDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" text: ").append(toIndentedString(text)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupAutoUpdateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupAutoUpdateDto.java new file mode 100644 index 00000000..b674a895 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupAutoUpdateDto.java @@ -0,0 +1,148 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** GroupAutoUpdateDto */ +@JsonPropertyOrder({ + GroupAutoUpdateDto.JSON_PROPERTY_TO, + GroupAutoUpdateDto.JSON_PROPERTY_ADD, + GroupAutoUpdateDto.JSON_PROPERTY_REMOVE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GroupAutoUpdateDto { + public static final String JSON_PROPERTY_TO = "to"; + private String to; + + public static final String JSON_PROPERTY_ADD = "add"; + private String add; + + public static final String JSON_PROPERTY_REMOVE = "remove"; + private String remove; + + public GroupAutoUpdateDto() {} + + public GroupAutoUpdateDto to(String to) { + this.to = to; + return this; + } + + /** + * Short code or long number addressed in <a + * href=\"https://community.sinch.com/t5/Glossary/MO-Mobile-Originated/ta-p/7618\" + * target=\"_blank\">MO</a>. Constraints: Must be valid MSISDN or short + * code. + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTo(String to) { + this.to = to; + } + + public GroupAutoUpdateDto add(String add) { + this.add = add; + return this; + } + + /** + * Get add + * + * @return add + */ + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAdd() { + return add; + } + + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAdd(String add) { + this.add = add; + } + + public GroupAutoUpdateDto remove(String remove) { + this.remove = remove; + return this; + } + + /** + * Get remove + * + * @return remove + */ + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRemove() { + return remove; + } + + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRemove(String remove) { + this.remove = remove; + } + + /** Return true if this GroupAutoUpdate object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroupAutoUpdateDto groupAutoUpdate = (GroupAutoUpdateDto) o; + return Objects.equals(this.to, groupAutoUpdate.to) + && Objects.equals(this.add, groupAutoUpdate.add) + && Objects.equals(this.remove, groupAutoUpdate.remove); + } + + @Override + public int hashCode() { + return Objects.hash(to, add, remove); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GroupAutoUpdateDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateDto.java new file mode 100644 index 00000000..2947e3bc --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateDto.java @@ -0,0 +1,148 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** GroupObjectAutoUpdateDto */ +@JsonPropertyOrder({ + GroupObjectAutoUpdateDto.JSON_PROPERTY_TO, + GroupObjectAutoUpdateDto.JSON_PROPERTY_ADD, + GroupObjectAutoUpdateDto.JSON_PROPERTY_REMOVE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GroupObjectAutoUpdateDto { + public static final String JSON_PROPERTY_TO = "to"; + private String to; + + public static final String JSON_PROPERTY_ADD = "add"; + private UpdateGroupRequestAutoUpdateAddDto add; + + public static final String JSON_PROPERTY_REMOVE = "remove"; + private GroupObjectAutoUpdateRemoveDto remove; + + public GroupObjectAutoUpdateDto() {} + + public GroupObjectAutoUpdateDto to(String to) { + this.to = to; + return this; + } + + /** + * Short code or long number addressed in <a + * href=\"https://community.sinch.com/t5/Glossary/MO-Mobile-Originated/ta-p/7618\" + * target=\"_blank\">MO</a>. Constraints: Must be valid phone number or + * short code. + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTo(String to) { + this.to = to; + } + + public GroupObjectAutoUpdateDto add(UpdateGroupRequestAutoUpdateAddDto add) { + this.add = add; + return this; + } + + /** + * Get add + * + * @return add + */ + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdateGroupRequestAutoUpdateAddDto getAdd() { + return add; + } + + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAdd(UpdateGroupRequestAutoUpdateAddDto add) { + this.add = add; + } + + public GroupObjectAutoUpdateDto remove(GroupObjectAutoUpdateRemoveDto remove) { + this.remove = remove; + return this; + } + + /** + * Get remove + * + * @return remove + */ + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public GroupObjectAutoUpdateRemoveDto getRemove() { + return remove; + } + + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRemove(GroupObjectAutoUpdateRemoveDto remove) { + this.remove = remove; + } + + /** Return true if this groupObject_auto_update object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroupObjectAutoUpdateDto groupObjectAutoUpdate = (GroupObjectAutoUpdateDto) o; + return Objects.equals(this.to, groupObjectAutoUpdate.to) + && Objects.equals(this.add, groupObjectAutoUpdate.add) + && Objects.equals(this.remove, groupObjectAutoUpdate.remove); + } + + @Override + public int hashCode() { + return Objects.hash(to, add, remove); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GroupObjectAutoUpdateDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateRemoveDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateRemoveDto.java new file mode 100644 index 00000000..dedc1987 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectAutoUpdateRemoveDto.java @@ -0,0 +1,120 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Keyword to be sent in MO to remove from a group. */ +@JsonPropertyOrder({ + GroupObjectAutoUpdateRemoveDto.JSON_PROPERTY_FIRST_WORD, + GroupObjectAutoUpdateRemoveDto.JSON_PROPERTY_SECOND_WORD +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GroupObjectAutoUpdateRemoveDto { + public static final String JSON_PROPERTY_FIRST_WORD = "first_word"; + private String firstWord; + + public static final String JSON_PROPERTY_SECOND_WORD = "second_word"; + private String secondWord; + + public GroupObjectAutoUpdateRemoveDto() {} + + public GroupObjectAutoUpdateRemoveDto firstWord(String firstWord) { + this.firstWord = firstWord; + return this; + } + + /** + * Opt-out keyword like \"LEAVE\" If auto_update.to is dedicated long/short number or + * unique brand keyword like \"Sinch\" if it is a shared short code. Constraints: Must + * be one word. + * + * @return firstWord + */ + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstWord() { + return firstWord; + } + + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstWord(String firstWord) { + this.firstWord = firstWord; + } + + public GroupObjectAutoUpdateRemoveDto secondWord(String secondWord) { + this.secondWord = secondWord; + return this; + } + + /** + * Opt-out keyword like \"LEAVE\" if auto_update.to is shared short code. Constraints: + * Must be one word. + * + * @return secondWord + */ + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSecondWord() { + return secondWord; + } + + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSecondWord(String secondWord) { + this.secondWord = secondWord; + } + + /** Return true if this groupObject_auto_update_remove object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroupObjectAutoUpdateRemoveDto groupObjectAutoUpdateRemove = (GroupObjectAutoUpdateRemoveDto) o; + return Objects.equals(this.firstWord, groupObjectAutoUpdateRemove.firstWord) + && Objects.equals(this.secondWord, groupObjectAutoUpdateRemove.secondWord); + } + + @Override + public int hashCode() { + return Objects.hash(firstWord, secondWord); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GroupObjectAutoUpdateRemoveDto {\n"); + sb.append(" firstWord: ").append(toIndentedString(firstWord)).append("\n"); + sb.append(" secondWord: ").append(toIndentedString(secondWord)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectDto.java new file mode 100644 index 00000000..24ac5ba3 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/GroupObjectDto.java @@ -0,0 +1,199 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** GroupObjectDto */ +@JsonPropertyOrder({ + GroupObjectDto.JSON_PROPERTY_NAME, + GroupObjectDto.JSON_PROPERTY_MEMBERS, + GroupObjectDto.JSON_PROPERTY_CHILD_GROUPS, + GroupObjectDto.JSON_PROPERTY_AUTO_UPDATE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class GroupObjectDto { + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_MEMBERS = "members"; + private List members; + + public static final String JSON_PROPERTY_CHILD_GROUPS = "child_groups"; + private List childGroups; + + public static final String JSON_PROPERTY_AUTO_UPDATE = "auto_update"; + private GroupObjectAutoUpdateDto autoUpdate; + + public GroupObjectDto() {} + + public GroupObjectDto name(String name) { + this.name = name; + return this; + } + + /** + * Name of the group + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public GroupObjectDto members(List members) { + this.members = members; + return this; + } + + public GroupObjectDto addMembersItem(String membersItem) { + if (this.members == null) { + this.members = new ArrayList<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * \"Initial list of phone numbers in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format <a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">MSISDNs</a> for the group.\" + * + * @return members + */ + @JsonProperty(JSON_PROPERTY_MEMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getMembers() { + return members; + } + + @JsonProperty(JSON_PROPERTY_MEMBERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMembers(List members) { + this.members = members; + } + + public GroupObjectDto childGroups(List childGroups) { + this.childGroups = childGroups; + return this; + } + + public GroupObjectDto addChildGroupsItem(String childGroupsItem) { + if (this.childGroups == null) { + this.childGroups = new ArrayList<>(); + } + this.childGroups.add(childGroupsItem); + return this; + } + + /** + * Phone numbers (<a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">MSISDNs</a>) of child group will be included in this + * group. If present then this group will be auto populated. Constraints: Elements must be group + * IDs. + * + * @return childGroups + */ + @JsonProperty(JSON_PROPERTY_CHILD_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getChildGroups() { + return childGroups; + } + + @JsonProperty(JSON_PROPERTY_CHILD_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setChildGroups(List childGroups) { + this.childGroups = childGroups; + } + + public GroupObjectDto autoUpdate(GroupObjectAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + return this; + } + + /** + * Get autoUpdate + * + * @return autoUpdate + */ + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public GroupObjectAutoUpdateDto getAutoUpdate() { + return autoUpdate; + } + + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAutoUpdate(GroupObjectAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + } + + /** Return true if this groupObject object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GroupObjectDto groupObject = (GroupObjectDto) o; + return Objects.equals(this.name, groupObject.name) + && Objects.equals(this.members, groupObject.members) + && Objects.equals(this.childGroups, groupObject.childGroups) + && Objects.equals(this.autoUpdate, groupObject.autoUpdate); + } + + @Override + public int hashCode() { + return Objects.hash(name, members, childGroups, autoUpdate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GroupObjectDto {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" childGroups: ").append(toIndentedString(childGroups)).append("\n"); + sb.append(" autoUpdate: ").append(toIndentedString(autoUpdate)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ListGroups200ResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ListGroups200ResponseDto.java new file mode 100644 index 00000000..3aa4b4cf --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ListGroups200ResponseDto.java @@ -0,0 +1,183 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ListGroups200ResponseDto */ +@JsonPropertyOrder({ + ListGroups200ResponseDto.JSON_PROPERTY_PAGE, + ListGroups200ResponseDto.JSON_PROPERTY_PAGE_SIZE, + ListGroups200ResponseDto.JSON_PROPERTY_COUNT, + ListGroups200ResponseDto.JSON_PROPERTY_GROUPS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ListGroups200ResponseDto { + public static final String JSON_PROPERTY_PAGE = "page"; + private Integer page; + + public static final String JSON_PROPERTY_PAGE_SIZE = "page_size"; + private Integer pageSize; + + public static final String JSON_PROPERTY_COUNT = "count"; + private Integer count; + + public static final String JSON_PROPERTY_GROUPS = "groups"; + private List groups; + + public ListGroups200ResponseDto() {} + + public ListGroups200ResponseDto page(Integer page) { + this.page = page; + return this; + } + + /** + * The requested page. + * + * @return page + */ + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPage() { + return page; + } + + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPage(Integer page) { + this.page = page; + } + + public ListGroups200ResponseDto pageSize(Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * The number of groups returned in this request + * + * @return pageSize + */ + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getPageSize() { + return pageSize; + } + + @JsonProperty(JSON_PROPERTY_PAGE_SIZE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public ListGroups200ResponseDto count(Integer count) { + this.count = count; + return this; + } + + /** + * The total number of groups. + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getCount() { + return count; + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCount(Integer count) { + this.count = count; + } + + public ListGroups200ResponseDto groups(List groups) { + this.groups = groups; + return this; + } + + public ListGroups200ResponseDto addGroupsItem(GroupObjectDto groupsItem) { + if (this.groups == null) { + this.groups = new ArrayList<>(); + } + this.groups.add(groupsItem); + return this; + } + + /** + * Get groups + * + * @return groups + */ + @JsonProperty(JSON_PROPERTY_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getGroups() { + return groups; + } + + @JsonProperty(JSON_PROPERTY_GROUPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGroups(List groups) { + this.groups = groups; + } + + /** Return true if this ListGroups_200_response object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListGroups200ResponseDto listGroups200Response = (ListGroups200ResponseDto) o; + return Objects.equals(this.page, listGroups200Response.page) + && Objects.equals(this.pageSize, listGroups200Response.pageSize) + && Objects.equals(this.count, listGroups200Response.count) + && Objects.equals(this.groups, listGroups200Response.groups); + } + + @Override + public int hashCode() { + return Objects.hash(page, pageSize, count, groups); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListGroups200ResponseDto {\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" groups: ").append(toIndentedString(groups)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDto.java new file mode 100644 index 00000000..f3fa0785 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDto.java @@ -0,0 +1,240 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** MOBinaryDto */ +@JsonPropertyOrder({ + MOBinaryDto.JSON_PROPERTY_BODY, + MOBinaryDto.JSON_PROPERTY_UDH, + MOBinaryDto.JSON_PROPERTY_TYPE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +/*@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true) +public class MOBinaryDto extends ApiMoMessageDto { + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_UDH = "udh"; + private String udh; + + /** SMS in binary format */ + public enum TypeEnum { + MO_BINARY("mo_binary"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public MOBinaryDto() {} + + @JsonCreator + public MOBinaryDto(@JsonProperty(JSON_PROPERTY_TYPE) String type) { + this(); + this.type = type; + } + + public MOBinaryDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content Base64 encoded. Max 140 bytes together with udh. + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBody(String body) { + this.body = body; + } + + public MOBinaryDto udh(String udh) { + this.udh = udh; + return this; + } + + /** + * The UDH header of a binary message HEX encoded. Max 140 bytes together with body. + * + * @return udh + */ + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUdh() { + return udh; + } + + @JsonProperty(JSON_PROPERTY_UDH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setUdh(String udh) { + this.udh = udh; + } + + /** + * SMS in binary format + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @Override + public MOBinaryDto from(String from) { + this.setFrom(from); + return this; + } + + @Override + public MOBinaryDto id(String id) { + this.setId(id); + return this; + } + + @Override + public MOBinaryDto receivedAt(OffsetDateTime receivedAt) { + this.setReceivedAt(receivedAt); + return this; + } + + @Override + public MOBinaryDto to(String to) { + this.setTo(to); + return this; + } + + @Override + public MOBinaryDto clientReference(String clientReference) { + this.setClientReference(clientReference); + return this; + } + + @Override + public MOBinaryDto operatorId(String operatorId) { + this.setOperatorId(operatorId); + return this; + } + + @Override + public MOBinaryDto sentAt(OffsetDateTime sentAt) { + this.setSentAt(sentAt); + return this; + } + + /** Return true if this MOBinary object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MOBinaryDto moBinary = (MOBinaryDto) o; + return Objects.equals(this.body, moBinary.body) + && Objects.equals(this.udh, moBinary.udh) + && Objects.equals(this.type, moBinary.type) + && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(body, udh, type, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MOBinaryDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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("}"); + 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 "); + } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("MOBinary", MOBinaryDto.class); + JSONNavigator.registerDiscriminator(MOBinaryDto.class, "type", mappings); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDto.java new file mode 100644 index 00000000..a0609af5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDto.java @@ -0,0 +1,209 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** MOTextDto */ +@JsonPropertyOrder({MOTextDto.JSON_PROPERTY_BODY, MOTextDto.JSON_PROPERTY_TYPE}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +/*@JsonIgnoreProperties( + value = "type", // ignore manually set type, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the type to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true) +public class MOTextDto extends ApiMoMessageDto { + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + /** Regular SMS */ + public enum TypeEnum { + MO_TEXT("mo_text"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public MOTextDto() {} + + @JsonCreator + public MOTextDto(@JsonProperty(JSON_PROPERTY_TYPE) String type) { + this(); + this.type = type; + } + + public MOTextDto body(String body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBody(String body) { + this.body = body; + } + + /** + * Regular SMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @Override + public MOTextDto from(String from) { + this.setFrom(from); + return this; + } + + @Override + public MOTextDto id(String id) { + this.setId(id); + return this; + } + + @Override + public MOTextDto receivedAt(OffsetDateTime receivedAt) { + this.setReceivedAt(receivedAt); + return this; + } + + @Override + public MOTextDto to(String to) { + this.setTo(to); + return this; + } + + @Override + public MOTextDto clientReference(String clientReference) { + this.setClientReference(clientReference); + return this; + } + + @Override + public MOTextDto operatorId(String operatorId) { + this.setOperatorId(operatorId); + return this; + } + + @Override + public MOTextDto sentAt(OffsetDateTime sentAt) { + this.setSentAt(sentAt); + return this; + } + + /** Return true if this MOText object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MOTextDto moText = (MOTextDto) o; + return Objects.equals(this.body, moText.body) + && Objects.equals(this.type, moText.type) + && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(body, type, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MOTextDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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 "); + } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("MOText", MOTextDto.class); + JSONNavigator.registerDiscriminator(MOTextDto.class, "type", mappings); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaBodyDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaBodyDto.java new file mode 100644 index 00000000..45e2ce21 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaBodyDto.java @@ -0,0 +1,114 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** The message content, including a URL to the media file */ +@JsonPropertyOrder({MediaBodyDto.JSON_PROPERTY_URL, MediaBodyDto.JSON_PROPERTY_MESSAGE}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MediaBodyDto { + public static final String JSON_PROPERTY_URL = "url"; + private String url; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public MediaBodyDto() {} + + public MediaBodyDto url(String url) { + this.url = url; + return this; + } + + /** + * URL to the media file + * + * @return url + */ + @JsonProperty(JSON_PROPERTY_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getUrl() { + return url; + } + + @JsonProperty(JSON_PROPERTY_URL) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setUrl(String url) { + this.url = url; + } + + public MediaBodyDto message(String message) { + this.message = message; + return this; + } + + /** + * The message text. Text only media messages will be rejected, please use SMS instead. + * + * @return message + */ + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMessage() { + return message; + } + + @JsonProperty(JSON_PROPERTY_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMessage(String message) { + this.message = message; + } + + /** 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; + } + MediaBodyDto mediaBody = (MediaBodyDto) o; + return Objects.equals(this.url, mediaBody.url) + && Objects.equals(this.message, mediaBody.message); + } + + @Override + public int hashCode() { + return Objects.hash(url, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MediaBodyDto {\n"); + sb.append(" url: ").append(toIndentedString(url)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaRequestDto.java new file mode 100644 index 00000000..d2c37eed --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaRequestDto.java @@ -0,0 +1,466 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Only available in the US. Contact support if you wish to send MMS. */ +@JsonPropertyOrder({ + MediaRequestDto.JSON_PROPERTY_TO, + MediaRequestDto.JSON_PROPERTY_BODY, + MediaRequestDto.JSON_PROPERTY_FROM, + MediaRequestDto.JSON_PROPERTY_PARAMETERS, + MediaRequestDto.JSON_PROPERTY_TYPE, + MediaRequestDto.JSON_PROPERTY_DELIVERY_REPORT, + MediaRequestDto.JSON_PROPERTY_SEND_AT, + MediaRequestDto.JSON_PROPERTY_EXPIRE_AT, + MediaRequestDto.JSON_PROPERTY_CALLBACK_URL, + MediaRequestDto.JSON_PROPERTY_CLIENT_REFERENCE, + MediaRequestDto.JSON_PROPERTY_FEEDBACK_ENABLED, + MediaRequestDto.JSON_PROPERTY_STRICT_VALIDATION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MediaRequestDto { + public static final String JSON_PROPERTY_TO = "to"; + private List to = new ArrayList<>(); + + public static final String JSON_PROPERTY_BODY = "body"; + private MediaBodyDto body; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + /** MMS */ + public enum TypeEnum { + MT_MEDIA("mt_media"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + private Boolean strictValidation = false; + + public MediaRequestDto() {} + + @JsonCreator + public MediaRequestDto(@JsonProperty(JSON_PROPERTY_TYPE) String type) { + this(); + this.type = type; + } + + public MediaRequestDto to(List to) { + this.to = to; + return this; + } + + public MediaRequestDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * List of Phone numbers and group IDs that will receive the batch. <a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">More info</a> + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTo(List to) { + this.to = to; + } + + public MediaRequestDto body(MediaBodyDto body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public MediaBodyDto getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBody(MediaBodyDto body) { + this.body = body; + } + + public MediaRequestDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public MediaRequestDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + /** + * MMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + public MediaRequestDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public MediaRequestDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * 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 <a href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public MediaRequestDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 <a + * href=\"https://en.wikipedia.org/wiki/ISO_8601\" + * target=\"_blank\">ISO-8601</a>: `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public MediaRequestDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public MediaRequestDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public MediaRequestDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to `true`, then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public MediaRequestDto strictValidation(Boolean strictValidation) { + this.strictValidation = strictValidation; + return this; + } + + /** + * Whether or not you want the media included in your message to be checked against [Sinch MMS + * channel best practices](/docs/mms/bestpractices/). 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 + */ + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getStrictValidation() { + return strictValidation; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStrictValidation(Boolean strictValidation) { + this.strictValidation = 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; + } + MediaRequestDto mediaRequest = (MediaRequestDto) o; + return Objects.equals(this.to, mediaRequest.to) + && Objects.equals(this.body, mediaRequest.body) + && Objects.equals(this.from, mediaRequest.from) + && 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, + body, + from, + parameters, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + strictValidation); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MediaRequestDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDto.java new file mode 100644 index 00000000..6999b5c8 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDto.java @@ -0,0 +1,542 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** MediaResponseDto */ +@JsonPropertyOrder({ + MediaResponseDto.JSON_PROPERTY_ID, + MediaResponseDto.JSON_PROPERTY_TO, + MediaResponseDto.JSON_PROPERTY_FROM, + MediaResponseDto.JSON_PROPERTY_CANCELED, + MediaResponseDto.JSON_PROPERTY_BODY, + MediaResponseDto.JSON_PROPERTY_PARAMETERS, + MediaResponseDto.JSON_PROPERTY_TYPE, + MediaResponseDto.JSON_PROPERTY_CREATED_AT, + MediaResponseDto.JSON_PROPERTY_MODIFIED_AT, + MediaResponseDto.JSON_PROPERTY_DELIVERY_REPORT, + MediaResponseDto.JSON_PROPERTY_SEND_AT, + MediaResponseDto.JSON_PROPERTY_EXPIRE_AT, + MediaResponseDto.JSON_PROPERTY_CALLBACK_URL, + MediaResponseDto.JSON_PROPERTY_CLIENT_REFERENCE, + MediaResponseDto.JSON_PROPERTY_FEEDBACK_ENABLED, + MediaResponseDto.JSON_PROPERTY_STRICT_VALIDATION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MediaResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TO = "to"; + private List to; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + private Boolean canceled = false; + + public static final String JSON_PROPERTY_BODY = "body"; + private MediaBodyDto body; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + /** Media message */ + public enum TypeEnum { + MT_MEDIA("mt_media"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private OffsetDateTime modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_STRICT_VALIDATION = "strict_validation"; + private Boolean strictValidation; + + public MediaResponseDto() {} + + @JsonCreator + public MediaResponseDto( + @JsonProperty(JSON_PROPERTY_ID) String id, + @JsonProperty(JSON_PROPERTY_CANCELED) Boolean canceled, + @JsonProperty(JSON_PROPERTY_TYPE) String type, + @JsonProperty(JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) OffsetDateTime modifiedAt) { + this(); + this.id = id; + this.canceled = canceled; + this.type = type; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + } + + /** + * Unique identifier for batch + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public MediaResponseDto to(List to) { + this.to = to; + return this; + } + + public MediaResponseDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * List of Phone numbers and group IDs that will receive the batch. [More + * info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628) + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTo(List to) { + this.to = to; + } + + public MediaResponseDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Required if Automatic Default Originator not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + /** + * Indicates if the batch has been canceled or not. + * + * @return canceled + */ + @JsonProperty(JSON_PROPERTY_CANCELED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getCanceled() { + return canceled; + } + + public MediaResponseDto body(MediaBodyDto body) { + this.body = body; + return this; + } + + /** + * Get body + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public MediaBodyDto getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(MediaBodyDto body) { + this.body = body; + } + + public MediaResponseDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + /** + * Media message + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + /** + * Timestamp for when batch was created. YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * Timestamp for when batch was last updated. YYYY-MM-DDThh:mm:ss.SSSZ format + * + * @return modifiedAt + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getModifiedAt() { + return modifiedAt; + } + + public MediaResponseDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public MediaResponseDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public MediaResponseDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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 + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public MediaResponseDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public MediaResponseDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public MediaResponseDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to true then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public MediaResponseDto strictValidation(Boolean strictValidation) { + this.strictValidation = strictValidation; + return this; + } + + /** + * Whether or not you want the media included in your message to be checked against [Sinch MMS + * channel best practices](/docs/mms/bestpractices/). 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 + */ + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getStrictValidation() { + return strictValidation; + } + + @JsonProperty(JSON_PROPERTY_STRICT_VALIDATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStrictValidation(Boolean strictValidation) { + this.strictValidation = 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; + } + MediaResponseDto mediaResponse = (MediaResponseDto) 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 MediaResponseDto {\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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MessageDeliveryStatusDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MessageDeliveryStatusDto.java new file mode 100644 index 00000000..465eb7a8 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/MessageDeliveryStatusDto.java @@ -0,0 +1,186 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import java.util.LinkedHashSet; +import java.util.Objects; +import java.util.Set; + +/** Array with status objects. Only status codes with at least one recipient will be listed. */ +@JsonPropertyOrder({ + MessageDeliveryStatusDto.JSON_PROPERTY_CODE, + MessageDeliveryStatusDto.JSON_PROPERTY_COUNT, + MessageDeliveryStatusDto.JSON_PROPERTY_RECIPIENTS, + MessageDeliveryStatusDto.JSON_PROPERTY_STATUS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MessageDeliveryStatusDto { + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_COUNT = "count"; + private Integer count; + + public static final String JSON_PROPERTY_RECIPIENTS = "recipients"; + private Set recipients = new LinkedHashSet<>(); + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + public MessageDeliveryStatusDto() {} + + public MessageDeliveryStatusDto code(Integer code) { + this.code = code; + return this; + } + + /** + * The detailed status code. + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setCode(Integer code) { + this.code = code; + } + + public MessageDeliveryStatusDto count(Integer count) { + this.count = count; + return this; + } + + /** + * The number of messages that currently has this code. minimum: 1 + * + * @return count + */ + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getCount() { + return count; + } + + @JsonProperty(JSON_PROPERTY_COUNT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setCount(Integer count) { + this.count = count; + } + + public MessageDeliveryStatusDto recipients(Set recipients) { + this.recipients = recipients; + return this; + } + + public MessageDeliveryStatusDto addRecipientsItem(String recipientsItem) { + if (this.recipients == null) { + this.recipients = new LinkedHashSet<>(); + } + this.recipients.add(recipientsItem); + return this; + } + + /** + * Only for `full` report. A list of the phone number recipients which messages has this + * status code. + * + * @return recipients + */ + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Set getRecipients() { + return recipients; + } + + @JsonDeserialize(as = LinkedHashSet.class) + @JsonProperty(JSON_PROPERTY_RECIPIENTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipients(Set recipients) { + this.recipients = recipients; + } + + public MessageDeliveryStatusDto status(String status) { + this.status = status; + return this; + } + + /** + * The simplified status as described in _Delivery Report Statuses_. + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStatus(String status) { + this.status = status; + } + + /** Return true if this MessageDeliveryStatus object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MessageDeliveryStatusDto messageDeliveryStatus = (MessageDeliveryStatusDto) o; + return Objects.equals(this.code, messageDeliveryStatus.code) + && Objects.equals(this.count, messageDeliveryStatus.count) + && Objects.equals(this.recipients, messageDeliveryStatus.recipients) + && Objects.equals(this.status, messageDeliveryStatus.status); + } + + @Override + public int hashCode() { + return Objects.hash(code, count, recipients, status); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MessageDeliveryStatusDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).append("\n"); + sb.append(" recipients: ").append(toIndentedString(recipients)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjDto.java new file mode 100644 index 00000000..21a5caed --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjDto.java @@ -0,0 +1,159 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** + * Contains the parameters that will be used for customizing the message for each recipient. [Click + * here to learn more about + * parameterization](/docs/sms/resources/message-info/message-parameterization). + */ +@JsonPropertyOrder({ + ParameterObjDto.JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ParameterObjDto extends HashMap { + public static final String JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET = + "{parameter_key}"; + private ParameterObjParameterKeyDto leftCurlyBracketParameterKeyRightCurlyBracket; + + public ParameterObjDto() {} + + public ParameterObjDto leftCurlyBracketParameterKeyRightCurlyBracket( + ParameterObjParameterKeyDto leftCurlyBracketParameterKeyRightCurlyBracket) { + this.leftCurlyBracketParameterKeyRightCurlyBracket = + leftCurlyBracketParameterKeyRightCurlyBracket; + return this; + } + + /** + * Get leftCurlyBracketParameterKeyRightCurlyBracket + * + * @return leftCurlyBracketParameterKeyRightCurlyBracket + */ + @JsonProperty(JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjParameterKeyDto getLeftCurlyBracketParameterKeyRightCurlyBracket() { + return leftCurlyBracketParameterKeyRightCurlyBracket; + } + + @JsonProperty(JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLeftCurlyBracketParameterKeyRightCurlyBracket( + ParameterObjParameterKeyDto leftCurlyBracketParameterKeyRightCurlyBracket) { + this.leftCurlyBracketParameterKeyRightCurlyBracket = + leftCurlyBracketParameterKeyRightCurlyBracket; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key the name of the property + * @param value the value of the property + * @return self reference + */ + @JsonAnySetter + public ParameterObjDto putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) properties. + * + * @return the additional (undeclared) properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key the name of the property + * @return the additional (undeclared) property with the specified name + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this parameterObj object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParameterObjDto parameterObj = (ParameterObjDto) o; + return Objects.equals( + this.leftCurlyBracketParameterKeyRightCurlyBracket, + parameterObj.leftCurlyBracketParameterKeyRightCurlyBracket) + && Objects.equals(this.additionalProperties, parameterObj.additionalProperties) + && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash( + leftCurlyBracketParameterKeyRightCurlyBracket, super.hashCode(), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParameterObjDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" leftCurlyBracketParameterKeyRightCurlyBracket: ") + .append(toIndentedString(leftCurlyBracketParameterKeyRightCurlyBracket)) + .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjParameterKeyDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjParameterKeyDto.java new file mode 100644 index 00000000..369df382 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ParameterObjParameterKeyDto.java @@ -0,0 +1,129 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** + * The name of the parameter that will be replaced in the message body. Letters A-Z and a-z, digits + * 0-9 and .-_ allowed. + */ +@JsonPropertyOrder({ + ParameterObjParameterKeyDto.JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET, + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ParameterObjParameterKeyDto { + public static final String JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET = + "{msisdn}"; + private String leftCurlyBracketMsisdnRightCurlyBracket; + + public static final String JSON_PROPERTY_DEFAULT = "default"; + private String _default; + + public ParameterObjParameterKeyDto() {} + + public ParameterObjParameterKeyDto leftCurlyBracketMsisdnRightCurlyBracket( + String leftCurlyBracketMsisdnRightCurlyBracket) { + this.leftCurlyBracketMsisdnRightCurlyBracket = leftCurlyBracketMsisdnRightCurlyBracket; + return this; + } + + /** + * The key is the recipient that should have the `parameter_key` replaced with the value + * + * @return leftCurlyBracketMsisdnRightCurlyBracket + */ + @JsonProperty(JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLeftCurlyBracketMsisdnRightCurlyBracket() { + return leftCurlyBracketMsisdnRightCurlyBracket; + } + + @JsonProperty(JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLeftCurlyBracketMsisdnRightCurlyBracket( + String leftCurlyBracketMsisdnRightCurlyBracket) { + this.leftCurlyBracketMsisdnRightCurlyBracket = leftCurlyBracketMsisdnRightCurlyBracket; + } + + public ParameterObjParameterKeyDto _default(String _default) { + this._default = _default; + return this; + } + + /** + * The fall-back value for omitted recipient phone numbers <a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">MSISDNs</a>. + * + * @return _default + */ + @JsonProperty(JSON_PROPERTY_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDefault() { + return _default; + } + + @JsonProperty(JSON_PROPERTY_DEFAULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDefault(String _default) { + this._default = _default; + } + + /** Return true if this parameterObj__parameter_key_ object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParameterObjParameterKeyDto parameterObjParameterKey = (ParameterObjParameterKeyDto) o; + return Objects.equals( + this.leftCurlyBracketMsisdnRightCurlyBracket, + parameterObjParameterKey.leftCurlyBracketMsisdnRightCurlyBracket) + && Objects.equals(this._default, parameterObjParameterKey._default); + } + + @Override + public int hashCode() { + return Objects.hash(leftCurlyBracketMsisdnRightCurlyBracket, _default); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParameterObjParameterKeyDto {\n"); + sb.append(" leftCurlyBracketMsisdnRightCurlyBracket: ") + .append(toIndentedString(leftCurlyBracketMsisdnRightCurlyBracket)) + .append("\n"); + sb.append(" _default: ").append(toIndentedString(_default)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RecipientDeliveryReportDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RecipientDeliveryReportDto.java new file mode 100644 index 00000000..be0a2cf7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RecipientDeliveryReportDto.java @@ -0,0 +1,485 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** RecipientDeliveryReportDto */ +@JsonPropertyOrder({ + RecipientDeliveryReportDto.JSON_PROPERTY_AT, + RecipientDeliveryReportDto.JSON_PROPERTY_BATCH_ID, + RecipientDeliveryReportDto.JSON_PROPERTY_CODE, + RecipientDeliveryReportDto.JSON_PROPERTY_RECIPIENT, + RecipientDeliveryReportDto.JSON_PROPERTY_STATUS, + RecipientDeliveryReportDto.JSON_PROPERTY_TYPE, + RecipientDeliveryReportDto.JSON_PROPERTY_APPLIED_ORIGINATOR, + RecipientDeliveryReportDto.JSON_PROPERTY_CLIENT_REFERENCE, + RecipientDeliveryReportDto.JSON_PROPERTY_ENCODING, + RecipientDeliveryReportDto.JSON_PROPERTY_NUMBER_OF_MESSAGE_PARTS, + RecipientDeliveryReportDto.JSON_PROPERTY_OPERATOR, + RecipientDeliveryReportDto.JSON_PROPERTY_OPERATOR_STATUS_AT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class RecipientDeliveryReportDto { + public static final String JSON_PROPERTY_AT = "at"; + private OffsetDateTime at; + + public static final String JSON_PROPERTY_BATCH_ID = "batch_id"; + private String batchId; + + public static final String JSON_PROPERTY_CODE = "code"; + private Integer code; + + public static final String JSON_PROPERTY_RECIPIENT = "recipient"; + private String recipient; + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + /** The recipient delivery report type. */ + public enum TypeEnum { + SMS("recipient_delivery_report_sms"), + + MMS("recipient_delivery_report_mms"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_APPLIED_ORIGINATOR = "applied_originator"; + private String appliedOriginator; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + /** Applied encoding for message. Present only if smart encoding is enabled. */ + public enum EncodingEnum { + GSM("GSM"), + + UNICODE("UNICODE"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EncodingEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EncodingEnum fromValue(String value) { + for (EncodingEnum b : EncodingEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_ENCODING = "encoding"; + private String encoding; + + public static final String JSON_PROPERTY_NUMBER_OF_MESSAGE_PARTS = "number_of_message_parts"; + private Integer numberOfMessageParts; + + public static final String JSON_PROPERTY_OPERATOR = "operator"; + private String operator; + + public static final String JSON_PROPERTY_OPERATOR_STATUS_AT = "operator_status_at"; + private OffsetDateTime operatorStatusAt; + + public RecipientDeliveryReportDto() {} + + @JsonCreator + public RecipientDeliveryReportDto(@JsonProperty(JSON_PROPERTY_BATCH_ID) String batchId) { + this(); + this.batchId = batchId; + } + + public RecipientDeliveryReportDto at(OffsetDateTime at) { + this.at = at; + return this; + } + + /** + * A timestamp of when the Delivery Report was created in the Sinch service. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return at + */ + @JsonProperty(JSON_PROPERTY_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getAt() { + return at; + } + + @JsonProperty(JSON_PROPERTY_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setAt(OffsetDateTime at) { + this.at = at; + } + + /** + * The ID of the batch this delivery report belongs to + * + * @return batchId + */ + @JsonProperty(JSON_PROPERTY_BATCH_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBatchId() { + return batchId; + } + + public RecipientDeliveryReportDto code(Integer code) { + this.code = code; + return this; + } + + /** + * The detailed status code. + * + * @return code + */ + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public Integer getCode() { + return code; + } + + @JsonProperty(JSON_PROPERTY_CODE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setCode(Integer code) { + this.code = code; + } + + public RecipientDeliveryReportDto recipient(String recipient) { + this.recipient = recipient; + return this; + } + + /** + * Phone number that was queried. + * + * @return recipient + */ + @JsonProperty(JSON_PROPERTY_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRecipient() { + return recipient; + } + + @JsonProperty(JSON_PROPERTY_RECIPIENT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setRecipient(String recipient) { + this.recipient = recipient; + } + + public RecipientDeliveryReportDto status(String status) { + this.status = status; + return this; + } + + /** + * The simplified status as described in _Delivery Report Statuses_. + * + * @return status + */ + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getStatus() { + return status; + } + + @JsonProperty(JSON_PROPERTY_STATUS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setStatus(String status) { + this.status = status; + } + + public RecipientDeliveryReportDto type(String type) { + this.type = type; + return this; + } + + /** + * The recipient delivery report type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setType(String type) { + this.type = type; + } + + public RecipientDeliveryReportDto appliedOriginator(String appliedOriginator) { + this.appliedOriginator = appliedOriginator; + return this; + } + + /** + * The default originator used for the recipient this delivery report belongs to, if default + * originator pool configured and no originator set when submitting batch. + * + * @return appliedOriginator + */ + @JsonProperty(JSON_PROPERTY_APPLIED_ORIGINATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAppliedOriginator() { + return appliedOriginator; + } + + @JsonProperty(JSON_PROPERTY_APPLIED_ORIGINATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAppliedOriginator(String appliedOriginator) { + this.appliedOriginator = appliedOriginator; + } + + public RecipientDeliveryReportDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of the batch this delivery report belongs to, if set when submitting + * batch. + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public RecipientDeliveryReportDto encoding(String encoding) { + this.encoding = encoding; + return this; + } + + /** + * Applied encoding for message. Present only if smart encoding is enabled. + * + * @return encoding + */ + @JsonProperty(JSON_PROPERTY_ENCODING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEncoding() { + return encoding; + } + + @JsonProperty(JSON_PROPERTY_ENCODING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEncoding(String encoding) { + this.encoding = encoding; + } + + public RecipientDeliveryReportDto numberOfMessageParts(Integer numberOfMessageParts) { + this.numberOfMessageParts = numberOfMessageParts; + return this; + } + + /** + * The number of parts the message was split into. Present only if + * `max_number_of_message_parts` parameter was set. + * + * @return numberOfMessageParts + */ + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getNumberOfMessageParts() { + return numberOfMessageParts; + } + + @JsonProperty(JSON_PROPERTY_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumberOfMessageParts(Integer numberOfMessageParts) { + this.numberOfMessageParts = numberOfMessageParts; + } + + public RecipientDeliveryReportDto operator(String operator) { + this.operator = operator; + return this; + } + + /** + * The operator that was used for delivering the message to this recipient, if enabled on the + * account by Sinch. + * + * @return operator + */ + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOperator() { + return operator; + } + + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperator(String operator) { + this.operator = operator; + } + + public RecipientDeliveryReportDto operatorStatusAt(OffsetDateTime operatorStatusAt) { + this.operatorStatusAt = operatorStatusAt; + return this; + } + + /** + * A timestamp extracted from the Delivery Receipt from the originating SMSC. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return operatorStatusAt + */ + @JsonProperty(JSON_PROPERTY_OPERATOR_STATUS_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getOperatorStatusAt() { + return operatorStatusAt; + } + + @JsonProperty(JSON_PROPERTY_OPERATOR_STATUS_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperatorStatusAt(OffsetDateTime operatorStatusAt) { + this.operatorStatusAt = operatorStatusAt; + } + + /** Return true if this RecipientDeliveryReport object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RecipientDeliveryReportDto recipientDeliveryReport = (RecipientDeliveryReportDto) o; + return Objects.equals(this.at, recipientDeliveryReport.at) + && Objects.equals(this.batchId, recipientDeliveryReport.batchId) + && Objects.equals(this.code, recipientDeliveryReport.code) + && Objects.equals(this.recipient, recipientDeliveryReport.recipient) + && Objects.equals(this.status, recipientDeliveryReport.status) + && Objects.equals(this.type, recipientDeliveryReport.type) + && Objects.equals(this.appliedOriginator, recipientDeliveryReport.appliedOriginator) + && Objects.equals(this.clientReference, recipientDeliveryReport.clientReference) + && Objects.equals(this.encoding, recipientDeliveryReport.encoding) + && Objects.equals(this.numberOfMessageParts, recipientDeliveryReport.numberOfMessageParts) + && Objects.equals(this.operator, recipientDeliveryReport.operator) + && Objects.equals(this.operatorStatusAt, recipientDeliveryReport.operatorStatusAt); + } + + @Override + public int hashCode() { + return Objects.hash( + at, + batchId, + code, + recipient, + status, + type, + appliedOriginator, + clientReference, + encoding, + numberOfMessageParts, + operator, + operatorStatusAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RecipientDeliveryReportDto {\n"); + sb.append(" at: ").append(toIndentedString(at)).append("\n"); + sb.append(" batchId: ").append(toIndentedString(batchId)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" recipient: ").append(toIndentedString(recipient)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" appliedOriginator: ").append(toIndentedString(appliedOriginator)).append("\n"); + sb.append(" clientReference: ").append(toIndentedString(clientReference)).append("\n"); + sb.append(" encoding: ").append(toIndentedString(encoding)).append("\n"); + sb.append(" numberOfMessageParts: ") + .append(toIndentedString(numberOfMessageParts)) + .append("\n"); + sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); + sb.append(" operatorStatusAt: ").append(toIndentedString(operatorStatusAt)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ReplaceGroupRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ReplaceGroupRequestDto.java new file mode 100644 index 00000000..495ad533 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/ReplaceGroupRequestDto.java @@ -0,0 +1,129 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ReplaceGroupRequestDto */ +@JsonPropertyOrder({ + ReplaceGroupRequestDto.JSON_PROPERTY_MEMBERS, + ReplaceGroupRequestDto.JSON_PROPERTY_NAME +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ReplaceGroupRequestDto { + public static final String JSON_PROPERTY_MEMBERS = "members"; + private List members = new ArrayList<>(); + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public ReplaceGroupRequestDto() {} + + public ReplaceGroupRequestDto members(List members) { + this.members = members; + return this; + } + + public ReplaceGroupRequestDto addMembersItem(String membersItem) { + if (this.members == null) { + this.members = new ArrayList<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * The initial members of the group. Constraints: Elements must be phone numbers in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164</a> format MSISDNs. + * + * @return members + */ + @JsonProperty(JSON_PROPERTY_MEMBERS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getMembers() { + return members; + } + + @JsonProperty(JSON_PROPERTY_MEMBERS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setMembers(List members) { + this.members = members; + } + + public ReplaceGroupRequestDto name(String name) { + this.name = name; + return this; + } + + /** + * Name of group. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + /** Return true if this ReplaceGroup_request object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ReplaceGroupRequestDto replaceGroupRequest = (ReplaceGroupRequestDto) o; + return Objects.equals(this.members, replaceGroupRequest.members) + && Objects.equals(this.name, replaceGroupRequest.name); + } + + @Override + public int hashCode() { + return Objects.hash(members, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ReplaceGroupRequestDto {\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDto.java new file mode 100644 index 00000000..0fa520b5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDto.java @@ -0,0 +1,307 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize( + using = + RetrieveInboundMessage200ResponseDto.RetrieveInboundMessage200ResponseDtoDeserializer.class) +@JsonSerialize( + using = + RetrieveInboundMessage200ResponseDto.RetrieveInboundMessage200ResponseDtoSerializer.class) +public class RetrieveInboundMessage200ResponseDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(RetrieveInboundMessage200ResponseDto.class.getName()); + + public static class RetrieveInboundMessage200ResponseDtoSerializer + extends StdSerializer { + public RetrieveInboundMessage200ResponseDtoSerializer( + Class t) { + super(t); + } + + public RetrieveInboundMessage200ResponseDtoSerializer() { + this(null); + } + + @Override + public void serialize( + RetrieveInboundMessage200ResponseDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class RetrieveInboundMessage200ResponseDtoDeserializer + extends StdDeserializer { + public RetrieveInboundMessage200ResponseDtoDeserializer() { + this(RetrieveInboundMessage200ResponseDto.class); + } + + public RetrieveInboundMessage200ResponseDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public RetrieveInboundMessage200ResponseDto deserialize( + JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + RetrieveInboundMessage200ResponseDto newRetrieveInboundMessage200ResponseDto = + new RetrieveInboundMessage200ResponseDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "MOBinary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOBinaryDto.class); + newRetrieveInboundMessage200ResponseDto.setActualInstance(deserialized); + return newRetrieveInboundMessage200ResponseDto; + case "MOText": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOTextDto.class); + newRetrieveInboundMessage200ResponseDto.setActualInstance(deserialized); + return newRetrieveInboundMessage200ResponseDto; + case "mo_binary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOBinaryDto.class); + newRetrieveInboundMessage200ResponseDto.setActualInstance(deserialized); + return newRetrieveInboundMessage200ResponseDto; + case "mo_text": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOTextDto.class); + newRetrieveInboundMessage200ResponseDto.setActualInstance(deserialized); + return newRetrieveInboundMessage200ResponseDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for" + + " RetrieveInboundMessage200ResponseDto. Possible values: MOBinary MOText" + + " mo_binary mo_text", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize MOBinaryDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MOBinaryDto.class.equals(Integer.class) + || MOBinaryDto.class.equals(Long.class) + || MOBinaryDto.class.equals(Float.class) + || MOBinaryDto.class.equals(Double.class) + || MOBinaryDto.class.equals(Boolean.class) + || MOBinaryDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MOBinaryDto.class.equals(Integer.class) || MOBinaryDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MOBinaryDto.class.equals(Float.class) || MOBinaryDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MOBinaryDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MOBinaryDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOBinaryDto.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 'MOBinaryDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MOBinaryDto'", e); + } + + // deserialize MOTextDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MOTextDto.class.equals(Integer.class) + || MOTextDto.class.equals(Long.class) + || MOTextDto.class.equals(Float.class) + || MOTextDto.class.equals(Double.class) + || MOTextDto.class.equals(Boolean.class) + || MOTextDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MOTextDto.class.equals(Integer.class) || MOTextDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MOTextDto.class.equals(Float.class) || MOTextDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MOTextDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MOTextDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MOTextDto.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 'MOTextDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MOTextDto'", e); + } + + if (match == 1) { + RetrieveInboundMessage200ResponseDto ret = new RetrieveInboundMessage200ResponseDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for RetrieveInboundMessage200ResponseDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public RetrieveInboundMessage200ResponseDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "RetrieveInboundMessage200ResponseDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public RetrieveInboundMessage200ResponseDto() { + super("oneOf", Boolean.FALSE); + } + + public RetrieveInboundMessage200ResponseDto(MOBinaryDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public RetrieveInboundMessage200ResponseDto(MOTextDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MOBinaryDto", MOBinaryDto.class); + schemas.put("MOTextDto", MOTextDto.class); + JSONNavigator.registerDescendants( + RetrieveInboundMessage200ResponseDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("MOBinary", MOBinaryDto.class); + mappings.put("MOText", MOTextDto.class); + mappings.put("mo_binary", MOBinaryDto.class); + mappings.put("mo_text", MOTextDto.class); + mappings.put("RetrieveInboundMessage_200_response", RetrieveInboundMessage200ResponseDto.class); + JSONNavigator.registerDiscriminator( + RetrieveInboundMessage200ResponseDto.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return RetrieveInboundMessage200ResponseDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MOBinaryDto, MOTextDto + * + *

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(MOBinaryDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MOTextDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MOBinaryDto, MOTextDto"); + } + + /** + * Get the actual instance, which can be the following: MOBinaryDto, MOTextDto + * + * @return The actual instance (MOBinaryDto, MOTextDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MOBinaryDto`. If the actual instance is not `MOBinaryDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MOBinaryDto` + * @throws ClassCastException if the instance is not `MOBinaryDto` + */ + public MOBinaryDto getMOBinaryDto() throws ClassCastException { + return (MOBinaryDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MOTextDto`. If the actual instance is not `MOTextDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MOTextDto` + * @throws ClassCastException if the instance is not `MOTextDto` + */ + public MOTextDto getMOTextDto() throws ClassCastException { + return (MOTextDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDto.java new file mode 100644 index 00000000..15abc800 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDto.java @@ -0,0 +1,375 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize(using = SendSMS201ResponseDto.SendSMS201ResponseDtoDeserializer.class) +@JsonSerialize(using = SendSMS201ResponseDto.SendSMS201ResponseDtoSerializer.class) +public class SendSMS201ResponseDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SendSMS201ResponseDto.class.getName()); + + public static class SendSMS201ResponseDtoSerializer extends StdSerializer { + public SendSMS201ResponseDtoSerializer(Class t) { + super(t); + } + + public SendSMS201ResponseDtoSerializer() { + this(null); + } + + @Override + public void serialize( + SendSMS201ResponseDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class SendSMS201ResponseDtoDeserializer + extends StdDeserializer { + public SendSMS201ResponseDtoDeserializer() { + this(SendSMS201ResponseDto.class); + } + + public SendSMS201ResponseDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public SendSMS201ResponseDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + SendSMS201ResponseDto newSendSMS201ResponseDto = new SendSMS201ResponseDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "BinaryResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + case "MediaResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + case "TextResponse": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + case "mt_binary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + case "mt_media": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + case "mt_text": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.class); + newSendSMS201ResponseDto.setActualInstance(deserialized); + return newSendSMS201ResponseDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for SendSMS201ResponseDto. Possible" + + " values: BinaryResponse MediaResponse TextResponse mt_binary mt_media" + + " mt_text", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize BinaryResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BinaryResponseDto.class.equals(Integer.class) + || BinaryResponseDto.class.equals(Long.class) + || BinaryResponseDto.class.equals(Float.class) + || BinaryResponseDto.class.equals(Double.class) + || BinaryResponseDto.class.equals(Boolean.class) + || BinaryResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((BinaryResponseDto.class.equals(Integer.class) + || BinaryResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((BinaryResponseDto.class.equals(Float.class) + || BinaryResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (BinaryResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (BinaryResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryResponseDto.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 'BinaryResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BinaryResponseDto'", e); + } + + // deserialize MediaResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MediaResponseDto.class.equals(Integer.class) + || MediaResponseDto.class.equals(Long.class) + || MediaResponseDto.class.equals(Float.class) + || MediaResponseDto.class.equals(Double.class) + || MediaResponseDto.class.equals(Boolean.class) + || MediaResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MediaResponseDto.class.equals(Integer.class) + || MediaResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MediaResponseDto.class.equals(Float.class) + || MediaResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MediaResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MediaResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaResponseDto.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 'MediaResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MediaResponseDto'", e); + } + + // deserialize TextResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (TextResponseDto.class.equals(Integer.class) + || TextResponseDto.class.equals(Long.class) + || TextResponseDto.class.equals(Float.class) + || TextResponseDto.class.equals(Double.class) + || TextResponseDto.class.equals(Boolean.class) + || TextResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((TextResponseDto.class.equals(Integer.class) + || TextResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((TextResponseDto.class.equals(Float.class) + || TextResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (TextResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (TextResponseDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextResponseDto.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 'TextResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'TextResponseDto'", e); + } + + if (match == 1) { + SendSMS201ResponseDto ret = new SendSMS201ResponseDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for SendSMS201ResponseDto: %d classes match result, expected" + + " 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public SendSMS201ResponseDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "SendSMS201ResponseDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public SendSMS201ResponseDto() { + super("oneOf", Boolean.FALSE); + } + + public SendSMS201ResponseDto(BinaryResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SendSMS201ResponseDto(MediaResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SendSMS201ResponseDto(TextResponseDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("BinaryResponseDto", BinaryResponseDto.class); + schemas.put("MediaResponseDto", MediaResponseDto.class); + schemas.put("TextResponseDto", TextResponseDto.class); + JSONNavigator.registerDescendants( + SendSMS201ResponseDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("BinaryResponse", BinaryResponseDto.class); + mappings.put("MediaResponse", MediaResponseDto.class); + mappings.put("TextResponse", TextResponseDto.class); + mappings.put("mt_binary", BinaryResponseDto.class); + mappings.put("mt_media", MediaResponseDto.class); + mappings.put("mt_text", TextResponseDto.class); + mappings.put("SendSMS_201_response", SendSMS201ResponseDto.class); + JSONNavigator.registerDiscriminator(SendSMS201ResponseDto.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return SendSMS201ResponseDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: BinaryResponseDto, MediaResponseDto, TextResponseDto + * + *

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(BinaryResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MediaResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(TextResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be BinaryResponseDto, MediaResponseDto, TextResponseDto"); + } + + /** + * Get the actual instance, which can be the following: BinaryResponseDto, MediaResponseDto, + * TextResponseDto + * + * @return The actual instance (BinaryResponseDto, MediaResponseDto, TextResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `BinaryResponseDto`. If the actual instance is not + * `BinaryResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `BinaryResponseDto` + * @throws ClassCastException if the instance is not `BinaryResponseDto` + */ + public BinaryResponseDto getBinaryResponseDto() throws ClassCastException { + return (BinaryResponseDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MediaResponseDto`. If the actual instance is not + * `MediaResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `MediaResponseDto` + * @throws ClassCastException if the instance is not `MediaResponseDto` + */ + public MediaResponseDto getMediaResponseDto() throws ClassCastException { + return (MediaResponseDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `TextResponseDto`. If the actual instance is not `TextResponseDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TextResponseDto` + * @throws ClassCastException if the instance is not `TextResponseDto` + */ + public TextResponseDto getTextResponseDto() throws ClassCastException { + return (TextResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDto.java new file mode 100644 index 00000000..9193a2bd --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDto.java @@ -0,0 +1,371 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize(using = SendSMSRequestDto.SendSMSRequestDtoDeserializer.class) +@JsonSerialize(using = SendSMSRequestDto.SendSMSRequestDtoSerializer.class) +public class SendSMSRequestDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SendSMSRequestDto.class.getName()); + + public static class SendSMSRequestDtoSerializer extends StdSerializer { + public SendSMSRequestDtoSerializer(Class t) { + super(t); + } + + public SendSMSRequestDtoSerializer() { + this(null); + } + + @Override + public void serialize(SendSMSRequestDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class SendSMSRequestDtoDeserializer extends StdDeserializer { + public SendSMSRequestDtoDeserializer() { + this(SendSMSRequestDto.class); + } + + public SendSMSRequestDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public SendSMSRequestDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + SendSMSRequestDto newSendSMSRequestDto = new SendSMSRequestDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("type"); + switch (discriminatorValue) { + case "BinaryRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + case "MediaRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + case "TextRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + case "mt_binary": + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + case "mt_media": + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + case "mt_text": + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextRequestDto.class); + newSendSMSRequestDto.setActualInstance(deserialized); + return newSendSMSRequestDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for SendSMSRequestDto. Possible" + + " values: BinaryRequest MediaRequest TextRequest mt_binary mt_media" + + " mt_text", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize BinaryRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (BinaryRequestDto.class.equals(Integer.class) + || BinaryRequestDto.class.equals(Long.class) + || BinaryRequestDto.class.equals(Float.class) + || BinaryRequestDto.class.equals(Double.class) + || BinaryRequestDto.class.equals(Boolean.class) + || BinaryRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((BinaryRequestDto.class.equals(Integer.class) + || BinaryRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((BinaryRequestDto.class.equals(Float.class) + || BinaryRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (BinaryRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (BinaryRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(BinaryRequestDto.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 'BinaryRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'BinaryRequestDto'", e); + } + + // deserialize MediaRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MediaRequestDto.class.equals(Integer.class) + || MediaRequestDto.class.equals(Long.class) + || MediaRequestDto.class.equals(Float.class) + || MediaRequestDto.class.equals(Double.class) + || MediaRequestDto.class.equals(Boolean.class) + || MediaRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MediaRequestDto.class.equals(Integer.class) + || MediaRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MediaRequestDto.class.equals(Float.class) + || MediaRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MediaRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MediaRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MediaRequestDto.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 'MediaRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MediaRequestDto'", e); + } + + // deserialize TextRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (TextRequestDto.class.equals(Integer.class) + || TextRequestDto.class.equals(Long.class) + || TextRequestDto.class.equals(Float.class) + || TextRequestDto.class.equals(Double.class) + || TextRequestDto.class.equals(Boolean.class) + || TextRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((TextRequestDto.class.equals(Integer.class) + || TextRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((TextRequestDto.class.equals(Float.class) + || TextRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (TextRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (TextRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(TextRequestDto.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 'TextRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'TextRequestDto'", e); + } + + if (match == 1) { + SendSMSRequestDto ret = new SendSMSRequestDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for SendSMSRequestDto: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public SendSMSRequestDto getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "SendSMSRequestDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public SendSMSRequestDto() { + super("oneOf", Boolean.FALSE); + } + + public SendSMSRequestDto(BinaryRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SendSMSRequestDto(MediaRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SendSMSRequestDto(TextRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("BinaryRequestDto", BinaryRequestDto.class); + schemas.put("MediaRequestDto", MediaRequestDto.class); + schemas.put("TextRequestDto", TextRequestDto.class); + JSONNavigator.registerDescendants( + SendSMSRequestDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("BinaryRequest", BinaryRequestDto.class); + mappings.put("MediaRequest", MediaRequestDto.class); + mappings.put("TextRequest", TextRequestDto.class); + mappings.put("mt_binary", BinaryRequestDto.class); + mappings.put("mt_media", MediaRequestDto.class); + mappings.put("mt_text", TextRequestDto.class); + mappings.put("SendSMS_request", SendSMSRequestDto.class); + JSONNavigator.registerDiscriminator(SendSMSRequestDto.class, "type", mappings); + } + + @Override + public Map> getSchemas() { + return SendSMSRequestDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: BinaryRequestDto, MediaRequestDto, TextRequestDto + * + *

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(BinaryRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MediaRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(TextRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be BinaryRequestDto, MediaRequestDto, TextRequestDto"); + } + + /** + * Get the actual instance, which can be the following: BinaryRequestDto, MediaRequestDto, + * TextRequestDto + * + * @return The actual instance (BinaryRequestDto, MediaRequestDto, TextRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `BinaryRequestDto`. If the actual instance is not + * `BinaryRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `BinaryRequestDto` + * @throws ClassCastException if the instance is not `BinaryRequestDto` + */ + public BinaryRequestDto getBinaryRequestDto() throws ClassCastException { + return (BinaryRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `MediaRequestDto`. If the actual instance is not `MediaRequestDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `MediaRequestDto` + * @throws ClassCastException if the instance is not `MediaRequestDto` + */ + public MediaRequestDto getMediaRequestDto() throws ClassCastException { + return (MediaRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `TextRequestDto`. If the actual instance is not `TextRequestDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `TextRequestDto` + * @throws ClassCastException if the instance is not `TextRequestDto` + */ + public TextRequestDto getTextRequestDto() throws ClassCastException { + return (TextRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextRequestDto.java new file mode 100644 index 00000000..757cac9c --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextRequestDto.java @@ -0,0 +1,591 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** TextRequestDto */ +@JsonPropertyOrder({ + TextRequestDto.JSON_PROPERTY_TO, + TextRequestDto.JSON_PROPERTY_BODY, + TextRequestDto.JSON_PROPERTY_FROM, + TextRequestDto.JSON_PROPERTY_PARAMETERS, + TextRequestDto.JSON_PROPERTY_TYPE, + TextRequestDto.JSON_PROPERTY_DELIVERY_REPORT, + TextRequestDto.JSON_PROPERTY_SEND_AT, + TextRequestDto.JSON_PROPERTY_EXPIRE_AT, + TextRequestDto.JSON_PROPERTY_CALLBACK_URL, + TextRequestDto.JSON_PROPERTY_CLIENT_REFERENCE, + TextRequestDto.JSON_PROPERTY_FEEDBACK_ENABLED, + TextRequestDto.JSON_PROPERTY_FLASH_MESSAGE, + TextRequestDto.JSON_PROPERTY_TRUNCATE_CONCAT, + TextRequestDto.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + TextRequestDto.JSON_PROPERTY_FROM_TON, + TextRequestDto.JSON_PROPERTY_FROM_NPI +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TextRequestDto { + public static final String JSON_PROPERTY_TO = "to"; + private List to = new ArrayList<>(); + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + /** Regular SMS */ + public enum TypeEnum { + MT_TEXT("mt_text"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + private Boolean flashMessage = false; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + private Boolean truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + private Integer maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + private Integer fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + private Integer fromNpi; + + public TextRequestDto() {} + + public TextRequestDto to(List to) { + this.to = to; + return this; + } + + public TextRequestDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * List of Phone numbers and group IDs that will receive the batch. <a + * href=\"https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628\" + * target=\"_blank\">More info</a> + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setTo(List to) { + this.to = to; + } + + public TextRequestDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setBody(String body) { + this.body = body; + } + + public TextRequestDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + public TextRequestDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + public TextRequestDto type(String type) { + this.type = type; + return this; + } + + /** + * Regular SMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setType(String type) { + this.type = type; + } + + public TextRequestDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public TextRequestDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public TextRequestDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public TextRequestDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the *default* callback URL for this batch. Must be a valid URL. Learn how to set a + * default callback URL <a + * href=\"https://community.sinch.com/t5/SMS/How-do-I-assign-a-callback-URL-to-an-SMS-service-plan/ta-p/8414\" + * target=\"_blank\">here</a>. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public TextRequestDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public TextRequestDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to `true`, then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public TextRequestDto flashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFlashMessage() { + return flashMessage; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + } + + public TextRequestDto truncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + /** + * If set to `true` the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getTruncateConcat() { + return truncateConcat; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + } + + public TextRequestDto maxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + /** + * Message will be dispatched only if it is not split to more parts than Max Number of Message + * Parts minimum: 1 + * + * @return maxNumberOfMessageParts + */ + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + } + + public TextRequestDto fromTon(Integer fromTon) { + this.fromTon = fromTon; + return this; + } + + /** + * The type of number for the sender number. Use to override the automatic detection. minimum: 0 + * maximum: 6 + * + * @return fromTon + */ + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromTon() { + return fromTon; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromTon(Integer fromTon) { + this.fromTon = fromTon; + } + + public TextRequestDto fromNpi(Integer fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. minimum: + * 0 maximum: 18 + * + * @return fromNpi + */ + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromNpi() { + return fromNpi; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromNpi(Integer fromNpi) { + this.fromNpi = 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; + } + TextRequestDto textRequest = (TextRequestDto) o; + return Objects.equals(this.to, textRequest.to) + && Objects.equals(this.body, textRequest.body) + && Objects.equals(this.from, textRequest.from) + && Objects.equals(this.parameters, textRequest.parameters) + && 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, + body, + from, + parameters, + type, + deliveryReport, + sendAt, + expireAt, + callbackUrl, + clientReference, + feedbackEnabled, + flashMessage, + truncateConcat, + maxNumberOfMessageParts, + fromTon, + fromNpi); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TextRequestDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" from: ").append(toIndentedString(from)).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(" 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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDto.java new file mode 100644 index 00000000..302ac1e2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDto.java @@ -0,0 +1,665 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** TextResponseDto */ +@JsonPropertyOrder({ + TextResponseDto.JSON_PROPERTY_ID, + TextResponseDto.JSON_PROPERTY_TO, + TextResponseDto.JSON_PROPERTY_FROM, + TextResponseDto.JSON_PROPERTY_CANCELED, + TextResponseDto.JSON_PROPERTY_PARAMETERS, + TextResponseDto.JSON_PROPERTY_BODY, + TextResponseDto.JSON_PROPERTY_TYPE, + TextResponseDto.JSON_PROPERTY_CREATED_AT, + TextResponseDto.JSON_PROPERTY_MODIFIED_AT, + TextResponseDto.JSON_PROPERTY_DELIVERY_REPORT, + TextResponseDto.JSON_PROPERTY_SEND_AT, + TextResponseDto.JSON_PROPERTY_EXPIRE_AT, + TextResponseDto.JSON_PROPERTY_CALLBACK_URL, + TextResponseDto.JSON_PROPERTY_CLIENT_REFERENCE, + TextResponseDto.JSON_PROPERTY_FEEDBACK_ENABLED, + TextResponseDto.JSON_PROPERTY_FLASH_MESSAGE, + TextResponseDto.JSON_PROPERTY_TRUNCATE_CONCAT, + TextResponseDto.JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS, + TextResponseDto.JSON_PROPERTY_FROM_TON, + TextResponseDto.JSON_PROPERTY_FROM_NPI +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class TextResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TO = "to"; + private List to; + + public static final String JSON_PROPERTY_FROM = "from"; + private String from; + + public static final String JSON_PROPERTY_CANCELED = "canceled"; + private Boolean canceled = false; + + public static final String JSON_PROPERTY_PARAMETERS = "parameters"; + private ParameterObjDto parameters; + + public static final String JSON_PROPERTY_BODY = "body"; + private String body; + + /** Regular SMS */ + public enum TypeEnum { + MT_TEXT("mt_text"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private OffsetDateTime modifiedAt; + + public static final String JSON_PROPERTY_DELIVERY_REPORT = "delivery_report"; + private String deliveryReport = "none"; + + public static final String JSON_PROPERTY_SEND_AT = "send_at"; + private OffsetDateTime sendAt; + + public static final String JSON_PROPERTY_EXPIRE_AT = "expire_at"; + private OffsetDateTime expireAt; + + public static final String JSON_PROPERTY_CALLBACK_URL = "callback_url"; + private String callbackUrl; + + public static final String JSON_PROPERTY_CLIENT_REFERENCE = "client_reference"; + private String clientReference; + + public static final String JSON_PROPERTY_FEEDBACK_ENABLED = "feedback_enabled"; + private Boolean feedbackEnabled = false; + + public static final String JSON_PROPERTY_FLASH_MESSAGE = "flash_message"; + private Boolean flashMessage = false; + + public static final String JSON_PROPERTY_TRUNCATE_CONCAT = "truncate_concat"; + private Boolean truncateConcat; + + public static final String JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS = + "max_number_of_message_parts"; + private Integer maxNumberOfMessageParts; + + public static final String JSON_PROPERTY_FROM_TON = "from_ton"; + private Integer fromTon; + + public static final String JSON_PROPERTY_FROM_NPI = "from_npi"; + private Integer fromNpi; + + public TextResponseDto() {} + + @JsonCreator + public TextResponseDto( + @JsonProperty(JSON_PROPERTY_ID) String id, + @JsonProperty(JSON_PROPERTY_CANCELED) Boolean canceled, + @JsonProperty(JSON_PROPERTY_TYPE) String type, + @JsonProperty(JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) OffsetDateTime modifiedAt) { + this(); + this.id = id; + this.canceled = canceled; + this.type = type; + this.createdAt = createdAt; + this.modifiedAt = modifiedAt; + } + + /** + * Unique identifier for batch + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getId() { + return id; + } + + public TextResponseDto to(List to) { + this.to = to; + return this; + } + + public TextResponseDto addToItem(String toItem) { + if (this.to == null) { + this.to = new ArrayList<>(); + } + this.to.add(toItem); + return this; + } + + /** + * List of Phone numbers and group IDs that will receive the batch. [More + * info](https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628) + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTo(List to) { + this.to = to; + } + + public TextResponseDto from(String from) { + this.from = from; + return this; + } + + /** + * Sender number. Must be valid phone number, short code or alphanumeric. Required if Automatic + * Default Originator not configured. + * + * @return from + */ + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFrom() { + return from; + } + + @JsonProperty(JSON_PROPERTY_FROM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFrom(String from) { + this.from = from; + } + + /** + * Indicates if the batch has been canceled or not. + * + * @return canceled + */ + @JsonProperty(JSON_PROPERTY_CANCELED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getCanceled() { + return canceled; + } + + public TextResponseDto parameters(ParameterObjDto parameters) { + this.parameters = parameters; + return this; + } + + /** + * Get parameters + * + * @return parameters + */ + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ParameterObjDto getParameters() { + return parameters; + } + + @JsonProperty(JSON_PROPERTY_PARAMETERS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setParameters(ParameterObjDto parameters) { + this.parameters = parameters; + } + + public TextResponseDto body(String body) { + this.body = body; + return this; + } + + /** + * The message content + * + * @return body + */ + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBody() { + return body; + } + + @JsonProperty(JSON_PROPERTY_BODY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBody(String body) { + this.body = body; + } + + /** + * Regular SMS + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getType() { + return type; + } + + /** + * Timestamp for when batch was created. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601):`YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * Timestamp for when batch was last updated. Formatted as + * [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601):`YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return modifiedAt + */ + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getModifiedAt() { + return modifiedAt; + } + + public TextResponseDto deliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + return this; + } + + /** + * Request delivery report callback. Note that delivery reports can be fetched from the API + * regardless of this setting. + * + * @return deliveryReport + */ + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeliveryReport() { + return deliveryReport; + } + + @JsonProperty(JSON_PROPERTY_DELIVERY_REPORT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeliveryReport(String deliveryReport) { + this.deliveryReport = deliveryReport; + } + + public TextResponseDto sendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return sendAt + */ + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSendAt() { + return sendAt; + } + + @JsonProperty(JSON_PROPERTY_SEND_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSendAt(OffsetDateTime sendAt) { + this.sendAt = sendAt; + } + + public TextResponseDto expireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + return this; + } + + /** + * 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](https://en.wikipedia.org/wiki/ISO_8601): `YYYY-MM-DDThh:mm:ss.SSSZ`. + * + * @return expireAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getExpireAt() { + return expireAt; + } + + @JsonProperty(JSON_PROPERTY_EXPIRE_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setExpireAt(OffsetDateTime expireAt) { + this.expireAt = expireAt; + } + + public TextResponseDto callbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + return this; + } + + /** + * Override the default callback URL for this batch. Must be valid URL. + * + * @return callbackUrl + */ + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallbackUrl() { + return callbackUrl; + } + + @JsonProperty(JSON_PROPERTY_CALLBACK_URL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallbackUrl(String callbackUrl) { + this.callbackUrl = callbackUrl; + } + + public TextResponseDto clientReference(String clientReference) { + this.clientReference = clientReference; + return this; + } + + /** + * The client identifier of a batch message. If set, the identifier will be added in the delivery + * report/callback of this batch + * + * @return clientReference + */ + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientReference() { + return clientReference; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientReference(String clientReference) { + this.clientReference = clientReference; + } + + public TextResponseDto feedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + return this; + } + + /** + * If set to `true`, then + * [feedback](/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback) is + * expected after successful delivery. + * + * @return feedbackEnabled + */ + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFeedbackEnabled() { + return feedbackEnabled; + } + + @JsonProperty(JSON_PROPERTY_FEEDBACK_ENABLED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFeedbackEnabled(Boolean feedbackEnabled) { + this.feedbackEnabled = feedbackEnabled; + } + + public TextResponseDto flashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + return this; + } + + /** + * Shows message on screen without user interaction while not saving the message to the inbox. + * + * @return flashMessage + */ + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFlashMessage() { + return flashMessage; + } + + @JsonProperty(JSON_PROPERTY_FLASH_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashMessage(Boolean flashMessage) { + this.flashMessage = flashMessage; + } + + public TextResponseDto truncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + return this; + } + + /** + * If set to `true` the message will be shortened when exceeding one part. + * + * @return truncateConcat + */ + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getTruncateConcat() { + return truncateConcat; + } + + @JsonProperty(JSON_PROPERTY_TRUNCATE_CONCAT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTruncateConcat(Boolean truncateConcat) { + this.truncateConcat = truncateConcat; + } + + public TextResponseDto maxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + return this; + } + + /** + * Message will be dispatched only if it is not split to more parts than Max Number of Message + * Parts minimum: 1 + * + * @return maxNumberOfMessageParts + */ + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getMaxNumberOfMessageParts() { + return maxNumberOfMessageParts; + } + + @JsonProperty(JSON_PROPERTY_MAX_NUMBER_OF_MESSAGE_PARTS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { + this.maxNumberOfMessageParts = maxNumberOfMessageParts; + } + + public TextResponseDto fromTon(Integer fromTon) { + this.fromTon = fromTon; + return this; + } + + /** + * The type of number for the sender number. Use to override the automatic detection. minimum: 0 + * maximum: 6 + * + * @return fromTon + */ + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromTon() { + return fromTon; + } + + @JsonProperty(JSON_PROPERTY_FROM_TON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromTon(Integer fromTon) { + this.fromTon = fromTon; + } + + public TextResponseDto fromNpi(Integer fromNpi) { + this.fromNpi = fromNpi; + return this; + } + + /** + * Number Plan Indicator for the sender number. Use to override the automatic detection. minimum: + * 0 maximum: 18 + * + * @return fromNpi + */ + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getFromNpi() { + return fromNpi; + } + + @JsonProperty(JSON_PROPERTY_FROM_NPI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFromNpi(Integer fromNpi) { + this.fromNpi = 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; + } + TextResponseDto textResponse = (TextResponseDto) 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 TextResponseDto {\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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateBatchMessageRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateBatchMessageRequestDto.java new file mode 100644 index 00000000..d41b118d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateBatchMessageRequestDto.java @@ -0,0 +1,338 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +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.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 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; + +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +@JsonDeserialize( + using = UpdateBatchMessageRequestDto.UpdateBatchMessageRequestDtoDeserializer.class) +@JsonSerialize(using = UpdateBatchMessageRequestDto.UpdateBatchMessageRequestDtoSerializer.class) +public class UpdateBatchMessageRequestDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(UpdateBatchMessageRequestDto.class.getName()); + + public static class UpdateBatchMessageRequestDtoSerializer + extends StdSerializer { + public UpdateBatchMessageRequestDtoSerializer(Class t) { + super(t); + } + + public UpdateBatchMessageRequestDtoSerializer() { + this(null); + } + + @Override + public void serialize( + UpdateBatchMessageRequestDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class UpdateBatchMessageRequestDtoDeserializer + extends StdDeserializer { + public UpdateBatchMessageRequestDtoDeserializer() { + this(UpdateBatchMessageRequestDto.class); + } + + public UpdateBatchMessageRequestDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public UpdateBatchMessageRequestDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize ApiUpdateBinaryMtMessageDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ApiUpdateBinaryMtMessageDto.class.equals(Integer.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Long.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Float.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Double.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Boolean.class) + || ApiUpdateBinaryMtMessageDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ApiUpdateBinaryMtMessageDto.class.equals(Integer.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ApiUpdateBinaryMtMessageDto.class.equals(Float.class) + || ApiUpdateBinaryMtMessageDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (ApiUpdateBinaryMtMessageDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ApiUpdateBinaryMtMessageDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(ApiUpdateBinaryMtMessageDto.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 'ApiUpdateBinaryMtMessageDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ApiUpdateBinaryMtMessageDto'", e); + } + + // deserialize ApiUpdateMmsMtMessageDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ApiUpdateMmsMtMessageDto.class.equals(Integer.class) + || ApiUpdateMmsMtMessageDto.class.equals(Long.class) + || ApiUpdateMmsMtMessageDto.class.equals(Float.class) + || ApiUpdateMmsMtMessageDto.class.equals(Double.class) + || ApiUpdateMmsMtMessageDto.class.equals(Boolean.class) + || ApiUpdateMmsMtMessageDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ApiUpdateMmsMtMessageDto.class.equals(Integer.class) + || ApiUpdateMmsMtMessageDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ApiUpdateMmsMtMessageDto.class.equals(Float.class) + || ApiUpdateMmsMtMessageDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (ApiUpdateMmsMtMessageDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ApiUpdateMmsMtMessageDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateMmsMtMessageDto.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 'ApiUpdateMmsMtMessageDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ApiUpdateMmsMtMessageDto'", e); + } + + // deserialize ApiUpdateTextMtMessageDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ApiUpdateTextMtMessageDto.class.equals(Integer.class) + || ApiUpdateTextMtMessageDto.class.equals(Long.class) + || ApiUpdateTextMtMessageDto.class.equals(Float.class) + || ApiUpdateTextMtMessageDto.class.equals(Double.class) + || ApiUpdateTextMtMessageDto.class.equals(Boolean.class) + || ApiUpdateTextMtMessageDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ApiUpdateTextMtMessageDto.class.equals(Integer.class) + || ApiUpdateTextMtMessageDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ApiUpdateTextMtMessageDto.class.equals(Float.class) + || ApiUpdateTextMtMessageDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (ApiUpdateTextMtMessageDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ApiUpdateTextMtMessageDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateTextMtMessageDto.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 'ApiUpdateTextMtMessageDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'ApiUpdateTextMtMessageDto'", e); + } + + if (match == 1) { + UpdateBatchMessageRequestDto ret = new UpdateBatchMessageRequestDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for UpdateBatchMessageRequestDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public UpdateBatchMessageRequestDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "UpdateBatchMessageRequestDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public UpdateBatchMessageRequestDto() { + super("oneOf", Boolean.FALSE); + } + + public UpdateBatchMessageRequestDto(ApiUpdateBinaryMtMessageDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdateBatchMessageRequestDto(ApiUpdateMmsMtMessageDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public UpdateBatchMessageRequestDto(ApiUpdateTextMtMessageDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ApiUpdateBinaryMtMessageDto", ApiUpdateBinaryMtMessageDto.class); + schemas.put("ApiUpdateMmsMtMessageDto", ApiUpdateMmsMtMessageDto.class); + schemas.put("ApiUpdateTextMtMessageDto", ApiUpdateTextMtMessageDto.class); + JSONNavigator.registerDescendants( + UpdateBatchMessageRequestDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return UpdateBatchMessageRequestDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto, + * ApiUpdateTextMtMessageDto + * + *

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( + ApiUpdateBinaryMtMessageDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + ApiUpdateMmsMtMessageDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + ApiUpdateTextMtMessageDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto," + + " ApiUpdateTextMtMessageDto"); + } + + /** + * Get the actual instance, which can be the following: ApiUpdateBinaryMtMessageDto, + * ApiUpdateMmsMtMessageDto, ApiUpdateTextMtMessageDto + * + * @return The actual instance (ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto, + * ApiUpdateTextMtMessageDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ApiUpdateBinaryMtMessageDto`. If the actual instance is not + * `ApiUpdateBinaryMtMessageDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `ApiUpdateBinaryMtMessageDto` + * @throws ClassCastException if the instance is not `ApiUpdateBinaryMtMessageDto` + */ + public ApiUpdateBinaryMtMessageDto getApiUpdateBinaryMtMessageDto() throws ClassCastException { + return (ApiUpdateBinaryMtMessageDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `ApiUpdateMmsMtMessageDto`. If the actual instance is not + * `ApiUpdateMmsMtMessageDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `ApiUpdateMmsMtMessageDto` + * @throws ClassCastException if the instance is not `ApiUpdateMmsMtMessageDto` + */ + public ApiUpdateMmsMtMessageDto getApiUpdateMmsMtMessageDto() throws ClassCastException { + return (ApiUpdateMmsMtMessageDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `ApiUpdateTextMtMessageDto`. If the actual instance is not + * `ApiUpdateTextMtMessageDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `ApiUpdateTextMtMessageDto` + * @throws ClassCastException if the instance is not `ApiUpdateTextMtMessageDto` + */ + public ApiUpdateTextMtMessageDto getApiUpdateTextMtMessageDto() throws ClassCastException { + return (ApiUpdateTextMtMessageDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateAddDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateAddDto.java new file mode 100644 index 00000000..b973f1b5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateAddDto.java @@ -0,0 +1,124 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** UpdateGroupRequestAutoUpdateAddDto */ +@JsonPropertyOrder({ + UpdateGroupRequestAutoUpdateAddDto.JSON_PROPERTY_FIRST_WORD, + UpdateGroupRequestAutoUpdateAddDto.JSON_PROPERTY_SECOND_WORD +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateGroupRequestAutoUpdateAddDto { + public static final String JSON_PROPERTY_FIRST_WORD = "first_word"; + private String firstWord; + + public static final String JSON_PROPERTY_SECOND_WORD = "second_word"; + private String secondWord; + + public UpdateGroupRequestAutoUpdateAddDto() {} + + public UpdateGroupRequestAutoUpdateAddDto firstWord(String firstWord) { + this.firstWord = firstWord; + return this; + } + + /** + * Keyword to be sent in <a + * href=\"https://community.sinch.com/t5/Glossary/MO-Mobile-Originated/ta-p/7618\" + * target=\"_blank\">MO</a> to add phone number to a group opt-in keyword + * like \"JOIN\". If `auto_update.to` is dedicated long/short number or unique + * brand keyword like \"Sinch\" if it is a shared short code. Constraints: Must be one + * word. + * + * @return firstWord + */ + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstWord() { + return firstWord; + } + + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstWord(String firstWord) { + this.firstWord = firstWord; + } + + public UpdateGroupRequestAutoUpdateAddDto secondWord(String secondWord) { + this.secondWord = secondWord; + return this; + } + + /** + * Opt-in keyword like \"JOIN\" if auto_update.to is shared short code. Constraints: + * Must be one word. + * + * @return secondWord + */ + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSecondWord() { + return secondWord; + } + + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSecondWord(String secondWord) { + this.secondWord = secondWord; + } + + /** Return true if this UpdateGroup_request_auto_update_add object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateGroupRequestAutoUpdateAddDto updateGroupRequestAutoUpdateAdd = + (UpdateGroupRequestAutoUpdateAddDto) o; + return Objects.equals(this.firstWord, updateGroupRequestAutoUpdateAdd.firstWord) + && Objects.equals(this.secondWord, updateGroupRequestAutoUpdateAdd.secondWord); + } + + @Override + public int hashCode() { + return Objects.hash(firstWord, secondWord); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateGroupRequestAutoUpdateAddDto {\n"); + sb.append(" firstWord: ").append(toIndentedString(firstWord)).append("\n"); + sb.append(" secondWord: ").append(toIndentedString(secondWord)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateDto.java new file mode 100644 index 00000000..d6e59a82 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateDto.java @@ -0,0 +1,149 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** UpdateGroupRequestAutoUpdateDto */ +@JsonPropertyOrder({ + UpdateGroupRequestAutoUpdateDto.JSON_PROPERTY_TO, + UpdateGroupRequestAutoUpdateDto.JSON_PROPERTY_ADD, + UpdateGroupRequestAutoUpdateDto.JSON_PROPERTY_REMOVE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateGroupRequestAutoUpdateDto { + public static final String JSON_PROPERTY_TO = "to"; + private String to; + + public static final String JSON_PROPERTY_ADD = "add"; + private UpdateGroupRequestAutoUpdateAddDto add; + + public static final String JSON_PROPERTY_REMOVE = "remove"; + private UpdateGroupRequestAutoUpdateRemoveDto remove; + + public UpdateGroupRequestAutoUpdateDto() {} + + public UpdateGroupRequestAutoUpdateDto to(String to) { + this.to = to; + return this; + } + + /** + * Short code or long number addressed in <a + * href=\"https://community.sinch.com/t5/Glossary/MO-Mobile-Originated/ta-p/7618\" + * target=\"_blank\">MO</a>. Constraints: Must be a valid phone number or + * short code. + * + * @return to + */ + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTo() { + return to; + } + + @JsonProperty(JSON_PROPERTY_TO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTo(String to) { + this.to = to; + } + + public UpdateGroupRequestAutoUpdateDto add(UpdateGroupRequestAutoUpdateAddDto add) { + this.add = add; + return this; + } + + /** + * Get add + * + * @return add + */ + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdateGroupRequestAutoUpdateAddDto getAdd() { + return add; + } + + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAdd(UpdateGroupRequestAutoUpdateAddDto add) { + this.add = add; + } + + public UpdateGroupRequestAutoUpdateDto remove(UpdateGroupRequestAutoUpdateRemoveDto remove) { + this.remove = remove; + return this; + } + + /** + * Get remove + * + * @return remove + */ + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdateGroupRequestAutoUpdateRemoveDto getRemove() { + return remove; + } + + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRemove(UpdateGroupRequestAutoUpdateRemoveDto remove) { + this.remove = remove; + } + + /** Return true if this UpdateGroup_request_auto_update object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateGroupRequestAutoUpdateDto updateGroupRequestAutoUpdate = + (UpdateGroupRequestAutoUpdateDto) o; + return Objects.equals(this.to, updateGroupRequestAutoUpdate.to) + && Objects.equals(this.add, updateGroupRequestAutoUpdate.add) + && Objects.equals(this.remove, updateGroupRequestAutoUpdate.remove); + } + + @Override + public int hashCode() { + return Objects.hash(to, add, remove); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateGroupRequestAutoUpdateDto {\n"); + sb.append(" to: ").append(toIndentedString(to)).append("\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateRemoveDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateRemoveDto.java new file mode 100644 index 00000000..1a2da651 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestAutoUpdateRemoveDto.java @@ -0,0 +1,121 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.Objects; + +/** Keyword to be sent in MO to remove from a group. */ +@JsonPropertyOrder({ + UpdateGroupRequestAutoUpdateRemoveDto.JSON_PROPERTY_FIRST_WORD, + UpdateGroupRequestAutoUpdateRemoveDto.JSON_PROPERTY_SECOND_WORD +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateGroupRequestAutoUpdateRemoveDto { + public static final String JSON_PROPERTY_FIRST_WORD = "first_word"; + private String firstWord; + + public static final String JSON_PROPERTY_SECOND_WORD = "second_word"; + private String secondWord; + + public UpdateGroupRequestAutoUpdateRemoveDto() {} + + public UpdateGroupRequestAutoUpdateRemoveDto firstWord(String firstWord) { + this.firstWord = firstWord; + return this; + } + + /** + * Opt-out keyword. For example, \"LEAVE\" if `auto_update.to` is a dedicated + * long/short number or a unique brand keyword like \"Sinch\" (if it is a shared short + * code). Constraints: Must be one word. + * + * @return firstWord + */ + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFirstWord() { + return firstWord; + } + + @JsonProperty(JSON_PROPERTY_FIRST_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstWord(String firstWord) { + this.firstWord = firstWord; + } + + public UpdateGroupRequestAutoUpdateRemoveDto secondWord(String secondWord) { + this.secondWord = secondWord; + return this; + } + + /** + * Opt-out keyword. For example, \"LEAVE\" if `auto_update.to` is a shared + * short code. Constraints: Must be one word. + * + * @return secondWord + */ + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSecondWord() { + return secondWord; + } + + @JsonProperty(JSON_PROPERTY_SECOND_WORD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSecondWord(String secondWord) { + this.secondWord = secondWord; + } + + /** Return true if this UpdateGroup_request_auto_update_remove object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateGroupRequestAutoUpdateRemoveDto updateGroupRequestAutoUpdateRemove = + (UpdateGroupRequestAutoUpdateRemoveDto) o; + return Objects.equals(this.firstWord, updateGroupRequestAutoUpdateRemove.firstWord) + && Objects.equals(this.secondWord, updateGroupRequestAutoUpdateRemove.secondWord); + } + + @Override + public int hashCode() { + return Objects.hash(firstWord, secondWord); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateGroupRequestAutoUpdateRemoveDto {\n"); + sb.append(" firstWord: ").append(toIndentedString(firstWord)).append("\n"); + sb.append(" secondWord: ").append(toIndentedString(secondWord)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestDto.java new file mode 100644 index 00000000..97023735 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/models/dto/v1/UpdateGroupRequestDto.java @@ -0,0 +1,254 @@ +/* + * API Overview | Sinch + * Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more. + * + * The version of the OpenAPI document: v1 + * Contact: Support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** UpdateGroupRequestDto */ +@JsonPropertyOrder({ + UpdateGroupRequestDto.JSON_PROPERTY_NAME, + UpdateGroupRequestDto.JSON_PROPERTY_ADD, + UpdateGroupRequestDto.JSON_PROPERTY_REMOVE, + UpdateGroupRequestDto.JSON_PROPERTY_ADD_FROM_GROUP, + UpdateGroupRequestDto.JSON_PROPERTY_REMOVE_FROM_GROUP, + UpdateGroupRequestDto.JSON_PROPERTY_AUTO_UPDATE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class UpdateGroupRequestDto { + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_ADD = "add"; + private List add; + + public static final String JSON_PROPERTY_REMOVE = "remove"; + private List remove; + + public static final String JSON_PROPERTY_ADD_FROM_GROUP = "add_from_group"; + private String addFromGroup; + + public static final String JSON_PROPERTY_REMOVE_FROM_GROUP = "remove_from_group"; + private String removeFromGroup; + + public static final String JSON_PROPERTY_AUTO_UPDATE = "auto_update"; + private UpdateGroupRequestAutoUpdateDto autoUpdate; + + public UpdateGroupRequestDto() {} + + public UpdateGroupRequestDto name(String name) { + this.name = name; + return this; + } + + /** + * The name of the group. Omitting `name` from the JSON body will leave the name + * unchanged. To remove an existing name set, name explicitly to the JSON value `null`. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setName(String name) { + this.name = name; + } + + public UpdateGroupRequestDto add(List add) { + this.add = add; + return this; + } + + public UpdateGroupRequestDto addAddItem(String addItem) { + if (this.add == null) { + this.add = new ArrayList<>(); + } + this.add.add(addItem); + return this; + } + + /** + * Add a list of phone numbers (MSISDNs) to this group. The phone numbers are a strings within an + * array and must be in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164 format</a>. + * + * @return add + */ + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getAdd() { + return add; + } + + @JsonProperty(JSON_PROPERTY_ADD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAdd(List add) { + this.add = add; + } + + public UpdateGroupRequestDto remove(List remove) { + this.remove = remove; + return this; + } + + public UpdateGroupRequestDto addRemoveItem(String removeItem) { + if (this.remove == null) { + this.remove = new ArrayList<>(); + } + this.remove.add(removeItem); + return this; + } + + /** + * Remove a list of phone numbers (MSISDNs) to this group.The phone numbers are a strings within + * an array and must be in <a + * href=\"https://community.sinch.com/t5/Glossary/E-164/ta-p/7537\" + * target=\"_blank\">E.164 format</a>. + * + * @return remove + */ + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getRemove() { + return remove; + } + + @JsonProperty(JSON_PROPERTY_REMOVE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRemove(List remove) { + this.remove = remove; + } + + public UpdateGroupRequestDto addFromGroup(String addFromGroup) { + this.addFromGroup = addFromGroup; + return this; + } + + /** + * Copy the members from the another group into this group. Constraints: Must be valid group ID + * + * @return addFromGroup + */ + @JsonProperty(JSON_PROPERTY_ADD_FROM_GROUP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getAddFromGroup() { + return addFromGroup; + } + + @JsonProperty(JSON_PROPERTY_ADD_FROM_GROUP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAddFromGroup(String addFromGroup) { + this.addFromGroup = addFromGroup; + } + + public UpdateGroupRequestDto removeFromGroup(String removeFromGroup) { + this.removeFromGroup = removeFromGroup; + return this; + } + + /** + * Remove the members in a specified group from this group. Constraints: Must be valid group ID + * + * @return removeFromGroup + */ + @JsonProperty(JSON_PROPERTY_REMOVE_FROM_GROUP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRemoveFromGroup() { + return removeFromGroup; + } + + @JsonProperty(JSON_PROPERTY_REMOVE_FROM_GROUP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRemoveFromGroup(String removeFromGroup) { + this.removeFromGroup = removeFromGroup; + } + + public UpdateGroupRequestDto autoUpdate(UpdateGroupRequestAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + return this; + } + + /** + * Get autoUpdate + * + * @return autoUpdate + */ + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdateGroupRequestAutoUpdateDto getAutoUpdate() { + return autoUpdate; + } + + @JsonProperty(JSON_PROPERTY_AUTO_UPDATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAutoUpdate(UpdateGroupRequestAutoUpdateDto autoUpdate) { + this.autoUpdate = autoUpdate; + } + + /** Return true if this UpdateGroup_request object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateGroupRequestDto updateGroupRequest = (UpdateGroupRequestDto) o; + return Objects.equals(this.name, updateGroupRequest.name) + && Objects.equals(this.add, updateGroupRequest.add) + && Objects.equals(this.remove, updateGroupRequest.remove) + && Objects.equals(this.addFromGroup, updateGroupRequest.addFromGroup) + && Objects.equals(this.removeFromGroup, updateGroupRequest.removeFromGroup) + && Objects.equals(this.autoUpdate, updateGroupRequest.autoUpdate); + } + + @Override + public int hashCode() { + return Objects.hash(name, add, remove, addFromGroup, removeFromGroup, autoUpdate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateGroupRequestDto {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" add: ").append(toIndentedString(add)).append("\n"); + sb.append(" remove: ").append(toIndentedString(remove)).append("\n"); + sb.append(" addFromGroup: ").append(toIndentedString(addFromGroup)).append("\n"); + sb.append(" removeFromGroup: ").append(toIndentedString(removeFromGroup)).append("\n"); + sb.append(" autoUpdate: ").append(toIndentedString(autoUpdate)).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 "); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApiTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApiTest.java new file mode 100644 index 00000000..a0a3e4b9 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/ActiveNumberApiTest.java @@ -0,0 +1,142 @@ +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.*; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class ActiveNumberApiTest extends BaseTest { + + @GivenTextResource("/domains/numbers/v1/active-numbers-list.json") + String activeListResponse; + + @GivenTextResource("/domains/numbers/v1/active-numbers-get.json") + String activeGetResponse; + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + HttpMapper mapper = new HttpMapper(); + + @InjectMocks + ActiveNumberApi service = new ActiveNumberApi(httpClient, serverConfiguration, mapper); + + ActiveNumberDto expectedActiveNumberDto = + new ActiveNumberDto( + "GB", + 1, + OffsetDateTime.parse("2023-09-22T15:49:58.813424Z"), + OffsetDateTime.parse("2023-10-06T15:49:58.813381Z")) + .phoneNumber("+447520651116XYZ") + .projectId("project id") + .displayName("a display") + .type("MOBILE") + .capability(Arrays.asList("SMS", "VOICE")) + .money(new MoneyDto().currencyCode("EUR").amount("0.80")) + .smsConfiguration( + new SMSConfigurationDto() + .servicePlanId("service plan id") + .scheduledProvisioning( + new ScheduledProvisioningDto( + "service plan id from scheduled", + "campaign id from scheduled", + OffsetDateTime.parse("2023-09-25T12:08:02.115Z"), + Collections.singletonList(SmsErrorCodeDto.ERROR_CODE_UNSPECIFIED)) + .status(ProvisioningStatusDto.PROVISIONING_STATUS_UNSPECIFIED))) + .voiceConfiguration( + new VoiceConfigurationDto(OffsetDateTime.parse("2023-09-25T12:08:02.115Z")) + .appId("app id") + .scheduledVoiceProvisioning( + new ScheduledVoiceProvisioningDto( + "app id from scheduled", + OffsetDateTime.parse("2023-09-25T12:08:02.115Z")) + .status(ProvisioningStatusDto.PROVISIONING_STATUS_UNSPECIFIED))) + .callbackUrl("foo callback"); + + @Test + void list() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, activeListResponse.getBytes(StandardCharsets.UTF_8))); + + ActiveNumbersResponseDto response = + service.numberServiceListActiveNumbers( + "project", + "region", + "type", + "pattern", + "searchPattern", + Collections.singletonList("capability"), + 45, + "token", + "order by"); + + ActiveNumbersResponseDto expected = + new ActiveNumbersResponseDto() + .totalSize(1) + .nextPageToken("foo") + .activeNumbers(Collections.singletonList(expectedActiveNumberDto)); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void get() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, activeGetResponse.getBytes(StandardCharsets.UTF_8))); + + ActiveNumberDto response = service.numberServiceGetActiveNumber("project", "foo phone"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedActiveNumberDto); + } + + @Test + void release() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, activeGetResponse.getBytes(StandardCharsets.UTF_8))); + + ActiveNumberDto response = service.numberServiceReleaseNumber("project", "foo phone"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedActiveNumberDto); + } + + @Test + void update() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, activeGetResponse.getBytes(StandardCharsets.UTF_8))); + + ActiveNumberRequestDto parameters = new ActiveNumberRequestDto(); + + ActiveNumberDto response = + service.numberServiceUpdateActiveNumber("project", "foo phone", parameters); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedActiveNumberDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApiTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApiTest.java new file mode 100644 index 00000000..b6a6a029 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableNumberApiTest.java @@ -0,0 +1,190 @@ +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.*; +import java.nio.charset.StandardCharsets; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class AvailableNumberApiTest extends BaseTest { + + @GivenTextResource("/domains/numbers/v1/error-trial-account.json") + String errorTrialAccount; + + @GivenTextResource("/domains/numbers/v1/rent-response.json") + String rentResponse; + + @GivenTextResource("/domains/numbers/v1/available-numbers-list.json") + String availableListResponse; + + @GivenTextResource("/domains/numbers/v1/available-numbers-get.json") + String availableGetResponse; + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + HttpMapper mapper = new HttpMapper(); + + @InjectMocks + AvailableNumberApi service = new AvailableNumberApi(httpClient, serverConfiguration, mapper); + + AvailableNumberDto expectedAvailableNumberDto = + new AvailableNumberDto("+46650553763", "SE", 1, true) + .type("LOCAL") + .capability(Collections.singletonList("VOICE")) + .setupPrice(new MoneyDto().currencyCode("DOLLAR").amount("0.57")) + .monthlyPrice(new MoneyDto().currencyCode("EUR").amount("0.80")); + + ActiveNumberDto expectedActiveNumberDto = + new ActiveNumberDto( + "US", + 0, + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME), + OffsetDateTime.parse("2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME)) + .phoneNumber("+12025550134") + .projectId("51bc3f40-f266-4ca8-8938-a1ed0ff32b9a") + .displayName("string") + .type("MOBILE") + .capability(Collections.singletonList("SMS")) + .money(new MoneyDto().currencyCode("USD").amount("2.00")) + .smsConfiguration( + new SMSConfigurationDto() + .servicePlanId("string") + .campaignId("string") + .scheduledProvisioning( + new ScheduledProvisioningDto( + "8200000f74924bd6800000b212f00000", + "string", + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME), + Collections.emptyList()) + .status(ProvisioningStatusDto.WAITING))) + .voiceConfiguration( + new VoiceConfigurationDto( + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME)) + .appId("string") + .scheduledVoiceProvisioning( + new ScheduledVoiceProvisioningDto( + "string", + OffsetDateTime.parse( + "2019-08-24T14:15:22Z", DateTimeFormatter.ISO_OFFSET_DATE_TIME)) + .status(ProvisioningStatusDto.WAITING))) + .callbackUrl("https://www.your-callback-server.com/callback"); + + @Test + void listAll() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, availableListResponse.getBytes(StandardCharsets.UTF_8))); + + AvailableNumbersResponseDto response = + service.numberServiceListAvailableNumbers( + "project", + "region", + "type", + "pattern", + "searchPattern", + Collections.singletonList("capability"), + 45); + + AvailableNumbersResponseDto expected = + new AvailableNumbersResponseDto() + .availableNumbers(Collections.singletonList(expectedAvailableNumberDto)); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void get() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, availableGetResponse.getBytes(StandardCharsets.UTF_8))); + + AvailableNumberDto response = service.numberServiceGetAvailableNumber("project", "region"); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(expectedAvailableNumberDto); + } + + @Test + void rentAny() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, rentResponse.getBytes(StandardCharsets.UTF_8))); + + RentAnyNumberRequestDto parameters = + new RentAnyNumberRequestDto() + .regionCode("region") + .type("type") + .numberPattern( + new SearchPatternDto().pattern("pattern").searchPattern("search pattern")) + .capabilities(Collections.singletonList("capability")) + .smsConfiguration( + new RentAnyNumberRequestSmsConfigurationDto() + .servicePlanId("service plan id") + .campaignId("campaign id")) + .voiceConfiguration(new RentAnyNumberRequestVoiceConfigurationDto().appId("app id")) + .callbackUrl("foo callback"); + + ActiveNumberDto response = service.numberServiceRentAnyNumber("project", parameters); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedActiveNumberDto); + } + + @Test + void rent() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, rentResponse.getBytes(StandardCharsets.UTF_8))); + + ActiveNumberDto response = + service.numberServiceRentNumber("project", "phone", new RentNumberRequestDto()); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedActiveNumberDto); + } + + @Test + void rentWithError() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 500, "foo message", null, errorTrialAccount.getBytes(StandardCharsets.UTF_8))); + + ApiException exception = + assertThrows( + ApiException.class, + () -> service.numberServiceRentNumber("project", "phone", new RentNumberRequestDto())); + + assertEquals(exception.getCode(), 403); + assertEquals( + exception.getMessage(), "PERMISSION_DENIED: Trial account is not enabled to rent number"); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApiTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApiTest.java new file mode 100644 index 00000000..823cc1f3 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/AvailableRegionsApiTest.java @@ -0,0 +1,56 @@ +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.AvailableRegionDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class AvailableRegionsApiTest extends BaseTest { + + @GivenTextResource("/domains/numbers/v1/available-regions-list.json") + String availableListResponse; + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + HttpMapper mapper = new HttpMapper(); + + @InjectMocks + AvailableRegionsApi service = new AvailableRegionsApi(httpClient, serverConfiguration, mapper); + + AvailableRegionDto expectedAvailableRegionDto = + new AvailableRegionDto("AU", "Australia", Collections.singletonList("MOBILE")); + + @Test + void listAll() { + + when(httpClient.invokeAPI(any(), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, availableListResponse.getBytes(StandardCharsets.UTF_8))); + + ListAvailableRegionsResponseDto response = + service.numberServiceListAvailableRegions( + "project", Collections.singletonList("capability")); + + ListAvailableRegionsResponseDto expected = + new ListAvailableRegionsResponseDto() + .availableRegions(Collections.singletonList(expectedAvailableRegionDto)); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expected); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApiTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApiTest.java new file mode 100644 index 00000000..7769e109 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/numbers/adapters/api/v1/CallbackConfigurationApiTest.java @@ -0,0 +1,67 @@ +package com.sinch.sdk.domains.numbers.adapters.api.v1; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationDto; +import com.sinch.sdk.domains.numbers.models.dto.v1.CallbackConfigurationUpdateDto; +import java.nio.charset.StandardCharsets; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +class CallbackConfigurationApiTest extends BaseTest { + + @GivenTextResource("/domains/numbers/v1/callback-configuration.json") + String callbackConfiguration; + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + HttpMapper mapper = new HttpMapper(); + + @InjectMocks + CallbackConfigurationApi service = + new CallbackConfigurationApi(httpClient, serverConfiguration, mapper); + + CallbackConfigurationDto expectedDto = + new CallbackConfigurationDto().projectId("The project ID").hmacSecret("The secret HMAC"); + + @Test + void get() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, callbackConfiguration.getBytes(StandardCharsets.UTF_8))); + + CallbackConfigurationDto response = service.getCallbackConfiguration("project"); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedDto); + } + + @Test + void update() { + + when(httpClient.invokeAPI(eq(serverConfiguration), any())) + .thenReturn( + new HttpResponse( + 200, "foo message", null, callbackConfiguration.getBytes(StandardCharsets.UTF_8))); + + CallbackConfigurationUpdateDto parameters = + new CallbackConfigurationUpdateDto().hmacSecret("HMAC value"); + + CallbackConfigurationDto response = service.updateCallbackConfiguration("project", parameters); + + Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedDto); + } +} 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 new file mode 100644 index 00000000..b53a13c1 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/BinaryResponseDtoTest.java @@ -0,0 +1,61 @@ +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.Arrays; +import org.assertj.core.api.Assertions; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class BinaryResponseDtoTest extends BaseTest { + @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + BinaryResponseDto loadedDto; + + @GivenTextResource("/domains/sms/v1/BinaryResponseDto.json") + String jsonStringDto; + + BinaryResponseDto dto = + new BinaryResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + OffsetDateTime.parse("2019-08-24T14:15:22Z"), + OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .body("Hi ${name}! How are you?") + .callbackUrl("callback url") + .clientReference("myReference") + .deliveryReport("none") + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .feedbackEnabled(false) + .flashMessage(true) + .from("+15551231234") + .fromTon(6) + .fromNpi(18) + .maxNumberOfMessageParts(1) + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .truncateConcat(true) + .type("mt_binary") + .udh("foo udh"); + + @Test + void deserialize() { + + BinaryResponseDto expected = dto; + + Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(dto); + + JSONAssert.assertEquals(jsonStringDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDtoTest.java new file mode 100644 index 00000000..6366473f --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOBinaryDtoTest.java @@ -0,0 +1,50 @@ +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 org.assertj.core.api.Assertions; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class MOBinaryDtoTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/MOBinaryDto.json") + MOBinaryDto loadedDto; + + @GivenTextResource("/domains/sms/v1/MOBinaryDto.json") + String jsonStringDto; + + MOBinaryDto dto = + new MOBinaryDto(MOBinaryDto.TypeEnum.MO_BINARY.getValue()) + .from("+11203494390") + .id("01FC66621XXXXX119Z8PMV1QPA") + .receivedAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .to("11203453453") + .body("a body") + .clientReference("a client reference") + .operatorId("35000") + .sentAt(OffsetDateTime.parse("2019-08-24T14:15:22Z")) + .udh("foo udh"); + + @Test + void deserialize() { + + MOBinaryDto expected = dto; + + Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(dto); + + JSONAssert.assertEquals(jsonStringDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDtoTest.java new file mode 100644 index 00000000..490d3f52 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MOTextDtoTest.java @@ -0,0 +1,49 @@ +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 org.assertj.core.api.Assertions; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +class MOTextDtoTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/MOTextDto.json") + MOTextDto loadedDto; + + @GivenTextResource("/domains/sms/v1/MOTextDto.json") + String jsonStringDto; + + MOTextDto dto = + new MOTextDto(MOTextDto.TypeEnum.MO_TEXT.getValue()) + .from("+11203494390") + .id("01FC66621XXXXX119Z8PMV1QPA") + .receivedAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .to("11203453453") + .body("a body") + .clientReference("a client reference") + .operatorId("35000") + .sentAt(OffsetDateTime.parse("2019-08-24T14:15:22Z")); + + @Test + void deserialize() { + + MOTextDto expected = dto; + + Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(dto); + + JSONAssert.assertEquals(jsonStringDto, serializedString, true); + } +} 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 new file mode 100644 index 00000000..680fa888 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/MediaResponseDtoTest.java @@ -0,0 +1,85 @@ +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; +import java.util.Arrays; +import java.util.Map; +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") + MediaResponseDto loadedDto; + + @GivenTextResource("/domains/sms/v1/MediaResponseDto.json") + String jsonStringDto; + + ParameterObjDto parameterObjDto = new ParameterObjDto(); + + MediaResponseDto mediaDTO = + new MediaResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + "mt_media", + OffsetDateTime.parse("2019-08-24T14:14:22Z"), + OffsetDateTime.parse("2019-08-24T14:15:22Z")) + .body( + new MediaBodyDto() + .url( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .message("Media message from Sinch!")) + .callbackUrl("callback url") + .clientReference("client reference") + .deliveryReport("summary") + .expireAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .feedbackEnabled(false) + .from("+15551231234") + .parameters(parameterObjDto) + .sendAt(OffsetDateTime.parse("2019-08-24T14:16:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .strictValidation(true); + + @Test + 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() { + Map entry1 = + Stream.of( + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto + .JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET, + "msisdn value"), + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map entry2 = + Stream.of(new AbstractMap.SimpleEntry<>("a key", "a value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + parameterObjDto.put( + ParameterObjDto.JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET, entry1); + parameterObjDto.put("an identifier", entry2); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDtoTest.java new file mode 100644 index 00000000..d47a6278 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/RetrieveInboundMessage200ResponseDtoTest.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import java.time.OffsetDateTime; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +class RetrieveInboundMessage200ResponseDtoTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/MOBinaryDto.json") + RetrieveInboundMessage200ResponseDto loadedBinaryMessage; + + @GivenJsonResource("/domains/sms/v1/MOTextDto.json") + RetrieveInboundMessage200ResponseDto loadedTextMessage; + + MOBinaryDto binaryDTO = + new MOBinaryDto("mo_binary") + .from("+11203494390") + .id("01FC66621XXXXX119Z8PMV1QPA") + .receivedAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .to("11203453453") + .body("a body") + .clientReference("a client reference") + .operatorId("35000") + .sentAt(OffsetDateTime.parse("2019-08-24T14:15:22Z")) + .udh("foo udh"); + + MOTextDto textDTO = + new MOTextDto("mo_text") + .from("+11203494390") + .id("01FC66621XXXXX119Z8PMV1QPA") + .receivedAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .to("11203453453") + .body("a body") + .clientReference("a client reference") + .operatorId("35000") + .sentAt(OffsetDateTime.parse("2019-08-24T14:15:22Z")); + + RetrieveInboundMessage200ResponseDto expectedBinaryMessageDto = + new RetrieveInboundMessage200ResponseDto(binaryDTO); + + RetrieveInboundMessage200ResponseDto expectedTextMessageDto = + new RetrieveInboundMessage200ResponseDto(textDTO); + + @Test + void deserializeBinaryMessage() { + + Assertions.assertThat(loadedBinaryMessage) + .usingRecursiveComparison() + .isEqualTo(expectedBinaryMessageDto); + } + + @Test + void deserializeTextMessage() { + + Assertions.assertThat(loadedTextMessage) + .usingRecursiveComparison() + .isEqualTo(expectedTextMessageDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDtoTest.java new file mode 100644 index 00000000..3bfef85b --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMS201ResponseDtoTest.java @@ -0,0 +1,138 @@ +package com.sinch.sdk.domains.sms.models.dto.v1; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +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; +import java.util.Arrays; +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; + +@TestWithResources +class SendSMS201ResponseDtoTest extends BaseTest { + + @GivenJsonResource("/domains/sms/v1/BinaryResponseDto.json") + SendSMS201ResponseDto loadedBinary; + + @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + SendSMS201ResponseDto loadedText; + + @GivenJsonResource("/domains/sms/v1/MediaResponseDto.json") + SendSMS201ResponseDto loadedMedia; + + ParameterObjDto parameterObjDto = new ParameterObjDto(); + + BinaryResponseDto binaryDTO = + new BinaryResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + OffsetDateTime.parse("2019-08-24T14:15:22Z"), + OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .body("Hi ${name}! How are you?") + .callbackUrl("callback url") + .clientReference("myReference") + .deliveryReport("none") + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .feedbackEnabled(false) + .flashMessage(true) + .from("+15551231234") + .fromTon(6) + .fromNpi(18) + .maxNumberOfMessageParts(1) + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .truncateConcat(true) + .type("mt_binary") + .udh("foo udh"); + + TextResponseDto textDTO = + new TextResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + "mt_text", + OffsetDateTime.parse("2019-08-24T14:15:22Z"), + OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .body("Hi ${name}! How are you?") + .callbackUrl("callback url") + .clientReference("myReference") + .deliveryReport("none") + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .feedbackEnabled(false) + .flashMessage(true) + .from("+15551231234") + .fromTon(6) + .fromNpi(18) + .maxNumberOfMessageParts(1) + .parameters(parameterObjDto) + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .truncateConcat(true); + SendSMS201ResponseDto expectedTextDto = new SendSMS201ResponseDto(textDTO); + MediaResponseDto mediaDTO = + new MediaResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + "mt_media", + OffsetDateTime.parse("2019-08-24T14:14:22Z"), + OffsetDateTime.parse("2019-08-24T14:15:22Z")) + .body( + new MediaBodyDto() + .url( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .message("Media message from Sinch!")) + .callbackUrl("callback url") + .clientReference("client reference") + .deliveryReport("summary") + .expireAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .feedbackEnabled(false) + .from("+15551231234") + .parameters(parameterObjDto) + .sendAt(OffsetDateTime.parse("2019-08-24T14:16:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .strictValidation(true); + SendSMS201ResponseDto expectedMediaDto = new SendSMS201ResponseDto(mediaDTO); + SendSMS201ResponseDto expectedBinaryDto = new SendSMS201ResponseDto(binaryDTO); + + @Test + void deserializeBinaryMessage() throws JsonProcessingException { + + Assertions.assertThat(loadedBinary).usingRecursiveComparison().isEqualTo(expectedBinaryDto); + } + + @Test + void deserializeTextMessage() throws JsonProcessingException { + + Assertions.assertThat(loadedText).usingRecursiveComparison().isEqualTo(expectedTextDto); + } + + @Test + void deserializeMediaMessage() throws JsonProcessingException { + + Assertions.assertThat(loadedMedia).usingRecursiveComparison().isEqualTo(expectedMediaDto); + } + + @BeforeEach + void setUp() { + Map entry1 = + Stream.of( + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto + .JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET, + "msisdn value"), + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map entry2 = + Stream.of(new AbstractMap.SimpleEntry<>("a key", "a value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + parameterObjDto.put( + ParameterObjDto.JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET, entry1); + parameterObjDto.put("an identifier", entry2); + } +} 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 new file mode 100644 index 00000000..e979efea --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/SendSMSRequestDtoTest.java @@ -0,0 +1,132 @@ +package com.sinch.sdk.domains.sms.models.dto.v1; + +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; +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 SendSMSRequestDtoTest extends BaseTest { + @GivenTextResource("/domains/sms/v1/SendSMSBinaryRequestDto.json") + String jsonRequestBinaryDto; + + @GivenTextResource("/domains/sms/v1/SendSMSTextRequestDto.json") + String jsonRequestTextDto; + + @GivenTextResource("/domains/sms/v1/SendSMSMediaRequestDto.json") + String jsonRequestMediaDto; + + @Test + void serializeBinaryRequestDto() throws JsonProcessingException, JSONException { + + BinaryRequestDto binaryRequestDTO = + new BinaryRequestDto() + .to(Arrays.asList("+15551231234", "+15551256344")) + .body("Hi ${name}! How are you?") + .udh("foo udh") + .from("+15551231234") + .type("mt_binary") + .deliveryReport("none") + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .callbackUrl("callback url") + .clientReference("myReference") + .feedbackEnabled(false) + .flashMessage(true) + .truncateConcat(true) + .maxNumberOfMessageParts(1) + .fromTon(6) + .fromNpi(18); + SendSMSRequestDto sendSMSRequestDto = new SendSMSRequestDto(binaryRequestDTO); + + String serializedString = objectMapper.writeValueAsString(sendSMSRequestDto); + + JSONAssert.assertEquals(jsonRequestBinaryDto, serializedString, true); + } + + @Test + void serializeTextRequestDto() throws JsonProcessingException, JSONException { + + Map map = + Stream.of( + new AbstractMap.SimpleEntry<>("12345678910", "Joe"), + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, "there")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + ParameterObjDto parameterObjDto = new ParameterObjDto(); + + parameterObjDto.put("name", map); + TextRequestDto textRequestDTO = + new TextRequestDto() + .to(Arrays.asList("+15551231234", "+15551256344")) + .body("Hi ${name}! How are you?") + .from("+15551231234") + .type("mt_text") + .deliveryReport("none") + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .callbackUrl("callback url") + .clientReference("myReference") + .feedbackEnabled(false) + .flashMessage(true) + .truncateConcat(true) + .maxNumberOfMessageParts(1) + .fromTon(6) + .fromNpi(18) + .parameters(parameterObjDto); + + SendSMSRequestDto sendSMSRequestDto = new SendSMSRequestDto(textRequestDTO); + + String serializedString = objectMapper.writeValueAsString(sendSMSRequestDto); + + JSONAssert.assertEquals(jsonRequestTextDto, serializedString, true); + } + + @Test + void serializeMediaRequestDto() throws JsonProcessingException, JSONException { + + Map map = + Stream.of( + new AbstractMap.SimpleEntry<>("12345678910", "Joe"), + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, "there")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + ParameterObjDto parameterObjDto = new ParameterObjDto(); + + parameterObjDto.put("name", map); + MediaRequestDto mediaRequestDTO = + new MediaRequestDto("mt_media") + .to(Arrays.asList("+15551231234", "+15551256344")) + .body( + new MediaBodyDto() + .url( + "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png") + .message("Media message from Sinch!")) + .from("+15551231234") + .deliveryReport("none") + .sendAt(OffsetDateTime.parse("2019-08-24T14:16:22Z")) + .expireAt(OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .callbackUrl("callback url") + .clientReference("client reference") + .feedbackEnabled(false) + .strictValidation(true) + .parameters(parameterObjDto); + + SendSMSRequestDto sendSMSRequestDto = new SendSMSRequestDto(mediaRequestDTO); + + String serializedString = objectMapper.writeValueAsString(sendSMSRequestDto); + + JSONAssert.assertEquals(jsonRequestMediaDto, serializedString, true); + } +} 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 new file mode 100644 index 00000000..ee1d121e --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/sms/models/dto/v1/TextResponseDtoTest.java @@ -0,0 +1,87 @@ +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; +import java.util.Arrays; +import java.util.Map; +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 TextResponseDtoTest extends BaseTest { + @GivenJsonResource("/domains/sms/v1/TextResponseDto.json") + TextResponseDto loadedDto; + + @GivenTextResource("/domains/sms/v1/TextResponseDto.json") + String jsonStringDto; + + ParameterObjDto parameterObjDto = new ParameterObjDto(); + + TextResponseDto dto = + new TextResponseDto( + "01FC66621XXXXX119Z8PMV1QPQ", + false, + TextResponseDto.TypeEnum.MT_TEXT.getValue(), + OffsetDateTime.parse("2019-08-24T14:15:22Z"), + OffsetDateTime.parse("2019-08-24T14:17:22Z")) + .body("Hi ${name}! How are you?") + .callbackUrl("callback url") + .clientReference("myReference") + .deliveryReport("none") + .expireAt(OffsetDateTime.parse("2019-08-24T14:21:22Z")) + .feedbackEnabled(false) + .flashMessage(true) + .from("+15551231234") + .fromTon(6) + .fromNpi(18) + .maxNumberOfMessageParts(1) + .parameters(parameterObjDto) + .sendAt(OffsetDateTime.parse("2019-08-24T14:19:22Z")) + .to(Arrays.asList("+15551231234", "+15551256344")) + .truncateConcat(true); + + @Test + void deserialize() { + + TextResponseDto expected = dto; + + Assertions.assertThat(loadedDto).usingRecursiveComparison().isEqualTo(expected); + } + + @Test + void serialize() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(dto); + + JSONAssert.assertEquals(jsonStringDto, serializedString, true); + } + + @BeforeEach + void setUp() { + Map entry1 = + Stream.of( + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto + .JSON_PROPERTY_LEFT_CURLY_BRACKET_MSISDN_RIGHT_CURLY_BRACKET, + "msisdn value"), + new AbstractMap.SimpleEntry<>( + ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, "default value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + Map entry2 = + Stream.of(new AbstractMap.SimpleEntry<>("a key", "a value")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + parameterObjDto.put( + ParameterObjDto.JSON_PROPERTY_LEFT_CURLY_BRACKET_PARAMETER_KEY_RIGHT_CURLY_BRACKET, entry1); + parameterObjDto.put("an identifier", entry2); + } +} diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..95d7c6c6 --- /dev/null +++ b/pom.xml @@ -0,0 +1,456 @@ + + 4.0.0 + + com.sinch.sdk + sinch-sdk-java + 0.0.1-SNAPSHOT + + Sinch Java SDK + + SDK providing a Java API for the Sinch REST APIs. + + https://github.com/sinch/sinch-sdk-java + + + Sinch + https://www.sinch.com + + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + Jean-Pierre Portier + jean-pierre.portier at sinch dot com + Sinch + https://www.sinch.com + + + + + https://github.com/sinch/sinch-sdk-java/tree/main + scm:git:git://github.com/sinch/sinch-sdk-java.git + scm:git:ssh://github.com:sinch/sinch-sdk-java.git + + + + https://github.com/sinch/sinch-sdk-java/issues + GitHub + + + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + + + UTF-8 + + + 1.8 + 1.8 + 1.8 + 1.8 + 8 + 3.8.0 + true + true + + + 2.15.2 + 5.2.1 + + + 5.5.0 + 3.2.1 + 3.2.1 + + + 3.2.1 + 3.6.0 + 3.1.1 + 1.5 + 1.6.13 + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven.javadoc.plugin.version} + + + attach-javadocs + + jar + javadoc + + + + + public + core/src/main; + client/src/main; + openapi-contracts/src/main; + + + com.sinch.sdk.auth; + com.sinch.sdk.auth*; + com.sinch.sdk.core.http; + com.sinch.sdk.core.http.*; + com.sinch.sdk.core.utils.databind; + com.sinch.sdk.http; + com.sinch.sdk.pagination.Page*; + **.dto.*; + **.api.*; + **.adapters.converters; + **.adapters; + + + **/pagination/Page*.java + **/AbstractOpenApiSchema.java + + + + Core package + com.sinch.sdk.core* + + + Numbers + com.sinch.sdk.domains.numbers* + + + SMS + com.sinch.sdk.domains.sms* + + + Sinch Client + com.sinch.sdk* + + + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-sources + generate-sources + + add-source + + + + core/src/main + openapi-contracts/src/main + client/src/main + + + + + + add-resources + generate-resources + + add-resource + + + + + client/resources + + + + + + + add-test-sources + generate-test-sources + + add-test-source + + + + core/src/test/java + test-resources/src/test/java + openapi-contracts/src/test/java + client/src/test/java + + + + + add-test-resources + generate-test-resources + + add-test-resource + + + + + test-resources/src/test/resources + + + client/src/test/resources + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.version} + + -Xlint:all + + + + + maven-failsafe-plugin + ${maven.failsafe.plugin.version} + + + + integration-test + verify + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + true + + + + + + com.diffplug.spotless + spotless-maven-plugin + 2.40.0 + + + + **/*.java + + + + 1.8 + + true + + + + + true + 2 + + + + + + + + + verify + + check + + + + + + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + ${jackson.version} + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + ${jackson.version} + + + + org.apache.httpcomponents.client5 + httpclient5 + ${httpclient5.version} + + + + org.junit.jupiter + junit-jupiter + 5.10.0 + test + + + + org.assertj + assertj-core + 3.24.2 + test + + + + org.mockito + mockito-junit-jupiter + ${mockito.version} + test + + + + io.hosuaby + inject-resources-core + 0.3.3 + test + + + + io.hosuaby + inject-resources-junit-jupiter + 0.3.3 + test + + + + org.skyscreamer + jsonassert + 1.5.1 + test + + + + com.squareup.okhttp3 + okhttp + 4.11.0 + test + + + + com.squareup.okhttp3 + mockwebserver + 4.11.0 + test + + + + + + + deploy + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven.source.plugin.version} + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + org.apache.maven.plugins + maven-gpg-plugin + ${maven-gpg-plugin.version} + + + sign-artifacts + verify + + sign + + + ${gpg.keyname} + ${gpg.keyname} + + --pinentry-mode + loopback + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + ${nexus-staging-maven-plugin} + true + + + default-deploy + deploy + + deploy + + + + + + ossrh + https://oss.sonatype.org/ + false + + + + + + + + + \ No newline at end of file diff --git a/sample-app/README.md b/sample-app/README.md new file mode 100644 index 00000000..4576d2ac --- /dev/null +++ b/sample-app/README.md @@ -0,0 +1,67 @@ +# Sample application based onto Sinch Java SDK + +This directory contains samples related to supported services/endpoint for Sinch Java SDK. + +It is not a submodule to mimic a real application to be built from a deployed SDK; this mean the SDK jar must be "installed" locally to be resolved as application dependency. + +## Usage + +1. Generate and install locally the Sinch SDK java + + From parent directory of this application (repository root directory): + ``` + mvn install + ``` + Then generated SDK will be available for sample application generation. +2. Application generation + + Application generation command: + ``` + mvn package + ``` +3. Execute a sample + ``` + java -cp target/sinch-sdk-java-sample-app-1.0.0-SNAPSHOT-jar-with-dependencies.jar + ``` + +## Samples execution required parameters +### Common parameters +Set your credentials used by sample app: +``` +export SINCH_KEY_ID= +export SINCH_KEY_SECRET= +export SINCH_PROJECT_ID= +``` + +### Test dependant parameters + +Like for credentials, use the following command to define a parameter required by test execution: + + ``` + export = + ``` + +Variable to be used: +- `PHONE_NUMBER`: Some test are requiring a phone number parameter. +- `BATCH_ID`: Some test are requiring a phone number parameter. + +See https://developers.sinch.com for details about these parameters + +## Available samples classes + +| API | Service | Sample | Class | Notes | +|---------|-----------|-----------|---------------------------------------------------------------------------------------------------------------|----------------------------------| +| Numbers | Available | - Get | [com.sinch.sample.numbers.available.Get](src/main/java/com/sinch/sample/numbers/available/Get.java) | Require `PHONE_NUMBER` parameter | +| | | - ListAll | [com.sinch.sample.numbers.available.ListAll](src/main/java/com/sinch/sample/numbers/available/ListAll.java) | | +| | | - Rent | [com.sinch.sample.numbers.available.Rent](src/main/java/com/sinch/sample/numbers/available/Rent.java) | Require `PHONE_NUMBER` parameter | +| | | - RentAny | [com.sinch.sample.numbers.available.RentAny](src/main/java/com/sinch/sample/numbers/available/RentAny.java) | | +| | Active | - Get | [com.sinch.sample.numbers.active.Get](src/main/java/com/sinch/sample/numbers/active/Get.java) | Require `PHONE_NUMBER` parameter | +| | | - List | [com.sinch.sample.numbers.active.List](src/main/java/com/sinch/sample/numbers/active/List.java) | | +| | | - Release | [com.sinch.sample.numbers.active.Release](src/main/java/com/sinch/sample/numbers/active/Release.java) | Require `PHONE_NUMBER` parameter | +| | | - Update | [com.sinch.sample.numbers.active.Update](src/main/java/com/sinch/sample/numbers/active/Update.java) | Require `PHONE_NUMBER` parameter | +| | Callback | - Get | [com.sinch.sample.numbers.callback.Get](src/main/java/com/sinch/sample/numbers/callback/Get.java) | | +| | | - Update | [com.sinch.sample.numbers.callback.Update](src/main/java/com/sinch/sample/numbers/callback/Get.java) | | +| | Regions | - ListAll | [com.sinch.sample.numbers.regions.ListAll](src/main/java/com/sinch/sample/numbers/regions/ListAll.java) | | +| SMS | Batches | - Get | [com.sinch.sample.sms.batches.Get](src/main/java/com/sinch/sample/sms/batches/Get.java) | Require `BATCH_ID` parameter | + + diff --git a/sample-app/pom.xml b/sample-app/pom.xml new file mode 100644 index 00000000..f7829518 --- /dev/null +++ b/sample-app/pom.xml @@ -0,0 +1,88 @@ + + 4.0.0 + + com.sinch.sdk + sinch-sdk-java-sample-app + 1.0.0-SNAPSHOT + + jar + Sinch Java SDK Sample Application + + + [0.0.0,) + + + + + + staging + + + oss-staging + https://oss.sonatype.org/content/repositories/${sinch.sdk.java.staging}/ + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.2.0 + + + add-sources + generate-sources + + add-source + + + + src/main/java + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + jar-with-dependencies + + + + + make-assembly + package + + single + + + + + + + + + + com.sinch.sdk + sinch-sdk-java + ${sinch.sdk.java.version} + + + + + org.slf4j + slf4j-nop + 2.0.9 + + + + + + \ No newline at end of file diff --git a/sample-app/src/main/java/com/sinch/sample/BaseApplication.java b/sample-app/src/main/java/com/sinch/sample/BaseApplication.java new file mode 100644 index 00000000..7ac80671 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/BaseApplication.java @@ -0,0 +1,96 @@ +package com.sinch.sample; + +import com.sinch.sdk.SinchClient; +import com.sinch.sdk.models.Configuration; +import com.sinch.sdk.models.SMSRegion; +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; +import java.util.logging.LogManager; +import java.util.logging.Logger; + +public abstract class BaseApplication { + + /** duplicate of SinchClient property files for lisibility facility but could be anything else */ + private static final String OAUTH_URL_KEY = "oauth-url"; + + private static final String NUMBERS_SERVER_KEY = "numbers-server"; + private static final String SMS_REGION_KEY = "sms-region"; + private static final String SMS_SERVER_KEY = "sms-server"; + + private static final String BATCH_ID_KEY = "BATCH_ID"; + private static final String PHONE_NUMBER_KEY = "PHONE_NUMBER"; + private static final String SINCH_KEY_ID = "SINCH_KEY_ID"; + private static final String SINCH_KEY_SECRET = "SINCH_KEY_SECRET"; + private static final String SINCH_PROJECT_ID = "SINCH_PROJECT_ID"; + + protected static Logger LOGGER; + + protected SinchClient client; + protected String phoneNumber; + protected String batchId; + + protected BaseApplication() throws IOException { + + Properties properties = handleConfigurations(); + + String keyId = + null != System.getenv(SINCH_KEY_ID) + ? System.getenv(SINCH_KEY_ID) + : properties.getProperty(SINCH_KEY_ID); + String keySecret = + null != System.getenv(SINCH_KEY_SECRET) + ? System.getenv(SINCH_KEY_SECRET) + : properties.getProperty(SINCH_KEY_SECRET); + String projectId = + null != System.getenv(SINCH_PROJECT_ID) + ? System.getenv(SINCH_PROJECT_ID) + : properties.getProperty(SINCH_PROJECT_ID); + + Configuration.Builder builder = + Configuration.builder().setKeyId(keyId).setKeySecret(keySecret).setProjectId(projectId); + + LOGGER.info("Starting application"); + + // override by local config + if (properties.containsKey(NUMBERS_SERVER_KEY)) { + builder.setNumbersUrl(properties.getProperty(NUMBERS_SERVER_KEY)); + } + if (properties.containsKey(SMS_SERVER_KEY)) { + builder.setSmsUrl(properties.getProperty(SMS_SERVER_KEY)); + } + if (properties.containsKey(SMS_REGION_KEY)) { + builder.setSmsRegion(SMSRegion.from(properties.getProperty(SMS_REGION_KEY))); + } + phoneNumber = + null != System.getenv(PHONE_NUMBER_KEY) + ? System.getenv(PHONE_NUMBER_KEY) + : properties.getProperty(PHONE_NUMBER_KEY); + batchId = + null != System.getenv(BATCH_ID_KEY) + ? System.getenv(BATCH_ID_KEY) + : properties.getProperty(BATCH_ID_KEY); + + client = new SinchClient(builder.build()); + } + + private static Properties handleConfigurations() throws IOException { + + InputStream is = BaseApplication.class.getResourceAsStream("/logging.properties"); + if (null != is) { + LogManager.getLogManager().readConfiguration(is); + is.close(); + } + LOGGER = Logger.getLogger(BaseApplication.class.getName()); + + Properties prop = new Properties(); + is = BaseApplication.class.getResourceAsStream("/config.properties"); + if (null != is) { + prop.load(is); + is.close(); + } + return prop; + } + + public abstract void run(); +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/active/Get.java b/sample-app/src/main/java/com/sinch/sample/numbers/active/Get.java new file mode 100644 index 00000000..42ba234f --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/active/Get.java @@ -0,0 +1,29 @@ +package com.sinch.sample.numbers.active; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +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() { + + LOGGER.info("Get for :" + phoneNumber); + ActiveNumber value = client.numbers().active().get(phoneNumber); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/active/List.java b/sample-app/src/main/java/com/sinch/sample/numbers/active/List.java new file mode 100644 index 00000000..416c0de4 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/active/List.java @@ -0,0 +1,47 @@ +package com.sinch.sample.numbers.active; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; +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() { + + LOGGER.info("List"); + + ActiveNumberListResponse response = + client + .numbers() + .active() + .list( + ActiveNumberListRequestParameters.builder() + .setRegionCode("US") + .setType(NumberType.LOCAL) + .setPageSize(2) + .build()); + AtomicInteger page = new AtomicInteger(1); + response + .autoPageIter() + .forEachRemaining( + value -> + LOGGER.info( + String.format("Response (page %d): %s", page.getAndIncrement(), value))); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/active/Release.java b/sample-app/src/main/java/com/sinch/sample/numbers/active/Release.java new file mode 100644 index 00000000..07aca0d8 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/active/Release.java @@ -0,0 +1,30 @@ +package com.sinch.sample.numbers.active; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import java.io.IOException; +import java.util.logging.Logger; + +public class Release extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Release.class.getName()); + + public Release() throws IOException {} + + public static void main(String[] args) { + try { + new Release().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + LOGGER.info("Get for :" + phoneNumber); + + ActiveNumber value = client.numbers().active().release(phoneNumber); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/active/Update.java b/sample-app/src/main/java/com/sinch/sample/numbers/active/Update.java new file mode 100644 index 00000000..f1dbfea5 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/active/Update.java @@ -0,0 +1,46 @@ +package com.sinch.sample.numbers.active; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters; +import java.io.IOException; +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() { + + LOGGER.info("Update for :" + phoneNumber); + + String displayName = "my display from app sample foo"; + ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration = + null; // new ActiveNumberUpdateSMSConfigurationRequestParameters(); + ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration = + null; // new ActiveNumberUpdateVoiceConfigurationRequestParameters(); + + ActiveNumberUpdateRequestParameters parameters = + ActiveNumberUpdateRequestParameters.builder() + .setDisplayName(displayName) + .setSmsConfiguration(smsConfiguration) + .setVoiceConfiguration(voiceConfiguration) + .build(); + + ActiveNumber value = client.numbers().active().update(phoneNumber, parameters); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/available/Get.java b/sample-app/src/main/java/com/sinch/sample/numbers/available/Get.java new file mode 100644 index 00000000..24074603 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/available/Get.java @@ -0,0 +1,30 @@ +package com.sinch.sample.numbers.available; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.AvailableNumber; +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() { + + LOGGER.info("Get for :" + phoneNumber); + + AvailableNumber value = client.numbers().available().get(phoneNumber); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/available/List.java b/sample-app/src/main/java/com/sinch/sample/numbers/available/List.java new file mode 100644 index 00000000..67970a46 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/available/List.java @@ -0,0 +1,85 @@ +package com.sinch.sample.numbers.available; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.Capability; +import com.sinch.sdk.domains.numbers.models.NumberPattern; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.SearchPattern; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; +import java.io.IOException; +import java.util.Collections; +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() { + + LOGGER.info("List"); + + int page = 1; + AvailableNumberListResponse response = + client + .numbers() + .available() + .list( + AvailableNumberListAllRequestParameters.builder() + .setRegionCode("US") + .setType(NumberType.LOCAL) + .setCapabilities(Collections.singletonList(Capability.from("SMS"))) + .build()); + LOGGER.info(String.format("Response (page %d): %s", page, response)); + + while (response.hasNextPage()) { + response = response.nextPage(); + page++; + LOGGER.info(String.format("Response (page %d): %s", page, response)); + } + + try { + LOGGER.info("List with error"); + page = 1; + response = + client + .numbers() + .available() + .list( + AvailableNumberListAllRequestParameters.builder() + .setRegionCode("SE") + // this will throw an error but from server side as an invalid parameter: we + // can pass new values (or private) + .setType(NumberType.from("foo")) + .setNumberPattern( + NumberPattern.builder() + .setPattern("93652") + .setSearchPattern(SearchPattern.CONTAINS) + .build()) + .setCapabilities(Collections.singletonList(Capability.SMS)) + .setSize(3) + .build()); + LOGGER.info(String.format("Response (page %d): %s", page, response)); + + while (response.hasNextPage()) { + response = response.nextPage(); + page++; + LOGGER.info(String.format("Response (page %d): %s", page, response)); + } + + } catch (ApiException e) { + LOGGER.severe("Error: " + e); + } + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/available/Rent.java b/sample-app/src/main/java/com/sinch/sample/numbers/available/Rent.java new file mode 100644 index 00000000..a1205c49 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/available/Rent.java @@ -0,0 +1,46 @@ +package com.sinch.sample.numbers.available; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.numbers.models.ActiveNumber; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentVoiceConfigurationRequestParameters; +import java.io.IOException; +import java.util.logging.Logger; + +public class Rent extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(Rent.class.getName()); + + public Rent() throws IOException {} + + public static void main(String[] args) { + try { + new Rent().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + LOGGER.info("Rent for :" + phoneNumber); + try { + + RentSMSConfigurationRequestParameters rentSms = + RentSMSConfigurationRequestParameters.builder() // .setCampaignId("campaign id") + .build(); + RentVoiceConfigurationRequestParameters rentVoice = + RentVoiceConfigurationRequestParameters.builder() // .setAppId("app id") + .build(); + AvailableNumberRentRequestParameters parameters = + new AvailableNumberRentRequestParameters(rentSms, rentVoice, "foo callback"); + ActiveNumber value = client.numbers().available().rent(phoneNumber, parameters); + + LOGGER.info("Response :" + value); + } catch (ApiException e) { + LOGGER.severe("Error: " + e); + } + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/available/RentAny.java b/sample-app/src/main/java/com/sinch/sample/numbers/available/RentAny.java new file mode 100644 index 00000000..1a307b23 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/available/RentAny.java @@ -0,0 +1,49 @@ +package com.sinch.sample.numbers.available; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.*; +import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentSMSConfigurationRequestParameters; +import com.sinch.sdk.domains.numbers.models.requests.RentVoiceConfigurationRequestParameters; +import java.io.IOException; +import java.util.Collections; +import java.util.logging.Logger; + +public class RentAny extends BaseApplication { + private static final Logger LOGGER = Logger.getLogger(RentAny.class.getName()); + + public RentAny() throws IOException {} + + public static void main(String[] args) { + try { + new RentAny().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + LOGGER.info("RentAny :"); + + AvailableNumberRentAnyRequestParameters parameters = + AvailableNumberRentAnyRequestParameters.builder() + .setRegionCode("US") + .setType(NumberType.LOCAL) + .setNumberPattern( + NumberPattern.builder() + .setPattern("2067387769") + .setSearchPattern(SearchPattern.END) + .build()) + .setCapabilities(Collections.singletonList(Capability.VOICE)) + .setSmsConfiguration(new RentSMSConfigurationRequestParameters("campaign id")) + .setVoiceConfiguration(new RentVoiceConfigurationRequestParameters("app id")) + .setCallbackUrl("foo callback") + .build(); + + ActiveNumber value = client.numbers().available().rentAny(parameters); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/callback/Get.java b/sample-app/src/main/java/com/sinch/sample/numbers/callback/Get.java new file mode 100644 index 00000000..051d94ad --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/callback/Get.java @@ -0,0 +1,30 @@ +package com.sinch.sample.numbers.callback; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +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() { + + LOGGER.info("Get"); + + CallbackConfiguration value = client.numbers().callback().get(); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/callback/Update.java b/sample-app/src/main/java/com/sinch/sample/numbers/callback/Update.java new file mode 100644 index 00000000..a0d897b9 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/callback/Update.java @@ -0,0 +1,35 @@ +package com.sinch.sample.numbers.callback; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; +import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; +import java.io.IOException; +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() { + + LOGGER.info("Update"); + + String hmac = "HMAC value"; + CallbackConfigurationUpdateRequestParameters parameters = + CallbackConfigurationUpdateRequestParameters.builder().setHMACSecret(hmac).build(); + + CallbackConfiguration value = client.numbers().callback().update(parameters); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/numbers/regions/List.java b/sample-app/src/main/java/com/sinch/sample/numbers/regions/List.java new file mode 100644 index 00000000..8be28e33 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/numbers/regions/List.java @@ -0,0 +1,47 @@ +package com.sinch.sample.numbers.regions; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.numbers.models.NumberType; +import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; +import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; +import java.io.IOException; +import java.util.Arrays; +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() { + + LOGGER.info("List"); + int page = 1; + + AvailableRegionListResponse response = + client + .numbers() + .regions() + .list( + AvailableRegionListAllRequestParameters.builder() + .setTypes(Arrays.asList(NumberType.MOBILE, NumberType.LOCAL)) + .build()); + + LOGGER.info(String.format("Response (page %d): %s", page, response)); + + while (response.hasNextPage()) { + response = response.nextPage(); + page++; + LOGGER.info(String.format("Response (page %d): %s", page, response)); + } + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/sms/batches/Get.java b/sample-app/src/main/java/com/sinch/sample/sms/batches/Get.java new file mode 100644 index 00000000..923463a7 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/sms/batches/Get.java @@ -0,0 +1,30 @@ +package com.sinch.sample.sms.batches; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.sms.models.Batch; +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() { + + LOGGER.info("Get for :" + batchId); + + Batch value = client.sms().batches().get(batchId); + + LOGGER.info("Response :" + value); + } +} diff --git a/sample-app/src/main/resources/config.properties b/sample-app/src/main/resources/config.properties new file mode 100644 index 00000000..820c9eb9 --- /dev/null +++ b/sample-app/src/main/resources/config.properties @@ -0,0 +1,2 @@ +# supersede default values from Sinch SDK +# numbers-server= https://numbers.api.sinch.com diff --git a/sample-app/src/main/resources/logging.properties b/sample-app/src/main/resources/logging.properties new file mode 100644 index 00000000..50a9f671 --- /dev/null +++ b/sample-app/src/main/resources/logging.properties @@ -0,0 +1,7 @@ +handlers = java.util.logging.ConsoleHandler +java.util.logging.ConsoleHandler.level = FINEST +com.sinch.sdk.level = INFO + +java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter +java.util.logging.SimpleFormatter.format=[%1$tF %1$tT] [%4$-7s %2$s] %5$s %n + diff --git a/settings.xml b/settings.xml new file mode 100644 index 00000000..edb2c4c5 --- /dev/null +++ b/settings.xml @@ -0,0 +1,21 @@ + + + + ossrh + ${env.OSSRH_USER} + ${env.OSSRH_PWD} + + + + + release + + true + + + ${env.GPG_KEY} + ${env.GPG_PWD} + + + + \ No newline at end of file diff --git a/test-resources/src/test/java/com/sinch/sdk/BaseTest.java b/test-resources/src/test/java/com/sinch/sdk/BaseTest.java new file mode 100644 index 00000000..71e77db7 --- /dev/null +++ b/test-resources/src/test/java/com/sinch/sdk/BaseTest.java @@ -0,0 +1,20 @@ +package com.sinch.sdk; + +import com.adelean.inject.resources.junit.jupiter.WithJacksonMapper; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sinch.sdk.core.utils.databind.Mapper; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.MockitoAnnotations; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class BaseTest { + + @WithJacksonMapper protected ObjectMapper objectMapper = Mapper.getInstance(); + + @BeforeEach + void init_mocks() { + MockitoAnnotations.openMocks(this); + } +} diff --git a/test-resources/src/test/resources/domains/numbers/v1/active-numbers-get.json b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-get.json new file mode 100644 index 00000000..b19757c9 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-get.json @@ -0,0 +1,40 @@ +{ + "phoneNumber": "+447520651116XYZ", + "projectId": "project id", + "displayName": "a display", + "regionCode": "GB", + "type": "MOBILE", + "capability": [ + "SMS", + "VOICE" + ], + "money": { + "currencyCode": "EUR", + "amount": "0.80" + }, + "paymentIntervalMonths": 1, + "nextChargeDate": "2023-09-22T15:49:58.813424Z", + "expireAt": "2023-10-06T15:49:58.813381Z", + "smsConfiguration": { + "servicePlanId": "service plan id", + "scheduledProvisioning": { + "servicePlanId": "service plan id from scheduled", + "campaignId": "campaign id from scheduled", + "status": "PROVISIONING_STATUS_UNSPECIFIED", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z", + "errorCodes": [ + "ERROR_CODE_UNSPECIFIED" + ] + } + }, + "voiceConfiguration": { + "appId": "app id", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z", + "scheduledVoiceProvisioning": { + "appId": "app id from scheduled", + "status": "PROVISIONING_STATUS_UNSPECIFIED", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z" + } + }, + "callbackUrl": "foo callback" +} diff --git a/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list-light.json b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list-light.json new file mode 100644 index 00000000..3245f960 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list-light.json @@ -0,0 +1,35 @@ +{ + "activeNumbers": [ + { + "phoneNumber": "+447520651116XYZ", + "projectId": "project id", + "displayName": "", + "regionCode": "GB", + "type": "MOBILE", + "capability": [ + "SMS", + "VOICE" + ], + "money": { + "currencyCode": "EUR", + "amount": "0.80" + }, + "paymentIntervalMonths": 1, + "nextChargeDate": "2023-09-22T15:49:58.813424Z", + "expireAt": "2023-10-06T15:49:58.813381Z", + "smsConfiguration": { + "servicePlanId": "service plan id", + "scheduledProvisioning": null, + "campaignId": "" + }, + "voiceConfiguration": { + "appId": "app id", + "scheduledVoiceProvisioning": null, + "lastUpdatedTime": null + }, + "callbackUrl": "" + } + ], + "nextPageToken": "", + "totalSize": 1 +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list.json b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list.json new file mode 100644 index 00000000..d85a5f96 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/active-numbers-list.json @@ -0,0 +1,46 @@ +{ + "activeNumbers": [ + { + "phoneNumber": "+447520651116XYZ", + "projectId": "project id", + "displayName": "a display", + "regionCode": "GB", + "type": "MOBILE", + "capability": [ + "SMS", + "VOICE" + ], + "money": { + "currencyCode": "EUR", + "amount": "0.80" + }, + "paymentIntervalMonths": 1, + "nextChargeDate": "2023-09-22T15:49:58.813424Z", + "expireAt": "2023-10-06T15:49:58.813381Z", + "smsConfiguration": { + "servicePlanId": "service plan id", + "scheduledProvisioning": { + "servicePlanId": "service plan id from scheduled", + "campaignId": "campaign id from scheduled", + "status": "PROVISIONING_STATUS_UNSPECIFIED", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z", + "errorCodes": [ + "ERROR_CODE_UNSPECIFIED" + ] + } + }, + "voiceConfiguration": { + "appId": "app id", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z", + "scheduledVoiceProvisioning": { + "appId": "app id from scheduled", + "status": "PROVISIONING_STATUS_UNSPECIFIED", + "lastUpdatedTime": "2023-09-25T12:08:02.115Z" + } + }, + "callbackUrl": "foo callback" + } + ], + "nextPageToken": "foo", + "totalSize": 1 +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/numbers/v1/available-numbers-get.json b/test-resources/src/test/resources/domains/numbers/v1/available-numbers-get.json new file mode 100644 index 00000000..0d6da8e4 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/available-numbers-get.json @@ -0,0 +1,19 @@ +{ + "phoneNumber": "+46650553763", + "regionCode": "SE", + "type": "LOCAL", + "capability": [ + "VOICE" + ], + "setupPrice": { + "currencyCode": "DOLLAR", + "amount": "0.57" + }, + "monthlyPrice": { + "currencyCode": "EUR", + "amount": "0.80" + }, + "paymentIntervalMonths": 1, + "supportingDocumentationRequired": true +} + diff --git a/test-resources/src/test/resources/domains/numbers/v1/available-numbers-list.json b/test-resources/src/test/resources/domains/numbers/v1/available-numbers-list.json new file mode 100644 index 00000000..1d5c4cc3 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/available-numbers-list.json @@ -0,0 +1,22 @@ +{ + "availableNumbers": [ + { + "phoneNumber": "+46650553763", + "regionCode": "SE", + "type": "LOCAL", + "capability": [ + "VOICE" + ], + "setupPrice": { + "currencyCode": "DOLLAR", + "amount": "0.57" + }, + "monthlyPrice": { + "currencyCode": "EUR", + "amount": "0.80" + }, + "paymentIntervalMonths": 1, + "supportingDocumentationRequired": true + } + ] +} diff --git a/test-resources/src/test/resources/domains/numbers/v1/available-regions-list.json b/test-resources/src/test/resources/domains/numbers/v1/available-regions-list.json new file mode 100644 index 00000000..8a5c7bfa --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/available-regions-list.json @@ -0,0 +1,11 @@ +{ + "availableRegions": [ + { + "regionCode": "AU", + "regionName": "Australia", + "types": [ + "MOBILE" + ] + } + ] +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/numbers/v1/callback-configuration.json b/test-resources/src/test/resources/domains/numbers/v1/callback-configuration.json new file mode 100644 index 00000000..709f09d1 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/callback-configuration.json @@ -0,0 +1,4 @@ +{ + "projectId": "The project ID", + "hmacSecret": "The secret HMAC" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/numbers/v1/error-trial-account.json b/test-resources/src/test/resources/domains/numbers/v1/error-trial-account.json new file mode 100644 index 00000000..0e680409 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/error-trial-account.json @@ -0,0 +1,16 @@ +{ + "error": { + "code": 403, + "message": "Trial account is not enabled to rent number", + "status": "PERMISSION_DENIED", + "details": [ + { + "type": "ResourceInfo", + "resourceType": "AvailableNumber", + "resourceName": "", + "owner": "", + "description": "Trial account is not enabled to rent number" + } + ] + } +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/numbers/v1/rent-response.json b/test-resources/src/test/resources/domains/numbers/v1/rent-response.json new file mode 100644 index 00000000..63432ba7 --- /dev/null +++ b/test-resources/src/test/resources/domains/numbers/v1/rent-response.json @@ -0,0 +1,38 @@ +{ + "phoneNumber": "+12025550134", + "projectId": "51bc3f40-f266-4ca8-8938-a1ed0ff32b9a", + "displayName": "string", + "regionCode": "US", + "type": "MOBILE", + "capability": [ + "SMS" + ], + "money": { + "currencyCode": "USD", + "amount": "2.00" + }, + "paymentIntervalMonths": 0, + "nextChargeDate": "2019-08-24T14:15:22Z", + "expireAt": "2019-08-24T14:15:22Z", + "smsConfiguration": { + "servicePlanId": "string", + "scheduledProvisioning": { + "servicePlanId": "8200000f74924bd6800000b212f00000", + "status": "WAITING", + "lastUpdatedTime": "2019-08-24T14:15:22Z", + "campaignId": "string", + "errorCodes": [] + }, + "campaignId": "string" + }, + "voiceConfiguration": { + "appId": "string", + "scheduledVoiceProvisioning": { + "appId": "string", + "status": "WAITING", + "lastUpdatedTime": "2019-08-24T14:15:22Z" + }, + "lastUpdatedTime": "2019-08-24T14:15:22Z" + }, + "callbackUrl": "https://www.your-callback-server.com/callback" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/BinaryResponseDto.json b/test-resources/src/test/resources/domains/sms/v1/BinaryResponseDto.json new file mode 100644 index 00000000..662decb8 --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/BinaryResponseDto.json @@ -0,0 +1,25 @@ +{ + "id": "01FC66621XXXXX119Z8PMV1QPQ", + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "canceled": false, + "body": "Hi ${name}! How are you?", + "type": "mt_binary", + "created_at": "2019-08-24T14:15:22Z", + "modified_at": "2019-08-24T14:17:22Z", + "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, + "flash_message": true, + "truncate_concat": true, + "max_number_of_message_parts": 1, + "from_ton": 6, + "from_npi": 18, + "udh": "foo udh" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/MOBinaryDto.json b/test-resources/src/test/resources/domains/sms/v1/MOBinaryDto.json new file mode 100644 index 00000000..e26d5753 --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/MOBinaryDto.json @@ -0,0 +1,12 @@ +{ + "body": "a body", + "client_reference": "a client reference", + "from": "+11203494390", + "id": "01FC66621XXXXX119Z8PMV1QPA", + "operator_id": "35000", + "received_at": "2019-08-24T14:17:22Z", + "sent_at": "2019-08-24T14:15:22Z", + "to": "11203453453", + "type": "mo_binary", + "udh": "foo udh" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/MOTextDto.json b/test-resources/src/test/resources/domains/sms/v1/MOTextDto.json new file mode 100644 index 00000000..6dfbfbc0 --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/MOTextDto.json @@ -0,0 +1,11 @@ +{ + "body": "a body", + "client_reference": "a client reference", + "from": "+11203494390", + "id": "01FC66621XXXXX119Z8PMV1QPA", + "operator_id": "35000", + "received_at": "2019-08-24T14:17:22Z", + "sent_at": "2019-08-24T14:15:22Z", + "to": "11203453453", + "type": "mo_text" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/MediaResponseDto.json b/test-resources/src/test/resources/domains/sms/v1/MediaResponseDto.json new file mode 100644 index 00000000..93cba683 --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/MediaResponseDto.json @@ -0,0 +1,32 @@ +{ + "id": "01FC66621XXXXX119Z8PMV1QPQ", + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "canceled": false, + "body": { + "message": "Media message from Sinch!", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + }, + "parameters": { + "{parameter_key}": { + "{msisdn}": "msisdn value", + "default": "default value" + }, + "an identifier": { + "a key": "a value" + } + }, + "type": "mt_media", + "created_at": "2019-08-24T14:14:22Z", + "modified_at": "2019-08-24T14:15:22Z", + "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 +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/SendSMSBinaryRequestDto.json b/test-resources/src/test/resources/domains/sms/v1/SendSMSBinaryRequestDto.json new file mode 100644 index 00000000..ce5ac53b --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/SendSMSBinaryRequestDto.json @@ -0,0 +1,21 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": "Hi ${name}! 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, + "flash_message": true, + "truncate_concat": true, + "max_number_of_message_parts": 1, + "from_ton": 6, + "from_npi": 18, + "udh": "foo udh" +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/SendSMSMediaRequestDto.json b/test-resources/src/test/resources/domains/sms/v1/SendSMSMediaRequestDto.json new file mode 100644 index 00000000..61e8e29a --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/SendSMSMediaRequestDto.json @@ -0,0 +1,25 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": { + "message": "Media message from Sinch!", + "url": "https://en.wikipedia.org/wiki/Sinch_(company)#/media/File:Sinch_LockUp_RGB.png" + }, + "parameters": { + "name": { + "12345678910": "Joe", + "default": "there" + } + }, + "type": "mt_media", + "delivery_report": "none", + "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 +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/SendSMSTextRequestDto.json b/test-resources/src/test/resources/domains/sms/v1/SendSMSTextRequestDto.json new file mode 100644 index 00000000..dfa4029a --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/SendSMSTextRequestDto.json @@ -0,0 +1,26 @@ +{ + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "body": "Hi ${name}! 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": "myReference", + "feedback_enabled": false, + "flash_message": true, + "truncate_concat": true, + "max_number_of_message_parts": 1, + "from_ton": 6, + "from_npi": 18, + "parameters": { + "name": { + "12345678910": "Joe", + "default": "there" + } + } +} \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/sms/v1/TextResponseDto.json b/test-resources/src/test/resources/domains/sms/v1/TextResponseDto.json new file mode 100644 index 00000000..ed8445d8 --- /dev/null +++ b/test-resources/src/test/resources/domains/sms/v1/TextResponseDto.json @@ -0,0 +1,33 @@ +{ + "id": "01FC66621XXXXX119Z8PMV1QPQ", + "to": [ + "+15551231234", + "+15551256344" + ], + "from": "+15551231234", + "canceled": false, + "parameters": { + "{parameter_key}": { + "{msisdn}": "msisdn value", + "default": "default value" + }, + "an identifier": { + "a key": "a value" + } + }, + "body": "Hi ${name}! How are you?", + "type": "mt_text", + "created_at": "2019-08-24T14:15:22Z", + "modified_at": "2019-08-24T14:17:22Z", + "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, + "flash_message": true, + "truncate_concat": true, + "max_number_of_message_parts": 1, + "from_ton": 6, + "from_npi": 18 +} \ No newline at end of file