From 982a2c6a8b295e53ce98e2c430234017b9364253 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Wed, 22 Nov 2023 16:34:30 +0100 Subject: [PATCH 1/6] feat: Support Verification Application Auth Manager: refactoring auth managers to return list of headers to send with request instead of single token --- client/resources/config-default.properties | 3 +- .../src/main/com/sinch/sdk/SinchClient.java | 32 +++++- .../sdk/auth/adapters/BasicAuthManager.java | 26 +++-- .../sdk/auth/adapters/BearerAuthManager.java | 16 +-- .../VerificationApplicationAuthManager.java | 90 +++++++++++++++++ .../verification/VerificationService.java | 19 ++++ .../verification/VerificationsService.java | 27 +++++ .../adapters/VerificationService.java | 56 +++++++++++ .../adapters/VerificationsService.java | 33 +++++++ .../converters/VerificationsDtoConverter.java | 55 +++++++++++ .../domains/verification/models/Identity.java | 3 + .../verification/models/NumberIdentity.java | 41 ++++++++ .../models/VerificationMethod.java | 55 +++++++++++ ...erificationFlashCallRequestParameters.java | 53 ++++++++++ .../StartVerificationRequestParameters.java | 98 +++++++++++++++++++ .../domains/verification/package-info.java | 6 ++ .../com/sinch/sdk/http/HttpClientApache.java | 25 +++-- .../com/sinch/sdk/models/Configuration.java | 43 +++++++- .../auth/adapters/BasicAuthManagerTest.java | 29 ++++-- .../auth/adapters/BearerAuthManagerTest.java | 22 +++-- ...erificationApplicationAuthManagerTest.java | 58 +++++++++++ .../core/exceptions/ApiExceptionBuilder.java | 43 +++++++- .../com/sinch/sdk/core/http/AuthManager.java | 10 +- .../verification/verifications/Start.java | 40 ++++++++ 24 files changed, 833 insertions(+), 50 deletions(-) create mode 100644 client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/VerificationService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/Identity.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/package-info.java create mode 100644 client/src/test/java/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManagerTest.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java diff --git a/client/resources/config-default.properties b/client/resources/config-default.properties index e0c4952e..c0626ca2 100644 --- a/client/resources/config-default.properties +++ b/client/resources/config-default.properties @@ -1,4 +1,5 @@ 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 +sms-server=https://zt.%s.sms.api.sinch.com +verification-server=https://verification.api.sinch.com diff --git a/client/src/main/com/sinch/sdk/SinchClient.java b/client/src/main/com/sinch/sdk/SinchClient.java index 223718f2..ca46e965 100644 --- a/client/src/main/com/sinch/sdk/SinchClient.java +++ b/client/src/main/com/sinch/sdk/SinchClient.java @@ -2,6 +2,7 @@ import com.sinch.sdk.domains.numbers.NumbersService; import com.sinch.sdk.domains.sms.SMSService; +import com.sinch.sdk.domains.verification.VerificationService; import com.sinch.sdk.http.HttpClientApache; import com.sinch.sdk.models.Configuration; import com.sinch.sdk.models.SMSRegion; @@ -18,13 +19,14 @@ public class SinchClient { 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 VERIFICATION_SERVER_KEY = "verification-server"; private static final Logger LOGGER = Logger.getLogger(SinchClient.class.getName()); private final Configuration configuration; private NumbersService numbers; - private SMSService sms; + private VerificationService verification; private HttpClientApache httpClient; @@ -51,6 +53,9 @@ public SinchClient(Configuration configuration) { if (null == configuration.getSmsRegion() && props.containsKey(SMS_REGION_KEY)) { builder.setSmsRegion(SMSRegion.from(props.getProperty(SMS_REGION_KEY))); } + if (null == configuration.getVerificationUrl() && props.containsKey(VERIFICATION_SERVER_KEY)) { + builder.setVerificationUrl(props.getProperty(VERIFICATION_SERVER_KEY)); + } Configuration newConfiguration = builder.build(); checkConfiguration(newConfiguration); this.configuration = newConfiguration; @@ -98,6 +103,21 @@ public SMSService sms() { return sms; } + /** + * Get verification domain service + * + * @return Return instance onto verification API service + * @see https://developers.sinch.com/docs/verification/api-reference// + * @since 1.0 + */ + public VerificationService verification() { + if (null == verification) { + verification = verificationInit(); + } + return verification; + } + private void checkConfiguration(Configuration configuration) throws NullPointerException { Objects.requireNonNull(configuration.getKeyId(), "'keyId' cannot be null"); Objects.requireNonNull(configuration.getKeySecret(), "'keySecret' cannot be null"); @@ -105,6 +125,7 @@ private void checkConfiguration(Configuration configuration) throws NullPointerE Objects.requireNonNull(configuration.getOAuthUrl(), "'oauthUrl' cannot be null"); Objects.requireNonNull(configuration.getNumbersUrl(), "'numbersUrl' cannot be null"); Objects.requireNonNull(configuration.getSmsUrl(), "'smsUrl' cannot be null"); + Objects.requireNonNull(configuration.getVerificationUrl(), "'verificationUrl' cannot be null"); } private NumbersService numbersInit() { @@ -122,6 +143,15 @@ private SMSService smsInit() { return new com.sinch.sdk.domains.sms.adapters.SMSService(getConfiguration(), getHttpClient()); } + private VerificationService verificationInit() { + LOGGER.fine( + "Activate verification API with server='" + + getConfiguration().getVerificationServer().getUrl() + + "'"); + return new com.sinch.sdk.domains.verification.adapters.VerificationService( + getConfiguration(), getHttpClient()); + } + private Properties handleDefaultConfigurationFile() { Properties prop = new Properties(); diff --git a/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java b/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java index 1de2ad4e..1f04fdc5 100644 --- a/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java +++ b/client/src/main/com/sinch/sdk/auth/adapters/BasicAuthManager.java @@ -1,16 +1,22 @@ package com.sinch.sdk.auth.adapters; import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.Pair; import com.sinch.sdk.models.Configuration; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.Collection; +import java.util.Collections; public class BasicAuthManager implements AuthManager { + private static final String AUTH_KEYWORD = "Basic"; - private final Configuration configuration; + private final String keyId; + private final String keySecret; public BasicAuthManager(Configuration configuration) { - this.configuration = configuration; + this.keyId = configuration.getKeyId(); + this.keySecret = configuration.getKeySecret(); } public String getSchema() { @@ -23,14 +29,18 @@ public void resetToken() { } @Override - public String getAuthorizationHeaderValue() { - String key = configuration.getKeyId() == null ? "" : configuration.getKeyId(); - String secret = configuration.getKeySecret() == null ? "" : configuration.getKeySecret(); + public Collection> getAuthorizationHeaders( + String method, String httpContentType, String path, String body) { + String key = keyId == null ? "" : keyId; + String secret = keySecret == null ? "" : keySecret; String raw = key + ":" + secret; - return AUTH_KEYWORD - + " " - + Base64.getEncoder().encodeToString(raw.getBytes(StandardCharsets.UTF_8)); + return Collections.singletonList( + new Pair<>( + "Authorization", + 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 index 19b9b30e..f5e41c88 100644 --- a/client/src/main/com/sinch/sdk/auth/adapters/BearerAuthManager.java +++ b/client/src/main/com/sinch/sdk/auth/adapters/BearerAuthManager.java @@ -9,8 +9,11 @@ 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.core.utils.Pair; import com.sinch.sdk.models.Configuration; import java.util.AbstractMap; +import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.Optional; @@ -24,15 +27,14 @@ public class BearerAuthManager implements AuthManager { private static final Logger LOGGER = Logger.getLogger(BearerAuthManager.class.getName()); private static final String AUTH_KEYWORD = "Bearer"; private static final int maxRefreshAttempt = 5; - private final Configuration configuration; + private final ServerConfiguration oAuthServer; private final HttpMapper mapper; private final HttpClient httpClient; private final Map authManagers; - private String token; public BearerAuthManager(Configuration configuration, HttpMapper mapper, HttpClient httpClient) { - this.configuration = configuration; + this.oAuthServer = configuration.getOAuthServer(); this.mapper = mapper; this.httpClient = httpClient; @@ -52,12 +54,13 @@ public void resetToken() { } @Override - public String getAuthorizationHeaderValue() { + public Collection> getAuthorizationHeaders( + String method, String httpContentType, String path, String body) { if (token == null) { refreshToken(); } - return AUTH_KEYWORD + " " + token; + return Collections.singletonList(new Pair<>("Authorization", AUTH_KEYWORD + " " + token)); } private void refreshToken() { @@ -88,8 +91,7 @@ private Optional getNewToken() { Collections.singletonList("application/x-www-form-urlencoded"), Collections.singletonList(SCHEMA_KEYWORD_BASIC)); try { - HttpResponse httpResponse = - httpClient.invokeAPI(configuration.getOAuthServer(), authManagers, request); + HttpResponse httpResponse = httpClient.invokeAPI(oAuthServer, authManagers, request); BearerAuthResponse authResponse = mapper.deserialize(httpResponse, new TypeReference() {}); return Optional.ofNullable(authResponse.getAccessToken()); diff --git a/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java b/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java new file mode 100644 index 00000000..61eb96f9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java @@ -0,0 +1,90 @@ +package com.sinch.sdk.auth.adapters; + +import com.sinch.sdk.core.exceptions.ApiAuthException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.Pair; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.Instant; +import java.util.Arrays; +import java.util.Base64; +import java.util.Collection; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +public class VerificationApplicationAuthManager implements AuthManager { + + private static final String AUTH_KEYWORD = "Application"; + private static final String XTIMESTAMP_HEADER = "x-timestamp"; + private final String key; + private final byte[] secret; + + public VerificationApplicationAuthManager(String key, String base64Secret) { + this.key = key; + this.secret = Base64.getDecoder().decode(base64Secret); + } + + // FIXME: Verification OAS file claim it support "Basic" but miss the "Application" definition + public String getSchema() { + return "Basic"; + } + + @Override + public void resetToken() { + // no op + } + + @Override + public Collection> getAuthorizationHeaders( + String method, String httpContentType, String path, String body) { + + // see + // https://developers.sinch.com/docs/verification/api-reference/authentication/signed-request/ + Instant timestamp = Instant.now(); + String bodyMD5Hash = getBodyMD5Hash(body); + String stringToSign = getSignature(method, bodyMD5Hash, httpContentType, timestamp, path); + String encoded = encode(stringToSign); + String key = this.key == null ? "" : this.key; + + return Arrays.asList( + new Pair<>("Authorization", AUTH_KEYWORD + " " + key + ":" + encoded), + new Pair<>(XTIMESTAMP_HEADER, timestamp.toString())); + } + + private String getBodyMD5Hash(String body) { + + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] digest = md.digest(body.getBytes(StandardCharsets.UTF_8)); + byte[] encodedMd5ToBase64VerificationBody = Base64.getEncoder().encode(digest); + return new String(encodedMd5ToBase64VerificationBody, StandardCharsets.UTF_8); + } catch (NoSuchAlgorithmException e) { + throw new ApiAuthException(e); + } + } + + private String getSignature( + String method, String bodyMD5Hash, String httpContentType, Instant timestamp, String path) { + return String.join( + "\n", + method, + bodyMD5Hash, + httpContentType, + XTIMESTAMP_HEADER + ":" + timestamp.toString(), + path); + } + + private String encode(String stringToSign) { + try { + SecretKeySpec secretKeySpec = new SecretKeySpec(secret, "HmacSHA256"); + Mac mac = Mac.getInstance("HmacSHA256"); + mac.init(secretKeySpec); + byte[] hmacSha256 = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)); + return new String(Base64.getEncoder().encode(hmacSha256), StandardCharsets.UTF_8); + } catch (NoSuchAlgorithmException | InvalidKeyException e) { + throw new ApiAuthException(e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java new file mode 100644 index 00000000..d3aca0d0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java @@ -0,0 +1,19 @@ +package com.sinch.sdk.domains.verification; + +/** + * Verification Service + * + * @see https://developers.sinch.com/docs/verification// + * @since 1.0 + */ +public interface VerificationService { + + /** + * Verifications Service instance + * + * @return service instance for project + * @since 1.0 + */ + VerificationsService verifications(); +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java new file mode 100644 index 00000000..c5299955 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java @@ -0,0 +1,27 @@ +package com.sinch.sdk.domains.verification; + +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; + +/** + * Verifications Service + * + *

Start new verification requests and report on existing verification requests. + * + * @see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verifications/// + * @since 1.0 + */ +public interface VerificationsService { + + /** + * Start verification + * + *

This method is used by the mobile and web Verification SDKs to start a verification. It can + * also be used to request a verification from your backend, by making an request. + * + * @param parameters Parameters to be used to start verification return service instance for + * project + * @since 1.0 + */ + void start(StartVerificationRequestParameters parameters); +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java new file mode 100644 index 00000000..bf17feba --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java @@ -0,0 +1,56 @@ +package com.sinch.sdk.domains.verification.adapters; + +import com.sinch.sdk.auth.adapters.BasicAuthManager; +import com.sinch.sdk.auth.adapters.VerificationApplicationAuthManager; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.domains.verification.VerificationsService; +import com.sinch.sdk.models.Configuration; +import java.util.AbstractMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class VerificationService implements com.sinch.sdk.domains.verification.VerificationService { + + // FIXME: Verification OAS file claim it support "Basic" but miss the "Application" definition + // trick to adapt the mapping of "Basic" keyword to the dedicated "Application" auth manager + private static final String SECURITY_SCHEME_KEYWORD_VERIFICATION = "Basic"; + + private final Configuration configuration; + private final HttpClient httpClient; + private VerificationsService verifications; + private final Map authManagers; + + public VerificationService(Configuration configuration, HttpClient httpClient) { + this.configuration = configuration; + this.httpClient = httpClient; + + AuthManager authManager; + boolean useApplicationAuth = true; + if (useApplicationAuth) { + authManager = + new VerificationApplicationAuthManager( + configuration.getKeyId(), + // TODO: Currently Verification do not accept project related key/secret. TBC + // fallback to the verifications usage ones for POC + // Base64.getEncoder().encodeToString(configuration.getKeySecret().getBytes(StandardCharsets.UTF_8)) + configuration.getKeySecret()); + } else { + authManager = new BasicAuthManager(configuration); + } + authManagers = + Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_VERIFICATION, authManager)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + } + + @Override + public VerificationsService verifications() { + if (null == this.verifications) { + this.verifications = + new com.sinch.sdk.domains.verification.adapters.VerificationsService( + configuration, httpClient, authManagers); + } + return this.verifications; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java new file mode 100644 index 00000000..b7a66d54 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java @@ -0,0 +1,33 @@ +package com.sinch.sdk.domains.verification.adapters; + +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.domains.verification.adapters.api.v1.SendingAndReportingVerificationsApi; +import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.models.Configuration; +import java.util.Map; + +public class VerificationsService + implements com.sinch.sdk.domains.verification.VerificationsService { + + private SendingAndReportingVerificationsApi api; + + public VerificationsService() {} + + public VerificationsService( + Configuration configuration, HttpClient httpClient, Map authManager) { + this.api = + new SendingAndReportingVerificationsApi( + httpClient, configuration.getVerificationServer(), authManager, new HttpMapper()); + } + + private SendingAndReportingVerificationsApi getApi() { + return this.api; + } + + public void start(StartVerificationRequestParameters parameters) { + getApi().startVerification(VerificationsDtoConverter.convert(parameters)); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java new file mode 100644 index 00000000..8079a282 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.verification.adapters.converters; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.dto.v1.FlashcallOptionsDto; +import com.sinch.sdk.domains.verification.models.dto.v1.IdentityDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceFlashCallOptionsDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceIdentityDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceMethodDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationMethodDto; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; + +public class VerificationsDtoConverter { + + private static final String IDENTITY_TYPE_NUMBER = "number"; + + public static InitiateVerificationResourceDto convert(StartVerificationRequestParameters client) { + InitiateVerificationResourceDto dto = new InitiateVerificationResourceDto(); + + dto.identity(convert(client.getIdentity())) + .method(convert(client.getMethod())) + .reference(client.getReference().orElse(null)) + .custom(client.getCustom().orElse(null)); + + if (client instanceof StartVerificationFlashCallRequestParameters) { + StartVerificationFlashCallRequestParameters options = + (StartVerificationFlashCallRequestParameters) client; + dto.flashCallOptions( + options + .getDialTimeOut() + .map( + f -> + new InitiateVerificationResourceFlashCallOptionsDto( + new FlashcallOptionsDto().dialTimeout(f))) + .orElse(null)); + } + return dto; + } + + public static InitiateVerificationResourceIdentityDto convert(Identity client) { + IdentityDto dto = new IdentityDto(); + if (client instanceof NumberIdentity) { + dto.type(IDENTITY_TYPE_NUMBER).endpoint(((NumberIdentity) client).getEndpoint()); + } + return new InitiateVerificationResourceIdentityDto(dto); + } + + public static InitiateVerificationResourceMethodDto convert(VerificationMethod client) { + VerificationMethodDto dto = VerificationMethodDto.fromValue(client.value()); + return new InitiateVerificationResourceMethodDto(dto); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java new file mode 100644 index 00000000..d8d0d5e0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java @@ -0,0 +1,3 @@ +package com.sinch.sdk.domains.verification.models; + +public abstract class Identity {} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java new file mode 100644 index 00000000..2cee0877 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java @@ -0,0 +1,41 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.domains.sms.models.Group.Builder; + +public class NumberIdentity extends Identity { + private final String endpoint; + + public String getEndpoint() { + return endpoint; + } + + public NumberIdentity(String endpoint) { + this.endpoint = endpoint; + } + + @Override + public String toString() { + return "NumberIdentity{" + "endpoint='" + endpoint + '\'' + "} " + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + String endpoint; + + private Builder() {} + ; + + public Builder setEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + public NumberIdentity build() { + return new NumberIdentity(endpoint); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java new file mode 100644 index 00000000..5f317d94 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java @@ -0,0 +1,55 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * The type of the verification request authorized values + * + * @since 1.0 + */ +public class VerificationMethod extends EnumDynamic { + + /** Verification by SMS message with a PIN code */ + public static final VerificationMethod SMS = new VerificationMethod("sms"); + /** + * Verification by placing a flashcall (missed call) and detecting the incoming calling number + * (CLI). + */ + public static final VerificationMethod FLASH_CALL = new VerificationMethod("flashCall"); + /** + * Verification by placing a PSTN call to the user's phone and playing an announcement, asking the + * user to press a particular digit to verify the phone number. + */ + public static final VerificationMethod CALLOUT = new VerificationMethod("callout"); + /** + * Data verification. Verification by accessing internal infrastructure of mobile carriers to + * verify if given verification attempt was originated from device with matching phone number. + */ + public static final VerificationMethod SEAMLESS = new VerificationMethod("seamless"); + + /** */ + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + VerificationMethod.class, + VerificationMethod::new, + Arrays.asList(SMS, FLASH_CALL, CALLOUT, SEAMLESS)); + + private VerificationMethod(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static VerificationMethod from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(VerificationMethod e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java new file mode 100644 index 00000000..d851477b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java @@ -0,0 +1,53 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import java.util.Optional; + +public class StartVerificationFlashCallRequestParameters + extends StartVerificationRequestParameters { + + private final Integer dialTimeOut; + + public StartVerificationFlashCallRequestParameters( + Identity identity, + VerificationMethod method, + String reference, + String custom, + Integer dialTimeOut) { + super(identity, method, reference, custom); + this.dialTimeOut = dialTimeOut; + } + + public Optional getDialTimeOut() { + return Optional.ofNullable(dialTimeOut); + } + + @Override + public String toString() { + return "StartVerificationFlashCallRequestParameters{" + + "dialTimeOut=" + + dialTimeOut + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends StartVerificationRequestParameters.Builder { + + Integer dialTimeOut; + + public Builder setDialTimeOut(Integer dialTimeOut) { + this.dialTimeOut = dialTimeOut; + return this; + } + + public StartVerificationFlashCallRequestParameters build() { + return new StartVerificationFlashCallRequestParameters( + identity, method, reference, custom, dialTimeOut); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java new file mode 100644 index 00000000..8e2d2b96 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java @@ -0,0 +1,98 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import java.util.Objects; +import java.util.Optional; + +/** + * Base class for start verification request parameters + * + * @since 1.0 + */ +public class StartVerificationRequestParameters { + + private final Identity identity; + private final VerificationMethod method; + private final String reference; + private final String custom; + + public StartVerificationRequestParameters( + Identity identity, VerificationMethod method, String reference, String custom) { + Objects.requireNonNull(identity); + Objects.requireNonNull(method); + + this.identity = identity; + this.method = method; + this.reference = reference; + this.custom = custom; + } + + public Identity getIdentity() { + return identity; + } + + public VerificationMethod getMethod() { + return method; + } + + public Optional getReference() { + return Optional.ofNullable(reference); + } + + public Optional getCustom() { + return Optional.ofNullable(custom); + } + + @Override + public String toString() { + return "StartVerificationRequestParameters{" + + "identity=" + + identity + + ", method=" + + method + + ", reference='" + + reference + + '\'' + + ", custom='" + + custom + + '\'' + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + Identity identity; + VerificationMethod method; + String reference; + String custom; + + public Builder setIdentity(Identity identity) { + this.identity = identity; + return this; + } + + public Builder setMethod(VerificationMethod method) { + this.method = method; + return this; + } + + public Builder setReference(String reference) { + this.reference = reference; + return this; + } + + public Builder setCustom(String custom) { + this.custom = custom; + return this; + } + + public StartVerificationRequestParameters build() { + return new StartVerificationRequestParameters(identity, method, reference, custom); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/package-info.java new file mode 100644 index 00000000..bd726f72 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/package-info.java @@ -0,0 +1,6 @@ +/** + * Verification API interface + * + * @since 1.0 + */ +package com.sinch.sdk.domains.verification; diff --git a/client/src/main/com/sinch/sdk/http/HttpClientApache.java b/client/src/main/com/sinch/sdk/http/HttpClientApache.java index 3e69205d..b700635f 100644 --- a/client/src/main/com/sinch/sdk/http/HttpClientApache.java +++ b/client/src/main/com/sinch/sdk/http/HttpClientApache.java @@ -2,6 +2,7 @@ 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.HttpContentType.CONTENT_TYPE_HEADER; import static com.sinch.sdk.core.http.URLParameterUtils.encodeParametersAsString; import com.sinch.sdk.auth.adapters.BearerAuthManager; @@ -13,6 +14,7 @@ import com.sinch.sdk.core.http.HttpStatus; import com.sinch.sdk.core.http.URLParameter; import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.utils.Pair; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.util.AbstractMap; @@ -37,7 +39,6 @@ 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 CloseableHttpClient client; public HttpClientApache() { @@ -109,10 +110,10 @@ public HttpResponse invokeAPI( addBody(requestBuilder, body); - addCollectionHeader(requestBuilder, "Content-Type", contentType); + addCollectionHeader(requestBuilder, CONTENT_TYPE_HEADER, contentType); addCollectionHeader(requestBuilder, "Accept", accept); - addAuth(requestBuilder, authManagersByOasSecuritySchemes, authNames); + addAuth(requestBuilder, authManagersByOasSecuritySchemes, authNames, body); ClassicHttpRequest request = requestBuilder.build(); @@ -125,7 +126,7 @@ public HttpResponse invokeAPI( processUnauthorizedResponse(httpRequest, response, authManagersByOasSecuritySchemes); if (couldRetryRequest) { // refresh authorization - addAuth(requestBuilder, authManagersByOasSecuritySchemes, authNames); + addAuth(requestBuilder, authManagersByOasSecuritySchemes, authNames, body); request = requestBuilder.build(); response = processRequest(client, request); LOGGER.finest("connection response on retry: " + response); @@ -208,7 +209,8 @@ private void addCollectionHeader( private void addAuth( ClassicRequestBuilder requestBuilder, Map authManagersByOasSecuritySchemes, - Collection values) { + Collection values, + String body) { if (null == values || values.isEmpty() || null == authManagersByOasSecuritySchemes) { return; } @@ -216,8 +218,17 @@ private void addAuth( for (String entry : values) { if (authManagersByOasSecuritySchemes.containsKey(entry)) { AuthManager authManager = authManagersByOasSecuritySchemes.get(entry); - requestBuilder.setHeader( - AUTHORIZATION_HEADER_KEYWORD, authManager.getAuthorizationHeaderValue()); + Collection> headers = + authManager.getAuthorizationHeaders( + requestBuilder.getMethod(), + null != requestBuilder.getFirstHeader(CONTENT_TYPE_HEADER) + ? requestBuilder.getFirstHeader(CONTENT_TYPE_HEADER).getValue() + : null, + requestBuilder.getPath(), + body); + headers.stream() + .iterator() + .forEachRemaining(f -> requestBuilder.setHeader(f.getLeft(), f.getRight())); return; } else { LOGGER.info("Ignore unknown authentication value: '" + entry + "'"); diff --git a/client/src/main/com/sinch/sdk/models/Configuration.java b/client/src/main/com/sinch/sdk/models/Configuration.java index dae0b99b..35f8b777 100644 --- a/client/src/main/com/sinch/sdk/models/Configuration.java +++ b/client/src/main/com/sinch/sdk/models/Configuration.java @@ -12,6 +12,7 @@ public class Configuration { private final String numbersUrl; private final SMSRegion smsRegion; private final String smsUrl; + private final String verificationUrl; private Configuration( String keyId, @@ -20,7 +21,8 @@ private Configuration( String oauthUrl, String numbersUrl, SMSRegion smsRegion, - String smsUrl) { + String smsUrl, + String verificationUrl) { this.keyId = keyId; this.keySecret = keySecret; this.projectId = projectId; @@ -28,6 +30,7 @@ private Configuration( this.numbersUrl = numbersUrl; this.smsRegion = null == smsRegion ? SMSRegion.US : smsRegion; this.smsUrl = smsUrl; + this.verificationUrl = verificationUrl; } @Override @@ -49,6 +52,9 @@ public String toString() { + ", smsUrl='" + smsUrl + '\'' + + ", verificationUrl='" + + verificationUrl + + '\'' + "}"; } @@ -157,6 +163,25 @@ public String getSmsUrl() { return smsUrl; } + /** + * Verification Server Configuration + * + * @return Verification Server configuration to be used + * @since 1.0 + */ + public ServerConfiguration getVerificationServer() { + return new ServerConfiguration(getVerificationUrl()); + } + /** + * Verification URL + * + * @return Verification Server URL + * @since 1.0 + */ + public String getVerificationUrl() { + return verificationUrl; + } + public static Builder builder() { return new Builder(); } @@ -175,6 +200,7 @@ public static class Builder { private String numbersUrl; private SMSRegion smsRegion; private String smsUrl; + private String verificationUrl; protected Builder() {} @@ -192,6 +218,7 @@ protected Builder(Configuration configuration) { this.numbersUrl = configuration.getNumbersUrl(); this.smsRegion = configuration.getSmsRegion(); this.smsUrl = configuration.getSmsUrl(); + this.verificationUrl = configuration.getVerificationUrl(); } /** @@ -202,7 +229,7 @@ protected Builder(Configuration configuration) { */ public Configuration build() { return new Configuration( - keyId, keySecret, projectId, oauthUrl, numbersUrl, smsRegion, smsUrl); + keyId, keySecret, projectId, oauthUrl, numbersUrl, smsRegion, smsUrl, verificationUrl); } /** @@ -288,5 +315,17 @@ public Builder setSmsUrl(String smsUrl) { this.smsUrl = smsUrl; return this; } + + /** + * Set Verification API URL + * + * @param verificationUrl Verification API URL + * @return Current builder + * @since 1.0 + */ + public Builder setVerificationUrl(String verificationUrl) { + this.verificationUrl = verificationUrl; + return this; + } } } 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 index c768946e..7d71c2f3 100644 --- a/client/src/test/java/com/sinch/sdk/auth/adapters/BasicAuthManagerTest.java +++ b/client/src/test/java/com/sinch/sdk/auth/adapters/BasicAuthManagerTest.java @@ -3,9 +3,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.Pair; import com.sinch.sdk.models.Configuration; import java.nio.charset.StandardCharsets; import java.util.Base64; +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; class BasicAuthManagerTest { @@ -25,14 +29,21 @@ void getSchema() { } @Test - void getAuthorizationHeaderValue() { - - String expectedToken = - "Basic " - + Base64.getEncoder() - .encodeToString( - (configuration.getKeyId() + ":" + configuration.getKeySecret()) - .getBytes(StandardCharsets.UTF_8)); - assertEquals(expectedToken, authManager.getAuthorizationHeaderValue()); + void getAuthorizationHeaders() { + + Collection> expectedHeaders = + Collections.singletonList( + new Pair<>( + "Authorization", + "Basic " + + Base64.getEncoder() + .encodeToString( + (configuration.getKeyId() + ":" + configuration.getKeySecret()) + .getBytes(StandardCharsets.UTF_8)))); + + Collection> headers = + authManager.getAuthorizationHeaders(null, null, null, null); + + Assertions.assertThat(headers).usingRecursiveComparison().isEqualTo(expectedHeaders); } } 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 index 4045e23a..12eb1b80 100644 --- a/client/src/test/java/com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java +++ b/client/src/test/java/com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java @@ -15,8 +15,12 @@ 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.core.utils.Pair; import com.sinch.sdk.models.Configuration; import java.nio.charset.StandardCharsets; +import java.util.Collection; +import java.util.Collections; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; @@ -56,17 +60,19 @@ void getSchema() { } @Test - void getAuthorizationHeaderValue() { - String expectedToken = "Bearer token value"; + void getAuthorizationHeaders() { + Collection> expectedHeaders = + Collections.singletonList(new Pair<>("Authorization", "Bearer token value")); when(httpClient.invokeAPI(any(), any(), any())) .thenReturn( new HttpResponse( 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); - String token = authManager.getAuthorizationHeaderValue(); + Collection> headers = + authManager.getAuthorizationHeaders(null, null, null, null); - assertEquals(expectedToken, token); + Assertions.assertThat(headers).usingRecursiveComparison().isEqualTo(expectedHeaders); } @Test @@ -77,7 +83,7 @@ void callToOAuthServer() { new HttpResponse( 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); - authManager.getAuthorizationHeaderValue(); + authManager.getAuthorizationHeaders(null, null, null, null); ServerConfiguration serverConfigurationValue = serverConfigurationCaptor.getValue(); assertEquals("OAuth url", serverConfigurationValue.getUrl()); @@ -99,7 +105,7 @@ void resetToken() { 200, "foo message", null, jsonResponse.getBytes(StandardCharsets.UTF_8))); authManager.resetToken(); - authManager.getAuthorizationHeaderValue(); + authManager.getAuthorizationHeaders(null, null, null, null); verify(httpClient, times(1)).invokeAPI(any(), any(), any()); } @@ -107,7 +113,9 @@ void resetToken() { @Test void noInfiniteLoopAndException() { ApiAuthException exception = - assertThrows(ApiAuthException.class, authManager::getAuthorizationHeaderValue); + assertThrows( + ApiAuthException.class, + () -> authManager.getAuthorizationHeaders(null, null, null, null)); assertEquals(exception.getCode(), 401); } } diff --git a/client/src/test/java/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManagerTest.java b/client/src/test/java/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManagerTest.java new file mode 100644 index 00000000..49e62adb --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManagerTest.java @@ -0,0 +1,58 @@ +package com.sinch.sdk.auth.adapters; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpContentType; +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.core.utils.Pair; +import java.nio.charset.StandardCharsets; +import java.time.Instant; +import java.util.Arrays; +import java.util.Base64; +import java.util.Collection; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; +import org.mockito.Mockito; + +class VerificationApplicationAuthManagerTest { + + static final String KEY = "my-key-id"; + static final String SECRET = + Base64.getEncoder().encodeToString("my-key-secret".getBytes(StandardCharsets.UTF_8)); + + AuthManager authManager = new VerificationApplicationAuthManager(KEY, SECRET); + + @Test + void getSchema() { + assertEquals("Basic", authManager.getSchema()); + } + + @Test + void getAuthorizationHeaderValue() { + String method = HttpMethod.POST.name(); + String contentType = HttpContentType.APPLICATION_JSON + "; charset=UTF-8"; + String path = "/path/pathParamValue"; + String body = + "{\"identity\":{\"type\":\"number\",\"endpoint\":\"+33444555666\"},\"method\":\"sms\"}"; + + Instant timestamp = Instant.parse("2023-11-22T09:10:11.999Z"); + + try (MockedStatic utilities = Mockito.mockStatic(Instant.class)) { + utilities.when(Instant::now).thenReturn(timestamp); + + Collection> expectedHeaders = + Arrays.asList( + new Pair<>( + "Authorization", + "Application my-key-id:QP3OzQZVzRZAEev6DBLvJkgpiqyZPuXYsc7oyjUV0K8="), + new Pair<>("x-timestamp", timestamp.toString())); + + Collection> headers = + authManager.getAuthorizationHeaders(method, contentType, path, body); + + Assertions.assertThat(headers).usingRecursiveComparison().isEqualTo(expectedHeaders); + } + } +} diff --git a/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java b/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java index 645f89bb..c437e0fc 100644 --- a/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java +++ b/core/src/main/com/sinch/sdk/core/exceptions/ApiExceptionBuilder.java @@ -12,13 +12,18 @@ public static ApiException build(String message, int code) { public static ApiException build(String message, int code, Map mappedResponse) { // Hardcoded Numbers API errors like format parsing - Optional numbersException = getExceptionFromNumbersError(mappedResponse); - if (numbersException.isPresent()) { - return numbersException.get(); + Optional exception = getExceptionFromNumbersError(mappedResponse); + if (exception.isPresent()) { + return exception.get(); } - Optional smsException = getExceptionFromSmsError(mappedResponse); - return smsException.orElseGet(() -> new ApiException(message, code)); + exception = getExceptionFromSmsError(mappedResponse); + if (exception.isPresent()) { + return exception.get(); + } + + exception = getExceptionFromVerificationError(mappedResponse); + return exception.orElseGet(() -> new ApiException(message, code)); } private static Optional getExceptionFromNumbersError(Map mappedResponse) { @@ -75,4 +80,32 @@ private static Optional getExceptionFromSmsError(Map mappedR return Optional.of(new ApiException(String.format("%s: %s", code, text))); } + + private static Optional getExceptionFromVerificationError( + Map mappedResponse) { + + // excepted Verification API errors have following form + // "errorCode": int, + // "message": string, + // "reference": string + + if (null == mappedResponse) { + return Optional.empty(); + } + + Integer codeValue = null; + if (mappedResponse.containsKey("errorCode")) { + codeValue = Integer.valueOf(String.valueOf(mappedResponse.get("errorCode"))); + } + String messageValue = String.valueOf(mappedResponse.get("message")); + String referenceValue = String.valueOf(mappedResponse.get("reference")); + + if (null == codeValue || null == messageValue || null == referenceValue) { + return Optional.empty(); + } + + return Optional.of( + new ApiException( + String.format("%s (reference=%s)", messageValue, referenceValue), codeValue)); + } } diff --git a/core/src/main/com/sinch/sdk/core/http/AuthManager.java b/core/src/main/com/sinch/sdk/core/http/AuthManager.java index 20a73243..c376d040 100644 --- a/core/src/main/com/sinch/sdk/core/http/AuthManager.java +++ b/core/src/main/com/sinch/sdk/core/http/AuthManager.java @@ -1,13 +1,17 @@ package com.sinch.sdk.core.http; +import com.sinch.sdk.core.utils.Pair; +import java.util.Collection; + public interface AuthManager { - final String SCHEMA_KEYWORD_BEARER = "Bearer"; - final String SCHEMA_KEYWORD_BASIC = "Basic"; + String SCHEMA_KEYWORD_BEARER = "Bearer"; + String SCHEMA_KEYWORD_BASIC = "Basic"; String getSchema(); void resetToken(); - String getAuthorizationHeaderValue(); + Collection> getAuthorizationHeaders( + String method, String httpContentType, String path, String body); } diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java new file mode 100644 index 00000000..3324f130 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java @@ -0,0 +1,40 @@ +package com.sinch.sample.verification.verifications; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; +import java.io.IOException; +import java.util.logging.Logger; + +public class Start extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(Start.class.getName()); + + public Start() throws IOException {} + + public static void main(String[] args) { + try { + new Start().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + LOGGER.info("Start verification for : " + phoneNumber); + + client + .verification() + .verifications() + .start( + StartVerificationFlashCallRequestParameters.builder() + .setIdentity(NumberIdentity.builder().setEndpoint("+33444555666").build()) + .setMethod(VerificationMethod.SMS) + .build()); + + // LOGGER.info("Response :" + response); + } +} From 08cae0de43dbb5f6e9e12137972e82db4a117558 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Wed, 22 Nov 2023 16:35:31 +0100 Subject: [PATCH 2/6] feat: initial commit for verification API generated files --- .../api/v1/QueryVerificationsApi.java | 283 +++++++++ .../SendingAndReportingVerificationsApi.java | 316 ++++++++++ .../AutoInitiateVerificationResponseDto.java | 98 +++ ...alloutInitiateVerificationResponseDto.java | 158 +++++ .../models/dto/v1/CalloutOptionsDto.java | 114 ++++ .../dto/v1/CalloutOptionsSpeechDto.java | 206 +++++++ .../models/dto/v1/CalloutSpeechDto.java | 201 ++++++ .../CalloutVerificationReportRequestDto.java | 88 +++ ...shCallInitiateVerificationResponseDto.java | 309 ++++++++++ .../models/dto/v1/FlashcallOptionsDto.java | 175 ++++++ ...FlashcallVerificationReportRequestDto.java | 88 +++ .../models/dto/v1/IdentityDto.java | 114 ++++ ...VerificationResourceCalloutOptionsDto.java | 217 +++++++ .../v1/InitiateVerificationResourceDto.java | 389 ++++++++++++ ...rificationResourceFlashCallOptionsDto.java | 218 +++++++ ...itiateVerificationResourceIdentityDto.java | 209 +++++++ ...itiateVerificationResourceMetadataDto.java | 218 +++++++ ...InitiateVerificationResourceMethodDto.java | 212 +++++++ ...erificationResourceSeamlessOptionsDto.java | 217 +++++++ ...iateVerificationResourceSmsOptionsDto.java | 217 +++++++ ...erificationResourceWhatsappOptionsDto.java | 217 +++++++ .../InitiateVerificationResponseAutoDto.java | 219 +++++++ ...nitiateVerificationResponseCalloutDto.java | 227 +++++++ .../v1/InitiateVerificationResponseDto.java | 424 +++++++++++++ ...tiateVerificationResponseFlashCallDto.java | 228 +++++++ ...itiateVerificationResponseMaxPriceDto.java | 214 +++++++ ...itiateVerificationResponseSeamlessDto.java | 227 +++++++ .../InitiateVerificationResponseSmsDto.java | 217 +++++++ ...itiateVerificationResponseWhatsappDto.java | 227 +++++++ .../verification/models/dto/v1/MoneyDto.java | 145 +++++ ...amlessInitiateVerificationResponseDto.java | 119 ++++ .../models/dto/v1/SeamlessOptionsDto.java | 87 +++ .../models/dto/v1/ServiceReplyDto.java | 145 +++++ .../models/dto/v1/SimSwapResourceDto.java | 87 +++ .../models/dto/v1/SimSwapResponseDto.java | 146 +++++ .../SmsInitiateVerificationResponseDto.java | 243 ++++++++ .../models/dto/v1/SmsOptionsDto.java | 231 +++++++ .../v1/SmsVerificationReportRequestDto.java | 118 ++++ .../v1/VerificationMetadataCellularDto.java | 118 ++++ .../dto/v1/VerificationMetadataDeviceDto.java | 211 +++++++ .../dto/v1/VerificationMetadataDto.java | 583 ++++++++++++++++++ ...icationMetadataNetworkInfoCellularDto.java | 222 +++++++ ...erificationMetadataNetworkInfoDataDto.java | 227 +++++++ .../VerificationMetadataNetworkInfoDto.java | 217 +++++++ .../v1/VerificationMetadataOperatorDto.java | 214 +++++++ .../VerificationMetadataPermissionsDto.java | 217 +++++++ ...tionMetadataSimCardInfoCollection1Dto.java | 224 +++++++ ...ationMetadataSimCardInfoCollectionDto.java | 177 ++++++ .../VerificationMetadataSimCardInfoDto.java | 118 ++++ .../VerificationMetadataSimCardsInfoDto.java | 227 +++++++ .../dto/v1/VerificationMetadataSimDto.java | 208 +++++++ .../models/dto/v1/VerificationMethodDto.java | 59 ++ .../v1/VerificationPriceInformationDto.java | 150 +++++ ...onPriceInformationTerminationPriceDto.java | 216 +++++++ ...nPriceInformationVerificationPriceDto.java | 211 +++++++ ...cationReportRequestResourceCalloutDto.java | 225 +++++++ .../VerificationReportRequestResourceDto.java | 262 ++++++++ ...tionReportRequestResourceFlashcallDto.java | 226 +++++++ ...rificationReportRequestResourceSmsDto.java | 221 +++++++ ...ationReportRequestResourceWhatsappDto.java | 225 +++++++ .../dto/v1/VerificationResourceLinkDto.java | 145 +++++ .../dto/v1/VerificationResponseDto.java | 411 ++++++++++++ .../v1/VerificationResponseIdentityDto.java | 207 +++++++ .../dto/v1/VerificationResponsePriceDto.java | 212 +++++++ ...atsappInitiateVerificationResponseDto.java | 186 ++++++ .../models/dto/v1/WhatsappOptionsDto.java | 145 +++++ .../WhatsappVerificationReportRequestDto.java | 88 +++ 67 files changed, 13720 insertions(+) create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/AutoInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsSpeechDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutSpeechDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutVerificationReportRequestDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashCallInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallVerificationReportRequestDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/IdentityDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceCalloutOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceFlashCallOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceIdentityDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMetadataDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMethodDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSeamlessOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSmsOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceWhatsappOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseAutoDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseCalloutDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseFlashCallDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseMaxPriceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSeamlessDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSmsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseWhatsappDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/MoneyDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/ServiceReplyDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResourceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsVerificationReportRequestDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataCellularDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDeviceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoCellularDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDataDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataOperatorDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataPermissionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollection1Dto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollectionDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardsInfoDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMethodDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationTerminationPriceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationVerificationPriceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceCalloutDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceFlashcallDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceSmsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceWhatsappDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResourceLinkDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseIdentityDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponsePriceDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappInitiateVerificationResponseDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappOptionsDto.java create mode 100644 openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappVerificationReportRequestDto.java diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java new file mode 100644 index 00000000..76209924 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java @@ -0,0 +1,283 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.core.http.HttpRequest; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.HttpStatus; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResponseDto; +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 QueryVerificationsApi { + + private static final Logger LOGGER = Logger.getLogger(QueryVerificationsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private Map authManagersByOasSecuritySchemes; + private HttpMapper mapper; + + public QueryVerificationsApi( + HttpClient httpClient, + ServerConfiguration serverConfiguration, + Map authManagersByOasSecuritySchemes, + HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.authManagersByOasSecuritySchemes = authManagersByOasSecuritySchemes; + this.mapper = mapper; + } + + /** + * Get verification by Id Queries the verification result by sending the verification Id. With + * this query you can get the result of a verification. + * + * @param id (required) + * @return VerificationResponseDto + * @throws ApiException if fails to make API call + */ + public VerificationResponseDto verificationStatusById(String id) throws ApiException { + + LOGGER.finest("[verificationStatusById] " + "id: " + id); + + HttpRequest httpRequest = verificationStatusByIdRequestBuilder(id); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest verificationStatusByIdRequestBuilder(String id) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, "Missing the required parameter 'id' when calling verificationStatusById"); + } + + String localVarPath = + "/verification/v1/verifications/id/{id}" + .replaceAll( + "\\{" + "id" + "\\}", URLParameterUtils.encodeParameterValue(id.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("Basic"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Get verification by Identity Queries the verification result by sending the verification + * Identity and its method. With this query you can get the result of a verification. + * + * @param type Type of identity, e.g. 'number', 'email' etc. (required) + * @param endpoint Value of identity in format defined by its type. (required) + * @param method (required) + * @return VerificationResponseDto + * @throws ApiException if fails to make API call + */ + public VerificationResponseDto verificationStatusByIdentity( + String type, String endpoint, String method) throws ApiException { + + LOGGER.finest( + "[verificationStatusByIdentity] " + + "type: " + + type + + ", " + + "endpoint: " + + endpoint + + ", " + + "method: " + + method); + + HttpRequest httpRequest = verificationStatusByIdentityRequestBuilder(type, endpoint, method); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest verificationStatusByIdentityRequestBuilder( + String type, String endpoint, String method) throws ApiException { + // verify the required parameter 'type' is set + if (type == null) { + throw new ApiException( + 400, "Missing the required parameter 'type' when calling verificationStatusByIdentity"); + } + // verify the required parameter 'endpoint' is set + if (endpoint == null) { + throw new ApiException( + 400, + "Missing the required parameter 'endpoint' when calling verificationStatusByIdentity"); + } + // verify the required parameter 'method' is set + if (method == null) { + throw new ApiException( + 400, "Missing the required parameter 'method' when calling verificationStatusByIdentity"); + } + + String localVarPath = + "/verification/v1/verifications/{method}/{type}/{endpoint}" + .replaceAll( + "\\{" + "type" + "\\}", URLParameterUtils.encodeParameterValue(type.toString())) + .replaceAll( + "\\{" + "endpoint" + "\\}", + URLParameterUtils.encodeParameterValue(endpoint.toString())) + .replaceAll( + "\\{" + "method" + "\\}", + URLParameterUtils.encodeParameterValue(method.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("Basic"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Get verification by Reference Queries the verification result by sending the verification + * Reference. With this query you can get the result of a verification. + * + * @param reference (required) + * @return VerificationResponseDto + * @throws ApiException if fails to make API call + */ + public VerificationResponseDto verificationStatusByReference(String reference) + throws ApiException { + + LOGGER.finest("[verificationStatusByReference] " + "reference: " + reference); + + HttpRequest httpRequest = verificationStatusByReferenceRequestBuilder(reference); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest verificationStatusByReferenceRequestBuilder(String reference) + throws ApiException { + // verify the required parameter 'reference' is set + if (reference == null) { + throw new ApiException( + 400, + "Missing the required parameter 'reference' when calling verificationStatusByReference"); + } + + String localVarPath = + "/verification/v1/verifications/reference/{reference}" + .replaceAll( + "\\{" + "reference" + "\\}", + URLParameterUtils.encodeParameterValue(reference.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("Basic"); + final String serializedBody = null; + + return new HttpRequest( + localVarPath, + HttpMethod.GET, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java new file mode 100644 index 00000000..bc2019d5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java @@ -0,0 +1,316 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.core.http.HttpRequest; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.HttpStatus; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameterUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResponseDto; +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 SendingAndReportingVerificationsApi { + + private static final Logger LOGGER = + Logger.getLogger(SendingAndReportingVerificationsApi.class.getName()); + private HttpClient httpClient; + private ServerConfiguration serverConfiguration; + private Map authManagersByOasSecuritySchemes; + private HttpMapper mapper; + + public SendingAndReportingVerificationsApi( + HttpClient httpClient, + ServerConfiguration serverConfiguration, + Map authManagersByOasSecuritySchemes, + HttpMapper mapper) { + this.httpClient = httpClient; + this.serverConfiguration = serverConfiguration; + this.authManagersByOasSecuritySchemes = authManagersByOasSecuritySchemes; + this.mapper = mapper; + } + + /** + * Verify verification code by Id Used to report OTP code. + * + * @param id (required) + * @param verificationReportRequestResourceDto (required) + * @return VerificationResponseDto + * @throws ApiException if fails to make API call + */ + public VerificationResponseDto reportVerificationById( + String id, VerificationReportRequestResourceDto verificationReportRequestResourceDto) + throws ApiException { + + LOGGER.finest( + "[reportVerificationById] " + + "id: " + + id + + ", " + + "verificationReportRequestResourceDto: " + + verificationReportRequestResourceDto); + + HttpRequest httpRequest = + reportVerificationByIdRequestBuilder(id, verificationReportRequestResourceDto); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest reportVerificationByIdRequestBuilder( + String id, VerificationReportRequestResourceDto verificationReportRequestResourceDto) + throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException( + 400, "Missing the required parameter 'id' when calling reportVerificationById"); + } + // verify the required parameter 'verificationReportRequestResourceDto' is set + if (verificationReportRequestResourceDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'verificationReportRequestResourceDto' when calling" + + " reportVerificationById"); + } + + String localVarPath = + "/verification/v1/verifications/id/{id}" + .replaceAll( + "\\{" + "id" + "\\}", URLParameterUtils.encodeParameterValue(id.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("Basic"); + final String serializedBody = + mapper.serialize(localVarContentTypes, verificationReportRequestResourceDto); + + return new HttpRequest( + localVarPath, + HttpMethod.PUT, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Verify verification code by Identity Used to report OTP code. + * + * @param type Type of identity, e.g. 'number', 'email' etc. (required) + * @param endpoint Value of identity in format defined by its type. (required) + * @param verificationReportRequestResourceDto (required) + * @return VerificationResponseDto + * @throws ApiException if fails to make API call + */ + public VerificationResponseDto reportVerificationByIdentity( + String type, + String endpoint, + VerificationReportRequestResourceDto verificationReportRequestResourceDto) + throws ApiException { + + LOGGER.finest( + "[reportVerificationByIdentity] " + + "type: " + + type + + ", " + + "endpoint: " + + endpoint + + ", " + + "verificationReportRequestResourceDto: " + + verificationReportRequestResourceDto); + + HttpRequest httpRequest = + reportVerificationByIdentityRequestBuilder( + type, endpoint, verificationReportRequestResourceDto); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest reportVerificationByIdentityRequestBuilder( + String type, + String endpoint, + VerificationReportRequestResourceDto verificationReportRequestResourceDto) + throws ApiException { + // verify the required parameter 'type' is set + if (type == null) { + throw new ApiException( + 400, "Missing the required parameter 'type' when calling reportVerificationByIdentity"); + } + // verify the required parameter 'endpoint' is set + if (endpoint == null) { + throw new ApiException( + 400, + "Missing the required parameter 'endpoint' when calling reportVerificationByIdentity"); + } + // verify the required parameter 'verificationReportRequestResourceDto' is set + if (verificationReportRequestResourceDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'verificationReportRequestResourceDto' when calling" + + " reportVerificationByIdentity"); + } + + String localVarPath = + "/verification/v1/verifications/{type}/{endpoint}" + .replaceAll( + "\\{" + "type" + "\\}", URLParameterUtils.encodeParameterValue(type.toString())) + .replaceAll( + "\\{" + "endpoint" + "\\}", + URLParameterUtils.encodeParameterValue(endpoint.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("Basic"); + final String serializedBody = + mapper.serialize(localVarContentTypes, verificationReportRequestResourceDto); + + return new HttpRequest( + localVarPath, + HttpMethod.PUT, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } + /** + * Start verification This method is used by the mobile and web Verification SDKs to start a + * verification. It can also be used to request a verification from your backend, by making an + * request. + * + * @param initiateVerificationResourceDto (required) + * @return InitiateVerificationResponseDto + * @throws ApiException if fails to make API call + */ + public InitiateVerificationResponseDto startVerification( + InitiateVerificationResourceDto initiateVerificationResourceDto) throws ApiException { + + LOGGER.finest( + "[startVerification] " + + "initiateVerificationResourceDto: " + + initiateVerificationResourceDto); + + HttpRequest httpRequest = startVerificationRequestBuilder(initiateVerificationResourceDto); + HttpResponse response = + httpClient.invokeAPI( + this.serverConfiguration, this.authManagersByOasSecuritySchemes, httpRequest); + + if (HttpStatus.isSuccessfulStatus(response.getCode())) { + TypeReference localVarReturnType = + new TypeReference() {}; + return mapper.deserialize(response, localVarReturnType); + } + // fallback to default errors handling: + // all error cases definition are not required from specs: will try some "hardcoded" content + // parsing + throw ApiExceptionBuilder.build( + response.getMessage(), + response.getCode(), + mapper.deserialize(response, new TypeReference>() {})); + } + + private HttpRequest startVerificationRequestBuilder( + InitiateVerificationResourceDto initiateVerificationResourceDto) throws ApiException { + // verify the required parameter 'initiateVerificationResourceDto' is set + if (initiateVerificationResourceDto == null) { + throw new ApiException( + 400, + "Missing the required parameter 'initiateVerificationResourceDto' when calling" + + " startVerification"); + } + + String localVarPath = "/verification/v1/verifications"; + + List localVarQueryParams = new ArrayList<>(); + + Map localVarHeaderParams = new HashMap<>(); + + final Collection localVarAccepts = Arrays.asList("application/json"); + + final Collection localVarContentTypes = + Arrays.asList("application/json; charset=UTF-8"); + + final Collection localVarAuthNames = Arrays.asList("Basic"); + final String serializedBody = + mapper.serialize(localVarContentTypes, initiateVerificationResourceDto); + + return new HttpRequest( + localVarPath, + HttpMethod.POST, + localVarQueryParams, + serializedBody, + localVarHeaderParams, + localVarAccepts, + localVarContentTypes, + localVarAuthNames); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/AutoInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/AutoInitiateVerificationResponseDto.java new file mode 100644 index 00000000..105e21c5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/AutoInitiateVerificationResponseDto.java @@ -0,0 +1,98 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** AutoInitiateVerificationResponseDto */ +@JsonPropertyOrder({AutoInitiateVerificationResponseDto.JSON_PROPERTY_METHODS_ORDER}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class AutoInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_METHODS_ORDER = "methodsOrder"; + private List methodsOrder; + + public AutoInitiateVerificationResponseDto() {} + + public AutoInitiateVerificationResponseDto methodsOrder(List methodsOrder) { + this.methodsOrder = methodsOrder; + return this; + } + + public AutoInitiateVerificationResponseDto addMethodsOrderItem(String methodsOrderItem) { + if (this.methodsOrder == null) { + this.methodsOrder = new ArrayList<>(); + } + this.methodsOrder.add(methodsOrderItem); + return this; + } + + /** + * Get methodsOrder + * + * @return methodsOrder + */ + @JsonProperty(JSON_PROPERTY_METHODS_ORDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getMethodsOrder() { + return methodsOrder; + } + + @JsonProperty(JSON_PROPERTY_METHODS_ORDER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethodsOrder(List methodsOrder) { + this.methodsOrder = methodsOrder; + } + + /** Return true if this AutoInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AutoInitiateVerificationResponseDto autoInitiateVerificationResponse = + (AutoInitiateVerificationResponseDto) o; + return Objects.equals(this.methodsOrder, autoInitiateVerificationResponse.methodsOrder); + } + + @Override + public int hashCode() { + return Objects.hash(methodsOrder); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AutoInitiateVerificationResponseDto {\n"); + sb.append(" methodsOrder: ").append(toIndentedString(methodsOrder)).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/verification/models/dto/v1/CalloutInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutInitiateVerificationResponseDto.java new file mode 100644 index 00000000..03064d5d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutInitiateVerificationResponseDto.java @@ -0,0 +1,158 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** CalloutInitiateVerificationResponseDto */ +@JsonPropertyOrder({ + CalloutInitiateVerificationResponseDto.JSON_PROPERTY_SUB_VERIFICATION_ID, + CalloutInitiateVerificationResponseDto.JSON_PROPERTY_CODE, + CalloutInitiateVerificationResponseDto.JSON_PROPERTY_LINKS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CalloutInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_SUB_VERIFICATION_ID = "subVerificationId"; + private String subVerificationId; + + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_LINKS = "_links"; + private List links; + + public CalloutInitiateVerificationResponseDto() {} + + public CalloutInitiateVerificationResponseDto subVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + return this; + } + + /** + * Get subVerificationId + * + * @return subVerificationId + */ + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSubVerificationId() { + return subVerificationId; + } + + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + } + + public CalloutInitiateVerificationResponseDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 CalloutInitiateVerificationResponseDto links(List links) { + this.links = links; + return this; + } + + public CalloutInitiateVerificationResponseDto addLinksItem( + VerificationResourceLinkDto linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * + * @return links + */ + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLinks(List links) { + this.links = links; + } + + /** Return true if this CalloutInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalloutInitiateVerificationResponseDto calloutInitiateVerificationResponse = + (CalloutInitiateVerificationResponseDto) o; + return Objects.equals( + this.subVerificationId, calloutInitiateVerificationResponse.subVerificationId) + && Objects.equals(this.code, calloutInitiateVerificationResponse.code) + && Objects.equals(this.links, calloutInitiateVerificationResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(subVerificationId, code, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalloutInitiateVerificationResponseDto {\n"); + sb.append(" subVerificationId: ").append(toIndentedString(subVerificationId)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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/verification/models/dto/v1/CalloutOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsDto.java new file mode 100644 index 00000000..b9481e17 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsDto.java @@ -0,0 +1,114 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** CalloutOptionsDto */ +@JsonPropertyOrder({CalloutOptionsDto.JSON_PROPERTY_CODE, CalloutOptionsDto.JSON_PROPERTY_SPEECH}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CalloutOptionsDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_SPEECH = "speech"; + private CalloutOptionsSpeechDto speech; + + public CalloutOptionsDto() {} + + public CalloutOptionsDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 CalloutOptionsDto speech(CalloutOptionsSpeechDto speech) { + this.speech = speech; + return this; + } + + /** + * Get speech + * + * @return speech + */ + @JsonProperty(JSON_PROPERTY_SPEECH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public CalloutOptionsSpeechDto getSpeech() { + return speech; + } + + @JsonProperty(JSON_PROPERTY_SPEECH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSpeech(CalloutOptionsSpeechDto speech) { + this.speech = speech; + } + + /** Return true if this CalloutOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalloutOptionsDto calloutOptions = (CalloutOptionsDto) o; + return Objects.equals(this.code, calloutOptions.code) + && Objects.equals(this.speech, calloutOptions.speech); + } + + @Override + public int hashCode() { + return Objects.hash(code, speech); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalloutOptionsDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" speech: ").append(toIndentedString(speech)).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/verification/models/dto/v1/CalloutOptionsSpeechDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsSpeechDto.java new file mode 100644 index 00000000..3b013e04 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutOptionsSpeechDto.java @@ -0,0 +1,206 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = CalloutOptionsSpeechDto.CalloutOptionsSpeechDtoDeserializer.class) +@JsonSerialize(using = CalloutOptionsSpeechDto.CalloutOptionsSpeechDtoSerializer.class) +public class CalloutOptionsSpeechDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CalloutOptionsSpeechDto.class.getName()); + + public static class CalloutOptionsSpeechDtoSerializer + extends StdSerializer { + public CalloutOptionsSpeechDtoSerializer(Class t) { + super(t); + } + + public CalloutOptionsSpeechDtoSerializer() { + this(null); + } + + @Override + public void serialize( + CalloutOptionsSpeechDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CalloutOptionsSpeechDtoDeserializer + extends StdDeserializer { + public CalloutOptionsSpeechDtoDeserializer() { + this(CalloutOptionsSpeechDto.class); + } + + public CalloutOptionsSpeechDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public CalloutOptionsSpeechDto 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 CalloutSpeechDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CalloutSpeechDto.class.equals(Integer.class) + || CalloutSpeechDto.class.equals(Long.class) + || CalloutSpeechDto.class.equals(Float.class) + || CalloutSpeechDto.class.equals(Double.class) + || CalloutSpeechDto.class.equals(Boolean.class) + || CalloutSpeechDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CalloutSpeechDto.class.equals(Integer.class) + || CalloutSpeechDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CalloutSpeechDto.class.equals(Float.class) + || CalloutSpeechDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (CalloutSpeechDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CalloutSpeechDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(CalloutSpeechDto.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 'CalloutSpeechDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CalloutSpeechDto'", e); + } + + if (match == 1) { + CalloutOptionsSpeechDto ret = new CalloutOptionsSpeechDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for CalloutOptionsSpeechDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public CalloutOptionsSpeechDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public CalloutOptionsSpeechDto() { + super("oneOf", Boolean.TRUE); + } + + public CalloutOptionsSpeechDto(CalloutSpeechDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("CalloutSpeechDto", CalloutSpeechDto.class); + JSONNavigator.registerDescendants( + CalloutOptionsSpeechDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return CalloutOptionsSpeechDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: CalloutSpeechDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(CalloutSpeechDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CalloutSpeechDto"); + } + + /** + * Get the actual instance, which can be the following: CalloutSpeechDto + * + * @return The actual instance (CalloutSpeechDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CalloutSpeechDto`. If the actual instance is not + * `CalloutSpeechDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `CalloutSpeechDto` + * @throws ClassCastException if the instance is not `CalloutSpeechDto` + */ + public CalloutSpeechDto getCalloutSpeechDto() throws ClassCastException { + return (CalloutSpeechDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutSpeechDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutSpeechDto.java new file mode 100644 index 00000000..c5c1f9a9 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutSpeechDto.java @@ -0,0 +1,201 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** CalloutSpeechDto */ +@JsonPropertyOrder({ + CalloutSpeechDto.JSON_PROPERTY_GREETING, + CalloutSpeechDto.JSON_PROPERTY_LOCALE, + CalloutSpeechDto.JSON_PROPERTY_CODE_PROMPT, + CalloutSpeechDto.JSON_PROPERTY_SPEED, + CalloutSpeechDto.JSON_PROPERTY_SSML_TEMPLATE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CalloutSpeechDto { + public static final String JSON_PROPERTY_GREETING = "greeting"; + private String greeting; + + public static final String JSON_PROPERTY_LOCALE = "locale"; + private String locale; + + public static final String JSON_PROPERTY_CODE_PROMPT = "codePrompt"; + private String codePrompt; + + public static final String JSON_PROPERTY_SPEED = "speed"; + private String speed; + + public static final String JSON_PROPERTY_SSML_TEMPLATE = "ssmlTemplate"; + private String ssmlTemplate; + + public CalloutSpeechDto() {} + + public CalloutSpeechDto greeting(String greeting) { + this.greeting = greeting; + return this; + } + + /** + * Get greeting + * + * @return greeting + */ + @JsonProperty(JSON_PROPERTY_GREETING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getGreeting() { + return greeting; + } + + @JsonProperty(JSON_PROPERTY_GREETING) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setGreeting(String greeting) { + this.greeting = greeting; + } + + public CalloutSpeechDto locale(String locale) { + this.locale = locale; + return this; + } + + /** + * Get locale + * + * @return locale + */ + @JsonProperty(JSON_PROPERTY_LOCALE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getLocale() { + return locale; + } + + @JsonProperty(JSON_PROPERTY_LOCALE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLocale(String locale) { + this.locale = locale; + } + + public CalloutSpeechDto codePrompt(String codePrompt) { + this.codePrompt = codePrompt; + return this; + } + + /** + * Get codePrompt + * + * @return codePrompt + */ + @JsonProperty(JSON_PROPERTY_CODE_PROMPT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodePrompt() { + return codePrompt; + } + + @JsonProperty(JSON_PROPERTY_CODE_PROMPT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodePrompt(String codePrompt) { + this.codePrompt = codePrompt; + } + + public CalloutSpeechDto speed(String speed) { + this.speed = speed; + return this; + } + + /** + * Get speed + * + * @return speed + */ + @JsonProperty(JSON_PROPERTY_SPEED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSpeed() { + return speed; + } + + @JsonProperty(JSON_PROPERTY_SPEED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSpeed(String speed) { + this.speed = speed; + } + + public CalloutSpeechDto ssmlTemplate(String ssmlTemplate) { + this.ssmlTemplate = ssmlTemplate; + return this; + } + + /** + * Get ssmlTemplate + * + * @return ssmlTemplate + */ + @JsonProperty(JSON_PROPERTY_SSML_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSsmlTemplate() { + return ssmlTemplate; + } + + @JsonProperty(JSON_PROPERTY_SSML_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSsmlTemplate(String ssmlTemplate) { + this.ssmlTemplate = ssmlTemplate; + } + + /** Return true if this CalloutSpeech object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalloutSpeechDto calloutSpeech = (CalloutSpeechDto) o; + return Objects.equals(this.greeting, calloutSpeech.greeting) + && Objects.equals(this.locale, calloutSpeech.locale) + && Objects.equals(this.codePrompt, calloutSpeech.codePrompt) + && Objects.equals(this.speed, calloutSpeech.speed) + && Objects.equals(this.ssmlTemplate, calloutSpeech.ssmlTemplate); + } + + @Override + public int hashCode() { + return Objects.hash(greeting, locale, codePrompt, speed, ssmlTemplate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalloutSpeechDto {\n"); + sb.append(" greeting: ").append(toIndentedString(greeting)).append("\n"); + sb.append(" locale: ").append(toIndentedString(locale)).append("\n"); + sb.append(" codePrompt: ").append(toIndentedString(codePrompt)).append("\n"); + sb.append(" speed: ").append(toIndentedString(speed)).append("\n"); + sb.append(" ssmlTemplate: ").append(toIndentedString(ssmlTemplate)).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/verification/models/dto/v1/CalloutVerificationReportRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutVerificationReportRequestDto.java new file mode 100644 index 00000000..0224bab7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/CalloutVerificationReportRequestDto.java @@ -0,0 +1,88 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** CalloutVerificationReportRequestDto */ +@JsonPropertyOrder({CalloutVerificationReportRequestDto.JSON_PROPERTY_CODE}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class CalloutVerificationReportRequestDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public CalloutVerificationReportRequestDto() {} + + public CalloutVerificationReportRequestDto code(String code) { + this.code = code; + return this; + } + + /** + * OTP code. + * + * @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; + } + + /** Return true if this CalloutVerificationReportRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CalloutVerificationReportRequestDto calloutVerificationReportRequest = + (CalloutVerificationReportRequestDto) o; + return Objects.equals(this.code, calloutVerificationReportRequest.code); + } + + @Override + public int hashCode() { + return Objects.hash(code); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CalloutVerificationReportRequestDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).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/verification/models/dto/v1/FlashCallInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashCallInitiateVerificationResponseDto.java new file mode 100644 index 00000000..1caf7d65 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashCallInitiateVerificationResponseDto.java @@ -0,0 +1,309 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** FlashCallInitiateVerificationResponseDto */ +@JsonPropertyOrder({ + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_CLI, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_CLI_FILTER, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_INTERCEPTION_TIMEOUT, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_REPORT_TIMEOUT, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_DENY_CALL_AFTER, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_CALL_ID, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_SUB_VERIFICATION_ID, + FlashCallInitiateVerificationResponseDto.JSON_PROPERTY_LINKS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FlashCallInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_CLI = "cli"; + private String cli; + + public static final String JSON_PROPERTY_CLI_FILTER = "cliFilter"; + private String cliFilter; + + public static final String JSON_PROPERTY_INTERCEPTION_TIMEOUT = "interceptionTimeout"; + private Integer interceptionTimeout; + + public static final String JSON_PROPERTY_REPORT_TIMEOUT = "reportTimeout"; + private Integer reportTimeout; + + public static final String JSON_PROPERTY_DENY_CALL_AFTER = "denyCallAfter"; + private Integer denyCallAfter; + + public static final String JSON_PROPERTY_CALL_ID = "callId"; + private String callId; + + public static final String JSON_PROPERTY_SUB_VERIFICATION_ID = "subVerificationId"; + private String subVerificationId; + + public static final String JSON_PROPERTY_LINKS = "_links"; + private List links; + + public FlashCallInitiateVerificationResponseDto() {} + + public FlashCallInitiateVerificationResponseDto cli(String cli) { + this.cli = cli; + return this; + } + + /** + * Get cli + * + * @return cli + */ + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCli() { + return cli; + } + + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCli(String cli) { + this.cli = cli; + } + + public FlashCallInitiateVerificationResponseDto cliFilter(String cliFilter) { + this.cliFilter = cliFilter; + return this; + } + + /** + * Filter that should be applied for incoming calls to intercept the Flashcall. + * + * @return cliFilter + */ + @JsonProperty(JSON_PROPERTY_CLI_FILTER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCliFilter() { + return cliFilter; + } + + @JsonProperty(JSON_PROPERTY_CLI_FILTER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCliFilter(String cliFilter) { + this.cliFilter = cliFilter; + } + + public FlashCallInitiateVerificationResponseDto interceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + return this; + } + + /** + * Amount of seconds client should wait for the Flashcall. + * + * @return interceptionTimeout + */ + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getInterceptionTimeout() { + return interceptionTimeout; + } + + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInterceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + } + + public FlashCallInitiateVerificationResponseDto reportTimeout(Integer reportTimeout) { + this.reportTimeout = reportTimeout; + return this; + } + + /** + * Get reportTimeout + * + * @return reportTimeout + */ + @JsonProperty(JSON_PROPERTY_REPORT_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getReportTimeout() { + return reportTimeout; + } + + @JsonProperty(JSON_PROPERTY_REPORT_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReportTimeout(Integer reportTimeout) { + this.reportTimeout = reportTimeout; + } + + public FlashCallInitiateVerificationResponseDto denyCallAfter(Integer denyCallAfter) { + this.denyCallAfter = denyCallAfter; + return this; + } + + /** + * Get denyCallAfter + * + * @return denyCallAfter + */ + @JsonProperty(JSON_PROPERTY_DENY_CALL_AFTER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getDenyCallAfter() { + return denyCallAfter; + } + + @JsonProperty(JSON_PROPERTY_DENY_CALL_AFTER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDenyCallAfter(Integer denyCallAfter) { + this.denyCallAfter = denyCallAfter; + } + + public FlashCallInitiateVerificationResponseDto callId(String callId) { + this.callId = callId; + return this; + } + + /** + * Get callId + * + * @return callId + */ + @JsonProperty(JSON_PROPERTY_CALL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallId() { + return callId; + } + + @JsonProperty(JSON_PROPERTY_CALL_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallId(String callId) { + this.callId = callId; + } + + public FlashCallInitiateVerificationResponseDto subVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + return this; + } + + /** + * Get subVerificationId + * + * @return subVerificationId + */ + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSubVerificationId() { + return subVerificationId; + } + + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + } + + public FlashCallInitiateVerificationResponseDto links(List links) { + this.links = links; + return this; + } + + public FlashCallInitiateVerificationResponseDto addLinksItem( + VerificationResourceLinkDto linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * + * @return links + */ + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLinks(List links) { + this.links = links; + } + + /** Return true if this FlashCallInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlashCallInitiateVerificationResponseDto flashCallInitiateVerificationResponse = + (FlashCallInitiateVerificationResponseDto) o; + return Objects.equals(this.cli, flashCallInitiateVerificationResponse.cli) + && Objects.equals(this.cliFilter, flashCallInitiateVerificationResponse.cliFilter) + && Objects.equals( + this.interceptionTimeout, flashCallInitiateVerificationResponse.interceptionTimeout) + && Objects.equals(this.reportTimeout, flashCallInitiateVerificationResponse.reportTimeout) + && Objects.equals(this.denyCallAfter, flashCallInitiateVerificationResponse.denyCallAfter) + && Objects.equals(this.callId, flashCallInitiateVerificationResponse.callId) + && Objects.equals( + this.subVerificationId, flashCallInitiateVerificationResponse.subVerificationId) + && Objects.equals(this.links, flashCallInitiateVerificationResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash( + cli, + cliFilter, + interceptionTimeout, + reportTimeout, + denyCallAfter, + callId, + subVerificationId, + links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlashCallInitiateVerificationResponseDto {\n"); + sb.append(" cli: ").append(toIndentedString(cli)).append("\n"); + sb.append(" cliFilter: ").append(toIndentedString(cliFilter)).append("\n"); + sb.append(" interceptionTimeout: ") + .append(toIndentedString(interceptionTimeout)) + .append("\n"); + sb.append(" reportTimeout: ").append(toIndentedString(reportTimeout)).append("\n"); + sb.append(" denyCallAfter: ").append(toIndentedString(denyCallAfter)).append("\n"); + sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); + sb.append(" subVerificationId: ").append(toIndentedString(subVerificationId)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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/verification/models/dto/v1/FlashcallOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallOptionsDto.java new file mode 100644 index 00000000..360c9fc5 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallOptionsDto.java @@ -0,0 +1,175 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** FlashcallOptionsDto */ +@JsonPropertyOrder({ + FlashcallOptionsDto.JSON_PROPERTY_CLI, + FlashcallOptionsDto.JSON_PROPERTY_CLI_EXTRA_DIGITS, + FlashcallOptionsDto.JSON_PROPERTY_DIAL_TIMEOUT, + FlashcallOptionsDto.JSON_PROPERTY_INTERCEPTION_TIMEOUT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FlashcallOptionsDto { + public static final String JSON_PROPERTY_CLI = "cli"; + private String cli; + + public static final String JSON_PROPERTY_CLI_EXTRA_DIGITS = "cliExtraDigits"; + private String cliExtraDigits; + + public static final String JSON_PROPERTY_DIAL_TIMEOUT = "dialTimeout"; + private Integer dialTimeout; + + public static final String JSON_PROPERTY_INTERCEPTION_TIMEOUT = "interceptionTimeout"; + private Integer interceptionTimeout; + + public FlashcallOptionsDto() {} + + public FlashcallOptionsDto cli(String cli) { + this.cli = cli; + return this; + } + + /** + * Get cli + * + * @return cli + */ + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCli() { + return cli; + } + + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCli(String cli) { + this.cli = cli; + } + + public FlashcallOptionsDto cliExtraDigits(String cliExtraDigits) { + this.cliExtraDigits = cliExtraDigits; + return this; + } + + /** + * Get cliExtraDigits + * + * @return cliExtraDigits + */ + @JsonProperty(JSON_PROPERTY_CLI_EXTRA_DIGITS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCliExtraDigits() { + return cliExtraDigits; + } + + @JsonProperty(JSON_PROPERTY_CLI_EXTRA_DIGITS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCliExtraDigits(String cliExtraDigits) { + this.cliExtraDigits = cliExtraDigits; + } + + public FlashcallOptionsDto dialTimeout(Integer dialTimeout) { + this.dialTimeout = dialTimeout; + return this; + } + + /** + * Get dialTimeout + * + * @return dialTimeout + */ + @JsonProperty(JSON_PROPERTY_DIAL_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getDialTimeout() { + return dialTimeout; + } + + @JsonProperty(JSON_PROPERTY_DIAL_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDialTimeout(Integer dialTimeout) { + this.dialTimeout = dialTimeout; + } + + public FlashcallOptionsDto interceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + return this; + } + + /** + * Get interceptionTimeout + * + * @return interceptionTimeout + */ + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getInterceptionTimeout() { + return interceptionTimeout; + } + + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInterceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + } + + /** Return true if this FlashcallOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlashcallOptionsDto flashcallOptions = (FlashcallOptionsDto) o; + return Objects.equals(this.cli, flashcallOptions.cli) + && Objects.equals(this.cliExtraDigits, flashcallOptions.cliExtraDigits) + && Objects.equals(this.dialTimeout, flashcallOptions.dialTimeout) + && Objects.equals(this.interceptionTimeout, flashcallOptions.interceptionTimeout); + } + + @Override + public int hashCode() { + return Objects.hash(cli, cliExtraDigits, dialTimeout, interceptionTimeout); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlashcallOptionsDto {\n"); + sb.append(" cli: ").append(toIndentedString(cli)).append("\n"); + sb.append(" cliExtraDigits: ").append(toIndentedString(cliExtraDigits)).append("\n"); + sb.append(" dialTimeout: ").append(toIndentedString(dialTimeout)).append("\n"); + sb.append(" interceptionTimeout: ") + .append(toIndentedString(interceptionTimeout)) + .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/verification/models/dto/v1/FlashcallVerificationReportRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallVerificationReportRequestDto.java new file mode 100644 index 00000000..171aa2e7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/FlashcallVerificationReportRequestDto.java @@ -0,0 +1,88 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** FlashcallVerificationReportRequestDto */ +@JsonPropertyOrder({FlashcallVerificationReportRequestDto.JSON_PROPERTY_CLI}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class FlashcallVerificationReportRequestDto { + public static final String JSON_PROPERTY_CLI = "cli"; + private String cli; + + public FlashcallVerificationReportRequestDto() {} + + public FlashcallVerificationReportRequestDto cli(String cli) { + this.cli = cli; + return this; + } + + /** + * Complete CLI received during Flashcall interception or read from call log. + * + * @return cli + */ + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCli() { + return cli; + } + + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCli(String cli) { + this.cli = cli; + } + + /** Return true if this FlashcallVerificationReportRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FlashcallVerificationReportRequestDto flashcallVerificationReportRequest = + (FlashcallVerificationReportRequestDto) o; + return Objects.equals(this.cli, flashcallVerificationReportRequest.cli); + } + + @Override + public int hashCode() { + return Objects.hash(cli); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FlashcallVerificationReportRequestDto {\n"); + sb.append(" cli: ").append(toIndentedString(cli)).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/verification/models/dto/v1/IdentityDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/IdentityDto.java new file mode 100644 index 00000000..01336fd2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/IdentityDto.java @@ -0,0 +1,114 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** IdentityDto */ +@JsonPropertyOrder({IdentityDto.JSON_PROPERTY_TYPE, IdentityDto.JSON_PROPERTY_ENDPOINT}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class IdentityDto { + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public static final String JSON_PROPERTY_ENDPOINT = "endpoint"; + private String endpoint; + + public IdentityDto() {} + + public IdentityDto type(String type) { + this.type = type; + return this; + } + + /** + * Type of identity, e.g. 'number', 'email' etc. + * + * @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 IdentityDto endpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + /** + * Value of identity in format defined by its type. + * + * @return endpoint + */ + @JsonProperty(JSON_PROPERTY_ENDPOINT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEndpoint() { + return endpoint; + } + + @JsonProperty(JSON_PROPERTY_ENDPOINT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + /** Return true if this Identity object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IdentityDto identity = (IdentityDto) o; + return Objects.equals(this.type, identity.type) + && Objects.equals(this.endpoint, identity.endpoint); + } + + @Override + public int hashCode() { + return Objects.hash(type, endpoint); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IdentityDto {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" endpoint: ").append(toIndentedString(endpoint)).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/verification/models/dto/v1/InitiateVerificationResourceCalloutOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceCalloutOptionsDto.java new file mode 100644 index 00000000..a55b40b7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceCalloutOptionsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceCalloutOptionsDto + .InitiateVerificationResourceCalloutOptionsDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResourceCalloutOptionsDto + .InitiateVerificationResourceCalloutOptionsDtoSerializer.class) +public class InitiateVerificationResourceCalloutOptionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceCalloutOptionsDto.class.getName()); + + public static class InitiateVerificationResourceCalloutOptionsDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceCalloutOptionsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceCalloutOptionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceCalloutOptionsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceCalloutOptionsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceCalloutOptionsDtoDeserializer() { + this(InitiateVerificationResourceCalloutOptionsDto.class); + } + + public InitiateVerificationResourceCalloutOptionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceCalloutOptionsDto 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 CalloutOptionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CalloutOptionsDto.class.equals(Integer.class) + || CalloutOptionsDto.class.equals(Long.class) + || CalloutOptionsDto.class.equals(Float.class) + || CalloutOptionsDto.class.equals(Double.class) + || CalloutOptionsDto.class.equals(Boolean.class) + || CalloutOptionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CalloutOptionsDto.class.equals(Integer.class) + || CalloutOptionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CalloutOptionsDto.class.equals(Float.class) + || CalloutOptionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (CalloutOptionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CalloutOptionsDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(CalloutOptionsDto.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 'CalloutOptionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'CalloutOptionsDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceCalloutOptionsDto ret = + new InitiateVerificationResourceCalloutOptionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceCalloutOptionsDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceCalloutOptionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceCalloutOptionsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceCalloutOptionsDto(CalloutOptionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("CalloutOptionsDto", CalloutOptionsDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceCalloutOptionsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceCalloutOptionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: CalloutOptionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(CalloutOptionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be CalloutOptionsDto"); + } + + /** + * Get the actual instance, which can be the following: CalloutOptionsDto + * + * @return The actual instance (CalloutOptionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CalloutOptionsDto`. If the actual instance is not + * `CalloutOptionsDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `CalloutOptionsDto` + * @throws ClassCastException if the instance is not `CalloutOptionsDto` + */ + public CalloutOptionsDto getCalloutOptionsDto() throws ClassCastException { + return (CalloutOptionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceDto.java new file mode 100644 index 00000000..a4debd2d --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceDto.java @@ -0,0 +1,389 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** InitiateVerificationResourceDto */ +@JsonPropertyOrder({ + InitiateVerificationResourceDto.JSON_PROPERTY_IDENTITY, + InitiateVerificationResourceDto.JSON_PROPERTY_METHOD, + InitiateVerificationResourceDto.JSON_PROPERTY_REFERENCE, + InitiateVerificationResourceDto.JSON_PROPERTY_CUSTOM, + InitiateVerificationResourceDto.JSON_PROPERTY_METADATA, + InitiateVerificationResourceDto.JSON_PROPERTY_FLASH_CALL_OPTIONS, + InitiateVerificationResourceDto.JSON_PROPERTY_CALLOUT_OPTIONS, + InitiateVerificationResourceDto.JSON_PROPERTY_SMS_OPTIONS, + InitiateVerificationResourceDto.JSON_PROPERTY_WHATSAPP_OPTIONS, + InitiateVerificationResourceDto.JSON_PROPERTY_SEAMLESS_OPTIONS, + InitiateVerificationResourceDto.JSON_PROPERTY_HONOUR_EARLY_REJECT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InitiateVerificationResourceDto { + public static final String JSON_PROPERTY_IDENTITY = "identity"; + private InitiateVerificationResourceIdentityDto identity; + + public static final String JSON_PROPERTY_METHOD = "method"; + private InitiateVerificationResourceMethodDto method; + + public static final String JSON_PROPERTY_REFERENCE = "reference"; + private String reference; + + public static final String JSON_PROPERTY_CUSTOM = "custom"; + private String custom; + + public static final String JSON_PROPERTY_METADATA = "metadata"; + private InitiateVerificationResourceMetadataDto metadata; + + public static final String JSON_PROPERTY_FLASH_CALL_OPTIONS = "flashCallOptions"; + private InitiateVerificationResourceFlashCallOptionsDto flashCallOptions; + + public static final String JSON_PROPERTY_CALLOUT_OPTIONS = "calloutOptions"; + private InitiateVerificationResourceCalloutOptionsDto calloutOptions; + + public static final String JSON_PROPERTY_SMS_OPTIONS = "smsOptions"; + private InitiateVerificationResourceSmsOptionsDto smsOptions; + + public static final String JSON_PROPERTY_WHATSAPP_OPTIONS = "whatsappOptions"; + private InitiateVerificationResourceWhatsappOptionsDto whatsappOptions; + + public static final String JSON_PROPERTY_SEAMLESS_OPTIONS = "seamlessOptions"; + private InitiateVerificationResourceSeamlessOptionsDto seamlessOptions; + + public static final String JSON_PROPERTY_HONOUR_EARLY_REJECT = "honourEarlyReject"; + private Boolean honourEarlyReject; + + public InitiateVerificationResourceDto() {} + + public InitiateVerificationResourceDto identity( + InitiateVerificationResourceIdentityDto identity) { + this.identity = identity; + return this; + } + + /** + * Get identity + * + * @return identity + */ + @JsonProperty(JSON_PROPERTY_IDENTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceIdentityDto getIdentity() { + return identity; + } + + @JsonProperty(JSON_PROPERTY_IDENTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setIdentity(InitiateVerificationResourceIdentityDto identity) { + this.identity = identity; + } + + public InitiateVerificationResourceDto method(InitiateVerificationResourceMethodDto method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceMethodDto getMethod() { + return method; + } + + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethod(InitiateVerificationResourceMethodDto method) { + this.method = method; + } + + public InitiateVerificationResourceDto reference(String reference) { + this.reference = reference; + return this; + } + + /** + * Custom identifier used to get verification status. + * + * @return reference + */ + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReference() { + return reference; + } + + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReference(String reference) { + this.reference = reference; + } + + public InitiateVerificationResourceDto custom(String custom) { + this.custom = custom; + return this; + } + + /** + * Custom data passed back to callback. + * + * @return custom + */ + @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCustom() { + return custom; + } + + @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCustom(String custom) { + this.custom = custom; + } + + public InitiateVerificationResourceDto metadata( + InitiateVerificationResourceMetadataDto metadata) { + this.metadata = metadata; + return this; + } + + /** + * Get metadata + * + * @return metadata + */ + @JsonProperty(JSON_PROPERTY_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceMetadataDto getMetadata() { + return metadata; + } + + @JsonProperty(JSON_PROPERTY_METADATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMetadata(InitiateVerificationResourceMetadataDto metadata) { + this.metadata = metadata; + } + + public InitiateVerificationResourceDto flashCallOptions( + InitiateVerificationResourceFlashCallOptionsDto flashCallOptions) { + this.flashCallOptions = flashCallOptions; + return this; + } + + /** + * Get flashCallOptions + * + * @return flashCallOptions + */ + @JsonProperty(JSON_PROPERTY_FLASH_CALL_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceFlashCallOptionsDto getFlashCallOptions() { + return flashCallOptions; + } + + @JsonProperty(JSON_PROPERTY_FLASH_CALL_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashCallOptions( + InitiateVerificationResourceFlashCallOptionsDto flashCallOptions) { + this.flashCallOptions = flashCallOptions; + } + + public InitiateVerificationResourceDto calloutOptions( + InitiateVerificationResourceCalloutOptionsDto calloutOptions) { + this.calloutOptions = calloutOptions; + return this; + } + + /** + * Get calloutOptions + * + * @return calloutOptions + */ + @JsonProperty(JSON_PROPERTY_CALLOUT_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceCalloutOptionsDto getCalloutOptions() { + return calloutOptions; + } + + @JsonProperty(JSON_PROPERTY_CALLOUT_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCalloutOptions(InitiateVerificationResourceCalloutOptionsDto calloutOptions) { + this.calloutOptions = calloutOptions; + } + + public InitiateVerificationResourceDto smsOptions( + InitiateVerificationResourceSmsOptionsDto smsOptions) { + this.smsOptions = smsOptions; + return this; + } + + /** + * Get smsOptions + * + * @return smsOptions + */ + @JsonProperty(JSON_PROPERTY_SMS_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceSmsOptionsDto getSmsOptions() { + return smsOptions; + } + + @JsonProperty(JSON_PROPERTY_SMS_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSmsOptions(InitiateVerificationResourceSmsOptionsDto smsOptions) { + this.smsOptions = smsOptions; + } + + public InitiateVerificationResourceDto whatsappOptions( + InitiateVerificationResourceWhatsappOptionsDto whatsappOptions) { + this.whatsappOptions = whatsappOptions; + return this; + } + + /** + * Get whatsappOptions + * + * @return whatsappOptions + */ + @JsonProperty(JSON_PROPERTY_WHATSAPP_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceWhatsappOptionsDto getWhatsappOptions() { + return whatsappOptions; + } + + @JsonProperty(JSON_PROPERTY_WHATSAPP_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWhatsappOptions(InitiateVerificationResourceWhatsappOptionsDto whatsappOptions) { + this.whatsappOptions = whatsappOptions; + } + + public InitiateVerificationResourceDto seamlessOptions( + InitiateVerificationResourceSeamlessOptionsDto seamlessOptions) { + this.seamlessOptions = seamlessOptions; + return this; + } + + /** + * Get seamlessOptions + * + * @return seamlessOptions + */ + @JsonProperty(JSON_PROPERTY_SEAMLESS_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResourceSeamlessOptionsDto getSeamlessOptions() { + return seamlessOptions; + } + + @JsonProperty(JSON_PROPERTY_SEAMLESS_OPTIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSeamlessOptions(InitiateVerificationResourceSeamlessOptionsDto seamlessOptions) { + this.seamlessOptions = seamlessOptions; + } + + public InitiateVerificationResourceDto honourEarlyReject(Boolean honourEarlyReject) { + this.honourEarlyReject = honourEarlyReject; + return this; + } + + /** + * Explicitly control if early rejects should be honoured. + * + * @return honourEarlyReject + */ + @JsonProperty(JSON_PROPERTY_HONOUR_EARLY_REJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getHonourEarlyReject() { + return honourEarlyReject; + } + + @JsonProperty(JSON_PROPERTY_HONOUR_EARLY_REJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setHonourEarlyReject(Boolean honourEarlyReject) { + this.honourEarlyReject = honourEarlyReject; + } + + /** Return true if this InitiateVerificationResource object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InitiateVerificationResourceDto initiateVerificationResource = + (InitiateVerificationResourceDto) o; + return Objects.equals(this.identity, initiateVerificationResource.identity) + && Objects.equals(this.method, initiateVerificationResource.method) + && Objects.equals(this.reference, initiateVerificationResource.reference) + && Objects.equals(this.custom, initiateVerificationResource.custom) + && Objects.equals(this.metadata, initiateVerificationResource.metadata) + && Objects.equals(this.flashCallOptions, initiateVerificationResource.flashCallOptions) + && Objects.equals(this.calloutOptions, initiateVerificationResource.calloutOptions) + && Objects.equals(this.smsOptions, initiateVerificationResource.smsOptions) + && Objects.equals(this.whatsappOptions, initiateVerificationResource.whatsappOptions) + && Objects.equals(this.seamlessOptions, initiateVerificationResource.seamlessOptions) + && Objects.equals(this.honourEarlyReject, initiateVerificationResource.honourEarlyReject); + } + + @Override + public int hashCode() { + return Objects.hash( + identity, + method, + reference, + custom, + metadata, + flashCallOptions, + calloutOptions, + smsOptions, + whatsappOptions, + seamlessOptions, + honourEarlyReject); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InitiateVerificationResourceDto {\n"); + sb.append(" identity: ").append(toIndentedString(identity)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" flashCallOptions: ").append(toIndentedString(flashCallOptions)).append("\n"); + sb.append(" calloutOptions: ").append(toIndentedString(calloutOptions)).append("\n"); + sb.append(" smsOptions: ").append(toIndentedString(smsOptions)).append("\n"); + sb.append(" whatsappOptions: ").append(toIndentedString(whatsappOptions)).append("\n"); + sb.append(" seamlessOptions: ").append(toIndentedString(seamlessOptions)).append("\n"); + sb.append(" honourEarlyReject: ").append(toIndentedString(honourEarlyReject)).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/verification/models/dto/v1/InitiateVerificationResourceFlashCallOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceFlashCallOptionsDto.java new file mode 100644 index 00000000..0dfca020 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceFlashCallOptionsDto.java @@ -0,0 +1,218 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceFlashCallOptionsDto + .InitiateVerificationResourceFlashCallOptionsDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResourceFlashCallOptionsDto + .InitiateVerificationResourceFlashCallOptionsDtoSerializer.class) +public class InitiateVerificationResourceFlashCallOptionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceFlashCallOptionsDto.class.getName()); + + public static class InitiateVerificationResourceFlashCallOptionsDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceFlashCallOptionsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceFlashCallOptionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceFlashCallOptionsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceFlashCallOptionsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceFlashCallOptionsDtoDeserializer() { + this(InitiateVerificationResourceFlashCallOptionsDto.class); + } + + public InitiateVerificationResourceFlashCallOptionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceFlashCallOptionsDto 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 FlashcallOptionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (FlashcallOptionsDto.class.equals(Integer.class) + || FlashcallOptionsDto.class.equals(Long.class) + || FlashcallOptionsDto.class.equals(Float.class) + || FlashcallOptionsDto.class.equals(Double.class) + || FlashcallOptionsDto.class.equals(Boolean.class) + || FlashcallOptionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((FlashcallOptionsDto.class.equals(Integer.class) + || FlashcallOptionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((FlashcallOptionsDto.class.equals(Float.class) + || FlashcallOptionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (FlashcallOptionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (FlashcallOptionsDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(FlashcallOptionsDto.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 'FlashcallOptionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'FlashcallOptionsDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceFlashCallOptionsDto ret = + new InitiateVerificationResourceFlashCallOptionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceFlashCallOptionsDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceFlashCallOptionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceFlashCallOptionsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceFlashCallOptionsDto(FlashcallOptionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("FlashcallOptionsDto", FlashcallOptionsDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceFlashCallOptionsDto.class, + Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceFlashCallOptionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: FlashcallOptionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(FlashcallOptionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be FlashcallOptionsDto"); + } + + /** + * Get the actual instance, which can be the following: FlashcallOptionsDto + * + * @return The actual instance (FlashcallOptionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `FlashcallOptionsDto`. If the actual instance is not + * `FlashcallOptionsDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `FlashcallOptionsDto` + * @throws ClassCastException if the instance is not `FlashcallOptionsDto` + */ + public FlashcallOptionsDto getFlashcallOptionsDto() throws ClassCastException { + return (FlashcallOptionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceIdentityDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceIdentityDto.java new file mode 100644 index 00000000..15498980 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceIdentityDto.java @@ -0,0 +1,209 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceIdentityDto.InitiateVerificationResourceIdentityDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResourceIdentityDto.InitiateVerificationResourceIdentityDtoSerializer + .class) +public class InitiateVerificationResourceIdentityDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceIdentityDto.class.getName()); + + public static class InitiateVerificationResourceIdentityDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceIdentityDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceIdentityDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceIdentityDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceIdentityDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceIdentityDtoDeserializer() { + this(InitiateVerificationResourceIdentityDto.class); + } + + public InitiateVerificationResourceIdentityDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceIdentityDto 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 IdentityDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (IdentityDto.class.equals(Integer.class) + || IdentityDto.class.equals(Long.class) + || IdentityDto.class.equals(Float.class) + || IdentityDto.class.equals(Double.class) + || IdentityDto.class.equals(Boolean.class) + || IdentityDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((IdentityDto.class.equals(Integer.class) || IdentityDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((IdentityDto.class.equals(Float.class) || IdentityDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (IdentityDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (IdentityDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(IdentityDto.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 'IdentityDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'IdentityDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceIdentityDto ret = new InitiateVerificationResourceIdentityDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceIdentityDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceIdentityDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "InitiateVerificationResourceIdentityDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceIdentityDto() { + super("oneOf", Boolean.FALSE); + } + + public InitiateVerificationResourceIdentityDto(IdentityDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("IdentityDto", IdentityDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceIdentityDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceIdentityDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: IdentityDto + * + *

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(IdentityDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be IdentityDto"); + } + + /** + * Get the actual instance, which can be the following: IdentityDto + * + * @return The actual instance (IdentityDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `IdentityDto`. If the actual instance is not `IdentityDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `IdentityDto` + * @throws ClassCastException if the instance is not `IdentityDto` + */ + public IdentityDto getIdentityDto() throws ClassCastException { + return (IdentityDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMetadataDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMetadataDto.java new file mode 100644 index 00000000..0f740c4b --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMetadataDto.java @@ -0,0 +1,218 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceMetadataDto.InitiateVerificationResourceMetadataDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResourceMetadataDto.InitiateVerificationResourceMetadataDtoSerializer + .class) +public class InitiateVerificationResourceMetadataDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceMetadataDto.class.getName()); + + public static class InitiateVerificationResourceMetadataDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceMetadataDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceMetadataDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceMetadataDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceMetadataDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceMetadataDtoDeserializer() { + this(InitiateVerificationResourceMetadataDto.class); + } + + public InitiateVerificationResourceMetadataDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceMetadataDto 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 VerificationMetadataDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataDto.class.equals(Integer.class) + || VerificationMetadataDto.class.equals(Long.class) + || VerificationMetadataDto.class.equals(Float.class) + || VerificationMetadataDto.class.equals(Double.class) + || VerificationMetadataDto.class.equals(Boolean.class) + || VerificationMetadataDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataDto.class.equals(Integer.class) + || VerificationMetadataDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataDto.class.equals(Float.class) + || VerificationMetadataDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataDto.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 'VerificationMetadataDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'VerificationMetadataDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceMetadataDto ret = new InitiateVerificationResourceMetadataDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceMetadataDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceMetadataDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceMetadataDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceMetadataDto(VerificationMetadataDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataDto", VerificationMetadataDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceMetadataDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceMetadataDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataDto + * + * @return The actual instance (VerificationMetadataDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataDto`. If the actual instance is not + * `VerificationMetadataDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataDto` + * @throws ClassCastException if the instance is not `VerificationMetadataDto` + */ + public VerificationMetadataDto getVerificationMetadataDto() throws ClassCastException { + return (VerificationMetadataDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMethodDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMethodDto.java new file mode 100644 index 00000000..d3dda31c --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceMethodDto.java @@ -0,0 +1,212 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceMethodDto.InitiateVerificationResourceMethodDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResourceMethodDto.InitiateVerificationResourceMethodDtoSerializer.class) +public class InitiateVerificationResourceMethodDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceMethodDto.class.getName()); + + public static class InitiateVerificationResourceMethodDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceMethodDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceMethodDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceMethodDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceMethodDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceMethodDtoDeserializer() { + this(InitiateVerificationResourceMethodDto.class); + } + + public InitiateVerificationResourceMethodDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceMethodDto 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 VerificationMethodDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMethodDto.class.equals(Integer.class) + || VerificationMethodDto.class.equals(Long.class) + || VerificationMethodDto.class.equals(Float.class) + || VerificationMethodDto.class.equals(Double.class) + || VerificationMethodDto.class.equals(Boolean.class) + || VerificationMethodDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMethodDto.class.equals(Integer.class) + || VerificationMethodDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMethodDto.class.equals(Float.class) + || VerificationMethodDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMethodDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMethodDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(VerificationMethodDto.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 'VerificationMethodDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'VerificationMethodDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceMethodDto ret = new InitiateVerificationResourceMethodDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceMethodDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceMethodDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "InitiateVerificationResourceMethodDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceMethodDto() { + super("oneOf", Boolean.FALSE); + } + + public InitiateVerificationResourceMethodDto(VerificationMethodDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMethodDto", VerificationMethodDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceMethodDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceMethodDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMethodDto + * + *

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( + VerificationMethodDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMethodDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMethodDto + * + * @return The actual instance (VerificationMethodDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMethodDto`. If the actual instance is not + * `VerificationMethodDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMethodDto` + * @throws ClassCastException if the instance is not `VerificationMethodDto` + */ + public VerificationMethodDto getVerificationMethodDto() throws ClassCastException { + return (VerificationMethodDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSeamlessOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSeamlessOptionsDto.java new file mode 100644 index 00000000..7d8e2a1f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSeamlessOptionsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceSeamlessOptionsDto + .InitiateVerificationResourceSeamlessOptionsDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResourceSeamlessOptionsDto + .InitiateVerificationResourceSeamlessOptionsDtoSerializer.class) +public class InitiateVerificationResourceSeamlessOptionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceSeamlessOptionsDto.class.getName()); + + public static class InitiateVerificationResourceSeamlessOptionsDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceSeamlessOptionsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceSeamlessOptionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceSeamlessOptionsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceSeamlessOptionsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceSeamlessOptionsDtoDeserializer() { + this(InitiateVerificationResourceSeamlessOptionsDto.class); + } + + public InitiateVerificationResourceSeamlessOptionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceSeamlessOptionsDto 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 SeamlessOptionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SeamlessOptionsDto.class.equals(Integer.class) + || SeamlessOptionsDto.class.equals(Long.class) + || SeamlessOptionsDto.class.equals(Float.class) + || SeamlessOptionsDto.class.equals(Double.class) + || SeamlessOptionsDto.class.equals(Boolean.class) + || SeamlessOptionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SeamlessOptionsDto.class.equals(Integer.class) + || SeamlessOptionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SeamlessOptionsDto.class.equals(Float.class) + || SeamlessOptionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (SeamlessOptionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SeamlessOptionsDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(SeamlessOptionsDto.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 'SeamlessOptionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SeamlessOptionsDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceSeamlessOptionsDto ret = + new InitiateVerificationResourceSeamlessOptionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceSeamlessOptionsDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceSeamlessOptionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceSeamlessOptionsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceSeamlessOptionsDto(SeamlessOptionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("SeamlessOptionsDto", SeamlessOptionsDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceSeamlessOptionsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceSeamlessOptionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: SeamlessOptionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(SeamlessOptionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SeamlessOptionsDto"); + } + + /** + * Get the actual instance, which can be the following: SeamlessOptionsDto + * + * @return The actual instance (SeamlessOptionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SeamlessOptionsDto`. If the actual instance is not + * `SeamlessOptionsDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `SeamlessOptionsDto` + * @throws ClassCastException if the instance is not `SeamlessOptionsDto` + */ + public SeamlessOptionsDto getSeamlessOptionsDto() throws ClassCastException { + return (SeamlessOptionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSmsOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSmsOptionsDto.java new file mode 100644 index 00000000..3135667c --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceSmsOptionsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceSmsOptionsDto + .InitiateVerificationResourceSmsOptionsDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResourceSmsOptionsDto + .InitiateVerificationResourceSmsOptionsDtoSerializer.class) +public class InitiateVerificationResourceSmsOptionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceSmsOptionsDto.class.getName()); + + public static class InitiateVerificationResourceSmsOptionsDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceSmsOptionsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceSmsOptionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceSmsOptionsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceSmsOptionsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceSmsOptionsDtoDeserializer() { + this(InitiateVerificationResourceSmsOptionsDto.class); + } + + public InitiateVerificationResourceSmsOptionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceSmsOptionsDto 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 SmsOptionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SmsOptionsDto.class.equals(Integer.class) + || SmsOptionsDto.class.equals(Long.class) + || SmsOptionsDto.class.equals(Float.class) + || SmsOptionsDto.class.equals(Double.class) + || SmsOptionsDto.class.equals(Boolean.class) + || SmsOptionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SmsOptionsDto.class.equals(Integer.class) + || SmsOptionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SmsOptionsDto.class.equals(Float.class) + || SmsOptionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (SmsOptionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SmsOptionsDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(SmsOptionsDto.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 'SmsOptionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'SmsOptionsDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceSmsOptionsDto ret = + new InitiateVerificationResourceSmsOptionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceSmsOptionsDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceSmsOptionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceSmsOptionsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceSmsOptionsDto(SmsOptionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("SmsOptionsDto", SmsOptionsDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceSmsOptionsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceSmsOptionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: SmsOptionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(SmsOptionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SmsOptionsDto"); + } + + /** + * Get the actual instance, which can be the following: SmsOptionsDto + * + * @return The actual instance (SmsOptionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SmsOptionsDto`. If the actual instance is not `SmsOptionsDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `SmsOptionsDto` + * @throws ClassCastException if the instance is not `SmsOptionsDto` + */ + public SmsOptionsDto getSmsOptionsDto() throws ClassCastException { + return (SmsOptionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceWhatsappOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceWhatsappOptionsDto.java new file mode 100644 index 00000000..e9840e67 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResourceWhatsappOptionsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResourceWhatsappOptionsDto + .InitiateVerificationResourceWhatsappOptionsDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResourceWhatsappOptionsDto + .InitiateVerificationResourceWhatsappOptionsDtoSerializer.class) +public class InitiateVerificationResourceWhatsappOptionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResourceWhatsappOptionsDto.class.getName()); + + public static class InitiateVerificationResourceWhatsappOptionsDtoSerializer + extends StdSerializer { + public InitiateVerificationResourceWhatsappOptionsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResourceWhatsappOptionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResourceWhatsappOptionsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResourceWhatsappOptionsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResourceWhatsappOptionsDtoDeserializer() { + this(InitiateVerificationResourceWhatsappOptionsDto.class); + } + + public InitiateVerificationResourceWhatsappOptionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResourceWhatsappOptionsDto 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 WhatsappOptionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (WhatsappOptionsDto.class.equals(Integer.class) + || WhatsappOptionsDto.class.equals(Long.class) + || WhatsappOptionsDto.class.equals(Float.class) + || WhatsappOptionsDto.class.equals(Double.class) + || WhatsappOptionsDto.class.equals(Boolean.class) + || WhatsappOptionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((WhatsappOptionsDto.class.equals(Integer.class) + || WhatsappOptionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((WhatsappOptionsDto.class.equals(Float.class) + || WhatsappOptionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (WhatsappOptionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (WhatsappOptionsDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(WhatsappOptionsDto.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 'WhatsappOptionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'WhatsappOptionsDto'", e); + } + + if (match == 1) { + InitiateVerificationResourceWhatsappOptionsDto ret = + new InitiateVerificationResourceWhatsappOptionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResourceWhatsappOptionsDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResourceWhatsappOptionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResourceWhatsappOptionsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResourceWhatsappOptionsDto(WhatsappOptionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("WhatsappOptionsDto", WhatsappOptionsDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResourceWhatsappOptionsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResourceWhatsappOptionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: WhatsappOptionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(WhatsappOptionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be WhatsappOptionsDto"); + } + + /** + * Get the actual instance, which can be the following: WhatsappOptionsDto + * + * @return The actual instance (WhatsappOptionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `WhatsappOptionsDto`. If the actual instance is not + * `WhatsappOptionsDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `WhatsappOptionsDto` + * @throws ClassCastException if the instance is not `WhatsappOptionsDto` + */ + public WhatsappOptionsDto getWhatsappOptionsDto() throws ClassCastException { + return (WhatsappOptionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseAutoDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseAutoDto.java new file mode 100644 index 00000000..3f8deb98 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseAutoDto.java @@ -0,0 +1,219 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseAutoDto.InitiateVerificationResponseAutoDtoDeserializer.class) +@JsonSerialize( + using = InitiateVerificationResponseAutoDto.InitiateVerificationResponseAutoDtoSerializer.class) +public class InitiateVerificationResponseAutoDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseAutoDto.class.getName()); + + public static class InitiateVerificationResponseAutoDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseAutoDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseAutoDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseAutoDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseAutoDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseAutoDtoDeserializer() { + this(InitiateVerificationResponseAutoDto.class); + } + + public InitiateVerificationResponseAutoDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseAutoDto 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 AutoInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (AutoInitiateVerificationResponseDto.class.equals(Integer.class) + || AutoInitiateVerificationResponseDto.class.equals(Long.class) + || AutoInitiateVerificationResponseDto.class.equals(Float.class) + || AutoInitiateVerificationResponseDto.class.equals(Double.class) + || AutoInitiateVerificationResponseDto.class.equals(Boolean.class) + || AutoInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((AutoInitiateVerificationResponseDto.class.equals(Integer.class) + || AutoInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((AutoInitiateVerificationResponseDto.class.equals(Float.class) + || AutoInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (AutoInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (AutoInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(AutoInitiateVerificationResponseDto.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 'AutoInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'AutoInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseAutoDto ret = new InitiateVerificationResponseAutoDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseAutoDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseAutoDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseAutoDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseAutoDto(AutoInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("AutoInitiateVerificationResponseDto", AutoInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseAutoDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseAutoDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: AutoInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + AutoInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be AutoInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: AutoInitiateVerificationResponseDto + * + * @return The actual instance (AutoInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `AutoInitiateVerificationResponseDto`. If the actual instance is not + * `AutoInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `AutoInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `AutoInitiateVerificationResponseDto` + */ + public AutoInitiateVerificationResponseDto getAutoInitiateVerificationResponseDto() + throws ClassCastException { + return (AutoInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseCalloutDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseCalloutDto.java new file mode 100644 index 00000000..5446aa96 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseCalloutDto.java @@ -0,0 +1,227 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseCalloutDto.InitiateVerificationResponseCalloutDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResponseCalloutDto.InitiateVerificationResponseCalloutDtoSerializer + .class) +public class InitiateVerificationResponseCalloutDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseCalloutDto.class.getName()); + + public static class InitiateVerificationResponseCalloutDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseCalloutDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseCalloutDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseCalloutDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseCalloutDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseCalloutDtoDeserializer() { + this(InitiateVerificationResponseCalloutDto.class); + } + + public InitiateVerificationResponseCalloutDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseCalloutDto 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 CalloutInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CalloutInitiateVerificationResponseDto.class.equals(Integer.class) + || CalloutInitiateVerificationResponseDto.class.equals(Long.class) + || CalloutInitiateVerificationResponseDto.class.equals(Float.class) + || CalloutInitiateVerificationResponseDto.class.equals(Double.class) + || CalloutInitiateVerificationResponseDto.class.equals(Boolean.class) + || CalloutInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CalloutInitiateVerificationResponseDto.class.equals(Integer.class) + || CalloutInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CalloutInitiateVerificationResponseDto.class.equals(Float.class) + || CalloutInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (CalloutInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CalloutInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(CalloutInitiateVerificationResponseDto.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 'CalloutInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'CalloutInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseCalloutDto ret = new InitiateVerificationResponseCalloutDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseCalloutDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseCalloutDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseCalloutDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseCalloutDto(CalloutInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "CalloutInitiateVerificationResponseDto", CalloutInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseCalloutDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseCalloutDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: CalloutInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + CalloutInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be CalloutInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: CalloutInitiateVerificationResponseDto + * + * @return The actual instance (CalloutInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CalloutInitiateVerificationResponseDto`. If the actual instance is + * not `CalloutInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `CalloutInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `CalloutInitiateVerificationResponseDto` + */ + public CalloutInitiateVerificationResponseDto getCalloutInitiateVerificationResponseDto() + throws ClassCastException { + return (CalloutInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseDto.java new file mode 100644 index 00000000..97eb3bc6 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseDto.java @@ -0,0 +1,424 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** InitiateVerificationResponseDto */ +@JsonPropertyOrder({ + InitiateVerificationResponseDto.JSON_PROPERTY_ID, + InitiateVerificationResponseDto.JSON_PROPERTY_METHOD, + InitiateVerificationResponseDto.JSON_PROPERTY_SMS, + InitiateVerificationResponseDto.JSON_PROPERTY_FLASH_CALL, + InitiateVerificationResponseDto.JSON_PROPERTY_CALLOUT, + InitiateVerificationResponseDto.JSON_PROPERTY_SEAMLESS, + InitiateVerificationResponseDto.JSON_PROPERTY_WHATSAPP, + InitiateVerificationResponseDto.JSON_PROPERTY_AUTO, + InitiateVerificationResponseDto.JSON_PROPERTY_EARLY_REJECT, + InitiateVerificationResponseDto.JSON_PROPERTY_EARLY_REJECT_MESSAGE, + InitiateVerificationResponseDto.JSON_PROPERTY_MAX_PRICE, + InitiateVerificationResponseDto.JSON_PROPERTY_LINKS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class InitiateVerificationResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_METHOD = "method"; + private VerificationMethodDto method; + + public static final String JSON_PROPERTY_SMS = "sms"; + private InitiateVerificationResponseSmsDto sms; + + public static final String JSON_PROPERTY_FLASH_CALL = "flashCall"; + private InitiateVerificationResponseFlashCallDto flashCall; + + public static final String JSON_PROPERTY_CALLOUT = "callout"; + private InitiateVerificationResponseCalloutDto callout; + + public static final String JSON_PROPERTY_SEAMLESS = "seamless"; + private InitiateVerificationResponseSeamlessDto seamless; + + public static final String JSON_PROPERTY_WHATSAPP = "whatsapp"; + private InitiateVerificationResponseWhatsappDto whatsapp; + + public static final String JSON_PROPERTY_AUTO = "auto"; + private InitiateVerificationResponseAutoDto auto; + + public static final String JSON_PROPERTY_EARLY_REJECT = "earlyReject"; + private Boolean earlyReject; + + public static final String JSON_PROPERTY_EARLY_REJECT_MESSAGE = "earlyRejectMessage"; + private String earlyRejectMessage; + + public static final String JSON_PROPERTY_MAX_PRICE = "maxPrice"; + private InitiateVerificationResponseMaxPriceDto maxPrice; + + public static final String JSON_PROPERTY_LINKS = "_links"; + private List links; + + public InitiateVerificationResponseDto() {} + + public InitiateVerificationResponseDto id(String id) { + this.id = id; + return this; + } + + /** + * Verification identifier used to query for status. + * + * @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 InitiateVerificationResponseDto method(VerificationMethodDto method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMethodDto getMethod() { + return method; + } + + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethod(VerificationMethodDto method) { + this.method = method; + } + + public InitiateVerificationResponseDto sms(InitiateVerificationResponseSmsDto sms) { + this.sms = sms; + return this; + } + + /** + * Get sms + * + * @return sms + */ + @JsonProperty(JSON_PROPERTY_SMS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseSmsDto getSms() { + return sms; + } + + @JsonProperty(JSON_PROPERTY_SMS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSms(InitiateVerificationResponseSmsDto sms) { + this.sms = sms; + } + + public InitiateVerificationResponseDto flashCall( + InitiateVerificationResponseFlashCallDto flashCall) { + this.flashCall = flashCall; + return this; + } + + /** + * Get flashCall + * + * @return flashCall + */ + @JsonProperty(JSON_PROPERTY_FLASH_CALL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseFlashCallDto getFlashCall() { + return flashCall; + } + + @JsonProperty(JSON_PROPERTY_FLASH_CALL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashCall(InitiateVerificationResponseFlashCallDto flashCall) { + this.flashCall = flashCall; + } + + public InitiateVerificationResponseDto callout(InitiateVerificationResponseCalloutDto callout) { + this.callout = callout; + return this; + } + + /** + * Get callout + * + * @return callout + */ + @JsonProperty(JSON_PROPERTY_CALLOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseCalloutDto getCallout() { + return callout; + } + + @JsonProperty(JSON_PROPERTY_CALLOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallout(InitiateVerificationResponseCalloutDto callout) { + this.callout = callout; + } + + public InitiateVerificationResponseDto seamless( + InitiateVerificationResponseSeamlessDto seamless) { + this.seamless = seamless; + return this; + } + + /** + * Get seamless + * + * @return seamless + */ + @JsonProperty(JSON_PROPERTY_SEAMLESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseSeamlessDto getSeamless() { + return seamless; + } + + @JsonProperty(JSON_PROPERTY_SEAMLESS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSeamless(InitiateVerificationResponseSeamlessDto seamless) { + this.seamless = seamless; + } + + public InitiateVerificationResponseDto whatsapp( + InitiateVerificationResponseWhatsappDto whatsapp) { + this.whatsapp = whatsapp; + return this; + } + + /** + * Get whatsapp + * + * @return whatsapp + */ + @JsonProperty(JSON_PROPERTY_WHATSAPP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseWhatsappDto getWhatsapp() { + return whatsapp; + } + + @JsonProperty(JSON_PROPERTY_WHATSAPP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWhatsapp(InitiateVerificationResponseWhatsappDto whatsapp) { + this.whatsapp = whatsapp; + } + + public InitiateVerificationResponseDto auto(InitiateVerificationResponseAutoDto auto) { + this.auto = auto; + return this; + } + + /** + * Get auto + * + * @return auto + */ + @JsonProperty(JSON_PROPERTY_AUTO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseAutoDto getAuto() { + return auto; + } + + @JsonProperty(JSON_PROPERTY_AUTO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAuto(InitiateVerificationResponseAutoDto auto) { + this.auto = auto; + } + + public InitiateVerificationResponseDto earlyReject(Boolean earlyReject) { + this.earlyReject = earlyReject; + return this; + } + + /** + * Whether or not verification has been early rejected. + * + * @return earlyReject + */ + @JsonProperty(JSON_PROPERTY_EARLY_REJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getEarlyReject() { + return earlyReject; + } + + @JsonProperty(JSON_PROPERTY_EARLY_REJECT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEarlyReject(Boolean earlyReject) { + this.earlyReject = earlyReject; + } + + public InitiateVerificationResponseDto earlyRejectMessage(String earlyRejectMessage) { + this.earlyRejectMessage = earlyRejectMessage; + return this; + } + + /** + * In case verification has been early rejected a detailed reason. + * + * @return earlyRejectMessage + */ + @JsonProperty(JSON_PROPERTY_EARLY_REJECT_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEarlyRejectMessage() { + return earlyRejectMessage; + } + + @JsonProperty(JSON_PROPERTY_EARLY_REJECT_MESSAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEarlyRejectMessage(String earlyRejectMessage) { + this.earlyRejectMessage = earlyRejectMessage; + } + + public InitiateVerificationResponseDto maxPrice( + InitiateVerificationResponseMaxPriceDto maxPrice) { + this.maxPrice = maxPrice; + return this; + } + + /** + * Get maxPrice + * + * @return maxPrice + */ + @JsonProperty(JSON_PROPERTY_MAX_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public InitiateVerificationResponseMaxPriceDto getMaxPrice() { + return maxPrice; + } + + @JsonProperty(JSON_PROPERTY_MAX_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMaxPrice(InitiateVerificationResponseMaxPriceDto maxPrice) { + this.maxPrice = maxPrice; + } + + public InitiateVerificationResponseDto links(List links) { + this.links = links; + return this; + } + + public InitiateVerificationResponseDto addLinksItem(VerificationResourceLinkDto linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * + * @return links + */ + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLinks(List links) { + this.links = links; + } + + /** Return true if this InitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InitiateVerificationResponseDto initiateVerificationResponse = + (InitiateVerificationResponseDto) o; + return Objects.equals(this.id, initiateVerificationResponse.id) + && Objects.equals(this.method, initiateVerificationResponse.method) + && Objects.equals(this.sms, initiateVerificationResponse.sms) + && Objects.equals(this.flashCall, initiateVerificationResponse.flashCall) + && Objects.equals(this.callout, initiateVerificationResponse.callout) + && Objects.equals(this.seamless, initiateVerificationResponse.seamless) + && Objects.equals(this.whatsapp, initiateVerificationResponse.whatsapp) + && Objects.equals(this.auto, initiateVerificationResponse.auto) + && Objects.equals(this.earlyReject, initiateVerificationResponse.earlyReject) + && Objects.equals(this.earlyRejectMessage, initiateVerificationResponse.earlyRejectMessage) + && Objects.equals(this.maxPrice, initiateVerificationResponse.maxPrice) + && Objects.equals(this.links, initiateVerificationResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + method, + sms, + flashCall, + callout, + seamless, + whatsapp, + auto, + earlyReject, + earlyRejectMessage, + maxPrice, + links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InitiateVerificationResponseDto {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" sms: ").append(toIndentedString(sms)).append("\n"); + sb.append(" flashCall: ").append(toIndentedString(flashCall)).append("\n"); + sb.append(" callout: ").append(toIndentedString(callout)).append("\n"); + sb.append(" seamless: ").append(toIndentedString(seamless)).append("\n"); + sb.append(" whatsapp: ").append(toIndentedString(whatsapp)).append("\n"); + sb.append(" auto: ").append(toIndentedString(auto)).append("\n"); + sb.append(" earlyReject: ").append(toIndentedString(earlyReject)).append("\n"); + sb.append(" earlyRejectMessage: ").append(toIndentedString(earlyRejectMessage)).append("\n"); + sb.append(" maxPrice: ").append(toIndentedString(maxPrice)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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/verification/models/dto/v1/InitiateVerificationResponseFlashCallDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseFlashCallDto.java new file mode 100644 index 00000000..39310de7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseFlashCallDto.java @@ -0,0 +1,228 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseFlashCallDto + .InitiateVerificationResponseFlashCallDtoDeserializer.class) +@JsonSerialize( + using = + InitiateVerificationResponseFlashCallDto.InitiateVerificationResponseFlashCallDtoSerializer + .class) +public class InitiateVerificationResponseFlashCallDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseFlashCallDto.class.getName()); + + public static class InitiateVerificationResponseFlashCallDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseFlashCallDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseFlashCallDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseFlashCallDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseFlashCallDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseFlashCallDtoDeserializer() { + this(InitiateVerificationResponseFlashCallDto.class); + } + + public InitiateVerificationResponseFlashCallDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseFlashCallDto 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 FlashCallInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (FlashCallInitiateVerificationResponseDto.class.equals(Integer.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Long.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Float.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Double.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Boolean.class) + || FlashCallInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((FlashCallInitiateVerificationResponseDto.class.equals(Integer.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((FlashCallInitiateVerificationResponseDto.class.equals(Float.class) + || FlashCallInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (FlashCallInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (FlashCallInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(FlashCallInitiateVerificationResponseDto.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 'FlashCallInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'FlashCallInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseFlashCallDto ret = + new InitiateVerificationResponseFlashCallDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseFlashCallDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseFlashCallDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseFlashCallDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseFlashCallDto(FlashCallInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "FlashCallInitiateVerificationResponseDto", FlashCallInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseFlashCallDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseFlashCallDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: FlashCallInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + FlashCallInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be FlashCallInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: FlashCallInitiateVerificationResponseDto + * + * @return The actual instance (FlashCallInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `FlashCallInitiateVerificationResponseDto`. If the actual instance + * is not `FlashCallInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `FlashCallInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `FlashCallInitiateVerificationResponseDto` + */ + public FlashCallInitiateVerificationResponseDto getFlashCallInitiateVerificationResponseDto() + throws ClassCastException { + return (FlashCallInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseMaxPriceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseMaxPriceDto.java new file mode 100644 index 00000000..d41a05be --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseMaxPriceDto.java @@ -0,0 +1,214 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseMaxPriceDto.InitiateVerificationResponseMaxPriceDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResponseMaxPriceDto.InitiateVerificationResponseMaxPriceDtoSerializer + .class) +public class InitiateVerificationResponseMaxPriceDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseMaxPriceDto.class.getName()); + + public static class InitiateVerificationResponseMaxPriceDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseMaxPriceDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseMaxPriceDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseMaxPriceDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseMaxPriceDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseMaxPriceDtoDeserializer() { + this(InitiateVerificationResponseMaxPriceDto.class); + } + + public InitiateVerificationResponseMaxPriceDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseMaxPriceDto 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 MoneyDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MoneyDto.class.equals(Integer.class) + || MoneyDto.class.equals(Long.class) + || MoneyDto.class.equals(Float.class) + || MoneyDto.class.equals(Double.class) + || MoneyDto.class.equals(Boolean.class) + || MoneyDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MoneyDto.class.equals(Integer.class) || MoneyDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MoneyDto.class.equals(Float.class) || MoneyDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MoneyDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MoneyDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MoneyDto.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 'MoneyDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MoneyDto'", e); + } + + if (match == 1) { + InitiateVerificationResponseMaxPriceDto ret = new InitiateVerificationResponseMaxPriceDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseMaxPriceDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseMaxPriceDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseMaxPriceDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseMaxPriceDto(MoneyDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("MoneyDto", MoneyDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseMaxPriceDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseMaxPriceDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MoneyDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MoneyDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MoneyDto"); + } + + /** + * Get the actual instance, which can be the following: MoneyDto + * + * @return The actual instance (MoneyDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MoneyDto`. If the actual instance is not `MoneyDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MoneyDto` + * @throws ClassCastException if the instance is not `MoneyDto` + */ + public MoneyDto getMoneyDto() throws ClassCastException { + return (MoneyDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSeamlessDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSeamlessDto.java new file mode 100644 index 00000000..a4d1d868 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSeamlessDto.java @@ -0,0 +1,227 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseSeamlessDto.InitiateVerificationResponseSeamlessDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResponseSeamlessDto.InitiateVerificationResponseSeamlessDtoSerializer + .class) +public class InitiateVerificationResponseSeamlessDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseSeamlessDto.class.getName()); + + public static class InitiateVerificationResponseSeamlessDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseSeamlessDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseSeamlessDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseSeamlessDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseSeamlessDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseSeamlessDtoDeserializer() { + this(InitiateVerificationResponseSeamlessDto.class); + } + + public InitiateVerificationResponseSeamlessDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseSeamlessDto 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 SeamlessInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SeamlessInitiateVerificationResponseDto.class.equals(Integer.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Long.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Float.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Double.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Boolean.class) + || SeamlessInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SeamlessInitiateVerificationResponseDto.class.equals(Integer.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SeamlessInitiateVerificationResponseDto.class.equals(Float.class) + || SeamlessInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (SeamlessInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SeamlessInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(SeamlessInitiateVerificationResponseDto.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 'SeamlessInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'SeamlessInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseSeamlessDto ret = new InitiateVerificationResponseSeamlessDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseSeamlessDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseSeamlessDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseSeamlessDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseSeamlessDto(SeamlessInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "SeamlessInitiateVerificationResponseDto", SeamlessInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseSeamlessDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseSeamlessDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: SeamlessInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + SeamlessInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be SeamlessInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: SeamlessInitiateVerificationResponseDto + * + * @return The actual instance (SeamlessInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SeamlessInitiateVerificationResponseDto`. If the actual instance is + * not `SeamlessInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `SeamlessInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `SeamlessInitiateVerificationResponseDto` + */ + public SeamlessInitiateVerificationResponseDto getSeamlessInitiateVerificationResponseDto() + throws ClassCastException { + return (SeamlessInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSmsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSmsDto.java new file mode 100644 index 00000000..3d69299e --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseSmsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = InitiateVerificationResponseSmsDto.InitiateVerificationResponseSmsDtoDeserializer.class) +@JsonSerialize( + using = InitiateVerificationResponseSmsDto.InitiateVerificationResponseSmsDtoSerializer.class) +public class InitiateVerificationResponseSmsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseSmsDto.class.getName()); + + public static class InitiateVerificationResponseSmsDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseSmsDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseSmsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseSmsDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseSmsDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseSmsDtoDeserializer() { + this(InitiateVerificationResponseSmsDto.class); + } + + public InitiateVerificationResponseSmsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseSmsDto 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 SmsInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SmsInitiateVerificationResponseDto.class.equals(Integer.class) + || SmsInitiateVerificationResponseDto.class.equals(Long.class) + || SmsInitiateVerificationResponseDto.class.equals(Float.class) + || SmsInitiateVerificationResponseDto.class.equals(Double.class) + || SmsInitiateVerificationResponseDto.class.equals(Boolean.class) + || SmsInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SmsInitiateVerificationResponseDto.class.equals(Integer.class) + || SmsInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SmsInitiateVerificationResponseDto.class.equals(Float.class) + || SmsInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (SmsInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SmsInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(SmsInitiateVerificationResponseDto.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 'SmsInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'SmsInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseSmsDto ret = new InitiateVerificationResponseSmsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseSmsDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseSmsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseSmsDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseSmsDto(SmsInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("SmsInitiateVerificationResponseDto", SmsInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseSmsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseSmsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: SmsInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + SmsInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SmsInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: SmsInitiateVerificationResponseDto + * + * @return The actual instance (SmsInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SmsInitiateVerificationResponseDto`. If the actual instance is not + * `SmsInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `SmsInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `SmsInitiateVerificationResponseDto` + */ + public SmsInitiateVerificationResponseDto getSmsInitiateVerificationResponseDto() + throws ClassCastException { + return (SmsInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseWhatsappDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseWhatsappDto.java new file mode 100644 index 00000000..503620a7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/InitiateVerificationResponseWhatsappDto.java @@ -0,0 +1,227 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + InitiateVerificationResponseWhatsappDto.InitiateVerificationResponseWhatsappDtoDeserializer + .class) +@JsonSerialize( + using = + InitiateVerificationResponseWhatsappDto.InitiateVerificationResponseWhatsappDtoSerializer + .class) +public class InitiateVerificationResponseWhatsappDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(InitiateVerificationResponseWhatsappDto.class.getName()); + + public static class InitiateVerificationResponseWhatsappDtoSerializer + extends StdSerializer { + public InitiateVerificationResponseWhatsappDtoSerializer( + Class t) { + super(t); + } + + public InitiateVerificationResponseWhatsappDtoSerializer() { + this(null); + } + + @Override + public void serialize( + InitiateVerificationResponseWhatsappDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class InitiateVerificationResponseWhatsappDtoDeserializer + extends StdDeserializer { + public InitiateVerificationResponseWhatsappDtoDeserializer() { + this(InitiateVerificationResponseWhatsappDto.class); + } + + public InitiateVerificationResponseWhatsappDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public InitiateVerificationResponseWhatsappDto 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 WhatsappInitiateVerificationResponseDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (WhatsappInitiateVerificationResponseDto.class.equals(Integer.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Long.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Float.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Double.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Boolean.class) + || WhatsappInitiateVerificationResponseDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((WhatsappInitiateVerificationResponseDto.class.equals(Integer.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((WhatsappInitiateVerificationResponseDto.class.equals(Float.class) + || WhatsappInitiateVerificationResponseDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (WhatsappInitiateVerificationResponseDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (WhatsappInitiateVerificationResponseDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(WhatsappInitiateVerificationResponseDto.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 'WhatsappInitiateVerificationResponseDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'WhatsappInitiateVerificationResponseDto'", + e); + } + + if (match == 1) { + InitiateVerificationResponseWhatsappDto ret = new InitiateVerificationResponseWhatsappDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for InitiateVerificationResponseWhatsappDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public InitiateVerificationResponseWhatsappDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public InitiateVerificationResponseWhatsappDto() { + super("oneOf", Boolean.TRUE); + } + + public InitiateVerificationResponseWhatsappDto(WhatsappInitiateVerificationResponseDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "WhatsappInitiateVerificationResponseDto", WhatsappInitiateVerificationResponseDto.class); + JSONNavigator.registerDescendants( + InitiateVerificationResponseWhatsappDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return InitiateVerificationResponseWhatsappDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: WhatsappInitiateVerificationResponseDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + WhatsappInitiateVerificationResponseDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be WhatsappInitiateVerificationResponseDto"); + } + + /** + * Get the actual instance, which can be the following: WhatsappInitiateVerificationResponseDto + * + * @return The actual instance (WhatsappInitiateVerificationResponseDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `WhatsappInitiateVerificationResponseDto`. If the actual instance is + * not `WhatsappInitiateVerificationResponseDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `WhatsappInitiateVerificationResponseDto` + * @throws ClassCastException if the instance is not `WhatsappInitiateVerificationResponseDto` + */ + public WhatsappInitiateVerificationResponseDto getWhatsappInitiateVerificationResponseDto() + throws ClassCastException { + return (WhatsappInitiateVerificationResponseDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/MoneyDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/MoneyDto.java new file mode 100644 index 00000000..b24103b6 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/MoneyDto.java @@ -0,0 +1,145 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** MoneyDto */ +@JsonPropertyOrder({ + MoneyDto.JSON_PROPERTY_CURRENCY_ID, + MoneyDto.JSON_PROPERTY_AMOUNT, + MoneyDto.JSON_PROPERTY_FORMATTED +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class MoneyDto { + public static final String JSON_PROPERTY_CURRENCY_ID = "currencyId"; + private String currencyId; + + public static final String JSON_PROPERTY_AMOUNT = "amount"; + private Float amount; + + public static final String JSON_PROPERTY_FORMATTED = "formatted"; + private String formatted; + + public MoneyDto() {} + + public MoneyDto currencyId(String currencyId) { + this.currencyId = currencyId; + return this; + } + + /** + * Get currencyId + * + * @return currencyId + */ + @JsonProperty(JSON_PROPERTY_CURRENCY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCurrencyId() { + return currencyId; + } + + @JsonProperty(JSON_PROPERTY_CURRENCY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCurrencyId(String currencyId) { + this.currencyId = currencyId; + } + + public MoneyDto amount(Float amount) { + this.amount = amount; + return this; + } + + /** + * Get amount + * + * @return amount + */ + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Float getAmount() { + return amount; + } + + @JsonProperty(JSON_PROPERTY_AMOUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setAmount(Float amount) { + this.amount = amount; + } + + public MoneyDto formatted(String formatted) { + this.formatted = formatted; + return this; + } + + /** + * Get formatted + * + * @return formatted + */ + @JsonProperty(JSON_PROPERTY_FORMATTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getFormatted() { + return formatted; + } + + @JsonProperty(JSON_PROPERTY_FORMATTED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFormatted(String formatted) { + this.formatted = formatted; + } + + /** 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.currencyId, money.currencyId) + && Objects.equals(this.amount, money.amount) + && Objects.equals(this.formatted, money.formatted); + } + + @Override + public int hashCode() { + return Objects.hash(currencyId, amount, formatted); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MoneyDto {\n"); + sb.append(" currencyId: ").append(toIndentedString(currencyId)).append("\n"); + sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); + sb.append(" formatted: ").append(toIndentedString(formatted)).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/verification/models/dto/v1/SeamlessInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessInitiateVerificationResponseDto.java new file mode 100644 index 00000000..44e72f99 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessInitiateVerificationResponseDto.java @@ -0,0 +1,119 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SeamlessInitiateVerificationResponseDto */ +@JsonPropertyOrder({ + SeamlessInitiateVerificationResponseDto.JSON_PROPERTY_TARGET_URI, + SeamlessInitiateVerificationResponseDto.JSON_PROPERTY_SUB_VERIFICATION_ID +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SeamlessInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_TARGET_URI = "targetUri"; + private String targetUri; + + public static final String JSON_PROPERTY_SUB_VERIFICATION_ID = "subVerificationId"; + private String subVerificationId; + + public SeamlessInitiateVerificationResponseDto() {} + + public SeamlessInitiateVerificationResponseDto targetUri(String targetUri) { + this.targetUri = targetUri; + return this; + } + + /** + * Target that client device should redirect to. + * + * @return targetUri + */ + @JsonProperty(JSON_PROPERTY_TARGET_URI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTargetUri() { + return targetUri; + } + + @JsonProperty(JSON_PROPERTY_TARGET_URI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTargetUri(String targetUri) { + this.targetUri = targetUri; + } + + public SeamlessInitiateVerificationResponseDto subVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + return this; + } + + /** + * Get subVerificationId + * + * @return subVerificationId + */ + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSubVerificationId() { + return subVerificationId; + } + + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + } + + /** Return true if this SeamlessInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SeamlessInitiateVerificationResponseDto seamlessInitiateVerificationResponse = + (SeamlessInitiateVerificationResponseDto) o; + return Objects.equals(this.targetUri, seamlessInitiateVerificationResponse.targetUri) + && Objects.equals( + this.subVerificationId, seamlessInitiateVerificationResponse.subVerificationId); + } + + @Override + public int hashCode() { + return Objects.hash(targetUri, subVerificationId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SeamlessInitiateVerificationResponseDto {\n"); + sb.append(" targetUri: ").append(toIndentedString(targetUri)).append("\n"); + sb.append(" subVerificationId: ").append(toIndentedString(subVerificationId)).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/verification/models/dto/v1/SeamlessOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessOptionsDto.java new file mode 100644 index 00000000..cdb04527 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SeamlessOptionsDto.java @@ -0,0 +1,87 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SeamlessOptionsDto */ +@JsonPropertyOrder({SeamlessOptionsDto.JSON_PROPERTY_END_USER_IP}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SeamlessOptionsDto { + public static final String JSON_PROPERTY_END_USER_IP = "endUserIp"; + private String endUserIp; + + public SeamlessOptionsDto() {} + + public SeamlessOptionsDto endUserIp(String endUserIp) { + this.endUserIp = endUserIp; + return this; + } + + /** + * Get endUserIp + * + * @return endUserIp + */ + @JsonProperty(JSON_PROPERTY_END_USER_IP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getEndUserIp() { + return endUserIp; + } + + @JsonProperty(JSON_PROPERTY_END_USER_IP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setEndUserIp(String endUserIp) { + this.endUserIp = endUserIp; + } + + /** Return true if this SeamlessOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SeamlessOptionsDto seamlessOptions = (SeamlessOptionsDto) o; + return Objects.equals(this.endUserIp, seamlessOptions.endUserIp); + } + + @Override + public int hashCode() { + return Objects.hash(endUserIp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SeamlessOptionsDto {\n"); + sb.append(" endUserIp: ").append(toIndentedString(endUserIp)).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/verification/models/dto/v1/ServiceReplyDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/ServiceReplyDto.java new file mode 100644 index 00000000..b3722cbb --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/ServiceReplyDto.java @@ -0,0 +1,145 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** ServiceReplyDto */ +@JsonPropertyOrder({ + ServiceReplyDto.JSON_PROPERTY_RESULT, + ServiceReplyDto.JSON_PROPERTY_MESSAGE, + ServiceReplyDto.JSON_PROPERTY_STACK_TRACE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class ServiceReplyDto { + public static final String JSON_PROPERTY_RESULT = "result"; + private Integer result; + + public static final String JSON_PROPERTY_MESSAGE = "message"; + private String message; + + public static final String JSON_PROPERTY_STACK_TRACE = "stackTrace"; + private String stackTrace; + + public ServiceReplyDto() {} + + public ServiceReplyDto result(Integer result) { + this.result = result; + return this; + } + + /** + * Get result + * + * @return result + */ + @JsonProperty(JSON_PROPERTY_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getResult() { + return result; + } + + @JsonProperty(JSON_PROPERTY_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setResult(Integer result) { + this.result = result; + } + + public ServiceReplyDto 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 ServiceReplyDto stackTrace(String stackTrace) { + this.stackTrace = stackTrace; + return this; + } + + /** + * Get stackTrace + * + * @return stackTrace + */ + @JsonProperty(JSON_PROPERTY_STACK_TRACE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getStackTrace() { + return stackTrace; + } + + @JsonProperty(JSON_PROPERTY_STACK_TRACE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setStackTrace(String stackTrace) { + this.stackTrace = stackTrace; + } + + /** Return true if this ServiceReply object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServiceReplyDto serviceReply = (ServiceReplyDto) o; + return Objects.equals(this.result, serviceReply.result) + && Objects.equals(this.message, serviceReply.message) + && Objects.equals(this.stackTrace, serviceReply.stackTrace); + } + + @Override + public int hashCode() { + return Objects.hash(result, message, stackTrace); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServiceReplyDto {\n"); + sb.append(" result: ").append(toIndentedString(result)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" stackTrace: ").append(toIndentedString(stackTrace)).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/verification/models/dto/v1/SimSwapResourceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResourceDto.java new file mode 100644 index 00000000..a853fd45 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResourceDto.java @@ -0,0 +1,87 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SimSwapResourceDto */ +@JsonPropertyOrder({SimSwapResourceDto.JSON_PROPERTY_NUMBER}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SimSwapResourceDto { + public static final String JSON_PROPERTY_NUMBER = "number"; + private String number; + + public SimSwapResourceDto() {} + + public SimSwapResourceDto number(String number) { + this.number = number; + return this; + } + + /** + * MSISDN to verify with sim swamp service. + * + * @return number + */ + @JsonProperty(JSON_PROPERTY_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getNumber() { + return number; + } + + @JsonProperty(JSON_PROPERTY_NUMBER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNumber(String number) { + this.number = number; + } + + /** Return true if this SimSwapResource object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SimSwapResourceDto simSwapResource = (SimSwapResourceDto) o; + return Objects.equals(this.number, simSwapResource.number); + } + + @Override + public int hashCode() { + return Objects.hash(number); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SimSwapResourceDto {\n"); + sb.append(" number: ").append(toIndentedString(number)).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/verification/models/dto/v1/SimSwapResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResponseDto.java new file mode 100644 index 00000000..559449a7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SimSwapResponseDto.java @@ -0,0 +1,146 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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.Objects; + +/** SimSwapResponseDto */ +@JsonPropertyOrder({ + SimSwapResponseDto.JSON_PROPERTY_ID, + SimSwapResponseDto.JSON_PROPERTY_SWAPPED, + SimSwapResponseDto.JSON_PROPERTY_SWAP_DATE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SimSwapResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_SWAPPED = "swapped"; + private Boolean swapped; + + public static final String JSON_PROPERTY_SWAP_DATE = "swapDate"; + private OffsetDateTime swapDate; + + public SimSwapResponseDto() {} + + public SimSwapResponseDto id(String id) { + this.id = id; + return this; + } + + /** + * Process identifier. + * + * @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 SimSwapResponseDto swapped(Boolean swapped) { + this.swapped = swapped; + return this; + } + + /** + * Result of SIM swap detection process. + * + * @return swapped + */ + @JsonProperty(JSON_PROPERTY_SWAPPED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getSwapped() { + return swapped; + } + + @JsonProperty(JSON_PROPERTY_SWAPPED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSwapped(Boolean swapped) { + this.swapped = swapped; + } + + public SimSwapResponseDto swapDate(OffsetDateTime swapDate) { + this.swapDate = swapDate; + return this; + } + + /** + * Time of last SIM card swap. + * + * @return swapDate + */ + @JsonProperty(JSON_PROPERTY_SWAP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getSwapDate() { + return swapDate; + } + + @JsonProperty(JSON_PROPERTY_SWAP_DATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSwapDate(OffsetDateTime swapDate) { + this.swapDate = swapDate; + } + + /** Return true if this SimSwapResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SimSwapResponseDto simSwapResponse = (SimSwapResponseDto) o; + return Objects.equals(this.id, simSwapResponse.id) + && Objects.equals(this.swapped, simSwapResponse.swapped) + && Objects.equals(this.swapDate, simSwapResponse.swapDate); + } + + @Override + public int hashCode() { + return Objects.hash(id, swapped, swapDate); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SimSwapResponseDto {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" swapped: ").append(toIndentedString(swapped)).append("\n"); + sb.append(" swapDate: ").append(toIndentedString(swapDate)).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/verification/models/dto/v1/SmsInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsInitiateVerificationResponseDto.java new file mode 100644 index 00000000..b3453296 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsInitiateVerificationResponseDto.java @@ -0,0 +1,243 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SmsInitiateVerificationResponseDto */ +@JsonPropertyOrder({ + SmsInitiateVerificationResponseDto.JSON_PROPERTY_TEMPLATE, + SmsInitiateVerificationResponseDto.JSON_PROPERTY_INTERCEPTION_TIMEOUT, + SmsInitiateVerificationResponseDto.JSON_PROPERTY_CODE, + SmsInitiateVerificationResponseDto.JSON_PROPERTY_CODE_MASK, + SmsInitiateVerificationResponseDto.JSON_PROPERTY_SUB_VERIFICATION_ID, + SmsInitiateVerificationResponseDto.JSON_PROPERTY_LINKS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SmsInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_TEMPLATE = "template"; + private String template; + + public static final String JSON_PROPERTY_INTERCEPTION_TIMEOUT = "interceptionTimeout"; + private Integer interceptionTimeout; + + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_CODE_MASK = "codeMask"; + private String codeMask; + + public static final String JSON_PROPERTY_SUB_VERIFICATION_ID = "subVerificationId"; + private String subVerificationId; + + public static final String JSON_PROPERTY_LINKS = "_links"; + private List links; + + public SmsInitiateVerificationResponseDto() {} + + public SmsInitiateVerificationResponseDto template(String template) { + this.template = template; + return this; + } + + /** + * Regular expression pattern used to extract OPT code from SMS. + * + * @return template + */ + @JsonProperty(JSON_PROPERTY_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTemplate() { + return template; + } + + @JsonProperty(JSON_PROPERTY_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTemplate(String template) { + this.template = template; + } + + public SmsInitiateVerificationResponseDto interceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + return this; + } + + /** + * Amount of seconds that client should be waiting for the SMS. + * + * @return interceptionTimeout + */ + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getInterceptionTimeout() { + return interceptionTimeout; + } + + @JsonProperty(JSON_PROPERTY_INTERCEPTION_TIMEOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setInterceptionTimeout(Integer interceptionTimeout) { + this.interceptionTimeout = interceptionTimeout; + } + + public SmsInitiateVerificationResponseDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 SmsInitiateVerificationResponseDto codeMask(String codeMask) { + this.codeMask = codeMask; + return this; + } + + /** + * Get codeMask + * + * @return codeMask + */ + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeMask() { + return codeMask; + } + + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeMask(String codeMask) { + this.codeMask = codeMask; + } + + public SmsInitiateVerificationResponseDto subVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + return this; + } + + /** + * Get subVerificationId + * + * @return subVerificationId + */ + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSubVerificationId() { + return subVerificationId; + } + + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + } + + public SmsInitiateVerificationResponseDto links(List links) { + this.links = links; + return this; + } + + public SmsInitiateVerificationResponseDto addLinksItem(VerificationResourceLinkDto linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * + * @return links + */ + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLinks(List links) { + this.links = links; + } + + /** Return true if this SmsInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SmsInitiateVerificationResponseDto smsInitiateVerificationResponse = + (SmsInitiateVerificationResponseDto) o; + return Objects.equals(this.template, smsInitiateVerificationResponse.template) + && Objects.equals( + this.interceptionTimeout, smsInitiateVerificationResponse.interceptionTimeout) + && Objects.equals(this.code, smsInitiateVerificationResponse.code) + && Objects.equals(this.codeMask, smsInitiateVerificationResponse.codeMask) + && Objects.equals(this.subVerificationId, smsInitiateVerificationResponse.subVerificationId) + && Objects.equals(this.links, smsInitiateVerificationResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(template, interceptionTimeout, code, codeMask, subVerificationId, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsInitiateVerificationResponseDto {\n"); + sb.append(" template: ").append(toIndentedString(template)).append("\n"); + sb.append(" interceptionTimeout: ") + .append(toIndentedString(interceptionTimeout)) + .append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" codeMask: ").append(toIndentedString(codeMask)).append("\n"); + sb.append(" subVerificationId: ").append(toIndentedString(subVerificationId)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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/verification/models/dto/v1/SmsOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsOptionsDto.java new file mode 100644 index 00000000..c9894191 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsOptionsDto.java @@ -0,0 +1,231 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SmsOptionsDto */ +@JsonPropertyOrder({ + SmsOptionsDto.JSON_PROPERTY_CODE, + SmsOptionsDto.JSON_PROPERTY_CODE_TYPE, + SmsOptionsDto.JSON_PROPERTY_CODE_MASK, + SmsOptionsDto.JSON_PROPERTY_TEMPLATE, + SmsOptionsDto.JSON_PROPERTY_READ_PERMISSION_TOKEN, + SmsOptionsDto.JSON_PROPERTY_APPLICATION_HASH +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SmsOptionsDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_CODE_TYPE = "codeType"; + private String codeType; + + public static final String JSON_PROPERTY_CODE_MASK = "codeMask"; + private String codeMask; + + public static final String JSON_PROPERTY_TEMPLATE = "template"; + private String template; + + public static final String JSON_PROPERTY_READ_PERMISSION_TOKEN = "readPermissionToken"; + private String readPermissionToken; + + public static final String JSON_PROPERTY_APPLICATION_HASH = "applicationHash"; + private String applicationHash; + + public SmsOptionsDto() {} + + public SmsOptionsDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 SmsOptionsDto codeType(String codeType) { + this.codeType = codeType; + return this; + } + + /** + * Get codeType + * + * @return codeType + */ + @JsonProperty(JSON_PROPERTY_CODE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeType() { + return codeType; + } + + @JsonProperty(JSON_PROPERTY_CODE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeType(String codeType) { + this.codeType = codeType; + } + + public SmsOptionsDto codeMask(String codeMask) { + this.codeMask = codeMask; + return this; + } + + /** + * Get codeMask + * + * @return codeMask + */ + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeMask() { + return codeMask; + } + + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeMask(String codeMask) { + this.codeMask = codeMask; + } + + public SmsOptionsDto template(String template) { + this.template = template; + return this; + } + + /** + * Get template + * + * @return template + */ + @JsonProperty(JSON_PROPERTY_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getTemplate() { + return template; + } + + @JsonProperty(JSON_PROPERTY_TEMPLATE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTemplate(String template) { + this.template = template; + } + + public SmsOptionsDto readPermissionToken(String readPermissionToken) { + this.readPermissionToken = readPermissionToken; + return this; + } + + /** + * Get readPermissionToken + * + * @return readPermissionToken + */ + @JsonProperty(JSON_PROPERTY_READ_PERMISSION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReadPermissionToken() { + return readPermissionToken; + } + + @JsonProperty(JSON_PROPERTY_READ_PERMISSION_TOKEN) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReadPermissionToken(String readPermissionToken) { + this.readPermissionToken = readPermissionToken; + } + + public SmsOptionsDto applicationHash(String applicationHash) { + this.applicationHash = applicationHash; + return this; + } + + /** + * Get applicationHash + * + * @return applicationHash + */ + @JsonProperty(JSON_PROPERTY_APPLICATION_HASH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getApplicationHash() { + return applicationHash; + } + + @JsonProperty(JSON_PROPERTY_APPLICATION_HASH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setApplicationHash(String applicationHash) { + this.applicationHash = applicationHash; + } + + /** Return true if this SmsOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SmsOptionsDto smsOptions = (SmsOptionsDto) o; + return Objects.equals(this.code, smsOptions.code) + && Objects.equals(this.codeType, smsOptions.codeType) + && Objects.equals(this.codeMask, smsOptions.codeMask) + && Objects.equals(this.template, smsOptions.template) + && Objects.equals(this.readPermissionToken, smsOptions.readPermissionToken) + && Objects.equals(this.applicationHash, smsOptions.applicationHash); + } + + @Override + public int hashCode() { + return Objects.hash(code, codeType, codeMask, template, readPermissionToken, applicationHash); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsOptionsDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" codeType: ").append(toIndentedString(codeType)).append("\n"); + sb.append(" codeMask: ").append(toIndentedString(codeMask)).append("\n"); + sb.append(" template: ").append(toIndentedString(template)).append("\n"); + sb.append(" readPermissionToken: ") + .append(toIndentedString(readPermissionToken)) + .append("\n"); + sb.append(" applicationHash: ").append(toIndentedString(applicationHash)).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/verification/models/dto/v1/SmsVerificationReportRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsVerificationReportRequestDto.java new file mode 100644 index 00000000..8bf1f4de --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/SmsVerificationReportRequestDto.java @@ -0,0 +1,118 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** SmsVerificationReportRequestDto */ +@JsonPropertyOrder({ + SmsVerificationReportRequestDto.JSON_PROPERTY_CODE, + SmsVerificationReportRequestDto.JSON_PROPERTY_CLI +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class SmsVerificationReportRequestDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_CLI = "cli"; + private String cli; + + public SmsVerificationReportRequestDto() {} + + public SmsVerificationReportRequestDto code(String code) { + this.code = code; + return this; + } + + /** + * OTP code read from SMS. + * + * @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 SmsVerificationReportRequestDto cli(String cli) { + this.cli = cli; + return this; + } + + /** + * Get cli + * + * @return cli + */ + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCli() { + return cli; + } + + @JsonProperty(JSON_PROPERTY_CLI) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCli(String cli) { + this.cli = cli; + } + + /** Return true if this SmsVerificationReportRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SmsVerificationReportRequestDto smsVerificationReportRequest = + (SmsVerificationReportRequestDto) o; + return Objects.equals(this.code, smsVerificationReportRequest.code) + && Objects.equals(this.cli, smsVerificationReportRequest.cli); + } + + @Override + public int hashCode() { + return Objects.hash(code, cli); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SmsVerificationReportRequestDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" cli: ").append(toIndentedString(cli)).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/verification/models/dto/v1/VerificationMetadataCellularDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataCellularDto.java new file mode 100644 index 00000000..088fdbd8 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataCellularDto.java @@ -0,0 +1,118 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationMetadataCellularDto */ +@JsonPropertyOrder({ + VerificationMetadataCellularDto.JSON_PROPERTY_SIGNAL_LEVEL, + VerificationMetadataCellularDto.JSON_PROPERTY_TYPE +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationMetadataCellularDto { + public static final String JSON_PROPERTY_SIGNAL_LEVEL = "signalLevel"; + private Integer signalLevel; + + public static final String JSON_PROPERTY_TYPE = "type"; + private String type; + + public VerificationMetadataCellularDto() {} + + public VerificationMetadataCellularDto signalLevel(Integer signalLevel) { + this.signalLevel = signalLevel; + return this; + } + + /** + * Get signalLevel + * + * @return signalLevel + */ + @JsonProperty(JSON_PROPERTY_SIGNAL_LEVEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getSignalLevel() { + return signalLevel; + } + + @JsonProperty(JSON_PROPERTY_SIGNAL_LEVEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSignalLevel(Integer signalLevel) { + this.signalLevel = signalLevel; + } + + public VerificationMetadataCellularDto 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; + } + + /** Return true if this VerificationMetadataCellular object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationMetadataCellularDto verificationMetadataCellular = + (VerificationMetadataCellularDto) o; + return Objects.equals(this.signalLevel, verificationMetadataCellular.signalLevel) + && Objects.equals(this.type, verificationMetadataCellular.type); + } + + @Override + public int hashCode() { + return Objects.hash(signalLevel, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationMetadataCellularDto {\n"); + sb.append(" signalLevel: ").append(toIndentedString(signalLevel)).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 "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDeviceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDeviceDto.java new file mode 100644 index 00000000..f6a346ce --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDeviceDto.java @@ -0,0 +1,211 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationMetadataDeviceDto.VerificationMetadataDeviceDtoDeserializer.class) +@JsonSerialize(using = VerificationMetadataDeviceDto.VerificationMetadataDeviceDtoSerializer.class) +public class VerificationMetadataDeviceDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(VerificationMetadataDeviceDto.class.getName()); + + public static class VerificationMetadataDeviceDtoSerializer + extends StdSerializer { + public VerificationMetadataDeviceDtoSerializer(Class t) { + super(t); + } + + public VerificationMetadataDeviceDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataDeviceDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataDeviceDtoDeserializer + extends StdDeserializer { + public VerificationMetadataDeviceDtoDeserializer() { + this(VerificationMetadataDeviceDto.class); + } + + public VerificationMetadataDeviceDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataDeviceDto 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 VerificationMetadataDeviceDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataDeviceDto.class.equals(Integer.class) + || VerificationMetadataDeviceDto.class.equals(Long.class) + || VerificationMetadataDeviceDto.class.equals(Float.class) + || VerificationMetadataDeviceDto.class.equals(Double.class) + || VerificationMetadataDeviceDto.class.equals(Boolean.class) + || VerificationMetadataDeviceDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataDeviceDto.class.equals(Integer.class) + || VerificationMetadataDeviceDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataDeviceDto.class.equals(Float.class) + || VerificationMetadataDeviceDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataDeviceDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataDeviceDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataDeviceDto.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 'VerificationMetadataDeviceDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'VerificationMetadataDeviceDto'", e); + } + + if (match == 1) { + VerificationMetadataDeviceDto ret = new VerificationMetadataDeviceDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataDeviceDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataDeviceDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataDeviceDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataDeviceDto(VerificationMetadataDeviceDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataDeviceDto", VerificationMetadataDeviceDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataDeviceDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataDeviceDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataDeviceDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataDeviceDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataDeviceDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataDeviceDto + * + * @return The actual instance (VerificationMetadataDeviceDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataDeviceDto`. If the actual instance is not + * `VerificationMetadataDeviceDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataDeviceDto` + * @throws ClassCastException if the instance is not `VerificationMetadataDeviceDto` + */ + public VerificationMetadataDeviceDto getVerificationMetadataDeviceDto() + throws ClassCastException { + return (VerificationMetadataDeviceDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDto.java new file mode 100644 index 00000000..0b07dd5f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataDto.java @@ -0,0 +1,583 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationMetadataDto */ +@JsonPropertyOrder({ + VerificationMetadataDto.JSON_PROPERTY_OS, + VerificationMetadataDto.JSON_PROPERTY_DEVICE_ID, + VerificationMetadataDto.JSON_PROPERTY_PLATFORM, + VerificationMetadataDto.JSON_PROPERTY_SDK, + VerificationMetadataDto.JSON_PROPERTY_SDK_FLAVOR, + VerificationMetadataDto.JSON_PROPERTY_DEFAULT_LOCALE, + VerificationMetadataDto.JSON_PROPERTY_BATTERY_LEVEL, + VerificationMetadataDto.JSON_PROPERTY_SIM_CARDS_COUNT, + VerificationMetadataDto.JSON_PROPERTY_PERMISSIONS, + VerificationMetadataDto.JSON_PROPERTY_DEVICE, + VerificationMetadataDto.JSON_PROPERTY_SIM, + VerificationMetadataDto.JSON_PROPERTY_OPERATOR, + VerificationMetadataDto.JSON_PROPERTY_NETWORK_INFO, + VerificationMetadataDto.JSON_PROPERTY_SIM_CARDS_INFO, + VerificationMetadataDto.JSON_PROPERTY_CLIENT_PRODUCT_ID, + VerificationMetadataDto.JSON_PROPERTY_FIRST_ATTEMPT, + VerificationMetadataDto.JSON_PROPERTY_PURPOSE, + VerificationMetadataDto.JSON_PROPERTY_OTHER +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationMetadataDto { + public static final String JSON_PROPERTY_OS = "os"; + private String os; + + public static final String JSON_PROPERTY_DEVICE_ID = "deviceId"; + private String deviceId; + + public static final String JSON_PROPERTY_PLATFORM = "platform"; + private String platform; + + public static final String JSON_PROPERTY_SDK = "sdk"; + private String sdk; + + public static final String JSON_PROPERTY_SDK_FLAVOR = "sdkFlavor"; + private String sdkFlavor; + + public static final String JSON_PROPERTY_DEFAULT_LOCALE = "defaultLocale"; + private String defaultLocale; + + public static final String JSON_PROPERTY_BATTERY_LEVEL = "batteryLevel"; + private String batteryLevel; + + public static final String JSON_PROPERTY_SIM_CARDS_COUNT = "simCardsCount"; + private Integer simCardsCount; + + public static final String JSON_PROPERTY_PERMISSIONS = "permissions"; + private VerificationMetadataPermissionsDto permissions; + + public static final String JSON_PROPERTY_DEVICE = "device"; + private VerificationMetadataDeviceDto device; + + public static final String JSON_PROPERTY_SIM = "sim"; + private VerificationMetadataSimDto sim; + + public static final String JSON_PROPERTY_OPERATOR = "operator"; + private VerificationMetadataOperatorDto operator; + + public static final String JSON_PROPERTY_NETWORK_INFO = "networkInfo"; + private VerificationMetadataNetworkInfoDto networkInfo; + + public static final String JSON_PROPERTY_SIM_CARDS_INFO = "simCardsInfo"; + private VerificationMetadataSimCardsInfoDto simCardsInfo; + + public static final String JSON_PROPERTY_CLIENT_PRODUCT_ID = "clientProductId"; + private String clientProductId; + + public static final String JSON_PROPERTY_FIRST_ATTEMPT = "firstAttempt"; + private Boolean firstAttempt; + + public static final String JSON_PROPERTY_PURPOSE = "purpose"; + private String purpose; + + public static final String JSON_PROPERTY_OTHER = "other"; + private String other; + + public VerificationMetadataDto() {} + + public VerificationMetadataDto os(String os) { + this.os = os; + return this; + } + + /** + * Get os + * + * @return os + */ + @JsonProperty(JSON_PROPERTY_OS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOs() { + return os; + } + + @JsonProperty(JSON_PROPERTY_OS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOs(String os) { + this.os = os; + } + + public VerificationMetadataDto deviceId(String deviceId) { + this.deviceId = deviceId; + return this; + } + + /** + * Get deviceId + * + * @return deviceId + */ + @JsonProperty(JSON_PROPERTY_DEVICE_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDeviceId() { + return deviceId; + } + + @JsonProperty(JSON_PROPERTY_DEVICE_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public VerificationMetadataDto platform(String platform) { + this.platform = platform; + return this; + } + + /** + * Get platform + * + * @return platform + */ + @JsonProperty(JSON_PROPERTY_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPlatform() { + return platform; + } + + @JsonProperty(JSON_PROPERTY_PLATFORM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPlatform(String platform) { + this.platform = platform; + } + + public VerificationMetadataDto sdk(String sdk) { + this.sdk = sdk; + return this; + } + + /** + * Get sdk + * + * @return sdk + */ + @JsonProperty(JSON_PROPERTY_SDK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSdk() { + return sdk; + } + + @JsonProperty(JSON_PROPERTY_SDK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSdk(String sdk) { + this.sdk = sdk; + } + + public VerificationMetadataDto sdkFlavor(String sdkFlavor) { + this.sdkFlavor = sdkFlavor; + return this; + } + + /** + * Get sdkFlavor + * + * @return sdkFlavor + */ + @JsonProperty(JSON_PROPERTY_SDK_FLAVOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSdkFlavor() { + return sdkFlavor; + } + + @JsonProperty(JSON_PROPERTY_SDK_FLAVOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSdkFlavor(String sdkFlavor) { + this.sdkFlavor = sdkFlavor; + } + + public VerificationMetadataDto defaultLocale(String defaultLocale) { + this.defaultLocale = defaultLocale; + return this; + } + + /** + * Get defaultLocale + * + * @return defaultLocale + */ + @JsonProperty(JSON_PROPERTY_DEFAULT_LOCALE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDefaultLocale() { + return defaultLocale; + } + + @JsonProperty(JSON_PROPERTY_DEFAULT_LOCALE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDefaultLocale(String defaultLocale) { + this.defaultLocale = defaultLocale; + } + + public VerificationMetadataDto batteryLevel(String batteryLevel) { + this.batteryLevel = batteryLevel; + return this; + } + + /** + * Get batteryLevel + * + * @return batteryLevel + */ + @JsonProperty(JSON_PROPERTY_BATTERY_LEVEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getBatteryLevel() { + return batteryLevel; + } + + @JsonProperty(JSON_PROPERTY_BATTERY_LEVEL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBatteryLevel(String batteryLevel) { + this.batteryLevel = batteryLevel; + } + + public VerificationMetadataDto simCardsCount(Integer simCardsCount) { + this.simCardsCount = simCardsCount; + return this; + } + + /** + * Get simCardsCount + * + * @return simCardsCount + */ + @JsonProperty(JSON_PROPERTY_SIM_CARDS_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getSimCardsCount() { + return simCardsCount; + } + + @JsonProperty(JSON_PROPERTY_SIM_CARDS_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSimCardsCount(Integer simCardsCount) { + this.simCardsCount = simCardsCount; + } + + public VerificationMetadataDto permissions(VerificationMetadataPermissionsDto permissions) { + this.permissions = permissions; + return this; + } + + /** + * Get permissions + * + * @return permissions + */ + @JsonProperty(JSON_PROPERTY_PERMISSIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataPermissionsDto getPermissions() { + return permissions; + } + + @JsonProperty(JSON_PROPERTY_PERMISSIONS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPermissions(VerificationMetadataPermissionsDto permissions) { + this.permissions = permissions; + } + + public VerificationMetadataDto device(VerificationMetadataDeviceDto device) { + this.device = device; + return this; + } + + /** + * Get device + * + * @return device + */ + @JsonProperty(JSON_PROPERTY_DEVICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataDeviceDto getDevice() { + return device; + } + + @JsonProperty(JSON_PROPERTY_DEVICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setDevice(VerificationMetadataDeviceDto device) { + this.device = device; + } + + public VerificationMetadataDto sim(VerificationMetadataSimDto sim) { + this.sim = sim; + return this; + } + + /** + * Get sim + * + * @return sim + */ + @JsonProperty(JSON_PROPERTY_SIM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimDto getSim() { + return sim; + } + + @JsonProperty(JSON_PROPERTY_SIM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSim(VerificationMetadataSimDto sim) { + this.sim = sim; + } + + public VerificationMetadataDto operator(VerificationMetadataOperatorDto operator) { + this.operator = operator; + return this; + } + + /** + * Get operator + * + * @return operator + */ + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataOperatorDto getOperator() { + return operator; + } + + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperator(VerificationMetadataOperatorDto operator) { + this.operator = operator; + } + + public VerificationMetadataDto networkInfo(VerificationMetadataNetworkInfoDto networkInfo) { + this.networkInfo = networkInfo; + return this; + } + + /** + * Get networkInfo + * + * @return networkInfo + */ + @JsonProperty(JSON_PROPERTY_NETWORK_INFO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataNetworkInfoDto getNetworkInfo() { + return networkInfo; + } + + @JsonProperty(JSON_PROPERTY_NETWORK_INFO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setNetworkInfo(VerificationMetadataNetworkInfoDto networkInfo) { + this.networkInfo = networkInfo; + } + + public VerificationMetadataDto simCardsInfo(VerificationMetadataSimCardsInfoDto simCardsInfo) { + this.simCardsInfo = simCardsInfo; + return this; + } + + /** + * Get simCardsInfo + * + * @return simCardsInfo + */ + @JsonProperty(JSON_PROPERTY_SIM_CARDS_INFO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimCardsInfoDto getSimCardsInfo() { + return simCardsInfo; + } + + @JsonProperty(JSON_PROPERTY_SIM_CARDS_INFO) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSimCardsInfo(VerificationMetadataSimCardsInfoDto simCardsInfo) { + this.simCardsInfo = simCardsInfo; + } + + public VerificationMetadataDto clientProductId(String clientProductId) { + this.clientProductId = clientProductId; + return this; + } + + /** + * Get clientProductId + * + * @return clientProductId + */ + @JsonProperty(JSON_PROPERTY_CLIENT_PRODUCT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getClientProductId() { + return clientProductId; + } + + @JsonProperty(JSON_PROPERTY_CLIENT_PRODUCT_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setClientProductId(String clientProductId) { + this.clientProductId = clientProductId; + } + + public VerificationMetadataDto firstAttempt(Boolean firstAttempt) { + this.firstAttempt = firstAttempt; + return this; + } + + /** + * Get firstAttempt + * + * @return firstAttempt + */ + @JsonProperty(JSON_PROPERTY_FIRST_ATTEMPT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getFirstAttempt() { + return firstAttempt; + } + + @JsonProperty(JSON_PROPERTY_FIRST_ATTEMPT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFirstAttempt(Boolean firstAttempt) { + this.firstAttempt = firstAttempt; + } + + public VerificationMetadataDto purpose(String purpose) { + this.purpose = purpose; + return this; + } + + /** + * Get purpose + * + * @return purpose + */ + @JsonProperty(JSON_PROPERTY_PURPOSE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getPurpose() { + return purpose; + } + + @JsonProperty(JSON_PROPERTY_PURPOSE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPurpose(String purpose) { + this.purpose = purpose; + } + + public VerificationMetadataDto other(String other) { + this.other = other; + return this; + } + + /** + * Get other + * + * @return other + */ + @JsonProperty(JSON_PROPERTY_OTHER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getOther() { + return other; + } + + @JsonProperty(JSON_PROPERTY_OTHER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOther(String other) { + this.other = other; + } + + /** Return true if this VerificationMetadata object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationMetadataDto verificationMetadata = (VerificationMetadataDto) o; + return Objects.equals(this.os, verificationMetadata.os) + && Objects.equals(this.deviceId, verificationMetadata.deviceId) + && Objects.equals(this.platform, verificationMetadata.platform) + && Objects.equals(this.sdk, verificationMetadata.sdk) + && Objects.equals(this.sdkFlavor, verificationMetadata.sdkFlavor) + && Objects.equals(this.defaultLocale, verificationMetadata.defaultLocale) + && Objects.equals(this.batteryLevel, verificationMetadata.batteryLevel) + && Objects.equals(this.simCardsCount, verificationMetadata.simCardsCount) + && Objects.equals(this.permissions, verificationMetadata.permissions) + && Objects.equals(this.device, verificationMetadata.device) + && Objects.equals(this.sim, verificationMetadata.sim) + && Objects.equals(this.operator, verificationMetadata.operator) + && Objects.equals(this.networkInfo, verificationMetadata.networkInfo) + && Objects.equals(this.simCardsInfo, verificationMetadata.simCardsInfo) + && Objects.equals(this.clientProductId, verificationMetadata.clientProductId) + && Objects.equals(this.firstAttempt, verificationMetadata.firstAttempt) + && Objects.equals(this.purpose, verificationMetadata.purpose) + && Objects.equals(this.other, verificationMetadata.other); + } + + @Override + public int hashCode() { + return Objects.hash( + os, + deviceId, + platform, + sdk, + sdkFlavor, + defaultLocale, + batteryLevel, + simCardsCount, + permissions, + device, + sim, + operator, + networkInfo, + simCardsInfo, + clientProductId, + firstAttempt, + purpose, + other); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationMetadataDto {\n"); + sb.append(" os: ").append(toIndentedString(os)).append("\n"); + sb.append(" deviceId: ").append(toIndentedString(deviceId)).append("\n"); + sb.append(" platform: ").append(toIndentedString(platform)).append("\n"); + sb.append(" sdk: ").append(toIndentedString(sdk)).append("\n"); + sb.append(" sdkFlavor: ").append(toIndentedString(sdkFlavor)).append("\n"); + sb.append(" defaultLocale: ").append(toIndentedString(defaultLocale)).append("\n"); + sb.append(" batteryLevel: ").append(toIndentedString(batteryLevel)).append("\n"); + sb.append(" simCardsCount: ").append(toIndentedString(simCardsCount)).append("\n"); + sb.append(" permissions: ").append(toIndentedString(permissions)).append("\n"); + sb.append(" device: ").append(toIndentedString(device)).append("\n"); + sb.append(" sim: ").append(toIndentedString(sim)).append("\n"); + sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); + sb.append(" networkInfo: ").append(toIndentedString(networkInfo)).append("\n"); + sb.append(" simCardsInfo: ").append(toIndentedString(simCardsInfo)).append("\n"); + sb.append(" clientProductId: ").append(toIndentedString(clientProductId)).append("\n"); + sb.append(" firstAttempt: ").append(toIndentedString(firstAttempt)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).append("\n"); + sb.append(" other: ").append(toIndentedString(other)).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/verification/models/dto/v1/VerificationMetadataNetworkInfoCellularDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoCellularDto.java new file mode 100644 index 00000000..20fd9e3f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoCellularDto.java @@ -0,0 +1,222 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationMetadataNetworkInfoCellularDto + .VerificationMetadataNetworkInfoCellularDtoDeserializer.class) +@JsonSerialize( + using = + VerificationMetadataNetworkInfoCellularDto + .VerificationMetadataNetworkInfoCellularDtoSerializer.class) +public class VerificationMetadataNetworkInfoCellularDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataNetworkInfoCellularDto.class.getName()); + + public static class VerificationMetadataNetworkInfoCellularDtoSerializer + extends StdSerializer { + public VerificationMetadataNetworkInfoCellularDtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataNetworkInfoCellularDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataNetworkInfoCellularDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataNetworkInfoCellularDtoDeserializer + extends StdDeserializer { + public VerificationMetadataNetworkInfoCellularDtoDeserializer() { + this(VerificationMetadataNetworkInfoCellularDto.class); + } + + public VerificationMetadataNetworkInfoCellularDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataNetworkInfoCellularDto 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 VerificationMetadataCellularDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataCellularDto.class.equals(Integer.class) + || VerificationMetadataCellularDto.class.equals(Long.class) + || VerificationMetadataCellularDto.class.equals(Float.class) + || VerificationMetadataCellularDto.class.equals(Double.class) + || VerificationMetadataCellularDto.class.equals(Boolean.class) + || VerificationMetadataCellularDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataCellularDto.class.equals(Integer.class) + || VerificationMetadataCellularDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataCellularDto.class.equals(Float.class) + || VerificationMetadataCellularDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataCellularDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataCellularDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataCellularDto.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 'VerificationMetadataCellularDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'VerificationMetadataCellularDto'", e); + } + + if (match == 1) { + VerificationMetadataNetworkInfoCellularDto ret = + new VerificationMetadataNetworkInfoCellularDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataNetworkInfoCellularDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataNetworkInfoCellularDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataNetworkInfoCellularDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataNetworkInfoCellularDto(VerificationMetadataCellularDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataCellularDto", VerificationMetadataCellularDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataNetworkInfoCellularDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataNetworkInfoCellularDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataCellularDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataCellularDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataCellularDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataCellularDto + * + * @return The actual instance (VerificationMetadataCellularDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataCellularDto`. If the actual instance is not + * `VerificationMetadataCellularDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataCellularDto` + * @throws ClassCastException if the instance is not `VerificationMetadataCellularDto` + */ + public VerificationMetadataCellularDto getVerificationMetadataCellularDto() + throws ClassCastException { + return (VerificationMetadataCellularDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDataDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDataDto.java new file mode 100644 index 00000000..d57c2c3b --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDataDto.java @@ -0,0 +1,227 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationMetadataNetworkInfoDataDto.VerificationMetadataNetworkInfoDataDtoDeserializer + .class) +@JsonSerialize( + using = + VerificationMetadataNetworkInfoDataDto.VerificationMetadataNetworkInfoDataDtoSerializer + .class) +public class VerificationMetadataNetworkInfoDataDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataNetworkInfoDataDto.class.getName()); + + public static class VerificationMetadataNetworkInfoDataDtoSerializer + extends StdSerializer { + public VerificationMetadataNetworkInfoDataDtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataNetworkInfoDataDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataNetworkInfoDataDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataNetworkInfoDataDtoDeserializer + extends StdDeserializer { + public VerificationMetadataNetworkInfoDataDtoDeserializer() { + this(VerificationMetadataNetworkInfoDataDto.class); + } + + public VerificationMetadataNetworkInfoDataDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataNetworkInfoDataDto 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 VerificationMetadataNetworkInfoDataDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataNetworkInfoDataDto.class.equals(Integer.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Long.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Float.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Double.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Boolean.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataNetworkInfoDataDto.class.equals(Integer.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataNetworkInfoDataDto.class.equals(Float.class) + || VerificationMetadataNetworkInfoDataDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataNetworkInfoDataDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataNetworkInfoDataDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(VerificationMetadataNetworkInfoDataDto.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 'VerificationMetadataNetworkInfoDataDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'VerificationMetadataNetworkInfoDataDto'", + e); + } + + if (match == 1) { + VerificationMetadataNetworkInfoDataDto ret = new VerificationMetadataNetworkInfoDataDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataNetworkInfoDataDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataNetworkInfoDataDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataNetworkInfoDataDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataNetworkInfoDataDto(VerificationMetadataNetworkInfoDataDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "VerificationMetadataNetworkInfoDataDto", VerificationMetadataNetworkInfoDataDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataNetworkInfoDataDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataNetworkInfoDataDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataNetworkInfoDataDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataNetworkInfoDataDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be VerificationMetadataNetworkInfoDataDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataNetworkInfoDataDto + * + * @return The actual instance (VerificationMetadataNetworkInfoDataDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataNetworkInfoDataDto`. If the actual instance is + * not `VerificationMetadataNetworkInfoDataDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataNetworkInfoDataDto` + * @throws ClassCastException if the instance is not `VerificationMetadataNetworkInfoDataDto` + */ + public VerificationMetadataNetworkInfoDataDto getVerificationMetadataNetworkInfoDataDto() + throws ClassCastException { + return (VerificationMetadataNetworkInfoDataDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDto.java new file mode 100644 index 00000000..bd9dfbe6 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataNetworkInfoDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationMetadataNetworkInfoDto.VerificationMetadataNetworkInfoDtoDeserializer.class) +@JsonSerialize( + using = VerificationMetadataNetworkInfoDto.VerificationMetadataNetworkInfoDtoSerializer.class) +public class VerificationMetadataNetworkInfoDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataNetworkInfoDto.class.getName()); + + public static class VerificationMetadataNetworkInfoDtoSerializer + extends StdSerializer { + public VerificationMetadataNetworkInfoDtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataNetworkInfoDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataNetworkInfoDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataNetworkInfoDtoDeserializer + extends StdDeserializer { + public VerificationMetadataNetworkInfoDtoDeserializer() { + this(VerificationMetadataNetworkInfoDto.class); + } + + public VerificationMetadataNetworkInfoDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataNetworkInfoDto 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 VerificationMetadataNetworkInfoDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataNetworkInfoDto.class.equals(Integer.class) + || VerificationMetadataNetworkInfoDto.class.equals(Long.class) + || VerificationMetadataNetworkInfoDto.class.equals(Float.class) + || VerificationMetadataNetworkInfoDto.class.equals(Double.class) + || VerificationMetadataNetworkInfoDto.class.equals(Boolean.class) + || VerificationMetadataNetworkInfoDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataNetworkInfoDto.class.equals(Integer.class) + || VerificationMetadataNetworkInfoDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataNetworkInfoDto.class.equals(Float.class) + || VerificationMetadataNetworkInfoDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataNetworkInfoDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataNetworkInfoDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataNetworkInfoDto.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 'VerificationMetadataNetworkInfoDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'VerificationMetadataNetworkInfoDto'", + e); + } + + if (match == 1) { + VerificationMetadataNetworkInfoDto ret = new VerificationMetadataNetworkInfoDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataNetworkInfoDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataNetworkInfoDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataNetworkInfoDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataNetworkInfoDto(VerificationMetadataNetworkInfoDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataNetworkInfoDto", VerificationMetadataNetworkInfoDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataNetworkInfoDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataNetworkInfoDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataNetworkInfoDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataNetworkInfoDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataNetworkInfoDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataNetworkInfoDto + * + * @return The actual instance (VerificationMetadataNetworkInfoDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataNetworkInfoDto`. If the actual instance is not + * `VerificationMetadataNetworkInfoDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataNetworkInfoDto` + * @throws ClassCastException if the instance is not `VerificationMetadataNetworkInfoDto` + */ + public VerificationMetadataNetworkInfoDto getVerificationMetadataNetworkInfoDto() + throws ClassCastException { + return (VerificationMetadataNetworkInfoDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataOperatorDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataOperatorDto.java new file mode 100644 index 00000000..fc2dd64c --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataOperatorDto.java @@ -0,0 +1,214 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationMetadataOperatorDto.VerificationMetadataOperatorDtoDeserializer.class) +@JsonSerialize( + using = VerificationMetadataOperatorDto.VerificationMetadataOperatorDtoSerializer.class) +public class VerificationMetadataOperatorDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataOperatorDto.class.getName()); + + public static class VerificationMetadataOperatorDtoSerializer + extends StdSerializer { + public VerificationMetadataOperatorDtoSerializer(Class t) { + super(t); + } + + public VerificationMetadataOperatorDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataOperatorDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataOperatorDtoDeserializer + extends StdDeserializer { + public VerificationMetadataOperatorDtoDeserializer() { + this(VerificationMetadataOperatorDto.class); + } + + public VerificationMetadataOperatorDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataOperatorDto 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 VerificationMetadataOperatorDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataOperatorDto.class.equals(Integer.class) + || VerificationMetadataOperatorDto.class.equals(Long.class) + || VerificationMetadataOperatorDto.class.equals(Float.class) + || VerificationMetadataOperatorDto.class.equals(Double.class) + || VerificationMetadataOperatorDto.class.equals(Boolean.class) + || VerificationMetadataOperatorDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataOperatorDto.class.equals(Integer.class) + || VerificationMetadataOperatorDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataOperatorDto.class.equals(Float.class) + || VerificationMetadataOperatorDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataOperatorDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataOperatorDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataOperatorDto.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 'VerificationMetadataOperatorDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'VerificationMetadataOperatorDto'", e); + } + + if (match == 1) { + VerificationMetadataOperatorDto ret = new VerificationMetadataOperatorDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataOperatorDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataOperatorDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataOperatorDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataOperatorDto(VerificationMetadataOperatorDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataOperatorDto", VerificationMetadataOperatorDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataOperatorDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataOperatorDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataOperatorDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataOperatorDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataOperatorDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataOperatorDto + * + * @return The actual instance (VerificationMetadataOperatorDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataOperatorDto`. If the actual instance is not + * `VerificationMetadataOperatorDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataOperatorDto` + * @throws ClassCastException if the instance is not `VerificationMetadataOperatorDto` + */ + public VerificationMetadataOperatorDto getVerificationMetadataOperatorDto() + throws ClassCastException { + return (VerificationMetadataOperatorDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataPermissionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataPermissionsDto.java new file mode 100644 index 00000000..de7d746a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataPermissionsDto.java @@ -0,0 +1,217 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationMetadataPermissionsDto.VerificationMetadataPermissionsDtoDeserializer.class) +@JsonSerialize( + using = VerificationMetadataPermissionsDto.VerificationMetadataPermissionsDtoSerializer.class) +public class VerificationMetadataPermissionsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataPermissionsDto.class.getName()); + + public static class VerificationMetadataPermissionsDtoSerializer + extends StdSerializer { + public VerificationMetadataPermissionsDtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataPermissionsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataPermissionsDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataPermissionsDtoDeserializer + extends StdDeserializer { + public VerificationMetadataPermissionsDtoDeserializer() { + this(VerificationMetadataPermissionsDto.class); + } + + public VerificationMetadataPermissionsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataPermissionsDto 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 VerificationMetadataPermissionsDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataPermissionsDto.class.equals(Integer.class) + || VerificationMetadataPermissionsDto.class.equals(Long.class) + || VerificationMetadataPermissionsDto.class.equals(Float.class) + || VerificationMetadataPermissionsDto.class.equals(Double.class) + || VerificationMetadataPermissionsDto.class.equals(Boolean.class) + || VerificationMetadataPermissionsDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataPermissionsDto.class.equals(Integer.class) + || VerificationMetadataPermissionsDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataPermissionsDto.class.equals(Float.class) + || VerificationMetadataPermissionsDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataPermissionsDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataPermissionsDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataPermissionsDto.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 'VerificationMetadataPermissionsDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'VerificationMetadataPermissionsDto'", + e); + } + + if (match == 1) { + VerificationMetadataPermissionsDto ret = new VerificationMetadataPermissionsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataPermissionsDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataPermissionsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataPermissionsDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataPermissionsDto(VerificationMetadataPermissionsDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataPermissionsDto", VerificationMetadataPermissionsDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataPermissionsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataPermissionsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataPermissionsDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataPermissionsDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataPermissionsDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataPermissionsDto + * + * @return The actual instance (VerificationMetadataPermissionsDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataPermissionsDto`. If the actual instance is not + * `VerificationMetadataPermissionsDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataPermissionsDto` + * @throws ClassCastException if the instance is not `VerificationMetadataPermissionsDto` + */ + public VerificationMetadataPermissionsDto getVerificationMetadataPermissionsDto() + throws ClassCastException { + return (VerificationMetadataPermissionsDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollection1Dto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollection1Dto.java new file mode 100644 index 00000000..4769a056 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollection1Dto.java @@ -0,0 +1,224 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationMetadataSimCardInfoCollection1Dto + .VerificationMetadataSimCardInfoCollection1DtoDeserializer.class) +@JsonSerialize( + using = + VerificationMetadataSimCardInfoCollection1Dto + .VerificationMetadataSimCardInfoCollection1DtoSerializer.class) +public class VerificationMetadataSimCardInfoCollection1Dto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataSimCardInfoCollection1Dto.class.getName()); + + public static class VerificationMetadataSimCardInfoCollection1DtoSerializer + extends StdSerializer { + public VerificationMetadataSimCardInfoCollection1DtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataSimCardInfoCollection1DtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataSimCardInfoCollection1Dto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataSimCardInfoCollection1DtoDeserializer + extends StdDeserializer { + public VerificationMetadataSimCardInfoCollection1DtoDeserializer() { + this(VerificationMetadataSimCardInfoCollection1Dto.class); + } + + public VerificationMetadataSimCardInfoCollection1DtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataSimCardInfoCollection1Dto 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 VerificationMetadataSimCardInfoDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataSimCardInfoDto.class.equals(Integer.class) + || VerificationMetadataSimCardInfoDto.class.equals(Long.class) + || VerificationMetadataSimCardInfoDto.class.equals(Float.class) + || VerificationMetadataSimCardInfoDto.class.equals(Double.class) + || VerificationMetadataSimCardInfoDto.class.equals(Boolean.class) + || VerificationMetadataSimCardInfoDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataSimCardInfoDto.class.equals(Integer.class) + || VerificationMetadataSimCardInfoDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataSimCardInfoDto.class.equals(Float.class) + || VerificationMetadataSimCardInfoDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataSimCardInfoDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataSimCardInfoDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataSimCardInfoDto.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 'VerificationMetadataSimCardInfoDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'VerificationMetadataSimCardInfoDto'", + e); + } + + if (match == 1) { + VerificationMetadataSimCardInfoCollection1Dto ret = + new VerificationMetadataSimCardInfoCollection1Dto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataSimCardInfoCollection1Dto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataSimCardInfoCollection1Dto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataSimCardInfoCollection1Dto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataSimCardInfoCollection1Dto(VerificationMetadataSimCardInfoDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataSimCardInfoDto", VerificationMetadataSimCardInfoDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataSimCardInfoCollection1Dto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataSimCardInfoCollection1Dto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataSimCardInfoDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataSimCardInfoDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataSimCardInfoDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataSimCardInfoDto + * + * @return The actual instance (VerificationMetadataSimCardInfoDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataSimCardInfoDto`. If the actual instance is not + * `VerificationMetadataSimCardInfoDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataSimCardInfoDto` + * @throws ClassCastException if the instance is not `VerificationMetadataSimCardInfoDto` + */ + public VerificationMetadataSimCardInfoDto getVerificationMetadataSimCardInfoDto() + throws ClassCastException { + return (VerificationMetadataSimCardInfoDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollectionDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollectionDto.java new file mode 100644 index 00000000..d1080dfc --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoCollectionDto.java @@ -0,0 +1,177 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationMetadataSimCardInfoCollectionDto */ +@JsonPropertyOrder({ + VerificationMetadataSimCardInfoCollectionDto.JSON_PROPERTY_1, + VerificationMetadataSimCardInfoCollectionDto.JSON_PROPERTY_2, + VerificationMetadataSimCardInfoCollectionDto.JSON_PROPERTY_3, + VerificationMetadataSimCardInfoCollectionDto.JSON_PROPERTY_COUNT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationMetadataSimCardInfoCollectionDto { + public static final String JSON_PROPERTY_1 = "1"; + private VerificationMetadataSimCardInfoCollection1Dto _1; + + public static final String JSON_PROPERTY_2 = "2"; + private VerificationMetadataSimCardInfoCollection1Dto _2; + + public static final String JSON_PROPERTY_3 = "3"; + private VerificationMetadataSimCardInfoCollection1Dto _3; + + public static final String JSON_PROPERTY_COUNT = "count"; + private Integer count; + + public VerificationMetadataSimCardInfoCollectionDto() {} + + public VerificationMetadataSimCardInfoCollectionDto _1( + VerificationMetadataSimCardInfoCollection1Dto _1) { + this._1 = _1; + return this; + } + + /** + * Get _1 + * + * @return _1 + */ + @JsonProperty(JSON_PROPERTY_1) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimCardInfoCollection1Dto get1() { + return _1; + } + + @JsonProperty(JSON_PROPERTY_1) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set1(VerificationMetadataSimCardInfoCollection1Dto _1) { + this._1 = _1; + } + + public VerificationMetadataSimCardInfoCollectionDto _2( + VerificationMetadataSimCardInfoCollection1Dto _2) { + this._2 = _2; + return this; + } + + /** + * Get _2 + * + * @return _2 + */ + @JsonProperty(JSON_PROPERTY_2) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimCardInfoCollection1Dto get2() { + return _2; + } + + @JsonProperty(JSON_PROPERTY_2) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set2(VerificationMetadataSimCardInfoCollection1Dto _2) { + this._2 = _2; + } + + public VerificationMetadataSimCardInfoCollectionDto _3( + VerificationMetadataSimCardInfoCollection1Dto _3) { + this._3 = _3; + return this; + } + + /** + * Get _3 + * + * @return _3 + */ + @JsonProperty(JSON_PROPERTY_3) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimCardInfoCollection1Dto get3() { + return _3; + } + + @JsonProperty(JSON_PROPERTY_3) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void set3(VerificationMetadataSimCardInfoCollection1Dto _3) { + this._3 = _3; + } + + public VerificationMetadataSimCardInfoCollectionDto count(Integer count) { + this.count = count; + return this; + } + + /** + * Get count + * + * @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; + } + + /** Return true if this VerificationMetadataSimCardInfoCollection object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationMetadataSimCardInfoCollectionDto verificationMetadataSimCardInfoCollection = + (VerificationMetadataSimCardInfoCollectionDto) o; + return Objects.equals(this._1, verificationMetadataSimCardInfoCollection._1) + && Objects.equals(this._2, verificationMetadataSimCardInfoCollection._2) + && Objects.equals(this._3, verificationMetadataSimCardInfoCollection._3) + && Objects.equals(this.count, verificationMetadataSimCardInfoCollection.count); + } + + @Override + public int hashCode() { + return Objects.hash(_1, _2, _3, count); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationMetadataSimCardInfoCollectionDto {\n"); + sb.append(" _1: ").append(toIndentedString(_1)).append("\n"); + sb.append(" _2: ").append(toIndentedString(_2)).append("\n"); + sb.append(" _3: ").append(toIndentedString(_3)).append("\n"); + sb.append(" count: ").append(toIndentedString(count)).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/verification/models/dto/v1/VerificationMetadataSimCardInfoDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoDto.java new file mode 100644 index 00000000..b0f8856a --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardInfoDto.java @@ -0,0 +1,118 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationMetadataSimCardInfoDto */ +@JsonPropertyOrder({ + VerificationMetadataSimCardInfoDto.JSON_PROPERTY_OPERATOR, + VerificationMetadataSimCardInfoDto.JSON_PROPERTY_SIM +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationMetadataSimCardInfoDto { + public static final String JSON_PROPERTY_OPERATOR = "operator"; + private VerificationMetadataOperatorDto operator; + + public static final String JSON_PROPERTY_SIM = "sim"; + private VerificationMetadataSimDto sim; + + public VerificationMetadataSimCardInfoDto() {} + + public VerificationMetadataSimCardInfoDto operator(VerificationMetadataOperatorDto operator) { + this.operator = operator; + return this; + } + + /** + * Get operator + * + * @return operator + */ + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataOperatorDto getOperator() { + return operator; + } + + @JsonProperty(JSON_PROPERTY_OPERATOR) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setOperator(VerificationMetadataOperatorDto operator) { + this.operator = operator; + } + + public VerificationMetadataSimCardInfoDto sim(VerificationMetadataSimDto sim) { + this.sim = sim; + return this; + } + + /** + * Get sim + * + * @return sim + */ + @JsonProperty(JSON_PROPERTY_SIM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMetadataSimDto getSim() { + return sim; + } + + @JsonProperty(JSON_PROPERTY_SIM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSim(VerificationMetadataSimDto sim) { + this.sim = sim; + } + + /** Return true if this VerificationMetadataSimCardInfo object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationMetadataSimCardInfoDto verificationMetadataSimCardInfo = + (VerificationMetadataSimCardInfoDto) o; + return Objects.equals(this.operator, verificationMetadataSimCardInfo.operator) + && Objects.equals(this.sim, verificationMetadataSimCardInfo.sim); + } + + @Override + public int hashCode() { + return Objects.hash(operator, sim); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationMetadataSimCardInfoDto {\n"); + sb.append(" operator: ").append(toIndentedString(operator)).append("\n"); + sb.append(" sim: ").append(toIndentedString(sim)).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/verification/models/dto/v1/VerificationMetadataSimCardsInfoDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardsInfoDto.java new file mode 100644 index 00000000..9f025de9 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimCardsInfoDto.java @@ -0,0 +1,227 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationMetadataSimCardsInfoDto.VerificationMetadataSimCardsInfoDtoDeserializer.class) +@JsonSerialize( + using = VerificationMetadataSimCardsInfoDto.VerificationMetadataSimCardsInfoDtoSerializer.class) +public class VerificationMetadataSimCardsInfoDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationMetadataSimCardsInfoDto.class.getName()); + + public static class VerificationMetadataSimCardsInfoDtoSerializer + extends StdSerializer { + public VerificationMetadataSimCardsInfoDtoSerializer( + Class t) { + super(t); + } + + public VerificationMetadataSimCardsInfoDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataSimCardsInfoDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataSimCardsInfoDtoDeserializer + extends StdDeserializer { + public VerificationMetadataSimCardsInfoDtoDeserializer() { + this(VerificationMetadataSimCardsInfoDto.class); + } + + public VerificationMetadataSimCardsInfoDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataSimCardsInfoDto 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 VerificationMetadataSimCardInfoCollectionDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataSimCardInfoCollectionDto.class.equals(Integer.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Long.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Float.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Double.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Boolean.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataSimCardInfoCollectionDto.class.equals(Integer.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataSimCardInfoCollectionDto.class.equals(Float.class) + || VerificationMetadataSimCardInfoCollectionDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataSimCardInfoCollectionDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataSimCardInfoCollectionDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()) + .readValueAs(VerificationMetadataSimCardInfoCollectionDto.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 'VerificationMetadataSimCardInfoCollectionDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'VerificationMetadataSimCardInfoCollectionDto'", + e); + } + + if (match == 1) { + VerificationMetadataSimCardsInfoDto ret = new VerificationMetadataSimCardsInfoDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataSimCardsInfoDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataSimCardsInfoDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataSimCardsInfoDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataSimCardsInfoDto(VerificationMetadataSimCardInfoCollectionDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "VerificationMetadataSimCardInfoCollectionDto", + VerificationMetadataSimCardInfoCollectionDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataSimCardsInfoDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataSimCardsInfoDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataSimCardInfoCollectionDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataSimCardInfoCollectionDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be VerificationMetadataSimCardInfoCollectionDto"); + } + + /** + * Get the actual instance, which can be the following: + * VerificationMetadataSimCardInfoCollectionDto + * + * @return The actual instance (VerificationMetadataSimCardInfoCollectionDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataSimCardInfoCollectionDto`. If the actual + * instance is not `VerificationMetadataSimCardInfoCollectionDto`, the ClassCastException will be + * thrown. + * + * @return The actual instance of `VerificationMetadataSimCardInfoCollectionDto` + * @throws ClassCastException if the instance is not + * `VerificationMetadataSimCardInfoCollectionDto` + */ + public VerificationMetadataSimCardInfoCollectionDto + getVerificationMetadataSimCardInfoCollectionDto() throws ClassCastException { + return (VerificationMetadataSimCardInfoCollectionDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimDto.java new file mode 100644 index 00000000..3a7e67c2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMetadataSimDto.java @@ -0,0 +1,208 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationMetadataSimDto.VerificationMetadataSimDtoDeserializer.class) +@JsonSerialize(using = VerificationMetadataSimDto.VerificationMetadataSimDtoSerializer.class) +public class VerificationMetadataSimDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(VerificationMetadataSimDto.class.getName()); + + public static class VerificationMetadataSimDtoSerializer + extends StdSerializer { + public VerificationMetadataSimDtoSerializer(Class t) { + super(t); + } + + public VerificationMetadataSimDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationMetadataSimDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationMetadataSimDtoDeserializer + extends StdDeserializer { + public VerificationMetadataSimDtoDeserializer() { + this(VerificationMetadataSimDto.class); + } + + public VerificationMetadataSimDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationMetadataSimDto 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 VerificationMetadataSimDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationMetadataSimDto.class.equals(Integer.class) + || VerificationMetadataSimDto.class.equals(Long.class) + || VerificationMetadataSimDto.class.equals(Float.class) + || VerificationMetadataSimDto.class.equals(Double.class) + || VerificationMetadataSimDto.class.equals(Boolean.class) + || VerificationMetadataSimDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationMetadataSimDto.class.equals(Integer.class) + || VerificationMetadataSimDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationMetadataSimDto.class.equals(Float.class) + || VerificationMetadataSimDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationMetadataSimDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationMetadataSimDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(VerificationMetadataSimDto.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 'VerificationMetadataSimDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'VerificationMetadataSimDto'", e); + } + + if (match == 1) { + VerificationMetadataSimDto ret = new VerificationMetadataSimDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationMetadataSimDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationMetadataSimDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationMetadataSimDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationMetadataSimDto(VerificationMetadataSimDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationMetadataSimDto", VerificationMetadataSimDto.class); + JSONNavigator.registerDescendants( + VerificationMetadataSimDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationMetadataSimDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationMetadataSimDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationMetadataSimDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationMetadataSimDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationMetadataSimDto + * + * @return The actual instance (VerificationMetadataSimDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationMetadataSimDto`. If the actual instance is not + * `VerificationMetadataSimDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationMetadataSimDto` + * @throws ClassCastException if the instance is not `VerificationMetadataSimDto` + */ + public VerificationMetadataSimDto getVerificationMetadataSimDto() throws ClassCastException { + return (VerificationMetadataSimDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMethodDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMethodDto.java new file mode 100644 index 00000000..561c1af7 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationMethodDto.java @@ -0,0 +1,59 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** */ +public enum VerificationMethodDto { + SMS("sms"), + + FLASHCALL("flashcall"), + + CALLOUT("callout"), + + SEAMLESS("seamless"), + + AUTO("auto"), + + WHATSAPP("whatsapp"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + VerificationMethodDto(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static VerificationMethodDto fromValue(String value) { + for (VerificationMethodDto b : VerificationMethodDto.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationDto.java new file mode 100644 index 00000000..a52bb1c3 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationDto.java @@ -0,0 +1,150 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationPriceInformationDto */ +@JsonPropertyOrder({ + VerificationPriceInformationDto.JSON_PROPERTY_VERIFICATION_PRICE, + VerificationPriceInformationDto.JSON_PROPERTY_TERMINATION_PRICE, + VerificationPriceInformationDto.JSON_PROPERTY_BILLABLE_DURATION +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationPriceInformationDto { + public static final String JSON_PROPERTY_VERIFICATION_PRICE = "verificationPrice"; + private VerificationPriceInformationVerificationPriceDto verificationPrice; + + public static final String JSON_PROPERTY_TERMINATION_PRICE = "terminationPrice"; + private VerificationPriceInformationTerminationPriceDto terminationPrice; + + public static final String JSON_PROPERTY_BILLABLE_DURATION = "billableDuration"; + private Integer billableDuration; + + public VerificationPriceInformationDto() {} + + public VerificationPriceInformationDto verificationPrice( + VerificationPriceInformationVerificationPriceDto verificationPrice) { + this.verificationPrice = verificationPrice; + return this; + } + + /** + * Get verificationPrice + * + * @return verificationPrice + */ + @JsonProperty(JSON_PROPERTY_VERIFICATION_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationPriceInformationVerificationPriceDto getVerificationPrice() { + return verificationPrice; + } + + @JsonProperty(JSON_PROPERTY_VERIFICATION_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVerificationPrice( + VerificationPriceInformationVerificationPriceDto verificationPrice) { + this.verificationPrice = verificationPrice; + } + + public VerificationPriceInformationDto terminationPrice( + VerificationPriceInformationTerminationPriceDto terminationPrice) { + this.terminationPrice = terminationPrice; + return this; + } + + /** + * Get terminationPrice + * + * @return terminationPrice + */ + @JsonProperty(JSON_PROPERTY_TERMINATION_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationPriceInformationTerminationPriceDto getTerminationPrice() { + return terminationPrice; + } + + @JsonProperty(JSON_PROPERTY_TERMINATION_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTerminationPrice( + VerificationPriceInformationTerminationPriceDto terminationPrice) { + this.terminationPrice = terminationPrice; + } + + public VerificationPriceInformationDto billableDuration(Integer billableDuration) { + this.billableDuration = billableDuration; + return this; + } + + /** + * Billable duration seconds of call + * + * @return billableDuration + */ + @JsonProperty(JSON_PROPERTY_BILLABLE_DURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getBillableDuration() { + return billableDuration; + } + + @JsonProperty(JSON_PROPERTY_BILLABLE_DURATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setBillableDuration(Integer billableDuration) { + this.billableDuration = billableDuration; + } + + /** Return true if this VerificationPriceInformation object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationPriceInformationDto verificationPriceInformation = + (VerificationPriceInformationDto) o; + return Objects.equals(this.verificationPrice, verificationPriceInformation.verificationPrice) + && Objects.equals(this.terminationPrice, verificationPriceInformation.terminationPrice) + && Objects.equals(this.billableDuration, verificationPriceInformation.billableDuration); + } + + @Override + public int hashCode() { + return Objects.hash(verificationPrice, terminationPrice, billableDuration); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationPriceInformationDto {\n"); + sb.append(" verificationPrice: ").append(toIndentedString(verificationPrice)).append("\n"); + sb.append(" terminationPrice: ").append(toIndentedString(terminationPrice)).append("\n"); + sb.append(" billableDuration: ").append(toIndentedString(billableDuration)).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/verification/models/dto/v1/VerificationPriceInformationTerminationPriceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationTerminationPriceDto.java new file mode 100644 index 00000000..1fe136f4 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationTerminationPriceDto.java @@ -0,0 +1,216 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationPriceInformationTerminationPriceDto + .VerificationPriceInformationTerminationPriceDtoDeserializer.class) +@JsonSerialize( + using = + VerificationPriceInformationTerminationPriceDto + .VerificationPriceInformationTerminationPriceDtoSerializer.class) +public class VerificationPriceInformationTerminationPriceDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationPriceInformationTerminationPriceDto.class.getName()); + + public static class VerificationPriceInformationTerminationPriceDtoSerializer + extends StdSerializer { + public VerificationPriceInformationTerminationPriceDtoSerializer( + Class t) { + super(t); + } + + public VerificationPriceInformationTerminationPriceDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationPriceInformationTerminationPriceDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationPriceInformationTerminationPriceDtoDeserializer + extends StdDeserializer { + public VerificationPriceInformationTerminationPriceDtoDeserializer() { + this(VerificationPriceInformationTerminationPriceDto.class); + } + + public VerificationPriceInformationTerminationPriceDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationPriceInformationTerminationPriceDto 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 MoneyDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MoneyDto.class.equals(Integer.class) + || MoneyDto.class.equals(Long.class) + || MoneyDto.class.equals(Float.class) + || MoneyDto.class.equals(Double.class) + || MoneyDto.class.equals(Boolean.class) + || MoneyDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MoneyDto.class.equals(Integer.class) || MoneyDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MoneyDto.class.equals(Float.class) || MoneyDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MoneyDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MoneyDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MoneyDto.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 'MoneyDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MoneyDto'", e); + } + + if (match == 1) { + VerificationPriceInformationTerminationPriceDto ret = + new VerificationPriceInformationTerminationPriceDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationPriceInformationTerminationPriceDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationPriceInformationTerminationPriceDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationPriceInformationTerminationPriceDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationPriceInformationTerminationPriceDto(MoneyDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("MoneyDto", MoneyDto.class); + JSONNavigator.registerDescendants( + VerificationPriceInformationTerminationPriceDto.class, + Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationPriceInformationTerminationPriceDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MoneyDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(MoneyDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MoneyDto"); + } + + /** + * Get the actual instance, which can be the following: MoneyDto + * + * @return The actual instance (MoneyDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MoneyDto`. If the actual instance is not `MoneyDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MoneyDto` + * @throws ClassCastException if the instance is not `MoneyDto` + */ + public MoneyDto getMoneyDto() throws ClassCastException { + return (MoneyDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationVerificationPriceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationVerificationPriceDto.java new file mode 100644 index 00000000..8adb6dfb --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationPriceInformationVerificationPriceDto.java @@ -0,0 +1,211 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationPriceInformationVerificationPriceDto + .VerificationPriceInformationVerificationPriceDtoDeserializer.class) +@JsonSerialize( + using = + VerificationPriceInformationVerificationPriceDto + .VerificationPriceInformationVerificationPriceDtoSerializer.class) +public class VerificationPriceInformationVerificationPriceDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationPriceInformationVerificationPriceDto.class.getName()); + + public static class VerificationPriceInformationVerificationPriceDtoSerializer + extends StdSerializer { + public VerificationPriceInformationVerificationPriceDtoSerializer( + Class t) { + super(t); + } + + public VerificationPriceInformationVerificationPriceDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationPriceInformationVerificationPriceDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationPriceInformationVerificationPriceDtoDeserializer + extends StdDeserializer { + public VerificationPriceInformationVerificationPriceDtoDeserializer() { + this(VerificationPriceInformationVerificationPriceDto.class); + } + + public VerificationPriceInformationVerificationPriceDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationPriceInformationVerificationPriceDto 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 MoneyDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (MoneyDto.class.equals(Integer.class) + || MoneyDto.class.equals(Long.class) + || MoneyDto.class.equals(Float.class) + || MoneyDto.class.equals(Double.class) + || MoneyDto.class.equals(Boolean.class) + || MoneyDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((MoneyDto.class.equals(Integer.class) || MoneyDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((MoneyDto.class.equals(Float.class) || MoneyDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (MoneyDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (MoneyDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(MoneyDto.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 'MoneyDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'MoneyDto'", e); + } + + if (match == 1) { + VerificationPriceInformationVerificationPriceDto ret = + new VerificationPriceInformationVerificationPriceDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationPriceInformationVerificationPriceDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationPriceInformationVerificationPriceDto getNullValue( + DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "VerificationPriceInformationVerificationPriceDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationPriceInformationVerificationPriceDto() { + super("oneOf", Boolean.FALSE); + } + + public VerificationPriceInformationVerificationPriceDto(MoneyDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("MoneyDto", MoneyDto.class); + JSONNavigator.registerDescendants( + VerificationPriceInformationVerificationPriceDto.class, + Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationPriceInformationVerificationPriceDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: MoneyDto + * + *

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(MoneyDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be MoneyDto"); + } + + /** + * Get the actual instance, which can be the following: MoneyDto + * + * @return The actual instance (MoneyDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `MoneyDto`. If the actual instance is not `MoneyDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `MoneyDto` + * @throws ClassCastException if the instance is not `MoneyDto` + */ + public MoneyDto getMoneyDto() throws ClassCastException { + return (MoneyDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceCalloutDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceCalloutDto.java new file mode 100644 index 00000000..72c99795 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceCalloutDto.java @@ -0,0 +1,225 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationReportRequestResourceCalloutDto + .VerificationReportRequestResourceCalloutDtoDeserializer.class) +@JsonSerialize( + using = + VerificationReportRequestResourceCalloutDto + .VerificationReportRequestResourceCalloutDtoSerializer.class) +public class VerificationReportRequestResourceCalloutDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationReportRequestResourceCalloutDto.class.getName()); + + public static class VerificationReportRequestResourceCalloutDtoSerializer + extends StdSerializer { + public VerificationReportRequestResourceCalloutDtoSerializer( + Class t) { + super(t); + } + + public VerificationReportRequestResourceCalloutDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationReportRequestResourceCalloutDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationReportRequestResourceCalloutDtoDeserializer + extends StdDeserializer { + public VerificationReportRequestResourceCalloutDtoDeserializer() { + this(VerificationReportRequestResourceCalloutDto.class); + } + + public VerificationReportRequestResourceCalloutDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationReportRequestResourceCalloutDto 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 CalloutVerificationReportRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (CalloutVerificationReportRequestDto.class.equals(Integer.class) + || CalloutVerificationReportRequestDto.class.equals(Long.class) + || CalloutVerificationReportRequestDto.class.equals(Float.class) + || CalloutVerificationReportRequestDto.class.equals(Double.class) + || CalloutVerificationReportRequestDto.class.equals(Boolean.class) + || CalloutVerificationReportRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((CalloutVerificationReportRequestDto.class.equals(Integer.class) + || CalloutVerificationReportRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((CalloutVerificationReportRequestDto.class.equals(Float.class) + || CalloutVerificationReportRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (CalloutVerificationReportRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (CalloutVerificationReportRequestDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(CalloutVerificationReportRequestDto.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 'CalloutVerificationReportRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'CalloutVerificationReportRequestDto'", + e); + } + + if (match == 1) { + VerificationReportRequestResourceCalloutDto ret = + new VerificationReportRequestResourceCalloutDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationReportRequestResourceCalloutDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationReportRequestResourceCalloutDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationReportRequestResourceCalloutDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationReportRequestResourceCalloutDto(CalloutVerificationReportRequestDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("CalloutVerificationReportRequestDto", CalloutVerificationReportRequestDto.class); + JSONNavigator.registerDescendants( + VerificationReportRequestResourceCalloutDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationReportRequestResourceCalloutDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: CalloutVerificationReportRequestDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + CalloutVerificationReportRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be CalloutVerificationReportRequestDto"); + } + + /** + * Get the actual instance, which can be the following: CalloutVerificationReportRequestDto + * + * @return The actual instance (CalloutVerificationReportRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `CalloutVerificationReportRequestDto`. If the actual instance is not + * `CalloutVerificationReportRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `CalloutVerificationReportRequestDto` + * @throws ClassCastException if the instance is not `CalloutVerificationReportRequestDto` + */ + public CalloutVerificationReportRequestDto getCalloutVerificationReportRequestDto() + throws ClassCastException { + return (CalloutVerificationReportRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceDto.java new file mode 100644 index 00000000..18595dee --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceDto.java @@ -0,0 +1,262 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationReportRequestResourceDto */ +@JsonPropertyOrder({ + VerificationReportRequestResourceDto.JSON_PROPERTY_METHOD, + VerificationReportRequestResourceDto.JSON_PROPERTY_SOURCE, + VerificationReportRequestResourceDto.JSON_PROPERTY_CODE, + VerificationReportRequestResourceDto.JSON_PROPERTY_SMS, + VerificationReportRequestResourceDto.JSON_PROPERTY_FLASHCALL, + VerificationReportRequestResourceDto.JSON_PROPERTY_CALLOUT, + VerificationReportRequestResourceDto.JSON_PROPERTY_WHATSAPP +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationReportRequestResourceDto { + public static final String JSON_PROPERTY_METHOD = "method"; + private VerificationMethodDto method; + + public static final String JSON_PROPERTY_SOURCE = "source"; + private String source; + + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_SMS = "sms"; + private VerificationReportRequestResourceSmsDto sms; + + public static final String JSON_PROPERTY_FLASHCALL = "flashcall"; + private VerificationReportRequestResourceFlashcallDto flashcall; + + public static final String JSON_PROPERTY_CALLOUT = "callout"; + private VerificationReportRequestResourceCalloutDto callout; + + public static final String JSON_PROPERTY_WHATSAPP = "whatsapp"; + private VerificationReportRequestResourceWhatsappDto whatsapp; + + public VerificationReportRequestResourceDto() {} + + public VerificationReportRequestResourceDto method(VerificationMethodDto method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMethodDto getMethod() { + return method; + } + + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethod(VerificationMethodDto method) { + this.method = method; + } + + public VerificationReportRequestResourceDto source(String source) { + this.source = source; + return this; + } + + /** + * Where OTP code has been retrieved from. E.g. 'manual', 'callLog', + * 'callInterceptor'. + * + * @return source + */ + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSource() { + return source; + } + + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSource(String source) { + this.source = source; + } + + public VerificationReportRequestResourceDto code(String code) { + this.code = code; + return this; + } + + /** + * Might be used as method-agnostic OTP code. + * + * @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 VerificationReportRequestResourceDto sms(VerificationReportRequestResourceSmsDto sms) { + this.sms = sms; + return this; + } + + /** + * Get sms + * + * @return sms + */ + @JsonProperty(JSON_PROPERTY_SMS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationReportRequestResourceSmsDto getSms() { + return sms; + } + + @JsonProperty(JSON_PROPERTY_SMS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSms(VerificationReportRequestResourceSmsDto sms) { + this.sms = sms; + } + + public VerificationReportRequestResourceDto flashcall( + VerificationReportRequestResourceFlashcallDto flashcall) { + this.flashcall = flashcall; + return this; + } + + /** + * Get flashcall + * + * @return flashcall + */ + @JsonProperty(JSON_PROPERTY_FLASHCALL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationReportRequestResourceFlashcallDto getFlashcall() { + return flashcall; + } + + @JsonProperty(JSON_PROPERTY_FLASHCALL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setFlashcall(VerificationReportRequestResourceFlashcallDto flashcall) { + this.flashcall = flashcall; + } + + public VerificationReportRequestResourceDto callout( + VerificationReportRequestResourceCalloutDto callout) { + this.callout = callout; + return this; + } + + /** + * Get callout + * + * @return callout + */ + @JsonProperty(JSON_PROPERTY_CALLOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationReportRequestResourceCalloutDto getCallout() { + return callout; + } + + @JsonProperty(JSON_PROPERTY_CALLOUT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallout(VerificationReportRequestResourceCalloutDto callout) { + this.callout = callout; + } + + public VerificationReportRequestResourceDto whatsapp( + VerificationReportRequestResourceWhatsappDto whatsapp) { + this.whatsapp = whatsapp; + return this; + } + + /** + * Get whatsapp + * + * @return whatsapp + */ + @JsonProperty(JSON_PROPERTY_WHATSAPP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationReportRequestResourceWhatsappDto getWhatsapp() { + return whatsapp; + } + + @JsonProperty(JSON_PROPERTY_WHATSAPP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setWhatsapp(VerificationReportRequestResourceWhatsappDto whatsapp) { + this.whatsapp = whatsapp; + } + + /** Return true if this VerificationReportRequestResource object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationReportRequestResourceDto verificationReportRequestResource = + (VerificationReportRequestResourceDto) o; + return Objects.equals(this.method, verificationReportRequestResource.method) + && Objects.equals(this.source, verificationReportRequestResource.source) + && Objects.equals(this.code, verificationReportRequestResource.code) + && Objects.equals(this.sms, verificationReportRequestResource.sms) + && Objects.equals(this.flashcall, verificationReportRequestResource.flashcall) + && Objects.equals(this.callout, verificationReportRequestResource.callout) + && Objects.equals(this.whatsapp, verificationReportRequestResource.whatsapp); + } + + @Override + public int hashCode() { + return Objects.hash(method, source, code, sms, flashcall, callout, whatsapp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationReportRequestResourceDto {\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" sms: ").append(toIndentedString(sms)).append("\n"); + sb.append(" flashcall: ").append(toIndentedString(flashcall)).append("\n"); + sb.append(" callout: ").append(toIndentedString(callout)).append("\n"); + sb.append(" whatsapp: ").append(toIndentedString(whatsapp)).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/verification/models/dto/v1/VerificationReportRequestResourceFlashcallDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceFlashcallDto.java new file mode 100644 index 00000000..aed735b0 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceFlashcallDto.java @@ -0,0 +1,226 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationReportRequestResourceFlashcallDto + .VerificationReportRequestResourceFlashcallDtoDeserializer.class) +@JsonSerialize( + using = + VerificationReportRequestResourceFlashcallDto + .VerificationReportRequestResourceFlashcallDtoSerializer.class) +public class VerificationReportRequestResourceFlashcallDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationReportRequestResourceFlashcallDto.class.getName()); + + public static class VerificationReportRequestResourceFlashcallDtoSerializer + extends StdSerializer { + public VerificationReportRequestResourceFlashcallDtoSerializer( + Class t) { + super(t); + } + + public VerificationReportRequestResourceFlashcallDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationReportRequestResourceFlashcallDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationReportRequestResourceFlashcallDtoDeserializer + extends StdDeserializer { + public VerificationReportRequestResourceFlashcallDtoDeserializer() { + this(VerificationReportRequestResourceFlashcallDto.class); + } + + public VerificationReportRequestResourceFlashcallDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationReportRequestResourceFlashcallDto 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 FlashcallVerificationReportRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (FlashcallVerificationReportRequestDto.class.equals(Integer.class) + || FlashcallVerificationReportRequestDto.class.equals(Long.class) + || FlashcallVerificationReportRequestDto.class.equals(Float.class) + || FlashcallVerificationReportRequestDto.class.equals(Double.class) + || FlashcallVerificationReportRequestDto.class.equals(Boolean.class) + || FlashcallVerificationReportRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((FlashcallVerificationReportRequestDto.class.equals(Integer.class) + || FlashcallVerificationReportRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((FlashcallVerificationReportRequestDto.class.equals(Float.class) + || FlashcallVerificationReportRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (FlashcallVerificationReportRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (FlashcallVerificationReportRequestDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(FlashcallVerificationReportRequestDto.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 'FlashcallVerificationReportRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'FlashcallVerificationReportRequestDto'", + e); + } + + if (match == 1) { + VerificationReportRequestResourceFlashcallDto ret = + new VerificationReportRequestResourceFlashcallDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationReportRequestResourceFlashcallDto: %d" + + " classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationReportRequestResourceFlashcallDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationReportRequestResourceFlashcallDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationReportRequestResourceFlashcallDto(FlashcallVerificationReportRequestDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put( + "FlashcallVerificationReportRequestDto", FlashcallVerificationReportRequestDto.class); + JSONNavigator.registerDescendants( + VerificationReportRequestResourceFlashcallDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationReportRequestResourceFlashcallDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: FlashcallVerificationReportRequestDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + FlashcallVerificationReportRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be FlashcallVerificationReportRequestDto"); + } + + /** + * Get the actual instance, which can be the following: FlashcallVerificationReportRequestDto + * + * @return The actual instance (FlashcallVerificationReportRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `FlashcallVerificationReportRequestDto`. If the actual instance is + * not `FlashcallVerificationReportRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `FlashcallVerificationReportRequestDto` + * @throws ClassCastException if the instance is not `FlashcallVerificationReportRequestDto` + */ + public FlashcallVerificationReportRequestDto getFlashcallVerificationReportRequestDto() + throws ClassCastException { + return (FlashcallVerificationReportRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceSmsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceSmsDto.java new file mode 100644 index 00000000..c42ba49c --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceSmsDto.java @@ -0,0 +1,221 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationReportRequestResourceSmsDto.VerificationReportRequestResourceSmsDtoDeserializer + .class) +@JsonSerialize( + using = + VerificationReportRequestResourceSmsDto.VerificationReportRequestResourceSmsDtoSerializer + .class) +public class VerificationReportRequestResourceSmsDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationReportRequestResourceSmsDto.class.getName()); + + public static class VerificationReportRequestResourceSmsDtoSerializer + extends StdSerializer { + public VerificationReportRequestResourceSmsDtoSerializer( + Class t) { + super(t); + } + + public VerificationReportRequestResourceSmsDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationReportRequestResourceSmsDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationReportRequestResourceSmsDtoDeserializer + extends StdDeserializer { + public VerificationReportRequestResourceSmsDtoDeserializer() { + this(VerificationReportRequestResourceSmsDto.class); + } + + public VerificationReportRequestResourceSmsDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationReportRequestResourceSmsDto 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 SmsVerificationReportRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (SmsVerificationReportRequestDto.class.equals(Integer.class) + || SmsVerificationReportRequestDto.class.equals(Long.class) + || SmsVerificationReportRequestDto.class.equals(Float.class) + || SmsVerificationReportRequestDto.class.equals(Double.class) + || SmsVerificationReportRequestDto.class.equals(Boolean.class) + || SmsVerificationReportRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((SmsVerificationReportRequestDto.class.equals(Integer.class) + || SmsVerificationReportRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((SmsVerificationReportRequestDto.class.equals(Float.class) + || SmsVerificationReportRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (SmsVerificationReportRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (SmsVerificationReportRequestDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(SmsVerificationReportRequestDto.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 'SmsVerificationReportRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'SmsVerificationReportRequestDto'", e); + } + + if (match == 1) { + VerificationReportRequestResourceSmsDto ret = new VerificationReportRequestResourceSmsDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationReportRequestResourceSmsDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationReportRequestResourceSmsDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationReportRequestResourceSmsDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationReportRequestResourceSmsDto(SmsVerificationReportRequestDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("SmsVerificationReportRequestDto", SmsVerificationReportRequestDto.class); + JSONNavigator.registerDescendants( + VerificationReportRequestResourceSmsDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationReportRequestResourceSmsDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: SmsVerificationReportRequestDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + SmsVerificationReportRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be SmsVerificationReportRequestDto"); + } + + /** + * Get the actual instance, which can be the following: SmsVerificationReportRequestDto + * + * @return The actual instance (SmsVerificationReportRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `SmsVerificationReportRequestDto`. If the actual instance is not + * `SmsVerificationReportRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `SmsVerificationReportRequestDto` + * @throws ClassCastException if the instance is not `SmsVerificationReportRequestDto` + */ + public SmsVerificationReportRequestDto getSmsVerificationReportRequestDto() + throws ClassCastException { + return (SmsVerificationReportRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceWhatsappDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceWhatsappDto.java new file mode 100644 index 00000000..655a0b48 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestResourceWhatsappDto.java @@ -0,0 +1,225 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = + VerificationReportRequestResourceWhatsappDto + .VerificationReportRequestResourceWhatsappDtoDeserializer.class) +@JsonSerialize( + using = + VerificationReportRequestResourceWhatsappDto + .VerificationReportRequestResourceWhatsappDtoSerializer.class) +public class VerificationReportRequestResourceWhatsappDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationReportRequestResourceWhatsappDto.class.getName()); + + public static class VerificationReportRequestResourceWhatsappDtoSerializer + extends StdSerializer { + public VerificationReportRequestResourceWhatsappDtoSerializer( + Class t) { + super(t); + } + + public VerificationReportRequestResourceWhatsappDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationReportRequestResourceWhatsappDto value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationReportRequestResourceWhatsappDtoDeserializer + extends StdDeserializer { + public VerificationReportRequestResourceWhatsappDtoDeserializer() { + this(VerificationReportRequestResourceWhatsappDto.class); + } + + public VerificationReportRequestResourceWhatsappDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationReportRequestResourceWhatsappDto 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 WhatsappVerificationReportRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (WhatsappVerificationReportRequestDto.class.equals(Integer.class) + || WhatsappVerificationReportRequestDto.class.equals(Long.class) + || WhatsappVerificationReportRequestDto.class.equals(Float.class) + || WhatsappVerificationReportRequestDto.class.equals(Double.class) + || WhatsappVerificationReportRequestDto.class.equals(Boolean.class) + || WhatsappVerificationReportRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((WhatsappVerificationReportRequestDto.class.equals(Integer.class) + || WhatsappVerificationReportRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((WhatsappVerificationReportRequestDto.class.equals(Float.class) + || WhatsappVerificationReportRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (WhatsappVerificationReportRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (WhatsappVerificationReportRequestDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(WhatsappVerificationReportRequestDto.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 'WhatsappVerificationReportRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'WhatsappVerificationReportRequestDto'", + e); + } + + if (match == 1) { + VerificationReportRequestResourceWhatsappDto ret = + new VerificationReportRequestResourceWhatsappDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationReportRequestResourceWhatsappDto: %d classes" + + " match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationReportRequestResourceWhatsappDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationReportRequestResourceWhatsappDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationReportRequestResourceWhatsappDto(WhatsappVerificationReportRequestDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("WhatsappVerificationReportRequestDto", WhatsappVerificationReportRequestDto.class); + JSONNavigator.registerDescendants( + VerificationReportRequestResourceWhatsappDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationReportRequestResourceWhatsappDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: WhatsappVerificationReportRequestDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + WhatsappVerificationReportRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be WhatsappVerificationReportRequestDto"); + } + + /** + * Get the actual instance, which can be the following: WhatsappVerificationReportRequestDto + * + * @return The actual instance (WhatsappVerificationReportRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `WhatsappVerificationReportRequestDto`. If the actual instance is + * not `WhatsappVerificationReportRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `WhatsappVerificationReportRequestDto` + * @throws ClassCastException if the instance is not `WhatsappVerificationReportRequestDto` + */ + public WhatsappVerificationReportRequestDto getWhatsappVerificationReportRequestDto() + throws ClassCastException { + return (WhatsappVerificationReportRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResourceLinkDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResourceLinkDto.java new file mode 100644 index 00000000..45239d2f --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResourceLinkDto.java @@ -0,0 +1,145 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationResourceLinkDto */ +@JsonPropertyOrder({ + VerificationResourceLinkDto.JSON_PROPERTY_REL, + VerificationResourceLinkDto.JSON_PROPERTY_HREF, + VerificationResourceLinkDto.JSON_PROPERTY_METHOD +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationResourceLinkDto { + public static final String JSON_PROPERTY_REL = "rel"; + private String rel; + + public static final String JSON_PROPERTY_HREF = "href"; + private String href; + + public static final String JSON_PROPERTY_METHOD = "method"; + private String method; + + public VerificationResourceLinkDto() {} + + public VerificationResourceLinkDto rel(String rel) { + this.rel = rel; + return this; + } + + /** + * Get rel + * + * @return rel + */ + @JsonProperty(JSON_PROPERTY_REL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getRel() { + return rel; + } + + @JsonProperty(JSON_PROPERTY_REL) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setRel(String rel) { + this.rel = rel; + } + + public VerificationResourceLinkDto href(String href) { + this.href = href; + return this; + } + + /** + * Get href + * + * @return href + */ + @JsonProperty(JSON_PROPERTY_HREF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getHref() { + return href; + } + + @JsonProperty(JSON_PROPERTY_HREF) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setHref(String href) { + this.href = href; + } + + public VerificationResourceLinkDto method(String method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getMethod() { + return method; + } + + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethod(String method) { + this.method = method; + } + + /** Return true if this VerificationResourceLink object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationResourceLinkDto verificationResourceLink = (VerificationResourceLinkDto) o; + return Objects.equals(this.rel, verificationResourceLink.rel) + && Objects.equals(this.href, verificationResourceLink.href) + && Objects.equals(this.method, verificationResourceLink.method); + } + + @Override + public int hashCode() { + return Objects.hash(rel, href, method); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationResourceLinkDto {\n"); + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).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/verification/models/dto/v1/VerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java new file mode 100644 index 00000000..c11e3016 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java @@ -0,0 +1,411 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** VerificationResponseDto */ +@JsonPropertyOrder({ + VerificationResponseDto.JSON_PROPERTY_ID, + VerificationResponseDto.JSON_PROPERTY_METHOD, + VerificationResponseDto.JSON_PROPERTY_STATUS, + VerificationResponseDto.JSON_PROPERTY_REASON, + VerificationResponseDto.JSON_PROPERTY_REFERENCE, + VerificationResponseDto.JSON_PROPERTY_SOURCE, + VerificationResponseDto.JSON_PROPERTY_PRICE, + VerificationResponseDto.JSON_PROPERTY_IDENTITY, + VerificationResponseDto.JSON_PROPERTY_COUNTRY_ID, + VerificationResponseDto.JSON_PROPERTY_VERIFICATION_TIMESTAMP, + VerificationResponseDto.JSON_PROPERTY_CALL_COMPLETE, + VerificationResponseDto.JSON_PROPERTY_CALL_RESULT +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class VerificationResponseDto { + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_METHOD = "method"; + private VerificationMethodDto method; + + public static final String JSON_PROPERTY_STATUS = "status"; + private String status; + + public static final String JSON_PROPERTY_REASON = "reason"; + private String reason; + + public static final String JSON_PROPERTY_REFERENCE = "reference"; + private String reference; + + public static final String JSON_PROPERTY_SOURCE = "source"; + private String source; + + public static final String JSON_PROPERTY_PRICE = "price"; + private VerificationResponsePriceDto price; + + public static final String JSON_PROPERTY_IDENTITY = "identity"; + private VerificationResponseIdentityDto identity; + + public static final String JSON_PROPERTY_COUNTRY_ID = "countryId"; + private String countryId; + + public static final String JSON_PROPERTY_VERIFICATION_TIMESTAMP = "verificationTimestamp"; + private String verificationTimestamp; + + public static final String JSON_PROPERTY_CALL_COMPLETE = "callComplete"; + private Boolean callComplete; + + public static final String JSON_PROPERTY_CALL_RESULT = "callResult"; + private String callResult; + + public VerificationResponseDto() {} + + public VerificationResponseDto id(String id) { + this.id = id; + return this; + } + + /** + * Verification identifier used to query for status. + * + * @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 VerificationResponseDto method(VerificationMethodDto method) { + this.method = method; + return this; + } + + /** + * Get method + * + * @return method + */ + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationMethodDto getMethod() { + return method; + } + + @JsonProperty(JSON_PROPERTY_METHOD) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setMethod(VerificationMethodDto method) { + this.method = method; + } + + public VerificationResponseDto status(String status) { + this.status = status; + return this; + } + + /** + * One of: PENDING, SUCCESSFUL, FAIL, DENIED, ABORTED, ERROR + * + * @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 VerificationResponseDto reason(String reason) { + this.reason = reason; + return this; + } + + /** + * In case of 'failed' verification exact reason of failure. + * + * @return reason + */ + @JsonProperty(JSON_PROPERTY_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReason() { + return reason; + } + + @JsonProperty(JSON_PROPERTY_REASON) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReason(String reason) { + this.reason = reason; + } + + public VerificationResponseDto reference(String reference) { + this.reference = reference; + return this; + } + + /** + * Custom Reference value if supplied during initiation. + * + * @return reference + */ + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getReference() { + return reference; + } + + @JsonProperty(JSON_PROPERTY_REFERENCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setReference(String reference) { + this.reference = reference; + } + + public VerificationResponseDto source(String source) { + this.source = source; + return this; + } + + /** + * Custom Source value if supplied during initiation. + * + * @return source + */ + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSource() { + return source; + } + + @JsonProperty(JSON_PROPERTY_SOURCE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSource(String source) { + this.source = source; + } + + public VerificationResponseDto price(VerificationResponsePriceDto price) { + this.price = price; + return this; + } + + /** + * Get price + * + * @return price + */ + @JsonProperty(JSON_PROPERTY_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationResponsePriceDto getPrice() { + return price; + } + + @JsonProperty(JSON_PROPERTY_PRICE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setPrice(VerificationResponsePriceDto price) { + this.price = price; + } + + public VerificationResponseDto identity(VerificationResponseIdentityDto identity) { + this.identity = identity; + return this; + } + + /** + * Get identity + * + * @return identity + */ + @JsonProperty(JSON_PROPERTY_IDENTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public VerificationResponseIdentityDto getIdentity() { + return identity; + } + + @JsonProperty(JSON_PROPERTY_IDENTITY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setIdentity(VerificationResponseIdentityDto identity) { + this.identity = identity; + } + + public VerificationResponseDto countryId(String countryId) { + this.countryId = countryId; + return this; + } + + /** + * Get countryId + * + * @return countryId + */ + @JsonProperty(JSON_PROPERTY_COUNTRY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCountryId() { + return countryId; + } + + @JsonProperty(JSON_PROPERTY_COUNTRY_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCountryId(String countryId) { + this.countryId = countryId; + } + + public VerificationResponseDto verificationTimestamp(String verificationTimestamp) { + this.verificationTimestamp = verificationTimestamp; + return this; + } + + /** + * Get verificationTimestamp + * + * @return verificationTimestamp + */ + @JsonProperty(JSON_PROPERTY_VERIFICATION_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getVerificationTimestamp() { + return verificationTimestamp; + } + + @JsonProperty(JSON_PROPERTY_VERIFICATION_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVerificationTimestamp(String verificationTimestamp) { + this.verificationTimestamp = verificationTimestamp; + } + + public VerificationResponseDto callComplete(Boolean callComplete) { + this.callComplete = callComplete; + return this; + } + + /** + * Get callComplete + * + * @return callComplete + */ + @JsonProperty(JSON_PROPERTY_CALL_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getCallComplete() { + return callComplete; + } + + @JsonProperty(JSON_PROPERTY_CALL_COMPLETE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallComplete(Boolean callComplete) { + this.callComplete = callComplete; + } + + public VerificationResponseDto callResult(String callResult) { + this.callResult = callResult; + return this; + } + + /** + * Get callResult + * + * @return callResult + */ + @JsonProperty(JSON_PROPERTY_CALL_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallResult() { + return callResult; + } + + @JsonProperty(JSON_PROPERTY_CALL_RESULT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallResult(String callResult) { + this.callResult = callResult; + } + + /** Return true if this VerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + VerificationResponseDto verificationResponse = (VerificationResponseDto) o; + return Objects.equals(this.id, verificationResponse.id) + && Objects.equals(this.method, verificationResponse.method) + && Objects.equals(this.status, verificationResponse.status) + && Objects.equals(this.reason, verificationResponse.reason) + && Objects.equals(this.reference, verificationResponse.reference) + && Objects.equals(this.source, verificationResponse.source) + && Objects.equals(this.price, verificationResponse.price) + && Objects.equals(this.identity, verificationResponse.identity) + && Objects.equals(this.countryId, verificationResponse.countryId) + && Objects.equals(this.verificationTimestamp, verificationResponse.verificationTimestamp) + && Objects.equals(this.callComplete, verificationResponse.callComplete) + && Objects.equals(this.callResult, verificationResponse.callResult); + } + + @Override + public int hashCode() { + return Objects.hash( + id, + method, + status, + reason, + reference, + source, + price, + identity, + countryId, + verificationTimestamp, + callComplete, + callResult); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerificationResponseDto {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); + sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" price: ").append(toIndentedString(price)).append("\n"); + sb.append(" identity: ").append(toIndentedString(identity)).append("\n"); + sb.append(" countryId: ").append(toIndentedString(countryId)).append("\n"); + sb.append(" verificationTimestamp: ") + .append(toIndentedString(verificationTimestamp)) + .append("\n"); + sb.append(" callComplete: ").append(toIndentedString(callComplete)).append("\n"); + sb.append(" callResult: ").append(toIndentedString(callResult)).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/verification/models/dto/v1/VerificationResponseIdentityDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseIdentityDto.java new file mode 100644 index 00000000..d421df88 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseIdentityDto.java @@ -0,0 +1,207 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationResponseIdentityDto.VerificationResponseIdentityDtoDeserializer.class) +@JsonSerialize( + using = VerificationResponseIdentityDto.VerificationResponseIdentityDtoSerializer.class) +public class VerificationResponseIdentityDto extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(VerificationResponseIdentityDto.class.getName()); + + public static class VerificationResponseIdentityDtoSerializer + extends StdSerializer { + public VerificationResponseIdentityDtoSerializer(Class t) { + super(t); + } + + public VerificationResponseIdentityDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationResponseIdentityDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationResponseIdentityDtoDeserializer + extends StdDeserializer { + public VerificationResponseIdentityDtoDeserializer() { + this(VerificationResponseIdentityDto.class); + } + + public VerificationResponseIdentityDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationResponseIdentityDto 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 IdentityDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (IdentityDto.class.equals(Integer.class) + || IdentityDto.class.equals(Long.class) + || IdentityDto.class.equals(Float.class) + || IdentityDto.class.equals(Double.class) + || IdentityDto.class.equals(Boolean.class) + || IdentityDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((IdentityDto.class.equals(Integer.class) || IdentityDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((IdentityDto.class.equals(Float.class) || IdentityDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (IdentityDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (IdentityDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(IdentityDto.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 'IdentityDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'IdentityDto'", e); + } + + if (match == 1) { + VerificationResponseIdentityDto ret = new VerificationResponseIdentityDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationResponseIdentityDto: %d classes match" + + " result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationResponseIdentityDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationResponseIdentityDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationResponseIdentityDto(IdentityDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("IdentityDto", IdentityDto.class); + JSONNavigator.registerDescendants( + VerificationResponseIdentityDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationResponseIdentityDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: IdentityDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(IdentityDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be IdentityDto"); + } + + /** + * Get the actual instance, which can be the following: IdentityDto + * + * @return The actual instance (IdentityDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `IdentityDto`. If the actual instance is not `IdentityDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `IdentityDto` + * @throws ClassCastException if the instance is not `IdentityDto` + */ + public IdentityDto getIdentityDto() throws ClassCastException { + return (IdentityDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponsePriceDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponsePriceDto.java new file mode 100644 index 00000000..9f1ded22 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponsePriceDto.java @@ -0,0 +1,212 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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 = VerificationResponsePriceDto.VerificationResponsePriceDtoDeserializer.class) +@JsonSerialize(using = VerificationResponsePriceDto.VerificationResponsePriceDtoSerializer.class) +public class VerificationResponsePriceDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(VerificationResponsePriceDto.class.getName()); + + public static class VerificationResponsePriceDtoSerializer + extends StdSerializer { + public VerificationResponsePriceDtoSerializer(Class t) { + super(t); + } + + public VerificationResponsePriceDtoSerializer() { + this(null); + } + + @Override + public void serialize( + VerificationResponsePriceDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VerificationResponsePriceDtoDeserializer + extends StdDeserializer { + public VerificationResponsePriceDtoDeserializer() { + this(VerificationResponsePriceDto.class); + } + + public VerificationResponsePriceDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public VerificationResponsePriceDto 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 VerificationPriceInformationDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (VerificationPriceInformationDto.class.equals(Integer.class) + || VerificationPriceInformationDto.class.equals(Long.class) + || VerificationPriceInformationDto.class.equals(Float.class) + || VerificationPriceInformationDto.class.equals(Double.class) + || VerificationPriceInformationDto.class.equals(Boolean.class) + || VerificationPriceInformationDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((VerificationPriceInformationDto.class.equals(Integer.class) + || VerificationPriceInformationDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((VerificationPriceInformationDto.class.equals(Float.class) + || VerificationPriceInformationDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (VerificationPriceInformationDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (VerificationPriceInformationDto.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + attemptParsing |= (token == JsonToken.VALUE_NULL); + } + } + if (attemptParsing) { + deserialized = + tree.traverse(jp.getCodec()).readValueAs(VerificationPriceInformationDto.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 'VerificationPriceInformationDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, "Input data does not match schema 'VerificationPriceInformationDto'", e); + } + + if (match == 1) { + VerificationResponsePriceDto ret = new VerificationResponsePriceDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for VerificationResponsePriceDto: %d classes match result," + + " expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public VerificationResponsePriceDto getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + return null; + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public VerificationResponsePriceDto() { + super("oneOf", Boolean.TRUE); + } + + public VerificationResponsePriceDto(VerificationPriceInformationDto o) { + super("oneOf", Boolean.TRUE); + setActualInstance(o); + } + + static { + schemas.put("VerificationPriceInformationDto", VerificationPriceInformationDto.class); + JSONNavigator.registerDescendants( + VerificationResponsePriceDto.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map> getSchemas() { + return VerificationResponsePriceDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: VerificationPriceInformationDto + * + *

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 (instance == null) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf( + VerificationPriceInformationDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException("Invalid instance type. Must be VerificationPriceInformationDto"); + } + + /** + * Get the actual instance, which can be the following: VerificationPriceInformationDto + * + * @return The actual instance (VerificationPriceInformationDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `VerificationPriceInformationDto`. If the actual instance is not + * `VerificationPriceInformationDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `VerificationPriceInformationDto` + * @throws ClassCastException if the instance is not `VerificationPriceInformationDto` + */ + public VerificationPriceInformationDto getVerificationPriceInformationDto() + throws ClassCastException { + return (VerificationPriceInformationDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappInitiateVerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappInitiateVerificationResponseDto.java new file mode 100644 index 00000000..172bbeef --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappInitiateVerificationResponseDto.java @@ -0,0 +1,186 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** WhatsappInitiateVerificationResponseDto */ +@JsonPropertyOrder({ + WhatsappInitiateVerificationResponseDto.JSON_PROPERTY_SUB_VERIFICATION_ID, + WhatsappInitiateVerificationResponseDto.JSON_PROPERTY_CODE, + WhatsappInitiateVerificationResponseDto.JSON_PROPERTY_CODE_MASK, + WhatsappInitiateVerificationResponseDto.JSON_PROPERTY_LINKS +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class WhatsappInitiateVerificationResponseDto { + public static final String JSON_PROPERTY_SUB_VERIFICATION_ID = "subVerificationId"; + private String subVerificationId; + + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_CODE_MASK = "codeMask"; + private String codeMask; + + public static final String JSON_PROPERTY_LINKS = "_links"; + private List links; + + public WhatsappInitiateVerificationResponseDto() {} + + public WhatsappInitiateVerificationResponseDto subVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + return this; + } + + /** + * Get subVerificationId + * + * @return subVerificationId + */ + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getSubVerificationId() { + return subVerificationId; + } + + @JsonProperty(JSON_PROPERTY_SUB_VERIFICATION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setSubVerificationId(String subVerificationId) { + this.subVerificationId = subVerificationId; + } + + public WhatsappInitiateVerificationResponseDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 WhatsappInitiateVerificationResponseDto codeMask(String codeMask) { + this.codeMask = codeMask; + return this; + } + + /** + * Get codeMask + * + * @return codeMask + */ + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeMask() { + return codeMask; + } + + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeMask(String codeMask) { + this.codeMask = codeMask; + } + + public WhatsappInitiateVerificationResponseDto links(List links) { + this.links = links; + return this; + } + + public WhatsappInitiateVerificationResponseDto addLinksItem( + VerificationResourceLinkDto linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * + * @return links + */ + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getLinks() { + return links; + } + + @JsonProperty(JSON_PROPERTY_LINKS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setLinks(List links) { + this.links = links; + } + + /** Return true if this WhatsappInitiateVerificationResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WhatsappInitiateVerificationResponseDto whatsappInitiateVerificationResponse = + (WhatsappInitiateVerificationResponseDto) o; + return Objects.equals( + this.subVerificationId, whatsappInitiateVerificationResponse.subVerificationId) + && Objects.equals(this.code, whatsappInitiateVerificationResponse.code) + && Objects.equals(this.codeMask, whatsappInitiateVerificationResponse.codeMask) + && Objects.equals(this.links, whatsappInitiateVerificationResponse.links); + } + + @Override + public int hashCode() { + return Objects.hash(subVerificationId, code, codeMask, links); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WhatsappInitiateVerificationResponseDto {\n"); + sb.append(" subVerificationId: ").append(toIndentedString(subVerificationId)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" codeMask: ").append(toIndentedString(codeMask)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).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/verification/models/dto/v1/WhatsappOptionsDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappOptionsDto.java new file mode 100644 index 00000000..e1658345 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappOptionsDto.java @@ -0,0 +1,145 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** WhatsappOptionsDto */ +@JsonPropertyOrder({ + WhatsappOptionsDto.JSON_PROPERTY_CODE, + WhatsappOptionsDto.JSON_PROPERTY_CODE_TYPE, + WhatsappOptionsDto.JSON_PROPERTY_CODE_MASK +}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class WhatsappOptionsDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public static final String JSON_PROPERTY_CODE_TYPE = "codeType"; + private String codeType; + + public static final String JSON_PROPERTY_CODE_MASK = "codeMask"; + private String codeMask; + + public WhatsappOptionsDto() {} + + public WhatsappOptionsDto code(String code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @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 WhatsappOptionsDto codeType(String codeType) { + this.codeType = codeType; + return this; + } + + /** + * Get codeType + * + * @return codeType + */ + @JsonProperty(JSON_PROPERTY_CODE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeType() { + return codeType; + } + + @JsonProperty(JSON_PROPERTY_CODE_TYPE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeType(String codeType) { + this.codeType = codeType; + } + + public WhatsappOptionsDto codeMask(String codeMask) { + this.codeMask = codeMask; + return this; + } + + /** + * Get codeMask + * + * @return codeMask + */ + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCodeMask() { + return codeMask; + } + + @JsonProperty(JSON_PROPERTY_CODE_MASK) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCodeMask(String codeMask) { + this.codeMask = codeMask; + } + + /** Return true if this WhatsappOptions object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WhatsappOptionsDto whatsappOptions = (WhatsappOptionsDto) o; + return Objects.equals(this.code, whatsappOptions.code) + && Objects.equals(this.codeType, whatsappOptions.codeType) + && Objects.equals(this.codeMask, whatsappOptions.codeMask); + } + + @Override + public int hashCode() { + return Objects.hash(code, codeType, codeMask); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WhatsappOptionsDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" codeType: ").append(toIndentedString(codeType)).append("\n"); + sb.append(" codeMask: ").append(toIndentedString(codeMask)).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/verification/models/dto/v1/WhatsappVerificationReportRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappVerificationReportRequestDto.java new file mode 100644 index 00000000..ccc66497 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/WhatsappVerificationReportRequestDto.java @@ -0,0 +1,88 @@ +/* + * Verification + * Verification REST API for verifying phone numbers and users. Support of FlashCall verification, PIN SMS verification and Callout verification. **Note:** OTP CODE must be the full valid E.164 number that we called from. ## Overview For general information on how to use the Sinch APIs including methods, types, errors and authorization, please check the [Using REST](doc:using-rest) page. Use the Sinch Verification Service to verify end-user's mobile phone numbers. The Sinch Verification APIs should be used in combination with the Verification SDKs for a complete end-to-end solution, though it is possible to only use the APIs. Currently, there are three verification methods supported: - FlashCall verification - Android only - PIN SMS verification - iOS, Android, Javascript - Callout verification (voice call) - iOS only - Data verification (distinguished by method = `seamless`) - iOS, Android #### FlashCall verification With the flashCall verification method, a user's phone number is verified by triggering a \"missed call\" towards this number. The call is intercepted by the Android SDK in the mobile app and blocked automatically. To initiate a flashCall verification, check the [Android SDK documentation](doc:verification-android-the-verification-process#flash-call-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### PIN SMS verification With the PIN SMS verification method, a user's phone number is verified by sending an SMS containing a PIN code to this number. In the case of iOS or Javascript, the user needs to enter the PIN manually in the app, while for Android there is an option of intercepting the SMS message delivery and capturing the PIN code automatically. To initiate a PIN SMS verification, check the [iOS](doc:verification-ios-sms-verification), [Android](doc:verification-for-android) and [Javascript](doc:verification-for-javascript) documentation. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Callout verification With the callout verification method, a user's phone number is verified by receiving a phone call and hearing a pre-recorded or text-to-speech message, advising the user to press a digit code. When the user presses the digit code in the dialpad, the verification is successful. To initiate a callout verification, check the [iOS documentation](doc:verification-ios-callout-verification). For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). #### Data verification With the data verification method, a user's phone number is verified by carrier using mobile data network. For additional security, it is recommended that you control which verification requests should proceed and which ones not, by listening in your backend for the [Verification Request Event](doc:verification-rest-verification-api#verification-request) and respond accordingly. Your backend will be notified on the result of the verification with the [Verification Result Event](doc:verification-rest-callback-api#verification-result-event). > 📘 For information about webhooks and the verifications events [Callbacks](/docs/verification-rest-callback-api). + * + * The version of the OpenAPI document: 1.0.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.verification.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; + +/** WhatsappVerificationReportRequestDto */ +@JsonPropertyOrder({WhatsappVerificationReportRequestDto.JSON_PROPERTY_CODE}) +// @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class WhatsappVerificationReportRequestDto { + public static final String JSON_PROPERTY_CODE = "code"; + private String code; + + public WhatsappVerificationReportRequestDto() {} + + public WhatsappVerificationReportRequestDto code(String code) { + this.code = code; + return this; + } + + /** + * OTP code read from whatsapp. + * + * @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; + } + + /** Return true if this WhatsappVerificationReportRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WhatsappVerificationReportRequestDto whatsappVerificationReportRequest = + (WhatsappVerificationReportRequestDto) o; + return Objects.equals(this.code, whatsappVerificationReportRequest.code); + } + + @Override + public int hashCode() { + return Objects.hash(code); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WhatsappVerificationReportRequestDto {\n"); + sb.append(" code: ").append(toIndentedString(code)).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 "); + } +} From 7c3ae1c447be39daf1ac6a6372c7dc8ed2cec63e Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Thu, 23 Nov 2023 08:21:19 +0100 Subject: [PATCH 3/6] feat: Start verification --- .../requests/SendSmsBatchBinaryRequest.java | 5 +- .../verification/VerificationsService.java | 9 +- .../adapters/VerificationsService.java | 6 +- .../adapters/converters/LinkDtoConverter.java | 23 +++ .../converters/VerificationsDtoConverter.java | 72 +++++++++ .../domains/verification/models/Identity.java | 9 +- .../sdk/domains/verification/models/Link.java | 71 +++++++++ .../verification/models/LinkRelType.java | 38 +++++ .../verification/models/NumberIdentity.java | 5 +- .../models/VerificationMethod.java | 2 +- ...erificationFlashCallRequestParameters.java | 31 +++- .../StartVerificationRequestParameters.java | 45 ++++-- .../response/StartVerificationResponse.java | 63 ++++++++ .../StartVerificationResponseCallout.java | 38 +++++ .../StartVerificationResponseFlashCall.java | 112 ++++++++++++++ .../StartVerificationResponseSMS.java | 75 +++++++++ .../StartVerificationResponseSeamless.java | 58 +++++++ .../adapters/VerificationsServiceTest.java | 49 ++++++ .../converters/LinkDtoConverterTest.java | 48 ++++++ .../VerificationsDtoConverterTest.java | 145 ++++++++++++++++++ ...icationFlashCallRequestParametersTest.java | 49 ++++++ ...tartVerificationRequestParametersTest.java | 43 ++++++ .../com/sinch/sdk/core/http/URLParameter.java | 4 +- .../sdk/core/http/URLParameterUtils.java | 3 +- .../dto/v1/VerificationResponseDto.java | 2 +- .../models/dto/v1/LinksDtoTest.java | 26 ++++ ...StartStartVerificationResponseDtoTest.java | 94 ++++++++++++ .../v1/StartVerificationRequestDtoTest.java | 92 +++++++++++ .../verification/verifications/Start.java | 31 ++-- .../domains/verification/v1/LinksDto.json | 12 ++ .../StartVerificationCalloutRequestDto.json | 9 ++ .../StartVerificationCalloutResponseDto.json | 17 ++ .../StartVerificationFlashCallRequestDto.json | 12 ++ ...StartVerificationFlashCallResponseDto.json | 23 +++ .../v1/StartVerificationSMSRequestDto.json | 9 ++ .../v1/StartVerificationSMSResponseDto.json | 20 +++ .../StartVerificationSeamlessRequestDto.json | 9 ++ .../StartVerificationSeamlessResponseDto.json | 19 +++ 38 files changed, 1333 insertions(+), 45 deletions(-) create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/Link.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverterTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/LinksDtoTest.java create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationRequestDtoTest.java create mode 100644 test-resources/src/test/resources/domains/verification/v1/LinksDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutResponseDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallResponseDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSResponseDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessResponseDto.json diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java index 7ec6593b..9afca142 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java @@ -126,7 +126,9 @@ public static class Builder extends BaseBatch.Builder { private Integer fromNpi; private String udh; - private Builder() {} + private Builder() { + super(); + } public Builder setFlashMessage(boolean flashMessage) { this.flashMessage = flashMessage; @@ -158,6 +160,7 @@ public Builder setUdh(String udh) { return this; } + @Override public SendSmsBatchBinaryRequest build() { return new SendSmsBatchBinaryRequest( to, diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java index c5299955..5067b38e 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.verification; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; /** * Verifications Service @@ -17,11 +18,11 @@ public interface VerificationsService { * Start verification * *

This method is used by the mobile and web Verification SDKs to start a verification. It can - * also be used to request a verification from your backend, by making an request. + * also be used to request a verification from your backend, by making a request. * - * @param parameters Parameters to be used to start verification return service instance for - * project + * @param parameters Parameters to be used to start verification + * @return Verification response * @since 1.0 */ - void start(StartVerificationRequestParameters parameters); + StartVerificationResponse start(StartVerificationRequestParameters parameters); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java index b7a66d54..3319feee 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java @@ -6,6 +6,7 @@ import com.sinch.sdk.domains.verification.adapters.api.v1.SendingAndReportingVerificationsApi; import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; import com.sinch.sdk.models.Configuration; import java.util.Map; @@ -27,7 +28,8 @@ private SendingAndReportingVerificationsApi getApi() { return this.api; } - public void start(StartVerificationRequestParameters parameters) { - getApi().startVerification(VerificationsDtoConverter.convert(parameters)); + public StartVerificationResponse start(StartVerificationRequestParameters parameters) { + return VerificationsDtoConverter.convert( + getApi().startVerification(VerificationsDtoConverter.convert(parameters))); } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java new file mode 100644 index 00000000..80ee60fa --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.verification.adapters.converters; + +import com.sinch.sdk.core.http.HttpMethod; +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.LinkRelType; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResourceLinkDto; +import java.util.Collection; +import java.util.stream.Collectors; + +public class LinkDtoConverter { + + public static Collection convert(Collection dto) { + return dto.stream().map(LinkDtoConverter::convert).collect(Collectors.toList()); + } + + public static Link convert(VerificationResourceLinkDto dto) { + return Link.builder() + .setRel(LinkRelType.from(dto.getRel())) + .setHref(dto.getHref()) + .setMethod(HttpMethod.valueOf(dto.getMethod())) + .build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java index 8079a282..3f7c81b3 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java @@ -3,15 +3,27 @@ import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.dto.v1.FlashCallInitiateVerificationResponseDto; import com.sinch.sdk.domains.verification.models.dto.v1.FlashcallOptionsDto; import com.sinch.sdk.domains.verification.models.dto.v1.IdentityDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceFlashCallOptionsDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceIdentityDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceMethodDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseFlashCallDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseSeamlessDto; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseSmsDto; +import com.sinch.sdk.domains.verification.models.dto.v1.SeamlessInitiateVerificationResponseDto; +import com.sinch.sdk.domains.verification.models.dto.v1.SmsInitiateVerificationResponseDto; import com.sinch.sdk.domains.verification.models.dto.v1.VerificationMethodDto; import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseCallout; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseFlashCall; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSMS; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSeamless; public class VerificationsDtoConverter { @@ -52,4 +64,64 @@ public static InitiateVerificationResourceMethodDto convert(VerificationMethod c VerificationMethodDto dto = VerificationMethodDto.fromValue(client.value()); return new InitiateVerificationResourceMethodDto(dto); } + + public static StartVerificationResponse convert(InitiateVerificationResponseDto dto) { + StartVerificationResponse.Builder builder; + switch (dto.getMethod()) { + case SMS: + { + StartVerificationResponseSMS.Builder aBuilder = StartVerificationResponseSMS.builder(); + InitiateVerificationResponseSmsDto aresponse = dto.getSms(); + if (null != aresponse) { + SmsInitiateVerificationResponseDto response = + aresponse.getSmsInitiateVerificationResponseDto(); + aBuilder + .setTemplate(response.getTemplate()) + .setInterceptionTimeOut(response.getInterceptionTimeout()); + } + builder = aBuilder; + break; + } + case FLASHCALL: + { + StartVerificationResponseFlashCall.Builder aBuilder = + StartVerificationResponseFlashCall.builder(); + InitiateVerificationResponseFlashCallDto aresponse = dto.getFlashCall(); + if (null != aresponse) { + FlashCallInitiateVerificationResponseDto response = + aresponse.getFlashCallInitiateVerificationResponseDto(); + aBuilder + .setCliFilter(response.getCliFilter()) + .setInterceptionTimeOut(response.getInterceptionTimeout()) + .setReportTimeout(response.getReportTimeout()) + .setDenyCallAfter(response.getDenyCallAfter()); + } + builder = aBuilder; + break; + } + case CALLOUT: + { + // noop: no specific parameters for callout but we create a specific builder for trace + // purpose + builder = StartVerificationResponseCallout.builder(); + break; + } + case SEAMLESS: + { + StartVerificationResponseSeamless.Builder aBuilder = + StartVerificationResponseSeamless.builder(); + InitiateVerificationResponseSeamlessDto aresponse = dto.getSeamless(); + if (null != aresponse) { + SeamlessInitiateVerificationResponseDto response = + aresponse.getSeamlessInitiateVerificationResponseDto(); + aBuilder.setTargetUri(response.getTargetUri()); + } + builder = aBuilder; + break; + } + default: + builder = StartVerificationResponse.builder(); + } + return builder.setId(dto.getId()).setLinks(LinkDtoConverter.convert(dto.getLinks())).build(); + } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java index d8d0d5e0..72f3032a 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java @@ -1,3 +1,10 @@ package com.sinch.sdk.domains.verification.models; -public abstract class Identity {} +/** Base class for Identity based objects */ +public abstract class Identity { + + @Override + public String toString() { + return "Identity{}"; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/Link.java b/client/src/main/com/sinch/sdk/domains/verification/models/Link.java new file mode 100644 index 00000000..959e8a2c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/Link.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.core.http.HttpMethod; + +/** Available methods and actions which can be done after a successful Verification */ +public class Link { + private final LinkRelType rel; + private final String href; + private final HttpMethod method; + + /** + * @param rel The related action that can be performed on the initiated Verification + * @param href The complete URL to perform the specified action, localized to the DataCenter which + * handled the original Verification request + * @param method The HTTP method to use when performing the action using the linked localized URL + */ + public Link(LinkRelType rel, String href, HttpMethod method) { + this.rel = rel; + this.href = href; + this.method = method; + } + + public LinkRelType getRel() { + return rel; + } + + public String getHref() { + return href; + } + + public HttpMethod getMethod() { + return method; + } + + @Override + public String toString() { + return "Link{" + "rel='" + rel + '\'' + ", href='" + href + '\'' + ", method=" + method + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + LinkRelType rel; + String href; + HttpMethod method; + + private Builder() {} + + public Builder setRel(LinkRelType rel) { + this.rel = rel; + return this; + } + + public Builder setHref(String href) { + this.href = href; + return this; + } + + public Builder setMethod(HttpMethod method) { + this.method = method; + return this; + } + + public Link build() { + return new Link(rel, href, method); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java b/client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java new file mode 100644 index 00000000..846a7e82 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * Link rel authorized values + * + * @since 1.0 + */ +public class LinkRelType extends EnumDynamic { + + /** Get the status of a Verification. */ + public static final LinkRelType STATUS = new LinkRelType("status"); + /** Report a verification */ + public static final LinkRelType REPORT = new LinkRelType("report"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>(LinkRelType.class, LinkRelType::new, Arrays.asList(STATUS, REPORT)); + + private LinkRelType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static LinkRelType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(LinkRelType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java index 2cee0877..bfa1ce79 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java @@ -1,7 +1,6 @@ package com.sinch.sdk.domains.verification.models; -import com.sinch.sdk.domains.sms.models.Group.Builder; - +/** Identity based onto a number */ public class NumberIdentity extends Identity { private final String endpoint; @@ -9,6 +8,7 @@ public String getEndpoint() { return endpoint; } + /** @param endpoint An E.164-compatible phone number. */ public NumberIdentity(String endpoint) { this.endpoint = endpoint; } @@ -27,7 +27,6 @@ public static class Builder { String endpoint; private Builder() {} - ; public Builder setEndpoint(String endpoint) { this.endpoint = endpoint; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java index 5f317d94..9441731d 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java @@ -18,7 +18,7 @@ public class VerificationMethod extends EnumDynamic * Verification by placing a flashcall (missed call) and detecting the incoming calling number * (CLI). */ - public static final VerificationMethod FLASH_CALL = new VerificationMethod("flashCall"); + public static final VerificationMethod FLASH_CALL = new VerificationMethod("flashcall"); /** * Verification by placing a PSTN call to the user's phone and playing an announcement, asking the * user to press a particular digit to verify the phone number. diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java index d851477b..764a6472 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java @@ -1,21 +1,26 @@ package com.sinch.sdk.domains.verification.models.requests; +import com.sinch.sdk.domains.sms.models.requests.SendSmsBatchBinaryRequest.Builder; import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.VerificationMethod; import java.util.Optional; +/** Dedicated request parameters to be use for a flash call verification */ public class StartVerificationFlashCallRequestParameters extends StartVerificationRequestParameters { private final Integer dialTimeOut; + /** + * @param identity Specifies the type of endpoint that will be verified and the particular + * endpoint. number is currently the only supported endpoint type + * @param reference Used to pass your own reference in the request for tracking purposes. + * @param custom Can be used to pass custom data in the request. + * @param dialTimeOut The dial timeout in seconds. + */ public StartVerificationFlashCallRequestParameters( - Identity identity, - VerificationMethod method, - String reference, - String custom, - Integer dialTimeOut) { - super(identity, method, reference, custom); + Identity identity, String reference, String custom, Integer dialTimeOut) { + super(identity, VerificationMethod.FLASH_CALL, reference, custom); this.dialTimeOut = dialTimeOut; } @@ -36,18 +41,28 @@ public static Builder builder() { return new Builder(); } - public static class Builder extends StartVerificationRequestParameters.Builder { + public static class Builder extends StartVerificationRequestParameters.Builder { Integer dialTimeOut; + public Builder() { + super(VerificationMethod.FLASH_CALL); + } + public Builder setDialTimeOut(Integer dialTimeOut) { this.dialTimeOut = dialTimeOut; return this; } + @Override public StartVerificationFlashCallRequestParameters build() { return new StartVerificationFlashCallRequestParameters( - identity, method, reference, custom, dialTimeOut); + identity, reference, custom, dialTimeOut); + } + + @Override + protected Builder self() { + return this; } } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java index 8e2d2b96..9d7bbe16 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java @@ -1,5 +1,6 @@ package com.sinch.sdk.domains.verification.models.requests; +import com.sinch.sdk.domains.sms.models.BaseDeliveryReport.Builder; import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.VerificationMethod; import java.util.Objects; @@ -17,6 +18,13 @@ public class StartVerificationRequestParameters { private final String reference; private final String custom; + /** + * @param identity Specifies the type of endpoint that will be verified and the particular + * endpoint. number is currently the only supported endpoint type + * @param method The type of the verification request. + * @param reference Used to pass your own reference in the request for tracking purposes. + * @param custom Can be used to pass custom data in the request. + */ public StartVerificationRequestParameters( Identity identity, VerificationMethod method, String reference, String custom) { Objects.requireNonNull(identity); @@ -60,39 +68,54 @@ public String toString() { + '}'; } - public static Builder builder() { - return new Builder(); + public static Builder builder() { + return new Builder<>(); } - public static class Builder { + public static Builder builder(VerificationMethod method) { + return new Builder<>(method); + } + + public static class Builder> { Identity identity; VerificationMethod method; String reference; String custom; - public Builder setIdentity(Identity identity) { + public Builder() {} + + public Builder(VerificationMethod method) { + this.method = method; + } + + public B setIdentity(Identity identity) { this.identity = identity; - return this; + return self(); } - public Builder setMethod(VerificationMethod method) { + protected B setMethod(VerificationMethod method) { this.method = method; - return this; + return self(); } - public Builder setReference(String reference) { + public B setReference(String reference) { this.reference = reference; - return this; + return self(); } - public Builder setCustom(String custom) { + public B setCustom(String custom) { this.custom = custom; - return this; + return self(); } public StartVerificationRequestParameters build() { return new StartVerificationRequestParameters(identity, method, reference, custom); } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java new file mode 100644 index 00000000..66574600 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.domains.verification.models.response; + +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters.Builder; +import java.util.Collection; + +/** Comme class to all Start verification requests */ +public class StartVerificationResponse { + + private final String id; + private final Collection links; + + /** + * @param id Verification identifier used to query for status. + * @param links Available methods and actions which can be done after a successful Verification + */ + public StartVerificationResponse(String id, Collection links) { + this.id = id; + this.links = links; + } + + public String getId() { + return id; + } + + public Collection getLinks() { + return links; + } + + @Override + public String toString() { + return "StartVerificationResponse{" + "id='" + id + '\'' + ", links=" + links + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> { + + String id; + Collection links; + + public B setId(String id) { + this.id = id; + return self(); + } + + public B setLinks(Collection links) { + this.links = links; + return self(); + } + + public StartVerificationResponse build() { + return new StartVerificationResponse(id, links); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java new file mode 100644 index 00000000..0e34ed70 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.verification.models.response; + +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters.Builder; +import java.util.Collection; + +/** Dedicated response type for a callout verification */ +public class StartVerificationResponseCallout extends StartVerificationResponse { + + /** + * @param id Verification identifier used to query for status. + * @param links Available methods and actions which can be done after a successful Verification + */ + public StartVerificationResponseCallout(String id, Collection links) { + super(id, links); + } + + @Override + public String toString() { + return "StartVerificationResponseCallout{} " + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends StartVerificationResponse.Builder { + + public StartVerificationResponseCallout build() { + return new StartVerificationResponseCallout(id, links); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java new file mode 100644 index 00000000..478b458f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java @@ -0,0 +1,112 @@ +package com.sinch.sdk.domains.verification.models.response; + +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.response.VerificationResponseCallout.Builder; +import java.util.Collection; + +/** Dedicated response type for a flashcall verification */ +public class StartVerificationResponseFlashCall extends StartVerificationResponse { + + private final String cliFilter; + private final Integer interceptionTimeOut; + private final Integer reportTimeout; + private final Integer denyCallAfter; + + /** + * @param id Verification identifier used to query for status. + * @param links Available methods and actions which can be done after a successful Verification + * @param cliFilter Filter that should be applied for incoming calls to intercept the Flashcall. + * @param interceptionTimeOut Amount of seconds client should wait for the Flashcall. + * @param reportTimeout The time in seconds allowed for reporting the code after which the + * verification will expire. + * @param denyCallAfter Used by the SDKs, this setting makes the handset deny the flashcall after + * the set time in seconds. + */ + public StartVerificationResponseFlashCall( + String id, + Collection links, + String cliFilter, + Integer interceptionTimeOut, + Integer reportTimeout, + Integer denyCallAfter) { + super(id, links); + this.cliFilter = cliFilter; + this.interceptionTimeOut = interceptionTimeOut; + this.reportTimeout = reportTimeout; + this.denyCallAfter = denyCallAfter; + } + + public String getCliFilter() { + return cliFilter; + } + + public Integer getInterceptionTimeOut() { + return interceptionTimeOut; + } + + public Integer getReportTimeout() { + return reportTimeout; + } + + public Integer getDenyCallAfter() { + return denyCallAfter; + } + + @Override + public String toString() { + return "StartVerificationResponseFlashCall{" + + "cliFilter='" + + cliFilter + + '\'' + + ", interceptionTimeOut=" + + interceptionTimeOut + + ", reportTimeout=" + + reportTimeout + + ", denyCallAfter=" + + denyCallAfter + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends StartVerificationResponse.Builder { + + String cliFilter; + Integer interceptionTimeOut; + Integer reportTimeout; + Integer denyCallAfter; + + public Builder setCliFilter(String cliFilter) { + this.cliFilter = cliFilter; + return self(); + } + + public Builder setInterceptionTimeOut(Integer interceptionTimeOut) { + this.interceptionTimeOut = interceptionTimeOut; + return self(); + } + + public Builder setReportTimeout(Integer reportTimeout) { + this.reportTimeout = reportTimeout; + return self(); + } + + public Builder setDenyCallAfter(Integer denyCallAfter) { + this.denyCallAfter = denyCallAfter; + return self(); + } + + public StartVerificationResponseFlashCall build() { + return new StartVerificationResponseFlashCall( + id, links, cliFilter, interceptionTimeOut, reportTimeout, denyCallAfter); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java new file mode 100644 index 00000000..4c4c7579 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java @@ -0,0 +1,75 @@ +package com.sinch.sdk.domains.verification.models.response; + +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.response.VerificationResponseSeamless.Builder; +import java.util.Collection; + +/** Dedicated response type for a sms verification */ +public class StartVerificationResponseSMS extends StartVerificationResponse { + + private final String template; + private final Integer interceptionTimeOut; + + /** + * @param id Verification identifier used to query for status. + * @param links Available methods and actions which can be done after a successful Verification + * @param template The expected template for the SMS response + * @param interceptionTimeOut The amount of time in seconds that the client should wait for the + * SMS. + */ + public StartVerificationResponseSMS( + String id, Collection links, String template, Integer interceptionTimeOut) { + super(id, links); + this.template = template; + this.interceptionTimeOut = interceptionTimeOut; + } + + public String getTemplate() { + return template; + } + + public Integer getInterceptionTimeOut() { + return interceptionTimeOut; + } + + @Override + public String toString() { + return "StartVerificationResponseSMS{" + + "template='" + + template + + '\'' + + ", interceptionTimeOut=" + + interceptionTimeOut + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends StartVerificationResponse.Builder { + + String template; + Integer interceptionTimeOut; + + public Builder setTemplate(String template) { + this.template = template; + return this; + } + + public Builder setInterceptionTimeOut(Integer interceptionTimeOut) { + this.interceptionTimeOut = interceptionTimeOut; + return this; + } + + public StartVerificationResponseSMS build() { + return new StartVerificationResponseSMS(id, links, template, interceptionTimeOut); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java new file mode 100644 index 00000000..aaeca8b9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java @@ -0,0 +1,58 @@ +package com.sinch.sdk.domains.verification.models.response; + +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.response.VerificationResponseCallout.Builder; +import java.util.Collection; + +/** Dedicated response type for a seamless verification */ +public class StartVerificationResponseSeamless extends StartVerificationResponse { + + private final String targetUri; + + /** + * @param id Verification identifier used to query for status. + * @param links Available methods and actions which can be done after a successful Verification + * @param targetUri The target URI + */ + public StartVerificationResponseSeamless(String id, Collection links, String targetUri) { + super(id, links); + this.targetUri = targetUri; + } + + public String getTargetUri() { + return targetUri; + } + + @Override + public String toString() { + return "StartVerificationResponseSeamless{" + + "targetUri='" + + targetUri + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends StartVerificationResponse.Builder { + + String targetUri; + + public Builder setTargetUri(String targetUri) { + this.targetUri = targetUri; + return this; + } + + public StartVerificationResponseSeamless build() { + return new StartVerificationResponseSeamless(id, links, targetUri); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java new file mode 100644 index 00000000..3a2b2ab9 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java @@ -0,0 +1,49 @@ +package com.sinch.sdk.domains.verification.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.sms.models.dto.v1.ApiDeliveryFeedbackDto; +import com.sinch.sdk.domains.verification.adapters.api.v1.SendingAndReportingVerificationsApi; +import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverterTest; +import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; +import com.sinch.sdk.domains.verification.models.dto.v1.StartStartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; +import com.sinch.sdk.models.Configuration; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.Captor; +import org.mockito.InjectMocks; +import org.mockito.Mock; + +@TestWithResources +public class VerificationsServiceTest extends BaseTest { + + @GivenJsonResource("/domains/verification/v1/StartVerificationSMSRequestDto.json") + public InitiateVerificationResourceDto startVerificationSMSRequestDto; + + @Mock Configuration configuration; + @Mock SendingAndReportingVerificationsApi api; + @InjectMocks VerificationsService service; + + @Captor ArgumentCaptor recipientsCaptor; + + @Test + void start() throws ApiException { + + when(api.startVerification(eq(startVerificationSMSRequestDto))) + .thenReturn(StartStartVerificationResponseDtoTest.expectedStartVerificationSMSDto); + + StartVerificationResponse response = + service.start(VerificationsDtoConverterTest.startVerificationSMSRequest); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedStartVerificationSMSResponse); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverterTest.java new file mode 100644 index 00000000..042a9a51 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverterTest.java @@ -0,0 +1,48 @@ +package com.sinch.sdk.domains.verification.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.http.HttpMethod; +import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.LinkRelType; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResourceLinkDto; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class LinkDtoConverterTest extends BaseTest { + + @GivenJsonResource("/domains/verification/v1/LinksDto.json") + public Collection linksDto; + + public static Collection linksClient = + Arrays.asList( + Link.builder() + .setRel(LinkRelType.STATUS) + .setHref("an href for status") + .setMethod(HttpMethod.GET) + .build(), + Link.builder() + .setRel(LinkRelType.REPORT) + .setHref("an href for report") + .setMethod(HttpMethod.PUT) + .build()); + + public static void compareWithDto(Link client, VerificationResourceLinkDto dto) { + assertEquals(dto.getRel(), client.getRel().value()); + assertEquals(dto.getHref(), client.getHref()); + assertEquals(dto.getMethod(), client.getMethod().name()); + } + + @Test + void convert() { + Iterator dtoIterator = linksDto.stream().iterator(); + Iterator clientIterator = linksClient.stream().iterator(); + dtoIterator.forEachRemaining(dtoItem -> compareWithDto(clientIterator.next(), dtoItem)); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java new file mode 100644 index 00000000..c49e85d1 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java @@ -0,0 +1,145 @@ +package com.sinch.sdk.domains.verification.adapters.converters; + +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.dto.v1.StartStartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.StartVerificationRequestDtoTest; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseCallout; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseFlashCall; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSMS; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSeamless; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +public class VerificationsDtoConverterTest extends BaseTest { + + public static StartVerificationRequestParameters startVerificationCalloutRequest = + StartVerificationRequestParameters.builder(VerificationMethod.CALLOUT) + .setCustom("a custom") + .setReference("a reference") + .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) + .build(); + + public static StartVerificationResponseCallout expectedStartVerificationCalloutResponse = + StartVerificationResponseCallout.builder() + .setId("the id") + .setLinks(LinkDtoConverterTest.linksClient) + .build(); + + public static StartVerificationRequestParameters startVerificationFlashCallRequest = + StartVerificationFlashCallRequestParameters.builder() + .setCustom("a custom") + .setReference("a reference") + .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) + .setDialTimeOut(17) + .build(); + public static StartVerificationResponseFlashCall expectedStartVerificationFlashCallResponse = + StartVerificationResponseFlashCall.builder() + .setId("the id") + .setLinks(LinkDtoConverterTest.linksClient) + .setCliFilter("(.*)5312(.*)") + .setInterceptionTimeOut(45) + .setReportTimeout(75) + .setDenyCallAfter(0) + .build(); + public static StartVerificationRequestParameters startVerificationSeamlessRequest = + StartVerificationRequestParameters.builder(VerificationMethod.SEAMLESS) + .setCustom("a custom") + .setReference("a reference") + .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) + .build(); + public static StartVerificationResponseSeamless expectedStartVerificationSeamlessResponse = + StartVerificationResponseSeamless.builder() + .setId("the id") + .setLinks(LinkDtoConverterTest.linksClient) + .setTargetUri("target URI") + .build(); + public static StartVerificationRequestParameters startVerificationSMSRequest = + StartVerificationRequestParameters.builder(VerificationMethod.SMS) + .setCustom("a custom") + .setReference("a reference") + .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) + .build(); + public static StartVerificationResponseSMS expectedStartVerificationSMSResponse = + StartVerificationResponseSMS.builder() + .setId("the id") + .setLinks(LinkDtoConverterTest.linksClient) + .setTemplate("Your verification code is {{CODE}}. Verified by Sinch") + .setInterceptionTimeOut(298) + .build(); + + @Test + void convertStartCalloutRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(startVerificationCalloutRequest)) + .usingRecursiveComparison() + .isEqualTo(StartVerificationRequestDtoTest.startVerificationCalloutDto); + } + + @Test + void convertStartFlashCallRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(startVerificationFlashCallRequest)) + .usingRecursiveComparison() + .isEqualTo(StartVerificationRequestDtoTest.startVerificationFlashCallDto); + } + + @Test + void convertStartSeamlessRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(startVerificationSeamlessRequest)) + .usingRecursiveComparison() + .isEqualTo(StartVerificationRequestDtoTest.startVerificationSeamlessDto); + } + + @Test + void convertStartSMSRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(startVerificationSMSRequest)) + .usingRecursiveComparison() + .isEqualTo(StartVerificationRequestDtoTest.startVerificationSMSDto); + } + + @Test + void convertStartCalloutResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + StartStartVerificationResponseDtoTest.expectedStartVerificationCalloutDto)) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationCalloutResponse); + } + + @Test + void convertStartFlashCallResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + StartStartVerificationResponseDtoTest.expectedStartVerificationFlashCallDto)) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationFlashCallResponse); + } + + @Test + void convertStartSeamlessResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + StartStartVerificationResponseDtoTest.expectedStartVerificationSeamlessDto)) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationSeamlessResponse); + } + + @Test + void convertStartSMSResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + StartStartVerificationResponseDtoTest.expectedStartVerificationSMSDto)) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationSMSResponse); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java new file mode 100644 index 00000000..433f8b57 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java @@ -0,0 +1,49 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class StartVerificationFlashCallRequestParametersTest { + + final Identity identity = NumberIdentity.builder().setEndpoint("foo identity").build(); + final VerificationMethod method = VerificationMethod.FLASH_CALL; + final String reference = "foo reference"; + final String custom = "foo custom"; + + final Integer dialTimeOut = 123; + final StartVerificationFlashCallRequestParameters value = + StartVerificationFlashCallRequestParameters.builder() + .setIdentity(identity) + .setReference(reference) + .setCustom(custom) + .setDialTimeOut(dialTimeOut) + .build(); + + @Test + void getIdentity() { + Assertions.assertThat(value.getIdentity()).isEqualTo(identity); + } + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(method); + } + + @Test + void getReference() { + Assertions.assertThat(value.getReference().get()).isEqualTo(reference); + } + + @Test + void getCustom() { + Assertions.assertThat(value.getCustom().get()).isEqualTo(custom); + } + + @Test + void getDialTimeOut() { + Assertions.assertThat(value.getDialTimeOut().get()).isEqualTo(dialTimeOut); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java new file mode 100644 index 00000000..a8399a80 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethod; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class StartVerificationRequestParametersTest { + + final Identity identity = NumberIdentity.builder().setEndpoint("foo identity").build(); + final VerificationMethod method = VerificationMethod.CALLOUT; + final String reference = "foo reference"; + final String custom = "foo custom"; + + final StartVerificationRequestParameters value = + StartVerificationRequestParameters.builder() + .setIdentity(identity) + .setMethod(method) + .setReference(reference) + .setCustom(custom) + .build(); + + @Test + void getIdentity() { + Assertions.assertThat(value.getIdentity()).isEqualTo(identity); + } + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(method); + } + + @Test + void getReference() { + Assertions.assertThat(value.getReference().get()).isEqualTo(reference); + } + + @Test + void getCustom() { + Assertions.assertThat(value.getCustom().get()).isEqualTo(custom); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/URLParameter.java b/core/src/main/com/sinch/sdk/core/http/URLParameter.java index 46f65593..5d6e063d 100644 --- a/core/src/main/com/sinch/sdk/core/http/URLParameter.java +++ b/core/src/main/com/sinch/sdk/core/http/URLParameter.java @@ -7,8 +7,8 @@ public class URLParameter { 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) + * Create a URL parameter from an object and a style: matrix, label, form, ... (see OAS OAS site) * * @param name The name of the parameter. * @param value The value of the parameter. Could be a collection of object values for name diff --git a/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java b/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java index e68a36a5..09c6e08e 100644 --- a/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java +++ b/core/src/main/com/sinch/sdk/core/http/URLParameterUtils.java @@ -12,7 +12,8 @@ import java.util.stream.Stream; /** - * See https://spec.openapis.org/oas/latest.html#parameter-object for encoding and rendering details + * See OAS site for + * encoding and rendering details */ public class URLParameterUtils { diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java index c11e3016..fee86e3c 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java @@ -336,7 +336,7 @@ public void setCallResult(String callResult) { this.callResult = callResult; } - /** Return true if this VerificationResponse object is equal to o. */ + /** Return true if this StartVerificationResponse object is equal to o. */ @Override public boolean equals(Object o) { if (this == o) { diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/LinksDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/LinksDtoTest.java new file mode 100644 index 00000000..abf3336c --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/LinksDtoTest.java @@ -0,0 +1,26 @@ +package com.sinch.sdk.domains.verification.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.util.Arrays; +import java.util.Collection; +import java.util.List; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class LinksDtoTest extends BaseTest { + @GivenJsonResource("/domains/verification/v1/LinksDto.json") + static Collection linksDto; + + public static List expectedLinks = + Arrays.asList( + new VerificationResourceLinkDto().rel("status").href("an href for status").method("GET"), + new VerificationResourceLinkDto().rel("report").href("an href for report").method("PUT")); + + @Test + void deserialize() { + Assertions.assertThat(linksDto).usingRecursiveComparison().isEqualTo(expectedLinks); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java new file mode 100644 index 00000000..37ac1660 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java @@ -0,0 +1,94 @@ +package com.sinch.sdk.domains.verification.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 org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class StartStartVerificationResponseDtoTest extends BaseTest { + + @GivenJsonResource("/domains/verification/v1/StartVerificationCalloutResponseDto.json") + InitiateVerificationResponseDto loadedStartVerificationCalloutDto; + + public static InitiateVerificationResponseDto expectedStartVerificationCalloutDto = + new InitiateVerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.CALLOUT) + .links(LinksDtoTest.expectedLinks) + .callout( + new InitiateVerificationResponseCalloutDto( + new CalloutInitiateVerificationResponseDto())); + + @GivenJsonResource("/domains/verification/v1/StartVerificationFlashCallResponseDto.json") + InitiateVerificationResponseDto loadedStartVerificationFlashCallDto; + + public static InitiateVerificationResponseDto expectedStartVerificationFlashCallDto = + new InitiateVerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.FLASHCALL) + .links(LinksDtoTest.expectedLinks) + .flashCall( + new InitiateVerificationResponseFlashCallDto( + new FlashCallInitiateVerificationResponseDto() + .cliFilter("(.*)5312(.*)") + .interceptionTimeout(45) + .reportTimeout(75) + .denyCallAfter(0) + .callId("a call id"))); + + @GivenJsonResource("/domains/verification/v1/StartVerificationSeamlessResponseDto.json") + InitiateVerificationResponseDto loadedStartVerificationSeamlessDto; + + public static InitiateVerificationResponseDto expectedStartVerificationSeamlessDto = + new InitiateVerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.SEAMLESS) + .links(LinksDtoTest.expectedLinks) + .seamless( + new InitiateVerificationResponseSeamlessDto( + new SeamlessInitiateVerificationResponseDto().targetUri("target URI"))); + + @GivenJsonResource("/domains/verification/v1/StartVerificationSMSResponseDto.json") + InitiateVerificationResponseDto loadedStartVerificationSMSDto; + + public static InitiateVerificationResponseDto expectedStartVerificationSMSDto = + new InitiateVerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.SMS) + .links(LinksDtoTest.expectedLinks) + .sms( + new InitiateVerificationResponseSmsDto( + new SmsInitiateVerificationResponseDto() + .template("Your verification code is {{CODE}}. Verified by Sinch") + .interceptionTimeout(298))); + + @Test + void deserializeStartCallout() { + Assertions.assertThat(loadedStartVerificationCalloutDto) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationCalloutDto); + } + + @Test + void deserializeStartFlashCall() { + Assertions.assertThat(loadedStartVerificationFlashCallDto) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationFlashCallDto); + } + + @Test + void deserializeStartSeamless() { + Assertions.assertThat(loadedStartVerificationSeamlessDto) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationSeamlessDto); + } + + @Test + void deserializeSMS() { + Assertions.assertThat(loadedStartVerificationSMSDto) + .usingRecursiveComparison() + .isEqualTo(expectedStartVerificationSMSDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationRequestDtoTest.java new file mode 100644 index 00000000..93aca6ac --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationRequestDtoTest.java @@ -0,0 +1,92 @@ +package com.sinch.sdk.domains.verification.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 org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class StartVerificationRequestDtoTest extends BaseTest { + + @GivenTextResource("/domains/verification/v1/StartVerificationCalloutRequestDto.json") + String jsonStartVerificationCallout; + + public static InitiateVerificationResourceDto startVerificationCalloutDto = + new InitiateVerificationResourceDto() + .method(new InitiateVerificationResourceMethodDto(VerificationMethodDto.CALLOUT)) + .custom("a custom") + .reference("a reference") + .identity( + new InitiateVerificationResourceIdentityDto( + new IdentityDto().type("number").endpoint("+endpoint"))); + + @GivenTextResource("/domains/verification/v1/StartVerificationFlashCallRequestDto.json") + String jsonStartVerificationFlashCall; + + public static InitiateVerificationResourceDto startVerificationFlashCallDto = + new InitiateVerificationResourceDto() + .method(new InitiateVerificationResourceMethodDto(VerificationMethodDto.FLASHCALL)) + .custom("a custom") + .reference("a reference") + .identity( + new InitiateVerificationResourceIdentityDto( + new IdentityDto().type("number").endpoint("+endpoint"))) + .flashCallOptions( + new InitiateVerificationResourceFlashCallOptionsDto( + new FlashcallOptionsDto().dialTimeout(17))); + + @GivenTextResource("/domains/verification/v1/StartVerificationSeamlessRequestDto.json") + String jsonStartVerificationSeamless; + + public static InitiateVerificationResourceDto startVerificationSeamlessDto = + new InitiateVerificationResourceDto() + .method(new InitiateVerificationResourceMethodDto(VerificationMethodDto.SEAMLESS)) + .custom("a custom") + .reference("a reference") + .identity( + new InitiateVerificationResourceIdentityDto( + new IdentityDto().type("number").endpoint("+endpoint"))); + + @GivenTextResource("/domains/verification/v1/StartVerificationSMSRequestDto.json") + String jsonStartVerificationSMS; + + public static InitiateVerificationResourceDto startVerificationSMSDto = + new InitiateVerificationResourceDto() + .method(new InitiateVerificationResourceMethodDto(VerificationMethodDto.SMS)) + .custom("a custom") + .reference("a reference") + .identity( + new InitiateVerificationResourceIdentityDto( + new IdentityDto().type("number").endpoint("+endpoint"))); + + @Test + void serializeStartCallout() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(startVerificationCalloutDto); + + JSONAssert.assertEquals(jsonStartVerificationCallout, serializedString, true); + } + + @Test + void serializeStartFlashCall() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(startVerificationFlashCallDto); + + JSONAssert.assertEquals(jsonStartVerificationFlashCall, serializedString, true); + } + + @Test + void serializeSeamlessCall() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(startVerificationSeamlessDto); + + JSONAssert.assertEquals(jsonStartVerificationSeamless, serializedString, true); + } + + @Test + void serializeSMSCall() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(startVerificationSMSDto); + + JSONAssert.assertEquals(jsonStartVerificationSMS, serializedString, true); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java index 3324f130..89036986 100644 --- a/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java @@ -1,9 +1,12 @@ package com.sinch.sample.verification.verifications; import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; import com.sinch.sdk.domains.verification.models.VerificationMethod; import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; import java.io.IOException; import java.util.logging.Logger; @@ -26,15 +29,23 @@ public void run() { LOGGER.info("Start verification for : " + phoneNumber); - client - .verification() - .verifications() - .start( - StartVerificationFlashCallRequestParameters.builder() - .setIdentity(NumberIdentity.builder().setEndpoint("+33444555666").build()) - .setMethod(VerificationMethod.SMS) - .build()); - - // LOGGER.info("Response :" + response); + Identity identity = NumberIdentity.builder().setEndpoint(phoneNumber).build(); + + VerificationMethod method = VerificationMethod.SMS; + + StartVerificationRequestParameters parameters; + if (method != VerificationMethod.FLASH_CALL) { + parameters = StartVerificationRequestParameters.builder(method).setIdentity(identity).build(); + } else { + // Dedicated flashcall builder usage do not require setting explicit verification method + // parameter + parameters = + StartVerificationFlashCallRequestParameters.builder() + .setIdentity(identity) + .setDialTimeOut(17) + .build(); + } + StartVerificationResponse response = client.verification().verifications().start(parameters); + LOGGER.info("Response :" + response); } } diff --git a/test-resources/src/test/resources/domains/verification/v1/LinksDto.json b/test-resources/src/test/resources/domains/verification/v1/LinksDto.json new file mode 100644 index 00000000..b5ed322a --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/LinksDto.json @@ -0,0 +1,12 @@ +[ + { + "rel": "status", + "href": "an href for status", + "method": "GET" + }, + { + "rel": "report", + "href": "an href for report", + "method": "PUT" + } +] \ No newline at end of file diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutRequestDto.json new file mode 100644 index 00000000..a814baa9 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutRequestDto.json @@ -0,0 +1,9 @@ +{ + "identity": { + "type": "number", + "endpoint": "+endpoint" + }, + "reference": "a reference", + "custom": "a custom", + "method": "callout" +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutResponseDto.json new file mode 100644 index 00000000..ca690dcd --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationCalloutResponseDto.json @@ -0,0 +1,17 @@ +{ + "id": "the id", + "method": "callout", + "callout": {}, + "_links": [ + { + "rel": "status", + "href": "an href for status", + "method": "GET" + }, + { + "rel": "report", + "href": "an href for report", + "method": "PUT" + } + ] +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallRequestDto.json new file mode 100644 index 00000000..4a294b66 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallRequestDto.json @@ -0,0 +1,12 @@ +{ + "identity": { + "type": "number", + "endpoint": "+endpoint" + }, + "reference": "a reference", + "custom": "a custom", + "method": "flashcall", + "flashCallOptions": { + "dialTimeout": 17 + } +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallResponseDto.json new file mode 100644 index 00000000..f8ea64ab --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationFlashCallResponseDto.json @@ -0,0 +1,23 @@ +{ + "id": "the id", + "method": "flashcall", + "flashCall": { + "cliFilter": "(.*)5312(.*)", + "interceptionTimeout": 45, + "reportTimeout": 75, + "denyCallAfter": 0, + "callId": "a call id" + }, + "_links": [ + { + "rel": "status", + "href": "an href for status", + "method": "GET" + }, + { + "rel": "report", + "href": "an href for report", + "method": "PUT" + } + ] +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSRequestDto.json new file mode 100644 index 00000000..0d6ea498 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSRequestDto.json @@ -0,0 +1,9 @@ +{ + "identity": { + "type": "number", + "endpoint": "+endpoint" + }, + "reference": "a reference", + "custom": "a custom", + "method": "sms" +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSResponseDto.json new file mode 100644 index 00000000..5046187f --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSMSResponseDto.json @@ -0,0 +1,20 @@ +{ + "id": "the id", + "method": "sms", + "sms": { + "template": "Your verification code is {{CODE}}. Verified by Sinch", + "interceptionTimeout": 298 + }, + "_links": [ + { + "rel": "status", + "href": "an href for status", + "method": "GET" + }, + { + "rel": "report", + "href": "an href for report", + "method": "PUT" + } + ] +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessRequestDto.json new file mode 100644 index 00000000..17b01f14 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessRequestDto.json @@ -0,0 +1,9 @@ +{ + "identity": { + "type": "number", + "endpoint": "+endpoint" + }, + "reference": "a reference", + "custom": "a custom", + "method": "seamless" +} diff --git a/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessResponseDto.json new file mode 100644 index 00000000..a2637267 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/StartVerificationSeamlessResponseDto.json @@ -0,0 +1,19 @@ +{ + "id": "the id", + "method": "seamless", + "seamless": { + "targetUri": "target URI" + }, + "_links": [ + { + "rel": "status", + "href": "an href for status", + "method": "GET" + }, + { + "rel": "report", + "href": "an href for report", + "method": "PUT" + } + ] +} From 69ecad749dc02c7f7254aad8308e57c95c979701 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Thu, 23 Nov 2023 15:03:54 +0100 Subject: [PATCH 4/6] docs/style: code cleaning --- .../sdk/domains/numbers/models/CallbackConfiguration.java | 2 -- .../src/main/com/sinch/sdk/domains/numbers/models/Money.java | 2 -- .../com/sinch/sdk/domains/numbers/models/NumberPattern.java | 2 -- .../src/main/com/sinch/sdk/domains/numbers/models/Region.java | 1 - .../models/requests/ActiveNumberListRequestParameters.java | 1 - .../models/requests/ActiveNumberUpdateRequestParameters.java | 1 - .../ActiveNumberUpdateSMSConfigurationRequestParameters.java | 1 - .../ActiveNumberUpdateVoiceConfigurationRequestParameters.java | 2 -- .../requests/AvailableNumberListAllRequestParameters.java | 1 - .../requests/AvailableNumberRentAnyRequestParameters.java | 1 - .../models/requests/AvailableNumberRentRequestParameters.java | 1 - .../requests/AvailableRegionListAllRequestParameters.java | 1 - .../requests/CallbackConfigurationUpdateRequestParameters.java | 2 -- .../models/requests/RentSMSConfigurationRequestParameters.java | 1 - .../sms/adapters/converters/ParametersDtoConverter.java | 1 - .../sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java | 1 - client/src/main/com/sinch/sdk/domains/sms/models/Group.java | 2 -- .../main/com/sinch/sdk/domains/sms/models/GroupAutoUpdate.java | 3 --- .../sinch/sdk/domains/sms/models/GroupAutoUpdateKeyword.java | 3 --- .../requests/StartVerificationFlashCallRequestParameters.java | 1 - .../models/requests/StartVerificationRequestParameters.java | 1 - .../models/response/StartVerificationResponse.java | 1 - .../models/response/StartVerificationResponseCallout.java | 1 - .../models/response/StartVerificationResponseFlashCall.java | 1 - .../models/response/StartVerificationResponseSMS.java | 1 - .../models/response/StartVerificationResponseSeamless.java | 1 - .../com/sinch/sdk/auth/adapters/BearerAuthManagerTest.java | 1 - .../sms/models/requests/BatchesListRequestParametersTest.java | 2 -- core/src/main/com/sinch/sdk/core/http/URLParameter.java | 2 +- 29 files changed, 1 insertion(+), 40 deletions(-) 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 index 9fc758ae..f24915c2 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java @@ -1,7 +1,5 @@ package com.sinch.sdk.domains.numbers.models; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; - /** * Callback configuration * 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 index c9d63ee5..8303c14b 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java @@ -1,7 +1,5 @@ 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. * 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 index 9505827e..4d589a2e 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java @@ -1,7 +1,5 @@ package com.sinch.sdk.domains.numbers.models; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; - /** * An object enabling to identify number by pattern * 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 index c4b26ae9..dba8f7ca 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java @@ -1,6 +1,5 @@ package com.sinch.sdk.domains.numbers.models; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; import java.util.Collection; /** 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 index 377f53b2..ddf58417 100644 --- 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 @@ -1,6 +1,5 @@ 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; 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 index 734cb6e8..8cc04bdb 100644 --- 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 @@ -1,6 +1,5 @@ package com.sinch.sdk.domains.numbers.models.requests; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; import java.util.Optional; /** 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 index 93ca4008..7c67aaf6 100644 --- 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 @@ -1,6 +1,5 @@ package com.sinch.sdk.domains.numbers.models.requests; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; import java.util.Optional; /*** 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 index 0989c0a6..a27c9461 100644 --- 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 @@ -1,7 +1,5 @@ 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 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 index 65be9f07..cb26cbc5 100644 --- 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 @@ -1,6 +1,5 @@ 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; 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 index 72235ff0..3501b8fd 100644 --- 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 @@ -1,6 +1,5 @@ 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; 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 index 8227363a..e1b04c06 100644 --- 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 @@ -1,6 +1,5 @@ package com.sinch.sdk.domains.numbers.models.requests; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; import java.util.Optional; /** 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 index 543e89e4..bd3f9bb1 100644 --- 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 @@ -1,6 +1,5 @@ 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; 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 index 3afb2f88..eeb30b2c 100644 --- 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 @@ -1,7 +1,5 @@ package com.sinch.sdk.domains.numbers.models.requests; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; - /** * Parameters request to update callback configuration * 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 index 9820089c..7df93647 100644 --- 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 @@ -1,6 +1,5 @@ package com.sinch.sdk.domains.numbers.models.requests; -import com.sinch.sdk.domains.numbers.models.ActiveNumber.Builder; import java.util.Optional; /** 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 index 73515eff..a82be356 100644 --- 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 @@ -68,5 +68,4 @@ public static ParameterObjDto convert(Parameters parameters) { }); return dto; } - ; } diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java index 5dda5cab..e2b57a2f 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java @@ -22,7 +22,6 @@ public class DeliveryReportErrorCode extends EnumDynamicOAS site) * * @param name The name of the parameter. From 64e9e4fcdd7fa3e0a8509ae74cda83ae945974cc Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier Date: Mon, 27 Nov 2023 16:47:43 +0100 Subject: [PATCH 5/6] doc: PR comment --- core/src/main/com/sinch/sdk/core/http/AuthManager.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/main/com/sinch/sdk/core/http/AuthManager.java b/core/src/main/com/sinch/sdk/core/http/AuthManager.java index c376d040..02429cca 100644 --- a/core/src/main/com/sinch/sdk/core/http/AuthManager.java +++ b/core/src/main/com/sinch/sdk/core/http/AuthManager.java @@ -5,6 +5,7 @@ public interface AuthManager { + // expected schemes identifier defined at OAS files level String SCHEMA_KEYWORD_BEARER = "Bearer"; String SCHEMA_KEYWORD_BASIC = "Basic"; From d5a3fbcb54252c30cca0f276d6785fdbc8b1e179 Mon Sep 17 00:00:00 2001 From: Jean-Pierre Portier <141755467+JPPortier@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:50:08 +0100 Subject: [PATCH 6/6] Feat: Verification report & status --- .../VerificationApplicationAuthManager.java | 18 +- .../domains/verification/StatusService.java | 51 ++++++ .../verification/VerificationService.java | 8 + .../verification/VerificationsService.java | 29 ++++ .../verification/adapters/StatusService.java | 57 +++++++ .../adapters/VerificationService.java | 12 +- .../adapters/VerificationsService.java | 28 ++++ .../converters/PriceDtoConverter.java | 14 ++ .../converters/VerificationsDtoConverter.java | 144 +++++++++++++++- .../domains/verification/models/Identity.java | 12 +- .../verification/models/NumberIdentity.java | 2 + .../domains/verification/models/Price.java | 54 ++++++ .../verification/models/VerificationId.java | 23 +++ ...ethod.java => VerificationMethodType.java} | 24 +-- .../models/VerificationReference.java | 23 +++ .../models/VerificationReport.java | 94 +++++++++++ .../models/VerificationReportCallout.java | 123 ++++++++++++++ .../models/VerificationReportFlashCall.java | 125 ++++++++++++++ .../models/VerificationReportReasonType.java | 80 +++++++++ .../models/VerificationReportSMS.java | 79 +++++++++ .../models/VerificationReportStatusType.java | 57 +++++++ ...erificationFlashCallRequestParameters.java | 9 +- .../StartVerificationRequestParameters.java | 28 ++-- ...icationReportCalloutRequestParameters.java | 56 +++++++ ...ationReportFlashCallRequestParameters.java | 56 +++++++ .../VerificationReportRequestParameters.java | 53 ++++++ ...erificationReportSMSRequestParameters.java | 71 ++++++++ .../response/StartVerificationResponse.java | 11 +- .../StartVerificationResponseCallout.java | 3 +- .../StartVerificationResponseFlashCall.java | 3 +- .../StartVerificationResponseSMS.java | 3 +- .../StartVerificationResponseSeamless.java | 4 +- .../adapters/StatusServiceTest.java | 71 ++++++++ .../adapters/VerificationsServiceTest.java | 50 +++++- .../VerificationsDtoConverterTest.java | 155 ++++++++++++++++-- ...icationFlashCallRequestParametersTest.java | 9 +- ...tartVerificationRequestParametersTest.java | 9 +- ...ionReportCalloutRequestParametersTest.java | 23 +++ ...nReportFlashCallRequestParametersTest.java | 23 +++ ...rificationReportRequestParametersTest.java | 18 ++ ...icationReportSMSRequestParametersTest.java | 29 ++++ .../com/sinch/sdk/core/http/URLPathUtils.java | 22 +++ .../adapters/api/v1/ActiveNumberApi.java | 20 +-- .../adapters/api/v1/AvailableNumberApi.java | 18 +- .../adapters/api/v1/AvailableRegionsApi.java | 5 +- .../api/v1/CallbackConfigurationApi.java | 8 +- .../sms/adapters/api/v1/BatchesApi.java | 33 ++-- .../adapters/api/v1/DeliveryReportsApi.java | 16 +- .../sms/adapters/api/v1/GroupsApi.java | 31 ++-- .../sms/adapters/api/v1/InboundsApi.java | 9 +- .../api/v1/QueryVerificationsApi.java | 17 +- .../SendingAndReportingVerificationsApi.java | 14 +- .../dto/v1/VerificationResponseDto.java | 2 +- ... => StartVerificationResponseDtoTest.java} | 2 +- .../dto/v1/VerificationReportDtoTest.java | 90 ++++++++++ .../v1/VerificationReportRequestDtoTest.java | 64 ++++++++ sample-app/README.md | 76 +++++---- .../sample/verification/status/GetById.java | 33 ++++ .../verification/status/GetByIdentity.java | 37 +++++ .../verification/status/GetByReference.java | 33 ++++ .../verifications/GetReportById.java | 52 ++++++ .../verifications/GetReportByIdentity.java | 54 ++++++ .../verification/verifications/Start.java | 25 +-- .../VerificationReportCalloutRequestDto.json | 6 + .../VerificationReportCalloutResponseDto.json | 19 +++ ...VerificationReportFlashCallRequestDto.json | 6 + ...erificationReportFlashCallResponseDto.json | 8 + .../v1/VerificationReportSMSRequestDto.json | 8 + .../v1/VerificationReportSMSResponseDto.json | 14 ++ 69 files changed, 2236 insertions(+), 227 deletions(-) create mode 100644 client/src/main/com/sinch/sdk/domains/verification/StatusService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/StatusService.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/adapters/converters/PriceDtoConverter.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/Price.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationId.java rename client/src/main/com/sinch/sdk/domains/verification/models/{VerificationMethod.java => VerificationMethodType.java} (59%) create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReference.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReport.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportCallout.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportFlashCall.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportReasonType.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportSMS.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportStatusType.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParameters.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParameters.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParameters.java create mode 100644 client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParameters.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/adapters/StatusServiceTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParametersTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParametersTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParametersTest.java create mode 100644 client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParametersTest.java create mode 100644 core/src/main/com/sinch/sdk/core/http/URLPathUtils.java rename openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/{StartStartVerificationResponseDtoTest.java => StartVerificationResponseDtoTest.java} (98%) create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportDtoTest.java create mode 100644 openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestDtoTest.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/status/GetByIdentity.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/status/GetByReference.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportById.java create mode 100644 sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportByIdentity.java create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutResponseDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallResponseDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSRequestDto.json create mode 100644 test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSResponseDto.json diff --git a/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java b/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java index 61eb96f9..86ec299b 100644 --- a/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java +++ b/client/src/main/com/sinch/sdk/auth/adapters/VerificationApplicationAuthManager.java @@ -1,8 +1,12 @@ package com.sinch.sdk.auth.adapters; import com.sinch.sdk.core.exceptions.ApiAuthException; +import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.core.utils.StringUtil; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.security.InvalidKeyException; import java.security.MessageDigest; @@ -40,11 +44,17 @@ public void resetToken() { public Collection> getAuthorizationHeaders( String method, String httpContentType, String path, String body) { + String decodePath; + try { + decodePath = new URI(path).getPath(); + } catch (URISyntaxException e) { + throw new ApiException(e); + } // see // https://developers.sinch.com/docs/verification/api-reference/authentication/signed-request/ Instant timestamp = Instant.now(); String bodyMD5Hash = getBodyMD5Hash(body); - String stringToSign = getSignature(method, bodyMD5Hash, httpContentType, timestamp, path); + String stringToSign = getSignature(method, bodyMD5Hash, httpContentType, timestamp, decodePath); String encoded = encode(stringToSign); String key = this.key == null ? "" : this.key; @@ -54,7 +64,9 @@ public Collection> getAuthorizationHeaders( } private String getBodyMD5Hash(String body) { - + if (StringUtil.isEmpty(body)) { + return ""; + } try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] digest = md.digest(body.getBytes(StandardCharsets.UTF_8)); @@ -71,7 +83,7 @@ private String getSignature( "\n", method, bodyMD5Hash, - httpContentType, + null != httpContentType ? httpContentType : "", XTIMESTAMP_HEADER + ":" + timestamp.toString(), path); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/StatusService.java b/client/src/main/com/sinch/sdk/domains/verification/StatusService.java new file mode 100644 index 00000000..88f2042e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/StatusService.java @@ -0,0 +1,51 @@ +package com.sinch.sdk.domains.verification; + +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReport; + +/** + * Get the status of specific verification requests in the verification process. Returns the status + * of pending and completed verifications. You can retrieve the status of verification requests by + * using the ID of the request, the phone number of the user being verified, or a custom reference + * string. + * + * @see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-status + * @since 1.0 + */ +public interface StatusService { + + /** + * Queries the verification result by sending the verification Identity (usually a phone number) + * and its method. With this query you can get the result of a verification. + * + * @param identity Only number identity is supported + * @param method Method used for verification + * @return Verification report response + * @since 1.0 + */ + VerificationReport get(Identity identity, VerificationMethodType method); + + /** + * Queries the verification result by sending the verification ID. With this query you can get the + * result of a verification. + * + * @param id The ID of the verification + * @return Verification report response + * @since 1.0 + */ + VerificationReport get(VerificationId id); + + /** + * Queries the verification result by sending the verification Reference. With this query you can + * get the result of a verification + * + * @param reference The custom reference of the verification + * @return Verification report response + * @since 1.0 + */ + VerificationReport get(VerificationReference reference); +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java index d3aca0d0..a97ee08d 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java @@ -16,4 +16,12 @@ public interface VerificationService { * @since 1.0 */ VerificationsService verifications(); + + /** + * Status Service instance + * + * @return service instance for project + * @since 1.0 + */ + StatusService status(); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java index 5067b38e..b04f7dab 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java @@ -1,6 +1,10 @@ package com.sinch.sdk.domains.verification; +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationReport; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportRequestParameters; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; /** @@ -25,4 +29,29 @@ public interface VerificationsService { * @since 1.0 */ StartVerificationResponse start(StartVerificationRequestParameters parameters); + + /** + * Report a verification using Identity + * + *

Report the received verification code to verify it, using the identity of the user (in most + * cases, the phone number). For an SMS PIN verification or Phone Call verification, this is the + * OTP code. For flashcalls, this is the CLI. + * + * @param identity Only number identity is supported + * @param parameters Parameters to be used to get report + * @return Verification report response + * @since 1.0 + */ + VerificationReport report(Identity identity, VerificationReportRequestParameters parameters); + + /** + * Report the received verification code to verify it, using the Verification ID of the + * Verification request + * + * @param id Id returned from start verification + * @param parameters Parameters to be used to get report + * @return Verification report response + * @since 1.0 + */ + VerificationReport report(VerificationId id, VerificationReportRequestParameters parameters); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/StatusService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/StatusService.java new file mode 100644 index 00000000..4fbb2237 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/StatusService.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.verification.adapters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.domains.verification.adapters.api.v1.QueryVerificationsApi; +import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import com.sinch.sdk.models.Configuration; +import java.util.Map; + +public class StatusService implements com.sinch.sdk.domains.verification.StatusService { + + private QueryVerificationsApi api; + + public StatusService() {} + + public StatusService( + Configuration configuration, HttpClient httpClient, Map authManager) { + this.api = + new QueryVerificationsApi( + httpClient, configuration.getVerificationServer(), authManager, new HttpMapper()); + } + + private QueryVerificationsApi getApi() { + return this.api; + } + + public VerificationReport get(Identity identity, VerificationMethodType method) { + if (!(identity instanceof NumberIdentity)) { + throw new ApiException("Unexpected entity: " + identity); + } + NumberIdentity numberIdentity = (NumberIdentity) identity; + + return VerificationsDtoConverter.convert( + getApi() + .verificationStatusByIdentity( + numberIdentity.getType(), numberIdentity.getEndpoint(), method.value())); + } + + public VerificationReport get(VerificationId id) { + + return VerificationsDtoConverter.convert(getApi().verificationStatusById(id.getId())); + } + + public VerificationReport get(VerificationReference reference) { + + return VerificationsDtoConverter.convert( + getApi().verificationStatusByReference(reference.getReference())); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java index bf17feba..536c7ef7 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationService.java @@ -4,6 +4,7 @@ import com.sinch.sdk.auth.adapters.VerificationApplicationAuthManager; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.domains.verification.StatusService; import com.sinch.sdk.domains.verification.VerificationsService; import com.sinch.sdk.models.Configuration; import java.util.AbstractMap; @@ -20,6 +21,7 @@ public class VerificationService implements com.sinch.sdk.domains.verification.V private final Configuration configuration; private final HttpClient httpClient; private VerificationsService verifications; + private StatusService status; private final Map authManagers; public VerificationService(Configuration configuration, HttpClient httpClient) { @@ -44,7 +46,6 @@ public VerificationService(Configuration configuration, HttpClient httpClient) { .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); } - @Override public VerificationsService verifications() { if (null == this.verifications) { this.verifications = @@ -53,4 +54,13 @@ public VerificationsService verifications() { } return this.verifications; } + + public StatusService status() { + if (null == this.status) { + this.status = + new com.sinch.sdk.domains.verification.adapters.StatusService( + configuration, httpClient, authManagers); + } + return this.status; + } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java index 3319feee..72266423 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java @@ -1,11 +1,17 @@ package com.sinch.sdk.domains.verification.adapters; +import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.core.http.HttpMapper; import com.sinch.sdk.domains.verification.adapters.api.v1.SendingAndReportingVerificationsApi; import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationReport; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportRequestParameters; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; import com.sinch.sdk.models.Configuration; import java.util.Map; @@ -32,4 +38,26 @@ public StartVerificationResponse start(StartVerificationRequestParameters parame return VerificationsDtoConverter.convert( getApi().startVerification(VerificationsDtoConverter.convert(parameters))); } + + public VerificationReport report( + Identity identity, VerificationReportRequestParameters parameters) { + if (!(identity instanceof NumberIdentity)) { + throw new ApiException("Unexpected entity: " + identity); + } + NumberIdentity numberIdentity = (NumberIdentity) identity; + + return VerificationsDtoConverter.convert( + getApi() + .reportVerificationByIdentity( + numberIdentity.getType(), + numberIdentity.getEndpoint(), + VerificationsDtoConverter.convert(parameters))); + } + + public VerificationReport report( + VerificationId id, VerificationReportRequestParameters parameters) { + + return VerificationsDtoConverter.convert( + getApi().reportVerificationById(id.getId(), VerificationsDtoConverter.convert(parameters))); + } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/PriceDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/PriceDtoConverter.java new file mode 100644 index 00000000..664735f4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/PriceDtoConverter.java @@ -0,0 +1,14 @@ +package com.sinch.sdk.domains.verification.adapters.converters; + +import com.sinch.sdk.domains.verification.models.Price; +import com.sinch.sdk.domains.verification.models.dto.v1.MoneyDto; + +public class PriceDtoConverter { + + public static Price convert(MoneyDto dto) { + if (null == dto) { + return Price.builder().build(); + } + return Price.builder().setCurrencyId(dto.getCurrencyId()).setAmount(dto.getAmount()).build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java index 3f7c81b3..628bdee9 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java @@ -1,10 +1,21 @@ package com.sinch.sdk.domains.verification.adapters.converters; +import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import com.sinch.sdk.domains.verification.models.VerificationReportCallout; +import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; +import com.sinch.sdk.domains.verification.models.VerificationReportReasonType; +import com.sinch.sdk.domains.verification.models.VerificationReportSMS; +import com.sinch.sdk.domains.verification.models.VerificationReportStatusType; +import com.sinch.sdk.domains.verification.models.dto.v1.CalloutVerificationReportRequestDto; import com.sinch.sdk.domains.verification.models.dto.v1.FlashCallInitiateVerificationResponseDto; import com.sinch.sdk.domains.verification.models.dto.v1.FlashcallOptionsDto; +import com.sinch.sdk.domains.verification.models.dto.v1.FlashcallVerificationReportRequestDto; import com.sinch.sdk.domains.verification.models.dto.v1.IdentityDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceFlashCallOptionsDto; @@ -16,9 +27,20 @@ import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseSmsDto; import com.sinch.sdk.domains.verification.models.dto.v1.SeamlessInitiateVerificationResponseDto; import com.sinch.sdk.domains.verification.models.dto.v1.SmsInitiateVerificationResponseDto; +import com.sinch.sdk.domains.verification.models.dto.v1.SmsVerificationReportRequestDto; import com.sinch.sdk.domains.verification.models.dto.v1.VerificationMethodDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationPriceInformationDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceCalloutDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceFlashcallDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceSmsDto; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResponseDto; import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportCalloutRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportSMSRequestParameters; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseCallout; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseFlashCall; @@ -34,7 +56,7 @@ public static InitiateVerificationResourceDto convert(StartVerificationRequestPa dto.identity(convert(client.getIdentity())) .method(convert(client.getMethod())) - .reference(client.getReference().orElse(null)) + .reference(client.getReference().map(VerificationReference::getReference).orElse(null)) .custom(client.getCustom().orElse(null)); if (client instanceof StartVerificationFlashCallRequestParameters) { @@ -60,7 +82,7 @@ public static InitiateVerificationResourceIdentityDto convert(Identity client) { return new InitiateVerificationResourceIdentityDto(dto); } - public static InitiateVerificationResourceMethodDto convert(VerificationMethod client) { + public static InitiateVerificationResourceMethodDto convert(VerificationMethodType client) { VerificationMethodDto dto = VerificationMethodDto.fromValue(client.value()); return new InitiateVerificationResourceMethodDto(dto); } @@ -122,6 +144,120 @@ public static StartVerificationResponse convert(InitiateVerificationResponseDto default: builder = StartVerificationResponse.builder(); } - return builder.setId(dto.getId()).setLinks(LinkDtoConverter.convert(dto.getLinks())).build(); + return builder + .setId(VerificationId.valueOf(dto.getId())) + .setLinks(LinkDtoConverter.convert(dto.getLinks())) + .build(); + } + + public static VerificationReportRequestResourceDto convert( + VerificationReportRequestParameters client) { + + VerificationReportRequestResourceDto dto = + new VerificationReportRequestResourceDto() + .method(VerificationMethodDto.fromValue(client.getMethod().value())); + + if (client instanceof VerificationReportFlashCallRequestParameters) { + VerificationReportFlashCallRequestParameters typedClient = + (VerificationReportFlashCallRequestParameters) client; + dto.flashcall(convert(typedClient)); + } else if (client instanceof VerificationReportSMSRequestParameters) { + VerificationReportSMSRequestParameters typedClient = + (VerificationReportSMSRequestParameters) client; + dto.sms(convert(typedClient)); + } else if (client instanceof VerificationReportCalloutRequestParameters) { + VerificationReportCalloutRequestParameters typedClient = + (VerificationReportCalloutRequestParameters) client; + dto.callout(convert(typedClient)); + } + return dto; + } + + private static VerificationReportRequestResourceFlashcallDto convert( + VerificationReportFlashCallRequestParameters client) { + + FlashcallVerificationReportRequestDto dto = + new FlashcallVerificationReportRequestDto().cli(client.getCli()); + return new VerificationReportRequestResourceFlashcallDto(dto); + } + + private static VerificationReportRequestResourceSmsDto convert( + VerificationReportSMSRequestParameters client) { + + SmsVerificationReportRequestDto dto = + new SmsVerificationReportRequestDto().code(client.getCode()); + client.getCli().ifPresent(dto::setCli); + return new VerificationReportRequestResourceSmsDto(dto); + } + + private static VerificationReportRequestResourceCalloutDto convert( + VerificationReportCalloutRequestParameters client) { + + CalloutVerificationReportRequestDto dto = + new CalloutVerificationReportRequestDto().code(client.getCode()); + return new VerificationReportRequestResourceCalloutDto(dto); + } + + public static VerificationReport convert(VerificationResponseDto dto) { + VerificationReport.Builder builder; + + switch (dto.getMethod()) { + case FLASHCALL: + { + VerificationReportFlashCall.Builder abuilder = + VerificationReportFlashCall.builder().setSource(dto.getSource()); + if (null != dto.getPrice() + && null != dto.getPrice().getVerificationPriceInformationDto()) { + VerificationPriceInformationDto price = + dto.getPrice().getVerificationPriceInformationDto(); + abuilder.setVerificationPrice( + PriceDtoConverter.convert(price.getVerificationPrice().getMoneyDto())); + abuilder.setTerminationPrice( + PriceDtoConverter.convert(price.getTerminationPrice().getMoneyDto())); + abuilder.setBillableDuration(price.getBillableDuration()); + } + builder = abuilder; + break; + } + case SMS: + { + VerificationReportSMS.Builder abuilder = + VerificationReportSMS.builder().setSource(dto.getSource()); + if (null != dto.getPrice() + && null != dto.getPrice().getVerificationPriceInformationDto()) { + VerificationPriceInformationDto price = + dto.getPrice().getVerificationPriceInformationDto(); + abuilder.setVerificationPrice( + PriceDtoConverter.convert(price.getVerificationPrice().getMoneyDto())); + } + builder = abuilder; + break; + } + case CALLOUT: + { + VerificationReportCallout.Builder abuilder = + VerificationReportCallout.builder().setCallComplete(dto.getCallComplete()); + if (null != dto.getPrice() + && null != dto.getPrice().getVerificationPriceInformationDto()) { + VerificationPriceInformationDto price = + dto.getPrice().getVerificationPriceInformationDto(); + abuilder.setVerificationPrice( + PriceDtoConverter.convert(price.getVerificationPrice().getMoneyDto())); + abuilder.setTerminationPrice( + PriceDtoConverter.convert(price.getTerminationPrice().getMoneyDto())); + abuilder.setBillableDuration(price.getBillableDuration()); + } + builder = abuilder; + break; + } + default: + throw new ApiException("Unexpected method: " + dto.getMethod()); + } + return builder + .setId(VerificationId.valueOf(dto.getId())) + .setReason(VerificationReportReasonType.from(dto.getReason())) + .setStatus(VerificationReportStatusType.from(dto.getStatus())) + .setReference(VerificationReference.valueOf(dto.getReference())) + .build(); } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java index 72f3032a..244af02d 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java @@ -3,8 +3,18 @@ /** Base class for Identity based objects */ public abstract class Identity { + public final String type; + + public Identity(String type) { + this.type = type; + } + @Override public String toString() { - return "Identity{}"; + return "Identity{" + "type='" + type + '\'' + '}'; + } + + public String getType() { + return type; } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java index bfa1ce79..f6839bf6 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java @@ -2,6 +2,7 @@ /** Identity based onto a number */ public class NumberIdentity extends Identity { + private final String endpoint; public String getEndpoint() { @@ -10,6 +11,7 @@ public String getEndpoint() { /** @param endpoint An E.164-compatible phone number. */ public NumberIdentity(String endpoint) { + super("number"); this.endpoint = endpoint; } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/Price.java b/client/src/main/com/sinch/sdk/domains/verification/models/Price.java new file mode 100644 index 00000000..64fe5e98 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/Price.java @@ -0,0 +1,54 @@ +package com.sinch.sdk.domains.verification.models; + +public class Price { + private final String currencyId; + private final Float amount; + + /** + * @param currencyId ISO 4217 currency code + * @param amount The amount + */ + public Price(String currencyId, Float amount) { + this.currencyId = currencyId; + this.amount = amount; + } + + public String getCurrencyId() { + return currencyId; + } + + public Float getAmount() { + return amount; + } + + @Override + public String toString() { + return "Price{" + "currencyId='" + currencyId + '\'' + ", amount=" + amount + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + String currencyId; + Float amount; + + private Builder() {} + + public Builder setCurrencyId(String currencyId) { + this.currencyId = currencyId; + return this; + } + + public Builder setAmount(Float amount) { + this.amount = amount; + return this; + } + + public Price build() { + return new Price(currencyId, amount); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationId.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationId.java new file mode 100644 index 00000000..7293dc2b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationId.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.verification.models; + +public class VerificationId { + + public final String id; + + public VerificationId(String id) { + this.id = id; + } + + @Override + public String toString() { + return "VerificationId{" + "id='" + id + '\'' + '}'; + } + + public String getId() { + return id; + } + + public static VerificationId valueOf(String id) { + return new VerificationId(id); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java similarity index 59% rename from client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java rename to client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java index 9441731d..d85a569f 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethod.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java @@ -10,46 +10,46 @@ * * @since 1.0 */ -public class VerificationMethod extends EnumDynamic { +public class VerificationMethodType extends EnumDynamic { /** Verification by SMS message with a PIN code */ - public static final VerificationMethod SMS = new VerificationMethod("sms"); + public static final VerificationMethodType SMS = new VerificationMethodType("sms"); /** * Verification by placing a flashcall (missed call) and detecting the incoming calling number * (CLI). */ - public static final VerificationMethod FLASH_CALL = new VerificationMethod("flashcall"); + public static final VerificationMethodType FLASH_CALL = new VerificationMethodType("flashcall"); /** * Verification by placing a PSTN call to the user's phone and playing an announcement, asking the * user to press a particular digit to verify the phone number. */ - public static final VerificationMethod CALLOUT = new VerificationMethod("callout"); + public static final VerificationMethodType CALLOUT = new VerificationMethodType("callout"); /** * Data verification. Verification by accessing internal infrastructure of mobile carriers to * verify if given verification attempt was originated from device with matching phone number. */ - public static final VerificationMethod SEAMLESS = new VerificationMethod("seamless"); + public static final VerificationMethodType SEAMLESS = new VerificationMethodType("seamless"); /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = + private static final EnumSupportDynamic ENUM_SUPPORT = new EnumSupportDynamic<>( - VerificationMethod.class, - VerificationMethod::new, + VerificationMethodType.class, + VerificationMethodType::new, Arrays.asList(SMS, FLASH_CALL, CALLOUT, SEAMLESS)); - private VerificationMethod(String value) { + private VerificationMethodType(String value) { super(value); } - public static Stream values() { + public static Stream values() { return ENUM_SUPPORT.values(); } - public static VerificationMethod from(String value) { + public static VerificationMethodType from(String value) { return ENUM_SUPPORT.from(value); } - public static String valueOf(VerificationMethod e) { + public static String valueOf(VerificationMethodType e) { return ENUM_SUPPORT.valueOf(e); } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReference.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReference.java new file mode 100644 index 00000000..f1f9ec63 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReference.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.verification.models; + +public class VerificationReference { + + public final String reference; + + public VerificationReference(String reference) { + this.reference = reference; + } + + @Override + public String toString() { + return "VerificationReference{" + "reference='" + reference + '\'' + '}'; + } + + public String getReference() { + return reference; + } + + public static VerificationReference valueOf(String reference) { + return new VerificationReference(reference); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReport.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReport.java new file mode 100644 index 00000000..5fc2aff9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReport.java @@ -0,0 +1,94 @@ +package com.sinch.sdk.domains.verification.models; + +/** Comme class to all verification report responses */ +public class VerificationReport { + + private final VerificationId id; + private final VerificationReportStatusType status; + private final VerificationReportReasonType reason; + private final VerificationReference reference; + + public VerificationReport( + VerificationId id, + VerificationReportStatusType status, + VerificationReportReasonType reason, + VerificationReference reference) { + this.id = id; + this.status = status; + this.reason = reason; + this.reference = reference; + } + + public VerificationId getId() { + return id; + } + + public VerificationReportStatusType getStatus() { + return status; + } + + public VerificationReportReasonType getReason() { + return reason; + } + + public VerificationReference getReference() { + return reference; + } + + @Override + public String toString() { + return "VerificationReport{" + + "id='" + + id + + '\'' + + ", status=" + + status + + ", reason=" + + reason + + ", reference='" + + reference + + '\'' + + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> { + + VerificationId id; + VerificationReportStatusType status; + VerificationReportReasonType reason; + VerificationReference reference; + + public B setId(VerificationId id) { + this.id = id; + return self(); + } + + public B setStatus(VerificationReportStatusType status) { + this.status = status; + return self(); + } + + public B setReason(VerificationReportReasonType reason) { + this.reason = reason; + return self(); + } + + public B setReference(VerificationReference reference) { + this.reference = reference; + return self(); + } + + public VerificationReport build() { + return new VerificationReport(id, status, reason, reference); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportCallout.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportCallout.java new file mode 100644 index 00000000..a09f266f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportCallout.java @@ -0,0 +1,123 @@ +package com.sinch.sdk.domains.verification.models; + +public class VerificationReportCallout extends VerificationReport { + + private final Price verificationPrice; + private final Price terminationPrice; + private final Integer billableDuration; + private final Boolean callComplete; + /** + * @param id The unique ID of the verification request + * @param status The status of the verification request + * @param reason Displays the reason why a verification has FAILED, was DENIED, or was ABORTED + * @param reference The reference that was optionally passed together with the verification + * request + * @param verificationPrice The maximum price charged for this verification process. This property + * will appear in the body of the response with a delay. It will become visible only when the + * verification status is other than PENDING + * @param terminationPrice The maximum cost of the call made during this verification process. + * Present only when termination debiting is enabled (disabled by default). This property will + * appear in the body of the response with a delay. It will become visible only after the call + * is completed, when its cost is known to Sinch + * @param billableDuration The time of the call for which the fee was charged. Present only when + * termination debiting is enabled (disabled by default). Depending on the type of rounding + * used, the value is the actual call time rounded to the nearest second, minute or other + * value. + * @param callComplete Shows whether the call is complete or not. + */ + public VerificationReportCallout( + VerificationId id, + VerificationReportStatusType status, + VerificationReportReasonType reason, + VerificationReference reference, + Price verificationPrice, + Price terminationPrice, + Integer billableDuration, + Boolean callComplete) { + super(id, status, reason, reference); + this.verificationPrice = verificationPrice; + this.terminationPrice = terminationPrice; + this.billableDuration = billableDuration; + this.callComplete = callComplete; + } + + public Price getVerificationPrice() { + return verificationPrice; + } + + public Price getTerminationPrice() { + return terminationPrice; + } + + public Integer getBillableDuration() { + return billableDuration; + } + + public Boolean getCallComplete() { + return callComplete; + } + + @Override + public String toString() { + return "VerificationReportCallout{" + + "verificationPrice=" + + verificationPrice + + ", terminationPrice=" + + terminationPrice + + ", billableDuration=" + + billableDuration + + ", callComplete=" + + callComplete + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReport.Builder { + + Price verificationPrice; + Price terminationPrice; + Integer billableDuration; + Boolean callComplete; + + public Builder setVerificationPrice(Price verificationPrice) { + this.verificationPrice = verificationPrice; + return this; + } + + public Builder setTerminationPrice(Price terminationPrice) { + this.terminationPrice = terminationPrice; + return this; + } + + public Builder setBillableDuration(Integer billableDuration) { + this.billableDuration = billableDuration; + return this; + } + + public Builder setCallComplete(Boolean callComplete) { + this.callComplete = callComplete; + return this; + } + + public VerificationReportCallout build() { + return new VerificationReportCallout( + id, + status, + reason, + reference, + verificationPrice, + terminationPrice, + billableDuration, + callComplete); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportFlashCall.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportFlashCall.java new file mode 100644 index 00000000..d5f9645a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportFlashCall.java @@ -0,0 +1,125 @@ +package com.sinch.sdk.domains.verification.models; + +public class VerificationReportFlashCall extends VerificationReport { + + private final Price verificationPrice; + private final Price terminationPrice; + private final Integer billableDuration; + private final String source; + /** + * @param id The unique ID of the verification request + * @param status The status of the verification request + * @param reason Displays the reason why a verification has FAILED, was DENIED, or was ABORTED + * @param reference The reference that was optionally passed together with the verification + * request + * @param verificationPrice The maximum price charged for this verification process. This property + * will appear in the body of the response with a delay. It will become visible only when the + * verification status is other than PENDING + * @param terminationPrice The maximum cost of the call made during this verification process. + * Present only when termination debiting is enabled (disabled by default). This property will + * appear in the body of the response with a delay. It will become visible only after the call + * is completed, when its cost is known to Sinch + * @param billableDuration The time of the call for which the fee was charged. Present only when + * termination debiting is enabled (disabled by default). Depending on the type of rounding + * used, the value is the actual call time rounded to the nearest second, minute or other + * value. + * @param source Free text that the client is sending, used to show if the call/SMS was + * intercepted or not + */ + public VerificationReportFlashCall( + VerificationId id, + VerificationReportStatusType status, + VerificationReportReasonType reason, + VerificationReference reference, + Price verificationPrice, + Price terminationPrice, + Integer billableDuration, + String source) { + super(id, status, reason, reference); + this.verificationPrice = verificationPrice; + this.terminationPrice = terminationPrice; + this.billableDuration = billableDuration; + this.source = source; + } + + public Price getVerificationPrice() { + return verificationPrice; + } + + public Price getTerminationPrice() { + return terminationPrice; + } + + public Integer getBillableDuration() { + return billableDuration; + } + + public String getSource() { + return source; + } + + @Override + public String toString() { + return "VerificationReportFlashCall{" + + "verificationPrice=" + + verificationPrice + + ", terminationPrice=" + + terminationPrice + + ", billableDuration=" + + billableDuration + + ", source='" + + source + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReport.Builder { + + Price verificationPrice; + Price terminationPrice; + Integer billableDuration; + String source; + + public Builder setVerificationPrice(Price verificationPrice) { + this.verificationPrice = verificationPrice; + return this; + } + + public Builder setTerminationPrice(Price terminationPrice) { + this.terminationPrice = terminationPrice; + return this; + } + + public Builder setBillableDuration(Integer billableDuration) { + this.billableDuration = billableDuration; + return this; + } + + public Builder setSource(String source) { + this.source = source; + return this; + } + + public VerificationReportFlashCall build() { + return new VerificationReportFlashCall( + id, + status, + reason, + reference, + verificationPrice, + terminationPrice, + billableDuration, + source); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportReasonType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportReasonType.java new file mode 100644 index 00000000..c023d599 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportReasonType.java @@ -0,0 +1,80 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * The type of the verification report reason + * + * @since 1.0 + */ +public class VerificationReportReasonType + extends EnumDynamic { + + public static final VerificationReportReasonType FRAUD = + new VerificationReportReasonType("Fraud"); + public static final VerificationReportReasonType NOT_ENOUGH_CREDIT = + new VerificationReportReasonType("Not enough credit"); + public static final VerificationReportReasonType BLOCKED = + new VerificationReportReasonType("Blocked"); + public static final VerificationReportReasonType DENIED_BY_CALLBACK = + new VerificationReportReasonType("Denied by callback"); + public static final VerificationReportReasonType INVALID_CALLBACK = + new VerificationReportReasonType("Invalid callback"); + public static final VerificationReportReasonType INTERNAL_ERROR = + new VerificationReportReasonType("Internal error"); + public static final VerificationReportReasonType DESTINATION_DENIED = + new VerificationReportReasonType("Destination denied"); + public static final VerificationReportReasonType NETWORK_ERROR_OR_NUMBER_UNREACHABLE = + new VerificationReportReasonType("Network error or number unreachable"); + public static final VerificationReportReasonType FAILED_PENDING = + new VerificationReportReasonType("Failed pending"); + public static final VerificationReportReasonType SMS_DELIVERY_FAILURE = + new VerificationReportReasonType("SMS delivery failure"); + public static final VerificationReportReasonType INVALID_CLI = + new VerificationReportReasonType("Invalid CLI"); + public static final VerificationReportReasonType INVALID_CODE = + new VerificationReportReasonType("Invalid code"); + public static final VerificationReportReasonType EXPIRED = + new VerificationReportReasonType("Expired"); + public static final VerificationReportReasonType HUNG_UP_WITHOUT_ENTERING_VALID_CODE = + new VerificationReportReasonType("Hung up without entering valid code"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + VerificationReportReasonType.class, + VerificationReportReasonType::new, + Arrays.asList( + FRAUD, + NOT_ENOUGH_CREDIT, + BLOCKED, + DENIED_BY_CALLBACK, + INVALID_CALLBACK, + INTERNAL_ERROR, + DESTINATION_DENIED, + NETWORK_ERROR_OR_NUMBER_UNREACHABLE, + FAILED_PENDING, + SMS_DELIVERY_FAILURE, + INVALID_CLI, + INVALID_CODE, + EXPIRED, + HUNG_UP_WITHOUT_ENTERING_VALID_CODE)); + + private VerificationReportReasonType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static VerificationReportReasonType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(VerificationReportReasonType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportSMS.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportSMS.java new file mode 100644 index 00000000..ae40a6b5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportSMS.java @@ -0,0 +1,79 @@ +package com.sinch.sdk.domains.verification.models; + +public class VerificationReportSMS extends VerificationReport { + + private final Price verificationPrice; + private final String source; + /** + * @param id The unique ID of the verification request + * @param status The status of the verification request + * @param reason Displays the reason why a verification has FAILED, was DENIED, or was ABORTED + * @param reference The reference that was optionally passed together with the verification + * request + * @param verificationPrice The maximum price charged for this verification process. This property + * will appear in the body of the response with a delay. It will become visible only when the + * verification status is other than PENDING + * @param source Free text that the client is sending, used to show if the call/SMS was + * intercepted or not + */ + public VerificationReportSMS( + VerificationId id, + VerificationReportStatusType status, + VerificationReportReasonType reason, + VerificationReference reference, + Price verificationPrice, + String source) { + super(id, status, reason, reference); + this.verificationPrice = verificationPrice; + this.source = source; + } + + public Price getVerificationPrice() { + return verificationPrice; + } + + public String getSource() { + return source; + } + + @Override + public String toString() { + return "VerificationReportSMS{" + + "verificationPrice=" + + verificationPrice + + ", source='" + + source + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReport.Builder { + + Price verificationPrice; + String source; + + public Builder setVerificationPrice(Price verificationPrice) { + this.verificationPrice = verificationPrice; + return this; + } + + public Builder setSource(String source) { + this.source = source; + return this; + } + + public VerificationReportSMS build() { + return new VerificationReportSMS(id, status, reason, reference, verificationPrice, source); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportStatusType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportStatusType.java new file mode 100644 index 00000000..811644d7 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportStatusType.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.verification.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * The type of the verification report status + * + * @since 1.0 + */ +public class VerificationReportStatusType + extends EnumDynamic { + + /** The verification is ongoing */ + public static final VerificationReportStatusType PENDING = + new VerificationReportStatusType("PENDING"); + /** The verification was successful */ + public static final VerificationReportStatusType SUCCESSFUL = + new VerificationReportStatusType("SUCCESSFUL"); + /** The verification attempt was made, but the number wasn't verified */ + public static final VerificationReportStatusType FAIL = new VerificationReportStatusType("FAIL"); + /** The verification attempt was denied by Sinch or your backend */ + public static final VerificationReportStatusType DENIED = + new VerificationReportStatusType("DENIED"); + /** The verification attempt was aborted by requesting a new verification */ + public static final VerificationReportStatusType ABORTED = + new VerificationReportStatusType("ABORTED"); + /** + * The verification couldn't be completed due to a network error or the number being unreachable + */ + public static final VerificationReportStatusType ERROR = + new VerificationReportStatusType("ERROR"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + VerificationReportStatusType.class, + VerificationReportStatusType::new, + Arrays.asList(PENDING, SUCCESSFUL, FAIL, DENIED, ABORTED, ERROR)); + + private VerificationReportStatusType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static VerificationReportStatusType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(VerificationReportStatusType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java index 0d805148..e4167d60 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java @@ -1,7 +1,8 @@ package com.sinch.sdk.domains.verification.models.requests; import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; import java.util.Optional; /** Dedicated request parameters to be use for a flash call verification */ @@ -18,8 +19,8 @@ public class StartVerificationFlashCallRequestParameters * @param dialTimeOut The dial timeout in seconds. */ public StartVerificationFlashCallRequestParameters( - Identity identity, String reference, String custom, Integer dialTimeOut) { - super(identity, VerificationMethod.FLASH_CALL, reference, custom); + Identity identity, VerificationReference reference, String custom, Integer dialTimeOut) { + super(identity, VerificationMethodType.FLASH_CALL, reference, custom); this.dialTimeOut = dialTimeOut; } @@ -45,7 +46,7 @@ public static class Builder extends StartVerificationRequestParameters.Builder getReference() { + public Optional getReference() { return Optional.ofNullable(reference); } @@ -71,20 +75,20 @@ public static Builder builder() { return new Builder<>(); } - public static Builder builder(VerificationMethod method) { + public static Builder builder(VerificationMethodType method) { return new Builder<>(method); } public static class Builder> { Identity identity; - VerificationMethod method; - String reference; + VerificationMethodType method; + VerificationReference reference; String custom; public Builder() {} - public Builder(VerificationMethod method) { + public Builder(VerificationMethodType method) { this.method = method; } @@ -93,12 +97,12 @@ public B setIdentity(Identity identity) { return self(); } - protected B setMethod(VerificationMethod method) { + protected B setMethod(VerificationMethodType method) { this.method = method; return self(); } - public B setReference(String reference) { + public B setReference(VerificationReference reference) { this.reference = reference; return self(); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParameters.java new file mode 100644 index 00000000..64cb5e6c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParameters.java @@ -0,0 +1,56 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; + +public class VerificationReportCalloutRequestParameters + extends VerificationReportRequestParameters { + + private final String code; + + public VerificationReportCalloutRequestParameters(String code) { + super(VerificationMethodType.CALLOUT); + this.code = code; + } + + public String getCode() { + return code; + } + + @Override + public String toString() { + return "VerificationReportCalloutRequestParameters{" + + "code='" + + code + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReportRequestParameters.Builder { + + String code; + + public Builder() { + super(VerificationMethodType.CALLOUT); + } + + public Builder setCode(String code) { + this.code = code; + return this; + } + + @Override + public VerificationReportCalloutRequestParameters build() { + return new VerificationReportCalloutRequestParameters(code); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParameters.java new file mode 100644 index 00000000..b975f958 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParameters.java @@ -0,0 +1,56 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; + +public class VerificationReportFlashCallRequestParameters + extends VerificationReportRequestParameters { + + private final String cli; + + public VerificationReportFlashCallRequestParameters(String cli) { + super(VerificationMethodType.FLASH_CALL); + this.cli = cli; + } + + public String getCli() { + return cli; + } + + @Override + public String toString() { + return "VerificationReportFlashCallRequestParameters{" + + "cli='" + + cli + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReportRequestParameters.Builder { + + String cli; + + public Builder() { + super(VerificationMethodType.FLASH_CALL); + } + + public Builder setCli(String cli) { + this.cli = cli; + return this; + } + + @Override + public VerificationReportFlashCallRequestParameters build() { + return new VerificationReportFlashCallRequestParameters(cli); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParameters.java new file mode 100644 index 00000000..af873ac2 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParameters.java @@ -0,0 +1,53 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import java.util.Objects; + +public class VerificationReportRequestParameters { + + private final VerificationMethodType method; + + public VerificationReportRequestParameters(VerificationMethodType method) { + Objects.requireNonNull(method); + + this.method = method; + } + + public VerificationMethodType getMethod() { + return method; + } + + @Override + public String toString() { + return "VerificationReportRequestParameters{" + "method=" + method + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> { + + VerificationMethodType method; + + public Builder() {} + + public Builder(VerificationMethodType method) { + this.method = method; + } + + protected B setMethod(VerificationMethodType method) { + this.method = method; + return self(); + } + + public VerificationReportRequestParameters build() { + return new VerificationReportRequestParameters(method); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParameters.java new file mode 100644 index 00000000..a0e0e03d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParameters.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import java.util.Optional; + +public class VerificationReportSMSRequestParameters extends VerificationReportRequestParameters { + + private final String code; + private final String cli; + + public VerificationReportSMSRequestParameters(String code, String cli) { + super(VerificationMethodType.SMS); + this.code = code; + this.cli = cli; + } + + public String getCode() { + return code; + } + + public Optional getCli() { + return Optional.ofNullable(cli); + } + + @Override + public String toString() { + return "VerificationReportSMSRequestParameters{" + + "code='" + + code + + '\'' + + ", cli='" + + cli + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder extends VerificationReportRequestParameters.Builder { + + String code; + String cli; + + public Builder() { + super(VerificationMethodType.SMS); + } + + public Builder setCode(String code) { + this.code = code; + return this; + } + + public Builder setCli(String cli) { + this.cli = cli; + return this; + } + + @Override + public VerificationReportSMSRequestParameters build() { + return new VerificationReportSMSRequestParameters(code, cli); + } + + @Override + protected Builder self() { + return this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java index 0cc34ae6..c547e3de 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java @@ -1,24 +1,25 @@ package com.sinch.sdk.domains.verification.models.response; import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.VerificationId; import java.util.Collection; /** Comme class to all Start verification requests */ public class StartVerificationResponse { - private final String id; + private final VerificationId id; private final Collection links; /** * @param id Verification identifier used to query for status. * @param links Available methods and actions which can be done after a successful Verification */ - public StartVerificationResponse(String id, Collection links) { + public StartVerificationResponse(VerificationId id, Collection links) { this.id = id; this.links = links; } - public String getId() { + public VerificationId getId() { return id; } @@ -37,10 +38,10 @@ public static Builder builder() { public static class Builder> { - String id; + VerificationId id; Collection links; - public B setId(String id) { + public B setId(VerificationId id) { this.id = id; return self(); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java index c2f510ef..b7649db5 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.verification.models.response; import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.VerificationId; import java.util.Collection; /** Dedicated response type for a callout verification */ @@ -10,7 +11,7 @@ public class StartVerificationResponseCallout extends StartVerificationResponse * @param id Verification identifier used to query for status. * @param links Available methods and actions which can be done after a successful Verification */ - public StartVerificationResponseCallout(String id, Collection links) { + public StartVerificationResponseCallout(VerificationId id, Collection links) { super(id, links); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java index a51cb324..7cdb59f6 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.verification.models.response; import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.VerificationId; import java.util.Collection; /** Dedicated response type for a flashcall verification */ @@ -22,7 +23,7 @@ public class StartVerificationResponseFlashCall extends StartVerificationRespons * the set time in seconds. */ public StartVerificationResponseFlashCall( - String id, + VerificationId id, Collection links, String cliFilter, Integer interceptionTimeOut, diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java index aaaba2ec..5e652285 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.verification.models.response; import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.VerificationId; import java.util.Collection; /** Dedicated response type for a sms verification */ @@ -17,7 +18,7 @@ public class StartVerificationResponseSMS extends StartVerificationResponse { * SMS. */ public StartVerificationResponseSMS( - String id, Collection links, String template, Integer interceptionTimeOut) { + VerificationId id, Collection links, String template, Integer interceptionTimeOut) { super(id, links); this.template = template; this.interceptionTimeOut = interceptionTimeOut; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java index a630b06d..173d7279 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.verification.models.response; import com.sinch.sdk.domains.verification.models.Link; +import com.sinch.sdk.domains.verification.models.VerificationId; import java.util.Collection; /** Dedicated response type for a seamless verification */ @@ -13,7 +14,8 @@ public class StartVerificationResponseSeamless extends StartVerificationResponse * @param links Available methods and actions which can be done after a successful Verification * @param targetUri The target URI */ - public StartVerificationResponseSeamless(String id, Collection links, String targetUri) { + public StartVerificationResponseSeamless( + VerificationId id, Collection links, String targetUri) { super(id, links); this.targetUri = targetUri; } diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/StatusServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/StatusServiceTest.java new file mode 100644 index 00000000..f3378ce8 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/StatusServiceTest.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.verification.adapters; + +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +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.verification.adapters.api.v1.QueryVerificationsApi; +import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverterTest; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportDtoTest; +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 +public class StatusServiceTest extends BaseTest { + + @Mock Configuration configuration; + @Mock QueryVerificationsApi api; + @InjectMocks StatusService service; + + @Test + void getByIdentity() throws ApiException { + + when(api.verificationStatusByIdentity(eq("number"), eq("endpoint string"), eq("sms"))) + .thenReturn(VerificationReportDtoTest.expectedVerificationCalloutDto); + + VerificationReport response = + service.get( + NumberIdentity.builder().setEndpoint("endpoint string").build(), + VerificationMethodType.SMS); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedVerificationReportCalloutResponse); + } + + @Test + void getById() throws ApiException { + + when(api.verificationStatusById(eq("the id"))) + .thenReturn(VerificationReportDtoTest.expectedVerificationCalloutDto); + + VerificationReport response = service.get(VerificationId.valueOf("the id")); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedVerificationReportCalloutResponse); + } + + @Test + void getByReference() throws ApiException { + + when(api.verificationStatusByReference(eq("the reference"))) + .thenReturn(VerificationReportDtoTest.expectedVerificationCalloutDto); + + VerificationReport response = service.get(VerificationReference.valueOf("the reference")); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedVerificationReportCalloutResponse); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java index 3a2b2ab9..a41c11b9 100644 --- a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/VerificationsServiceTest.java @@ -7,17 +7,19 @@ 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.sms.models.dto.v1.ApiDeliveryFeedbackDto; import com.sinch.sdk.domains.verification.adapters.api.v1.SendingAndReportingVerificationsApi; import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverterTest; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationReport; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; -import com.sinch.sdk.domains.verification.models.dto.v1.StartStartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.StartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestResourceDto; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; import com.sinch.sdk.models.Configuration; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.InjectMocks; import org.mockito.Mock; @@ -27,17 +29,18 @@ public class VerificationsServiceTest extends BaseTest { @GivenJsonResource("/domains/verification/v1/StartVerificationSMSRequestDto.json") public InitiateVerificationResourceDto startVerificationSMSRequestDto; + @GivenJsonResource("/domains/verification/v1/VerificationReportCalloutRequestDto.json") + public VerificationReportRequestResourceDto verificationReportRequestResourceDto; + @Mock Configuration configuration; @Mock SendingAndReportingVerificationsApi api; @InjectMocks VerificationsService service; - @Captor ArgumentCaptor recipientsCaptor; - @Test void start() throws ApiException { when(api.startVerification(eq(startVerificationSMSRequestDto))) - .thenReturn(StartStartVerificationResponseDtoTest.expectedStartVerificationSMSDto); + .thenReturn(StartVerificationResponseDtoTest.expectedStartVerificationSMSDto); StartVerificationResponse response = service.start(VerificationsDtoConverterTest.startVerificationSMSRequest); @@ -46,4 +49,37 @@ void start() throws ApiException { .usingRecursiveComparison() .isEqualTo(VerificationsDtoConverterTest.expectedStartVerificationSMSResponse); } + + @Test + void getByIdentity() throws ApiException { + + when(api.reportVerificationByIdentity( + eq("number"), eq("endpoint string"), eq(verificationReportRequestResourceDto))) + .thenReturn(VerificationReportDtoTest.expectedVerificationCalloutDto); + + VerificationReport response = + service.report( + NumberIdentity.builder().setEndpoint("endpoint string").build(), + VerificationsDtoConverterTest.verificationReportCalloutRequest); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedVerificationReportCalloutResponse); + } + + @Test + void getById() throws ApiException { + + when(api.reportVerificationById(eq("the id"), eq(verificationReportRequestResourceDto))) + .thenReturn(VerificationReportDtoTest.expectedVerificationCalloutDto); + + VerificationReport response = + service.report( + VerificationId.valueOf("the id"), + VerificationsDtoConverterTest.verificationReportCalloutRequest); + + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(VerificationsDtoConverterTest.expectedVerificationReportCalloutResponse); + } } diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java index c49e85d1..dc8d333a 100644 --- a/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverterTest.java @@ -2,11 +2,24 @@ import com.sinch.sdk.BaseTest; import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; -import com.sinch.sdk.domains.verification.models.dto.v1.StartStartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.Price; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReportCallout; +import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; +import com.sinch.sdk.domains.verification.models.VerificationReportReasonType; +import com.sinch.sdk.domains.verification.models.VerificationReportSMS; +import com.sinch.sdk.domains.verification.models.VerificationReportStatusType; import com.sinch.sdk.domains.verification.models.dto.v1.StartVerificationRequestDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.StartVerificationResponseDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportDtoTest; +import com.sinch.sdk.domains.verification.models.dto.v1.VerificationReportRequestDtoTest; import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportCalloutRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportSMSRequestParameters; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseCallout; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseFlashCall; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSMS; @@ -17,28 +30,28 @@ public class VerificationsDtoConverterTest extends BaseTest { public static StartVerificationRequestParameters startVerificationCalloutRequest = - StartVerificationRequestParameters.builder(VerificationMethod.CALLOUT) + StartVerificationRequestParameters.builder(VerificationMethodType.CALLOUT) .setCustom("a custom") - .setReference("a reference") + .setReference(VerificationReference.valueOf("a reference")) .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) .build(); public static StartVerificationResponseCallout expectedStartVerificationCalloutResponse = StartVerificationResponseCallout.builder() - .setId("the id") + .setId(VerificationId.valueOf("the id")) .setLinks(LinkDtoConverterTest.linksClient) .build(); public static StartVerificationRequestParameters startVerificationFlashCallRequest = StartVerificationFlashCallRequestParameters.builder() .setCustom("a custom") - .setReference("a reference") + .setReference(VerificationReference.valueOf("a reference")) .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) .setDialTimeOut(17) .build(); public static StartVerificationResponseFlashCall expectedStartVerificationFlashCallResponse = StartVerificationResponseFlashCall.builder() - .setId("the id") + .setId(VerificationId.valueOf("the id")) .setLinks(LinkDtoConverterTest.linksClient) .setCliFilter("(.*)5312(.*)") .setInterceptionTimeOut(45) @@ -46,26 +59,26 @@ public class VerificationsDtoConverterTest extends BaseTest { .setDenyCallAfter(0) .build(); public static StartVerificationRequestParameters startVerificationSeamlessRequest = - StartVerificationRequestParameters.builder(VerificationMethod.SEAMLESS) + StartVerificationRequestParameters.builder(VerificationMethodType.SEAMLESS) .setCustom("a custom") - .setReference("a reference") + .setReference(VerificationReference.valueOf("a reference")) .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) .build(); public static StartVerificationResponseSeamless expectedStartVerificationSeamlessResponse = StartVerificationResponseSeamless.builder() - .setId("the id") + .setId(VerificationId.valueOf("the id")) .setLinks(LinkDtoConverterTest.linksClient) .setTargetUri("target URI") .build(); public static StartVerificationRequestParameters startVerificationSMSRequest = - StartVerificationRequestParameters.builder(VerificationMethod.SMS) + StartVerificationRequestParameters.builder(VerificationMethodType.SMS) .setCustom("a custom") - .setReference("a reference") + .setReference(VerificationReference.valueOf("a reference")) .setIdentity(NumberIdentity.builder().setEndpoint("+endpoint").build()) .build(); public static StartVerificationResponseSMS expectedStartVerificationSMSResponse = StartVerificationResponseSMS.builder() - .setId("the id") + .setId(VerificationId.valueOf("the id")) .setLinks(LinkDtoConverterTest.linksClient) .setTemplate("Your verification code is {{CODE}}. Verified by Sinch") .setInterceptionTimeOut(298) @@ -108,7 +121,7 @@ void convertStartCalloutResponse() { Assertions.assertThat( VerificationsDtoConverter.convert( - StartStartVerificationResponseDtoTest.expectedStartVerificationCalloutDto)) + StartVerificationResponseDtoTest.expectedStartVerificationCalloutDto)) .usingRecursiveComparison() .isEqualTo(expectedStartVerificationCalloutResponse); } @@ -118,7 +131,7 @@ void convertStartFlashCallResponse() { Assertions.assertThat( VerificationsDtoConverter.convert( - StartStartVerificationResponseDtoTest.expectedStartVerificationFlashCallDto)) + StartVerificationResponseDtoTest.expectedStartVerificationFlashCallDto)) .usingRecursiveComparison() .isEqualTo(expectedStartVerificationFlashCallResponse); } @@ -128,7 +141,7 @@ void convertStartSeamlessResponse() { Assertions.assertThat( VerificationsDtoConverter.convert( - StartStartVerificationResponseDtoTest.expectedStartVerificationSeamlessDto)) + StartVerificationResponseDtoTest.expectedStartVerificationSeamlessDto)) .usingRecursiveComparison() .isEqualTo(expectedStartVerificationSeamlessResponse); } @@ -138,8 +151,116 @@ void convertStartSMSResponse() { Assertions.assertThat( VerificationsDtoConverter.convert( - StartStartVerificationResponseDtoTest.expectedStartVerificationSMSDto)) + StartVerificationResponseDtoTest.expectedStartVerificationSMSDto)) .usingRecursiveComparison() .isEqualTo(expectedStartVerificationSMSResponse); } + + public static VerificationReportCalloutRequestParameters verificationReportCalloutRequest = + VerificationReportCalloutRequestParameters.builder().setCode("foo code").build(); + + public static VerificationReportCallout expectedVerificationReportCalloutResponse = + VerificationReportCallout.builder() + .setId(VerificationId.valueOf("the id")) + .setStatus(VerificationReportStatusType.FAIL) + .setReason(VerificationReportReasonType.FRAUD) + .setCallComplete(true) + .setReference(VerificationReference.valueOf("my reference")) + .setVerificationPrice( + Price.builder() + .setCurrencyId("verificationPrice currency id") + .setAmount(3.141516F) + .build()) + .setTerminationPrice( + Price.builder() + .setCurrencyId("terminationPrice currency id") + .setAmount(6.626070F) + .build()) + .setBillableDuration(34) + .build(); + + @Test + void convertReportCalloutRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(verificationReportCalloutRequest)) + .usingRecursiveComparison() + .isEqualTo(VerificationReportRequestDtoTest.verificationReportCalloutDto); + } + + @Test + void convertReportCalloutResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + VerificationReportDtoTest.expectedVerificationCalloutDto)) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationReportCalloutResponse); + } + + public static VerificationReportFlashCallRequestParameters verificationReportFlashCallRequest = + VerificationReportFlashCallRequestParameters.builder().setCli("foo cli").build(); + + public static VerificationReportFlashCall expectedVerificationReportFlashCallResponse = + VerificationReportFlashCall.builder() + .setId(VerificationId.valueOf("the id")) + .setStatus(VerificationReportStatusType.FAIL) + .setReason(VerificationReportReasonType.FRAUD) + .setReference(VerificationReference.valueOf("my reference")) + .setSource("my source") + .build(); + + @Test + void convertReportFlashCallRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(verificationReportFlashCallRequest)) + .usingRecursiveComparison() + .isEqualTo(VerificationReportRequestDtoTest.verificationReportFlashCallDto); + } + + @Test + void convertReportFlashCallResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert( + VerificationReportDtoTest.expectedVerificationFlashCallDto)) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationReportFlashCallResponse); + } + + public static VerificationReportSMSRequestParameters verificationReportSMSRequest = + VerificationReportSMSRequestParameters.builder() + .setCode("foo code") + .setCli("foo cli") + .build(); + + public static VerificationReportSMS expectedVerificationReportSMSResponse = + VerificationReportSMS.builder() + .setId(VerificationId.valueOf("the id")) + .setStatus(VerificationReportStatusType.FAIL) + .setReason(VerificationReportReasonType.FRAUD) + .setReference(VerificationReference.valueOf("my reference")) + .setSource("my source") + .setVerificationPrice( + Price.builder() + .setCurrencyId("verificationPrice currency id") + .setAmount(3.141516F) + .build()) + .build(); + + @Test + void convertReportSMSRequest() { + + Assertions.assertThat(VerificationsDtoConverter.convert(verificationReportSMSRequest)) + .usingRecursiveComparison() + .isEqualTo(VerificationReportRequestDtoTest.verificationReportSMSDto); + } + + @Test + void convertReportSMSResponse() { + + Assertions.assertThat( + VerificationsDtoConverter.convert(VerificationReportDtoTest.expectedVerificationSMSDto)) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationReportSMSResponse); + } } diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java index 433f8b57..49a8143d 100644 --- a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParametersTest.java @@ -2,14 +2,15 @@ import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; class StartVerificationFlashCallRequestParametersTest { final Identity identity = NumberIdentity.builder().setEndpoint("foo identity").build(); - final VerificationMethod method = VerificationMethod.FLASH_CALL; + final VerificationMethodType method = VerificationMethodType.FLASH_CALL; final String reference = "foo reference"; final String custom = "foo custom"; @@ -17,7 +18,7 @@ class StartVerificationFlashCallRequestParametersTest { final StartVerificationFlashCallRequestParameters value = StartVerificationFlashCallRequestParameters.builder() .setIdentity(identity) - .setReference(reference) + .setReference(VerificationReference.valueOf(reference)) .setCustom(custom) .setDialTimeOut(dialTimeOut) .build(); @@ -34,7 +35,7 @@ void getMethod() { @Test void getReference() { - Assertions.assertThat(value.getReference().get()).isEqualTo(reference); + Assertions.assertThat(value.getReference().get().getReference()).isEqualTo(reference); } @Test diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java index a8399a80..42d8969a 100644 --- a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParametersTest.java @@ -2,14 +2,15 @@ import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; class StartVerificationRequestParametersTest { final Identity identity = NumberIdentity.builder().setEndpoint("foo identity").build(); - final VerificationMethod method = VerificationMethod.CALLOUT; + final VerificationMethodType method = VerificationMethodType.CALLOUT; final String reference = "foo reference"; final String custom = "foo custom"; @@ -17,7 +18,7 @@ class StartVerificationRequestParametersTest { StartVerificationRequestParameters.builder() .setIdentity(identity) .setMethod(method) - .setReference(reference) + .setReference(VerificationReference.valueOf(reference)) .setCustom(custom) .build(); @@ -33,7 +34,7 @@ void getMethod() { @Test void getReference() { - Assertions.assertThat(value.getReference().get()).isEqualTo(reference); + Assertions.assertThat(value.getReference().get().getReference()).isEqualTo(reference); } @Test diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParametersTest.java new file mode 100644 index 00000000..5fa4b4c3 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParametersTest.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class VerificationReportCalloutRequestParametersTest { + + final String code = "foo code"; + + final VerificationReportCalloutRequestParameters value = + VerificationReportCalloutRequestParameters.builder().setCode(code).build(); + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(VerificationMethodType.CALLOUT); + } + + @Test + void getCode() { + Assertions.assertThat(value.getCode()).isEqualTo(code); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParametersTest.java new file mode 100644 index 00000000..21265bcd --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParametersTest.java @@ -0,0 +1,23 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class VerificationReportFlashCallRequestParametersTest { + + final String cli = "foo cli"; + + final VerificationReportFlashCallRequestParameters value = + VerificationReportFlashCallRequestParameters.builder().setCli(cli).build(); + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(VerificationMethodType.FLASH_CALL); + } + + @Test + void getCli() { + Assertions.assertThat(value.getCli()).isEqualTo(cli); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParametersTest.java new file mode 100644 index 00000000..75b280cb --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParametersTest.java @@ -0,0 +1,18 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class VerificationReportRequestParametersTest { + + final VerificationMethodType method = VerificationMethodType.CALLOUT; + + final VerificationReportRequestParameters value = + VerificationReportRequestParameters.builder().setMethod(method).build(); + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(method); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParametersTest.java new file mode 100644 index 00000000..0c65f7e6 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParametersTest.java @@ -0,0 +1,29 @@ +package com.sinch.sdk.domains.verification.models.requests; + +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +class VerificationReportSMSRequestParametersTest { + + final String code = "foo code"; + final String cli = "foo cli"; + + final VerificationReportSMSRequestParameters value = + VerificationReportSMSRequestParameters.builder().setCode(code).setCli(cli).build(); + + @Test + void getMethod() { + Assertions.assertThat(value.getMethod()).isEqualTo(VerificationMethodType.SMS); + } + + @Test + void getCode() { + Assertions.assertThat(value.getCode()).isEqualTo(code); + } + + @Test + void getCli() { + Assertions.assertThat(value.getCli().get()).isEqualTo(cli); + } +} diff --git a/core/src/main/com/sinch/sdk/core/http/URLPathUtils.java b/core/src/main/com/sinch/sdk/core/http/URLPathUtils.java new file mode 100644 index 00000000..dbd310ce --- /dev/null +++ b/core/src/main/com/sinch/sdk/core/http/URLPathUtils.java @@ -0,0 +1,22 @@ +package com.sinch.sdk.core.http; + +import com.sinch.sdk.core.utils.StringUtil; +import java.net.URI; +import java.net.URISyntaxException; + +public class URLPathUtils { + + public static String encodePathSegment(String segment) { + + if (StringUtil.isEmpty(segment)) { + return ""; + } + URI uri; + try { + uri = new URI("foo", "foo", "/" + segment, null); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + return uri.getRawPath().substring(1); + } +} 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 index b4495ea2..90222d8d 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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; @@ -116,11 +116,10 @@ private HttpRequest numberServiceGetActiveNumberRequestBuilder( String localVarPath = "/v1/projects/{projectId}/activeNumbers/{phoneNumber}" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())) + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())) .replaceAll( "\\{" + "phoneNumber" + "\\}", - URLParameterUtils.encodeParameterValue(phoneNumber.toString())); + URLPathUtils.encodePathSegment(phoneNumber.toString())); List localVarQueryParams = new ArrayList<>(); @@ -271,8 +270,7 @@ private HttpRequest numberServiceListActiveNumbersRequestBuilder( String localVarPath = "/v1/projects/{projectId}/activeNumbers" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != regionCode) { @@ -401,11 +399,10 @@ private HttpRequest numberServiceReleaseNumberRequestBuilder(String projectId, S String localVarPath = "/v1/projects/{projectId}/activeNumbers/{phoneNumber}:release" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())) + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())) .replaceAll( "\\{" + "phoneNumber" + "\\}", - URLParameterUtils.encodeParameterValue(phoneNumber.toString())); + URLPathUtils.encodePathSegment(phoneNumber.toString())); List localVarQueryParams = new ArrayList<>(); @@ -501,11 +498,10 @@ private HttpRequest numberServiceUpdateActiveNumberRequestBuilder( String localVarPath = "/v1/projects/{projectId}/activeNumbers/{phoneNumber}" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())) + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())) .replaceAll( "\\{" + "phoneNumber" + "\\}", - URLParameterUtils.encodeParameterValue(phoneNumber.toString())); + URLPathUtils.encodePathSegment(phoneNumber.toString())); List localVarQueryParams = new ArrayList<>(); 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 index 40674927..5b8d74e3 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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; @@ -123,11 +123,10 @@ private HttpRequest numberServiceGetAvailableNumberRequestBuilder( String localVarPath = "/v1/projects/{projectId}/availableNumbers/{phoneNumber}" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())) + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())) .replaceAll( "\\{" + "phoneNumber" + "\\}", - URLParameterUtils.encodeParameterValue(phoneNumber.toString())); + URLPathUtils.encodePathSegment(phoneNumber.toString())); List localVarQueryParams = new ArrayList<>(); @@ -267,8 +266,7 @@ private HttpRequest numberServiceListAvailableNumbersRequestBuilder( String localVarPath = "/v1/projects/{projectId}/availableNumbers" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != numberPatternPattern) { @@ -389,8 +387,7 @@ private HttpRequest numberServiceRentAnyNumberRequestBuilder( String localVarPath = "/v1/projects/{projectId}/availableNumbers:rentAny" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -487,11 +484,10 @@ private HttpRequest numberServiceRentNumberRequestBuilder( String localVarPath = "/v1/projects/{projectId}/availableNumbers/{phoneNumber}:rent" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())) + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())) .replaceAll( "\\{" + "phoneNumber" + "\\}", - URLParameterUtils.encodeParameterValue(phoneNumber.toString())); + URLPathUtils.encodePathSegment(phoneNumber.toString())); List localVarQueryParams = new ArrayList<>(); 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 index 6ce73532..fc49aa7a 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.domains.numbers.models.dto.v1.ListAvailableRegionsResponseDto; import java.util.ArrayList; @@ -112,8 +112,7 @@ private HttpRequest numberServiceListAvailableRegionsRequestBuilder( String localVarPath = "/v1/projects/{projectId}/availableRegions" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != types) { 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 index 120d64dc..5f35b55f 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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; @@ -97,8 +97,7 @@ private HttpRequest getCallbackConfigurationRequestBuilder(String projectId) thr String localVarPath = "/v1/projects/{projectId}/callbackConfiguration" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -177,8 +176,7 @@ private HttpRequest updateCallbackConfigurationRequestBuilder( String localVarPath = "/v1/projects/{projectId}/callbackConfiguration" .replaceAll( - "\\{" + "projectId" + "\\}", - URLParameterUtils.encodeParameterValue(projectId.toString())); + "\\{" + "projectId" + "\\}", URLPathUtils.encodePathSegment(projectId.toString())); List localVarQueryParams = new ArrayList<>(); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java index 266bdc50..957773cc 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/sms/adapters/api/v1/BatchesApi.java @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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; @@ -115,10 +115,9 @@ private HttpRequest cancelBatchMessageRequestBuilder(String servicePlanId, Strin "/xms/v1/{service_plan_id}/batches/{batch_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -215,10 +214,9 @@ private HttpRequest deliveryFeedbackRequestBuilder( "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_feedback" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -311,7 +309,7 @@ private HttpRequest dryRunRequestBuilder( "/xms/v1/{service_plan_id}/batches/dry_run" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != perRecipient) { @@ -401,10 +399,9 @@ private HttpRequest getBatchMessageRequestBuilder(String servicePlanId, String b "/xms/v1/{service_plan_id}/batches/{batch_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -519,7 +516,7 @@ private HttpRequest listBatchesRequestBuilder( "/xms/v1/{service_plan_id}/batches" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != page) { @@ -636,10 +633,9 @@ private HttpRequest replaceBatchRequestBuilder( "/xms/v1/{service_plan_id}/batches/{batch_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -718,7 +714,7 @@ private HttpRequest sendSMSRequestBuilder( "/xms/v1/{service_plan_id}/batches" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -809,10 +805,9 @@ private HttpRequest updateBatchMessageRequestBuilder( "/xms/v1/{service_plan_id}/batches/{batch_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); 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 index df92a507..af2bc6e1 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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; @@ -134,10 +134,9 @@ private HttpRequest getDeliveryReportByBatchIdRequestBuilder( "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_report" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())); + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != type) { @@ -245,13 +244,12 @@ private HttpRequest getDeliveryReportByPhoneNumberRequestBuilder( "/xms/v1/{service_plan_id}/batches/{batch_id}/delivery_report/{recipient_msisdn}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "batch_id" + "\\}", - URLParameterUtils.encodeParameterValue(batchId.toString())) + "\\{" + "batch_id" + "\\}", URLPathUtils.encodePathSegment(batchId.toString())) .replaceAll( "\\{" + "recipient_msisdn" + "\\}", - URLParameterUtils.encodeParameterValue(recipientMsisdn.toString())); + URLPathUtils.encodePathSegment(recipientMsisdn.toString())); List localVarQueryParams = new ArrayList<>(); @@ -369,7 +367,7 @@ private HttpRequest getDeliveryReportsRequestBuilder( "/xms/v1/{service_plan_id}/delivery_reports" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != page) { 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 index d258a8ae..88ead4ca 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupListDto; import com.sinch.sdk.domains.sms.models.dto.v1.CreateGroupResponseDto; @@ -111,7 +111,7 @@ private HttpRequest createGroupRequestBuilder(String servicePlanId, GroupObjectD "/xms/v1/{service_plan_id}/groups" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -181,10 +181,9 @@ private HttpRequest deleteGroupRequestBuilder(String servicePlanId, String group "/xms/v1/{service_plan_id}/groups/{group_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "group_id" + "\\}", - URLParameterUtils.encodeParameterValue(groupId.toString())); + "\\{" + "group_id" + "\\}", URLPathUtils.encodePathSegment(groupId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -257,10 +256,9 @@ private HttpRequest getMembersRequestBuilder(String servicePlanId, String groupI "/xms/v1/{service_plan_id}/groups/{group_id}/members" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "group_id" + "\\}", - URLParameterUtils.encodeParameterValue(groupId.toString())); + "\\{" + "group_id" + "\\}", URLPathUtils.encodePathSegment(groupId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -338,7 +336,7 @@ private HttpRequest listGroupsRequestBuilder(String servicePlanId, Integer page, "/xms/v1/{service_plan_id}/groups" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != page) { @@ -435,10 +433,9 @@ private HttpRequest replaceGroupRequestBuilder( "/xms/v1/{service_plan_id}/groups/{group_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "group_id" + "\\}", - URLParameterUtils.encodeParameterValue(groupId.toString())); + "\\{" + "group_id" + "\\}", URLPathUtils.encodePathSegment(groupId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -512,10 +509,9 @@ private HttpRequest retrieveGroupRequestBuilder(String servicePlanId, String gro "/xms/v1/{service_plan_id}/groups/{group_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "group_id" + "\\}", - URLParameterUtils.encodeParameterValue(groupId.toString())); + "\\{" + "group_id" + "\\}", URLPathUtils.encodePathSegment(groupId.toString())); List localVarQueryParams = new ArrayList<>(); @@ -611,10 +607,9 @@ private HttpRequest updateGroupRequestBuilder( "/xms/v1/{service_plan_id}/groups/{group_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "group_id" + "\\}", - URLParameterUtils.encodeParameterValue(groupId.toString())); + "\\{" + "group_id" + "\\}", URLPathUtils.encodePathSegment(groupId.toString())); List localVarQueryParams = new ArrayList<>(); 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 index 9b150ba7..a210a142 100644 --- 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 @@ -23,7 +23,7 @@ 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.http.URLPathUtils; 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.InboundDto; @@ -157,7 +157,7 @@ private HttpRequest listInboundMessagesRequestBuilder( "/xms/v1/{service_plan_id}/inbounds" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())); + URLPathUtils.encodePathSegment(servicePlanId.toString())); List localVarQueryParams = new ArrayList<>(); if (null != page) { @@ -268,10 +268,9 @@ private HttpRequest retrieveInboundMessageRequestBuilder(String servicePlanId, S "/xms/v1/{service_plan_id}/inbounds/{inbound_id}" .replaceAll( "\\{" + "service_plan_id" + "\\}", - URLParameterUtils.encodeParameterValue(servicePlanId.toString())) + URLPathUtils.encodePathSegment(servicePlanId.toString())) .replaceAll( - "\\{" + "inbound_id" + "\\}", - URLParameterUtils.encodeParameterValue(inboundId.toString())); + "\\{" + "inbound_id" + "\\}", URLPathUtils.encodePathSegment(inboundId.toString())); List localVarQueryParams = new ArrayList<>(); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java index 76209924..60a6c2df 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/QueryVerificationsApi.java @@ -23,7 +23,7 @@ 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.http.URLPathUtils; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.domains.verification.models.dto.v1.VerificationResponseDto; import java.util.ArrayList; @@ -94,8 +94,7 @@ private HttpRequest verificationStatusByIdRequestBuilder(String id) throws ApiEx String localVarPath = "/verification/v1/verifications/id/{id}" - .replaceAll( - "\\{" + "id" + "\\}", URLParameterUtils.encodeParameterValue(id.toString())); + .replaceAll("\\{" + "id" + "\\}", URLPathUtils.encodePathSegment(id.toString())); List localVarQueryParams = new ArrayList<>(); @@ -182,14 +181,11 @@ private HttpRequest verificationStatusByIdentityRequestBuilder( String localVarPath = "/verification/v1/verifications/{method}/{type}/{endpoint}" + .replaceAll("\\{" + "type" + "\\}", URLPathUtils.encodePathSegment(type.toString())) .replaceAll( - "\\{" + "type" + "\\}", URLParameterUtils.encodeParameterValue(type.toString())) - .replaceAll( - "\\{" + "endpoint" + "\\}", - URLParameterUtils.encodeParameterValue(endpoint.toString())) + "\\{" + "endpoint" + "\\}", URLPathUtils.encodePathSegment(endpoint.toString())) .replaceAll( - "\\{" + "method" + "\\}", - URLParameterUtils.encodeParameterValue(method.toString())); + "\\{" + "method" + "\\}", URLPathUtils.encodePathSegment(method.toString())); List localVarQueryParams = new ArrayList<>(); @@ -256,8 +252,7 @@ private HttpRequest verificationStatusByReferenceRequestBuilder(String reference String localVarPath = "/verification/v1/verifications/reference/{reference}" .replaceAll( - "\\{" + "reference" + "\\}", - URLParameterUtils.encodeParameterValue(reference.toString())); + "\\{" + "reference" + "\\}", URLPathUtils.encodePathSegment(reference.toString())); List localVarQueryParams = new ArrayList<>(); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java index bc2019d5..58f2d62a 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/adapters/api/v1/SendingAndReportingVerificationsApi.java @@ -23,7 +23,7 @@ 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.http.URLPathUtils; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResourceDto; import com.sinch.sdk.domains.verification.models.dto.v1.InitiateVerificationResponseDto; @@ -116,8 +116,7 @@ private HttpRequest reportVerificationByIdRequestBuilder( String localVarPath = "/verification/v1/verifications/id/{id}" - .replaceAll( - "\\{" + "id" + "\\}", URLParameterUtils.encodeParameterValue(id.toString())); + .replaceAll("\\{" + "id" + "\\}", URLPathUtils.encodePathSegment(id.toString())); List localVarQueryParams = new ArrayList<>(); @@ -214,11 +213,9 @@ private HttpRequest reportVerificationByIdentityRequestBuilder( String localVarPath = "/verification/v1/verifications/{type}/{endpoint}" + .replaceAll("\\{" + "type" + "\\}", URLPathUtils.encodePathSegment(type.toString())) .replaceAll( - "\\{" + "type" + "\\}", URLParameterUtils.encodeParameterValue(type.toString())) - .replaceAll( - "\\{" + "endpoint" + "\\}", - URLParameterUtils.encodeParameterValue(endpoint.toString())); + "\\{" + "endpoint" + "\\}", URLPathUtils.encodePathSegment(endpoint.toString())); List localVarQueryParams = new ArrayList<>(); @@ -296,8 +293,7 @@ private HttpRequest startVerificationRequestBuilder( final Collection localVarAccepts = Arrays.asList("application/json"); - final Collection localVarContentTypes = - Arrays.asList("application/json; charset=UTF-8"); + final Collection localVarContentTypes = Arrays.asList("application/json"); final Collection localVarAuthNames = Arrays.asList("Basic"); final String serializedBody = diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java index fee86e3c..c11e3016 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/verification/models/dto/v1/VerificationResponseDto.java @@ -336,7 +336,7 @@ public void setCallResult(String callResult) { this.callResult = callResult; } - /** Return true if this StartVerificationResponse object is equal to o. */ + /** Return true if this VerificationResponse object is equal to o. */ @Override public boolean equals(Object o) { if (this == o) { diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationResponseDtoTest.java similarity index 98% rename from openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java rename to openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationResponseDtoTest.java index 37ac1660..deebc0c1 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartStartVerificationResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/StartVerificationResponseDtoTest.java @@ -7,7 +7,7 @@ import org.junit.jupiter.api.Test; @TestWithResources -public class StartStartVerificationResponseDtoTest extends BaseTest { +public class StartVerificationResponseDtoTest extends BaseTest { @GivenJsonResource("/domains/verification/v1/StartVerificationCalloutResponseDto.json") InitiateVerificationResponseDto loadedStartVerificationCalloutDto; diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportDtoTest.java new file mode 100644 index 00000000..78441aba --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportDtoTest.java @@ -0,0 +1,90 @@ +package com.sinch.sdk.domains.verification.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 org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class VerificationReportDtoTest extends BaseTest { + + @GivenJsonResource("/domains/verification/v1/VerificationReportCalloutResponseDto.json") + VerificationResponseDto loadedVerificationCalloutDto; + + public static VerificationResponseDto expectedVerificationCalloutDto = + new VerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.CALLOUT) + .status("FAIL") + .reason("Fraud") + .callComplete(true) + .reference("my reference") + .price( + new VerificationResponsePriceDto( + new VerificationPriceInformationDto() + .verificationPrice( + new VerificationPriceInformationVerificationPriceDto( + new MoneyDto() + .currencyId("verificationPrice currency id") + .amount(3.141516F))) + .terminationPrice( + new VerificationPriceInformationTerminationPriceDto( + new MoneyDto() + .currencyId("terminationPrice currency id") + .amount(6.626070F))) + .billableDuration(34))); + + @GivenJsonResource("/domains/verification/v1/VerificationReportFlashCallResponseDto.json") + VerificationResponseDto loadedVerificationFlashCallDto; + + public static VerificationResponseDto expectedVerificationFlashCallDto = + new VerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.FLASHCALL) + .status("FAIL") + .reason("Fraud") + .reference("my reference") + .source("my source"); + + @GivenJsonResource("/domains/verification/v1/VerificationReportSMSResponseDto.json") + VerificationResponseDto loadedVerificationSMSDto; + + public static VerificationResponseDto expectedVerificationSMSDto = + new VerificationResponseDto() + .id("the id") + .method(VerificationMethodDto.SMS) + .status("FAIL") + .reason("Fraud") + .reference("my reference") + .source("my source") + .price( + new VerificationResponsePriceDto( + new VerificationPriceInformationDto() + .verificationPrice( + new VerificationPriceInformationVerificationPriceDto( + new MoneyDto() + .currencyId("verificationPrice currency id") + .amount(3.141516F))))); + + @Test + void deserializeCallout() { + Assertions.assertThat(loadedVerificationCalloutDto) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationCalloutDto); + } + + @Test + void deserializeFlashCall() { + Assertions.assertThat(loadedVerificationFlashCallDto) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationFlashCallDto); + } + + @Test + void deserializeSMS() { + Assertions.assertThat(loadedVerificationSMSDto) + .usingRecursiveComparison() + .isEqualTo(expectedVerificationSMSDto); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestDtoTest.java new file mode 100644 index 00000000..8b016a45 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/verification/models/dto/v1/VerificationReportRequestDtoTest.java @@ -0,0 +1,64 @@ +package com.sinch.sdk.domains.verification.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 org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class VerificationReportRequestDtoTest extends BaseTest { + + @GivenTextResource("/domains/verification/v1/VerificationReportCalloutRequestDto.json") + String jsonVerificationReportCallout; + + public static VerificationReportRequestResourceDto verificationReportCalloutDto = + new VerificationReportRequestResourceDto() + .method(VerificationMethodDto.CALLOUT) + .callout( + new VerificationReportRequestResourceCalloutDto( + new CalloutVerificationReportRequestDto().code("foo code"))); + + @GivenTextResource("/domains/verification/v1/VerificationReportFlashCallRequestDto.json") + String jsonVerificationReportFlashCall; + + public static VerificationReportRequestResourceDto verificationReportFlashCallDto = + new VerificationReportRequestResourceDto() + .method(VerificationMethodDto.FLASHCALL) + .flashcall( + new VerificationReportRequestResourceFlashcallDto( + new FlashcallVerificationReportRequestDto().cli("foo cli"))); + + @GivenTextResource("/domains/verification/v1/VerificationReportSMSRequestDto.json") + String jsonVerificationReportSMS; + + public static VerificationReportRequestResourceDto verificationReportSMSDto = + new VerificationReportRequestResourceDto() + .method(VerificationMethodDto.SMS) + .sms( + new VerificationReportRequestResourceSmsDto( + new SmsVerificationReportRequestDto().code("foo code").cli("foo cli"))); + + @Test + void serializeCallout() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(verificationReportCalloutDto); + + JSONAssert.assertEquals(jsonVerificationReportCallout, serializedString, true); + } + + @Test + void serializeFlashCall() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(verificationReportFlashCallDto); + + JSONAssert.assertEquals(jsonVerificationReportFlashCall, serializedString, true); + } + + @Test + void serializeSMS() throws JsonProcessingException, JSONException { + String serializedString = objectMapper.writeValueAsString(verificationReportSMSDto); + + JSONAssert.assertEquals(jsonVerificationReportSMS, serializedString, true); + } +} diff --git a/sample-app/README.md b/sample-app/README.md index b51dfed9..edb079a1 100644 --- a/sample-app/README.md +++ b/sample-app/README.md @@ -49,38 +49,44 @@ See https://developers.sinch.com for details about these parameters ## Available samples classes -| API | Service | Sample | Class | Notes | -|---------|----------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------| -| Numbers | Available | - CheckAvailability | [com.sinch.sample.numbers.available.CheckAvailability](src/main/java/com/sinch/sample/numbers/available/CheckAvailability.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 | -| | | - List | [com.sinch.sample.sms.batches.List](src/main/java/com/sinch/sample/sms/batches/List.java) | | -| | | - Send | [com.sinch.sample.sms.batches.Send](src/main/java/com/sinch/sample/sms/batches/Send.java) | | -| | | - Replace | [com.sinch.sample.sms.batches.Replace](src/main/java/com/sinch/sample/sms/batches/Replace.java) | Require `BATCH_ID` parameter | -| | | - Update | [com.sinch.sample.sms.batches.Update](src/main/java/com/sinch/sample/sms/batches/Update.java) | Require `BATCH_ID` parameter | -| | | - DryRun | [com.sinch.sample.sms.batches.DryRun](src/main/java/com/sinch/sample/sms/batches/dryRun.java) | | -| | | - Cancel | [com.sinch.sample.sms.batches.Cancel](src/main/java/com/sinch/sample/sms/batches/Cancel.java) | Require `BATCH_ID` parameter | -| | | - SendDeliveryFeedback | [com.sinch.sample.sms.batches.SendDeliveryFeedback](src/main/java/com/sinch/sample/sms/batches/SendDeliveryFeedback.java) | Require `BATCH_ID` parameter | -| | DeliveryReport | - Get | [com.sinch.sample.sms.deliveryReports.Get](src/main/java/com/sinch/sample/sms/deliveryReports/Get.java) | Require `BATCH_ID` parameter | -| | | - GetForNumber | [com.sinch.sample.sms.deliveryReports.GetForNumber](src/main/java/com/sinch/sample/sms/deliveryReports/GetForNumber.java) | Require `BATCH_ID` and `PHONE_NUMBER` parameters | -| | | - List | [com.sinch.sample.sms.deliveryReports.List](src/main/java/com/sinch/sample/sms/deliveryReports/List.java) | | -| | Groups | - Create | [com.sinch.sample.sms.groups.Create](src/main/java/com/sinch/sample/sms/groups/Create.java) | | -| | | - Get | [com.sinch.sample.sms.groups.Get](src/main/java/com/sinch/sample/sms/groups/Get.java) | | -| | | - Delete | [com.sinch.sample.sms.groups.Delete](src/main/java/com/sinch/sample/sms/groups/Delete.java) | | -| | | - List | [com.sinch.sample.sms.groups.List](src/main/java/com/sinch/sample/sms/groups/List.java) | | -| | | - ListMembers | [com.sinch.sample.sms.groups.ListMembers](src/main/java/com/sinch/sample/sms/groups/ListMembers.java) | | -| | | - Replace | [com.sinch.sample.sms.groups.Replace](src/main/java/com/sinch/sample/sms/groups/Replace.java) | | -| | | - Update | [com.sinch.sample.sms.groups.Update](src/main/java/com/sinch/sample/sms/groups/Update.java) | | -| | Inbounds | - Get | [com.sinch.sample.sms.inbounds.Get](src/main/java/com/sinch/sample/sms/inbounds/Get.java) | | -| | | - List | [com.sinch.sample.sms.inbounds.List](src/main/java/com/sinch/sample/sms/inbounds/List.java) | | -| | WebHooks | - DeliveryReport | [com.sinch.sample.sms.webhooks.DeliveryReport](src/main/java/com/sinch/sample/sms/webhooks/DeliveryReport.java) | | -| | | - IncomingSMSReport | [com.sinch.sample.sms.webhooks.IncomingSMS](src/main/java/com/sinch/sample/sms/webhooks/IncomingSMS.java) | | +| API | Service | Sample | Class | Notes | +|--------------|----------------|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------| +| Numbers | Available | - CheckAvailability | [com.sinch.sample.numbers.available.CheckAvailability](src/main/java/com/sinch/sample/numbers/available/CheckAvailability.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 | +| | | - List | [com.sinch.sample.sms.batches.List](src/main/java/com/sinch/sample/sms/batches/List.java) | | +| | | - Send | [com.sinch.sample.sms.batches.Send](src/main/java/com/sinch/sample/sms/batches/Send.java) | | +| | | - Replace | [com.sinch.sample.sms.batches.Replace](src/main/java/com/sinch/sample/sms/batches/Replace.java) | Require `BATCH_ID` parameter | +| | | - Update | [com.sinch.sample.sms.batches.Update](src/main/java/com/sinch/sample/sms/batches/Update.java) | Require `BATCH_ID` parameter | +| | | - DryRun | [com.sinch.sample.sms.batches.DryRun](src/main/java/com/sinch/sample/sms/batches/dryRun.java) | | +| | | - Cancel | [com.sinch.sample.sms.batches.Cancel](src/main/java/com/sinch/sample/sms/batches/Cancel.java) | Require `BATCH_ID` parameter | +| | | - SendDeliveryFeedback | [com.sinch.sample.sms.batches.SendDeliveryFeedback](src/main/java/com/sinch/sample/sms/batches/SendDeliveryFeedback.java) | Require `BATCH_ID` parameter | +| | DeliveryReport | - Get | [com.sinch.sample.sms.deliveryReports.Get](src/main/java/com/sinch/sample/sms/deliveryReports/Get.java) | Require `BATCH_ID` parameter | +| | | - GetForNumber | [com.sinch.sample.sms.deliveryReports.GetForNumber](src/main/java/com/sinch/sample/sms/deliveryReports/GetForNumber.java) | Require `BATCH_ID` and `PHONE_NUMBER` parameters | +| | | - List | [com.sinch.sample.sms.deliveryReports.List](src/main/java/com/sinch/sample/sms/deliveryReports/List.java) | | +| | Groups | - Create | [com.sinch.sample.sms.groups.Create](src/main/java/com/sinch/sample/sms/groups/Create.java) | | +| | | - Get | [com.sinch.sample.sms.groups.Get](src/main/java/com/sinch/sample/sms/groups/Get.java) | | +| | | - Delete | [com.sinch.sample.sms.groups.Delete](src/main/java/com/sinch/sample/sms/groups/Delete.java) | | +| | | - List | [com.sinch.sample.sms.groups.List](src/main/java/com/sinch/sample/sms/groups/List.java) | | +| | | - ListMembers | [com.sinch.sample.sms.groups.ListMembers](src/main/java/com/sinch/sample/sms/groups/ListMembers.java) | | +| | | - Replace | [com.sinch.sample.sms.groups.Replace](src/main/java/com/sinch/sample/sms/groups/Replace.java) | | +| | | - Update | [com.sinch.sample.sms.groups.Update](src/main/java/com/sinch/sample/sms/groups/Update.java) | | +| | Inbounds | - Get | [com.sinch.sample.sms.inbounds.Get](src/main/java/com/sinch/sample/sms/inbounds/Get.java) | | +| | | - List | [com.sinch.sample.sms.inbounds.List](src/main/java/com/sinch/sample/sms/inbounds/List.java) | | +| | WebHooks | - DeliveryReport | [com.sinch.sample.sms.webhooks.DeliveryReport](src/main/java/com/sinch/sample/sms/webhooks/DeliveryReport.java) | | +| | | - IncomingSMSReport | [com.sinch.sample.sms.webhooks.IncomingSMS](src/main/java/com/sinch/sample/sms/webhooks/IncomingSMS.java) | | +| Verification | Report | - Start | [com.sinch.sample.verification.verifications.Start](src/main/java/com/sinch/sample/verification/verifications/Start.java) | | +| | | - GetReportById | [com.sinch.sample.verification.verifications.GetReportById](src/main/java/com/sinch/sample/verification/verifications/GetReportById.java) | | +| | | - GetReportByIdentity | [com.sinch.sample.verification.verifications.GetReportByIdentity](src/main/java/com/sinch/sample/verification/verifications/GetReportByIdentity.java) | | +| | Status | - GetById | [com.sinch.sample.verification.status.GetById](src/main/java/com/sinch/sample/verification/status/GetById.java) | | +| | | - GetByIdentity | [com.sinch.sample.verification.status.GetByIdentity](src/main/java/com/sinch/sample/verification/status/GetByIdentity.java) | | +| | | - GetByReference | [com.sinch.sample.verification.status.GetByReference](src/main/java/com/sinch/sample/verification/status/GetByReference.java) | | diff --git a/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java b/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java new file mode 100644 index 00000000..edece1bc --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java @@ -0,0 +1,33 @@ +package com.sinch.sample.verification.status; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import java.io.IOException; +import java.util.logging.Logger; + +public class GetById extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(GetById.class.getName()); + + public GetById() throws IOException {} + + public static void main(String[] args) { + try { + new GetById().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + VerificationId id = VerificationId.valueOf("018c01d2-a726-0b2b-5c0f-0dab29e5a2f9"); + + LOGGER.info("Get status by id for : " + id); + + VerificationReport response = client.verification().status().get(id); + LOGGER.info("Response :" + response); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/status/GetByIdentity.java b/sample-app/src/main/java/com/sinch/sample/verification/status/GetByIdentity.java new file mode 100644 index 00000000..38a69cc2 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/status/GetByIdentity.java @@ -0,0 +1,37 @@ +package com.sinch.sample.verification.status; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import java.io.IOException; +import java.util.logging.Logger; + +public class GetByIdentity extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(GetByIdentity.class.getName()); + + public GetByIdentity() throws IOException {} + + public static void main(String[] args) { + try { + new GetByIdentity().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + Identity identity = NumberIdentity.builder().setEndpoint(phoneNumber).build(); + + LOGGER.info("Get status by identity for : " + identity); + + VerificationMethodType method = VerificationMethodType.SMS; + + VerificationReport response = client.verification().status().get(identity, method); + LOGGER.info("Response :" + response); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/status/GetByReference.java b/sample-app/src/main/java/com/sinch/sample/verification/status/GetByReference.java new file mode 100644 index 00000000..eb283ce3 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/status/GetByReference.java @@ -0,0 +1,33 @@ +package com.sinch.sample.verification.status; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.VerificationReference; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import java.io.IOException; +import java.util.logging.Logger; + +public class GetByReference extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(GetByReference.class.getName()); + + public GetByReference() throws IOException {} + + public static void main(String[] args) { + try { + new GetByReference().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + VerificationReference reference = VerificationReference.valueOf("a test reference"); + + LOGGER.info("Get status by reference for: '" + reference + "'"); + + VerificationReport response = client.verification().status().get(reference); + LOGGER.info("Response :" + response); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportById.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportById.java new file mode 100644 index 00000000..1b46db4b --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportById.java @@ -0,0 +1,52 @@ +package com.sinch.sample.verification.verifications; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.VerificationId; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportCalloutRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportSMSRequestParameters; +import java.io.IOException; +import java.util.logging.Logger; + +public class GetReportById extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(GetReportById.class.getName()); + + public GetReportById() throws IOException {} + + public static void main(String[] args) { + try { + new GetReportById().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + VerificationId id = VerificationId.valueOf("018c017e-111d-cf38-6015-2003e49baaa1"); + + LOGGER.info("Get report by id for : " + id); + + VerificationMethodType method = VerificationMethodType.CALLOUT; + + VerificationReportRequestParameters.Builder builder; + + if (method == VerificationMethodType.FLASH_CALL) { + builder = VerificationReportFlashCallRequestParameters.builder().setCli("+19799770634"); + } else if (method == VerificationMethodType.SMS) { + builder = VerificationReportSMSRequestParameters.builder().setCode("4511"); + } else if (method == VerificationMethodType.CALLOUT) { + builder = VerificationReportCalloutRequestParameters.builder().setCode("5762"); + } else { + builder = VerificationReportRequestParameters.builder(); + } + + VerificationReport response = client.verification().verifications().report(id, builder.build()); + LOGGER.info("Response :" + response); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportByIdentity.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportByIdentity.java new file mode 100644 index 00000000..67db0fd7 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/GetReportByIdentity.java @@ -0,0 +1,54 @@ +package com.sinch.sample.verification.verifications; + +import com.sinch.sample.BaseApplication; +import com.sinch.sdk.domains.verification.models.Identity; +import com.sinch.sdk.domains.verification.models.NumberIdentity; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReport; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportCalloutRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportFlashCallRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportRequestParameters; +import com.sinch.sdk.domains.verification.models.requests.VerificationReportSMSRequestParameters; +import java.io.IOException; +import java.util.logging.Logger; + +public class GetReportByIdentity extends BaseApplication { + + private static final Logger LOGGER = Logger.getLogger(GetReportByIdentity.class.getName()); + + public GetReportByIdentity() throws IOException {} + + public static void main(String[] args) { + try { + new GetReportByIdentity().run(); + } catch (Exception e) { + LOGGER.severe(e.getMessage()); + e.printStackTrace(); + } + } + + public void run() { + + LOGGER.info("Get report by identity for : " + phoneNumber); + + Identity identity = NumberIdentity.builder().setEndpoint(phoneNumber).build(); + + VerificationMethodType method = VerificationMethodType.SMS; + + VerificationReportRequestParameters.Builder builder; + + if (method == VerificationMethodType.FLASH_CALL) { + builder = VerificationReportFlashCallRequestParameters.builder().setCli("+12098910108"); + } else if (method == VerificationMethodType.SMS) { + builder = VerificationReportSMSRequestParameters.builder().setCode("0271"); + } else if (method == VerificationMethodType.CALLOUT) { + builder = VerificationReportCalloutRequestParameters.builder().setCode("5762"); + } else { + builder = VerificationReportRequestParameters.builder(); + } + + VerificationReport response = + client.verification().verifications().report(identity, builder.build()); + LOGGER.info("Response :" + response); + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java index 89036986..6d09aef8 100644 --- a/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/Start.java @@ -3,7 +3,8 @@ import com.sinch.sample.BaseApplication; import com.sinch.sdk.domains.verification.models.Identity; import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationMethod; +import com.sinch.sdk.domains.verification.models.VerificationMethodType; +import com.sinch.sdk.domains.verification.models.VerificationReference; import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; import com.sinch.sdk.domains.verification.models.requests.StartVerificationRequestParameters; import com.sinch.sdk.domains.verification.models.response.StartVerificationResponse; @@ -31,21 +32,25 @@ public void run() { Identity identity = NumberIdentity.builder().setEndpoint(phoneNumber).build(); - VerificationMethod method = VerificationMethod.SMS; + VerificationMethodType method = VerificationMethodType.SMS; - StartVerificationRequestParameters parameters; - if (method != VerificationMethod.FLASH_CALL) { - parameters = StartVerificationRequestParameters.builder(method).setIdentity(identity).build(); + StartVerificationRequestParameters.Builder builder; + + if (method != VerificationMethodType.FLASH_CALL) { + builder = StartVerificationRequestParameters.builder(method); } else { - // Dedicated flashcall builder usage do not require setting explicit verification method + // Dedicated flashcall builder usage do not require setting explicit verification method // parameter - parameters = + builder = StartVerificationFlashCallRequestParameters.builder() .setIdentity(identity) - .setDialTimeOut(17) - .build(); + .setDialTimeOut(17); } - StartVerificationResponse response = client.verification().verifications().start(parameters); + + builder.setIdentity(identity).setReference(VerificationReference.valueOf("a test reference")); + + StartVerificationResponse response = + client.verification().verifications().start(builder.build()); LOGGER.info("Response :" + response); } } diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutRequestDto.json new file mode 100644 index 00000000..7150fc76 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutRequestDto.json @@ -0,0 +1,6 @@ +{ + "method": "callout", + "callout": { + "code": "foo code" + } +} diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutResponseDto.json new file mode 100644 index 00000000..ac8f2a41 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportCalloutResponseDto.json @@ -0,0 +1,19 @@ +{ + "id": "the id", + "method": "callout", + "status": "FAIL", + "reason": "Fraud", + "callComplete": true, + "reference": "my reference", + "price": { + "verificationPrice": { + "currencyId": "verificationPrice currency id", + "amount": 3.141516 + }, + "terminationPrice": { + "currencyId": "terminationPrice currency id", + "amount": 6.626070 + }, + "billableDuration": 34 + } +} diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallRequestDto.json new file mode 100644 index 00000000..2941c316 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallRequestDto.json @@ -0,0 +1,6 @@ +{ + "method": "flashcall", + "flashcall": { + "cli": "foo cli" + } +} diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallResponseDto.json new file mode 100644 index 00000000..e3cc0f17 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportFlashCallResponseDto.json @@ -0,0 +1,8 @@ +{ + "id": "the id", + "method": "flashcall", + "status": "FAIL", + "reason": "Fraud", + "reference": "my reference", + "source": "my source" +} diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSRequestDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSRequestDto.json new file mode 100644 index 00000000..2b4fe560 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSRequestDto.json @@ -0,0 +1,8 @@ +{ + "method": "sms", + "sms": { + "code": "foo code", + "cli": "foo cli" + + } +} diff --git a/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSResponseDto.json b/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSResponseDto.json new file mode 100644 index 00000000..05652a76 --- /dev/null +++ b/test-resources/src/test/resources/domains/verification/v1/VerificationReportSMSResponseDto.json @@ -0,0 +1,14 @@ +{ + "id": "the id", + "method": "sms", + "status": "FAIL", + "reason": "Fraud", + "reference": "my reference", + "source": "my source", + "price": { + "verificationPrice": { + "currencyId": "verificationPrice currency id", + "amount": 3.141516 + } + } +}