diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1f708f778..457c4eb04 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,6 +54,6 @@ jobs: - name: Link to feature files run: | ln -s ${{ github.workspace }}/sinch-sdk-mockserver/features client/src/test/resources - + - name: Run e2e tests run: mvn -B -DskipUTs -Dspotless.check.skip=true verify --file pom.xml diff --git a/.github/workflows/samples-compilation.yaml b/.github/workflows/samples-compilation.yaml index e61d9b4d9..3d5c2c25e 100644 --- a/.github/workflows/samples-compilation.yaml +++ b/.github/workflows/samples-compilation.yaml @@ -1,4 +1,4 @@ -name: Samples Compilation +name: Examples Compilation on: [push] @@ -18,10 +18,9 @@ jobs: - name: Building run: | mvn clean install -DskipTests=true -Dspotless.apply.skip=true -DskipUTs -DskipITs - cd sample-app - mvn -B clean package - cd ../examples + cd examples ./compile.sh + # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive - name: Update dependency graph uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 8cc24f575..46d966446 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -5,4 +5,4 @@ This repository is composed of following directories: - `core`: The core definition of models (OpenAPI contracts generated sources are based onto them) - `openapi-contracts`: Open API files and dedicated sources to implement REST API calls. Sources are generated by OpenAPI generator tool and should not be modified. - `client`: Sinch SDK implementation -- `sample-app`: A sample application using the Sinch SDK \ No newline at end of file +- `examples`: Samples using the Sinch Java SDK \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..7683628b2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,312 @@ +# Changelog + +All notable changes to the **Sinch Java SDK** are documented in this file. + +> **Tag legend** +> - `[feature]` — new capability +> - `[fix]` — bug fix +> - `[deprecation notice]` — will be removed in a future release +> - `[dependency]` — third-party library update +> - `[doc]` — documentation only +> - `[test]` — test coverage +> - `[refactor]` — internal restructuring +> - `[releasing]` — release infrastructure +> - `[design]` — API design change +> - `[tech]` — technical improvement + +--- + +## v2.0 – 2026-03-31 + +### Major breaking changes with major release +- see [MIGRATION-GUIDE](MIGRATION-GUIDE.md#200) + +### Chore +- **[dependency]** Updated `maven-model` dependency to `3.9.14` or more recent version to fix security vulnerabilities [#8](https://github.com/sinch/sinch-sdk-java/security/dependabot/8) + +### Conversation +- **[feature]** Support `Project Settings` API +- **[feature]** Support `Contacts Identity Conflicts` API +- **[feature]** [Messages] Support new `direction` query parameter for `MessagesListQueryParameters` +- **[feature]** [Messages] Support `listLastMessagesByChannelIdentity` API +- **[feature]** [KakaoTalk] Support `COMMERCE` and `CAROUSEL_COMMERCE` channel specific message +- **[feature]** [LINE] Support `NOTIFICATION_MESSAGE_TEMPLATE` channel specific message +- **[deprecation notice]** [OrderDetailsSettings] [`PaymentSettings`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/OrderDetailsPayment.html#getPaymentSettings()) deprecated in favor of [`PaymentButtons`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/OrderDetailsPayment.html#getPaymentButtons()) + +### Verification +- **[feature]** Support `VerificationSmsDeliveredEvent` webhook events +- FlashCall + - **[feature]** `VerificationStartRequestFlashCall` support `interceptionTimeout` and additionalProperties + - **[feature]** `VerificationStartResponseFlashCall` support additionalProperties + - **[feature]** `VerificationRequestEventResponseFlashCall` support `interceptionTimeout` and additionalProperties +- PhoneCall + - **[feature]** `VerificationStartRequestPhoneCall` support additionalProperties + - **[feature]** `VerificationRequestEventResponsePhoneCall` support additionalProperties +- SMS + - **[feature]** `VerificationStartResponseSms` support `codeType` and additionalProperties + - **[feature]** `VerificationRequestEventResponseSms` support `codeType`, `expiry` and additionalProperties +- WhatsApp + - **[feature]** [BETA] Support `WhatsApp` verification method + +### Voice +- **[feature]** Support new DICE reason values + + +--- + +## v1.7.1 – 2025-10-14 +- **[fix]** Issue #273: Fix NPE when handling 401 response without a token expired header + +--- + +## v1.7.0 – 2025-07-16 +### SDK +- **[dependency]** Bump Jackson dependency to '2.19.0' +- **[dependency]** Bump generated sources based onto generator '7.13' +- **[dependency]** Bump maven-gpg-plugin used to sign released artifacts to '1.6' +- **[releasing]** Migration to replace deprecated OSSRH in favor of SonaType Central +- **[test]** Activate parallel mode for unit tests + +### Conversation +- **[fix]** Specifications fixed: + - `TemplateMessage.OmniTemplate` field is now requiring a `TemplateReference` with `version` field filled. + - `TemplateMessage.ChannelTemplate` still use a `TemplateReference` with `version` field not required. + To avoid breaking changes and namespace pollution, SDK is accepting a common `TemplateReference` instance and validation about the required `version` field won't be performed at client level by client, but will validate at backend level after having sent the request. +- **[feature]** `Reason.channel_code` field added (only for supported by WhatsApp) +- **[deprecation notice]** Emit a warning log onto using default region for Conversation (US). To avoid regulation issue, defaulting to US will no longer be supported in future version and defining the region will be required. +- **[test]** Clean Jackson cache during unit tests + +### Mailgun +- **[feature]** `copyVersion` API based now return `version` field in place of deprecated `template` one +- **[doc]** Improve Javadoc rendering by separating summary and notes +- **[deprecation notice]** Emit a warning log onto using default region for Mailgun (US). To avoid regulation issue, defaulting to US will no longer be supported in future version and defining the region will be required. + +### Numbers +- **[feature]** Support Emergency Address +- **[feature]** Add new API `rent(phoneNumber)` without configuration +- **[feature]** Switch from 'Basic' to 'OAuth' auth +- **[deprecation notice]** + - [list(ActiveNumberListRequest)](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.0/com/sinch/sdk/domains/numbers/api/v1/NumbersService.html#list(com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest)) replaced by [list(ActiveNumbersListQueryParameters)](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.0/com/sinch/sdk/domains/numbers/api/v1/ActiveNumberService.html#list(com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters)) + - [searchForAvailableNumbers(AvailableNumberListRequest)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/numbers/api/v1/NumbersService.html#searchForAvailableNumbers(com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest)) replaced by [searchForAvailableNumbers(AvailableNumbersListQueryParameters)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/numbers/api/v1/AvailableNumberService.html#searchForAvailableNumbers(com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumbersListQueryParameters)) + - [list(AvailableRegionListRequest)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionService.html#list(com.sinch.sdk.domains.numbers.models.v1.regions.available.request.AvailableRegionListRequest)) replaced by [list(AvailableRegionsListQueryParameters)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionsService.html#list(com.sinch.sdk.domains.numbers.models.v1.regions.request.AvailableRegionsListQueryParameters)) +- **[refactor]** Voice configuration RTC is optional onto requests. No effect at SDK interface level +- **[refactor]** Move to facade pattern and consume APIs from generator + +### SMS +- **[doc]** Improve Javadoc rendering by separating summary and notes +- **[deprecation notice]** Emit a warning log onto using default region for SMS (US). To avoid regulation issue, defaulting to US will no longer be supported in future version and defining the region will be required. + +### Voice +- **[test]** Extend end-to-end tests against `notify` +- **[feature]** Support SVAML `connectStream` action +- **[feature]** Support `asynch` field for `amdRequest` +- **[feature]** Define two new values for `AnsweringMachineDetection.Reason` enum + +--- + +## v1.6.0 – 2025-04-23 + +### SDK +- **[feature]** Lazy HTTP client initialization until really required + +### Cross domains +- **[feature]** Relax domains init for Webhooks when credentials are not required +- **[feature]** Validation against missing required property at protocol level + +### Conversation +- **[fix]** `CardMessage.media_message` is now of `MediaMessage` type +- **[feature]** New `ListMessage.media` field is supported +- **[feature]** New SG (Singapore) country defined for WhatsApp order payment details +- **[feature]** New `ConversationChannelCredentials.credential_ordinal_number` field is supported +- **[feature]** New `LineEnterpriseCredentials` is supported +- **[feature]** New `LineCredentialsField.isDefault` field is supported +- **[feature]** New `SendMessageRequest.message_content_type` is supported (enum of `MessageContentType`) +- **[feature]** New `ChannelSpecificMessage` classes for WhatsApp: + - `OrderDetails` + - `OrderStatus` +- **[deprecation notice]** `CardMessageMedia` class is deprecated in favor of shared `MediaMessage` + +### Mailgun as PREVIEW features + +- **[feature]** Support "Emails" +- **[feature]** Support "Templates" + +### SMS + +- **[fix]** `contentType` VS `content_type` JSON field name for `MediaMessageBodyDetails` at protocol level +- **[fix]** Body requests defined as required at protocol level +- **[fix]** `UpdateBinaryRequest.udh` field is required at protocol level +- **[feature]** `DryRunPerRecipientDetails.encodingEnum` defined as an enum +- **[feature]** List batches query parameters is accepting a list from values of code +- **[deprecation notice]** List batches query parameters accepting a single from value (replaced by function above) +- **[deprecation notice]** `DryRunPerRecipientDetails.encoding` is deprecated in favor of `DryRunPerRecipientDetails.encodingEnum` + +### Voice + +- **[feature]** Define `AnsweringMachineDetection` used by `AnsweredCallEvent` and `NotificationEvent` +- **[feature]** `conferenceId` field is supported by + - `AnsweredCallEvent` + - `DisconnectCallEvent` + - `IncomingCallEvent` + - `NotificationEvent` + - `PromptInputEvent` +- **[feature]** `NotificationEvent` support `destination` and `amd` fields +- **[deprecation notice]** `AnsweredCallEventAnsweringMachineDetection` is replaced by `AnsweringMachineDetection` +- **[deprecation notice]** Following backend endpoint deprecation `applications.queryNumber` is deprecated + +--- + +## v1.5.1 – 2025-03-04 +### Conversation +- **[fix]** `CardMessage` + - `CardMessage.media` field is of `MediaMessage` type (see Javadoc) + - `CardMessageMedia` class is deprecated (see Javadoc) + +--- + +## v1.5.0 – 2025-02-12 + +### Chore +- **[dependency]** Updated Jackson dependency to jackson-jakarta-rs-providers v2.18.2 + +### SMS +- **[feature]** Versioned access to SMS services +- **[deprecation notice]** Un-versioned access to SMS services (see SMS migration guide) + +### Conversation +- **[fix]** Channel specific message (Messenger / FLOWS) fix for serialization/de-serialization +- **[fix]** List `ChoiceItem.media` field fix for serialization/de-serialization + +### Numbers +- **[deprecation notice]** Un-versioned access to Numbers services (see Numbers migration guide) + +### Verification +- **[deprecation notice]** Un-versioned access to Verification services (see Verification migration guide) + +### Voice +- **[deprecation notice]** Un-versioned access to Voice services (see Voice migration guide) + +--- + +## v1.4.0 – 2024-11-06 + +### Voice + +- **[feature]** Support V1 design +- **[feature]** Follow specification update for SVAML `PlayFiles.locale`, field is no longer required +- **[fix]** Webhooks callbacks validation use case-insensitive headers (`validateAuthenticationHeader`) +- **[test]** Extend tests coverage (introduced end-to-end tests) + +### Numbers +- **[feature]** Specification update for `VoiceConfiguration.scheduledProvisioning` defined as readOnly +- **[feature]** Specification update for `SmSConfiguration.scheduledProvisioning` defined as readOnly + +--- + +## v1.3.1 – 2024-09-30 +### SMS +- **[fix]** Enable list of parameters grouped by duplicated keys + +--- + +## v1.3.0 – 2024-09-27 +### Core + +#### Generated sources +- **[fix]** Generated sources with OptionalValue getter: guard against uninitialized value +- **[feature]** Contains serializer/deserializer to be used for delegation pattern +- **[feature]** Enhanced javadoc content + +#### Versioning +- **[feature]** Store SDK related information within sources + +### Conversation +- **[feature]** Support Conversation API + +### Numbers +- **[feature]** Helper function for webhook authentication header +- **[feature]** `readOnly` fields are no longer sent over network + +### SMS +- **[feature]** Align with updated specs for DryRun + +### Verification +- **[fix]** Enforce webhooks validation logic for empty or missing `authorization` header + +--- + +## v1.2.4 – 2024-09-30 +### SMS +- **[fix]** Enable list of parameters grouped by duplicated keys + +--- + +## v1.2.3 – 2024-09-04 +### Verification (SMS) +- **[feature]** Support additional properties onto Start verification by SMS + +--- + +## v1.2.2 – 2024-08-19 +- **[fix]** UTF-8 encoding for body payloads. + +--- + +## v1.2.1 – 2024-07-24 +### Numbers +- **[fix]** Add missing `WebHooksService.validateAuthenticationHeader` function for Numbers + +--- + +## v1.2.0 – 2024-07-11 + +Starting with version `1.2`, `Numbers` domain now support versioned access by using the `v1()` API calls. +The existing non-versioned services will no longer be updated with new features/fields. + +### Numbers +- **[design]** New versioned service simplified access to available or active: APIs are accessible directly under `v1()` +- **[feature]** FAX & EST number's configuration. The `VoiceConfiguration` and `ScheduledVoiceProvisioning` models have been updated to reflect the "Unified Numbers" API updates: they now hold values for Fax and Elastic SIP Trunking configuration (respectively with the properties `serviceId` and `trunkId`). + +### Verification +- **[doc]** Error message related to invalid configuration (credentials) fixed + +--- + +## v1.1.0 – 2024-06-28 +With version `1.1` we are moving to support versioned domain access. + +Starting with the `Verification` domain, you can access services by using the `v1()` API calls. +The existing non-versioned services will no longer be updated with new features/fields. + +### Verification +- **[feature]** [Design] Non-versioned `Verification` domain is split into dedicated Start and Report new versioned services + +- **[feature]** Synchronization with documentation terms + - `Callout` related fields and APIs are now named Phone Call + - `Seamless` related fields and APIs are now named Data +- **[feature]** Start Verification + - `VerificationStartRequestSms` + - Support `Accept-Language` option + - Support `code type` option + - Support `expiry` option + - `VerificationStartRequestPhoneCall` + - Support `speech` option + - `VerificationStartResponseData` + - **[fix]** `targetUri` field added +- **[feature]** Verification Report + - **[fix]** `VerificationReportResponse`: Report service no longer returns a common status response shared with status service, but a dedicated verification report response. + +- **[feature]** Webhooks + - **[deprecation notice]** `VerificationRequestEvent.acceptLanguage` field is deprecated + +- **[tech]** Logs + - Reduce logging severity related to phone number not compliant with E164 format + +--- + +## v1.0.0 – 2024-04-18 +- **[feature]** Support Numbers API (SDK doc) +- **[feature]** Support SMS API (SDK doc). Support both unified credentials (projectId) and service planId +- **[feature]** Support Verification API (SDK doc) +- **[feature]** Support Voice API (REST API) +- **[doc]** Online javadoc diff --git a/MIGRATION-GUIDE.md b/MIGRATION-GUIDE.md new file mode 100644 index 000000000..c61a8a812 --- /dev/null +++ b/MIGRATION-GUIDE.md @@ -0,0 +1,559 @@ +# Sinch Java SDK Migration Guide + +## Table of Contents + +- [2.0.0](#200) + - [General design change](#general-design-change) + - [Conversation](#conversation) + - [Numbers](#numbers) + - [SMS](#sms) + - [Voice](#voice) + - [Verification](#verification) + - [Mailgun](#mailgun) +- [1.5.0](#150) + +--- +## 2.0.0 + +This release removes legacy SDK support. + +This guide lists all removed classes and interfaces from SDK V1 and how to migrate to their SDK V2 equivalents. + +### General design change +- Webhooks callbacks managements and parsing are now covered with 2 different services: + - "Event Destinations": for managing the configuration of event destinations in the Sinch platform. This includes creating, updating, listing, and deleting them. + - "Sinch Events": for parsing and handling incoming events from the Sinch platform. This includes parsing the incoming payloads into strongly-typed Java objects and providing utilities for handling these events in your application. + +### [`Conversation`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/package-summary.html) + +- `region` is no longer defaulting to `US` and is now a required field to use Conversation related APIs (see [Configuration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/models/Configuration.Builder.html#setConversationRegion(com.sinch.sdk.models.ConversationRegion)) +- Removed support of `SINCH_CHAT` channel. +- [channelspecific.whatsapp.payment.OrderDetailsPayment](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/OrderDetailsPayment.html) removed support of deprecated `payment_settings` in favor of new `payment_buttons` for payment methods. +- The `metadata` field has been **removed** from the [Conversation](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/conversation/models/v1/conversations/Conversation.html) and [CreateConversationRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/conversations/request/CreateConversationRequest.html) classes. This field is no longer supported in the API and has been replaced with `metadataJson`. +- APIs returning a list are supporting common naming: `QueyParameters` models for filtering, sorting, and pagination onto requests and `ListResponse` models for responses. +- New APIs supporting auto-pagination for list responses: + - apps.list() + - webhooks.list(). + - templates.list(). + - templates.listTranslations(). +- [CallbackSettings.secretForOverriddenCallbackUrls](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/conversation/models/v1/app/CallbackSettings.html#getSecretForOverriddenCallbackUrls()) is replaced by [EventDestinationSettings. +secretForOverriddenTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/EventDestinationSettings.html#getSecretForOverriddenTarget()). +- [SendEventRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/conversation/models/v1/events/request/SendEventRequest.html#getCallbackUrl()) is replaced by [SendEventRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/request/SendEventRequest.html#getEventDestinationTarget()). +- [SendMessageRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/conversation/models/v1/messages/request/SendMessageRequest.html#getCallbackUrl()) is replaced by [SendMessageRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/messages/request/SendMessageRequest.html#getEventDestinationTarget()). + +- Templates: + - Conversation `Template V1` is removed. Use Conversation`Template V2` instead. + - Conversation Templates models moved from `com.sinch.sdk.domains.conversation.models.templates` package to `com.sinch.sdk.domains.conversation.templates.models`. + +#### Replacement models +| Old const | New const | +|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `ComposingEndEvent.EMPTY` | [ComposingEndEvent.COMPOSING_END_EVENT](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/types/ComposingEndEvent.html) | +| `ComposingEvent.EMPTY` | [ComposingEvent.COMPOSING_EVENT](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/types/ComposingEvent.html) | +| `ConversationDeletedEvent.EMPTY` | [ConversationDeletedEvent.CONVERSATION_DELETED_EVENT](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/types/ConversationDeletedEvent.html) | +| `ConversationDirection.UNDEFINED_DIRECTION` | Support removed | +| `PaymentStatus` | constant values are now prefixed with `PAYMENT_STATUS_` | +| `ReactionAction` | constant values prefixed with `REACTION_ACTION_` | +| `MessageContentType` | constant values prefixed with `CONTENT_` | +| `OptInEventNotification` | constant values prefixed with `OPT_IN_` | +| `OptOutEventNotification` | constant values prefixed with `OPT_OUT_` | +| `Templates V1` | Removed support for `Templates` V1 | + +| Old class | New class | +|-------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| api.v1.MessagesService.MessageSource | [messages.request.MessageSource](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessageSource.html) | +| messages.types.card.CardMessageMedia | [messages.types.media.MediaMessage](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/messages/types/media/MediaMessage.html) | +| contact.request.IdentityConflictsListRequest | [contacts.request.ContactListIdentityConflictsQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactListIdentityConflictsQueryParameters.html) | +| contact.request.ContactListRequest | [contacts.request.ContactsListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactsListQueryParameters.html) | +| contact.response.ContactsListResponse | [contacts.response.ContactsListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/response/ContactsListResponse.html) | +| conversation.request.ConversationsListRequest | [conversations.request.ConversationsListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListQueryParameters.html) | +| conversation.request.ConversationsListRecentRequest | [conversations.request.ConversationsListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/conversations/request/RecentConversationsListQueryParameters.html) | +| conversation.response.ConversationsListRecentResponse | [conversations.response.RecentConversationsListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/conversations/response/RecentConversationsListResponse.html) | +| events.request.EventsListRequest | [events.request.EventsListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListQueryParameters.html) | +| messages.request.MessagesListRequest | [messages.request.MessagesListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListQueryParameters.html) | +| webhooks.Webhook | [eventdestinations.EventDestination](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/EventDestination.html) | +| webhooks.events.ConversationWebhookEvent | [sinchevents.ConversationSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/sinchevents/ConversationSinchEvent.html) | +| webhooks.WebhookTrigger | [sinchevents.EventDestinationTrigger](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestination/EventDestinationTrigger.html) | +| webhooks.WebhookTargetType | [sinchevents.EventDestinationTargetType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestination/EventDestinationTargetType.html) | +| apps.CallbackSettings | [EventDestinationSettings](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/apps/EventDestinationSettings.html) | + +#### Replacement Services +| Old package | New package | +|------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| api.v1.AppService | [api.v1.AppsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/AppsService.html) | +| api.v1.ContactService | [api.v1.ContactsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/ContactsService.html) | +| api.v1.Conversation | [api.v1.ConversationsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/ConversationsService.html) | +| api.v1.EventService | [api.v1.EventsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/EventsService.html) | +| api.v1.WebHooksService | [api.v1.EventDestinationsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/EventDestinationsService.html) | +| | [api.v1.SinchEventsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/api/v1/SinchEventsService.html) | + +#### Replacement packages +| Old package | New package | +|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models.v1.app | [models.v1.apps](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/apps/package-summary.html) | +| models.v1.contact | [models.v1.contacts](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/package-summary.html) | +| models.v1.conversation | [models.v1.conversations](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/conversations/package-summary.html) | +| models.v1.event | [models.v1.events](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/events/package-summary.html) | +| models.v1.webhooks | [models.v1.evendestinations](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/package-summary.html) | +| models.v1.webhooks.events | [models.v1.sinchevents](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/sinchevents/package-summary.html) | +| api.templates.v2.TemplatesServiceV2 | [conversation.templates.api.v2.TemplatesV2Service](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/templates/api/v2/TemplatesV2Service/package-summary.html) | + +#### Replacement APIs + +| Old interface | New Equivalent | +|------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ContactsService.getChannelProfileByChannelIdentity() | Returned class is changed from `String` to [GetChannelProfileResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/response/GetChannelProfileResponse.html) | +| ContactsService.getChannelProfileByContactId() | Returned class is changed from `String` to [GetChannelProfileResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/contacts/response/GetChannelProfileResponse.html) | +| AppsService.list(...) | Returned class is changed from `Collection` to [AppsListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/apps/response/AppsListResponse.html) | +| MessagesService.get(...) | Is accepting now a `MessagesGetQueryParameeters` object for request parameters instead of individual parameters. | +| MessagesService.delete(...) | Is accepting now a `MessagesDeleteQueryParameeters` object for request parameters instead of individual parameters. | +| MessagesService.update(...) | Is accepting now a `MessagesUpdateQueryParameeters` object for request parameters instead of individual parameters. | +| WebhooksService.create(...) | Request parameter type is changed from `Webhook` to [EventDestinationCreateRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/eventdestinations/request/EventDestinationCreateRequest.html) | +| WebhooksService.list(...) | Returned class is changed from `Collection` to [EventDestinationsListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/response/EventDestinationsListResponse.html) | +| TemplatesServiceV2.list(...) | Returned class is changed from `Collection` to [TemplatesV2ListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/templates/models/v2/response/TemplatesV2ListResponse.html) | +| TemplatesServiceV2.listTranslations(...) | Returned class is changed from `Collection` to [TranslationV2ListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/conversation/templates/models/v2/response/TranslationsV2ListResponse.html) | +### [`Numbers`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/package-summary.html) + +#### Replacement models + +##### Common models +| Old class | New class | +|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ActiveNumber | [com.sinch.sdk.domains.numbers.models.v1.ActiveNumber](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/ActiveNumber.html) | +| AvailableNumber | [com.sinch.sdk.domains.numbers.models.v1.response/AvailableNumber](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/response/AvailableNumber.html) | +| Capability | [com.sinch.sdk.domains.numbers.models.v1.Capability](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/Capability.html) | +| Money | [com.sinch.sdk.domains.numbers.models.v1.Money](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/Money.html) | +| NumberPattern | [com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/SearchPattern.html) | +| NumberType | [com.sinch.sdk.domains.numbers.models.v1.NumberType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/NumberType.html) | +| OrderBy | [com.sinch.sdk.domains.numbers.models.v1.request.OrderBy](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/OrderBy.html) | +| ProvisioningStatus | [com.sinch.sdk.domains.numbers.models.v1.ProvisioningStatus](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/ProvisioningStatus.html) | +| Region | Part of [com.sinch.sdk.domains.numbers.models.v1.regions.available.AvailableRegion](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/regions/available/AvailableRegion.html) | +| SMSConfiguration | [com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/SmsConfiguration.html) | +| ScheduledSmsProvisioning | [com.sinch.sdk.domains.numbers.models.v1.ScheduledSmsProvisioning](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/ScheduledSmsProvisioning.html) | +| ScheduledVoiceProvisioning | [com.sinch.sdk.domains.numbers.models.v1.request/ScheduledVoiceProvisioning](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/ScheduledVoiceProvisioning.html) | +| SearchPattern | [com.sinch.sdk.domains.numbers.models.v1.request/SearchPosition](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/SearchPosition.html) | +| SmsErrorCode | [com.sinch.sdk.domains.numbers.models.v1.SmsErrorCode](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/SmsErrorCode.html) | +| VoiceConfiguration | [com.sinch.sdk.domains.numbers.models.v1.VoiceConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/VoiceConfiguration.html) | + +| Old enum | New enum | +|------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| SmsErrorCode.EXCEEDED_10DLC_LIMIT | [SmsErrorCode.EXCEEDED_10_DLC_LIMIT](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/SmsErrorCode.htmll#EXCEEDED_10_DLC_LIMIT) | +| NumberEvent.EXCEEDED_10DLC_LIMIT | [NumberSinchEvent.FailureCodeEnum.EXCEEDED_10_DLC_LIMIT](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/sinchevents/NumberSinchEvent.FailureCodeEnum.html#EXCEEDED_10_DLC_LIMIT) | + +##### Active Numbers +| Old class | New class | +|----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| requests.ActiveNumberListRequestParameters | [request.ActiveNumbersListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumbersListQueryParameters.html) | +| requests.ActiveNumberUpdateRequestParameters | [request.ActiveNumberUpdateRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberUpdateRequest.html) | +| requests.ActiveNumberUpdateSMSConfigurationRequestParameters | [SmsConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/SmsConfiguration.html) | +| requests.ActiveNumberUpdateVoiceConfigurationRequestParameters | [VoiceConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/VoiceConfiguration.html) | +| responses.ActiveNumberListResponse.java | [response.ActiveNumbersListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/response/ActiveNumbersListResponse.html) | + +| Renamed field | New field | +|---------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| ActiveNumber.callbackUrl | [ActiveNumber.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/ActiveNumber.html#getEventDestinationTarget()) | +| ActiveNumberUpdateRequest.callbackUrl | [ActiveNumberUpdateRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberUpdateRequest.html#getEventDestinationTarget()) | + +##### Available Numbers +| Old class | New class | +|--------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| requests.AvailableNumberListAllRequestParameters | [request.AvailableNumbersListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumbersListQueryParameters.html) | +| requests.AvailableNumberRentAnyRequestParameters | [request.AvailableNumberRentAnyRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberRentAnyRequest.html) | +| requests.AvailableNumberRentRequestParameters | [request.AvailableNumberRentRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberRentRequest.html) | +| responses.AvailableNumberListResponse | [response.AvailableNumbersListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/response/AvailableNumbersListResponse.html) | +| requests.RentSMSConfigurationRequestParameters | [SmsConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/SmsConfiguration.html) | +| requests.RentVoiceConfigurationRequestParameters | [VoiceConfiguration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/VoiceConfiguration.html) | + +| Renamed field | New field | +|-----------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| AvailableNumberRentAnyRequestParameters.callbackUrl | [AvailableNumberRentAnyRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberRentAnyRequest.html#getEventDestinationTarget()) | +| AvailableNumberRentRequestParameters.callbackUrl | [AvailableNumberRentRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberRentRequest.html#getEventDestinationTarget()) | + +##### Regions +| Old class | New class | +|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| regions.available.request.AvailableRegionListRequest | [regions.request.AvailableRegionsListQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/regions/request/AvailableRegionsListQueryParameters.html) | +| regions.available.responses.AvailableRegionListResponse | [regions.response.AvailableRegionsListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/regions/response/AvailableRegionsListResponse.html) | + +##### Event Destinations +| Old class | New class | +|------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| callbacks.request.CallbackConfigurationUpdateRequest | [eventdestinations.request.EventDestinationUpdateRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/request/EventDestinationUpdateRequest.html) | +| callbacks.response.CallbackConfigurationResponse | [eventdestinations.response.EventDestinationResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/response/EventDestinationResponse.html) | + +##### Sinch Events +| Old class | New class | +|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| webhooks.NumberEvent | [sinchevents.NumberSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/sinchevents/NumberSinchEvent.html) | +| webhooks.ResourceType | [sinchevents.ResourceType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/models/v1/sinchevents/ResourceType.html) | + +#### Replacement APIs + +Use the new versioned API under `numbers().v1()` to get access to [NumbersService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/NumbersService.html): [`sinchClient.numbers().v1()`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0./com/sinch/sdk/domains/numbers/NumbersService.html#v1()) + +| Old interface | New Equivalent in `numbers().v1()` | +|------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| active() | [Direct access from v1()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/NumbersService.html) | +| available() | [Direct access from v1()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/NumbersService.html) | +| regions() | [v1().regions()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionsService.html) | +| callback() | [v1().callback()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/CallbackConfigurationService.html) | +| webhook() | [v1().sinchevents()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/SinchEventService.html) | +| v1().callback() | [v1().callbackConfiguration()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/numbers/api/v1/CallbackConfigurationService.html) | + +### [`SMS`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/package-summary.html) + +- `region` is no longer defaulting to `US` and is now a required field to use SMS related APIs (see [Configuration](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/models/Configuration.Builder.html#setSmsRegion(com.sinch.sdk.models.SMSRegion)) + +#### Deprecated fields +- Deprecated `MediaMessageBodyDetails.status` field of type `String` is replaced by `MediaMessageBodyDetails.status` of [StatusEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/MediaMessageBodyDetails.StatusEnum.html) type +- [BinaryRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.html#getCallbackUrl()) is replaced by [BinaryRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.html#getEventDestinationTarget()) +- [UpdateBinaryRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.html#getCallbackUrl()) is replaced by [BinaryRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.html#getEventDestinationTarget()) +- [BinaryResponse.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.html#getCallbackUrl()) is replaced by [BinaryResponse.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.html#getEventDestinationTarget()) +- [MediaRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.html#getCallbackUrl()) is replaced by [MediaRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.html#getEventDestinationTarget()) +- [UpdateMediaRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.html#getCallbackUrl()) is replaced by [UpdateMediaRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.html#getEventDestinationTarget()) +- [MediaResponse.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.html#getCallbackUrl()) is replaced by [MediaResponse.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.html#getEventDestinationTarget()) +- [TextRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.html#getCallbackUrl()) is replaced by [MediaRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.html#getEventDestinationTarget()) +- [UpdateTextRequest.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.html#getCallbackUrl()) is replaced by [UpdateTextRequest.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.html#getEventDestinationTarget()) +- [TextResponse.callbackUrl](https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.7.1/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.html#getCallbackUrl()) is replaced by [TextResponse.eventDestinationTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.html#getEventDestinationTarget()) + +#### Replacement models + +##### Batches +| Old class | New class | +|-----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/Parameters | N/A. Part of `Create` and `Update` batch requests | +| models/MediaBody | [com.sinch.sdk.domains.sms.models.v1.batches.MediaBody](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/MediaBody.html) | +| models/BaseBatch | [com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/BatchRequest.html) | +| models/Batch | [com.sinch.sdk.domains.sms.models.v1.batches.response.BatchResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/BatchResponse.html) | +| models/BatchBinary | [com.sinch.sdk.domains.sms.models.v1.batches.response.BinaryResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/BinaryResponse.html) | +| models/BatchMedia | [com.sinch.sdk.domains.sms.models.v1.batches.response.MediaResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/MediaResponse.html) | +| models/BatchText | [com.sinch.sdk.domains.sms.models.v1.batches.response.TextResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/TextResponse.html) | +| models/DryRun | [com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunResponse.html) | +| models/DryRunPerRecipientDetails | [com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunPerRecipientDetails](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetails.html) | +| models/requests/BatchesListRequestParameters | [com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/ListBatchesQueryParameters.html) | +| models/requests/SendSmsBatchBinaryRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.BinaryRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/BinaryRequest.html) | +| models/requests/SendSmsBatchMediaRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.MediaRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/MediaRequest.html) | +| models/requests/SendSmsBatchTextRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.TextRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/TextRequest.html) | +| models/requests/UpdateBaseBatchRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBatchRequest.html) | +| models/requests/UpdateSmsBatchBinaryRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBinaryRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateBinaryRequest.html) | +| models/requests/UpdateSmsBatchMediaRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateMediaRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateMediaRequest.html) | +| models/requests/UpdateSmsBatchTextRequest | [com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateTextRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/request/UpdateTextRequest.html) | +| models/responses/BatchesListResponse | [com.sinch.sdk.domains.sms.models.v1.batches.response.ListBatchesResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/ListBatchesResponse.html) | + +- The deprecated `getEncoding`/`setEncoding` APIs accepting `String` parameter are removed from [com.sinch.sdk.domains.sms.models.v1.batches.response.DryRunPerRecipientDetails](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/batches/response/DryRunPerRecipientDetails.html) + +##### Delivery Reports +| Old class | New class | +|---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/BaseDeliveryReport | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.DeliveryReport](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReport.html) | +| models/DeliveryReportBatch | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.BatchDeliveryReport](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReport.html) | +| models/DeliveryReportBatchMMS | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.BatchDeliveryReportMMS](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReportMMS.html) | +| models/DeliveryReportBatchSMS | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.BatchDeliveryReportSMS](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReportSMS.html) | +| models/DeliveryReportErrorCode | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.DeliveryReceiptErrorCode](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReceiptErrorCode.html) | +| models/DeliveryReportRecipient | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.RecipientDeliveryReport](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReport.html) | +| models/DeliveryReportRecipientEncoding | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.EncodingType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/EncodingType.html) | +| models/DeliveryReportRecipientMMS | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.RecipientDeliveryReportMMS](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReportMMS.html) | +| models/DeliveryReportRecipientSMS | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.RecipientDeliveryReportSMS](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReportSMS.html) | +| models/DeliveryReportStatus | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.DeliveryStatus](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryStatus.html) | +| models/DeliveryReportStatusDetails | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.MessageDeliveryStatus](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/MessageDeliveryStatus.html) | +| models/DeliveryReportType | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.QueryReportType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/request/QueryReportType.html) | +| models/requests/DeliveryReportBatchGetRequestParameters | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.BatchDeliveryReportQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/request/BatchDeliveryReportQueryParameters.html) | +| models/requests/DeliveryReportListRequestParameters | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.ListDeliveryReportsQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/request/ListDeliveryReportsQueryParameters.html) | +| models/responses/DeliveryReportsListResponse | [com.sinch.sdk.domains.sms.models.v1.deliveryreports.response.ListDeliveryReportsResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/response/ListDeliveryReportsResponse.html) | +| models/v1/deliveryreports/DeliveryReceiptErrorCode | Renamed to [com.sinch.sdk.domains.sms.models.v1.deliveryreports.DeliveryReceiptStatusCode](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/deliveryreports/deliveryreports/DeliveryReceiptStatusCode.html) | + +##### Groups +| Old class | New class | +|---------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/Group | [com.sinch.sdk.domains.sms.models.v1.groups.Group](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/Group.html) | +| models/GroupAutoUpdate | [com.sinch.sdk.domains.sms.models.v1.groups.GroupAutoUpdate](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/GroupAutoUpdate.html) | +| models/GroupAutoUpdateKeyword | [com.sinch.sdk.domains.sms.models.v1.groups.AddKeyword](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/AddKeyword.html) and [com.sinch.sdk.domains.sms.models.v1.groups.RemoveKeyword](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/RemoveKeyword.html) | +| models/requests/GroupAutoUpdateKeywordRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.AddKeyword](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/AddKeyword.html) and [com.sinch.sdk.domains.sms.models.v1.groups.RemoveKeyword](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/groups/RemoveKeyword.html) | +| models/requests/GroupAutoUpdateRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.request.GroupUpdateRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/request/GroupUpdateRequest.html) | +| models/requests/GroupCreateRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.request.GroupRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/request/GroupRequest.html) | +| models/requests/GroupReplaceRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.request.GroupRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/request/GroupRequest.html) | +| models/requests/GroupUpdateRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.request.GroupUpdateRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/request/GroupUpdateRequest.html) | +| models/requests/GroupsListRequestParameters | [com.sinch.sdk.domains.sms.models.v1.groups.request.ListGroupsQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/request/ListGroupsQueryParameters.html) | +| models/responses/GroupsListResponse | [com.sinch.sdk.domains.sms.models.v1.groups.response.ListGroupsResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/response/ListGroupsResponse.html) | + +##### Inbounds +| Old class | New class | +|-----------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/Inbound | [com.sinch.sdk.domains.sms.models.v1.inbounds.InboundMessage](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/InboundMessage.html) | +| models/InboundBinary | [com.sinch.sdk.domains.sms.models.v1.inbounds.BinaryMessage](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/BinaryMessage.html) | +| models/InboundText | [com.sinch.sdk.domains.sms.models.v1.inbounds.TextMessage](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/TextMessage.html) | +| models/requests/InboundsListRequestParameters | [com.sinch.sdk.domains.sms.models.v1.inbounds.request.ListInboundMessagesQueryParameters](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/request/ListInboundMessagesQueryParameters.html) | +| models/responses/InboundsListResponse | [com.sinch.sdk.domains.sms.models.v1.inbounds.response.ListInboundsResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/inbounds/response/ListInboundsResponse.html) | + +##### Webhooks +| Old class | New class | +|------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------| +| webhooks/WebhooksEvent | [sinchevents.SmsSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/models/v1/sinchevents/SmsSinchEvent.html) | +| WebHooksService | [SinchEventsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/v1/SinchEventsService.html) | + +#### Replacement APIs + +Use the new versioned API under `sms().v1()` to get access to [SMSService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/SMSService.html): [`sinchClient.sms().v1()`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0./com/sinch/sdk/domains/sms/SMSService.html#v1()) + +| Old interface | New Equivalent in `sms().v1()` | +|-------------------|------------------------------------------------------------------------------------------------------------------------------------------------------| +| batches() | [v1().batches()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/BatchesService.html) | +| deliveryReports() | [v1().deliveryReports()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/DeliveryReportsService.html) | +| groups() | [v1().groups()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/GroupsService.html) | +| inbounds() | [v1().inbounds()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/InboundsService.html) | +| webHooks() | [v1().sinchEvent()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/sms/api/v1/SinchEventsService.html) | + +### [`Voice`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/package-summary.html) + +- `Applications.listNumbers()` is returning a `[OwnedNumbersListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/application/response/OwnedNumbersListResponse.html)` instead of a list of `OwnedNumbersResponse`. The new response still contains the list of assigned numbers but support the pagination of the results by iterator. +- Deprecated `Applications.queryNumber()` is removed and `NumberInformation`, `QueryNumber` related classes no longer available. + +#### Replacement APIs + +Use the new versioned API under `voice().v1()` to get access to [VoiceService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/VoiceService.html): [`sinchClient.voice().v1()`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0./com/sinch/sdk/domains/voice/VoiceService.html#v1()) + +| Old interface | New Equivalent in `voice().v1()` | +|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| applications() | [v1().applications()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.html) | +| applications().getCallbackUrls() | [v1().applications().getEventDestinations()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.html#getEventDestinations(java.lang.String)) | +| applications().updateCallbackUrls() | [v1().applications().updateEventDestinations()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.html#updateEventDestinations(java.lang.String,com.sinch.sdk.domains.voice.models.v1.applications.EventDestinations)) | +| callouts() | [v1().callouts()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/CalloutsService.html) | +| calls() | [v1().calls()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/CallsService.html) | +| conferences() | [v1().conferences()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/ConferencesService.html) | +| webhooks() | [v1().sinchEvents()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/api/v1/SinchEventService.html) | + +#### Replacement models + +| Old const | New const | +|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| SvamlActionContinue.DEFAULT | [SvamlActionContinue.SVAML_ACTION_CONTINUE](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionContinue.html) | +| SvamlActionHangup.DEFAULT | [SvamlActionHangup.SVAML_ACTION_HANGUP](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionHangup.html) | +| SvamlInstructionAnswer.DEFAULT | [SvamlInstructionAnswer.SVAML_INSTRUCTION_ANSWER](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlInstructionAnswer.html) | +| SvamlInstructionStopRecording.DEFAULT | [SvamlInstructionStopRecording.SVAML_INSTRUCTION_STOP_RECORDING](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlInstructionStopRecording.html) | + + +##### Destination +| Old class | New class | +|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/Destination | [com.sinch.sdk.domains.voice.models.v1.destination.Destination](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/destination/Destination.html) | +| models/DestinationNumber | [com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/destination/DestinationSip.html) or [com.sinch.sdk.domains.voice.models.v1.destination.DestinationPstn](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/destination/DestinationPstn.html) | +| models/DestinationNumberType | N/A | +| models/DestinationSip | [com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/destination/DestinationSip.html) | +| models/DestinationUser | [com.sinch.sdk.domains.voice.models.v1.destination.DestinationMxp](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/destination/DestinationMxp.html) | + +##### Applications +| Old class | New class | +|------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/ApplicationAssignedNumber | [com.sinch.sdk.domains.voice.models.v1.applications.response](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/response/OwnedNumberInformation.html) | +| models/response/AssignedNumbers | [com.sinch.sdk.domains.voice.models.v1.applications.response.OwnedNumbersListResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/response/OwnedNumbersListResponse.html) | +| models/Callbacks | [com.sinch.sdk.domains.voice.models.v1.applications.EventDestinations](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/EventDestinations.html) | +| models/CallbacskUrls | [com.sinch.sdk.domains.voice.models.v1.applications.EventDestinationsTarget](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/EventDestinationsTarget.html) | +| models/requests/ApplicationsAssignNumbersRequestParameters | [com.sinch.sdk.domains.voice.models.v1.applications.request.UpdateNumbersRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/request/UpdateNumbersRequest.html) | +| models/NumberType | N/A | +| models/CapabilityType | [com.sinch.sdk.domains.voice.models.v1.applications.Capability](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/applications/Capability.html) | + +##### Callouts +| Old class | New class | +|----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/requests/CalloutRequestParameters | [com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/callouts/request/CalloutRequest.html) | +| models/requests/CalloutRequestParametersConference | [com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/callouts/request/CalloutRequestConference.html) | +| models/requests/CalloutRequestParametersCustom | [com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/callouts/request/CalloutRequestCustom.html) | +| models/requests/CalloutRequestParametersTTS | [com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/callouts/request/CalloutRequestTTS.html) | + +##### Calls +| Old class | New class | +|---------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/CallLegType | [com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/request/CallLeg.html) | +| models/response/CallInformation | [com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/response/CallInformation.html) | +| models/response/CallStatusType | [com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation.StatusEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/response/CallInformation.StatusEnum.html) | +| models/CallResultType | [com.sinch.sdk.domains.voice.models.v1.calls.response.CallResult](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/response/CallResult.html) | +| models/CallReasonType | [com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation.ReasonEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/response/CallInformation.ReasonEnum.html) | +| models/DomainType | [com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation.DomainEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/calls/response/CallInformation.DomainEnum.html) | + +##### Conferences +| Old class | New class | +|--------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/requests/ConferenceManageParticipantCommandType | [com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest.CommandEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/conferences/request/ManageConferenceParticipantRequest.CommandEnum.html) | +| models/requests/ConferenceManageParticipantRequestParameters | [com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/conferences/request/ManageConferenceParticipantRequest.html) | +| models/ConferenceDtfmOptions | [com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceDtmfOptions](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/conferences/ConferenceDtmfOptions.html) | +| models/MusicOnHoldType | [com.sinch.sdk.domains.voice.models.v1.MusicOnHold](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/MusicOnHold.html) | +| models/DtfmModeType | [com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceDtmfOptions.ModeEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/conferences/ConferenceDtmfOptions.ModeEnum.html) | +| models/response/ConferenceParticipant | [com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceParticipant](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/conferences/ConferenceParticipant.html) | + +##### Svaml +| Old class | New class | +|-------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/requests/Control | [com.sinch.sdk.domains.voice.models.v1.svaml.Control](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/Control.html) | +| models/svaml/SVAMLControl | [com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/SvamlControl.html) | +| models/requests/ControlUrl | [com.sinch.sdk.domains.voice.models.v1.svaml.ControlUrl](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/ControlUrl.html) | +| models/svaml/Action | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlAction](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlAction.html) | +| models/svaml/ActionConnectConference | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectConference](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectConference.html) | +| models/svaml/ActionConnectMxp | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectMxp](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectMxp.html) | +| models/svaml/ActionConnectPstn | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectPstn](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectPstn.html) | +| models/svaml/ActionConnectSip | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectSip](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectSip.html) | +| models/svaml/ActionContinue | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionContinue](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionContinue.html) | +| models/svaml/ActionHangUp | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionHangup](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionHangup.html) | +| models/svaml/ActionPark | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionPark](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionPark.html) | +| models/svaml/ActionRunMenu | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionRunMenu](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionRunMenu.html) | +| models/svaml/AnsweringMachineDetection | [com.sinch.sdk.domains.voice.models.v1.svaml.action.AnsweringMachineDetectionQuery](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/AnsweringMachineDetectionQuery.html) | +| models/svaml/IndicationType | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectPstn.IndicationsEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectPstn.IndicationsEnum.html) | +| models/TransportType | [com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectSip.TransportEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/SvamlActionConnectSip.TransportEnum.html) | +| models/svaml/Menu | [com.sinch.sdk.domains.voice.models.v1.svaml.action.Menu](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/Menu.html) | +| models/svaml/MenuOption | [com.sinch.sdk.domains.voice.models.v1.svaml.action.MenuOption](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOption.html) | +| models/svaml/MenuOptionAction | see [com.sinch.sdk.domains.voice.models.v1.svaml.action.MenuOptionActionFactory](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.html) | +| models/svaml/MenuOptionActionType | [com.sinch.sdk.domains.voice.models.v1.svaml.action.MenuOptionActionFactory.MenuOptionActionType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.MenuOptionActionType.html) | +| models/v1/svaml/action/ConnectPstnAnsweringMachineDetection | [com.sinch.sdk.domains.voice.models.v1.svaml.action.AnsweringMachineDetectionQuery](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/action/AnsweringMachineDetectionQuery.html) | +| models/svaml/Instruction | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstruction](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstruction.html) | +| models/svaml/InstructionAnswer | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionAnswer](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionAnswer.html) | +| models/svaml/InstructionPlayFiles | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionPlayFiles](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionPlayFiles.html) | +| models/svaml/InstructionSay | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSay](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionSay.html) | +| models/svaml/InstructionSendDtfm | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSendDtmf](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionSendDtmf.html) | +| models/svaml/InstructionSetCookie | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSetCookie](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionSetCookie.html) | +| models/svaml/InstructionStartRecording | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionStartRecording](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionStartRecording.html) | +| models/svaml/InstructionStopRecording | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionStopRecording](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/SvamlInstructionStopRecording.html) | +| models/svaml/StartRecordingOptions | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.StartRecordingOptions](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/StartRecordingOptions.html) | +| models/svaml/TranscriptionOptions | [com.sinch.sdk.domains.voice.models.v1.svaml.instruction.TranscriptionOptions](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/svaml/instruction/TranscriptionOptions.html) | + +##### Sinch Events +| Old class | New class | +|---------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/v1/webhooks/AnsweredCallEventAnsweringMachineDetection | Replaced by [com.sinch.sdk.domains.voice.models.v1.sinchevents.AnsweringMachineDetection](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/AnsweringMachineDetection.html) | +| models/v1/webhooks/AnsweringMachineDetection | [com.sinch.sdk.domains.voice.models.v1.sinchevents.AnsweringMachineDetection](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/AnsweringMachineDetection.html) | +| models/v1/webhooks/AnsweredCallEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.AnsweredCallEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/AnsweredCallEvent.html) | +| models/v1/webhooks/DisconnectCallEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.DisconnectedCallEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/DisconnectedCallEvent.html) | +| models/v1/webhooks/IncomingCallEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.IncomingCallEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/IncomingCallEvent.html) | +| models/v1/webhooks/MenuResult | [com.sinch.sdk.domains.voice.models.v1.sinchevents.MenuResult](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/MenuResult.html) | +| models/v1/webhooks/NotifyEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.NotificationEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/NotificationEvent.html) ; | +| models/v1/webhooks/PromptInputEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.PromptInputEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/PromptInputEvent.html) | +| models/v1/webhooks/CallEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.VoiceCallSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/VoiceCallSinchEvent.html) | +| models/v1/webhooks/VoiceWebhookEvent | [com.sinch.sdk.domains.voice.models.v1.sinchevents.VoiceSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/VoiceSinchEvent.html) | +| models/v1/webhooks/WebhooksEventRequestType | [com.sinch.sdk.domains.voice.models.v1.sinchevents.SinchEventType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/voice/models/v1/sinchevents/SinchEventType.html) | + +### [`Verification`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/package-summary.html) + +#### Replacement APIs + +Use the new versioned API under `verification().v1()` to get access to [VerificationService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationService.html): [`sinchClient.verification().v1()`](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/VerificationService.html#v1()) + +| Old interface | New Equivalent in `verification().v1()` | +|---------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| verifications() `start` related APIs | [v1().verificationStart()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationStartService.html) | +| verifications() `report` related APIs | [v1().verificationReport()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationReportService.html) | +| verificationStatus() | [v1().verificationStatus()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationStatusService.html) | +| webhooks() | [v1().sinchEvents()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.html) | +| VerificationStartService | [VerificationsStartService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationsStartService.html) | +| VerificationReportService | [VerificationsReportService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationsReportService.html) | +| VerificationStatusService | [VerificationsStatusService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/VerificationsStatusService.html) | +| WebHooksService | [SinchEventsService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.html) | + +#### Replacement models +##### Common Report + +| Old class | New class | +|-------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/Price | [com.sinch.sdk.domains.verification.models.v1.Price](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/Price.html) | +| models/VerificationStatusType | [com.sinch.sdk.domains.verification.models.v1.VerificationStatus](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/VerificationStatus.html) | +| models/VerificationMethodType | [com.sinch.sdk.domains.verification.models.v1.VerificationMethod](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/VerificationMethod.html) | +| models/Identity | [com.sinch.sdk.domains.verification.models.v1.Identity](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/Identity.html) | +| models/NumberIdentity | [com.sinch.sdk.domains.verification.models.v1.NumberIdentity](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/NumberIdentity.html) | +| models/VerificationId | `java.lang.String` | +| models/VerificationReference | `java.lang.String` | + +##### Verification Report +| Old class | New class | +|--------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/requests/VerificationReportCalloutRequestParameters | [com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestPhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestPhoneCall.html) | +| models/requests/VerificationReportFlashCallRequestParameters | [com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestFlashCall.html) | +| models/requests/VerificationReportRequestParameters | [com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequest.html) | +| models/requests/VerificationReportSMSRequestParameters | [com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/request/VerificationReportRequestSms.html) | +| models/VerificationReport | [com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponse.html) | +| models/VerificationReportCallout | [com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponsePhoneCall.html) | +| models/VerificationReportFlashCall | [com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponseFlashCall.html) | +| models/VerificationReportSMS | [com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponseSms.html) | + +##### Verification Start +| Old class | New class | +|-------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/requests/StartVerificationCalloutOptions | N/A (direct access to `PhoneCallSpeech` from `VerificationStartRequestPhoneCall`) | +| models/requests/StartVerificationCalloutRequestParameters | [com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestPhoneCall.html) | +| models/requests/StartVerificationCalloutSpeechOptions | [com.sinch.sdk.domains.verification.models.v1.start.request.PhoneCallSpeech](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/PhoneCallSpeech.html) | +| models/requests/StartVerificationFlashCallRequestParameters | [com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestFlashCall.html) | +| models/requests/StartVerificationRequestParameters | [com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequest](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequest.html) | +| models/requests/StartVerificationSMSOptions | N/A (direct access to dedicated `fields` from `VerificationStartRequestSms`) | +| models/requests/StartVerificationSMSRequestParameters | [com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestSms.html) | +| models/requests/StartVerificationSeamlessRequestParameters | [com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/request/VerificationStartRequestData.html) | +| models/requests/SMSCodeType | [com.sinch.sdk.domains.verification.models.v1.SmsCodeType](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/SmsCodeType.html) | +| models/response/StartVerificationResponse | [com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponse.html) | +| models/response/StartVerificationResponseCallout | [com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponsePhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponsePhoneCall.html) | +| models/response/StartVerificationResponseFlashCall | [com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseFlashCall.html) | +| models/response/StartVerificationResponseSMS | [com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseSms.html) | +| models/response/StartVerificationResponseSeamless | [com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseData.html) | +| models/Link | [com.sinch.sdk.domains.verification.models.v1.start.response.Link](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/Link.html) | +| models/LinkRelType | [com.sinch.sdk.domains.verification.models.v1.start.response.Link.RelEnum](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/start/response/Link.RelEnum.html) | + +##### Verification Status +| Old class | New class | +|-------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/VerificationStatus | [com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponse.html) | +| models/VerificationStatusCallout | [com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponsePhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponsePhoneCall.html) | +| models/VerificationStatusFlashCall | [com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponseFlashCall.html) | +| models/VerificationStatusReasonType | [com.sinch.sdk.domains.verification.models.v1.VerificationStatusReason](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/VerificationStatusReason.html) | +| models/VerificationStatusSMS | [com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponseSms.html) | +| models/VerificationSourceType | [com.sinch.sdk.domains.verification.models.v1.status.StatusSource](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/status/StatusSource.html) | + +##### Webhooks +| Old class | New class | +|-----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| models/webhooks/VerificationEvent | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationSinchEvent.html) | +| models/webhooks/VerificationRequestEvent | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEvent.html) | +| models/webhooks/VerificationRequestEventResponse | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEventResponse.html) | +| models/webhooks/VerificationEventResponseAction | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventAction](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEventAction.html) | +| models/webhooks/VerificationRequestEventResponsePhoneCall | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponsePhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEventResponsePhoneCall.html) | +| models/webhooks/VerificationRequestEventResponseFlashCall | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponseFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEventResponseFlashCall.html) | +| models/webhooks/VerificationRequestEventResponseSMS | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponseSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationStartEventResponseSms.html) | +| models/webhooks/VerificationResultEvent | [com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationResultEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/sinchevents/VerificationResultEvent.html) | + +- `event` field removed from `VerificationRequestEvent`, `VerificationResultEvent` events. +- `method` values based onto common `VerificationMethod` class. +- `VerificationMethod.DATA` enum no longer defined. No need to be replaced because not public definition is required. +- `template` field removed from `VerificationStartRequestSms`. + +### `Mailgun` + +Full Mailgun support (introduced in SDK 1.6 as preview) has been **removed** in SDK V2. There is no replacement within this SDK. To continue using Mailgun, integrate [Mailgun's SDKs](https://documentation.mailgun.com/docs/mailgun/sdk/introduction) directly. + +#### Removed entry point + +- `SinchClient.mailgun()` has been removed. Remove all calls to this method and its returned service. + +#### Removed `Configuration.Builder` methods + +- `Configuration.Builder.setMailgunApiKey(String apiKey)` +- `Configuration.Builder.setMailgunUrl(String url)` +- `Configuration.Builder.setMailgunRegion(MailgunRegion region)` + +#### Removed classes + +- `com.sinch.sdk.models.MailgunCredentials` +- `com.sinch.sdk.models.MailgunRegion` + +#### Removed service interfaces and implementations + +- `com.sinch.sdk.domains.mailgun.MailgunService` +- `com.sinch.sdk.domains.mailgun.api.v1.MailgunService` +- `com.sinch.sdk.domains.mailgun.api.v1.EmailsService` +- `com.sinch.sdk.domains.mailgun.api.v1.TemplatesService` + +#### Removed email request/response models +- `com.sinch.sdk.domains.mailgun.models.v1.emails` +- `com.sinch.sdk.domains.mailgun.models.v1.templates` + +--- + +## 1.5.0 +Find migration guides in the developer documentation portal: +- [Messaging](https://developers.sinch.com/docs/sms/sdks/java/migration-guides) +- [Numbers](https://developers.sinch.com/docs/numbers/sdk/java/migration-guides/migration-to-versioned) +- [Verification](https://developers.sinch.com/docs/verification/sdk/java/migration-guides/migration-to-versioned) +- [Voice](https://developers.sinch.com/docs/voice/sdk/java/migration-guides/migration-to-versioned) + \ No newline at end of file diff --git a/README.md b/README.md index 995bc76a9..50dd691a6 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,6 @@ Here is the list of the Sinch products and their level of support by the Java SD | API Category | API Name | Status | |------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------|:------:| -| Email | `(preview)` Mailgun API [(javadoc)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/mailgun/package-summary.html) | ✅ | | Messaging | Conversation API [(javadoc)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/conversation/package-summary.html) | ✅ | | | SMS API [(javadoc)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/sms/package-summary.html) | ✅ | | Numbers & Connectivity | Numbers API [(javadoc)](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/latest/com/sinch/sdk/domains/numbers/package-summary.html) | ✅ | @@ -155,12 +154,9 @@ Note: Replace VERSION-YOU-WANT-TO-BE-USED by a Jackson version of a ... ``` -## Migration guides -Find migration guides in the developer documentation portal: -- [Messaging](https://developers.sinch.com/docs/sms/sdks/java/migration-guides) -- [Numbers](https://developers.sinch.com/docs/numbers/sdk/java/migration-guides/migration-to-versioned) -- [Verification](https://developers.sinch.com/docs/verification/sdk/java/migration-guides/migration-to-versioned) -- [Voice](https://developers.sinch.com/docs/voice/sdk/java/migration-guides/migration-to-versioned) +## Changelog & Migration +For information about the latest changes in the SDK, please refer to the [CHANGELOG](CHANGELOG.md) file +and the [MIGRATION-GUIDE](MIGRATION-GUIDE.md) for instructions on how to update your code when upgrading to a new major version of the SDK. ## License diff --git a/client/resources/config-default.properties b/client/resources/config-default.properties index 42cd1838a..0009c6269 100644 --- a/client/resources/config-default.properties +++ b/client/resources/config-default.properties @@ -21,9 +21,3 @@ voice-server-south-east-asia2=https://calling-apse2.api.sinch.com conversation-region= conversation-server=https://%s.conversation.api.sinch.com template-management-conversation-server=https://%s.template.api.sinch.com - -mailgun-default-server=https://api.mailgun.net -mailgun-region-server=https://api.%s.mailgun.net -mailgun-region= -mailgun-us-storage=https://storage-us-east4.api.mailgun.net,https://storage-us-west1.api.mailgun.net -mailgun-eu-storage=https://storage-europe-west1.api.mailgun.net \ No newline at end of file diff --git a/client/src/main/com/sinch/sdk/SDK.java b/client/src/main/com/sinch/sdk/SDK.java index e91d13936..98d6ab17c 100644 --- a/client/src/main/com/sinch/sdk/SDK.java +++ b/client/src/main/com/sinch/sdk/SDK.java @@ -3,6 +3,6 @@ public class SDK { public static final String NAME = "Sinch Java SDK"; - public static final String VERSION = "1.8.0-dev"; + public static final String VERSION = "2.1.0-dev"; public static final String AUXILIARY_FLAG = ""; } diff --git a/client/src/main/com/sinch/sdk/SinchClient.java b/client/src/main/com/sinch/sdk/SinchClient.java index 234610239..9e7897162 100644 --- a/client/src/main/com/sinch/sdk/SinchClient.java +++ b/client/src/main/com/sinch/sdk/SinchClient.java @@ -2,7 +2,6 @@ import com.sinch.sdk.core.utils.StringUtil; import com.sinch.sdk.domains.conversation.ConversationService; -import com.sinch.sdk.domains.mailgun.MailgunService; import com.sinch.sdk.domains.numbers.NumbersService; import com.sinch.sdk.domains.sms.SMSService; import com.sinch.sdk.domains.verification.VerificationService; @@ -11,8 +10,6 @@ import com.sinch.sdk.models.Configuration; import com.sinch.sdk.models.ConversationContext; import com.sinch.sdk.models.ConversationRegion; -import com.sinch.sdk.models.MailgunContext; -import com.sinch.sdk.models.MailgunRegion; import com.sinch.sdk.models.NumbersContext; import com.sinch.sdk.models.SMSRegion; import com.sinch.sdk.models.SmsContext; @@ -22,7 +19,6 @@ import com.sinch.sdk.models.adapters.DualToneMultiFrequencyMapper; import java.io.IOException; import java.io.InputStream; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Objects; @@ -53,11 +49,6 @@ public class SinchClient { private static final String CONVERSATION_TEMPLATE_SERVER_KEY = "template-management-conversation-server"; - private static final String MAILGUN_REGION_KEY = "mailgun-region"; - private static final String MAILGUN_DEFAULT_SERVER_KEY = "mailgun-default-server"; - private static final String MAILGUN_REGION_SERVER_KEY = "mailgun-region-server"; - private static final String MAILGUN_STORAGE_BY_REGION_SERVER_KEY = "mailgun-%s-storage"; - // sinch-sdk/{sdk_version} ({language}/{language_version}; {implementation_type}; // {auxiliary_flag}) private static final String SDK_USER_AGENT_HEADER = "User-Agent"; @@ -66,13 +57,12 @@ public class SinchClient { private final Configuration configuration; - private NumbersService numbers; - private SMSService sms; - private VerificationService verification; - private VoiceService voice; - private ConversationService conversation; - private MailgunService mailgun; - private HttpClientApache httpClient; + private volatile NumbersService numbers; + private volatile SMSService sms; + private volatile VerificationService verification; + private volatile VoiceService voice; + private volatile ConversationService conversation; + private volatile HttpClientApache httpClient; /** * Create a Sinch Client instance based onto configuration @@ -97,7 +87,6 @@ public SinchClient(Configuration configuration) { handleDefaultVerificationSettings(configurationGuard, props, builder); handleDefaultVoiceSettings(configurationGuard, props, builder); handleDefaultConversationSettings(configurationGuard, props, builder); - handleDefaultMailgunSettings(configurationGuard, props, builder); Configuration newConfiguration = builder.build(); checkConfiguration(newConfiguration); @@ -145,18 +134,9 @@ private void handleDefaultSmsSettings( } SMSRegion smsRegion = contextBuilder.getSmsRegion(); - if (null == smsRegion) { - - if (!StringUtil.isEmpty(props.getProperty(SMS_REGION_KEY))) { - smsRegion = SMSRegion.from(props.getProperty(SMS_REGION_KEY).trim()); - } - Boolean regionAsDefault = null == smsRegion; - - // To be deprecated with 2.0: no more defaulting to US region - if (null == smsRegion) { - smsRegion = SMSRegion.US; - } - contextBuilder.setSmsRegion(smsRegion).setRegionAsDefault(regionAsDefault); + if (null == smsRegion && !StringUtil.isEmpty(props.getProperty(SMS_REGION_KEY))) { + smsRegion = SMSRegion.from(props.getProperty(SMS_REGION_KEY).trim()); + contextBuilder.setSmsRegion(smsRegion); } builder.setSmsContext(contextBuilder.build()); @@ -227,25 +207,19 @@ private void handleDefaultConversationSettings( ConversationContext.Builder contextBuilder = ConversationContext.builder(configuration.getConversationContext().orElse(null)); - if (null == contextBuilder.getRegion()) { - ConversationRegion region = null; - if (!StringUtil.isEmpty(props.getProperty(CONVERSATION_REGION_KEY))) { - region = ConversationRegion.from(props.getProperty(CONVERSATION_REGION_KEY).trim()); - } - Boolean regionAsDefault = null == region; - // To be deprecated with 2.0: no more defaulting to US region - if (null == region) { - region = ConversationRegion.US; - } - contextBuilder.setRegion(region).setRegionAsDefault(regionAsDefault); + if (null == contextBuilder.getRegion() + && !StringUtil.isEmpty(props.getProperty(CONVERSATION_REGION_KEY))) { + contextBuilder.setRegion( + ConversationRegion.from(props.getProperty(CONVERSATION_REGION_KEY).trim())); } - if (StringUtil.isEmpty(contextBuilder.getUrl())) { + if (StringUtil.isEmpty(contextBuilder.getUrl()) && null != contextBuilder.getRegion()) { contextBuilder.setUrl( String.format(props.getProperty(CONVERSATION_SERVER_KEY), contextBuilder.getRegion())); } - if (StringUtil.isEmpty(contextBuilder.getTemplateManagementUrl())) { + if (StringUtil.isEmpty(contextBuilder.getTemplateManagementUrl()) + && null != contextBuilder.getRegion()) { contextBuilder.setTemplateManagementUrl( String.format( props.getProperty(CONVERSATION_TEMPLATE_SERVER_KEY), contextBuilder.getRegion())); @@ -253,63 +227,6 @@ private void handleDefaultConversationSettings( builder.setConversationContext(contextBuilder.build()); } - private void handleDefaultMailgunSettings( - Configuration configuration, Properties props, Configuration.Builder builder) { - - MailgunContext.Builder contextBuilder = - MailgunContext.builder(configuration.getMailgunContext().orElse(null)); - - if (null == contextBuilder.getRegion()) { - MailgunRegion region = null; - if (!StringUtil.isEmpty(props.getProperty(MAILGUN_REGION_KEY))) { - region = MailgunRegion.from(props.getProperty(MAILGUN_REGION_KEY).trim()); - } - Boolean regionAsDefault = null == region; - // To be deprecated with 2.0: no more defaulting to US region - if (null == region) { - region = MailgunRegion.US; - } - contextBuilder.setRegion(region).setRegionAsDefault(regionAsDefault); - } - - // url is not defined: use the region to set to an existing one and use "global" as a default - // fallback - // String url = previousContext.map(MailgunContext::getUrl).orElse(null); - if (StringUtil.isEmpty(contextBuilder.getUrl())) { - String url; - boolean useDefaultRegion = - null == contextBuilder.getRegion() - || MailgunRegion.US.value().equalsIgnoreCase(contextBuilder.getRegion().value()); - if (useDefaultRegion) { - url = props.getProperty(MAILGUN_DEFAULT_SERVER_KEY); - } else { - url = - String.format( - props.getProperty(MAILGUN_REGION_SERVER_KEY), contextBuilder.getRegion().value()); - } - contextBuilder.setUrl(url); - } - - // storage URls are not defined: set a default set related to region in use - Collection storageUrls = contextBuilder.getStorageUrls(); - if (null == storageUrls || storageUrls.isEmpty()) { - String storageKeyRegionAsString = - null == contextBuilder.getRegion() - ? "" - : contextBuilder.getRegion().value().toLowerCase(); - String storageKey = - String.format(MAILGUN_STORAGE_BY_REGION_SERVER_KEY, storageKeyRegionAsString); - String value = props.getProperty(storageKey); - if (!StringUtil.isEmpty(value)) { - storageUrls = - Arrays.stream(value.split(",")).map(String::trim).collect(Collectors.toList()); - contextBuilder.setStorageUrls(storageUrls); - } - } - - builder.setMailgunContext(contextBuilder.build()); - } - /** * Get current configuration * @@ -330,7 +247,11 @@ public Configuration getConfiguration() { */ public NumbersService numbers() { if (null == numbers) { - numbers = numbersInit(); + synchronized (this) { + if (null == numbers) { + numbers = numbersInit(); + } + } } return numbers; } @@ -345,7 +266,11 @@ public NumbersService numbers() { */ public SMSService sms() { if (null == sms) { - sms = smsInit(); + synchronized (this) { + if (null == sms) { + sms = smsInit(); + } + } } return sms; } @@ -360,7 +285,11 @@ public SMSService sms() { */ public VerificationService verification() { if (null == verification) { - verification = verificationInit(); + synchronized (this) { + if (null == verification) { + verification = verificationInit(); + } + } } return verification; } @@ -375,7 +304,11 @@ public VerificationService verification() { */ public VoiceService voice() { if (null == voice) { - voice = voiceInit(); + synchronized (this) { + if (null == voice) { + voice = voiceInit(); + } + } } return voice; } @@ -390,25 +323,15 @@ public VoiceService voice() { */ public ConversationService conversation() { if (null == conversation) { - conversation = conversationInit(); + synchronized (this) { + if (null == conversation) { + conversation = conversationInit(); + } + } } return conversation; } - /** - * Get Mailgun domain service - * - * @return Return instance onto Mailgun API service - * @see https://documentation.mailgun.com/ - * @since 1.6 - */ - public MailgunService mailgun() { - if (null == mailgun) { - mailgun = mailgunInit(); - } - return mailgun; - } - private void checkConfiguration(Configuration configuration) throws NullPointerException { Objects.requireNonNull(configuration.getOAuthUrl(), "'oauthUrl' cannot be null"); } @@ -460,13 +383,6 @@ private ConversationService conversationInit() { this::getHttpClient); } - private MailgunService mailgunInit() { - return new com.sinch.sdk.domains.mailgun.adapters.MailgunService( - getConfiguration().getMailgunCredentials().orElse(null), - getConfiguration().getMailgunContext().orElse(null), - getHttpClient()); - } - private Properties handlePropertiesFile(String fileName) { Properties prop = new Properties(); @@ -479,21 +395,28 @@ private Properties handlePropertiesFile(String fileName) { } private HttpClientApache getHttpClient() { - if (null == httpClient || httpClient.isClosed()) { - // TODO: by adding a setter, we could imagine having another HTTP client provided - // programmatically or use - // configuration file referencing another class by name - this.httpClient = new HttpClientApache(); - - // set SDK User-Agent - String userAgent = formatSdkUserAgentHeader(); - this.httpClient.setRequestHeaders( - Stream.of(new String[][] {{SDK_USER_AGENT_HEADER, userAgent}}) - .collect(Collectors.toMap(data -> data[0], data -> data[1]))); - - LOGGER.finest(String.format("HTTP client loaded (%s='%s'", SDK_USER_AGENT_HEADER, userAgent)); + HttpClientApache local = httpClient; + if (null == local || local.isClosed()) { + synchronized (this) { + local = httpClient; + if (null == local || local.isClosed()) { + // TODO: by adding a setter, we could imagine having another HTTP client provided + // programmatically or use configuration file referencing another class by name + local = new HttpClientApache(); + + // set SDK User-Agent + String userAgent = formatSdkUserAgentHeader(); + local.setRequestHeaders( + Stream.of(new String[][] {{SDK_USER_AGENT_HEADER, userAgent}}) + .collect(Collectors.toMap(data -> data[0], data -> data[1]))); + + LOGGER.finest( + String.format("HTTP client loaded (%s='%s'", SDK_USER_AGENT_HEADER, userAgent)); + this.httpClient = local; + } + } } - return this.httpClient; + return local; } private String formatSdkUserAgentHeader() { diff --git a/client/src/main/com/sinch/sdk/domains/conversation/ConversationService.java b/client/src/main/com/sinch/sdk/domains/conversation/ConversationService.java index 85c3297ea..aa8740cfd 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/ConversationService.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/ConversationService.java @@ -1,6 +1,6 @@ package com.sinch.sdk.domains.conversation; -import com.sinch.sdk.domains.conversation.api.templates.TemplatesService; +import com.sinch.sdk.domains.conversation.templates.api.TemplatesService; /** * Conversation Service diff --git a/client/src/main/com/sinch/sdk/domains/conversation/adapters/ConversationService.java b/client/src/main/com/sinch/sdk/domains/conversation/adapters/ConversationService.java index 860338e73..5061d481b 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/adapters/ConversationService.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/adapters/ConversationService.java @@ -2,7 +2,7 @@ import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.domains.conversation.api.templates.adapters.TemplatesService; +import com.sinch.sdk.domains.conversation.templates.api.adapters.TemplatesService; import com.sinch.sdk.models.ConversationContext; import com.sinch.sdk.models.UnifiedCredentials; import java.util.function.Supplier; @@ -14,8 +14,8 @@ public class ConversationService implements com.sinch.sdk.domains.conversation.C private final ServerConfiguration oAuthServer; private final Supplier httpClientSupplier; - private com.sinch.sdk.domains.conversation.api.v1.ConversationService conversationV1; - private TemplatesService templates; + private volatile com.sinch.sdk.domains.conversation.api.v1.ConversationService conversationV1; + private volatile TemplatesService templates; public ConversationService( UnifiedCredentials credentials, @@ -30,16 +30,25 @@ public ConversationService( public com.sinch.sdk.domains.conversation.api.v1.ConversationService v1() { if (null == this.conversationV1) { - this.conversationV1 = - new com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationService( - credentials, context, oAuthServer, httpClientSupplier); + synchronized (this) { + if (null == this.conversationV1) { + this.conversationV1 = + new com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationService( + credentials, context, oAuthServer, httpClientSupplier); + } + } } return this.conversationV1; } public TemplatesService templates() { if (null == this.templates) { - this.templates = new TemplatesService(credentials, context, oAuthServer, httpClientSupplier); + synchronized (this) { + if (null == this.templates) { + this.templates = + new TemplatesService(credentials, context, oAuthServer, httpClientSupplier); + } + } } return this.templates; } diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/TemplatesService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/TemplatesService.java deleted file mode 100644 index 9f336ff54..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/TemplatesService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates; - -import com.sinch.sdk.domains.conversation.api.templates.v1.TemplatesServiceV1; -import com.sinch.sdk.domains.conversation.api.templates.v2.TemplatesServiceV2; - -/** - * Service for working with Conversation templates - * - * @see online - * documentation - * @since 1.3 - */ -public interface TemplatesService { - - /** - * Service for working with templates V1 - * - * @return Templates V1 service - * @since 1.3 - */ - TemplatesServiceV1 v1(); - - /** - * Service for working with templates V2 - * - * @return Templates V2 service - * @since 1.3 - */ - TemplatesServiceV2 v2(); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplatesService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplatesService.java deleted file mode 100644 index 820e07e8f..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplatesService.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.adapters; - -import com.sinch.sdk.auth.adapters.OAuthManager; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.templates.adapters.v1.TemplatesServiceV1; -import com.sinch.sdk.domains.conversation.api.templates.adapters.v2.TemplatesServiceV2; -import com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationService; -import com.sinch.sdk.domains.conversation.templates.models.v2.ChannelTemplateOverrideMapper; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslationMapper; -import com.sinch.sdk.models.ConversationContext; -import com.sinch.sdk.models.UnifiedCredentials; -import java.util.AbstractMap; -import java.util.Map; -import java.util.Objects; -import java.util.function.Supplier; -import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class TemplatesService - implements com.sinch.sdk.domains.conversation.api.templates.TemplatesService { - - private static final Logger LOGGER = Logger.getLogger(TemplatesService.class.getName()); - private static final String SECURITY_SCHEME_KEYWORD_ = "oAuth2"; - - private final String uriUUID; - private final UnifiedCredentials credentials; - private final ServerConfiguration oAuthServer; - - private final ConversationContext context; - private final Supplier httpClientSupplier; - - private volatile Map authManagers; - private volatile TemplatesServiceV1 v1; - private volatile TemplatesServiceV2 v2; - - static { - LocalLazyInit.init(); - } - - public TemplatesService( - UnifiedCredentials credentials, - ConversationContext context, - ServerConfiguration oAuthServer, - Supplier httpClientSupplier) { - - this.uriUUID = null != credentials ? credentials.getProjectId() : null; - this.context = context; - this.credentials = credentials; - this.oAuthServer = oAuthServer; - this.httpClientSupplier = httpClientSupplier; - } - - public TemplatesServiceV1 v1() { - if (null == this.v1) { - instanceLazyInit(); - this.v1 = new TemplatesServiceV1(uriUUID, context, httpClientSupplier.get(), authManagers); - } - return this.v1; - } - - public TemplatesServiceV2 v2() { - if (null == this.v2) { - instanceLazyInit(); - this.v2 = new TemplatesServiceV2(uriUUID, context, httpClientSupplier.get(), authManagers); - } - return this.v2; - } - - private void instanceLazyInit() { - if (null != this.authManagers) { - return; - } - synchronized (this) { - if (null == this.authManagers) { - Objects.requireNonNull(credentials, "Templates service requires credentials to be defined"); - Objects.requireNonNull(context, "Templates service requires context to be defined"); - StringUtil.requireNonEmpty( - credentials.getKeyId(), "Templates service requires 'keyId' to be defined"); - StringUtil.requireNonEmpty( - credentials.getKeySecret(), "Templates service requires 'keySecret' to be defined"); - StringUtil.requireNonEmpty( - credentials.getProjectId(), "Templates service requires 'projectId' to be defined"); - - StringUtil.requireNonEmpty( - context.getTemplateManagementUrl(), - "Templates service requires 'templateManagementUrl' to be defined"); - - // To be deprecated with 2.0: no more defaulting to US region - if (Boolean.TRUE == context.regionAsDefault()) { - LOGGER.warning( - String.format( - "Using default region for Conversation Template '%s'. This default fallback will" - + " be removed in next major release and will cause a runtime error. Please" - + " configure the region you want to be used (see" - + " https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.6.0/com/sinch/sdk/models/Configuration.Builder.html#setConversationRegion(com.sinch.sdk.models.ConversationRegion))", - context.getRegion())); - } - - OAuthManager authManager = - new OAuthManager( - credentials, oAuthServer, HttpMapper.getInstance(), httpClientSupplier); - authManagers = - Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_, authManager)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - LOGGER.fine( - String.format( - "Activate templates API with template server: '%s", - context.getTemplateManagementServer().getUrl())); - } - } - } - - static final class LocalLazyInit { - - private LocalLazyInit() { - // Because of templates classes are depending of Conversation classes we need to init for a - // proper serialize/deserialize process - ConversationService.LocalLazyInit.init(); - TemplateTranslationMapper.initMapper(); - ChannelTemplateOverrideMapper.initMapper(); - } - - public static LocalLazyInit init() { - return LocalLazyInit.LazyHolder.INSTANCE; - } - - private static class LazyHolder { - - public static final LocalLazyInit INSTANCE = new LocalLazyInit(); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1.java deleted file mode 100644 index 33b10b0fd..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.adapters.v1; - -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.conversation.templates.api.internal.V1Api; -import com.sinch.sdk.domains.conversation.templates.models.v1.TemplateV1; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Map; - -public class TemplatesServiceV1 - implements com.sinch.sdk.domains.conversation.api.templates.v1.TemplatesServiceV1 { - - private final String uriUUID; - private final V1Api api; - - public TemplatesServiceV1( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new V1Api( - httpClient, - context.getTemplateManagementServer(), - authManagers, - HttpMapper.getInstance()); - } - - protected V1Api getApi() { - return this.api; - } - - public Collection list() { - return getApi().templatesListTemplates(uriUUID).getTemplates(); - } - - public TemplateV1 create(TemplateV1 template) { - return getApi().templatesCreateTemplate(uriUUID, template); - } - - public TemplateV1 get(String templateId) { - return getApi().templatesGetTemplate(uriUUID, templateId); - } - - public void delete(String templateId) { - getApi().templatesDeleteTemplate(uriUUID, templateId); - } - - public TemplateV1 update(String templateId, TemplateV1 template) { - return getApi().templatesUpdateTemplate(uriUUID, templateId, template, null); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2.java deleted file mode 100644 index 9f958ac33..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.adapters.v2; - -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.conversation.templates.api.internal.V2Api; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslation; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateV2; -import com.sinch.sdk.domains.conversation.templates.models.v2.internal.V2ListTranslationsResponseInternal; -import com.sinch.sdk.domains.conversation.templates.models.v2.request.TranslationListRequest; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.stream.Collectors; - -public class TemplatesServiceV2 - implements com.sinch.sdk.domains.conversation.api.templates.v2.TemplatesServiceV2 { - - private final String uriUUID; - private final V2Api api; - - public TemplatesServiceV2( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new V2Api( - httpClient, - context.getTemplateManagementServer(), - authManagers, - HttpMapper.getInstance()); - } - - protected V2Api getApi() { - return this.api; - } - - public Collection list() { - return getApi().templatesV2ListTemplates(uriUUID).getTemplates(); - } - - public Collection listTranslations( - String templateId, TranslationListRequest request) { - - if (null == request) { - request = TranslationListRequest.builder().build(); - } - String languageCode = request.getLanguageCode().orElse(null); - String translationVersion = request.getTranslationVersion().orElse(null); - - V2ListTranslationsResponseInternal response = - getApi().templatesV2ListTranslations(uriUUID, templateId, languageCode, translationVersion); - if (null == response || null == response.getTranslations()) { - return Collections.emptyList(); - } - return response.getTranslations().stream() - .map(TemplateTranslation::from) - .collect(Collectors.toList()); - } - - public TemplateV2 create(TemplateV2 template) { - return getApi().templatesV2CreateTemplate(uriUUID, template); - } - - public TemplateV2 get(String templateId) { - return getApi().templatesV2GetTemplate(uriUUID, templateId); - } - - public void delete(String templateId) { - getApi().templatesV2DeleteTemplate(uriUUID, templateId); - } - - public TemplateV2 update(String templateId, TemplateV2 template) { - return getApi().templatesV2UpdateTemplate(uriUUID, templateId, template); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/package-info.java deleted file mode 100644 index fe4ba06a1..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation API interface for templates management - * - * @see Conversation - * Templates - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.api.templates; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/TemplatesServiceV1.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/TemplatesServiceV1.java deleted file mode 100644 index 359701a24..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/TemplatesServiceV1.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.v1; - -import com.sinch.sdk.domains.conversation.templates.models.v1.TemplateV1; -import java.util.Collection; - -/** - * Templates V1 - * - *

Version 1 endpoints for managing message templates. - * - *

Currently maintained for existing users. - * - *

Version 2 is recommended. - * - * @see online - * documentation - * @since 1.3 - */ -public interface TemplatesServiceV1 { - - /** - * List all templates belonging to a project ID. - * - * @return List of templates - * @since 1.3 - */ - Collection list(); - - /** - * Creates a template - * - * @param template Information for creation - * @return Created template - * @since 1.3 - */ - TemplateV1 create(TemplateV1 template); - - /*** - * Get a template - * @param templateId The ID of the template to fetch. - * @return The template information - * @since 1.3 - */ - TemplateV1 get(String templateId); - - /*** - * Delete a template - * @param templateId The ID of the template to delete. - * @since 1.3 - */ - void delete(String templateId); - - /** - * Updates a template - * - * @param template Information to be updated - * @return Updated template - * @since 1.3 - */ - TemplateV1 update(String templateId, TemplateV1 template); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/package-info.java deleted file mode 100644 index da8264ff2..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v1/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation API interface for templates V1 management - * - * @see Conversation - * Templates V1 - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.api.templates.v1; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/TemplatesServiceV2.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/TemplatesServiceV2.java deleted file mode 100644 index 8717f033e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/TemplatesServiceV2.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.v2; - -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslation; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateV2; -import com.sinch.sdk.domains.conversation.templates.models.v2.request.TranslationListRequest; -import java.util.Collection; - -/** - * Templates V2 - * - *

Version 2 endpoints for managing message templates. - * - *

Recommended version for all users. - * - *

Includes strongly typed translations field (allowing for message definition using - * JSON structures also used in the send message request of the Conversation API), improved - * validation, and the ability to override omni-channel templates in favor of channel-specific - * templates (where available). - * - * @see online - * documentation - * @since 1.3 - */ -public interface TemplatesServiceV2 { - - /** - * List all templates belonging to a project ID. - * - * @return List of templates - * @since 1.3 - */ - Collection list(); - - /** - * List translations for a template - * - * @param templateId The ID of the template to fetch - * @param request Parameters for request - * @return The translations list - * @since 1.3 - */ - Collection listTranslations( - String templateId, TranslationListRequest request); - - /** - * Creates a template - * - * @param template Information for creation - * @return Created template - * @since 1.3 - */ - TemplateV2 create(TemplateV2 template); - - /*** - * Get a template - * @param templateId The ID of the template to fetch. - * @return The template information - * @since 1.3 - */ - TemplateV2 get(String templateId); - - /*** - * Delete a template - * @param templateId The ID of the template to delete. - * @since 1.3 - */ - void delete(String templateId); - - /** - * Updates a template - * - * @param template Information to be updated - * @return Updated template - * @since 1.3 - */ - TemplateV2 update(String templateId, TemplateV2 template); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/package-info.java deleted file mode 100644 index 9c16e3c54..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/templates/v2/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation API interface for templates V2 management - * - * @see Conversation - * Templates V2 - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.api.templates.v2; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/AppService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/AppService.java deleted file mode 100644 index 1089ff755..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/AppService.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.app.request.AppCreateRequest; -import com.sinch.sdk.domains.conversation.models.v1.app.request.AppUpdateRequest; -import com.sinch.sdk.domains.conversation.models.v1.app.response.AppResponse; -import com.sinch.sdk.models.ConversationRegion; -import java.util.Collection; - -/** - * Applications related service - * - *

Apps are created and configured through the Sinch Dashboard, are tied to the API user and come - * with a set of channel credentials for each underlying connected channel. - * - *

The app has a list of conversations between itself and different contacts which share the same - * project. - * - *

Webhooks, which the app is attached to, defines the destination for various events coming from - * the Conversation API. An app has the following configurable properties: - * - * @see https://developers.sinch.com/docs/conversation/api-reference/conversation/tag/App/ - * @since 1.3 - */ -public interface AppService { - - /** - * List all apps - * - *

Get a list of all apps in the specified project - * - * @return List of apps related to configured region (from {@link - * com.sinch.sdk.models.Configuration.Builder#setConversationRegion(ConversationRegion)}) - * @since 1.3 - */ - Collection list(); - - /** - * Get an app - * - *

Returns a particular app as specified by the App ID. - * - * @param appId The application identifier - * @return App information details - * @since 1.3 - */ - AppResponse get(String appId); - - /** - * Delete an app - * - *

Deletes the app specified by the App ID - * - *

Note that this operation will not delete contacts (which are stored at the project level) - * nor any channel-specific resources (for example, WhatsApp Sender Identities will not be - * deleted). - * - * @param appId The application identifier - * @since 1.3 - */ - void delete(String appId); - - /** - * Create a Conversation application - * - *

You can create a new Conversation API app using the API. - * - *

You can create an app for one or more channels at once. - * - * @param parameters Creation parameters - * @return Created application - * @since 1.3 - */ - AppResponse create(AppCreateRequest parameters); - - /** - * Update a Conversation application - * - *

Updates a particular app as specified by the App ID. - * - *

Any specified field values will replace existing values. - * - *

Therefore, if you'd like to add additional configurations to an existing Conversation API - * app, ensure that you include existing values AND new values in the call.
- * For example, if you'd like to add new channel_credentials, you can get your - * existing Conversation API app, extract the existing channel_credentials list, - * append your new configuration to that list, and include the updated channel_credentials - * list in this update call. - * - * @param appId The unique ID of the app to be updated - * @param parameters Fields to be updated. Only fields filled within the parameters will be - * updated - * @return Updated application - * @since 1.3 - */ - AppResponse update(String appId, AppUpdateRequest parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/CapabilityService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/CapabilityService.java deleted file mode 100644 index 3b51613a7..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/CapabilityService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.capability.request.QueryCapabilityRequest; -import com.sinch.sdk.domains.conversation.models.v1.capability.response.QueryCapabilityResponse; - -/** - * Service for working with capability - * - *

A capability query checks the options available for reaching the contact on the channels on - * which it has a channel identity. - * - *

Capability queries can only be executed for contacts that already exist in a project and app. - * For executing the request, either the contact ID or the channel recipient identities of the - * contact are required. - * - *

The request is executed asynchronously, therefore the service responds immediately. The result - * of the capability query is sent to the registered webhook for the CAPABILITY trigger. - * - * @see online - * documentation - * @since 1.3 - */ -public interface CapabilityService { - - /** - * Capability lookup - * - *

This method is asynchronous - it immediately returns the requested Capability registration. - * - *

Capability check is then delivered as a callback to registered webhooks with trigger - * CAPABILITY for every reachable channel. - * - * @param request The request parameters to lookup capability - * @return The capability response - * @since 1.3 - */ - QueryCapabilityResponse lookup(QueryCapabilityRequest request); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ContactService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ContactService.java deleted file mode 100644 index 27cc78709..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ContactService.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import com.sinch.sdk.domains.conversation.models.v1.contact.Contact; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactCreateRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByChannelIdentityRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByContactIdRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactListRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.response.ContactListResponse; - -/** - * Contact related service - * - *

A contact is a collection that groups together underlying connected channel recipient - * identities. - * - *

It's tied to a specific project and is therefore considered public to all apps sharing the - * same project. - * - *

Most contact creation and maintenance is handled by the Conversation API's automatic see contact management - * processes. - * - *

However, you can also use API calls to manually manage your contacts. - * - * @see https://developers.sinch.com/docs/conversation/api-reference/conversation/tag/Contact - * @since 1.3 - */ -public interface ContactService { - - /** - * List Contacts - * - *

List all contacts in the project. Note that, if a WhatsApp contact is returned, the - * display_name field of that contact may be populated with the WhatsApp display name (if the name - * is already stored on the server and the display_name field has not been overwritten by the - * user). - * - * @param parameters Filtering parameters - * @return List of contacts according to search criteria - * @since 1.3 - */ - ContactListResponse list(ContactListRequest parameters); - - /** - * Get a Contact - * - *

Returns a specific contact as specified by the contact ID. Note that, if a WhatsApp contact - * is returned, the display_name field of that contact may be populated with the WhatsApp display - * name (if the name is already stored on the server and the display_name field has not been - * overwritten by the user). - * - * @param contactId Contact's Id - * @return Contact information - * @since 1.3 - */ - Contact get(String contactId); - - /** - * Create a Contact - * - *

Most Conversation API contacts are created - * automatically when a message is sent to a new recipient. You can also create a new contact - * manually using this API call. - * - * @param contact Contact information to be used for creation - * @return Contact information - * @since 1.3 - */ - Contact create(ContactCreateRequest contact); - - /** - * Delete a contact as specified by the contact ID. - * - * @param contactId Contact's Id - * @since 1.3 - */ - void delete(String contactId); - - /** - * Updates a contact as specified by the contact ID. - * - * @param contactId Contact ID to be updated - * @param contact Contact information to be updated - * @return Updated contact information - * @since 1.3 - */ - Contact update(String contactId, Contact contact); - - /** - * Merge two Contacts. - * - *

The remaining contact will contain all conversations that the removed contact did. - * - *

If both contacts had conversations within the same App, messages from the removed contact - * will be merged into corresponding active conversations in the destination contact. - * - *

Channel identities will be moved from the source contact to the destination contact only for - * channels that weren't present there before. - * - *

Moved channel identities will be placed at the bottom of the channel priority list. Optional - * fields from the source contact will be copied only if corresponding fields in the destination - * contact are empty - * - *

The contact being removed cannot be referenced after this call. - * - * @param destinationId The unique ID of the contact that should be kept when merging two - * contacts. - * @param sourceId The ID of the contact that should be removed - * @return The merged contact details - * @since 1.3 - */ - Contact mergeContact(String destinationId, String sourceId); - - /** - * Get user profile from a specific channel by contact ID. - * - *

Only supported on {@link ConversationChannel#MESSENGER MESSENGER}, {@link - * ConversationChannel#INSTAGRAM INSTAGRAM}, {@link ConversationChannel#VIBER VIBER} and {@link - * ConversationChannel#LINE LINE} channels. - * - *

Note that, in order to retrieve a WhatsApp display name, you can use the Get a Contact or - * List Contacts operations, which will populate the display_name field of each returned contact - * with the WhatsApp display name (if the name is already stored on the server and the - * display_name field has not been overwritten by the user). - * - * @param parameters The ID of the contact to be used to check profile information - * @return The profile name - * @since 1.3 - */ - String getChannelProfileByContactId(ContactGetChannelProfileByContactIdRequest parameters); - - /** - * Get user profile from a specific channel by channel identity. - * - *

Only supported on {@link ConversationChannel#MESSENGER MESSENGER}, {@link - * ConversationChannel#INSTAGRAM INSTAGRAM}, {@link ConversationChannel#VIBER VIBER} and {@link - * ConversationChannel#LINE LINE} channels. - * - *

Note that, in order to retrieve a WhatsApp display name, you can use the Get a Contact or - * List Contacts operations, which will populate the display_name field of each returned contact - * with the WhatsApp display name (if the name is already stored on the server and the - * display_name field has not been overwritten by the user). - * - * @param parameters The identity as specified by the channel to be used to check profile - * information - * @return The profile name - * @since 1.3 - */ - String getChannelProfileByChannelIdentity( - ContactGetChannelProfileByChannelIdentityRequest parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationService.java index 6bafe0a07..dd36aec6c 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationService.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationService.java @@ -1,5 +1,7 @@ package com.sinch.sdk.domains.conversation.api.v1; +import com.sinch.sdk.domains.conversation.templates.api.TemplatesService; + /** * Conversation Service V1 * @@ -15,7 +17,7 @@ public interface ConversationService { * @return service instance for project * @since 1.3 */ - AppService app(); + AppsService apps(); /** * Contact Service instance @@ -23,7 +25,7 @@ public interface ConversationService { * @return service instance for project * @since 1.3 */ - ContactService contact(); + ContactsService contacts(); /** * Messages Service instance @@ -66,10 +68,34 @@ public interface ConversationService { CapabilityService capability(); /** - * WebHooksService Service instance + * ProjectSettings Service instance * * @return service instance for project - * @since 1.3 + * @since 2.0 + */ + ProjectSettingsService projectSettings(); + + /** + * Event Destinations Management Service instance + * + * @return service instance for project + * @since 2.0 + */ + EventDestinationsService eventDestinations(); + + /** + * Sinch Events helpers instance + * + * @return service instance for project + * @since 2.0 + */ + SinchEventsService sinchEvents(); + + /** + * Templates Service instance + * + * @return service instance for project + * @since 2.0 */ - WebHooksService webhooks(); + TemplatesService templates(); } diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationsService.java deleted file mode 100644 index c07daade3..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationsService.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.conversation.Conversation; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.CreateConversationRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectEventRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListRecentResponse; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListResponse; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.InjectEventResponse; -import com.sinch.sdk.domains.conversation.models.v1.request.MetadataUpdateStrategy; - -/** - * Service for working with the conversation log - * - * @see online - * documentation - * @since 1.3 - */ -public interface ConversationsService { - - /** - * Creates a new empty conversation. - * - *

It is generally not needed to create a conversation explicitly since sending or receiving a - * message automatically creates a new conversation if it does not already exist between the given - * app and contact. - * - *

Creating empty conversation is useful if the metadata of the conversation should be - * populated when the first message in the conversation is a contact message or the first message - * in the conversation comes out-of-band and needs to be injected with InjectMessage. - * - * @param request Conversation request for creation - * @return Created conversation - * @since 1.3 - */ - Conversation create(CreateConversationRequest request); - - /** - * Retrieves a conversation by id. A conversation has two participating entities, an app and a - * contact. - * - * @param conversationId The unique ID of the conversation. - * @return Conversation details - * @since 1.3 - */ - Conversation get(String conversationId); - - /** - * This operation lists all conversations that are associated with an app and/or a contact. - * - * @param request Request parameters - * @since 1.3 - */ - ConversationsListResponse list(ConversationsListRequest request); - - /** - * This operation lists conversations and their most recent message, ordered by when the most - * recent message was sent for that conversation. - * - * @param request Request parameters - * @since 1.3 - */ - ConversationsListRecentResponse listRecent(ConversationsListRecentRequest request); - - /** - * This operation stops the referenced conversation, if the conversation is still active. - * - *

A new conversation will be created if a new message is exchanged between the app or contact - * that was part of the stopped conversation. - * - * @param conversationId The unique ID of the conversation. - * @since 1.3 - */ - void stopActive(String conversationId); - - /** - * Deletes a conversation together with all the messages sent as part of the conversation. - * - * @param conversationId The unique ID of the conversation. - * @since 1.3 - */ - void delete(String conversationId); - - /** - * This operation updates a conversation which can, for instance, be used to update the metadata - * associated with a conversation. - * - * @param request Conversation instance with fields to be updated - * @return Update conversation - * @since 1.3 - */ - Conversation update( - String conversationId, MetadataUpdateStrategy updateStrategy, Conversation request); - - /** - * This operation injects a conversation message in to a specific conversation. - * - * @param conversationId The ID of the conversation. - * @param request Request parameters to inject message - * @since 1.3 - */ - void injectMessage(String conversationId, InjectMessageRequest request); - - /** - * This operation injects a conversation event into a specific conversation. - * - * @param conversationId The ID of the conversation. - * @param request Request parameters to inject event - * @since 1.3 - */ - InjectEventResponse injectEvent(String conversationId, InjectEventRequest request); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/EventsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/EventsService.java deleted file mode 100644 index b419746ac..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/EventsService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.events.ConversationEvent; -import com.sinch.sdk.domains.conversation.models.v1.events.request.EventsListRequest; -import com.sinch.sdk.domains.conversation.models.v1.events.request.SendEventRequest; -import com.sinch.sdk.domains.conversation.models.v1.events.response.EventsListResponse; -import com.sinch.sdk.domains.conversation.models.v1.events.response.SendEventResponse; - -/** - * Service for working with the Events - * - * @see online - * documentation - * @since 1.3 - */ -public interface EventsService { - - /** - * Send an event - * - *

Sends an event to the referenced contact from the referenced app. - * - *

Note that this operation enqueues the event in a queue so a successful response only - * indicates that the event has been queued - * - * @param request Send event request parameters - * @return Response related to event enqueued - * @since 1.3 - */ - SendEventResponse send(SendEventRequest request); - - /** - * Get event from ID - * - * @param eventId The unique ID of the event - * @return Conversation event - * @since 1.3 - */ - ConversationEvent get(String eventId); - - /** - * Delete a specific event by its ID - * - * @param eventId The unique ID of the event - * @since 1.3 - */ - void delete(String eventId); - - /** - * List all events in a project - * - * @param request Request parameters - * @return List of events - * @since 1.3 - */ - EventsListResponse list(EventsListRequest request); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/MessagesService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/MessagesService.java deleted file mode 100644 index b90e197ea..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/MessagesService.java +++ /dev/null @@ -1,252 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody; -import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessageUpdateRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesListRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.SendMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.response.MessagesListResponse; -import com.sinch.sdk.domains.conversation.models.v1.messages.response.SendMessageResponse; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.card.CardMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.carousel.CarouselMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.contactinfo.ContactInfoMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.list.ListMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.template.TemplateMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; - -/** - * Messages related service - * - *

To start sending messages you must have a Conversation API app. The app holds information about the - * channel credentials and registered webhooks to which the API delivers callbacks such as message - * delivery receipts and contact messages. If you don't already have an app please follow the - * instructions in the getting started guide available in the Sinch Dashboard to create one. - * - * @see https://developers.sinch.com/docs/conversation/api-reference/conversation/tag/Messages - * @since 1.3 - */ -public interface MessagesService { - - /** - * Send a message - * - *

You can send a message from a Conversation app to a contact associated with that app. If the - * recipient is not associated with an existing contact, a new contact will be created. - * - *

The message is added to the active conversation with the contact if a conversation already - * exists. If no active conversation exists a new one is started automatically. - * - *

You can find all of your IDs and authentication credentials on the Sinch Customer Dashboard. - * - * @param request Request parameters - * @return Response related to sent message - * @since 1.3 - */ - SendMessageResponse sendMessage(SendMessageRequest request); - - /** - * Send a card message - * - * @param request CardMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendCardMessage(SendMessageRequest request); - - /** - * Send a carousel message - * - * @param request CarouselMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendCarouselMessage(SendMessageRequest request); - - /** - * Send a choice message - * - * @param request ChoiceMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendChoiceMessage(SendMessageRequest request); - - /** - * Send a contact info message - * - * @param request ContactInfoMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendContactInfoMessage(SendMessageRequest request); - - /** - * Send a list message - * - * @param request ListMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendListMessage(SendMessageRequest request); - - /** - * Send a location message - * - * @param request LocationMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendLocationMessage(SendMessageRequest request); - - /** - * Send a media message - * - * @param request MediaMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendMediaMessage(SendMessageRequest request); - - /** - * Send a template message - * - * @param request TemplateMessage request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendTemplateMessage(SendMessageRequest request); - - /** - * Send a send message request message - * - * @param request request - * @return Response related to sent message - * @see #sendMessage(SendMessageRequest) - * @since 1.3 - */ - SendMessageResponse sendTextMessage(SendMessageRequest request); - - /** - * Helper method for {@link #get(String, MessageSource)} - * - * @see #get(String, MessageSource) - * @param messageId The unique ID of the message. - * @return Conversation message - * @since 1.3 - */ - ConversationMessage get(String messageId); - - /** - * Retrieves a specific message by its ID. - * - * @param messageId The unique ID of the message. - * @param messageSource Specifies the message source for which the request will be processed. Used - * for operations on messages in Dispatch Mode. For more information, see Processing Modes - * @default CONVERSATION_SOURCE - * @return Conversation message - * @since 1.3 - */ - ConversationMessage get(String messageId, MessageSource messageSource); - - /** - * This operation lists all messages sent or received via particular {@link - * com.sinch.sdk.domains.conversation.models.v1.ProcessingMode}. - * - *

Setting the messages_source parameter to CONVERSATION_SOURCE - * allows for querying messages in CONVERSATION mode, and setting it to - * DISPATCH_SOURCE will allow for queries of messages in DISPATCH mode. - * - *

Combining multiple parameters is supported for more detailed filtering of messages, but some - * of them are not supported depending on the value specified for messages_source. - * The description for each field will inform if that field may not be supported. - * - *

The messages are ordered by their accept_time property in descending order, - * where accept_time is a timestamp of when the message was enqueued by the - * Conversation API. This means messages received most recently will be listed first. - * - * @param request Request parameters - * @return List of messages - * @since 1.3 - */ - MessagesListResponse list(MessagesListRequest request); - - /** - * Helper method for {@link #delete(String, MessageSource)} - * - * @see #delete(String, MessageSource) - * @param messageId The unique ID of the message. - * @since 1.3 - */ - void delete(String messageId); - - /** - * Delete a specific message by its ID. - * - * @apiNote Removing all messages of a conversation will not automatically delete the - * conversation. - * @param messageId The unique ID of the message. - * @param messageSource Specifies the message source for which the request will be processed. Used - * for operations on messages in Dispatch Mode. For more information, see Processing Modes - * @default CONVERSATION_SOURCE - * @since 1.3 - */ - void delete(String messageId, MessageSource messageSource); - - /** - * Helper method for {@link #update(String, MessageSource, MessageUpdateRequest)} - * - * @see #update(String, MessageSource, MessageUpdateRequest) - * @param messageId The unique ID of the message. - * @param request Request parameters to be used for updating - * @return Updated message - * @since 1.3 - */ - ConversationMessage update(String messageId, MessageUpdateRequest request); - - /** - * Update a specific message by its ID. - * - * @param messageId The unique ID of the message - * @param messageSource Specifies the message source for which the request will be processed. Used - * for operations on messages in Dispatch Mode. For more information, see Processing Modes - * @default CONVERSATION_SOURCE - * @param request Request parameters to be used for updating - * @return Updated message - * @since 1.3 - */ - ConversationMessage update( - String messageId, MessageSource messageSource, MessageUpdateRequest request); - - /** - * Specifies the message source for which the request will be processed. Used for operations on - * messages in Dispatch Mode - */ - enum MessageSource { - /** - * The default messages source. Retrieves messages sent in the default CONVERSATION - * processing mode, which associates the messages with a specific conversation and contact. - */ - CONVERSATION_SOURCE, - /** - * Retrieves messages sent in the DISPATCH processing mode. These types of messages - * are not associated with any conversation or contact. - */ - DISPATCH_SOURCE - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/SinchEventsService.java new file mode 100644 index 000000000..e8863ae54 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/SinchEventsService.java @@ -0,0 +1,54 @@ +package com.sinch.sdk.domains.conversation.api.v1; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.ConversationSinchEvent; +import java.util.Map; + +/** + * Sinch Events service + * + *

Callback events are used to get notified about Conversation usage according to your configured + * callback URL + * + *

see online + * documentation + * + * @since 2.0 + */ +public interface SinchEventsService { + + /** + * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request + * and result events. All callback requests are signed and the signature is included in the + * Authorization header of the request + * + *

By using following function, you can ensure authentication according to received payload + * from your backend + * + * @param secret Secret token to be used to validate received request. See App's webhook configuration onto dashboard + * @param headers Received headers + * @param jsonPayload Received payload + * @return Is authentication validated (true) or not (false) + *

see online + * documentation + * @since 2.0 + */ + boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload); + + /** + * This function can be called to deserialize received payload onto callback onto proper java + * verification event class + * + * @param jsonPayload Received payload to be deserialized + * @return The verification event instance class + *

see triggered + * events + * @since 2.0 + */ + ConversationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException; +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/TranscodingService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/TranscodingService.java deleted file mode 100644 index ca52e36bd..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/TranscodingService.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.domains.conversation.models.v1.transcoding.request.TranscodeMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.transcoding.response.TranscodeMessageResponse; - -/** - * Service for working with transcoding - * - * @see online - * documentation - * @since 1.3 - */ -public interface TranscodingService { - - /** - * Transcodes the message from the Conversation API format to the channel-specific formats for the - * requested channels. - * - *

No message is sent to the contact. - * - * @param request The message to be transcoded, and the app and channels for which the message is - * to be transcoded - * @return Transcoded message - * @since 1.3 - */ - TranscodeMessageResponse transcodeMessage(TranscodeMessageRequest request); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/WebHooksService.java deleted file mode 100644 index b42dc165f..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/WebHooksService.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.ConversationWebhookEvent; -import java.util.Collection; -import java.util.Map; - -/** - * Webhooks service - * - *

The Conversation API delivers contact messages, delivery receipts for app messages and various - * notifications through callbacks. - * - *

see online - * documentation - * - * @since 1.3 - */ -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed and the signature is included in the - * Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param secret Secret token to be used to validate received request. See App's webhook configuration onto dashboard - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see online - * documentation - * @since 1.3 - */ - boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback onto proper java - * verification event class - * - * @param jsonPayload Received payload to be deserialized - * @return The verification event instance class - *

see triggered - * events - * @since 1.3 - */ - ConversationWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException; - - /** - * List all webhooks for a given app as specified by the App ID. - * - * @param appId The unique ID of the app - * @return List of defined webhooks - * @since 1.3 - */ - Collection list(String appId); - - /** - * Get a webhook as specified by the webhook ID. - * - * @param webhookId The unique ID of the webhook. - * @return Webhook definition - * @since 1.3 - */ - Webhook get(String webhookId); - - /** - * Creates a webhook for receiving callbacks on specific triggers - * - * @param webhook Webhook parameter for creation - * @return Created webhook - * @since 1.3 - */ - Webhook create(Webhook webhook); - - /** - * Updates an existing webhook as specified by the webhook ID. - * - * @param webhookId The unique ID of the webhook. - * @param webhook Webhook parameter for creation - * @return Created webhook - * @since 1.3 - */ - Webhook update(String webhookId, Webhook webhook); - - /** - * Deletes a webhook as specified by the webhook ID - * - * @param webhookId The unique ID of the webhook. - * @since 1.3 - */ - void delete(String webhookId); -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/AppService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/AppService.java deleted file mode 100644 index cbd5354b7..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/AppService.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.domains.conversation.api.v1.internal.AppApi; -import com.sinch.sdk.domains.conversation.models.v1.app.request.AppCreateRequest; -import com.sinch.sdk.domains.conversation.models.v1.app.request.AppUpdateRequest; -import com.sinch.sdk.domains.conversation.models.v1.app.response.AppResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Map; - -public class AppService implements com.sinch.sdk.domains.conversation.api.v1.AppService { - - private final String uriUUID; - private final AppApi api; - - public AppService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = new AppApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected AppApi getApi() { - return this.api; - } - - public Collection list() throws ApiException { - return getApi().appListApps(uriUUID).getApps(); - } - - public AppResponse get(String appId) { - return getApi().appGetApp(uriUUID, appId); - } - - public void delete(String appId) { - getApi().appDeleteApp(uriUUID, appId); - } - - public AppResponse create(AppCreateRequest parameters) { - - return getApi().appCreateApp(uriUUID, parameters); - } - - public AppResponse update(String appId, AppUpdateRequest parameters) { - return getApi().appUpdateApp(uriUUID, appId, parameters, null); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityService.java deleted file mode 100644 index c11b99dec..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.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.conversation.api.v1.internal.CapabilityApi; -import com.sinch.sdk.domains.conversation.models.v1.capability.request.QueryCapabilityRequest; -import com.sinch.sdk.domains.conversation.models.v1.capability.response.QueryCapabilityResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Map; - -public class CapabilityService - implements com.sinch.sdk.domains.conversation.api.v1.CapabilityService { - - private final String uriUUID; - private final CapabilityApi api; - - public CapabilityService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new CapabilityApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected CapabilityApi getApi() { - return this.api; - } - - public QueryCapabilityResponse lookup(QueryCapabilityRequest request) { - return getApi().capabilityQueryCapability(uriUUID, request); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactService.java deleted file mode 100644 index 731875d61..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactService.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.conversation.api.v1.internal.ContactApi; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import com.sinch.sdk.domains.conversation.models.v1.contact.Contact; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactCreateRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByChannelIdentityRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByContactIdRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactListRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.GetChannelProfileRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.MergeContactRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.response.ContactListResponse; -import com.sinch.sdk.domains.conversation.models.v1.contact.response.ListContactsResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -public class ContactService implements com.sinch.sdk.domains.conversation.api.v1.ContactService { - - private final String uriUUID; - private final ContactApi api; - private final Collection supportedChannelForGetProfile = - Arrays.asList( - ConversationChannel.INSTAGRAM, - ConversationChannel.MESSENGER, - ConversationChannel.VIBER, - ConversationChannel.LINE); - - public ContactService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new ContactApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected ContactApi getApi() { - return this.api; - } - - public ContactListResponse list(ContactListRequest client) throws ApiException { - - // guard against null value to start with a default request parameters set - if (null == client) { - client = ContactListRequest.builder(null).build(); - } - - String externalId = client.getExternalId().orElse(null); - ConversationChannel channel = client.getChannel().orElse(null); - String identity = client.getIdentity().orElse(null); - - Integer pageSize = client.getPageSize().orElse(null); - String pageToken = client.getPageToken().orElse(null); - - ListContactsResponse response = - getApi().contactListContacts(uriUUID, pageSize, pageToken, externalId, channel, identity); - - String nextPageToken = response.getNextPageToken(); - List list = response.getContacts(); - Collection pageContent = null != list ? list : Collections.emptyList(); - Pair, TokenPageNavigator> content = - new Pair<>(pageContent, TokenPageNavigator.valueOf(nextPageToken)); - return new ContactListResponse(this, new Page<>(client, content.getLeft(), content.getRight())); - } - - public Contact get(String contactId) { - return getApi().contactGetContact(uriUUID, contactId); - } - - public Contact create(ContactCreateRequest client) { - return getApi().contactCreateContact(uriUUID, client); - } - - public void delete(String contactId) { - - getApi().contactDeleteContact(uriUUID, contactId); - } - - public Contact update(String contactId, Contact client) { - - return getApi().contactUpdateContact(uriUUID, contactId, client, null); - } - - public Contact mergeContact(String destinationId, String sourceId) { - return getApi() - .contactMergeContact( - uriUUID, destinationId, MergeContactRequest.builder().setSourceId(sourceId).build()); - } - - public String getChannelProfileByContactId(ContactGetChannelProfileByContactIdRequest client) { - - checkGetChannelProfileChannelType(client); - return getApi().contactGetChannelProfile(uriUUID, client).getProfileName(); - } - - public String getChannelProfileByChannelIdentity( - ContactGetChannelProfileByChannelIdentityRequest client) { - - checkGetChannelProfileChannelType(client); - return getApi().contactGetChannelProfile(uriUUID, client).getProfileName(); - } - - private void checkGetChannelProfileChannelType(GetChannelProfileRequest client) { - - if (null != client && !supportedChannelForGetProfile.contains(client.getChannel())) { - throw new IllegalArgumentException( - String.format( - "Invalid channel value '%s'. Channel has to be in list '%s'", - client.getChannel(), supportedChannelForGetProfile)); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java index 695e8384c..ce9c0160d 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationService.java @@ -1,13 +1,21 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import com.sinch.sdk.auth.HmacAuthenticationValidation; import com.sinch.sdk.auth.adapters.OAuthManager; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.core.http.HttpMapper; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.templates.adapters.TemplatesService; -import com.sinch.sdk.domains.conversation.api.v1.WebHooksService; +import com.sinch.sdk.domains.conversation.api.v1.AppsService; +import com.sinch.sdk.domains.conversation.api.v1.CapabilityService; +import com.sinch.sdk.domains.conversation.api.v1.ContactsService; +import com.sinch.sdk.domains.conversation.api.v1.ConversationsService; +import com.sinch.sdk.domains.conversation.api.v1.EventDestinationsService; +import com.sinch.sdk.domains.conversation.api.v1.EventsService; +import com.sinch.sdk.domains.conversation.api.v1.MessagesService; +import com.sinch.sdk.domains.conversation.api.v1.ProjectSettingsService; +import com.sinch.sdk.domains.conversation.api.v1.TranscodingService; import com.sinch.sdk.domains.conversation.api.v1.adapters.credentials.LineEnterpriseCredentialsMapper; import com.sinch.sdk.domains.conversation.api.v1.adapters.events.app.AppEventMapper; import com.sinch.sdk.domains.conversation.api.v1.adapters.events.contactmessage.internal.ContactMessageEventMapper; @@ -20,6 +28,9 @@ import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.OmniMessageOverrideMapper; import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.SendMessageRequestMapper; import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.WhatsAppInteractiveHeaderMapper; +import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.buttons.KakaoTalkButtonMapper; +import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.commerce.KakaoTalkCommerceMapper; +import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.coupons.KakaoTalkCouponMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.ChoiceItemMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.AppMessageInternalMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ChannelSpecificMessageInternalMapper; @@ -28,7 +39,9 @@ import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.CardMessageMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.ChoiceMessageMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.ListMessageInternalMapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.WhatsAppPaymentButtonMapper; import com.sinch.sdk.domains.conversation.models.v1.messages.types.template.TemplateMessageMapper; +import com.sinch.sdk.domains.conversation.templates.api.adapters.TemplatesService; import com.sinch.sdk.models.ConversationContext; import com.sinch.sdk.models.UnifiedCredentials; import java.util.AbstractMap; @@ -52,14 +65,16 @@ public class ConversationService private final Supplier httpClientSupplier; private volatile Map authManagers; - private volatile AppService app; - private volatile ContactService contact; + private volatile AppsService apps; + private volatile ContactsService contacts; private volatile MessagesService messages; private volatile ConversationsService conversations; private volatile EventsService events; private volatile TranscodingService transcoding; private volatile CapabilityService capability; - private volatile WebHooksService webhooks; + private volatile ProjectSettingsService projectSettings; + private volatile EventDestinationsService eventDestinations; + private volatile SinchEventsService sinchEvents; private volatile TemplatesService templates; static { @@ -79,79 +94,189 @@ public ConversationService( this.oAuthServer = oAuthServer; } - public AppService app() { - if (null == this.app) { - instanceLazyInit(); - this.app = new AppService(uriUUID, context, httpClientSupplier.get(), authManagers); + public AppsService apps() { + if (null == this.apps) { + synchronized (this) { + if (null == this.apps) { + instanceLazyInit(); + this.apps = + new AppsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } - return this.app; + return this.apps; } - public ContactService contact() { - if (null == this.contact) { - instanceLazyInit(); - this.contact = new ContactService(uriUUID, context, httpClientSupplier.get(), authManagers); + public ContactsService contacts() { + if (null == this.contacts) { + synchronized (this) { + if (null == this.contacts) { + instanceLazyInit(); + this.contacts = + new ContactsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } - return this.contact; + return this.contacts; } public MessagesService messages() { if (null == this.messages) { - instanceLazyInit(); - this.messages = new MessagesService(uriUUID, context, httpClientSupplier.get(), authManagers); + synchronized (this) { + if (null == this.messages) { + instanceLazyInit(); + this.messages = + new MessagesServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.messages; } public ConversationsService conversations() { if (null == this.conversations) { - instanceLazyInit(); - this.conversations = - new ConversationsService(uriUUID, context, httpClientSupplier.get(), authManagers); + synchronized (this) { + if (null == this.conversations) { + instanceLazyInit(); + this.conversations = + new ConversationsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.conversations; } public EventsService events() { if (null == this.events) { - instanceLazyInit(); - this.events = new EventsService(uriUUID, context, httpClientSupplier.get(), authManagers); + synchronized (this) { + if (null == this.events) { + instanceLazyInit(); + this.events = + new EventsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.events; } public TranscodingService transcoding() { if (null == this.transcoding) { - instanceLazyInit(); - this.transcoding = - new TranscodingService(uriUUID, context, httpClientSupplier.get(), authManagers); + synchronized (this) { + if (null == this.transcoding) { + instanceLazyInit(); + this.transcoding = + new TranscodingServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.transcoding; } public CapabilityService capability() { if (null == this.capability) { - instanceLazyInit(); - this.capability = - new CapabilityService(uriUUID, context, httpClientSupplier.get(), authManagers); + synchronized (this) { + if (null == this.capability) { + instanceLazyInit(); + this.capability = + new CapabilityServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.capability; } public TemplatesService templates() { if (null == this.templates) { - this.templates = new TemplatesService(credentials, context, oAuthServer, httpClientSupplier); + synchronized (this) { + if (null == this.templates) { + this.templates = + new TemplatesService(credentials, context, oAuthServer, httpClientSupplier); + } + } } return this.templates; } - public WebHooksService webhooks() { - if (null == this.webhooks) { - this.webhooks = - new WebHooksAdaptorService( - uriUUID, context, this::instanceLazyInit, httpClientSupplier, () -> authManagers); + public EventDestinationsService eventDestinations() { + if (null == this.eventDestinations) { + synchronized (this) { + if (null == this.eventDestinations) { + instanceLazyInit(); + this.eventDestinations = + new EventDestinationsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } + } + return this.eventDestinations; + } + + public SinchEventsService sinchEvents() { + if (null == this.sinchEvents) { + synchronized (this) { + if (null == this.sinchEvents) { + this.sinchEvents = new SinchEventsService(new HmacAuthenticationValidation()); + } + } + } + return this.sinchEvents; + } + + public ProjectSettingsService projectSettings() { + if (null == this.projectSettings) { + synchronized (this) { + if (null == this.projectSettings) { + instanceLazyInit(); + this.projectSettings = + new ProjectSettingsServiceImpl( + httpClientSupplier.get(), + context.getServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } - return this.webhooks; + return this.projectSettings; } private void instanceLazyInit() { @@ -169,20 +294,13 @@ private void instanceLazyInit() { credentials.getKeySecret(), "Conversation service requires 'keySecret' to be defined"); StringUtil.requireNonEmpty( credentials.getProjectId(), "Conversation service requires 'projectId' to be defined"); + Objects.requireNonNull( + context.getRegion(), "Conversation service requires 'region' to be defined"); + StringUtil.requireNonEmpty( + context.getRegion().value(), "Conversation service requires 'region' to be defined"); StringUtil.requireNonEmpty( context.getUrl(), "Conversation service requires 'url' to be defined"); - // To be deprecated with 2.0: no more defaulting to US region - if (Boolean.TRUE == context.regionAsDefault()) { - LOGGER.warning( - String.format( - "Using default region for Conversation '%s'. This default fallback will be" - + " removed in next major release and will cause a runtime error. Please" - + " configure the region you want to be used (see" - + " https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.6.0/com/sinch/sdk/models/Configuration.Builder.html#setConversationRegion(com.sinch.sdk.models.ConversationRegion))", - context.getRegion())); - } - OAuthManager authManager = new OAuthManager( credentials, oAuthServer, HttpMapper.getInstance(), httpClientSupplier); @@ -214,6 +332,9 @@ private LocalLazyInit() { ContactMessageMapper.initMapper(); ContactMessageInternalMapper.initMapper(); ConversationMessageMapper.initMapper(); + KakaoTalkButtonMapper.initMapper(); + KakaoTalkCommerceMapper.initMapper(); + KakaoTalkCouponMapper.initMapper(); LineEnterpriseCredentialsMapper.initMapper(); ListMessageInternalMapper.initMapper(); ListSectionMapper.initMapper(); @@ -222,6 +343,7 @@ private LocalLazyInit() { SendMessageRequestMapper.initMapper(); TemplateMessageMapper.initMapper(); WhatsAppInteractiveHeaderMapper.initMapper(); + WhatsAppPaymentButtonMapper.initMapper(); } public static LocalLazyInit init() { diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsService.java deleted file mode 100644 index 2526fea8b..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsService.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.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.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.conversation.api.v1.internal.ConversationApi; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import com.sinch.sdk.domains.conversation.models.v1.conversation.Conversation; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListConversationsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListConversationsResponseInternalImpl; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListRecentConversationsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListRecentConversationsResponseInternalImpl; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest.OrderEnum; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.CreateConversationRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectEventRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationRecentMessage; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListRecentResponse; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListResponse; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.InjectEventResponse; -import com.sinch.sdk.domains.conversation.models.v1.request.MetadataUpdateStrategy; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -public class ConversationsService - implements com.sinch.sdk.domains.conversation.api.v1.ConversationsService { - - private final String uriUUID; - private final ConversationApi api; - - public ConversationsService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new ConversationApi( - httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected ConversationApi getApi() { - return this.api; - } - - public Conversation create(CreateConversationRequest request) { - return getApi().conversationCreateConversation(uriUUID, request); - } - - public Conversation get(String conversationId) { - return getApi().conversationGetConversation(uriUUID, conversationId); - } - - public ConversationsListResponse list(ConversationsListRequest parameters) { - - Boolean onlyActive = parameters.getOnlyActive().orElse(null); - String contactId = parameters.getContactId().orElse(null); - String appId = parameters.getAppId().orElse(null); - - Integer pageSize = parameters.getPageSize().orElse(null); - String pageToken = parameters.getPageToken().orElse(null); - ConversationChannel activeChannel = parameters.getActiveChannel().orElse(null); - - ListConversationsResponseInternal response = - getApi() - .conversationListConversations( - uriUUID, appId, contactId, onlyActive, pageSize, pageToken, activeChannel); - - return mapForPaging(parameters, response); - } - - public ConversationsListRecentResponse listRecent(ConversationsListRecentRequest parameters) { - - Boolean onlyActive = parameters.getOnlyActive().orElse(null); - String appId = parameters.getAppId().orElse(null); - - Integer pageSize = parameters.getPageSize().orElse(null); - String pageToken = parameters.getPageToken().orElse(null); - String order = parameters.getOrder().map(OrderEnum::value).orElse(null); - - ListRecentConversationsResponseInternal response = - getApi() - .conversationListRecentConversations( - uriUUID, appId, onlyActive, pageSize, pageToken, order); - - return mapForPaging(parameters, response); - } - - public void stopActive(String conversationId) { - getApi().conversationStopActiveConversation(uriUUID, conversationId); - } - - public void delete(String conversationId) { - getApi().conversationDeleteConversation(uriUUID, conversationId); - } - - public Conversation update( - String conversationId, MetadataUpdateStrategy updateStrategy, Conversation request) { - return getApi() - .conversationUpdateConversation(uriUUID, conversationId, request, null, updateStrategy); - } - - public void injectMessage(String conversationId, InjectMessageRequest request) { - getApi().conversationInjectMessage(uriUUID, conversationId, request); - } - - public InjectEventResponse injectEvent(String conversationId, InjectEventRequest request) { - return getApi().eventsInjectEvent(uriUUID, conversationId, request); - } - - private ConversationsListResponse mapForPaging( - ConversationsListRequest parameters, ListConversationsResponseInternal _dto) { - - ListConversationsResponseInternalImpl dto = (ListConversationsResponseInternalImpl) _dto; - - String nextPageToken = dto.nextPageToken().orElse(null); - Collection list = dto.conversations().orElse(Collections.emptyList()); - - Pair, TokenPageNavigator> paginated = - new Pair<>(list, new TokenPageNavigator(nextPageToken)); - - return new ConversationsListResponse( - this, new Page<>(parameters, paginated.getLeft(), paginated.getRight())); - } - - private ConversationsListRecentResponse mapForPaging( - ConversationsListRecentRequest parameters, ListRecentConversationsResponseInternal _dto) { - - ListRecentConversationsResponseInternalImpl dto = - (ListRecentConversationsResponseInternalImpl) _dto; - - String nextPageToken = dto.nextPageToken().orElse(null); - Collection list = - dto.conversations().orElse(Collections.emptyList()); - - Pair, TokenPageNavigator> paginated = - new Pair<>(list, new TokenPageNavigator(nextPageToken)); - - return new ConversationsListRecentResponse( - this, new Page<>(parameters, paginated.getLeft(), paginated.getRight())); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsService.java deleted file mode 100644 index f98ee5f40..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsService.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.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.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.conversation.api.v1.internal.EventsApi; -import com.sinch.sdk.domains.conversation.models.v1.events.ConversationEvent; -import com.sinch.sdk.domains.conversation.models.v1.events.internal.ListEventsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.events.internal.ListEventsResponseInternalImpl; -import com.sinch.sdk.domains.conversation.models.v1.events.request.EventsListRequest; -import com.sinch.sdk.domains.conversation.models.v1.events.request.SendEventRequest; -import com.sinch.sdk.domains.conversation.models.v1.events.response.EventsListResponse; -import com.sinch.sdk.domains.conversation.models.v1.events.response.SendEventResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -public class EventsService implements com.sinch.sdk.domains.conversation.api.v1.EventsService { - - private final String uriUUID; - private final EventsApi api; - - public EventsService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new EventsApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected EventsApi getApi() { - return this.api; - } - - public SendEventResponse send(SendEventRequest request) { - return getApi().eventsSendEvent(uriUUID, request); - } - - public ConversationEvent get(String eventId) { - return getApi().eventsGetEvent(uriUUID, eventId); - } - - public void delete(String eventId) { - - getApi().eventsDeleteEvents(uriUUID, eventId); - } - - public EventsListResponse list(EventsListRequest request) { - - String conversationId = request.getConversationId().orElse(null); - String contactId = request.getContactId().orElse(null); - Integer pageSize = request.getPageSize().orElse(null); - String pageToken = request.getPageToken().orElse(null); - - ListEventsResponseInternal response = - getApi().eventsListEvents(uriUUID, conversationId, contactId, pageSize, pageToken); - - return mapForPaging(request, response); - } - - private EventsListResponse mapForPaging( - EventsListRequest parameters, ListEventsResponseInternal _dto) { - - ListEventsResponseInternalImpl dto = (ListEventsResponseInternalImpl) _dto; - - String nextPageToken = dto.nextPageToken().orElse(null); - Collection list = dto.events().orElse(Collections.emptyList()); - - Pair, TokenPageNavigator> paginated = - new Pair<>(list, new TokenPageNavigator(nextPageToken)); - - return new EventsListResponse( - this, new Page<>(parameters, paginated.getLeft(), paginated.getRight())); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesService.java deleted file mode 100644 index 765259a92..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesService.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.ConversationMessageMapper; -import com.sinch.sdk.domains.conversation.api.v1.internal.MessagesApi; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import com.sinch.sdk.domains.conversation.models.v1.internal.ConversationMessageInternal; -import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessageBody; -import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ListMessagesResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ListMessagesResponseInternalImpl; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.ConversationMessagesView; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessageUpdateRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesListRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.SendMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.response.MessagesListResponse; -import com.sinch.sdk.domains.conversation.models.v1.messages.response.SendMessageResponse; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.card.CardMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.carousel.CarouselMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.ChoiceMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.contactinfo.ContactInfoMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.list.ListMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.template.TemplateMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; -import com.sinch.sdk.models.ConversationContext; -import java.time.Instant; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -public class MessagesService implements com.sinch.sdk.domains.conversation.api.v1.MessagesService { - - private final String uriUUID; - private final MessagesApi api; - - public MessagesService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new MessagesApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected MessagesApi getApi() { - return this.api; - } - - public SendMessageResponse sendMessage(SendMessageRequest request) - throws ApiException { - return getApi().messagesSendMessage(uriUUID, request); - } - - public SendMessageResponse sendCardMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendCarouselMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendChoiceMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendContactInfoMessage( - SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendListMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendLocationMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendMediaMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendTemplateMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public SendMessageResponse sendTextMessage(SendMessageRequest request) { - return sendMessage(request); - } - - public ConversationMessage get(String messageId) { - return get(messageId, null); - } - - public ConversationMessage get(String messageId, MessageSource messageSource) { - return ConversationMessageMapper.convert( - getApi() - .messagesGetMessage( - uriUUID, messageId, null == messageSource ? null : messageSource.name())); - } - - public MessagesListResponse list(MessagesListRequest parameters) { - - String conversationId = parameters.getConversationId().orElse(null); - String contactId = parameters.getContactId().orElse(null); - String appId = parameters.getAppId().orElse(null); - String channelIdentity = parameters.getChannelIdentity().orElse(null); - Instant startTime = parameters.getStartTime().orElse(null); - Instant endTime = parameters.getEndTime().orElse(null); - Integer pageSize = parameters.getPageSize().orElse(null); - String pageToken = parameters.getPageToken().orElse(null); - ConversationMessagesView view = parameters.getView().orElse(null); - String messagesSource = parameters.getMessagesSource().map(Enum::name).orElse(null); - Boolean onlyRecipientOriginated = parameters.getOnlyRecipientOriginated().orElse(null); - ConversationChannel channel = parameters.getChannel().orElse(null); - - ListMessagesResponseInternal response = - getApi() - .messagesListMessages( - uriUUID, - conversationId, - contactId, - appId, - channelIdentity, - startTime, - endTime, - pageSize, - pageToken, - view, - messagesSource, - onlyRecipientOriginated, - channel); - - return mapForPaging(parameters, response); - } - - public void delete(String messageId) { - delete(messageId, null); - } - - public void delete(String messageId, MessageSource messageSource) { - getApi() - .messagesDeleteMessage( - uriUUID, messageId, null == messageSource ? null : messageSource.name()); - } - - public ConversationMessage update(String messageId, MessageUpdateRequest parameters) { - return update(messageId, null, parameters); - } - - public ConversationMessage update( - String messageId, MessageSource _messageSource, MessageUpdateRequest parameters) { - - String messageSource = null == _messageSource ? null : _messageSource.name(); - - ConversationMessageInternal response = - getApi().messagesUpdateMessageMetadata(uriUUID, messageId, parameters, messageSource); - - return ConversationMessageMapper.convert(response); - } - - private MessagesListResponse mapForPaging( - MessagesListRequest parameters, ListMessagesResponseInternal _dto) { - - ListMessagesResponseInternalImpl dto = (ListMessagesResponseInternalImpl) _dto; - - String nextPageToken = dto.nextPageToken().orElse(null); - Collection list = dto.messages().orElse(Collections.emptyList()); - - Pair, TokenPageNavigator> paginated = - new Pair<>(list, new TokenPageNavigator(nextPageToken)); - - return new MessagesListResponse( - this, new Page<>(parameters, paginated.getLeft(), paginated.getRight())); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsService.java new file mode 100644 index 000000000..c7e5121d2 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsService.java @@ -0,0 +1,37 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.auth.HmacAuthenticationValidation; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.ConversationSinchEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.internal.ConversationSinchEventInternalImpl; +import java.util.Map; + +public class SinchEventsService + implements com.sinch.sdk.domains.conversation.api.v1.SinchEventsService { + + private final HmacAuthenticationValidation authenticationChecker; + + public SinchEventsService(HmacAuthenticationValidation authenticationChecker) { + this.authenticationChecker = authenticationChecker; + } + + @Override + public boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload) { + + return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); + } + + @Override + public ConversationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException { + try { + ConversationSinchEventInternalImpl dto = + Mapper.getInstance().readValue(jsonPayload, ConversationSinchEventInternalImpl.class); + return (ConversationSinchEvent) dto.getActualInstance(); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingService.java deleted file mode 100644 index 171b430aa..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.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.conversation.api.v1.internal.TranscodingApi; -import com.sinch.sdk.domains.conversation.models.v1.transcoding.request.TranscodeMessageRequest; -import com.sinch.sdk.domains.conversation.models.v1.transcoding.response.TranscodeMessageResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Map; - -public class TranscodingService - implements com.sinch.sdk.domains.conversation.api.v1.TranscodingService { - - private final String uriUUID; - private final TranscodingApi api; - - public TranscodingService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new TranscodingApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected TranscodingApi getApi() { - return this.api; - } - - public TranscodeMessageResponse transcodeMessage(TranscodeMessageRequest request) { - return getApi().transcodingTranscodeMessage(uriUUID, request); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorService.java deleted file mode 100644 index 4b91094cd..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorService.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.sinch.sdk.auth.HmacAuthenticationValidation; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.ConversationWebhookEvent; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Map; -import java.util.function.Supplier; - -public class WebHooksAdaptorService - implements com.sinch.sdk.domains.conversation.api.v1.WebHooksService { - - private final Runnable instanceLazyInit; - private final Supplier> authManagersSupplier; - private final String uriUUID; - private final ConversationContext context; - private final Supplier httpClientSupplier; - private volatile WebHooksApiService apiService; - private volatile WebHooksCallbackService callbackService; - - public WebHooksAdaptorService( - String uriUUID, - ConversationContext context, - Runnable instanceLazyInit, - Supplier httpClientSupplier, - Supplier> authManagersSupplier) { - this.uriUUID = uriUUID; - this.context = context; - this.instanceLazyInit = instanceLazyInit; - this.httpClientSupplier = httpClientSupplier; - this.authManagersSupplier = authManagersSupplier; - } - - public Collection list(String appId) { - return activateApiService().list(appId); - } - - public Webhook get(String webhookId) { - return activateApiService().get(webhookId); - } - - public Webhook create(Webhook _webhook) { - return activateApiService().create(_webhook); - } - - public Webhook update(String webhookId, Webhook _webhook) { - return activateApiService().update(webhookId, _webhook); - } - - public void delete(String webhookId) { - activateApiService().delete(webhookId); - } - - WebHooksApiService activateApiService() { - - if (null == this.apiService) { - instanceLazyInit.run(); - this.apiService = - new WebHooksApiService( - uriUUID, context, httpClientSupplier.get(), authManagersSupplier.get()); - } - return getApiService(); - } - - protected WebHooksApiService getApiService() { - return this.apiService; - } - - WebHooksCallbackService activateCallbackApiService() { - - if (null == this.callbackService) { - this.callbackService = new WebHooksCallbackService(new HmacAuthenticationValidation()); - } - return callbackService; - } - - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - return activateCallbackApiService().validateAuthenticationHeader(secret, headers, jsonPayload); - } - - @Override - public ConversationWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException { - return activateCallbackApiService().parseEvent(jsonPayload); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiService.java deleted file mode 100644 index 00fa3264e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiService.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -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.conversation.api.v1.internal.WebhooksApi; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.WebhookImpl; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.ConversationWebhookEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.internal.CreateWebhookRequestInternal; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.response.ListWebhooksResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -public class WebHooksApiService - implements com.sinch.sdk.domains.conversation.api.v1.WebHooksService { - - private final String uriUUID; - private final WebhooksApi api; - - public WebHooksApiService( - String uriUUID, - ConversationContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new WebhooksApi(httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - - protected WebhooksApi getApi() { - return this.api; - } - - public Collection list(String appId) { - - ListWebhooksResponse response = getApi().webhooksListWebhooks(uriUUID, appId); - - if (null == response) { - return Collections.emptyList(); - } - return response.getWebhooks(); - } - - public Webhook get(String webhookId) { - return getApi().webhooksGetWebhook(uriUUID, webhookId); - } - - public Webhook create(Webhook _webhook) { - - WebhookImpl webhook = (WebhookImpl) _webhook; - CreateWebhookRequestInternal.Builder builder = CreateWebhookRequestInternal.builder(); - - webhook.appId().ifPresent(builder::setAppId); - webhook.clientCredentials().ifPresent(builder::setClientCredentials); - webhook.secret().ifPresent(builder::setSecret); - webhook.target().ifPresent(builder::setTarget); - webhook.targetType().ifPresent(builder::setTargetType); - webhook.triggers().ifPresent(builder::setTriggers); - - return getApi().webhooksCreateWebhook(uriUUID, builder.build()); - } - - public Webhook update(String webhookId, Webhook _webhook) { - - List mask = new ArrayList<>(); - - WebhookImpl webhook = (WebhookImpl) _webhook; - webhook.appId().ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_APP_ID)); - webhook - .clientCredentials() - .ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_CLIENT_CREDENTIALS)); - webhook.target().ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_TARGET)); - webhook.targetType().ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_TARGET_TYPE)); - webhook.triggers().ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_TRIGGERS)); - webhook.secret().ifPresent(_unused -> mask.add(WebhookImpl.JSON_PROPERTY_SECRET)); - - return getApi().webhooksUpdateWebhook(uriUUID, webhookId, _webhook, mask); - } - - public void delete(String webhookId) { - getApi().webhooksDeleteWebhook(uriUUID, webhookId); - } - - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - throw new UnsupportedOperationException(); - } - - @Override - public ConversationWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException { - throw new UnsupportedOperationException(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackService.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackService.java deleted file mode 100644 index 147a65a2f..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.auth.HmacAuthenticationValidation; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.ConversationWebhookEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.internal.ConversationEventInternalImpl; -import java.util.Collection; -import java.util.Map; - -public class WebHooksCallbackService - implements com.sinch.sdk.domains.conversation.api.v1.WebHooksService { - - private final HmacAuthenticationValidation authenticationChecker; - - public WebHooksCallbackService(HmacAuthenticationValidation authenticationChecker) { - this.authenticationChecker = authenticationChecker; - } - - public Collection list(String appId) { - throw new UnsupportedOperationException(); - } - - public Webhook get(String webhookId) { - throw new UnsupportedOperationException(); - } - - public Webhook create(Webhook _webhook) { - throw new UnsupportedOperationException(); - } - - public Webhook update(String webhookId, Webhook _webhook) { - throw new UnsupportedOperationException(); - } - - public void delete(String webhookId) { - throw new UnsupportedOperationException(); - } - - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - - return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); - } - - @Override - public ConversationWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException { - try { - ConversationEventInternalImpl dto = - Mapper.getInstance().readValue(jsonPayload, ConversationEventInternalImpl.class); - return (ConversationWebhookEvent) dto.getActualInstance(); - } catch (JsonProcessingException e) { - throw new ApiMappingException(jsonPayload, e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/buttons/KakaoTalkButtonMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/buttons/KakaoTalkButtonMapper.java new file mode 100644 index 000000000..fb97549fd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/buttons/KakaoTalkButtonMapper.java @@ -0,0 +1,39 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.buttons; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.buttons.KakaoTalkButton; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.buttons.internal.KakaoTalkButtonInternalImpl; +import java.io.IOException; + +public class KakaoTalkButtonMapper { + + public static void initMapper() { + Mapper.getInstance() + .registerModule( + new SimpleModule().addDeserializer(KakaoTalkButton.class, new Deserializer())); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public KakaoTalkButton deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + KakaoTalkButtonInternalImpl deserialized = jp.readValueAs(KakaoTalkButtonInternalImpl.class); + + return (KakaoTalkButton) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/commerce/KakaoTalkCommerceMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/commerce/KakaoTalkCommerceMapper.java new file mode 100644 index 000000000..e4e322ddb --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/commerce/KakaoTalkCommerceMapper.java @@ -0,0 +1,40 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.commerce; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.commerce.KakaoTalkCommerce; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.commerce.internal.KakaoTalkCommerceMessageCommerceImpl; +import java.io.IOException; + +public class KakaoTalkCommerceMapper { + + public static void initMapper() { + Mapper.getInstance() + .registerModule( + new SimpleModule().addDeserializer(KakaoTalkCommerce.class, new Deserializer())); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public KakaoTalkCommerce deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + KakaoTalkCommerceMessageCommerceImpl deserialized = + jp.readValueAs(KakaoTalkCommerceMessageCommerceImpl.class); + + return (KakaoTalkCommerce) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/coupons/KakaoTalkCouponMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/coupons/KakaoTalkCouponMapper.java new file mode 100644 index 000000000..7b544cf22 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/api/v1/adapters/messages/type/channelspecific/kakaotalk/coupons/KakaoTalkCouponMapper.java @@ -0,0 +1,39 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters.messages.type.channelspecific.kakaotalk.coupons; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.coupons.KakaoTalkCoupon; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.coupons.internal.KakaoTalkCouponInternalImpl; +import java.io.IOException; + +public class KakaoTalkCouponMapper { + + public static void initMapper() { + Mapper.getInstance() + .registerModule( + new SimpleModule().addDeserializer(KakaoTalkCoupon.class, new Deserializer())); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public KakaoTalkCoupon deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + KakaoTalkCouponInternalImpl deserialized = jp.readValueAs(KakaoTalkCouponInternalImpl.class); + + return (KakaoTalkCoupon) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/package-info.java deleted file mode 100644 index 5a9a103b0..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/package-info.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Conversation models for App - * - *

Apps are created and configured through the Sinch Dashboard, are tied to the API user and come - * with a set of channel credentials for each underlying connected channel. - * - *

The app has a list of conversations between itself and different contacts which - * share the same project. - * - * @see App - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.app; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/request/package-info.java deleted file mode 100644 index 3a6674316..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/request/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * App request models - * - * @see App - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.app.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/response/package-info.java deleted file mode 100644 index 0dde08579..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/app/response/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * App response models - * - * @see App - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.app.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/package-info.java new file mode 100644 index 000000000..c2c807376 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/package-info.java @@ -0,0 +1,14 @@ +/** + * Conversation models for Apps + * + *

Apps are created and configured through the Sinch Dashboard, are tied to the API user and come + * with a set of channel credentials for each underlying connected channel. + * + *

The app has a list of conversations between itself and different contacts which + * share the same project. + * + * @see App + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.apps; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/request/package-info.java new file mode 100644 index 000000000..506f51dbd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/request/package-info.java @@ -0,0 +1,8 @@ +/** + * App request models + * + * @see App + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.apps.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/response/package-info.java new file mode 100644 index 000000000..23cde4ed5 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/apps/response/package-info.java @@ -0,0 +1,8 @@ +/** + * App response models + * + * @see App + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.apps.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/package-info.java deleted file mode 100644 index db4b02355..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/package-info.java +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Conversation models for Contact - * - *

A contact is a collection that groups together underlying connected channel recipient - * identities. It's tied to a specific project and is therefore considered public to all - * apps sharing the same project. - * - *

Most contact creation and maintenance is handled by the Conversation API's automatic contact - * management processes. However, you can also use API calls to manually manage your contacts. - * - * @see Capability - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.contact; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactListRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactListRequest.java deleted file mode 100644 index 8db817647..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactListRequest.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.contact.request; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; - -public class ContactListRequest { - - private final OptionalValue externalId; - private final OptionalValue channel; - private final OptionalValue identity; - private final OptionalValue pageSize; - private final OptionalValue pageToken; - - private ContactListRequest( - OptionalValue externalId, - OptionalValue channel, - OptionalValue identity, - OptionalValue pageSize, - OptionalValue pageToken) { - this.externalId = externalId; - this.channel = channel; - this.identity = identity; - this.pageSize = pageSize; - this.pageToken = pageToken; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(ContactListRequest parameters) { - return new Builder(parameters); - } - - public OptionalValue getExternalId() { - return externalId; - } - - public OptionalValue getChannel() { - return channel; - } - - public OptionalValue getIdentity() { - return identity; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public OptionalValue getPageToken() { - return pageToken; - } - - public static class Builder { - - OptionalValue externalId = OptionalValue.empty(); - OptionalValue channel = OptionalValue.empty(); - OptionalValue identity = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - OptionalValue pageToken = OptionalValue.empty(); - - private Builder() {} - - private Builder(ContactListRequest parameters) { - if (null == parameters) { - return; - } - parameters.externalId.ifPresent(this::setExternalId); - parameters.channel.ifPresent(this::setChannel); - parameters.identity.ifPresent(this::setIdentity); - parameters.pageSize.ifPresent(this::setPageSize); - parameters.pageToken.ifPresent(this::setPageToken); - } - - public Builder setExternalId(String externalId) { - this.externalId = OptionalValue.of(externalId); - return this; - } - - public Builder setChannel(ConversationChannel channel) { - this.channel = OptionalValue.of(channel); - return this; - } - - public Builder setIdentity(String identity) { - this.identity = OptionalValue.of(identity); - return this; - } - - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - public Builder setPageToken(String pageToken) { - this.pageToken = OptionalValue.of(pageToken); - return this; - } - - public ContactListRequest build() { - return new ContactListRequest(externalId, channel, identity, pageSize, pageToken); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/package-info.java deleted file mode 100644 index 946c22ed6..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Contact request models - * - * @see Contact - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.contact.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/ContactListResponse.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/ContactListResponse.java deleted file mode 100644 index 9cfc82674..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/ContactListResponse.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.contact.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.v1.ContactService; -import com.sinch.sdk.domains.conversation.models.v1.contact.Contact; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactListRequest; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all contacts - * - * @since 1.0 - */ -public class ContactListResponse extends ListResponse { - - private final Page page; - private final ContactService service; - - /** - * Create paginated list response for Contacts - * - * @param service Service to be used to paginate across responses - * @param page Page content - */ - public ContactListResponse( - ContactService service, Page page) { - this.service = service; - this.page = page; - } - - /** {@inheritDoc} */ - @Override - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - /** {@inheritDoc} */ - @Override - public ContactListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - ContactListRequest.Builder newParameters = ContactListRequest.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - /** {@inheritDoc} */ - @Override - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "ContactListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/package-info.java deleted file mode 100644 index 93b851c49..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/response/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Contact response models - * - * @see Contact - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.contact.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/package-info.java new file mode 100644 index 000000000..45ab94c66 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/package-info.java @@ -0,0 +1,15 @@ +/** + * Conversation models for Contact + * + *

A contact is a collection that groups together underlying connected channel recipient + * identities. It's tied to a specific project and is therefore considered public to all + * apps sharing the same project. + * + *

Most contact creation and maintenance is handled by the Conversation API's automatic contact + * management processes. However, you can also use API calls to manually manage your contacts. + * + * @see Contacts + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.contacts; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByChannelIdentityRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByChannelIdentityRequest.java similarity index 95% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByChannelIdentityRequest.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByChannelIdentityRequest.java index 20b7aaf8e..f5a4d881b 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByChannelIdentityRequest.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByChannelIdentityRequest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.contact.request; +package com.sinch.sdk.domains.conversation.models.v1.contacts.request; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.conversation.models.v1.ChannelRecipientIdentities; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByContactIdRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByContactIdRequest.java similarity index 94% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByContactIdRequest.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByContactIdRequest.java index 99c516db7..d1fa9a418 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contact/request/ContactGetChannelProfileByContactIdRequest.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/ContactGetChannelProfileByContactIdRequest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.contact.request; +package com.sinch.sdk.domains.conversation.models.v1.contacts.request; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.conversation.models.v1.ContactId; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/package-info.java new file mode 100644 index 000000000..2d3636b78 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/request/package-info.java @@ -0,0 +1,8 @@ +/** + * Contact request models + * + * @see Contact + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.contacts.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/response/package-info.java new file mode 100644 index 000000000..cebc3a0c4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/contacts/response/package-info.java @@ -0,0 +1,8 @@ +/** + * Contact response models + * + * @see Contact + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.contacts.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/package-info.java deleted file mode 100644 index 980f5494f..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Conversation models for Conversation - * - *

APIS for working with the conversation log. - * - * @see Conversation - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.conversation; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/package-info.java deleted file mode 100644 index 29469b48b..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation request models - * - * @see Conversation - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListRecentResponse.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListRecentResponse.java deleted file mode 100644 index 308b4ce6d..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListRecentResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.v1.ConversationsService; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Recent messages and conversation response - * - * @since 1.3 - */ -public class ConversationsListRecentResponse extends ListResponse { - - private final Page page; - private final ConversationsService service; - - public ConversationsListRecentResponse( - ConversationsService service, - Page page) { - this.service = service; - this.page = page; - } - - @Override - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - @Override - public ConversationsListRecentResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - ConversationsListRecentRequest.Builder newParameters = - ConversationsListRecentRequest.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.listRecent(newParameters.build()); - } - - @Override - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "ConversationsListRecentResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListResponse.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListResponse.java deleted file mode 100644 index ad605ceed..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/ConversationsListResponse.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.v1.ConversationsService; -import com.sinch.sdk.domains.conversation.models.v1.conversation.Conversation; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRequest; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all conversations response - * - * @since 1.3 - */ -public class ConversationsListResponse extends ListResponse { - - private final Page page; - private final ConversationsService service; - - public ConversationsListResponse( - ConversationsService service, Page page) { - this.service = service; - this.page = page; - } - - @Override - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - @Override - public ConversationsListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - ConversationsListRequest.Builder newParameters = - ConversationsListRequest.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - @Override - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "ConversationsListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/package-info.java deleted file mode 100644 index d98c352f6..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/response/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation response models - * - * @see Conversation - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.conversation.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/package-info.java new file mode 100644 index 000000000..a6c7b0475 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/package-info.java @@ -0,0 +1,10 @@ +/** + * Conversation models for Conversation + * + *

APIS for working with the conversation log. + * + * @see Conversation + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.conversations; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequest.java similarity index 99% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequest.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequest.java index db1f1f60b..161728a7a 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequest.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import com.sinch.sdk.core.utils.EnumDynamic; import com.sinch.sdk.core.utils.EnumSupportDynamic; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequestImpl.java similarity index 99% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequestImpl.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequestImpl.java index 8d7c9169d..5f12d7e46 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRecentRequestImpl.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRecentRequestImpl.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import java.util.Optional; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequest.java similarity index 99% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequest.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequest.java index cbb3d957a..8722c75e5 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequest.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; import java.util.Optional; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequestImpl.java similarity index 99% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequestImpl.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequestImpl.java index 847e90b9a..54c0ef248 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/ConversationsListRequestImpl.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/ConversationsListRequestImpl.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; import java.util.Optional; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequest.java similarity index 98% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequest.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequest.java index 6e3f867e4..52febc8d8 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequest.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequest.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessageBody; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequestImpl.java similarity index 95% rename from client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequestImpl.java rename to client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequestImpl.java index 8827146a5..17e326180 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversation/request/InjectMessageRequestImpl.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/InjectMessageRequestImpl.java @@ -1,11 +1,10 @@ -package com.sinch.sdk.domains.conversation.models.v1.conversation.request; +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; import com.fasterxml.jackson.annotation.JsonIgnore; import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.conversation.models.v1.ChannelIdentity; import com.sinch.sdk.domains.conversation.models.v1.ConversationDirection; import com.sinch.sdk.domains.conversation.models.v1.ProcessingMode; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectMessageRequestBaseImpl.Builder; import com.sinch.sdk.domains.conversation.models.v1.messages.AppMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.ContactMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessageBody; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/package-info.java new file mode 100644 index 000000000..cc066a32c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/request/package-info.java @@ -0,0 +1,8 @@ +/** + * Conversation request models + * + * @see Conversation + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.conversations.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/response/package-info.java new file mode 100644 index 000000000..6957cacc8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/conversations/response/package-info.java @@ -0,0 +1,8 @@ +/** + * Conversation response models + * + * @see Conversation + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.conversations.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactory.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactory.java index 062bf8423..625f0fca5 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactory.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactory.java @@ -150,20 +150,6 @@ public static ConversationChannelCredentials.Builder telegram(TelegramCredential .setCredentials(credentials); } - /** - * Create dedicated conversation credential builder for{@link ConversationChannel#VIBER} - * channel - * - * @param credentials Credentials parameters to be used to init builder - * @return Conversation channel credentials builder filled with input parameters - * @since 1.3 - */ - public static ConversationChannelCredentials.Builder viber(StaticTokenCredentials credentials) { - return ConversationChannelCredentials.builder() - .setChannel(ConversationChannel.VIBER) - .setCredentials(credentials); - } - /** * Create dedicated conversation credential builder for{@link ConversationChannel#VIBERBM} * channel diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/package-info.java new file mode 100644 index 000000000..570dd2799 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/package-info.java @@ -0,0 +1,8 @@ +/** + * Conversation models for Event Destinations + * + * @see Webhooks + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.eventdestinations; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/request/package-info.java new file mode 100644 index 000000000..1ebd0676d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/request/package-info.java @@ -0,0 +1,8 @@ +/** + * Event Destinations request models + * + * @see Webhooks + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.eventdestinations.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/response/package-info.java new file mode 100644 index 000000000..275464d4f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/eventdestinations/response/package-info.java @@ -0,0 +1,8 @@ +/** + * Event Destinations response models + * + * @see Webhooks + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.eventdestinations.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequest.java deleted file mode 100644 index 473a4197e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.events.request; - -import java.util.Optional; - -/** - * Parameters request to list events - * - * @see online - * documentation - * @since 1.3 - */ -public interface EventsListRequest { - - /** - * Resource name (ID) of the conversation. - * - * @return conversation id - */ - Optional getConversationId(); - - /** - * Resource name (ID) of the contact. - * - *

Note that either app_id or contact_id is required in order for the - * operation to function correctly. - * - * @return contact id - */ - Optional getContactId(); - - /** - * Maximum number of events to fetch. - * - *

Defaults to 10 and the maximum is 20. - * - * @default 10 - * @return Page size - */ - Optional getPageSize(); - - /** - * Next page token previously returned if any. - * - *

When specifying this token, make sure to use the same values for the other parameters from - * the request that originated the token, otherwise the paged results may be inconsistent. - * - * @return Page token - */ - Optional getPageToken(); - - static Builder builder() { - return new EventsListRequestImpl.Builder(); - } - - static Builder builder(EventsListRequest parameters) { - return new EventsListRequestImpl.Builder(parameters); - } - - /** Dedicated Builder */ - interface Builder { - - /** - * see getter - * - * @param conversationId see getter - * @return Current builder - * @see #getConversationId() - */ - Builder setConversationId(String conversationId); - - /** - * see getter - * - * @param contactId see getter - * @return Current builder - * @see #getContactId() - */ - Builder setContactId(String contactId); - - /** - * see getter - * - * @param pageSize see getter - * @return Current builder - * @see #getPageSize() - */ - Builder setPageSize(Integer pageSize); - - /** - * see getter - * - * @param pageToken see getter - * @return Current builder - * @see #getPageToken() - */ - Builder setPageToken(String pageToken); - - EventsListRequest build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequestImpl.java deleted file mode 100644 index 2fd41fd3f..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/request/EventsListRequestImpl.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.events.request; - -import java.util.Optional; - -public class EventsListRequestImpl implements EventsListRequest { - - final String conversationId; - final String contactId; - final Integer pageSize; - final String pageToken; - - public EventsListRequestImpl( - String conversationId, String contactId, Integer pageSize, String pageToken) { - this.conversationId = conversationId; - this.contactId = contactId; - this.pageSize = pageSize; - this.pageToken = pageToken; - } - - @Override - public Optional getConversationId() { - return Optional.ofNullable(conversationId); - } - - @Override - public Optional getContactId() { - return Optional.ofNullable(contactId); - } - - @Override - public Optional getPageSize() { - return Optional.ofNullable(pageSize); - } - - @Override - public Optional getPageToken() { - return Optional.ofNullable(pageToken); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(EventsListRequest parameters) { - return new Builder(parameters); - } - - public static class Builder implements EventsListRequest.Builder { - - String conversationId; - String contactId; - Integer pageSize; - String pageToken; - - Builder() {} - - Builder(EventsListRequest parameters) { - - parameters.getConversationId().ifPresent(this::setConversationId); - parameters.getContactId().ifPresent(this::setContactId); - parameters.getPageSize().ifPresent(this::setPageSize); - parameters.getPageToken().ifPresent(this::setPageToken); - } - - @Override - public Builder setConversationId(String conversationId) { - this.conversationId = conversationId; - return this; - } - - @Override - public Builder setContactId(String contactId) { - this.contactId = contactId; - return this; - } - - @Override - public Builder setPageSize(Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - @Override - public Builder setPageToken(String pageToken) { - this.pageToken = pageToken; - return this; - } - - public EventsListRequest build() { - return new EventsListRequestImpl(conversationId, contactId, pageSize, pageToken); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/response/EventsListResponse.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/response/EventsListResponse.java deleted file mode 100644 index 6b3c22971..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/events/response/EventsListResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.events.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.v1.EventsService; -import com.sinch.sdk.domains.conversation.models.v1.events.ConversationEvent; -import com.sinch.sdk.domains.conversation.models.v1.events.request.EventsListRequest; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all messages response - * - * @since 1.3 - */ -public class EventsListResponse extends ListResponse { - - private final Page page; - private final EventsService service; - - public EventsListResponse( - EventsService service, Page page) { - this.service = service; - this.page = page; - } - - @Override - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - @Override - public EventsListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - EventsListRequest.Builder newParameters = EventsListRequest.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - @Override - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "EventsListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/package-info.java index 9fe9cd431..5177b4a0c 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/package-info.java @@ -3,8 +3,8 @@ * *

To start sending messages you must have a Conversation API app. * - *

The app holds information about the channel credentials and registered webhooks to which the - * API delivers callbacks such as message delivery receipts and contact messages. + *

The app holds information about the channel credentials and registered event destinations to + * which the API delivers callbacks such as message delivery receipts and contact messages. * *

If you don't already have an app please follow the instructions in the getting started guide * available in the Sinch Dashboard to create one.* diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequest.java deleted file mode 100644 index d51ebf2a9..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequest.java +++ /dev/null @@ -1,239 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.request; - -import com.sinch.sdk.domains.conversation.api.v1.MessagesService.MessageSource; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import java.time.Instant; -import java.util.Optional; - -/** - * Parameters request to list messages - * - * @see online - * documentation - * @since 1.3 - */ -public interface MessagesListRequest { - - /** - * Resource name (ID) of the conversation. - * - * @return conversation id - */ - Optional getConversationId(); - - /** - * Resource name (ID) of the contact. - * - *

Note that either app_id or contact_id is required in order for the - * operation to function correctly. - * - * @return contact id - */ - Optional getContactId(); - - /** - * Id of the application. - * - *

Note that either app_id or contact_id is required in order for the - * operation to function correctly. - * - * @return application id - */ - Optional getAppId(); - - /** - * Channel identity of the contact. - * - * @return Channel identity - */ - Optional getChannelIdentity(); - - /** - * Filter messages with accept_time after this timestamp. - * - *

Must be before end_time if that is specified. - * - * @return Start time - */ - Optional getStartTime(); - - /** - * Filter messages with accept_time before this timestamp. - * - * @return End time - */ - Optional getEndTime(); - - /** - * Maximum number of messages to fetch. - * - *

Defaults to 10 and the maximum is 1000. - * - * @default 10 - * @return Page size - */ - Optional getPageSize(); - - /** - * Next page token previously returned if any. - * - *

When specifying this token, make sure to use the same values for the other parameters from - * the request that originated the token, otherwise the paged results may be inconsistent. - * - * @return Page token - */ - Optional getPageToken(); - - /** - * @return view - */ - Optional getView(); - - /** - * Specifies the message source for which the request will be processed. Used for operations on - * messages in Dispatch Mode. For more information, see Processing Modes - * - * @default CONVERSATION_SOURCE - * @return Messages sources - */ - Optional getMessagesSource(); - - /** - * If true, fetch only recipient originated messages. Available only when messages_source - * is DISPATCH_SOURCE. - * - * @return only recipient originated value - */ - Optional getOnlyRecipientOriginated(); - - /** - * Only fetch messages from the channel - * - * @return Channel to filtered on - */ - Optional getChannel(); - - static Builder builder() { - return new MessagesListRequestImpl.Builder(); - } - - static Builder builder(MessagesListRequest parameters) { - return new MessagesListRequestImpl.Builder(parameters); - } - - /** Dedicated Builder */ - interface Builder { - - /** - * see getter - * - * @param conversationId see getter - * @return Current builder - * @see #getConversationId() - */ - Builder setConversationId(String conversationId); - - /** - * see getter - * - * @param contactId see getter - * @return Current builder - * @see #getContactId() - */ - Builder setContactId(String contactId); - - /** - * see getter - * - * @param appId see getter - * @return Current builder - * @see #getAppId() - */ - Builder setAppId(String appId); - - /** - * see getter - * - * @param channelIdentity see getter - * @return Current builder - * @see #getChannelIdentity() - */ - Builder setChannelIdentity(String channelIdentity); - - /** - * see getter - * - * @param startTime see getter - * @return Current builder - * @see #setStartTime - */ - Builder setStartTime(Instant startTime); - - /** - * see getter - * - * @param endTime see getter - * @return Current builder - * @see #getEndTime() - */ - Builder setEndTime(Instant endTime); - - /** - * see getter - * - * @param pageSize see getter - * @return Current builder - * @see #getPageSize() - */ - Builder setPageSize(Integer pageSize); - - /** - * see getter - * - * @param pageToken see getter - * @return Current builder - * @see #getPageToken() - */ - Builder setPageToken(String pageToken); - - /** - * see getter - * - * @param view see getter - * @return Current builder - * @see #getView() - */ - Builder setView(ConversationMessagesView view); - - /** - * see getter - * - * @param source see getter - * @return Current builder - * @see #getMessagesSource() - */ - Builder setMessagesSource(MessageSource source); - - /** - * see getter - * - * @param onlyRecipientOriginated see getter - * @return Current builder - * @see #getOnlyRecipientOriginated() - */ - Builder setOnlyRecipientOriginated(Boolean onlyRecipientOriginated); - - /** - * see getter - * - * @param channel see getter - * @return Current builder - * @see #getChannel() - */ - Builder setChannel(ConversationChannel channel); - - MessagesListRequest build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequestImpl.java deleted file mode 100644 index b78d19fcb..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/request/MessagesListRequestImpl.java +++ /dev/null @@ -1,239 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.request; - -import com.sinch.sdk.domains.conversation.api.v1.MessagesService.MessageSource; -import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import java.time.Instant; -import java.util.Optional; - -public class MessagesListRequestImpl implements MessagesListRequest { - - final String conversationId; - final String contactId; - final String appId; - final String channelIdentity; - final Instant startTime; - final Instant endTime; - final Integer pageSize; - final String pageToken; - final ConversationMessagesView view; - final MessageSource messagesSource; - final Boolean onlyRecipientOriginated; - final ConversationChannel channel; - - public MessagesListRequestImpl( - String conversationId, - String contactId, - String appId, - String channelIdentity, - Instant startTime, - Instant endTime, - Integer pageSize, - String pageToken, - ConversationMessagesView view, - MessageSource messagesSource, - Boolean onlyRecipientOriginated, - ConversationChannel channel) { - this.conversationId = conversationId; - this.contactId = contactId; - this.appId = appId; - this.channelIdentity = channelIdentity; - this.startTime = startTime; - this.endTime = endTime; - this.pageSize = pageSize; - this.pageToken = pageToken; - this.view = view; - this.messagesSource = messagesSource; - this.onlyRecipientOriginated = onlyRecipientOriginated; - this.channel = channel; - } - - @Override - public Optional getConversationId() { - return Optional.ofNullable(conversationId); - } - - @Override - public Optional getContactId() { - return Optional.ofNullable(contactId); - } - - @Override - public Optional getAppId() { - return Optional.ofNullable(appId); - } - - @Override - public Optional getChannelIdentity() { - return Optional.ofNullable(channelIdentity); - } - - @Override - public Optional getStartTime() { - return Optional.ofNullable(startTime); - } - - @Override - public Optional getEndTime() { - return Optional.ofNullable(endTime); - } - - @Override - public Optional getPageSize() { - return Optional.ofNullable(pageSize); - } - - @Override - public Optional getPageToken() { - return Optional.ofNullable(pageToken); - } - - @Override - public Optional getView() { - return Optional.ofNullable(view); - } - - @Override - public Optional getMessagesSource() { - return Optional.ofNullable(messagesSource); - } - - @Override - public Optional getOnlyRecipientOriginated() { - return Optional.ofNullable(onlyRecipientOriginated); - } - - @Override - public Optional getChannel() { - return Optional.ofNullable(channel); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(MessagesListRequest parameters) { - return new Builder(parameters); - } - - public static class Builder implements MessagesListRequest.Builder { - - String conversationId; - String contactId; - String appId; - String channelIdentity; - Instant startTime; - Instant endTime; - Integer pageSize; - String pageToken; - ConversationMessagesView view; - MessageSource messagesSource; - Boolean onlyRecipientOriginated; - ConversationChannel channel; - - Builder() {} - - Builder(MessagesListRequest parameters) { - - parameters.getConversationId().ifPresent(this::setConversationId); - parameters.getContactId().ifPresent(this::setContactId); - parameters.getAppId().ifPresent(this::setAppId); - parameters.getChannelIdentity().ifPresent(this::setChannelIdentity); - parameters.getStartTime().ifPresent(this::setStartTime); - parameters.getEndTime().ifPresent(this::setEndTime); - parameters.getPageSize().ifPresent(this::setPageSize); - parameters.getPageToken().ifPresent(this::setPageToken); - parameters.getView().ifPresent(this::setView); - parameters.getMessagesSource().ifPresent(this::setMessagesSource); - parameters.getOnlyRecipientOriginated().ifPresent(this::setOnlyRecipientOriginated); - parameters.getChannel().ifPresent(this::setChannel); - } - - @Override - public Builder setConversationId(String conversationId) { - this.conversationId = conversationId; - return this; - } - - @Override - public Builder setContactId(String contactId) { - this.contactId = contactId; - return this; - } - - @Override - public Builder setAppId(String appId) { - this.appId = appId; - return this; - } - - @Override - public Builder setChannelIdentity(String channelIdentity) { - this.channelIdentity = channelIdentity; - return this; - } - - @Override - public Builder setStartTime(Instant startTime) { - this.startTime = startTime; - return this; - } - - @Override - public Builder setEndTime(Instant endTime) { - this.endTime = endTime; - return this; - } - - @Override - public Builder setPageSize(Integer pageSize) { - this.pageSize = pageSize; - return this; - } - - @Override - public Builder setPageToken(String pageToken) { - this.pageToken = pageToken; - return this; - } - - @Override - public Builder setView(ConversationMessagesView view) { - this.view = view; - return this; - } - - @Override - public Builder setMessagesSource(MessageSource messagesSource) { - this.messagesSource = messagesSource; - return this; - } - - @Override - public Builder setOnlyRecipientOriginated(Boolean onlyRecipientOriginated) { - this.onlyRecipientOriginated = onlyRecipientOriginated; - return this; - } - - @Override - public Builder setChannel(ConversationChannel channel) { - this.channel = channel; - return this; - } - - public MessagesListRequest build() { - return new MessagesListRequestImpl( - conversationId, - contactId, - appId, - channelIdentity, - startTime, - endTime, - pageSize, - pageToken, - view, - messagesSource, - onlyRecipientOriginated, - channel); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/response/MessagesListResponse.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/response/MessagesListResponse.java deleted file mode 100644 index 81cc23452..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/response/MessagesListResponse.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.conversation.api.v1.MessagesService; -import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesListRequest; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all messages response - * - * @since 1.3 - */ -public class MessagesListResponse extends ListResponse { - - private final Page page; - private final MessagesService service; - - public MessagesListResponse( - MessagesService service, Page page) { - this.service = service; - this.page = page; - } - - @Override - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - @Override - public MessagesListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - MessagesListRequest.Builder newParameters = MessagesListRequest.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - @Override - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "MessagesListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/calendar/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/calendar/package-info.java new file mode 100644 index 000000000..d48370508 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/calendar/package-info.java @@ -0,0 +1,6 @@ +/** + * Calendar message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.calendar; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMedia.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMedia.java deleted file mode 100644 index 7babdc6d1..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMedia.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.types.card; - -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; - -/** - * Deprecated class, use - * - * @deprecated use {@link - * com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage} instead. - */ -@Deprecated -public interface CardMessageMedia extends MediaMessage { - /** - * Getting builder - * - * @return New Builder instance - * @deprecated use {@link MediaMessage#builder()} instead. - */ - @Deprecated - static Builder builder() { - return new CardMessageMediaImpl.Builder(); - } - - /** - * @deprecated use {@link MediaMessage.Builder} instead. - */ - @Deprecated - interface Builder extends MediaMessage.Builder {} -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMediaImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMediaImpl.java deleted file mode 100644 index 6ae5d6f8e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/card/CardMessageMediaImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sinch.sdk.domains.conversation.models.v1.messages.types.card; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessage.Builder; -import com.sinch.sdk.domains.conversation.models.v1.messages.types.media.MediaMessageImpl; - -@Deprecated -public class CardMessageMediaImpl extends MediaMessageImpl implements CardMessageMedia { - - protected CardMessageMediaImpl(MediaMessageImpl mediaMessage) { - super(OptionalValue.of(mediaMessage.getMediaMessage())); - } - - static class Builder implements CardMessageMedia.Builder { - - MediaMessage.Builder builder = MediaMessage.builder(); - - @Override - public Builder setThumbnailUrl(String thumbnailUrl) { - builder.setThumbnailUrl(thumbnailUrl); - return this; - } - - @Override - public Builder setUrl(String url) { - builder.setUrl(url); - return this; - } - - @Override - public Builder setFilenameOverride(String filenameOverride) { - builder.setFilenameOverride(filenameOverride); - return this; - } - - public CardMessageMedia build() { - - return new CardMessageMediaImpl((MediaMessageImpl) builder.build()); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/KakaoTalkButton.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/KakaoTalkButton.java new file mode 100644 index 000000000..2bccbee33 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/KakaoTalkButton.java @@ -0,0 +1,4 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.buttons; + +/** Base class for all classes supported by KakaoTalkButton */ +public interface KakaoTalkButton {} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/package-info.java new file mode 100644 index 000000000..515b6b254 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/buttons/package-info.java @@ -0,0 +1,6 @@ +/** + * KakaoTalk buttons specific models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.buttons; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/carousel/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/carousel/package-info.java new file mode 100644 index 000000000..faf91fc07 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/carousel/package-info.java @@ -0,0 +1,6 @@ +/** + * Kakaotalk Carousel message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.carousel; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/KakaoTalkCommerce.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/KakaoTalkCommerce.java new file mode 100644 index 000000000..36a05e467 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/KakaoTalkCommerce.java @@ -0,0 +1,4 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.commerce; + +/** Base class for all classes supported by KakaoTalkCommerce */ +public interface KakaoTalkCommerce {} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/package-info.java new file mode 100644 index 000000000..a9e0e15e1 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/commerce/package-info.java @@ -0,0 +1,6 @@ +/** + * KakaoTalk commerce specific models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.commerce; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/KakaoTalkCoupon.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/KakaoTalkCoupon.java new file mode 100644 index 000000000..e284f1ee4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/KakaoTalkCoupon.java @@ -0,0 +1,4 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.coupons; + +/** Base class for all classes supported by KakaoTalkCoupon */ +public interface KakaoTalkCoupon {} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/package-info.java new file mode 100644 index 000000000..884ced743 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/coupons/package-info.java @@ -0,0 +1,6 @@ +/** + * KakaoTalk coupons specific models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.coupons; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/image/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/image/package-info.java new file mode 100644 index 000000000..7d0e272e7 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/image/package-info.java @@ -0,0 +1,6 @@ +/** + * KakaoTalk image message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk.image; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/package-info.java new file mode 100644 index 000000000..ece0b0377 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/kakaotalk/package-info.java @@ -0,0 +1,6 @@ +/** + * KakaoTalk channel specific message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.kakaotalk; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/flows/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/flows/package-info.java index 571e4bf11..0a3aeb2a8 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/flows/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/flows/package-info.java @@ -1,5 +1,5 @@ /** - * Whatsapp Flow channel specific message message models + * Whatsapp Flow channel specific message models * * @since 1.3 */ diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/WhatsAppPaymentButton.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/WhatsAppPaymentButton.java new file mode 100644 index 000000000..40b758751 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/WhatsAppPaymentButton.java @@ -0,0 +1,4 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.whatsapp.payment; + +/** Base class for all classes supported by WhatsAppPaymentButton */ +public interface WhatsAppPaymentButton {} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/package-info.java new file mode 100644 index 000000000..3a344aad9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/channelspecific/whatsapp/payment/package-info.java @@ -0,0 +1,6 @@ +/** + * WhatsApp payment message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.whatsapp.payment; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choice/ChoiceImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choice/ChoiceImpl.java index 657093cf8..a8f29cc99 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choice/ChoiceImpl.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/choice/ChoiceImpl.java @@ -8,6 +8,8 @@ import com.fasterxml.jackson.databind.deser.std.StdDeserializer; import com.fasterxml.jackson.databind.ser.std.StdSerializer; import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.calendar.CalendarMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.calendar.CalendarMessageImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.types.call.CallMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.call.CallMessageImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.types.choice.Choice.Builder; @@ -15,6 +17,8 @@ import com.sinch.sdk.domains.conversation.models.v1.messages.types.internal.ChoiceMessageOneOfInternalImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.location.LocationMessageImpl; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.sharelocation.ShareLocationMessage; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.sharelocation.ShareLocationMessageImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.types.text.TextMessageImpl; import com.sinch.sdk.domains.conversation.models.v1.messages.types.url.UrlMessage; @@ -110,6 +114,11 @@ public void serialize(Choice raw, JsonGenerator jgen, SerializerProvider provide internal.setTextMessage(((TextMessageImpl) m).getTextMessage()); } else if (m instanceof UrlMessage) { internal.setUrlMessage(((UrlMessageImpl) m).getUrlMessage()); + } else if (m instanceof CalendarMessage) { + internal.setCalendarMessage(((CalendarMessageImpl) m).getCalendarMessage()); + } else if (m instanceof ShareLocationMessage) { + internal.setShareLocationMessage( + ((ShareLocationMessageImpl) m).getShareLocationMessage()); } else { LOGGER.severe("Unexpected class '" + m.getClass() + "'"); } @@ -165,6 +174,18 @@ public Choice deserialize(JsonParser jp, DeserializationContext ctxt) throws if (message.isPresent()) { builder = Choice.builder().setMessage(message.get()); } + } else if (deserialized.calendarMessage().isPresent()) { + Optional message = + CalendarMessageImpl.delegatedConverter(deserialized.getCalendarMessage()); + if (message.isPresent()) { + builder = Choice.builder().setMessage(message.get()); + } + } else if (deserialized.shareLocationMessage().isPresent()) { + Optional message = + ShareLocationMessageImpl.delegatedConverter(deserialized.getShareLocationMessage()); + if (message.isPresent()) { + builder = Choice.builder().setMessage(message.get()); + } } else { LOGGER.severe("Unexpected content'" + deserialized + "'"); return null; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/internal/WhatsAppPaymentButtonMapper.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/internal/WhatsAppPaymentButtonMapper.java new file mode 100644 index 000000000..5c5be0b18 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/internal/WhatsAppPaymentButtonMapper.java @@ -0,0 +1,39 @@ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.internal; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.whatsapp.payment.WhatsAppPaymentButton; +import com.sinch.sdk.domains.conversation.models.v1.messages.types.channelspecific.whatsapp.payment.internal.WhatsAppPaymentButtonInternalImpl; +import java.io.IOException; + +public class WhatsAppPaymentButtonMapper { + + public static void initMapper() { + SimpleModule module = + new SimpleModule().addDeserializer(WhatsAppPaymentButton.class, new Deserializer()); + Mapper.getInstance().registerModule(module); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public WhatsAppPaymentButton deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + WhatsAppPaymentButtonInternalImpl deserialized = + jp.readValueAs(WhatsAppPaymentButtonInternalImpl.class); + return (WhatsAppPaymentButton) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/sharelocation/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/sharelocation/package-info.java new file mode 100644 index 000000000..e0d0f0617 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/messages/types/sharelocation/package-info.java @@ -0,0 +1,6 @@ +/** + * Share location message models + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.messages.types.sharelocation; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/package-info.java new file mode 100644 index 000000000..0d2360fad --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/package-info.java @@ -0,0 +1,9 @@ +/** + * Conversation models for Project Settings + * + * @see Project + * Settings + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.projectsettings; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/request/package-info.java new file mode 100644 index 000000000..f90638b74 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/request/package-info.java @@ -0,0 +1,9 @@ +/** + * Request models for Project Settings + * + * @see Project + * Settings + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.projectsettings.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/response/package-info.java new file mode 100644 index 000000000..b040149bf --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/projectsettings/response/package-info.java @@ -0,0 +1,9 @@ +/** + * Response models for Project Settings + * + * @see Project + * Settings + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.projectsettings.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/capability/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/capability/package-info.java new file mode 100644 index 000000000..9545d2fd9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/capability/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for CAPABILITY sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.capability; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/channel/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/channel/package-info.java new file mode 100644 index 000000000..adab33e3f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/channel/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for CHANNEL sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.channel; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/contact/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/contact/package-info.java new file mode 100644 index 000000000..d8651847a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/contact/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for CONTACT sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/conversation/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/conversation/package-info.java new file mode 100644 index 000000000..b1b139b75 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/conversation/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for CONVERSATION sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.conversation; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/delivery/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/delivery/package-info.java new file mode 100644 index 000000000..675908cd4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/delivery/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for DELIVERY sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.delivery; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/inbound/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/inbound/package-info.java new file mode 100644 index 000000000..0c6326ef8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/inbound/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for INBOUND sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.inbound; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/message/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/message/package-info.java new file mode 100644 index 000000000..9dd21370a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/message/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for MESSAGE sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.message; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/opting/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/opting/package-info.java new file mode 100644 index 000000000..3afa41e57 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/opting/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for OPT-IN/OPT-OUT sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.opting; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/package-info.java new file mode 100644 index 000000000..592e22607 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/package-info.java @@ -0,0 +1,7 @@ +/** + * Conversation models for Sinch Events sent onto callbacks + * + * @see callbacks + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/record/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/record/package-info.java new file mode 100644 index 000000000..4aa6672ba --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/record/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for RECORD sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.record; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/smartconversations/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/smartconversations/package-info.java new file mode 100644 index 000000000..f2c16f9a1 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/smartconversations/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for SMART CONVERSATIONS sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.smartconversations; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/unsupported/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/unsupported/package-info.java new file mode 100644 index 000000000..3b9697f2e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/sinchevents/unsupported/package-info.java @@ -0,0 +1,6 @@ +/** + * Conversation models for UNSUPPORTED sent onto callbacks + * + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.models.v1.sinchevents.unsupported; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/capability/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/capability/package-info.java deleted file mode 100644 index b73fc9779..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/capability/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for CAPABILITY sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.capability; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/channel/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/channel/package-info.java deleted file mode 100644 index 7bb21bdc0..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/channel/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for CHANNEL sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.channel; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/contact/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/contact/package-info.java deleted file mode 100644 index 087762c48..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/contact/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for CONTACT sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/conversation/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/conversation/package-info.java deleted file mode 100644 index 1c56a70bc..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/conversation/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for CONVERSATION sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.conversation; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/delivery/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/delivery/package-info.java deleted file mode 100644 index ed711b16a..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/delivery/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for DELIVERY sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.delivery; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/inbound/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/inbound/package-info.java deleted file mode 100644 index d54fb6738..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/inbound/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for INBOUND sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.inbound; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/package-info.java deleted file mode 100644 index 845ea3c10..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/message/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for MESSAGE sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/opting/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/opting/package-info.java deleted file mode 100644 index e274fcd7e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/opting/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for OPT-IN/OPT-OUT sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.opting; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/package-info.java deleted file mode 100644 index 922556e37..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Conversation models for webhooks events sent onto callbacks - * - * @see callbacks - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/record/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/record/package-info.java deleted file mode 100644 index 6ce385f05..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/record/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for RECORD sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.record; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/package-info.java deleted file mode 100644 index fb4096b6c..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/smartconversations/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for SMART CONVERSATIONS sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.smartconversations; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/unsupported/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/unsupported/package-info.java deleted file mode 100644 index 93d2d2dc8..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/events/unsupported/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Conversation models for UNSUPPORTED sent onto callbacks - * - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.events.unsupported; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/package-info.java deleted file mode 100644 index 4af029bb7..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Conversation models for Webhooks - * - * @see Webhooks - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/response/package-info.java deleted file mode 100644 index 07802ac40..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/models/v1/webhooks/response/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Webhooks response models - * - * @see Webhooks - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.models.v1.webhooks.response; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/api/TemplatesService.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/TemplatesService.java new file mode 100644 index 000000000..830c3c9f9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/TemplatesService.java @@ -0,0 +1,22 @@ +package com.sinch.sdk.domains.conversation.templates.api; + +import com.sinch.sdk.domains.conversation.templates.api.v2.TemplatesV2Service; + +/** + * Service for working with Conversation templates + * + * @see online + * documentation + * @since 1.3 + */ +public interface TemplatesService { + + /** + * Service for working with templates V2 + * + * @return Templates V2 service + * @since 1.3 + */ + TemplatesV2Service v2(); +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/api/adapters/TemplatesService.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/adapters/TemplatesService.java new file mode 100644 index 000000000..021cef5dd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/adapters/TemplatesService.java @@ -0,0 +1,131 @@ +package com.sinch.sdk.domains.conversation.templates.api.adapters; + +import com.sinch.sdk.auth.adapters.OAuthManager; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpMapper; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.utils.StringUtil; +import com.sinch.sdk.domains.conversation.api.v1.adapters.ConversationService; +import com.sinch.sdk.domains.conversation.templates.api.v2.TemplatesV2Service; +import com.sinch.sdk.domains.conversation.templates.api.v2.adapters.TemplatesV2ServiceImpl; +import com.sinch.sdk.domains.conversation.templates.models.v2.ChannelTemplateOverrideMapper; +import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslationMapper; +import com.sinch.sdk.models.ConversationContext; +import com.sinch.sdk.models.UnifiedCredentials; +import java.util.AbstractMap; +import java.util.Map; +import java.util.Objects; +import java.util.function.Supplier; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class TemplatesService + implements com.sinch.sdk.domains.conversation.templates.api.TemplatesService { + + private static final Logger LOGGER = Logger.getLogger(TemplatesService.class.getName()); + private static final String SECURITY_SCHEME_KEYWORD_ = "oAuth2"; + + private final String uriUUID; + private final UnifiedCredentials credentials; + private final ServerConfiguration oAuthServer; + + private final ConversationContext context; + private final Supplier httpClientSupplier; + + private volatile Map authManagers; + private volatile TemplatesV2Service v2; + + static { + LocalLazyInit.init(); + } + + public TemplatesService( + UnifiedCredentials credentials, + ConversationContext context, + ServerConfiguration oAuthServer, + Supplier httpClientSupplier) { + + this.uriUUID = null != credentials ? credentials.getProjectId() : null; + this.context = context; + this.credentials = credentials; + this.oAuthServer = oAuthServer; + this.httpClientSupplier = httpClientSupplier; + } + + public TemplatesV2Service v2() { + if (null == this.v2) { + synchronized (this) { + if (null == this.v2) { + instanceLazyInit(); + this.v2 = + new TemplatesV2ServiceImpl( + httpClientSupplier.get(), + context.getTemplateManagementServer(), + authManagers, + HttpMapper.getInstance(), + this.uriUUID); + } + } + } + return this.v2; + } + + private void instanceLazyInit() { + if (null != this.authManagers) { + return; + } + synchronized (this) { + if (null == this.authManagers) { + Objects.requireNonNull(credentials, "Templates service requires credentials to be defined"); + Objects.requireNonNull(context, "Templates service requires context to be defined"); + StringUtil.requireNonEmpty( + credentials.getKeyId(), "Templates service requires 'keyId' to be defined"); + StringUtil.requireNonEmpty( + credentials.getKeySecret(), "Templates service requires 'keySecret' to be defined"); + StringUtil.requireNonEmpty( + credentials.getProjectId(), "Templates service requires 'projectId' to be defined"); + Objects.requireNonNull( + context.getRegion(), "Templates service requires 'region' to be defined"); + StringUtil.requireNonEmpty( + context.getRegion().value(), "Templates service requires 'region' to be defined"); + StringUtil.requireNonEmpty( + context.getTemplateManagementUrl(), + "Templates service requires 'templateManagementUrl' to be defined"); + + OAuthManager authManager = + new OAuthManager( + credentials, oAuthServer, HttpMapper.getInstance(), httpClientSupplier); + authManagers = + Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_, authManager)) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + LOGGER.fine( + String.format( + "Activate templates API with template server: '%s", + context.getTemplateManagementServer().getUrl())); + } + } + } + + static final class LocalLazyInit { + + private LocalLazyInit() { + // Because of templates classes are depending of Conversation classes we need to init for a + // proper serialize/deserialize process + ConversationService.LocalLazyInit.init(); + TemplateTranslationMapper.initMapper(); + ChannelTemplateOverrideMapper.initMapper(); + } + + public static LocalLazyInit init() { + return LocalLazyInit.LazyHolder.INSTANCE; + } + + private static class LazyHolder { + + public static final LocalLazyInit INSTANCE = new LocalLazyInit(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/api/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/package-info.java new file mode 100644 index 000000000..948304b1f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/package-info.java @@ -0,0 +1,8 @@ +/** + * Conversation API interface for templates management + * + * @see Conversation + * Templates + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.templates.api; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/api/v2/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/v2/package-info.java new file mode 100644 index 000000000..f06d2bdc1 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/api/v2/package-info.java @@ -0,0 +1,8 @@ +/** + * Conversation API interface for templates V2 management + * + * @see Conversation + * Templates + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.templates.api.v2; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v1/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v1/package-info.java deleted file mode 100644 index 1b8581aae..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v1/package-info.java +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Conversation models for templates V1 - * - * @see Templates - * V1 - * @since 1.3 - */ -package com.sinch.sdk.domains.conversation.templates.models.v1; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequest.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequest.java deleted file mode 100644 index 1357bc47e..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.conversation.templates.models.v2.request; - -import java.util.Optional; - -/** - * Parameters request to list translation relate to a template - * - * @see online - * documentation - * @since 1.3 - */ -public interface TranslationListRequest { - - /** - * The translation's language code. - * - * @return Language code. - */ - Optional getLanguageCode(); - - /** - * The translation's version - * - * @return Translation's version - */ - Optional getTranslationVersion(); - - static Builder builder() { - return new TranslationListRequestImpl.Builder(); - } - - interface Builder { - - /** - * see getter - * - * @param languageCode see getter - * @return Current builder - * @see #getLanguageCode() () - */ - Builder setLanguageCode(String languageCode); - - /** - * see getter - * - * @param translationVersion see getter - * @return Current builder - * @see #getTranslationVersion() () - */ - Builder setTranslationVersion(String translationVersion); - - TranslationListRequest build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequestImpl.java deleted file mode 100644 index a4a3fb55b..000000000 --- a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/TranslationListRequestImpl.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.conversation.templates.models.v2.request; - -import com.sinch.sdk.domains.conversation.templates.models.v2.request.TranslationListRequest.Builder; -import java.util.Optional; - -public class TranslationListRequestImpl implements TranslationListRequest { - - final String languageCode; - final String translationVersion; - - public TranslationListRequestImpl(String languageCode, String translationVersion) { - this.languageCode = languageCode; - this.translationVersion = translationVersion; - } - - @Override - public Optional getLanguageCode() { - return Optional.ofNullable(languageCode); - } - - @Override - public Optional getTranslationVersion() { - return Optional.ofNullable(translationVersion); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder implements TranslationListRequest.Builder { - - String languageCode; - String translationVersion; - - Builder() {} - - @Override - public Builder setLanguageCode(String languageCode) { - this.languageCode = languageCode; - return this; - } - - @Override - public Builder setTranslationVersion(String translationVersion) { - this.translationVersion = translationVersion; - return this; - } - - public TranslationListRequest build() { - return new TranslationListRequestImpl(languageCode, translationVersion); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/package-info.java index e47f05d53..cd0e32256 100644 --- a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/request/package-info.java @@ -1,6 +1,9 @@ /** - * Conversation Templates V2 request models + * Request models for templates V2 * + * @see Templates + * V2 * @since 1.3 */ package com.sinch.sdk.domains.conversation.templates.models.v2.request; diff --git a/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/response/package-info.java b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/response/package-info.java new file mode 100644 index 000000000..cfa2114bd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/conversation/templates/models/v2/response/package-info.java @@ -0,0 +1,9 @@ +/** + * Response models for templates V2 + * + * @see Templates + * V2 + * @since 1.3 + */ +package com.sinch.sdk.domains.conversation.templates.models.v2.response; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/MailgunService.java b/client/src/main/com/sinch/sdk/domains/mailgun/MailgunService.java deleted file mode 100644 index 8e56a0e8b..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/MailgunService.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.sinch.sdk.domains.mailgun; - -/** - * Mailgun Service - * - * @see https://documentation.mailgun.com/docs/mailgun/user-manual/get-started/ - * @since 1.6 - */ -public interface MailgunService { - - /** - * Mailgun Service V1 - * - * @return V1 service instance for project - * @since 1.6 - */ - com.sinch.sdk.domains.mailgun.api.v1.MailgunService v1(); -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/adapters/MailgunService.java b/client/src/main/com/sinch/sdk/domains/mailgun/adapters/MailgunService.java deleted file mode 100644 index 25cd6ceea..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/adapters/MailgunService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.mailgun.adapters; - -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.models.MailgunContext; -import com.sinch.sdk.models.MailgunCredentials; - -public class MailgunService implements com.sinch.sdk.domains.mailgun.MailgunService { - - private final MailgunCredentials credentials; - private final MailgunContext context; - private final HttpClient httpClient; - - private com.sinch.sdk.domains.mailgun.api.v1.MailgunService mailgunV1; - - public MailgunService( - MailgunCredentials credentials, MailgunContext context, HttpClient httpClient) { - this.credentials = credentials; - this.context = context; - this.httpClient = httpClient; - } - - public com.sinch.sdk.domains.mailgun.api.v1.MailgunService v1() { - if (null == this.mailgunV1) { - this.mailgunV1 = - new com.sinch.sdk.domains.mailgun.api.v1.adapters.MailgunService( - credentials, context, httpClient); - } - return this.mailgunV1; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/MailgunService.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/MailgunService.java deleted file mode 100644 index 6f573c51d..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/MailgunService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1; - -/** - * Mailgun Service V1 - * - * @see https://documentation.mailgun.com/docs/mailgun - * @since 1.6 - */ -public interface MailgunService { - - /** - * Emails Service instance V1 - * - * @return service instance for project - * @see Messages - * API documentation - * @since 1.6 - */ - EmailsService emails(); - - /** - * Templates Service instance V1 - * - * @return service instance for project - * @see Templates - * API documentation - * @since 1.6 - */ - TemplatesService templates(); -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializer.java deleted file mode 100644 index 84d9df594..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializer.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import java.util.Map; - -public class BooleanFormSerializer extends FormSerializer { - - @Override - public void serialize(Boolean in, String fieldName, Map out) { - if (null != in) { - out.put(fieldName, format(in)); - } - } - - private static String format(Boolean value) { - return String.format("%s", value); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializer.java deleted file mode 100644 index 1ac64cc85..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializer.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import com.sinch.sdk.core.utils.Pair; -import java.util.List; -import java.util.Map; - -public class CustomHeadersFormSerializer extends FormSerializer>> { - - @Override - public void serialize(List> in, String fieldName, Map out) { - PrefixedListFormSerializerHelper.serialize("h:", in, out); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializer.java deleted file mode 100644 index 525e4083d..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializer.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import com.sinch.sdk.core.utils.Pair; -import java.util.List; -import java.util.Map; - -public class CustomVariablesFormSerializer extends FormSerializer>> { - - @Override - public void serialize(List> in, String fieldName, Map out) { - PrefixedListFormSerializerHelper.serialize("v:", in, out); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializer.java deleted file mode 100644 index 352426b32..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializer.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import java.util.Map; - -public class DeliveryTimeFormSerializer extends FormSerializer { - - @Override - public void serialize(Integer in, String fieldName, Map out) { - if (null != in) { - out.put(fieldName, String.format("%dh", in)); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializer.java deleted file mode 100644 index a8cfb1602..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializer.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.core.utils.databind.Mapper; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -public class ListOfPairFormSerializer extends FormSerializer>> { - - @Override - public void serialize(List> in, String fieldName, Map out) { - - try { - - if (null == in) { - out.put(fieldName, null); - return; - } - - Map collected = - in.stream() - .collect( - Collectors.toMap( - Pair::getLeft, Pair::getRight, (s1, s2) -> s1, LinkedHashMap::new)); - - out.put(fieldName, Mapper.getInstance().writeValueAsString(collected)); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunService.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunService.java deleted file mode 100644 index c8ab06d9c..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunService.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.auth.adapters.BasicAuthManager; -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.utils.StringUtil; -import com.sinch.sdk.domains.mailgun.api.v1.EmailsService; -import com.sinch.sdk.domains.mailgun.api.v1.TemplatesService; -import com.sinch.sdk.models.MailgunContext; -import com.sinch.sdk.models.MailgunCredentials; -import java.util.AbstractMap; -import java.util.Map; -import java.util.Objects; -import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class MailgunService implements com.sinch.sdk.domains.mailgun.api.v1.MailgunService { - - private static final Logger LOGGER = Logger.getLogger(MailgunService.class.getName()); - private static final String SECURITY_SCHEME_KEYWORD_NUMBERS = "basicAuth"; - - private final MailgunContext context; - private final HttpClient httpClient; - - private final Map authManagers; - - private EmailsService emails; - private TemplatesService templates; - - public MailgunService( - MailgunCredentials credentials, MailgunContext context, HttpClient httpClient) { - - Objects.requireNonNull(credentials, "Mailgun service require credentials to be defined"); - Objects.requireNonNull(context, "Mailgun service requires context to be defined"); - StringUtil.requireNonEmpty( - credentials.getApiUser(), "Mailgun service requires 'apiUser' to be defined"); - StringUtil.requireNonEmpty( - credentials.getApiKey(), "Mailgun service requires 'apiKey' to be defined"); - StringUtil.requireNonEmpty(context.getUrl(), "'Mailgun service requires 'url' to be defined"); - - if (Boolean.TRUE == context.getRegionAsDefault()) { - LOGGER.warning( - String.format( - "Using default region for Mailgun '%s'. This default fallback will be removed in next" - + " major release and will cause a runtime error. Please configure the region you" - + " want to be used (see" - + " https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.6.0/com/sinch/sdk/models/Configuration.Builder.html#setMailgunRegion(com.sinch.sdk.models.MailgunRegion)", - context.getRegion())); - } - - LOGGER.fine("Activate Mailgun API with server='" + context.getServer().getUrl() + "'"); - - this.context = context; - this.httpClient = httpClient; - - AuthManager basicAuthManager = - new BasicAuthManager(credentials.getApiUser(), credentials.getApiKey()); - - authManagers = - Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_NUMBERS, basicAuthManager)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - } - - public EmailsService emails() { - if (null == this.emails) { - this.emails = - new EmailsServiceImpl( - httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - return this.emails; - } - - public TemplatesService templates() { - if (null == this.templates) { - this.templates = - new TemplatesServiceImpl( - httpClient, context.getServer(), authManagers, HttpMapper.getInstance()); - } - return this.templates; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelper.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelper.java deleted file mode 100644 index afaf7ff05..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import static java.util.stream.Collectors.toMap; - -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.core.utils.databind.Mapper; -import java.util.Collection; -import java.util.Map; -import java.util.Map.Entry; - -public final class MapOfPairsToJSONHelper { - - private MapOfPairsToJSONHelper() {} - - public static String serialize(Map>> in) { - if (null == in) { - return null; - } - - try { - Map> collected = - in.entrySet().stream() - .collect( - toMap( - Entry::getKey, - entry -> - entry.getValue().stream().collect(toMap(Pair::getLeft, Pair::getRight)))); - return Mapper.getInstance().writeValueAsString(collected); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelper.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelper.java deleted file mode 100644 index f27f63ac7..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.utils.databind.Mapper; -import java.util.Map; - -public final class MapToJSONStringHelper { - - private MapToJSONStringHelper() {} - - public static String serialize(Map in) { - if (null == in) { - return null; - } - try { - return Mapper.getInstance().writeValueAsString(in); - } catch (Exception e) { - throw new RuntimeException(e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializer.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializer.java deleted file mode 100644 index 7bb77137e..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializer.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.FormSerializer; -import com.sinch.sdk.core.utils.databind.MultiPartMapper; -import java.util.Map; - -public class NestedFieldFormSerializer extends FormSerializer { - - @Override - public void serialize(Object in, String fieldName, Map out) { - if (null != in) { - try { - out.putAll(MultiPartMapper.getInstance().serialize(in)); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/PrefixedListFormSerializerHelper.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/PrefixedListFormSerializerHelper.java deleted file mode 100644 index 1e6fcef00..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/adapters/PrefixedListFormSerializerHelper.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import static java.util.stream.Collectors.groupingBy; -import static java.util.stream.Collectors.mapping; -import static java.util.stream.Collectors.toList; - -import com.sinch.sdk.core.utils.Pair; -import java.util.List; -import java.util.Map; - -public final class PrefixedListFormSerializerHelper { - - private PrefixedListFormSerializerHelper() {} - - public static void serialize( - String prefix, List> in, Map out) { - if (null != in) { - try { - Map> groupedByKey = - in.stream() - .map( - entry -> - Pair.of(String.format("%s%s", prefix, entry.getLeft()), entry.getRight())) - .collect(groupingBy(Pair::getLeft, mapping(Pair::getRight, toList()))); - - out.putAll(groupedByKey); - - } catch (Exception e) { - throw new RuntimeException(e); - } - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/package-info.java deleted file mode 100644 index 55d32b8cd..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/api/v1/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Mailgun API interface for V1 endpoints - * - * @see Mailgun - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.api.v1; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/SendEmailRequest.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/SendEmailRequest.java deleted file mode 100644 index 705a4e69f..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/SendEmailRequest.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.sinch.sdk.domains.mailgun.models.v1.emails.request; - -/** - * Base class for all classes supported by SendEmail - * - * @see com.sinch.sdk.domains.mailgun.api.v1.EmailsService#sendEmail(String, SendEmailRequest) - * @since 1.6 - */ -public interface SendEmailRequest {} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/package-info.java deleted file mode 100644 index 9792f83f8..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/request/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Mailgun emails API requests related models - * - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.models.v1.emails.request; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/response/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/response/package-info.java deleted file mode 100644 index 96440f9b7..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/emails/response/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Mailgun emails API response related models - * - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.models.v1.emails.response; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/internal/MailgunPageNavigator.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/internal/MailgunPageNavigator.java deleted file mode 100644 index 997d8458d..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/internal/MailgunPageNavigator.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.sinch.sdk.domains.mailgun.models.v1.internal; - -import com.sinch.sdk.core.http.HttpRequest; -import com.sinch.sdk.core.models.pagination.PageNavigator; - -public class MailgunPageNavigator extends PageNavigator { - - private final HttpRequest nextPageRequest; - - public MailgunPageNavigator(HttpRequest nextPageRequest) { - super(null); - this.nextPageRequest = nextPageRequest; - } - - private HttpRequest computeNextPageCursor() { - return nextPageRequest; - } - - @Override - public HttpRequest getToken() { - return computeNextPageCursor(); - } - - @Override - public String toString() { - return "MailgunPageNavigator{" + "nextPageRequest=" + nextPageRequest + "} " + super.toString(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/package-info.java deleted file mode 100644 index 39cc15664..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Mailgun Templates API related models - * - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.models.v1.templates; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/request/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/request/package-info.java deleted file mode 100644 index ab42ebf9f..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/request/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Mailgun Templates API requests related models - * - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.models.v1.templates.request; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/response/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/response/package-info.java deleted file mode 100644 index 2a64a2ae7..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/models/v1/templates/response/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Mailgun Templates API responses related models - * - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun.models.v1.templates.response; diff --git a/client/src/main/com/sinch/sdk/domains/mailgun/package-info.java b/client/src/main/com/sinch/sdk/domains/mailgun/package-info.java deleted file mode 100644 index bdeb06ec0..000000000 --- a/client/src/main/com/sinch/sdk/domains/mailgun/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Mailgun API interface - * - *

The Mailgun API is part of the Sinch family and enables you to send, track, and receive email - * effortlessly - * - * @see https://documentation.mailgun.com/docs/mailgun - * @since 1.6 - */ -package com.sinch.sdk.domains.mailgun; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java deleted file mode 100644 index ae40a1509..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/ActiveNumberService.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.sinch.sdk.domains.numbers; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest; - -/** - * Active Numbers Service - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService} instead. - */ -@Deprecated -public interface ActiveNumberService { - - /** - * Lists active numbers for a project - * - * @param parameters Filtering criteria - * @return List of active numbers - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService#list(ActiveNumberListRequest)} instead. - */ - @Deprecated - ActiveNumberListResponse list(ActiveNumberListRequestParameters parameters) throws ApiException; - - /** - * Get active number information by phone number - * - * @param phoneNumber Phone number - * @return Active number information - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#get(String)} - * instead. - */ - @Deprecated - ActiveNumber get(String phoneNumber) throws ApiException; - - /** - * Release an active number from the project - * - * @param phoneNumber Phone number - * @return Released active number - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#release(String)} - * instead. - */ - @Deprecated - ActiveNumber release(String phoneNumber) throws ApiException; - - /** - * Update an active phone number - * - * @param phoneNumber Phone number - * @param parameters Parameters to be updated - * @return Updated active number - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#update(String, - * ActiveNumberUpdateRequest)} instead. - */ - @Deprecated - ActiveNumber update(String phoneNumber, ActiveNumberUpdateRequestParameters parameters) - throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java deleted file mode 100644 index f05b0c3fa..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/AvailableNumberService.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.sinch.sdk.domains.numbers; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.AvailableNumber; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentAnyRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest; - -/** - * Available Number Service - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService} instead. - */ -@Deprecated -public interface AvailableNumberService { - - /** - * Search for available phone numbers - * - *

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

When searching, indicate the capability of the number in the array as SMS and/or VOICE. To - * search for a number capable of both, list both SMS and VOICE. - * - * @param parameters Filtering criteria - * @return List of available numbers according to search criteria - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService#searchForAvailableNumbers(AvailableNumberListRequest)} - * instead. - */ - @Deprecated - AvailableNumberListResponse list(AvailableNumberListAllRequestParameters parameters) - throws ApiException; - - /** - * Get available number information by phone number - * - *

This endpoint allows you to enter a specific phone number to check if it's available for use - * - * @param phoneNumber Phone number - * @return Available number information - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService#checkAvailability(String)} instead. - */ - @Deprecated - AvailableNumber checkAvailability(String phoneNumber) throws ApiException; - - /** - * Activate a new phone number - * - *

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

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

Note: You cannot add both objects if you only need to configure one object. For example, if - * you only need to configure smsConfiguration for SMS messaging, do not add the - * voiceConfiguration object or it will result in an error. - * - * @param phoneNumber Number to be activated - * @param parameters Activation parameters - * @return Activated number - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#rent(String, - * AvailableNumberRentRequest)} instead. - */ - @Deprecated - ActiveNumber rent(String phoneNumber, AvailableNumberRentRequestParameters parameters) - throws ApiException; - - /** - * Rent any number that matches the criteria - * - *

Activates a phone number that matches the search criteria provided in the request. Currently - * the rentAny operation works only for US LOCAL numbers - * - * @param parameters Selection and activation parameters - * @return Activated number according to criteria - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService#rentAny(AvailableNumberRentAnyRequest)} - * instead. - */ - @Deprecated - ActiveNumber rentAny(AvailableNumberRentAnyRequestParameters parameters) throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java b/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java deleted file mode 100644 index b44a87615..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/AvailableRegionService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.numbers; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.request.AvailableRegionListRequest; - -/** - * Available Region Service - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Regions - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService} instead. - */ -@Deprecated -public interface AvailableRegionService { - - /** - * List available regions - * - * @param parameters Filtering criteria - * @return List of available regions according to search criteria - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService#list(AvailableRegionListRequest)} - * instead. - */ - @Deprecated - AvailableRegionListResponse list(AvailableRegionListAllRequestParameters parameters) - throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java b/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java deleted file mode 100644 index c04e73359..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/CallbackConfigurationService.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.numbers; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; -import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.callbacks.request.CallbackConfigurationUpdateRequest; - -/** - * Callback Configuration Service - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Callbacks/ - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService} - * instead. - */ -@Deprecated -public interface CallbackConfigurationService { - - /** - * Get callbacks configuration - * - * @return callbacks configuration for the project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService#get()} - * instead. - */ - @Deprecated - CallbackConfiguration get() throws ApiException; - - /** - * Update callbacks configuration - * - * @param parameters Parameters to be updated - * @return Updated callbacks configuration - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService#update(CallbackConfigurationUpdateRequest)} - * instead. - */ - @Deprecated - CallbackConfiguration update(CallbackConfigurationUpdateRequestParameters parameters) - throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java index 28b38e795..3741c08aa 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/NumbersService.java @@ -18,64 +18,4 @@ public interface NumbersService { * @since 1.2 */ com.sinch.sdk.domains.numbers.api.v1.NumbersService v1(); - - /** - * Non versioned Available Number Service instance - * - * @apiNote This version is no longer updated, to get updates use V1 version: {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService} - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService} instead. - */ - @Deprecated - AvailableNumberService available(); - - /** - * Non versioned Available Region Service instance - * - * @apiNote This version is no longer updated, to get updates use V1 version: {@link - * com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService} - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#regions()} instead. - */ - @Deprecated - AvailableRegionService regions(); - - /** - * Non versioned Active Number Service instance - * - * @apiNote This version is no longer updated, to get updates use V1 version: {@link - * com.sinch.sdk.domains.numbers.api.v1.NumbersService} - * @return service instance for project - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService} instead. - * @since 1.0 - */ - @Deprecated - ActiveNumberService active(); - - /** - * Non versioned Callbacks Configuration Service instance - * - * @apiNote This version is no longer updated, to get updates use V1 version: {@link - * com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService} - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#callback()} instead. - */ - @Deprecated - CallbackConfigurationService callback(); - - /** - * Non versioned Webhooks helpers instance - * - * @apiNote This version is no longer updated, to get updates use V1 version: {@link - * com.sinch.sdk.domains.numbers.api.v1.WebHooksService} - * @return instance service related to webhooks helpers - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.NumbersService#webhooks()} instead. - */ - @Deprecated - WebHooksService webhooks(); } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/numbers/WebHooksService.java deleted file mode 100644 index 0c73c6a8f..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/WebHooksService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.numbers; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.numbers.models.webhooks.EventNotification; - -/** - * Webhooks service - * - *

Callback events are used to get notified about Numbers usage according to your configured - * callback URL - * - *

see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Callbacks/#tag/Callbacks/operation/ImportedNumberService_EventsCallback - * - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.WebHooksService} instead. - */ -@Deprecated -public interface WebHooksService { - - /** - * This function can be called to deserialize received payload onto callback. Function return Java - * class instance from un-serialized payload - * - * @param jsonPayload Received payload to be un-serialized - * @return The decoded event notification instance class - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.numbers.api.v1.WebHooksService#parseEvent(String)} - * instead. - */ - @Deprecated - EventNotification unserializeEventNotification(String jsonPayload) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java deleted file mode 100644 index b1f00b181..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/ActiveNumberService.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberDtoConverter; -import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberUpdateRequestParametersDtoConverter; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.ActiveNumberListResponse; -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.OrderBy; -import com.sinch.sdk.domains.numbers.models.v1.request.SearchPosition; -import java.util.Collection; -import java.util.stream.Collectors; - -public class ActiveNumberService implements com.sinch.sdk.domains.numbers.ActiveNumberService { - - private final com.sinch.sdk.domains.numbers.api.v1.NumbersService v1; - - public ActiveNumberService(com.sinch.sdk.domains.numbers.api.v1.NumbersService v1) { - this.v1 = v1; - } - - public ActiveNumberListResponse list(ActiveNumberListRequestParameters parameters) - throws ApiException { - - ActiveNumberListRequest.Builder builder = ActiveNumberListRequest.builder(); - - parameters.getRegionCode().ifPresent(builder::setRegionCode); - parameters.getType().ifPresent(f -> builder.setType(NumberType.from(f.value()))); - - parameters - .getNumberPattern() - .ifPresent( - f -> { - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.Builder spBuilder = - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.builder(); - spBuilder.setPattern(f.getPattern()); - spBuilder.setPosition( - null != f.getSearchPattern() - ? SearchPosition.from(f.getSearchPattern().value()) - : null); - builder.setSearchPattern(spBuilder.build()); - }); - - parameters - .getCapabilities() - .ifPresent( - f -> - builder.setCapabilities( - f.stream().map(c -> Capability.from(c.value())).collect(Collectors.toList()))); - - parameters.getPageSize().ifPresent(builder::setPageSize); - parameters.getOrderBy().ifPresent(f -> builder.setOrderBy(OrderBy.from(f.value()))); - - parameters.getPageToken().ifPresent(builder::setPageToken); - - com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumberListResponse response = - v1.list(builder.build()); - Pair, TokenPageNavigator> content = - ActiveNumberDtoConverter.convert(response); - return new ActiveNumberListResponse( - this, new Page<>(parameters, content.getLeft(), content.getRight())); - } - - public ActiveNumber get(String phoneNumber) throws ApiException { - return ActiveNumberDtoConverter.convert(v1.get(phoneNumber)); - } - - public ActiveNumber release(String phoneNumber) throws ApiException { - return ActiveNumberDtoConverter.convert(v1.release(phoneNumber)); - } - - public ActiveNumber update(String phoneNumber, ActiveNumberUpdateRequestParameters parameters) - throws ApiException { - - return ActiveNumberDtoConverter.convert( - v1.update( - phoneNumber, ActiveNumberUpdateRequestParametersDtoConverter.convert(parameters))); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java deleted file mode 100644 index bb355e180..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableNumberService.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.adapters.converters.ActiveNumberDtoConverter; -import com.sinch.sdk.domains.numbers.adapters.converters.AvailableNumberDtoConverter; -import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRentAnyRequestParametersDtoConverter; -import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRentRequestParametersDtoConverter; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.AvailableNumber; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberListAllRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.AvailableNumberListResponse; -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.SearchPosition; -import java.util.Collection; -import java.util.stream.Collectors; - -public class AvailableNumberService - implements com.sinch.sdk.domains.numbers.AvailableNumberService { - - private final com.sinch.sdk.domains.numbers.api.v1.NumbersService v1; - - public AvailableNumberService(com.sinch.sdk.domains.numbers.api.v1.NumbersService v1) { - this.v1 = v1; - } - - public AvailableNumberListResponse list(AvailableNumberListAllRequestParameters parameters) - throws ApiException { - - AvailableNumberListRequest.Builder builder = AvailableNumberListRequest.builder(); - - parameters.getRegionCode().ifPresent(builder::setRegionCode); - parameters.getType().ifPresent(f -> builder.setType(NumberType.from(f.value()))); - - parameters - .getNumberPattern() - .ifPresent( - f -> { - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.Builder spBuilder = - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.builder(); - spBuilder.setPattern(f.getPattern()); - spBuilder.setPosition( - null != f.getSearchPattern() - ? SearchPosition.from(f.getSearchPattern().value()) - : null); - builder.setSearchPattern(spBuilder.build()); - }); - - parameters - .getCapabilities() - .ifPresent( - f -> - builder.setCapabilities( - f.stream().map(c -> Capability.from(c.value())).collect(Collectors.toList()))); - - parameters.getSize().ifPresent(builder::setSize); - - com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse response = - v1.searchForAvailableNumbers(builder.build()); - - Collection entities = AvailableNumberDtoConverter.convert(response); - - return new AvailableNumberListResponse(entities); - } - - public AvailableNumber checkAvailability(String phoneNumber) throws ApiException { - - com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumber response = - v1.checkAvailability(phoneNumber); - return AvailableNumberDtoConverter.convert(response); - } - - public ActiveNumber rent(String phoneNumber, AvailableNumberRentRequestParameters parameters) - throws ApiException { - - AvailableNumberRentRequestParameters guardParameters = - null != parameters ? parameters : AvailableNumberRentRequestParameters.builder().build(); - - com.sinch.sdk.domains.numbers.models.v1.ActiveNumber response = - v1.rent(phoneNumber, AvailableRentRequestParametersDtoConverter.convert(guardParameters)); - - return ActiveNumberDtoConverter.convert(response); - } - - public ActiveNumber rentAny(AvailableNumberRentAnyRequestParameters parameters) - throws ApiException { - - AvailableNumberRentAnyRequestParameters guardParameters = - null != parameters ? parameters : AvailableNumberRentAnyRequestParameters.builder().build(); - - com.sinch.sdk.domains.numbers.models.v1.ActiveNumber response = - v1.rentAny(AvailableRentAnyRequestParametersDtoConverter.convert(guardParameters)); - return ActiveNumberDtoConverter.convert(response); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java deleted file mode 100644 index 88bb7d040..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/AvailableRegionService.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.adapters.converters.AvailableRegionsDtoConverter; -import com.sinch.sdk.domains.numbers.models.Region; -import com.sinch.sdk.domains.numbers.models.requests.AvailableRegionListAllRequestParameters; -import com.sinch.sdk.domains.numbers.models.responses.AvailableRegionListResponse; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.request.AvailableRegionListRequest; -import java.util.Collection; -import java.util.stream.Collectors; - -public class AvailableRegionService - implements com.sinch.sdk.domains.numbers.AvailableRegionService { - - private final com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService v1; - - public AvailableRegionService(com.sinch.sdk.domains.numbers.api.v1.AvailableRegionService v1) { - this.v1 = v1; - } - - public AvailableRegionListResponse list(AvailableRegionListAllRequestParameters parameters) - throws ApiException { - - AvailableRegionListRequest dto = null; - if (null != parameters && parameters.getTypes().isPresent()) { - dto = - AvailableRegionListRequest.builder() - .setTypes( - parameters.getTypes().get().stream() - .map(f -> NumberType.from(f.value())) - .collect(Collectors.toList())) - .build(); - } - - com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegionListResponse - response = v1.list(dto); - Collection entities = AvailableRegionsDtoConverter.convert(response); - - return new AvailableRegionListResponse(entities); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java deleted file mode 100644 index 18c69bc19..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/CallbackConfigurationService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationDtoConverter; -import com.sinch.sdk.domains.numbers.adapters.converters.CallbackConfigurationUpdateRequestParametersDtoConverter; -import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; -import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; - -public class CallbackConfigurationService - implements com.sinch.sdk.domains.numbers.CallbackConfigurationService { - - com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService v1; - - public CallbackConfigurationService( - com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService v1) { - this.v1 = v1; - } - - public CallbackConfiguration get() throws ApiException { - return CallbackConfigurationDtoConverter.convert(v1.get()); - } - - public CallbackConfiguration update(CallbackConfigurationUpdateRequestParameters parameters) - throws ApiException { - - return CallbackConfigurationDtoConverter.convert( - v1.update(CallbackConfigurationUpdateRequestParametersDtoConverter.convert(parameters))); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java index 74dd0e1f1..eff4ba206 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/adapters/NumbersService.java @@ -8,62 +8,34 @@ public class NumbersService implements com.sinch.sdk.domains.numbers.NumbersService { - private final com.sinch.sdk.domains.numbers.api.v1.NumbersService v1; + private final UnifiedCredentials credentials; + private final NumbersContext context; + private final ServerConfiguration oAuthServer; + private final Supplier httpClientSupplier; - private AvailableNumberService available; - private ActiveNumberService active; - private AvailableRegionService regions; - private CallbackConfigurationService callback; - private WebHooksService webhooks; + private volatile com.sinch.sdk.domains.numbers.api.v1.NumbersService v1; public NumbersService( UnifiedCredentials credentials, NumbersContext context, ServerConfiguration oAuthServer, Supplier httpClientSupplier) { - - this.v1 = - new com.sinch.sdk.domains.numbers.api.v1.adapters.NumbersService( - credentials, context, oAuthServer, httpClientSupplier); + this.credentials = credentials; + this.context = context; + this.oAuthServer = oAuthServer; + this.httpClientSupplier = httpClientSupplier; } public com.sinch.sdk.domains.numbers.api.v1.NumbersService v1() { - return v1; - } - - public AvailableNumberService available() { - if (null == this.available) { - this.available = new AvailableNumberService(v1); - } - return this.available; - } - - public AvailableRegionService regions() { - if (null == this.regions) { - this.regions = new AvailableRegionService(v1.regions()); - } - return this.regions; - } - - public ActiveNumberService active() { - if (null == this.active) { - this.active = new ActiveNumberService(v1); - } - return this.active; - } - - public CallbackConfigurationService callback() { - if (null == this.callback) { - this.callback = new CallbackConfigurationService(v1().callback()); - } - return this.callback; - } - - public WebHooksService webhooks() { - - if (null == this.webhooks) { - this.webhooks = new WebHooksService(v1().webhooks()); + if (null == this.v1) { + synchronized (this) { + if (null == this.v1) { + this.v1 = + new com.sinch.sdk.domains.numbers.api.v1.adapters.NumbersService( + credentials, context, oAuthServer, httpClientSupplier); + } + } } - return this.webhooks; + return this.v1; } } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/WebHooksService.java deleted file mode 100644 index a1bc25895..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/WebHooksService.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.numbers.adapters.converters.CallbackPayloadDtoConverter; -import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent; -import com.sinch.sdk.domains.numbers.models.webhooks.EventNotification; - -public class WebHooksService implements com.sinch.sdk.domains.numbers.WebHooksService { - - com.sinch.sdk.domains.numbers.api.v1.WebHooksService v1; - - public WebHooksService(com.sinch.sdk.domains.numbers.api.v1.WebHooksService v1) { - this.v1 = v1; - } - - @Override - public EventNotification unserializeEventNotification(String jsonPayload) - throws ApiMappingException { - - NumberEvent dto = v1.parseEvent(jsonPayload); - if (null != dto) { - return CallbackPayloadDtoConverter.convert(dto); - } - throw new ApiMappingException(jsonPayload, null); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java deleted file mode 100644 index 52f75f608..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberDtoConverter.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.Capability; -import com.sinch.sdk.domains.numbers.models.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumberListResponse; -import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; - -public class ActiveNumberDtoConverter { - - public static Pair, TokenPageNavigator> convert( - ActiveNumberListResponse dto) { - String nextPageToken = dto.getNextPageToken(); - Collection pageContent = Collections.emptyList(); - if (null != dto.getContent()) { - pageContent = - dto.getContent().stream() - .map(ActiveNumberDtoConverter::convert) - .collect(Collectors.toList()); - } - return new Pair<>(pageContent, new TokenPageNavigator(nextPageToken)); - } - - public static ActiveNumber convert(com.sinch.sdk.domains.numbers.models.v1.ActiveNumber dto) { - - return new ActiveNumber( - dto.getPhoneNumber(), - dto.getProjectId(), - dto.getDisplayName(), - dto.getRegionCode(), - null == dto.getType() ? null : NumberType.from(dto.getType().value()), - null != dto.getCapability() - ? dto.getCapability().stream() - .map(f -> Capability.from(f.value())) - .collect(Collectors.toList()) - : null, - MoneyDtoConverter.convert(dto.getMoney()), - dto.getPaymentIntervalMonths(), - dto.getNextChargeDate(), - dto.getExpireAt(), - SmsConfigurationDtoConverter.convert(dto.getSmsConfiguration()), - VoiceConfigurationDtoConverter.convert(dto.getVoiceConfiguration()), - dto.getCallbackUrl()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java deleted file mode 100644 index 81fba27b9..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ActiveNumberUpdateRequestParametersDtoConverter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest; - -public class ActiveNumberUpdateRequestParametersDtoConverter { - - public static ActiveNumberUpdateRequest convert(ActiveNumberUpdateRequestParameters parameters) { - ActiveNumberUpdateRequest.Builder dto = ActiveNumberUpdateRequest.builder(); - parameters.getDisplayName().ifPresent(dto::setDisplayName); - parameters - .getSmsConfiguration() - .ifPresent(value -> dto.setSmsConfiguration(SmsConfigurationDtoConverter.convert(value))); - parameters - .getVoiceConfiguration() - .ifPresent( - value -> dto.setVoiceConfiguration(VoiceConfigurationDtoConverter.convert(value))); - parameters.getCallback().ifPresent(dto::setCallbackUrl); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java deleted file mode 100644 index 917057f2f..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableNumberDtoConverter.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.AvailableNumber; -import com.sinch.sdk.domains.numbers.models.Capability; -import com.sinch.sdk.domains.numbers.models.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse; -import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; - -public class AvailableNumberDtoConverter { - - public static Collection convert(AvailableNumberListResponse dto) { - Collection list = - dto.getContent(); - if (null == list) { - return Collections.emptyList(); - } - return list.stream().map(AvailableNumberDtoConverter::convert).collect(Collectors.toList()); - } - - public static AvailableNumber convert( - com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumber dto) { - - return new AvailableNumber( - dto.getPhoneNumber(), - dto.getRegionCode(), - null == dto.getType() ? null : NumberType.from(dto.getType().value()), - null != dto.getCapability() - ? dto.getCapability().stream() - .map(f -> Capability.from(f.value())) - .collect(Collectors.toList()) - : null, - MoneyDtoConverter.convert(dto.getSetupPrice()), - MoneyDtoConverter.convert(dto.getMonthlyPrice()), - dto.getPaymentIntervalMonths(), - dto.getSupportingDocumentationRequired()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java deleted file mode 100644 index 831526207..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRegionsDtoConverter.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.NumberType; -import com.sinch.sdk.domains.numbers.models.Region; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegion; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegionListResponse; -import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; - -public class AvailableRegionsDtoConverter { - - public static Collection convert(AvailableRegionListResponse dto) { - Collection list = dto.getContent(); - if (null == list) { - return Collections.emptyList(); - } - return list.stream().map(AvailableRegionsDtoConverter::convert).collect(Collectors.toList()); - } - - public static Region convert(AvailableRegion dto) { - - return Region.builder() - .setRegionCode(dto.getRegionCode()) - .setRegionName(dto.getRegionName()) - .setTypes( - null != dto.getTypes() - ? dto.getTypes().stream() - .map(f -> NumberType.from(f.value())) - .collect(Collectors.toList()) - : null) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java deleted file mode 100644 index 58e1e0c2d..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentAnyRequestParametersDtoConverter.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentAnyRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration; -import com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentAnyRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.SearchPosition; -import java.util.stream.Collectors; - -public class AvailableRentAnyRequestParametersDtoConverter { - public static AvailableNumberRentAnyRequest convert( - AvailableNumberRentAnyRequestParameters parameters) { - - AvailableNumberRentAnyRequest.Builder dto = AvailableNumberRentAnyRequest.builder(); - - parameters.getRegionCode().ifPresent(dto::setRegionCode); - parameters.getType().ifPresent(f -> dto.setType(NumberType.from(f.value()))); - - parameters - .getNumberPattern() - .ifPresent( - f -> { - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.Builder spBuilder = - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.builder(); - com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern.builder(); - spBuilder.setPattern(f.getPattern()); - spBuilder.setPosition( - null != f.getSearchPattern() - ? SearchPosition.from(f.getSearchPattern().value()) - : null); - dto.setNumberPattern(spBuilder.build()); - }); - - parameters - .getCapabilities() - .ifPresent( - f -> - dto.setCapabilities( - f.stream().map(c -> Capability.from(c.value())).collect(Collectors.toList()))); - - parameters - .getSmsConfiguration() - .ifPresent( - value -> { - SmsConfiguration.Builder config = SmsConfiguration.builder(); - value.getServicePlanId().ifPresent(config::setServicePlanId); - value.getCampaignId().ifPresent(config::setCampaignId); - dto.setSmsConfiguration(config.build()); - }); - - parameters - .getVoiceConfiguration() - .ifPresent( - value -> { - VoiceConfigurationRTC.Builder config = VoiceConfigurationRTC.builder(); - value.getAppId().ifPresent(config::setAppId); - dto.setVoiceConfiguration(config.build()); - }); - parameters.getCallBackUrl().ifPresent(dto::setCallbackUrl); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java deleted file mode 100644 index c85323147..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/AvailableRentRequestParametersDtoConverter.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.requests.AvailableNumberRentRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration; -import com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest; - -public class AvailableRentRequestParametersDtoConverter { - - public static AvailableNumberRentRequest convert( - AvailableNumberRentRequestParameters parameters) { - - AvailableNumberRentRequest.Builder dto = AvailableNumberRentRequest.builder(); - - parameters - .getSmsConfiguration() - .ifPresent( - value -> { - SmsConfiguration.Builder config = SmsConfiguration.builder(); - value.getServicePlanId().ifPresent(config::setServicePlanId); - value.getCampaignId().ifPresent(config::setCampaignId); - dto.setSmsConfiguration(config.build()); - }); - - parameters - .getVoiceConfiguration() - .ifPresent( - value -> { - VoiceConfigurationRTC.Builder config = VoiceConfigurationRTC.builder(); - value.getAppId().ifPresent(config::setAppId); - dto.setVoiceConfiguration(config.build()); - }); - - parameters.getCallBackUrl().ifPresent(dto::setCallbackUrl); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java deleted file mode 100644 index 51194d4c0..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationDtoConverter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.CallbackConfiguration; -import com.sinch.sdk.domains.numbers.models.v1.callbacks.response.CallbackConfigurationResponse; - -public class CallbackConfigurationDtoConverter { - - public static CallbackConfiguration convert(CallbackConfigurationResponse dto) { - - if (null == dto) { - return null; - } - return CallbackConfiguration.builder() - .setProjectId(dto.getProjectId()) - .setHMACSecret(dto.getHmacSecret()) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java deleted file mode 100644 index ecb0ea197..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackConfigurationUpdateRequestParametersDtoConverter.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.requests.CallbackConfigurationUpdateRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.callbacks.request.CallbackConfigurationUpdateRequest; - -public class CallbackConfigurationUpdateRequestParametersDtoConverter { - - public static CallbackConfigurationUpdateRequest convert( - CallbackConfigurationUpdateRequestParameters parameters) { - - if (null == parameters) { - return null; - } - CallbackConfigurationUpdateRequest.Builder dto = CallbackConfigurationUpdateRequest.builder(); - parameters.getHMACSecret().ifPresent(dto::setHmacSecret); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackPayloadDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackPayloadDtoConverter.java deleted file mode 100644 index a1fd68ff9..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/CallbackPayloadDtoConverter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.SmsErrorCode; -import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent; -import com.sinch.sdk.domains.numbers.models.webhooks.EventNotification; -import com.sinch.sdk.domains.numbers.models.webhooks.EventStatus; -import com.sinch.sdk.domains.numbers.models.webhooks.EventType; -import com.sinch.sdk.domains.numbers.models.webhooks.ResourceType; -import java.time.Instant; - -public class CallbackPayloadDtoConverter { - - public static EventNotification convert(NumberEvent dto) { - - String eventId = dto.getEventId(); - Instant timestamp = dto.getTimestamp(); - String projectId = dto.getProjectId(); - String resourceId = dto.getResourceId(); - ResourceType resourceType = - null == dto.getResourceType() ? null : ResourceType.from(dto.getResourceType().value()); - EventType eventType = - null == dto.getEventType() ? null : EventType.from(dto.getEventType().value()); - EventStatus status = null == dto.getStatus() ? null : EventStatus.from(dto.getStatus().value()); - SmsErrorCode failureCode = - null == dto.getFailureCode() ? null : SmsErrorCode.from(dto.getFailureCode().value()); - - return new EventNotification( - eventId, timestamp, projectId, resourceId, resourceType, eventType, status, failureCode); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java deleted file mode 100644 index 8723cb6df..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/MoneyDtoConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.Money; - -public class MoneyDtoConverter { - - public static Money convert(com.sinch.sdk.domains.numbers.models.v1.Money dto) { - - if (null == dto) { - return null; - } - return new Money(dto.getCurrencyCode(), dto.getAmount()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java deleted file mode 100644 index 15e4afee5..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledSmsProvisioningDtoConverter.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.numbers.models.ProvisioningStatus; -import com.sinch.sdk.domains.numbers.models.ScheduledSmsProvisioning; -import com.sinch.sdk.domains.numbers.models.SmsErrorCode; -import java.util.stream.Collectors; - -public class ScheduledSmsProvisioningDtoConverter { - - public static ScheduledSmsProvisioning convert( - com.sinch.sdk.domains.numbers.models.v1.ScheduledSmsProvisioning dto) { - - if (null == dto) { - return null; - } - return new ScheduledSmsProvisioning( - dto.getServicePlanId(), - dto.getCampaignId(), - null == dto.getStatus() ? null : ProvisioningStatus.from(dto.getStatus().value()), - dto.getLastUpdatedTime(), - dto.getErrorCodes().stream() - .map(e -> SmsErrorCode.from(e.value())) - .collect(Collectors.toList())); - } - - public static com.sinch.sdk.domains.numbers.models.v1.ScheduledSmsProvisioning convert( - ScheduledSmsProvisioning provisioning) { - - if (null == provisioning) { - return null; - } - - com.sinch.sdk.domains.numbers.models.v1.ScheduledSmsProvisioning.Builder builder = - com.sinch.sdk.domains.numbers.models.v1.ScheduledSmsProvisioning.builder(); - - if (null != provisioning.getServicePlanId()) { - builder.setServicePlanId(provisioning.getServicePlanId()); - } - if (null != provisioning.getCampaignId()) { - builder.setCampaignId(provisioning.getCampaignId()); - } - if (null != provisioning.getLastUpdatedTime()) { - builder.setLastUpdatedTime(provisioning.getLastUpdatedTime()); - } - if (null != provisioning.getErrorCodes()) { - builder.setErrorCodes( - provisioning.getErrorCodes().stream() - .map( - e -> - com.sinch.sdk.domains.numbers.models.v1.SmsErrorCode.from( - EnumDynamicConverter.convert(e))) - .collect(Collectors.toList())); - } - return builder.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java deleted file mode 100644 index 60d2a0057..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/ScheduledVoiceProvisioningDtoConverter.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.numbers.models.ProvisioningStatus; -import com.sinch.sdk.domains.numbers.models.ScheduledVoiceProvisioning; -import com.sinch.sdk.domains.numbers.models.v1.ScheduledVoiceProvisioningRTC; - -public class ScheduledVoiceProvisioningDtoConverter { - - public static ScheduledVoiceProvisioning convert( - com.sinch.sdk.domains.numbers.models.v1.ScheduledVoiceProvisioning _dto) { - - if (null == _dto) { - return null; - } - - if (!(_dto instanceof ScheduledVoiceProvisioningRTC)) { - return null; - } - - ScheduledVoiceProvisioningRTC dto = (ScheduledVoiceProvisioningRTC) _dto; - return new ScheduledVoiceProvisioning( - dto.getAppId(), - null == dto.getStatus() ? null : ProvisioningStatus.from(dto.getStatus().value()), - dto.getLastUpdatedTime()); - } - - public static com.sinch.sdk.domains.numbers.models.v1.ScheduledVoiceProvisioning convert( - ScheduledVoiceProvisioning provisioning) { - - if (null == provisioning) { - return null; - } - - com.sinch.sdk.domains.numbers.models.v1.ScheduledVoiceProvisioningRTC.Builder dto = - com.sinch.sdk.domains.numbers.models.v1.ScheduledVoiceProvisioningRTC.builder(); - - dto.setAppId(provisioning.getAppId()); - dto.setLastUpdatedTime(provisioning.getLastUpdatedTime()); - if (null != provisioning.getStatus()) { - dto.setStatus( - com.sinch.sdk.domains.numbers.models.v1.ProvisioningStatus.from( - EnumDynamicConverter.convert(provisioning.getStatus()))); - } - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java deleted file mode 100644 index e3aad58a8..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/SmsConfigurationDtoConverter.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.SMSConfiguration; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateSMSConfigurationRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration; - -public class SmsConfigurationDtoConverter { - - public static SMSConfiguration convert( - com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration dto) { - - if (null == dto) { - return null; - } - return new SMSConfiguration( - dto.getServicePlanId(), - dto.getCampaignId(), - ScheduledSmsProvisioningDtoConverter.convert(dto.getScheduledProvisioning())); - } - - public static com.sinch.sdk.domains.numbers.models.v1.SmsConfiguration convert( - ActiveNumberUpdateSMSConfigurationRequestParameters configuration) { - - if (null == configuration) { - return null; - } - SmsConfiguration.Builder dto = SmsConfiguration.builder(); - configuration.getServicePlanId().ifPresent(dto::setServicePlanId); - configuration.getCampaignId().ifPresent(dto::setCampaignId); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java deleted file mode 100644 index 64ae116de..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/adapters/converters/VoiceConfigurationDtoConverter.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.numbers.adapters.converters; - -import com.sinch.sdk.domains.numbers.models.VoiceConfiguration; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberUpdateVoiceConfigurationRequestParameters; -import com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC; - -public class VoiceConfigurationDtoConverter { - - public static VoiceConfiguration convert( - com.sinch.sdk.domains.numbers.models.v1.VoiceConfiguration _dto) { - - if (null == _dto) { - return null; - } - if (!(_dto instanceof VoiceConfigurationRTC)) { - return null; - } - - com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC dto = - (com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC) _dto; - return new VoiceConfiguration( - dto.getAppId(), - dto.getLastUpdatedTime(), - ScheduledVoiceProvisioningDtoConverter.convert(dto.getScheduledProvisioning())); - } - - public static com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC convert( - ActiveNumberUpdateVoiceConfigurationRequestParameters configuration) { - - if (null == configuration) { - return null; - } - - com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC.Builder dto = - com.sinch.sdk.domains.numbers.models.v1.VoiceConfigurationRTC.builder(); - configuration.getAppId().ifPresent(dto::setAppId); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionService.java deleted file mode 100644 index b6b677b01..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/AvailableRegionService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.numbers.api.v1; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.request.AvailableRegionListRequest; -import com.sinch.sdk.domains.numbers.models.v1.regions.available.response.AvailableRegionListResponse; -import com.sinch.sdk.domains.numbers.models.v1.regions.request.AvailableRegionsListQueryParameters; - -/** - * Available Region Service - * - * @see online - * documentation - * @since 1.2 - * @deprecated As of release 2.0, replaced by {@link AvailableRegionsService} - */ -@Deprecated -public interface AvailableRegionService { - - /** - * List available regions - * - * @param parameters Filtering criteria - * @return List of available regions according to search criteria - * @since 1.2 - * @deprecated As of release 2.0, replaced by {@link - * AvailableRegionsService#list(AvailableRegionsListQueryParameters)} - */ - @Deprecated - AvailableRegionListResponse list(AvailableRegionListRequest parameters) throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/NumbersService.java index 42afd1d2c..2210b90d3 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/NumbersService.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/NumbersService.java @@ -2,13 +2,7 @@ import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumbersListQueryParameters; -import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumberListResponse; -import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse; /** * Numbers Service @@ -19,25 +13,6 @@ */ public interface NumbersService extends ActiveNumberService, AvailableNumberService { - /** - * Search for available phone numbers - * - *

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

When searching, indicate the capability of the number in the array as SMS and/or VOICE. To - * search for a number capable of both, list both SMS and VOICE. - * - * @param parameters Filtering criteria - * @return List of available numbers according to search criteria - * @since 1.2 - * @deprecated As of release 2.0, replaced by {@link - * AvailableNumberService#searchForAvailableNumbers(AvailableNumbersListQueryParameters)} - */ - @Deprecated - AvailableNumberListResponse searchForAvailableNumbers(AvailableNumberListRequest parameters) - throws ApiException; - /** * Activate a new phone number * @@ -47,18 +22,6 @@ AvailableNumberListResponse searchForAvailableNumbers(AvailableNumberListRequest */ ActiveNumber rent(String phoneNumber) throws ApiException; - /** - * Lists active numbers for a project - * - * @param parameters Filtering criteria - * @return List of active numbers - * @since 1.2 - * @deprecated As of release 2.0, replaced by {@link - * ActiveNumberService#list(ActiveNumbersListQueryParameters)} - */ - @Deprecated - ActiveNumberListResponse list(ActiveNumberListRequest parameters) throws ApiException; - /** * Available Region Service instance * @@ -68,18 +31,18 @@ AvailableNumberListResponse searchForAvailableNumbers(AvailableNumberListRequest AvailableRegionsService regions(); /** - * Callbacks Configuration Service instance + * Event Destinations Configuration Service instance * * @return service instance for project - * @since 1.2 + * @since 2.0 */ - CallbackConfigurationService callback(); + EventDestinationsService eventDestinations(); /** - * Webhooks helpers instance + * Sinch Events helpers instance * - * @return instance service related to webhooks helpers - * @since 1.2 + * @return instance service related to Sinch Events helpers + * @since 2.0 */ - WebHooksService webhooks(); + SinchEventsService sinchEvents(); } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/SinchEventsService.java new file mode 100644 index 000000000..1022fd69f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/SinchEventsService.java @@ -0,0 +1,51 @@ +package com.sinch.sdk.domains.numbers.api.v1; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.numbers.models.v1.sinchevents.NumberSinchEvent; +import java.util.Map; + +/** + * Sinch Events service + * + *

Callback events are used to get notified about Numbers usage according to your configured + * callback URL + * + *

see online + * documentation + * + * @since 1.2 + */ +public interface SinchEventsService { + + /** + * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request + * and result events. All callback requests are signed using your Application key and secret pair + * found on your dashboard. The signature is included in the Authorization header of the request + * + *

By using following function, you can ensure authentication according to received payload + * from your backend + * + * @param secret The HMAC secret used for hashing the callback body using the HMAC-SHA1 algorithm + * and for creating the X-Sinch-Signature header. + * @param headers Received headers + * @param jsonPayload Received payload + * @return Is authentication is validated (true) or not (false) + *

see online + * documentation + * @since 1.2.1 + */ + boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload); + + /** + * This function can be called to deserialize received payload onto callback. Function return Java + * class instance from un-serialized payload + * + * @param jsonPayload Received payload to be un-serialized + * @return The decoded event notification instance class + * @since 1.2 + */ + NumberSinchEvent parseEvent(String jsonPayload) throws ApiMappingException; +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/WebHooksService.java deleted file mode 100644 index 78eef185a..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/WebHooksService.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.numbers.api.v1; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent; -import java.util.Map; - -/** - * Webhooks service - * - *

Callback events are used to get notified about Numbers usage according to your configured - * callback URL - * - *

see online - * documentation - * - * @since 1.2 - */ -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed using your Application key and secret pair - * found on your dashboard. The signature is included in the Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param secret The HMAC secret used for hashing the callback body using the HMAC-SHA1 algorithm - * and for creating the X-Sinch-Signature header. - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see online - * documentation - * @since 1.2.1 - */ - boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback. Function return Java - * class instance from un-serialized payload - * - * @param jsonPayload Received payload to be un-serialized - * @return The decoded event notification instance class - * @since 1.2 - */ - NumberEvent parseEvent(String jsonPayload) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/ActiveNumberServiceFacade.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/ActiveNumberServiceFacade.java index f165785bf..c9b50646a 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/ActiveNumberServiceFacade.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/ActiveNumberServiceFacade.java @@ -8,21 +8,16 @@ import com.sinch.sdk.domains.numbers.api.v1.NumbersService; import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber; import com.sinch.sdk.domains.numbers.models.v1.EmergencyAddress; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequestImpl; import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest; import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters.OrderByEnum; import com.sinch.sdk.domains.numbers.models.v1.request.EmergencyAddressRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern; -import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumberListResponse; +import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumbersListResponse; import com.sinch.sdk.domains.numbers.models.v1.response.ValidateAddressResponse; import com.sinch.sdk.models.NumbersContext; -import java.util.ArrayList; import java.util.Map; import java.util.function.Supplier; -public class ActiveNumberServiceFacade implements ActiveNumberService { +class ActiveNumberServiceFacade implements ActiveNumberService { private final ActiveNumberService activeNumberService; @@ -42,11 +37,6 @@ public ActiveNumberServiceFacade( numbersService); } - @Deprecated - public ActiveNumberListResponse list(ActiveNumberListRequest _parameters) throws ApiException { - return list(convert(_parameters)); - } - @Override public ActiveNumber get(String phoneNumber) throws ApiException { return activeNumberService.get(phoneNumber); @@ -86,37 +76,13 @@ public EmergencyAddress getEmergencyAddress(String phoneNumber) throws ApiExcept } @Override - public ActiveNumberListResponse list(ActiveNumbersListQueryParameters queryParameter) - throws ApiException { - return activeNumberService.list(queryParameter); + public ActiveNumbersListResponse list() throws ApiException { + return activeNumberService.list(); } - @Deprecated - public static ActiveNumbersListQueryParameters convert(ActiveNumberListRequest _parameters) + @Override + public ActiveNumbersListResponse list(ActiveNumbersListQueryParameters queryParameter) throws ApiException { - - if (null == _parameters) { - return null; - } - - ActiveNumberListRequestImpl parameters = (ActiveNumberListRequestImpl) _parameters; - - ActiveNumbersListQueryParameters.Builder builder = ActiveNumbersListQueryParameters.builder(); - - parameters.regionCode().ifPresent(builder::setRegionCode); - parameters.type().ifPresent(builder::setType); - parameters.capabilities().ifPresent(p -> builder.setCapabilities(new ArrayList<>(p))); - parameters.pageSize().ifPresent(builder::setPageSize); - - parameters.orderBy().ifPresent(p -> builder.setOrderBy(OrderByEnum.from(p.value()))); - - parameters.pageToken().ifPresent(builder::setPageToken); - - if (parameters.searchPattern().isPresent()) { - SearchPattern search = parameters.getSearchPattern(); - builder.setSearchPattern(search.getPattern()); - builder.setSearchPosition(search.getPosition()); - } - return builder.build(); + return activeNumberService.list(queryParameter); } } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/AvailableNumberServiceFacade.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/AvailableNumberServiceFacade.java index 91267d3ee..6da9566b2 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/AvailableNumberServiceFacade.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/AvailableNumberServiceFacade.java @@ -6,20 +6,16 @@ import com.sinch.sdk.core.http.HttpMapper; import com.sinch.sdk.domains.numbers.api.v1.AvailableNumberService; import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequestImpl; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentAnyRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumbersListQueryParameters; -import com.sinch.sdk.domains.numbers.models.v1.request.SearchPattern; import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumber; -import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse; +import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumbersListResponse; import com.sinch.sdk.models.NumbersContext; -import java.util.ArrayList; import java.util.Map; import java.util.function.Supplier; -public class AvailableNumberServiceFacade implements AvailableNumberService { +class AvailableNumberServiceFacade implements AvailableNumberService { private final AvailableNumberService availableNumberService; @@ -38,17 +34,11 @@ public AvailableNumberServiceFacade( } @Override - public AvailableNumberListResponse searchForAvailableNumbers( + public AvailableNumbersListResponse searchForAvailableNumbers( AvailableNumbersListQueryParameters queryParameter) throws ApiException { return availableNumberService.searchForAvailableNumbers(queryParameter); } - @Deprecated - public AvailableNumberListResponse searchForAvailableNumbers( - AvailableNumberListRequest _parameters) throws ApiException { - return searchForAvailableNumbers(convert(_parameters)); - } - @Override public AvailableNumber checkAvailability(String phoneNumber) throws ApiException { return availableNumberService.checkAvailability(phoneNumber); @@ -68,28 +58,4 @@ public ActiveNumber rent(String phoneNumber, AvailableNumberRentRequest paramete public ActiveNumber rentAny(AvailableNumberRentAnyRequest parameters) throws ApiException { return availableNumberService.rentAny(parameters); } - - @Deprecated - public static AvailableNumbersListQueryParameters convert(AvailableNumberListRequest _parameters) - throws ApiException { - - if (null == _parameters) { - return null; - } - AvailableNumberListRequestImpl parameters = (AvailableNumberListRequestImpl) _parameters; - AvailableNumbersListQueryParameters.Builder builder = - AvailableNumbersListQueryParameters.builder(); - - parameters.regionCode().ifPresent(builder::setRegionCode); - parameters.type().ifPresent(builder::setType); - parameters.capabilities().ifPresent(f -> builder.setCapabilities(new ArrayList<>(f))); - parameters.size().ifPresent(builder::setSize); - - if (parameters.searchPattern().isPresent()) { - SearchPattern search = parameters.getSearchPattern(); - builder.setSearchPattern(search.getPattern()); - builder.setSearchPosition(search.getPosition()); - } - return builder.build(); - } } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersService.java index cfc48b2f8..fbab255b7 100644 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersService.java +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersService.java @@ -8,20 +8,18 @@ import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.core.utils.StringUtil; import com.sinch.sdk.domains.numbers.api.v1.AvailableRegionsService; -import com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService; +import com.sinch.sdk.domains.numbers.api.v1.EventDestinationsService; import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber; import com.sinch.sdk.domains.numbers.models.v1.EmergencyAddress; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest; import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters; -import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberListRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentAnyRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumberRentRequest; import com.sinch.sdk.domains.numbers.models.v1.request.AvailableNumbersListQueryParameters; import com.sinch.sdk.domains.numbers.models.v1.request.EmergencyAddressRequest; -import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumberListResponse; +import com.sinch.sdk.domains.numbers.models.v1.response.ActiveNumbersListResponse; import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumber; -import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumberListResponse; +import com.sinch.sdk.domains.numbers.models.v1.response.AvailableNumbersListResponse; import com.sinch.sdk.domains.numbers.models.v1.response.ValidateAddressResponse; import com.sinch.sdk.models.NumbersContext; import com.sinch.sdk.models.UnifiedCredentials; @@ -48,8 +46,8 @@ public class NumbersService implements com.sinch.sdk.domains.numbers.api.v1.Numb private volatile AvailableNumberServiceFacade available; private volatile ActiveNumberServiceFacade active; private volatile AvailableRegionsService regions; - private volatile CallbackConfigurationService callback; - private volatile WebHooksService webhooks; + private volatile EventDestinationsService eventDestinations; + private volatile SinchEventsService sinchEvents; static { LocalLazyInit.init(); @@ -68,124 +66,150 @@ public NumbersService( AvailableNumberServiceFacade available() { if (null == this.available) { - instanceLazyInit(); - this.available = - new AvailableNumberServiceFacade(uriUUID, context, httpClientSupplier, authManagers); + synchronized (this) { + if (null == this.available) { + instanceLazyInit(); + this.available = + new AvailableNumberServiceFacade(uriUUID, context, httpClientSupplier, authManagers); + } + } } return this.available; } public AvailableRegionsService regions() { if (null == this.regions) { - instanceLazyInit(); - this.regions = - new AvailableRegionsServiceImpl( - httpClientSupplier.get(), - context.getNumbersServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + synchronized (this) { + if (null == this.regions) { + instanceLazyInit(); + this.regions = + new AvailableRegionsServiceImpl( + httpClientSupplier.get(), + context.getNumbersServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.regions; } ActiveNumberServiceFacade active() { if (null == this.active) { - instanceLazyInit(); - this.active = - new ActiveNumberServiceFacade(uriUUID, this, context, httpClientSupplier, authManagers); + synchronized (this) { + if (null == this.active) { + instanceLazyInit(); + this.active = + new ActiveNumberServiceFacade( + uriUUID, this, context, httpClientSupplier, authManagers); + } + } } return this.active; } - public CallbackConfigurationService callback() { - if (null == this.callback) { - instanceLazyInit(); - this.callback = - new CallbackConfigurationServiceImpl( - httpClientSupplier.get(), - context.getNumbersServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + public EventDestinationsService eventDestinations() { + if (null == this.eventDestinations) { + synchronized (this) { + if (null == this.eventDestinations) { + instanceLazyInit(); + this.eventDestinations = + new EventDestinationsServiceImpl( + httpClientSupplier.get(), + context.getNumbersServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } - return this.callback; + return this.eventDestinations; } - public WebHooksService webhooks() { - - if (null == this.webhooks) { - this.webhooks = new WebHooksService(new NumbersWebhooksAuthenticationValidation()); + public SinchEventsService sinchEvents() { + if (null == this.sinchEvents) { + synchronized (this) { + if (null == this.sinchEvents) { + this.sinchEvents = new SinchEventsService(new SinchEventsAuthenticationValidation()); + } + } } - return this.webhooks; + return this.sinchEvents; } - public AvailableNumberListResponse searchForAvailableNumbers( + @Override + public AvailableNumbersListResponse searchForAvailableNumbers( AvailableNumbersListQueryParameters parameters) throws ApiException { return available().searchForAvailableNumbers(parameters); } - @Deprecated - public AvailableNumberListResponse searchForAvailableNumbers( - AvailableNumberListRequest parameters) throws ApiException { - return available().searchForAvailableNumbers(parameters); - } - + @Override public AvailableNumber checkAvailability(String phoneNumber) throws ApiException { return available().checkAvailability(phoneNumber); } + @Override public ActiveNumber rent(String phoneNumber) throws ApiException { return available().rent(phoneNumber); } + @Override public ActiveNumber rent(String phoneNumber, AvailableNumberRentRequest parameters) throws ApiException { return available().rent(phoneNumber, parameters); } + @Override public ActiveNumber rentAny(AvailableNumberRentAnyRequest parameters) throws ApiException { return available().rentAny(parameters); } - @Deprecated - public ActiveNumberListResponse list(ActiveNumberListRequest parameters) throws ApiException { - return active().list(parameters); + @Override + public ActiveNumbersListResponse list() throws ApiException { + return active().list(); } @Override - public ActiveNumberListResponse list(ActiveNumbersListQueryParameters queryParameter) + public ActiveNumbersListResponse list(ActiveNumbersListQueryParameters queryParameter) throws ApiException { return active().list(queryParameter); } + @Override public ActiveNumber get(String phoneNumber) throws ApiException { return active().get(phoneNumber); } + @Override public ActiveNumber update(String phoneNumber, ActiveNumberUpdateRequest parameters) throws ApiException { return active().update(phoneNumber, parameters); } + @Override public ActiveNumber release(String phoneNumber) throws ApiException { return active().release(phoneNumber); } + @Override public ValidateAddressResponse validateEmergencyAddress( String phoneNumber, EmergencyAddressRequest emergencyAddressRequest) throws ApiException { return active().validateEmergencyAddress(phoneNumber, emergencyAddressRequest); } + @Override public EmergencyAddress provisionEmergencyAddress( String phoneNumber, EmergencyAddressRequest emergencyAddressRequest) throws ApiException { return active().provisionEmergencyAddress(phoneNumber, emergencyAddressRequest); } + @Override public void deprovisionEmergencyAddress(String phoneNumber) throws ApiException { active().deprovisionEmergencyAddress(phoneNumber); } + @Override public EmergencyAddress getEmergencyAddress(String phoneNumber) throws ApiException { return active().getEmergencyAddress(phoneNumber); } diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersWebhooksAuthenticationValidation.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersWebhooksAuthenticationValidation.java deleted file mode 100644 index 261e3560d..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersWebhooksAuthenticationValidation.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.sinch.sdk.domains.numbers.api.v1.adapters; - -import com.sinch.sdk.core.exceptions.ApiAuthException; -import com.sinch.sdk.core.utils.MapUtils; -import com.sinch.sdk.core.utils.StringUtil; -import java.nio.charset.StandardCharsets; -import java.security.InvalidKeyException; -import java.security.NoSuchAlgorithmException; -import java.util.Map; -import java.util.Objects; -import javax.crypto.Mac; -import javax.crypto.spec.SecretKeySpec; - -public class NumbersWebhooksAuthenticationValidation { - - public static final String SIGNATURE_HEADER = "X-Sinch-Signature"; - static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; - - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - - // convert header keys to use case-insensitive map keys - String signatureHeader = MapUtils.getCaseInsensitiveMap(headers).get(SIGNATURE_HEADER); - - // missing authorization header(s) - if (StringUtil.isEmpty(secret) || StringUtil.isEmpty(signatureHeader)) { - return false; - } - - String signedData = encode(secret, jsonPayload); - - return Objects.equals(signatureHeader, signedData); - } - - private String encode(String secret, String stringToSign) { - try { - SecretKeySpec secretKeySpec = - new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), HMAC_SHA1_ALGORITHM); - Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); - mac.init(secretKeySpec); - byte[] hmacSha256 = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)); - return NumbersWebhooksAuthenticationValidation.bytesToHex(hmacSha256); - } catch (NoSuchAlgorithmException | InvalidKeyException e) { - throw new ApiAuthException(e); - } - } - - private static String bytesToHex(byte[] hash) { - StringBuilder hexString = new StringBuilder(2 * hash.length); - for (byte h : hash) { - String hex = Integer.toHexString(0xff & h); - if (hex.length() == 1) hexString.append('0'); - hexString.append(hex); - } - return hexString.toString(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsAuthenticationValidation.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsAuthenticationValidation.java new file mode 100644 index 000000000..5afabd3e4 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsAuthenticationValidation.java @@ -0,0 +1,57 @@ +package com.sinch.sdk.domains.numbers.api.v1.adapters; + +import com.sinch.sdk.core.exceptions.ApiAuthException; +import com.sinch.sdk.core.utils.MapUtils; +import com.sinch.sdk.core.utils.StringUtil; +import java.nio.charset.StandardCharsets; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.Map; +import java.util.Objects; +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +public class SinchEventsAuthenticationValidation { + + public static final String SIGNATURE_HEADER = "X-Sinch-Signature"; + static final String HMAC_SHA1_ALGORITHM = "HmacSHA1"; + + public boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload) { + + // convert header keys to use case-insensitive map keys + String signatureHeader = MapUtils.getCaseInsensitiveMap(headers).get(SIGNATURE_HEADER); + + // missing authorization header(s) + if (StringUtil.isEmpty(secret) || StringUtil.isEmpty(signatureHeader)) { + return false; + } + + String signedData = encode(secret, jsonPayload); + + return Objects.equals(signatureHeader, signedData); + } + + private String encode(String secret, String stringToSign) { + try { + SecretKeySpec secretKeySpec = + new SecretKeySpec(secret.getBytes(StandardCharsets.UTF_8), HMAC_SHA1_ALGORITHM); + Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM); + mac.init(secretKeySpec); + byte[] hmacSHA1 = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8)); + return SinchEventsAuthenticationValidation.bytesToHex(hmacSHA1); + } catch (NoSuchAlgorithmException | InvalidKeyException e) { + throw new ApiAuthException(e); + } + } + + private static String bytesToHex(byte[] hash) { + StringBuilder hexString = new StringBuilder(2 * hash.length); + for (byte h : hash) { + String hex = Integer.toHexString(0xff & h); + if (hex.length() == 1) hexString.append('0'); + hexString.append(hex); + } + return hexString.toString(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsService.java new file mode 100644 index 000000000..c48c93b62 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsService.java @@ -0,0 +1,31 @@ +package com.sinch.sdk.domains.numbers.api.v1.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.numbers.models.v1.sinchevents.NumberSinchEvent; +import java.util.Map; + +public class SinchEventsService implements com.sinch.sdk.domains.numbers.api.v1.SinchEventsService { + private final SinchEventsAuthenticationValidation authenticationChecker; + + public SinchEventsService(SinchEventsAuthenticationValidation authenticationChecker) { + this.authenticationChecker = authenticationChecker; + } + + @Override + public boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload) { + return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); + } + + @Override + public NumberSinchEvent parseEvent(String jsonPayload) throws ApiMappingException { + + try { + return Mapper.getInstance().readValue(jsonPayload, NumberSinchEvent.class); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/WebHooksService.java deleted file mode 100644 index e89f1cfc2..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/WebHooksService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.numbers.api.v1.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent; -import java.util.Map; - -public class WebHooksService implements com.sinch.sdk.domains.numbers.api.v1.WebHooksService { - private final NumbersWebhooksAuthenticationValidation authenticationChecker; - - public WebHooksService(NumbersWebhooksAuthenticationValidation authenticationChecker) { - this.authenticationChecker = authenticationChecker; - } - - @Override - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); - } - - @Override - public NumberEvent parseEvent(String jsonPayload) throws ApiMappingException { - - try { - return Mapper.getInstance().readValue(jsonPayload, NumberEvent.class); - } catch (JsonProcessingException e) { - throw new ApiMappingException(jsonPayload, e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java deleted file mode 100644 index 854c4dcdd..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/ActiveNumber.java +++ /dev/null @@ -1,288 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * Active Number - * - * @since 1.0 - */ -public class ActiveNumber { - private final String phoneNumber; - - private final String projectId; - - private final String displayName; - - private final String regionCode; - - private final NumberType type; - - private final Collection capability; - - private final Money money; - - private final Integer paymentIntervalMonths; - - private final Instant nextChargeDate; - - private final Instant expireAt; - - private final SMSConfiguration smsConfiguration; - - private final VoiceConfiguration voiceConfiguration; - - private final String callbackUrl; - - /** - * @param phoneNumber The phone number in E.164 format with leading +. Example: +12025550134. - * @param projectId Project ID. Your project ID can be found on your Sinch Customer Dashboard. - * @param displayName User supplied name for the phone number. - * @param regionCode ISO 3166-1 alpha-2 country code of the phone number. Example US, UK or SE. - * @param type The number type. - * @param capability The capability of the number - * @param money An object giving details on currency code and the amount charged. - * @param paymentIntervalMonths How often the recurring price is charged in months. - * @param nextChargeDate The date of the next charge - * @param expireAt The timestamp when the subscription will expire if an expiration date has been - * set. - * @param smsConfiguration The current SMS configuration for this number. - * @param voiceConfiguration The current voice configuration for this number. - * @param callbackUrl The callback URL to be called for a rented number's provisioning / - * deprovisioning operations. - */ - public ActiveNumber( - String phoneNumber, - String projectId, - String displayName, - String regionCode, - NumberType type, - Collection capability, - Money money, - Integer paymentIntervalMonths, - Instant nextChargeDate, - Instant expireAt, - SMSConfiguration smsConfiguration, - VoiceConfiguration voiceConfiguration, - String callbackUrl) { - this.phoneNumber = phoneNumber; - this.projectId = projectId; - this.displayName = displayName; - this.regionCode = regionCode; - this.type = type; - this.capability = capability; - this.money = money; - this.paymentIntervalMonths = paymentIntervalMonths; - this.nextChargeDate = nextChargeDate; - this.expireAt = expireAt; - this.smsConfiguration = smsConfiguration; - this.voiceConfiguration = voiceConfiguration; - this.callbackUrl = callbackUrl; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public String getProjectId() { - return projectId; - } - - public String getDisplayName() { - return displayName; - } - - public String getRegionCode() { - return regionCode; - } - - public NumberType getType() { - return type; - } - - public Collection getCapability() { - return capability; - } - - public Money getMoney() { - return money; - } - - public Integer getPaymentIntervalMonths() { - return paymentIntervalMonths; - } - - public Instant getNextChargeDate() { - return nextChargeDate; - } - - public Instant getExpireAt() { - return expireAt; - } - - public SMSConfiguration getSmsConfiguration() { - return smsConfiguration; - } - - public VoiceConfiguration getVoiceConfiguration() { - return voiceConfiguration; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "ActiveNumber{" - + "phoneNumber='" - + phoneNumber - + '\'' - + ", projectId='" - + projectId - + '\'' - + ", displayName='" - + displayName - + '\'' - + ", regionCode='" - + regionCode - + '\'' - + ", type=" - + type - + ", capability=" - + capability - + ", money=" - + money - + ", paymentIntervalMonths=" - + paymentIntervalMonths - + ", nextChargeDate=" - + nextChargeDate - + ", expireAt=" - + expireAt - + ", smsConfiguration=" - + smsConfiguration - + ", voiceConfiguration=" - + voiceConfiguration - + ", callbackUrl='" - + callbackUrl - + '\'' - + '}'; - } - - public static class Builder { - private String phoneNumber; - - private String projectId; - - private String displayName; - - private String regionCode; - - private NumberType type; - - private Collection capability; - - private Money money; - - private Integer paymentIntervalMonths; - - private Instant nextChargeDate; - - private Instant expireAt; - - private SMSConfiguration smsConfiguration; - - private VoiceConfiguration voiceConfiguration; - - private String callbackUrl; - - private Builder() {} - - public ActiveNumber build() { - return new ActiveNumber( - phoneNumber, - projectId, - displayName, - regionCode, - type, - capability, - money, - paymentIntervalMonths, - nextChargeDate, - expireAt, - smsConfiguration, - voiceConfiguration, - callbackUrl); - } - - public Builder setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - public Builder setProjectId(String projectId) { - this.projectId = projectId; - return this; - } - - public Builder setDisplayName(String displayName) { - this.displayName = displayName; - return this; - } - - public Builder setRegionCode(String regionCode) { - this.regionCode = regionCode; - return this; - } - - public Builder setType(NumberType type) { - this.type = type; - return this; - } - - public Builder setCapability(Collection capability) { - this.capability = capability; - return this; - } - - public Builder setMoney(Money money) { - this.money = money; - return this; - } - - public Builder setPaymentIntervalMonths(Integer paymentIntervalMonths) { - this.paymentIntervalMonths = paymentIntervalMonths; - return this; - } - - public Builder setNextChargeDate(Instant nextChargeDate) { - this.nextChargeDate = nextChargeDate; - return this; - } - - public Builder setExpireAt(Instant expireAt) { - this.expireAt = expireAt; - return this; - } - - public Builder setSmsConfiguration(SMSConfiguration smsConfiguration) { - this.smsConfiguration = smsConfiguration; - return this; - } - - public Builder setVoiceConfiguration(VoiceConfiguration voiceConfiguration) { - this.voiceConfiguration = voiceConfiguration; - return this; - } - - public Builder setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java b/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java deleted file mode 100644 index 77f929409..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/AvailableNumber.java +++ /dev/null @@ -1,189 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.util.Collection; - -/** - * Active Number - * - * @since 1.0 - */ -public class AvailableNumber { - private final String phoneNumber; - - private final String regionCode; - - private final NumberType type; - - private final Collection capability; - - private final Money setupPrice; - - private final Money monthlyPrice; - - private final Integer paymentIntervalMonths; - - private final Boolean supportingDocumentationRequired; - - /** - * @param phoneNumber The phone number in E.164 format with leading +. Example +12025550134. - * @param regionCode ISO 3166-1 alpha-2 country code of the phone number. Example: US, UK or SE. - * @param type The number type. - * @param capability The capability of the number. - * @param setupPrice An object giving details on currency code and the amount charged. - * @param monthlyPrice An object giving details on currency code and the amount charged. - * @param paymentIntervalMonths How often the recurring price is charged in months. - * @param supportingDocumentationRequired Whether or not supplementary documentation will be - * required to complete the number rental. - */ - public AvailableNumber( - String phoneNumber, - String regionCode, - NumberType type, - Collection capability, - Money setupPrice, - Money monthlyPrice, - Integer paymentIntervalMonths, - Boolean supportingDocumentationRequired) { - this.phoneNumber = phoneNumber; - this.regionCode = regionCode; - this.type = type; - this.capability = capability; - this.setupPrice = setupPrice; - this.monthlyPrice = monthlyPrice; - this.paymentIntervalMonths = paymentIntervalMonths; - this.supportingDocumentationRequired = supportingDocumentationRequired; - } - - public String getPhoneNumber() { - return phoneNumber; - } - - public String getRegionCode() { - return regionCode; - } - - public NumberType getType() { - return type; - } - - public Collection getCapability() { - return capability; - } - - public Money getSetupPrice() { - return setupPrice; - } - - public Money getMonthlyPrice() { - return monthlyPrice; - } - - public Integer getPaymentIntervalMonths() { - return paymentIntervalMonths; - } - - public Boolean getSupportingDocumentationRequired() { - return supportingDocumentationRequired; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "AvailableNumber{" - + "phoneNumber='" - + phoneNumber - + '\'' - + ", regionCode='" - + regionCode - + '\'' - + ", type='" - + type - + '\'' - + ", capability=" - + capability - + ", setupPrice=" - + setupPrice - + ", monthlyPrice=" - + monthlyPrice - + ", paymentIntervalMonths=" - + paymentIntervalMonths - + ", supportingDocumentationRequired=" - + supportingDocumentationRequired - + '}'; - } - - public static class Builder { - private String phoneNumber; - - private String regionCode; - - private NumberType type; - - private Collection capability; - - private Money setupPrice; - - private Money monthlyPrice; - - private Integer paymentIntervalMonths; - - private Boolean supportingDocumentationRequired; - - private Builder() {} - - public AvailableNumber build() { - return new AvailableNumber( - phoneNumber, - regionCode, - type, - capability, - setupPrice, - monthlyPrice, - paymentIntervalMonths, - supportingDocumentationRequired); - } - - public Builder setPhoneNumber(String phoneNumber) { - this.phoneNumber = phoneNumber; - return this; - } - - public Builder setRegionCode(String regionCode) { - this.regionCode = regionCode; - return this; - } - - public Builder setType(NumberType type) { - this.type = type; - return this; - } - - public Builder setCapability(Collection capability) { - this.capability = capability; - return this; - } - - public Builder setSetupPrice(Money setupPrice) { - this.setupPrice = setupPrice; - return this; - } - - public Builder setMonthlyPrice(Money monthlyPrice) { - this.monthlyPrice = monthlyPrice; - return this; - } - - public Builder setPaymentIntervalMonths(Integer paymentIntervalMonths) { - this.paymentIntervalMonths = paymentIntervalMonths; - return this; - } - - public Builder setSupportingDocumentationRequired(Boolean supportingDocumentationRequired) { - this.supportingDocumentationRequired = supportingDocumentationRequired; - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java deleted file mode 100644 index f24915c25..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/CallbackConfiguration.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -/** - * Callback configuration - * - * @since 1.0 - */ -public class CallbackConfiguration { - private final String projectId; - - private final String hmacSecret; - - /** - * @param projectId ID of the project the configuration belongs to. - * @param hmacSecret The HMAC secret used for creating the callbacks X-Sinch-Signature header. - */ - public CallbackConfiguration(String projectId, String hmacSecret) { - this.projectId = projectId; - this.hmacSecret = hmacSecret; - } - - public String getProjectId() { - return projectId; - } - - public String getHMACSecret() { - return hmacSecret; - } - - @Override - public String toString() { - // do not output secret ! - return "CallbackConfiguration{" - + "projectId='" - + projectId - + '\'' - + ", hmacSecret='" - + "..." - + '\'' - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String projectId; - - private String hmacSecret; - - private Builder() {} - - public CallbackConfiguration build() { - return new CallbackConfiguration(projectId, hmacSecret); - } - - public Builder setProjectId(String projectId) { - this.projectId = projectId; - return this; - } - - public Builder setHMACSecret(String hmacSecret) { - this.hmacSecret = hmacSecret; - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java deleted file mode 100644 index 801d31379..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/Capability.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Capability of a phone number - * - * @since 1.0 - */ -public final class Capability extends EnumDynamic { - /** The SMS product can use the number. */ - public static final Capability SMS = new Capability("SMS"); - - /** The Voice product can use the number. */ - public static final Capability VOICE = new Capability("VOICE"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>(Capability.class, Capability::new, Arrays.asList(SMS, VOICE)); - - private Capability(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static Capability from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(Capability e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java deleted file mode 100644 index 83e5da434..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/Money.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -/** - * An object giving details on currency code and the amount charged. - * - * @since 1.0 - */ -public class Money { - private final String currencyCode; - - private final Double amount; - - /** - * @param currencyCode The 3-letter currency code defined in ISO 4217. - * @param amount The amount. There are no guarantees on the precision unless documented by the - * message origin. The amount cannot be updated and is read-only. - */ - public Money(String currencyCode, Double amount) { - this.currencyCode = currencyCode; - this.amount = amount; - } - - public String getCurrencyCode() { - return currencyCode; - } - - public Double getAmount() { - return amount; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "Money{" + "currencyCode='" + currencyCode + '\'' + ", amount='" + amount + '\'' + '}'; - } - - public static class Builder { - private String currencyCode; - - private Double amount; - - private Builder() {} - - public Builder setCurrencyCode(String value) { - this.currencyCode = value; - return this; - } - - public Builder setAmount(Double value) { - this.amount = value; - return this; - } - - public Money build() { - return new Money(this.currencyCode, this.amount); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java deleted file mode 100644 index 4d589a2ec..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberPattern.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -/** - * An object enabling to identify number by pattern - * - * @since 1.0 - */ -public class NumberPattern { - - private final String pattern; - private final SearchPattern searchPattern; - - /** - * @param pattern Sequence of digits to search for. - * @param searchPattern The pattern to apply to searches - */ - public NumberPattern(String pattern, SearchPattern searchPattern) { - this.pattern = pattern; - this.searchPattern = searchPattern; - } - - public String getPattern() { - return pattern; - } - - public SearchPattern getSearchPattern() { - return searchPattern; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "NumberPattern{" - + "pattern='" - + pattern - + '\'' - + ", searchPattern='" - + searchPattern - + '\'' - + '}'; - } - - public static class Builder { - private String pattern; - - private SearchPattern searchPattern; - - private Builder() {} - - public Builder setPattern(String value) { - this.pattern = value; - return this; - } - - public Builder setSearchPattern(SearchPattern value) { - this.searchPattern = value; - return this; - } - - public NumberPattern build() { - return new NumberPattern(this.pattern, this.searchPattern); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java b/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java deleted file mode 100644 index 0b354cfbd..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/NumberType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Type of phone number - * - * @since 1.0 - */ -public final class NumberType extends EnumDynamic { - - /** Numbers that belong to a specific range. */ - public static final NumberType MOBILE = new NumberType("MOBILE"); - - /** Numbers that are assigned to a specific geographic region. */ - public static final NumberType LOCAL = new NumberType("LOCAL"); - - /** Numbers that are free of charge for the calling party but billed for all arriving calls. */ - public static final NumberType TOLL_FREE = new NumberType("TOLL_FREE"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - NumberType.class, NumberType::new, Arrays.asList(MOBILE, LOCAL, TOLL_FREE)); - - private NumberType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static NumberType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(NumberType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java b/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java deleted file mode 100644 index 056274e14..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/OrderBy.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Supported fields for ordering - * - * @since 1.0 - */ -public final class OrderBy extends EnumDynamic { - /** Ordering by phoneNumber */ - public static final OrderBy PHONE_NUMBER = new OrderBy("phoneNumber"); - - /** Ordering by displayName */ - public static final OrderBy DISPLAY_NAME = new OrderBy("displayName"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - OrderBy.class, OrderBy::new, Arrays.asList(PHONE_NUMBER, DISPLAY_NAME)); - - private OrderBy(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static OrderBy from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(OrderBy e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java deleted file mode 100644 index 4bd5e95b6..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/ProvisioningStatus.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Provisioning Status - * - * @see https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/ - * @since 1.0 - */ -public final class ProvisioningStatus extends EnumDynamic { - - public static final ProvisioningStatus PROVISIONING_STATUS_UNSPECIFIED = - new ProvisioningStatus("PROVISIONING_STATUS_UNSPECIFIED"); - public static final ProvisioningStatus WAITING = new ProvisioningStatus("WAITING"); - public static final ProvisioningStatus IN_PROGRESS = new ProvisioningStatus("IN_PROGRESS"); - public static final ProvisioningStatus FAILED = new ProvisioningStatus("FAILED"); - public static final ProvisioningStatus UNKNOWN_DEFAULT_OPEN_API = - new ProvisioningStatus("UNKNOWN_DEFAULT_OPEN_API"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - ProvisioningStatus.class, - ProvisioningStatus::new, - Arrays.asList( - PROVISIONING_STATUS_UNSPECIFIED, - WAITING, - IN_PROGRESS, - FAILED, - UNKNOWN_DEFAULT_OPEN_API)); - - ProvisioningStatus(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static ProvisioningStatus from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(ProvisioningStatus e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java b/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java deleted file mode 100644 index dba8f7ca3..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/Region.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.util.Collection; - -/** - * Region information related to assigned numbers - * - * @since 1.0 - */ -public class Region { - private final String regionCode; - - private final String regionName; - - private final Collection types; - - /** - * @param regionCode ISO 3166-1 alpha-2 region code. Examples: US, UK or SE. - * @param regionName Display name of the region. Examples: United States, United Kingdom or - * Sweden. - * @param types A list of the different number types available. - */ - public Region(String regionCode, String regionName, Collection types) { - this.regionCode = regionCode; - this.regionName = regionName; - this.types = types; - } - - public String getRegionCode() { - return regionCode; - } - - public String getRegionName() { - return regionName; - } - - public Collection getTypes() { - return types; - } - - @Override - public String toString() { - return "AvailableRegion{" - + "regionCode='" - + regionCode - + '\'' - + ", regionName='" - + regionName - + '\'' - + ", types=" - + types - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String regionCode; - - private String regionName; - - private Collection types; - - private Builder() {} - - public Region build() { - return new Region(regionCode, regionName, types); - } - - public Builder setRegionCode(String regionCode) { - this.regionCode = regionCode; - return this; - } - - public Builder setRegionName(String regionName) { - this.regionName = regionName; - return this; - } - - public Builder setTypes(Collection types) { - this.types = types; - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java deleted file mode 100644 index 678d92c7b..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/SMSConfiguration.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.util.Optional; - -/** The SMS configuration for a number */ -public class SMSConfiguration { - private final String servicePlanId; - - private final String campaignId; - - private final ScheduledSmsProvisioning scheduledSmsProvisioning; - - /** - * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The - * service plan ID is what ties this to the configured SMS service. - * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic to - * US; click here to read more about 10DLC A2P messaging. So, it is the current campaign ID - * for this number. The campaignId is found on your TCR platform. - * @param scheduledSmsProvisioning This object is temporary and will appear while the scheduled - * provisioning for SMS is processing. Once it has successfully processed, only the ID of the - * SMS configuration will display. - */ - public SMSConfiguration( - String servicePlanId, String campaignId, ScheduledSmsProvisioning scheduledSmsProvisioning) { - this.servicePlanId = servicePlanId; - this.campaignId = campaignId; - this.scheduledSmsProvisioning = scheduledSmsProvisioning; - } - - public String getServicePlanId() { - return servicePlanId; - } - - public Optional getCampaignId() { - return Optional.ofNullable(campaignId); - } - - public Optional getScheduledSmsProvisioning() { - return Optional.ofNullable(scheduledSmsProvisioning); - } - - @Override - public String toString() { - return "SMSConfiguration{" - + "servicePlanId='" - + servicePlanId - + '\'' - + ", campaignId='" - + campaignId - + '\'' - + ", scheduledSmsProvisioning=" - + scheduledSmsProvisioning - + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java b/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java deleted file mode 100644 index 33f57ca07..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/ScheduledSmsProvisioning.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * Scheduled SMS provisioning information - * - *

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

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

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

For example, to search for area code 206 in the US, you would enter, %2b1206 - */ - public static final SearchPattern START = new SearchPattern("START"); - - /** - * The number pattern entered is contained somewhere in the number, the location being undefined. - */ - public static final SearchPattern CONTAINS = new SearchPattern("CONTAINS"); - - /** The number ends with the number pattern entered. */ - public static final SearchPattern END = new SearchPattern("END"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - SearchPattern.class, SearchPattern::new, Arrays.asList(START, CONTAINS, END)); - - private SearchPattern(String value) { - super(value); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java b/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java deleted file mode 100644 index 6b84e001b..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/SmsErrorCode.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Errors used in SMS Scheduled Provisioning configuration by the Numbers API - * - * @see https://developers.sinch.com/docs/numbers/api-reference/error-codes/provisioning-errors/ - * @since 1.0 - */ -public final class SmsErrorCode extends EnumDynamic { - public static final SmsErrorCode ERROR_CODE_UNSPECIFIED = - new SmsErrorCode("ERROR_CODE_UNSPECIFIED"); - public static final SmsErrorCode INTERNAL_ERROR = new SmsErrorCode("INTERNAL_ERROR"); - public static final SmsErrorCode SMS_PROVISIONING_FAILED = - new SmsErrorCode("SMS_PROVISIONING_FAILED"); - public static final SmsErrorCode CAMPAIGN_PROVISIONING_FAILED = - new SmsErrorCode("CAMPAIGN_PROVISIONING_FAILED"); - public static final SmsErrorCode CAMPAIGN_NOT_AVAILABLE = - new SmsErrorCode("CAMPAIGN_NOT_AVAILABLE"); - public static final SmsErrorCode EXCEEDED_10DLC_LIMIT = new SmsErrorCode("EXCEEDED_10DLC_LIMIT"); - public static final SmsErrorCode NUMBER_PROVISIONING_FAILED = - new SmsErrorCode("NUMBER_PROVISIONING_FAILED"); - public static final SmsErrorCode PARTNER_SERVICE_UNAVAILABLE = - new SmsErrorCode("PARTNER_SERVICE_UNAVAILABLE"); - public static final SmsErrorCode CAMPAIGN_PENDING_ACCEPTANCE = - new SmsErrorCode("CAMPAIGN_PENDING_ACCEPTANCE"); - public static final SmsErrorCode MNO_SHARING_ERROR = new SmsErrorCode("MNO_SHARING_ERROR"); - public static final SmsErrorCode CAMPAIGN_EXPIRED = new SmsErrorCode("CAMPAIGN_EXPIRED"); - public static final SmsErrorCode CAMPAIGN_MNO_REJECTED = - new SmsErrorCode("CAMPAIGN_MNO_REJECTED"); - public static final SmsErrorCode CAMPAIGN_MNO_SUSPENDED = - new SmsErrorCode("CAMPAIGN_MNO_SUSPENDED"); - public static final SmsErrorCode CAMPAIGN_MNO_REVIEW = new SmsErrorCode("CAMPAIGN_MNO_REVIEW"); - public static final SmsErrorCode INSUFFICIENT_BALANCE = new SmsErrorCode("INSUFFICIENT_BALANCE"); - public static final SmsErrorCode MOCK_CAMPAIGN_NOT_ALLOWED = - new SmsErrorCode("MOCK_CAMPAIGN_NOT_ALLOWED"); - public static final SmsErrorCode TFN_NOT_ALLOWED = new SmsErrorCode("TFN_NOT_ALLOWED"); - public static final SmsErrorCode INVALID_NNID = new SmsErrorCode("INVALID_NNID"); - public static final SmsErrorCode UNKNOWN_DEFAULT_OPEN_API = - new SmsErrorCode("UNKNOWN_DEFAULT_OPEN_API"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - SmsErrorCode.class, - SmsErrorCode::new, - Arrays.asList( - ERROR_CODE_UNSPECIFIED, - INTERNAL_ERROR, - SMS_PROVISIONING_FAILED, - CAMPAIGN_PROVISIONING_FAILED, - CAMPAIGN_NOT_AVAILABLE, - EXCEEDED_10DLC_LIMIT, - NUMBER_PROVISIONING_FAILED, - PARTNER_SERVICE_UNAVAILABLE, - CAMPAIGN_PENDING_ACCEPTANCE, - MNO_SHARING_ERROR, - CAMPAIGN_EXPIRED, - CAMPAIGN_MNO_REJECTED, - CAMPAIGN_MNO_SUSPENDED, - CAMPAIGN_MNO_REVIEW, - INSUFFICIENT_BALANCE, - MOCK_CAMPAIGN_NOT_ALLOWED, - TFN_NOT_ALLOWED, - INVALID_NNID, - UNKNOWN_DEFAULT_OPEN_API)); - - SmsErrorCode(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static SmsErrorCode from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(SmsErrorCode e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java b/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java deleted file mode 100644 index d596c3803..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/VoiceConfiguration.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.sinch.sdk.domains.numbers.models; - -import java.time.Instant; -import java.util.Optional; - -/** - * The voice configuration for a number - * - * @since 1.0 - */ -public class VoiceConfiguration { - private final String appId; - - private final Instant lastUpdatedTime; - - private final ScheduledVoiceProvisioning scheduledVoiceProvisioning; - - /** - * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer - * Dashboard under Voice, then apps. - * @param lastUpdatedTime when the status was last updated - * @param scheduledVoiceProvisioning This object is temporary and will appear while the scheduled - * voice provisioning is processing. Once it has successfully processed, only the ID of the - * Voice configuration will display. - */ - public VoiceConfiguration( - String appId, - Instant lastUpdatedTime, - ScheduledVoiceProvisioning scheduledVoiceProvisioning) { - this.appId = appId; - this.lastUpdatedTime = lastUpdatedTime; - this.scheduledVoiceProvisioning = scheduledVoiceProvisioning; - } - - public String getAppId() { - return appId; - } - - public Optional getLastUpdatedTime() { - return Optional.ofNullable(lastUpdatedTime); - } - - public Optional getScheduledVoiceProvisioning() { - return Optional.ofNullable(scheduledVoiceProvisioning); - } - - @Override - public String toString() { - return "VoiceConfiguration{" - + "appId='" - + appId - + '\'' - + ", lastUpdatedTime=" - + lastUpdatedTime - + ", scheduledVoiceProvisioning=" - + scheduledVoiceProvisioning - + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java deleted file mode 100644 index 43f7cbed4..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberListRequestParameters.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.Capability; -import com.sinch.sdk.domains.numbers.models.NumberPattern; -import com.sinch.sdk.domains.numbers.models.NumberType; -import com.sinch.sdk.domains.numbers.models.OrderBy; -import java.util.Collection; - -/** - * Parameters request to list active numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/ - * @since 1.0 - */ -public class ActiveNumberListRequestParameters { - - private final OptionalValue regionCode; - private final OptionalValue type; - private final OptionalValue numberPattern; - private final OptionalValue> capabilities; - private final OptionalValue pageSize; - private final OptionalValue pageToken; - private final OptionalValue orderBy; - - private ActiveNumberListRequestParameters( - OptionalValue regionCode, - OptionalValue type, - OptionalValue numberPattern, - OptionalValue> capabilities, - OptionalValue pageSize, - OptionalValue pageToken, - OptionalValue orderBy) { - this.regionCode = regionCode; - this.type = type; - this.numberPattern = numberPattern; - this.capabilities = capabilities; - this.pageSize = pageSize; - this.pageToken = pageToken; - this.orderBy = orderBy; - } - - public OptionalValue getRegionCode() { - return regionCode; - } - - public OptionalValue getType() { - return type; - } - - public OptionalValue getNumberPattern() { - return numberPattern; - } - - public OptionalValue> getCapabilities() { - return capabilities; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public OptionalValue getPageToken() { - return pageToken; - } - - public OptionalValue getOrderBy() { - return orderBy; - } - - @Override - public String toString() { - return "ActiveNumberListRequestParameters{" - + "regionCode='" - + regionCode - + '\'' - + ", type=" - + type - + ", numberPattern=" - + numberPattern - + ", capabilities=" - + capabilities - + ", pageSize=" - + pageSize - + ", pageToken=" - + pageToken - + ", orderBy=" - + orderBy - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(ActiveNumberListRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue regionCode = OptionalValue.empty(); - OptionalValue type = OptionalValue.empty(); - OptionalValue numberPattern = OptionalValue.empty(); - OptionalValue> capabilities = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - OptionalValue pageToken = OptionalValue.empty(); - OptionalValue orderBy = OptionalValue.empty(); - - private Builder() {} - - private Builder(ActiveNumberListRequestParameters parameters) { - parameters.regionCode.ifPresent(this::setRegionCode); - parameters.type.ifPresent(this::setType); - parameters.numberPattern.ifPresent(this::setNumberPattern); - parameters.capabilities.ifPresent(this::setCapabilities); - parameters.pageSize.ifPresent(this::setPageSize); - parameters.pageToken.ifPresent(this::setPageToken); - parameters.orderBy.ifPresent(this::setOrderBy); - } - - /** - * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone - * number. Example: US, GB or SE. - * @return Current builder - */ - public Builder setRegionCode(String regionCode) { - this.regionCode = OptionalValue.of(regionCode); - return this; - } - - /** - * @param type Number type to filter by - * @return Current builder - */ - public Builder setType(NumberType type) { - this.type = OptionalValue.of(type); - return this; - } - - /** - * @param numberPattern Pattern to search for - * @return Current builder - */ - public Builder setNumberPattern(NumberPattern numberPattern) { - this.numberPattern = OptionalValue.of(numberPattern); - return this; - } - - /** - * @param capabilities Number capabilities to filter by - * @return Current builder - */ - public Builder setCapabilities(Collection capabilities) { - this.capabilities = OptionalValue.of(capabilities); - return this; - } - - /** - * @param pageSize The maximum number of items to return. - * @return Current builder - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - /** - * @param pageToken The next page token value returned from a previous List request, if any - * @return Current builder - */ - public Builder setPageToken(String pageToken) { - this.pageToken = OptionalValue.of(pageToken); - return this; - } - - /** - * @param orderBy Ordering results - * @return Current builder - */ - public Builder setOrderBy(OrderBy orderBy) { - this.orderBy = OptionalValue.of(orderBy); - return this; - } - - public ActiveNumberListRequestParameters build() { - return new ActiveNumberListRequestParameters( - regionCode, type, numberPattern, capabilities, pageSize, pageToken, orderBy); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java deleted file mode 100644 index 8c5253a96..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateRequestParameters.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Parameters request to update an active number for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/#tag/Active-Number/operation/NumberService_UpdateActiveNumber - * @since 1.0 - */ -public class ActiveNumberUpdateRequestParameters { - private final OptionalValue displayName; - private final OptionalValue smsConfiguration; - private final OptionalValue - voiceConfiguration; - private final OptionalValue callback; - - private ActiveNumberUpdateRequestParameters( - OptionalValue displayName, - OptionalValue smsConfiguration, - OptionalValue voiceConfiguration, - OptionalValue callback) { - this.displayName = displayName; - this.smsConfiguration = smsConfiguration; - this.voiceConfiguration = voiceConfiguration; - this.callback = callback; - } - - public OptionalValue getDisplayName() { - return displayName; - } - - public OptionalValue getSmsConfiguration() { - return smsConfiguration; - } - - public OptionalValue - getVoiceConfiguration() { - return voiceConfiguration; - } - - public OptionalValue getCallback() { - return callback; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue displayName = OptionalValue.empty(); - OptionalValue smsConfiguration = - OptionalValue.empty(); - OptionalValue voiceConfiguration = - OptionalValue.empty(); - OptionalValue callback = OptionalValue.empty(); - - private Builder() {} - - /** - * @param displayName User supplied name for the phone number - * @return current builder - */ - public Builder setDisplayName(String displayName) { - this.displayName = OptionalValue.of(displayName); - return this; - } - - /** - * @param smsConfiguration The current SMS configuration for this number - * @return current builder - */ - public Builder setSmsConfiguration( - ActiveNumberUpdateSMSConfigurationRequestParameters smsConfiguration) { - this.smsConfiguration = OptionalValue.of(smsConfiguration); - return this; - } - - /** - * @param voiceConfiguration The current voice configuration for this number - * @return current builder - */ - public Builder setVoiceConfiguration( - ActiveNumberUpdateVoiceConfigurationRequestParameters voiceConfiguration) { - this.voiceConfiguration = OptionalValue.of(voiceConfiguration); - return this; - } - - /** - * @param callback The callback URL to be called for a rented number's provisioning / - * deprovisioning operations ({@link com.sinch.sdk.domains.numbers.WebHooksService see - * WebHooksService}) - * @return current builder - */ - public Builder setCallback(String callback) { - this.callback = OptionalValue.of(callback); - return this; - } - - public ActiveNumberUpdateRequestParameters build() { - return new ActiveNumberUpdateRequestParameters( - displayName, smsConfiguration, voiceConfiguration, callback); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java deleted file mode 100644 index 74e936caf..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateSMSConfigurationRequestParameters.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/*** - * SMS configuration parameters request to update an active number for a project - * @since 1.0 - */ -public class ActiveNumberUpdateSMSConfigurationRequestParameters { - - private final OptionalValue servicePlanId; - private final OptionalValue campaignId; - - private ActiveNumberUpdateSMSConfigurationRequestParameters( - OptionalValue servicePlanId, OptionalValue campaignId) { - this.servicePlanId = servicePlanId; - this.campaignId = campaignId; - } - - public OptionalValue getServicePlanId() { - return servicePlanId; - } - - public OptionalValue getCampaignId() { - return campaignId; - } - - @Override - public String toString() { - return "ActiveNumberUpdateSMSConfigurationRequestParameters{" - + "servicePlanId='" - + servicePlanId - + '\'' - + ", campaignId=" - + campaignId - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue servicePlanId = OptionalValue.empty(); - - OptionalValue campaignId = OptionalValue.empty(); - - private Builder() {} - - /** - * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The - * service plan ID is what ties this number to the configured SMS service. - * @return current builder - */ - public Builder setServicePlanId(String servicePlanId) { - this.servicePlanId = OptionalValue.of(servicePlanId); - return this; - } - - /** - * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic - * to US; click here to read more about 10DLC A2P messaging. So, it is the current campaign - * ID for this number. The campaignId is found on your TCR platform. - * @return current builder - */ - public Builder setCampaignId(String campaignId) { - this.campaignId = OptionalValue.of(campaignId); - return this; - } - - public ActiveNumberUpdateSMSConfigurationRequestParameters build() { - return new ActiveNumberUpdateSMSConfigurationRequestParameters(servicePlanId, campaignId); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java deleted file mode 100644 index 0c8c9fdea..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/ActiveNumberUpdateVoiceConfigurationRequestParameters.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/*** - * SMS configuration parameters request to update an active number for a project - * @since 1.0 - */ - -public class ActiveNumberUpdateVoiceConfigurationRequestParameters { - private final OptionalValue appId; - - private ActiveNumberUpdateVoiceConfigurationRequestParameters(OptionalValue appId) { - this.appId = appId; - } - - public OptionalValue getAppId() { - return appId; - } - - @Override - public String toString() { - return "ActiveNumberUpdateVoiceConfigurationRequestParameters{" - + "appId='" - + appId - + '\'' - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue appId = OptionalValue.empty(); - - private Builder() {} - - /** - * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer - * Dashboard under Voice, then apps. - * @return current builder - */ - public Builder setAppId(String appId) { - this.appId = OptionalValue.of(appId); - return this; - } - - public ActiveNumberUpdateVoiceConfigurationRequestParameters build() { - return new ActiveNumberUpdateVoiceConfigurationRequestParameters(appId); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java deleted file mode 100644 index 4e00bf779..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberListAllRequestParameters.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.Capability; -import com.sinch.sdk.domains.numbers.models.NumberPattern; -import com.sinch.sdk.domains.numbers.models.NumberType; -import java.util.Collection; - -/** - * Parameters request to list available numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ - * @since 1.0 - */ -public class AvailableNumberListAllRequestParameters { - private final OptionalValue regionCode; - private final OptionalValue type; - private final OptionalValue numberPattern; - private final OptionalValue> capabilities; - private final OptionalValue size; - - private AvailableNumberListAllRequestParameters( - OptionalValue regionCode, - OptionalValue type, - OptionalValue numberPattern, - OptionalValue> capabilities, - OptionalValue size) { - this.regionCode = regionCode; - this.type = type; - this.numberPattern = numberPattern; - this.capabilities = capabilities; - this.size = size; - } - - public OptionalValue getRegionCode() { - return regionCode; - } - - public OptionalValue getType() { - return type; - } - - public OptionalValue getNumberPattern() { - return numberPattern; - } - - public OptionalValue> getCapabilities() { - return capabilities; - } - - public OptionalValue getSize() { - return size; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue regionCode = OptionalValue.empty(); - OptionalValue type = OptionalValue.empty(); - OptionalValue numberPattern = OptionalValue.empty(); - OptionalValue> capabilities = OptionalValue.empty(); - OptionalValue size = OptionalValue.empty(); - - private Builder() {} - - /** - * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone - * number. Example: US, GB or SE. - * @return current builder - */ - public Builder setRegionCode(String regionCode) { - this.regionCode = OptionalValue.of(regionCode); - return this; - } - - /** - * @param type Number type to filter by - * @return current builder - */ - public Builder setType(NumberType type) { - this.type = OptionalValue.of(type); - return this; - } - - /** - * @return current builder - */ - public Builder setNumberPattern(NumberPattern numberPattern) { - this.numberPattern = OptionalValue.of(numberPattern); - return this; - } - - /** - * @return current builder - */ - public Builder setCapabilities(Collection capabilities) { - this.capabilities = OptionalValue.of(capabilities); - return this; - } - - /** - * @param size Optional. The maximum number of items to return. - * @return current builder - */ - public Builder setSize(Integer size) { - this.size = OptionalValue.of(size); - return this; - } - - public AvailableNumberListAllRequestParameters build() { - return new AvailableNumberListAllRequestParameters( - regionCode, type, numberPattern, capabilities, size); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java deleted file mode 100644 index 9a53b7e53..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentAnyRequestParameters.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.Capability; -import com.sinch.sdk.domains.numbers.models.NumberPattern; -import com.sinch.sdk.domains.numbers.models.NumberType; -import java.util.Collection; - -/** - * Parameters request to rent a number using criteria - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ - * @since 1.0 - */ -public class AvailableNumberRentAnyRequestParameters { - private final OptionalValue regionCode; - private final OptionalValue type; - private final OptionalValue numberPattern; - private final OptionalValue> capabilities; - private final OptionalValue smsConfiguration; - private final OptionalValue voiceConfiguration; - private final OptionalValue callbackUrl; - - private AvailableNumberRentAnyRequestParameters( - OptionalValue regionCode, - OptionalValue type, - OptionalValue numberPattern, - OptionalValue> capabilities, - OptionalValue smsConfiguration, - OptionalValue voiceConfiguration, - OptionalValue callbackUrl) { - this.regionCode = regionCode; - this.type = type; - this.numberPattern = numberPattern; - this.capabilities = capabilities; - this.smsConfiguration = smsConfiguration; - this.voiceConfiguration = voiceConfiguration; - this.callbackUrl = callbackUrl; - } - - public OptionalValue getRegionCode() { - return regionCode; - } - - public OptionalValue getType() { - return type; - } - - public OptionalValue getNumberPattern() { - return numberPattern; - } - - public OptionalValue> getCapabilities() { - return capabilities; - } - - public OptionalValue getSmsConfiguration() { - return smsConfiguration; - } - - public OptionalValue getVoiceConfiguration() { - return voiceConfiguration; - } - - public OptionalValue getCallBackUrl() { - return callbackUrl; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue regionCode = OptionalValue.empty(); - OptionalValue type = OptionalValue.empty(); - OptionalValue numberPattern = OptionalValue.empty(); - OptionalValue> capabilities = OptionalValue.empty(); - OptionalValue smsConfiguration = OptionalValue.empty(); - OptionalValue voiceConfiguration = - OptionalValue.empty(); - OptionalValue callbackUrl = OptionalValue.empty(); - - private Builder() {} - - /** - * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone - * number. Example: US, GB or SE. - * @return current builder - */ - public Builder setRegionCode(String regionCode) { - this.regionCode = OptionalValue.of(regionCode); - return this; - } - - /** - * @param type Number type to filter by - * @return current builder - */ - public Builder setType(NumberType type) { - this.type = OptionalValue.of(type); - return this; - } - - /** - * @param numberPattern Search pattern - * @return current builder - */ - public Builder setNumberPattern(NumberPattern numberPattern) { - this.numberPattern = OptionalValue.of(numberPattern); - return this; - } - - /** - * @param capabilities Capabilities to filter by - * @return current builder - */ - public Builder setCapabilities(Collection capabilities) { - this.capabilities = OptionalValue.of(capabilities); - return this; - } - - /** - * @param smsConfiguration The current SMS configuration for this number - * @return current builder - */ - public Builder setSmsConfiguration(RentSMSConfigurationRequestParameters smsConfiguration) { - this.smsConfiguration = OptionalValue.of(smsConfiguration); - return this; - } - - /** - * @param voiceConfiguration The current voice configuration for this number - * @return current builder - */ - public Builder setVoiceConfiguration( - RentVoiceConfigurationRequestParameters voiceConfiguration) { - this.voiceConfiguration = OptionalValue.of(voiceConfiguration); - return this; - } - - /** - * @param callbackUrl The callback URL to be called for a rented number's provisioning / - * de-provisioning operations ({@link com.sinch.sdk.domains.numbers.WebHooksService see - * WebHooksService}) - * @return current builder - */ - public Builder setCallbackUrl(String callbackUrl) { - this.callbackUrl = OptionalValue.of(callbackUrl); - return this; - } - - public AvailableNumberRentAnyRequestParameters build() { - return new AvailableNumberRentAnyRequestParameters( - regionCode, - type, - numberPattern, - capabilities, - smsConfiguration, - voiceConfiguration, - callbackUrl); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java deleted file mode 100644 index 065d4624e..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableNumberRentRequestParameters.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Parameters request to rent a number - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_RentNumber - * @since 1.0 - */ -public class AvailableNumberRentRequestParameters { - private final OptionalValue smsConfiguration; - private final OptionalValue voiceConfiguration; - private final OptionalValue callbackUrl; - - private AvailableNumberRentRequestParameters( - OptionalValue smsConfiguration, - OptionalValue voiceConfiguration, - OptionalValue callbackUrl) { - this.smsConfiguration = smsConfiguration; - this.voiceConfiguration = voiceConfiguration; - this.callbackUrl = callbackUrl; - } - - public OptionalValue getSmsConfiguration() { - return smsConfiguration; - } - - public OptionalValue getVoiceConfiguration() { - return voiceConfiguration; - } - - public OptionalValue getCallBackUrl() { - return callbackUrl; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue smsConfiguration = OptionalValue.empty(); - OptionalValue voiceConfiguration = - OptionalValue.empty(); - OptionalValue callbackUrl = OptionalValue.empty(); - - private Builder() {} - - /** - * @param smsConfiguration The current SMS configuration for this number - * @return current builder - */ - public Builder setSmsConfiguration(RentSMSConfigurationRequestParameters smsConfiguration) { - this.smsConfiguration = OptionalValue.of(smsConfiguration); - return this; - } - - /** - * @param voiceConfiguration The current voice configuration for this number. During scheduled - * provisioning, the app ID value may be empty in a response if it is still processing or if - * it has failed. The status of scheduled provisioning will show under a - * scheduledVoiceProvisioning object if it's still running. Once processed successfully, the - * appId sent will appear directly under the voiceConfiguration object. - * @return current builder - */ - public Builder setVoiceConfiguration( - RentVoiceConfigurationRequestParameters voiceConfiguration) { - this.voiceConfiguration = OptionalValue.of(voiceConfiguration); - return this; - } - - /** - * @param callbackUrl The callback URL to be called for a rented number's provisioning / - * de-provisioning operations. - * @return current builder - */ - public Builder setCallbackUrl(String callbackUrl) { - this.callbackUrl = OptionalValue.of(callbackUrl); - return this; - } - - public AvailableNumberRentRequestParameters build() { - return new AvailableNumberRentRequestParameters( - smsConfiguration, voiceConfiguration, callbackUrl); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java deleted file mode 100644 index 771392203..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/AvailableRegionListAllRequestParameters.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.NumberType; -import java.util.Collection; - -/** - * Parameters request to list all regions by criteria - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Regions/ - * @since 1.0 - */ -public class AvailableRegionListAllRequestParameters { - - private final OptionalValue> types; - - private AvailableRegionListAllRequestParameters(OptionalValue> types) { - this.types = types; - } - - public OptionalValue> getTypes() { - return types; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue> types = OptionalValue.empty(); - - private Builder() {} - - /** - * @param types Only return regions for which numbers are provided with the given types - * @return current builder - */ - public Builder setTypes(Collection types) { - this.types = OptionalValue.of(types); - return this; - } - - public AvailableRegionListAllRequestParameters build() { - return new AvailableRegionListAllRequestParameters(types); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java deleted file mode 100644 index 8b0402d7c..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/CallbackConfigurationUpdateRequestParameters.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Parameters request to update callback configuration - * - * @see https://developers.sinch.com/docs/numbers/api-reference/callbacks-numbers/tag/Callback-Configuration/#tag/Callback-Configuration/operation/UpdateCallbackConfiguration - * @since 1.0 - */ -public class CallbackConfigurationUpdateRequestParameters { - /** */ - private final OptionalValue hmacSecret; - - private CallbackConfigurationUpdateRequestParameters(OptionalValue hmacSecret) { - this.hmacSecret = hmacSecret; - } - - public OptionalValue getHMACSecret() { - return hmacSecret; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue hmacSecret = OptionalValue.empty(); - - private Builder() {} - - /*** - * - * @param hmacSecret The HMAC secret to be updated for the specified project - * @return current builder - */ - public Builder setHMACSecret(String hmacSecret) { - this.hmacSecret = OptionalValue.of(hmacSecret); - return this; - } - - public CallbackConfigurationUpdateRequestParameters build() { - return new CallbackConfigurationUpdateRequestParameters(hmacSecret); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java deleted file mode 100644 index 5361c7ef0..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentSMSConfigurationRequestParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * SMS configuration parameters request to rent a number - * - * @since 1.0 - */ -public class RentSMSConfigurationRequestParameters { - private final OptionalValue servicePlanId; - private final OptionalValue campaignId; - - private RentSMSConfigurationRequestParameters( - OptionalValue servicePlanId, OptionalValue campaignId) { - this.servicePlanId = servicePlanId; - this.campaignId = campaignId; - } - - public OptionalValue getServicePlanId() { - return servicePlanId; - } - - public OptionalValue getCampaignId() { - return this.campaignId; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue servicePlanId = OptionalValue.empty(); - OptionalValue campaignId = OptionalValue.empty(); - - private Builder() {} - - /** - * @param servicePlanId The servicePlanId can be found in the Sinch Customer Dashboard. The - * service plan ID is what ties this number to the configured SMS service. - * @return current builder - */ - public Builder setServicePlanId(String servicePlanId) { - this.servicePlanId = OptionalValue.of(servicePlanId); - return this; - } - - /** - * @param campaignId Only for US phone numbers. This campaignId is required to send SMS traffic - * to US; click here to read more about 10DLC A2P messaging. So, it is the current campaign - * ID for this number. The campaignId is found on your TCR platform. - */ - public Builder setCampaignId(String campaignId) { - this.campaignId = OptionalValue.of(campaignId); - return this; - } - - public RentSMSConfigurationRequestParameters build() { - return new RentSMSConfigurationRequestParameters(servicePlanId, campaignId); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java deleted file mode 100644 index 50e870f96..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/RentVoiceConfigurationRequestParameters.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Voice configuration parameters request to rent a number - * - * @since 1.0 - */ -public class RentVoiceConfigurationRequestParameters { - private final OptionalValue appId; - - private RentVoiceConfigurationRequestParameters(OptionalValue appId) { - this.appId = appId; - } - - public OptionalValue getAppId() { - return appId; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue appId = OptionalValue.empty(); - - private Builder() {} - - /** - * @param appId Your app ID for the Voice API. The appId can be found in your Sinch Customer - * Dashboard under Voice, then apps. - * @return current builder - */ - public Builder setAppId(String appId) { - this.appId = OptionalValue.of(appId); - return this; - } - - public RentVoiceConfigurationRequestParameters build() { - return new RentVoiceConfigurationRequestParameters(appId); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java deleted file mode 100644 index baf5491db..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/requests/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Numbers API requests related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.numbers.models.requests; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java deleted file mode 100644 index 4321f1509..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/ActiveNumberListResponse.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.numbers.ActiveNumberService; -import com.sinch.sdk.domains.numbers.models.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.requests.ActiveNumberListRequestParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all active numbers for a project - * - * @since 1.0 - */ -public class ActiveNumberListResponse extends ListResponse { - - private final Page page; - private final ActiveNumberService service; - - public ActiveNumberListResponse( - ActiveNumberService service, - Page page) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - public ActiveNumberListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - ActiveNumberListRequestParameters.Builder newParameters = - ActiveNumberListRequestParameters.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "ActiveNumberListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java deleted file mode 100644 index b33104958..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableNumberListResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.domains.numbers.models.AvailableNumber; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all available numbers - * - * @since 1.0 - */ -public class AvailableNumberListResponse extends ListResponse { - - Collection content; - - public AvailableNumberListResponse(Collection list) { - this.content = list; - } - - public boolean hasNextPage() { - return false; - } - - public AvailableNumberListResponse nextPage() { - throw new NoSuchElementException("Reached the last page of the API response"); - } - - public Collection getContent() { - return content; - } - - @Override - public String toString() { - return "AvailableNumberListResponse{" + "content=" + content + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java deleted file mode 100644 index 927a6ede2..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/AvailableRegionListResponse.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.domains.numbers.models.Region; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all regions for numbers provided for the project ID. - * - * @since 1.0 - */ -public class AvailableRegionListResponse extends ListResponse { - - Collection content; - - public AvailableRegionListResponse(Collection list) { - this.content = list; - } - - public boolean hasNextPage() { - return false; - } - - public AvailableRegionListResponse nextPage() { - throw new NoSuchElementException("Reached the last page of the API response"); - } - - public Collection getContent() { - return content; - } - - @Override - public String toString() { - return "AvailableRegionListResponse{" + "content=" + content + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java deleted file mode 100644 index 9fa13e9f4..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/responses/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Numbers API response related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.numbers.models.responses; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/request/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/request/package-info.java deleted file mode 100644 index 617fd560e..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/request/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Numbers Callback Configuration API requests related models - * - * @since 1.2 - */ -package com.sinch.sdk.domains.numbers.models.v1.callbacks.request; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/response/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/response/package-info.java deleted file mode 100644 index d0e577f91..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/response/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Numbers Callback Configuration API responses related models - * - * @since 1.2 - */ -package com.sinch.sdk.domains.numbers.models.v1.callbacks.response; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/package-info.java new file mode 100644 index 000000000..38bb63e74 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers API Event Destinations related models + * + * @since 1.2 + */ +package com.sinch.sdk.domains.numbers.models.v1.eventdestinations; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/request/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/request/package-info.java new file mode 100644 index 000000000..952e29ceb --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/request/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers Event Destinations API requests related models + * + * @since 1.2 + */ +package com.sinch.sdk.domains.numbers.models.v1.eventdestinations.request; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/response/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/response/package-info.java new file mode 100644 index 000000000..cd838838a --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/eventdestinations/response/package-info.java @@ -0,0 +1,6 @@ +/** + * Numbers Event Destinations API responses related models + * + * @since 1.2 + */ +package com.sinch.sdk.domains.numbers.models.v1.eventdestinations.response; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/request/AvailableRegionListRequest.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/request/AvailableRegionListRequest.java deleted file mode 100644 index 3311f674d..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/request/AvailableRegionListRequest.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.regions.available.request; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import java.util.Collection; -import java.util.Objects; - -/** - * Parameters request to list all regions by criteria - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Regions/ - * @since 1.2 - */ -public class AvailableRegionListRequest { - - private final OptionalValue> types; - - private AvailableRegionListRequest(OptionalValue> types) { - this.types = types; - } - - public OptionalValue> getTypes() { - return types; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - OptionalValue> types = OptionalValue.empty(); - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Builder)) { - return false; - } - Builder builder = (Builder) o; - return Objects.equals(types, builder.types); - } - - @Override - public int hashCode() { - return Objects.hash(types); - } - - private Builder() {} - - /** - * @param types Only return regions for which numbers are provided with the given types - * @return current builder - */ - public Builder setTypes(Collection types) { - this.types = OptionalValue.of(types); - return this; - } - - public AvailableRegionListRequest build() { - return new AvailableRegionListRequest(types); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/response/AvailableRegionListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/response/AvailableRegionListResponse.java deleted file mode 100644 index 6298220b6..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/regions/available/response/AvailableRegionListResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.regions.available.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all available numbers for a project - * - * @since 1.2 - */ -public class AvailableRegionListResponse extends ListResponse { - - Collection content; - - public AvailableRegionListResponse(Collection content) { - this.content = content; - } - - public boolean hasNextPage() { - return false; - } - - public AvailableRegionListResponse nextPage() { - throw new NoSuchElementException("Reached the last page of the API response"); - } - - public Collection getContent() { - return content; - } - - @Override - public String toString() { - return "AvailableRegionListResponse{" + "content=" + content + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequest.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequest.java deleted file mode 100644 index c8b2409e8..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequest.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.request; - -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import java.util.Collection; - -/** - * Parameters request to list active numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/ - * @since 1.2 - */ -public interface ActiveNumberListRequest { - - /** - * @return Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. - *

Example: "US", "GB" or "SE". - */ - String getRegionCode(); - - /** - * @return Number type to filter by. - */ - NumberType getType(); - - /** - * @return Search criteria - */ - SearchPattern getSearchPattern(); - - /** - * @return Number capabilities to filter by. - */ - Collection getCapabilities(); - - /** - * @return The maximum number of items to return - */ - Integer getPageSize(); - - /** - * @return The next page token value returned from a previous List request, if any. - */ - String getPageToken(); - - /** - * @return Supported fields for ordering by. - */ - OrderBy getOrderBy(); - - static Builder builder() { - return new ActiveNumberListRequestImpl.Builder(); - } - - static Builder builder(ActiveNumberListRequest parameters) { - return new ActiveNumberListRequestImpl.Builder(parameters); - } - - public interface Builder { - - /** - * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone - * number. Example: US, GB or SE. - * @return Current builder - */ - Builder setRegionCode(String regionCode); - - /** - * @param type Number type to filter by - * @return Current builder - */ - Builder setType(NumberType type); - - /** - * @param searchPattern Pattern to search for - * @return Current builder - */ - Builder setSearchPattern(SearchPattern searchPattern); - - /** - * @param capabilities Number capabilities to filter by - * @return Current builder - */ - Builder setCapabilities(Collection capabilities); - - /** - * @param pageSize The maximum number of items to return. - * @return Current builder - */ - Builder setPageSize(Integer pageSize); - - /** - * @param pageToken The next page token value returned from a previous List request, if any - * @return Current builder - */ - Builder setPageToken(String pageToken); - - /** - * @param orderBy Ordering results - * @return Current builder - */ - Builder setOrderBy(OrderBy orderBy); - - ActiveNumberListRequest build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequestImpl.java deleted file mode 100644 index b9f4df84c..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/ActiveNumberListRequestImpl.java +++ /dev/null @@ -1,249 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.request; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import java.util.Collection; -import java.util.Objects; - -/** - * Parameters request to list active numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Active-Number/ - * @since 1.2 - */ -public class ActiveNumberListRequestImpl implements ActiveNumberListRequest { - - private final OptionalValue regionCode; - private final OptionalValue type; - private final OptionalValue searchPattern; - private final OptionalValue> capabilities; - private final OptionalValue pageSize; - private final OptionalValue pageToken; - private final OptionalValue orderBy; - - private ActiveNumberListRequestImpl( - OptionalValue regionCode, - OptionalValue type, - OptionalValue searchPattern, - OptionalValue> capabilities, - OptionalValue pageSize, - OptionalValue pageToken, - OptionalValue orderBy) { - this.regionCode = regionCode; - this.type = type; - this.searchPattern = searchPattern; - this.capabilities = capabilities; - this.pageSize = pageSize; - this.pageToken = pageToken; - this.orderBy = orderBy; - } - - public String getRegionCode() { - return regionCode.orElse(null); - } - - public OptionalValue regionCode() { - return regionCode; - } - - public NumberType getType() { - return type.orElse(null); - } - - public OptionalValue type() { - return type; - } - - public SearchPattern getSearchPattern() { - return searchPattern.orElse(null); - } - - public OptionalValue searchPattern() { - return searchPattern; - } - - public Collection getCapabilities() { - return capabilities.orElse(null); - } - - public OptionalValue> capabilities() { - return capabilities; - } - - public Integer getPageSize() { - return pageSize.orElse(null); - } - - public OptionalValue pageSize() { - return pageSize; - } - - public String getPageToken() { - return pageToken.orElse(null); - } - - public OptionalValue pageToken() { - return pageToken; - } - - public OrderBy getOrderBy() { - return orderBy.orElse(null); - } - - public OptionalValue orderBy() { - return orderBy; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof ActiveNumberListRequestImpl)) { - return false; - } - ActiveNumberListRequestImpl that = (ActiveNumberListRequestImpl) o; - return Objects.equals(getRegionCode(), that.getRegionCode()) - && Objects.equals(getType(), that.getType()) - && Objects.equals(getSearchPattern(), that.getSearchPattern()) - && Objects.equals(getCapabilities(), that.getCapabilities()) - && Objects.equals(getPageSize(), that.getPageSize()) - && Objects.equals(getPageToken(), that.getPageToken()) - && Objects.equals(getOrderBy(), that.getOrderBy()); - } - - @Override - public int hashCode() { - return Objects.hash( - getRegionCode(), - getType(), - getSearchPattern(), - getCapabilities(), - getPageSize(), - getPageToken(), - getOrderBy()); - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(ActiveNumberListRequest parameters) { - return new Builder(parameters); - } - - public static class Builder implements ActiveNumberListRequest.Builder { - - OptionalValue regionCode = OptionalValue.empty(); - OptionalValue type = OptionalValue.empty(); - OptionalValue searchPattern = OptionalValue.empty(); - OptionalValue> capabilities = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - OptionalValue pageToken = OptionalValue.empty(); - OptionalValue orderBy = OptionalValue.empty(); - - protected Builder() {} - - protected Builder(ActiveNumberListRequest _parameters) { - ActiveNumberListRequestImpl parameters = (ActiveNumberListRequestImpl) _parameters; - parameters.regionCode.ifPresent(this::setRegionCode); - parameters.type.ifPresent(this::setType); - parameters.searchPattern.ifPresent(this::setSearchPattern); - parameters.capabilities.ifPresent(this::setCapabilities); - parameters.pageSize.ifPresent(this::setPageSize); - parameters.pageToken.ifPresent(this::setPageToken); - parameters.orderBy.ifPresent(this::setOrderBy); - } - - /** - * see getter - * - * @param regionCode see getter - * @return Current builder - * @see #getRegionCode() - */ - public Builder setRegionCode(String regionCode) { - this.regionCode = OptionalValue.of(regionCode); - return this; - } - - /** - * see getter - * - * @param type see getter - * @return Current builder - * @see #getType - */ - public Builder setType(NumberType type) { - this.type = OptionalValue.of(type); - return this; - } - - /** - * see getter - * - * @param searchPattern see getter - * @return Current builder - * @see #getSearchPattern() - */ - public Builder setSearchPattern(SearchPattern searchPattern) { - this.searchPattern = OptionalValue.of(searchPattern); - return this; - } - - /** - * see getter - * - * @param capabilities see getter - * @return Current builder - * @see #getCapabilities() - */ - public Builder setCapabilities(Collection capabilities) { - this.capabilities = OptionalValue.of(capabilities); - return this; - } - - /** - * see getter - * - * @param pageSize see getter - * @return Current builder - * @see #getPageSize() - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - /** - * see getter - * - * @param pageToken see getter - * @return Current builder - * @see #getPageToken() - */ - public Builder setPageToken(String pageToken) { - this.pageToken = OptionalValue.of(pageToken); - return this; - } - - /** - * see getter - * - * @param orderBy see getter - * @return Current builder - * @see #getOrderBy() - */ - public Builder setOrderBy(OrderBy orderBy) { - this.orderBy = OptionalValue.of(orderBy); - return this; - } - - public ActiveNumberListRequest build() { - return new ActiveNumberListRequestImpl( - regionCode, type, searchPattern, capabilities, pageSize, pageToken, orderBy); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequest.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequest.java deleted file mode 100644 index 712d3febc..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequest.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.request; - -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import java.util.Collection; - -/** - * Parameters request to list available numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ - * @since 1.2 - */ -public interface AvailableNumberListRequest { - - /** - * @return Region code to filter by. ISO 3166-1 alpha-2 country code of the phone number. Example: - * `US`, `GB` or `SE`. (required) - */ - String getRegionCode(); - - /** - * @return Number type to filter by. Options include, `MOBILE`, `LOCAL` or - * `TOLL_FREE`. (required) - */ - NumberType getType(); - - /** - * @return Search criteria - */ - SearchPattern getSearchPattern(); - - /** - * @return Number capabilities to filter by, `SMS` and/or `VOICE`. - */ - Collection getCapabilities(); - - /** - * @return The maximum number of items to return - */ - Integer getSize(); - - static Builder builder() { - return AvailableNumberListRequestImpl.builder(); - } - - interface Builder { - - /** - * @param regionCode Region code to filter by. ISO 3166-1 alpha-2 country code of the phone - * number. Example: US, GB or SE. - * @return current builder - */ - Builder setRegionCode(String regionCode); - - /** - * @param type Number type to filter by - * @return current builder - */ - Builder setType(NumberType type); - - /** - * @param searchPattern Search criteria - * @return current builder - */ - Builder setSearchPattern(SearchPattern searchPattern); - - /** - * @param capabilities capability criteria - * @return current builder - */ - Builder setCapabilities(Collection capabilities); - - /** - * @param size Optional. The maximum number of items to return. - * @return current builder - */ - Builder setSize(Integer size); - - AvailableNumberListRequest build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequestImpl.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequestImpl.java deleted file mode 100644 index 996025f4d..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/AvailableNumberListRequestImpl.java +++ /dev/null @@ -1,148 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.request; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.numbers.models.v1.Capability; -import com.sinch.sdk.domains.numbers.models.v1.NumberType; -import java.util.Collection; -import java.util.Objects; - -/** - * Parameters request to list available numbers for a project - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Available-Number/#tag/Available-Number/operation/NumberService_ListAvailableNumbers/ - * @since 1.2 - */ -public class AvailableNumberListRequestImpl implements AvailableNumberListRequest { - private final OptionalValue regionCode; - private final OptionalValue type; - private final OptionalValue searchPattern; - private final OptionalValue> capabilities; - private final OptionalValue size; - - private AvailableNumberListRequestImpl( - OptionalValue regionCode, - OptionalValue type, - OptionalValue searchPattern, - OptionalValue> capabilities, - OptionalValue size) { - this.regionCode = regionCode; - this.type = type; - this.searchPattern = searchPattern; - this.capabilities = capabilities; - this.size = size; - } - - public String getRegionCode() { - return regionCode.orElse(null); - } - - public OptionalValue regionCode() { - return regionCode; - } - - public NumberType getType() { - return type.orElse(null); - } - - public OptionalValue type() { - return type; - } - - public SearchPattern getSearchPattern() { - return searchPattern.orElse(null); - } - - public OptionalValue searchPattern() { - return searchPattern; - } - - public Collection getCapabilities() { - return capabilities.orElse(null); - } - - public OptionalValue> capabilities() { - return capabilities; - } - - public Integer getSize() { - return size.orElse(null); - } - - public OptionalValue size() { - return size; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof AvailableNumberListRequestImpl)) { - return false; - } - AvailableNumberListRequestImpl that = (AvailableNumberListRequestImpl) o; - return Objects.equals(getRegionCode(), that.getRegionCode()) - && Objects.equals(getType(), that.getType()) - && Objects.equals(getSearchPattern(), that.getSearchPattern()) - && Objects.equals(getCapabilities(), that.getCapabilities()) - && Objects.equals(getSize(), that.getSize()); - } - - @Override - public int hashCode() { - return Objects.hash( - getRegionCode(), getType(), getSearchPattern(), getCapabilities(), getSize()); - } - - public static class Builder implements AvailableNumberListRequest.Builder { - OptionalValue regionCode = OptionalValue.empty(); - OptionalValue type = OptionalValue.empty(); - OptionalValue searchPattern = OptionalValue.empty(); - OptionalValue> capabilities = OptionalValue.empty(); - OptionalValue size = OptionalValue.empty(); - - private Builder() {} - - public Builder setRegionCode(String regionCode) { - this.regionCode = OptionalValue.of(regionCode); - return this; - } - - public Builder setType(NumberType type) { - this.type = OptionalValue.of(type); - return this; - } - - public Builder setSearchPattern(SearchPattern searchPattern) { - this.searchPattern = OptionalValue.of(searchPattern); - return this; - } - - /** - * @return current builder - */ - public Builder setCapabilities(Collection capabilities) { - this.capabilities = OptionalValue.of(capabilities); - return this; - } - - /** - * @param size Optional. The maximum number of items to return. - * @return current builder - */ - public Builder setSize(Integer size) { - this.size = OptionalValue.of(size); - return this; - } - - public AvailableNumberListRequestImpl build() { - return new AvailableNumberListRequestImpl( - regionCode, type, searchPattern, capabilities, size); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/OrderBy.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/OrderBy.java deleted file mode 100644 index c0e6f1312..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/request/OrderBy.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.request; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Supported fields for ordering - * - * @since 1.2 - */ -public final class OrderBy extends EnumDynamic { - /** Ordering by phoneNumber */ - public static final OrderBy PHONE_NUMBER = new OrderBy("phoneNumber"); - - /** Ordering by displayName */ - public static final OrderBy DISPLAY_NAME = new OrderBy("displayName"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - OrderBy.class, OrderBy::new, Arrays.asList(PHONE_NUMBER, DISPLAY_NAME)); - - private OrderBy(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static OrderBy from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(OrderBy e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/ActiveNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/ActiveNumberListResponse.java deleted file mode 100644 index 77271fc5c..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/ActiveNumberListResponse.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.models.pagination.TokenPageNavigator; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.numbers.api.v1.NumbersService; -import com.sinch.sdk.domains.numbers.api.v1.adapters.ActiveNumberServiceFacade; -import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberListRequest; -import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumbersListQueryParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all active numbers for a project - * - * @since 1.2 - */ -public class ActiveNumberListResponse extends ListResponse { - - private final Page page; - private final NumbersService service; - - @Deprecated - public ActiveNumberListResponse( - NumbersService service, Page page) { - this.service = service; - this.page = - new Page<>( - ActiveNumberServiceFacade.convert(page.getParameters()), - page.getEntities(), - new TokenPageNavigator(page.getNextPageToken())); - } - - public ActiveNumberListResponse( - Page page, NumbersService service) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - return (null != page.getNextPageToken() && !StringUtil.isEmpty(page.getNextPageToken())); - } - - public ActiveNumberListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - ActiveNumbersListQueryParameters.Builder newParameters = - ActiveNumbersListQueryParameters.builder(page.getParameters()); - newParameters.setPageToken(page.getNextPageToken()); - return service.list(newParameters.build()); - } - - /** - * Do not use / Internal usage only - * - * @return Internal usage only - * @deprecated - */ - public String getNextPageToken() { - return page.getNextPageToken(); - } - - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "ActiveNumberListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/AvailableNumberListResponse.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/AvailableNumberListResponse.java deleted file mode 100644 index f65141b5b..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/response/AvailableNumberListResponse.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.v1.response; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists all available numbers for a project - * - * @since 1.2 - */ -public class AvailableNumberListResponse extends ListResponse { - - Collection content; - - public AvailableNumberListResponse(Collection content) { - this.content = content; - } - - public boolean hasNextPage() { - return false; - } - - public AvailableNumberListResponse nextPage() { - throw new NoSuchElementException("Reached the last page of the API response"); - } - - public Collection getContent() { - return content; - } - - @Override - public String toString() { - return "AvailableNumberListResponse{" + "content=" + content + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/sinchevents/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/sinchevents/package-info.java new file mode 100644 index 000000000..323aa4681 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/sinchevents/package-info.java @@ -0,0 +1,6 @@ +/** + * Models related to Numbers Sinch Events + * + * @since 1.2 + */ +package com.sinch.sdk.domains.numbers.models.v1.sinchevents; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/v1/webhooks/package-info.java deleted file mode 100644 index 6b5188549..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/v1/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Models related to Numbers WebHooks - * - * @since 1.2 - */ -package com.sinch.sdk.domains.numbers.models.v1.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventNotification.java b/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventNotification.java deleted file mode 100644 index 3b973281f..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventNotification.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.webhooks; - -import com.sinch.sdk.domains.numbers.models.SmsErrorCode; -import java.time.Instant; - -/** A notification of an event sent to your configured callback URL. */ -public class EventNotification { - - private final String eventId; - private final Instant timestamp; - private final String projectId; - private final String resourceId; - private final ResourceType resourceType; - private final EventType eventType; - private final EventStatus status; - private final SmsErrorCode failureCode; - - /** - * @param eventId The ID of the event - * @param timestamp The date and time when the callback was created and added to the callbacks - * queue - * @param projectId The ID of the project to which the event belongs - * @param resourceId The unique identifier of the resource, depending on the resource type. For - * example, a phone number, a hosting order ID, or a brand ID. - * @param resourceType The type of the resource - * @param eventType The type of the event - * @param status The status of the event - * @param failureCode If the status is FAILED, a failure code will be provided. For numbers - * provisioning to SMS platform, there won't be any extra failureCode, as the result is - * binary. For campaign provisioning-related failures, refer to the list for the possible - * values. - */ - public EventNotification( - String eventId, - Instant timestamp, - String projectId, - String resourceId, - ResourceType resourceType, - EventType eventType, - EventStatus status, - SmsErrorCode failureCode) { - this.eventId = eventId; - this.timestamp = timestamp; - this.projectId = projectId; - this.resourceId = resourceId; - this.resourceType = resourceType; - this.eventType = eventType; - this.status = status; - this.failureCode = failureCode; - } - - public String getEventId() { - return eventId; - } - - public Instant getTimestamp() { - return timestamp; - } - - public String getProjectId() { - return projectId; - } - - public String getResourceId() { - return resourceId; - } - - public ResourceType getResourceType() { - return resourceType; - } - - public EventType getEventType() { - return eventType; - } - - public EventStatus getStatus() { - return status; - } - - public SmsErrorCode getFailureCode() { - return failureCode; - } - - @Override - public String toString() { - return "EventNotification{" - + "eventId='" - + eventId - + '\'' - + ", timestamp=" - + timestamp - + ", projectId='" - + projectId - + '\'' - + ", resourceId='" - + resourceId - + '\'' - + ", resourceType=" - + resourceType - + ", eventType=" - + eventType - + ", status=" - + status - + ", failureCode=" - + failureCode - + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventStatus.java b/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventStatus.java deleted file mode 100644 index e37950021..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventStatus.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.webhooks; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -public final class EventStatus extends EnumDynamic { - - /** - * The status of the event - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Callbacks/#tag/Callbacks/operation/ImportedNumberService_EventsCallback!path=status&t=request/ - * @since 1.0 - */ - public static final EventStatus SUCCEEDED = new EventStatus("SUCCEEDED"); - - public static final EventStatus FAILED = new EventStatus("FAILED"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - EventStatus.class, EventStatus::new, Arrays.asList(SUCCEEDED, FAILED)); - - EventStatus(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static EventStatus from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(EventStatus e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventType.java b/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventType.java deleted file mode 100644 index b80898f15..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/EventType.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.webhooks; - -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 event - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Callbacks/#tag/Callbacks/operation/ImportedNumberService_EventsCallback!path=eventType&t=request - * @since 1.0 - */ -public final class EventType extends EnumDynamic { - - /** An event that occurs when a number is linked to a Service Plan ID. */ - public static final EventType PROVISIONING_TO_SMS_PLATFORM = - new EventType("PROVISIONING_TO_SMS_PLATFORM"); - - /** An event that occurs when a number is unlinked from a Service Plan ID */ - public static final EventType DEPROVISIONING_FROM_SMS_PLATFORM = - new EventType("DEPROVISIONING_FROM_SMS_PLATFORM"); - - /** An event that occurs when a number is linked to a Campaign */ - public static final EventType PROVISIONING_TO_CAMPAIGN = - new EventType("PROVISIONING_TO_CAMPAIGN"); - - /** An event that occurs when a number is unlinked from a Campaign */ - public static final EventType DEPROVISIONING_FROM_CAMPAIGN = - new EventType("DEPROVISIONING_FROM_CAMPAIGN"); - - /** An event that occurs when a number is enabled for Voice operations. */ - public static final EventType PROVISIONING_TO_VOICE_PLATFORM = - new EventType("PROVISIONING_TO_VOICE_PLATFORM"); - - /** An event that occurs when a number is disabled for Voice operations */ - public static final EventType DEPROVISIONING_TO_VOICE_PLATFORM = - new EventType("DEPROVISIONING_TO_VOICE_PLATFORM"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - EventType.class, - EventType::new, - Arrays.asList( - PROVISIONING_TO_SMS_PLATFORM, - DEPROVISIONING_FROM_SMS_PLATFORM, - PROVISIONING_TO_CAMPAIGN, - DEPROVISIONING_FROM_CAMPAIGN, - PROVISIONING_TO_VOICE_PLATFORM, - DEPROVISIONING_TO_VOICE_PLATFORM)); - - EventType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static EventType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(EventType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/ResourceType.java b/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/ResourceType.java deleted file mode 100644 index f6e9d860d..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/ResourceType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.numbers.models.webhooks; - -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 resource - * - * @see https://developers.sinch.com/docs/numbers/api-reference/numbers/tag/Callbacks/#tag/Callbacks/operation/ImportedNumberService_EventsCallback!path=resourceType&t=request - * @since 1.0 - */ -public final class ResourceType extends EnumDynamic { - - /** Numbers which are already active and updated with new campaign IDs or service plan IDs. */ - public static final ResourceType ACTIVE_NUMBER = new ResourceType("ACTIVE_NUMBER"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>(ResourceType.class, ResourceType::new, Arrays.asList(ACTIVE_NUMBER)); - - ResourceType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static ResourceType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(ResourceType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/package-info.java deleted file mode 100644 index cb0c2db7b..000000000 --- a/client/src/main/com/sinch/sdk/domains/numbers/models/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Numbers API webhooks (callback) related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.numbers.models.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java deleted file mode 100644 index 269dc9849..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/BatchesService.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.sinch.sdk.domains.sms; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.Batch; -import com.sinch.sdk.domains.sms.models.DryRun; -import com.sinch.sdk.domains.sms.models.requests.BatchesListRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.UpdateBaseBatchRequest; -import com.sinch.sdk.domains.sms.models.responses.BatchesListResponse; -import com.sinch.sdk.domains.sms.models.v1.batches.request.BatchRequest; -import com.sinch.sdk.domains.sms.models.v1.batches.request.DryRunQueryParameters; -import com.sinch.sdk.domains.sms.models.v1.batches.request.ListBatchesQueryParameters; -import com.sinch.sdk.domains.sms.models.v1.batches.request.SendDeliveryFeedbackRequest; -import com.sinch.sdk.domains.sms.models.v1.batches.request.UpdateBatchRequest; -import java.util.Collection; - -/** - * Batches Service - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/ - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService} instead. - */ -@Deprecated -public interface BatchesService { - - /** - * Get a batch message. - * - *

This operation returns a specific batch that matches the provided batch ID. - * - * @param batchId The batch ID you received from sending a message - * @param A type of Batch - * @return Batch information - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/GetBatchMessage - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService#get(String)} instead. - */ - @Deprecated - > T get(String batchId) throws ApiException; - - /** - * Send a message or a batch of messages. - * - *

Depending on the length of the body, one message might be split into multiple parts and - * charged accordingly.
- * Any groups targeted in a scheduled batch will be evaluated at the time of sending. If a group - * is deleted between batch creation and scheduled date, it will be considered empty.
- * Be sure to use the correct region in the server URL. - * - * @param batch The batch to be created - * @param A type of Batch - * @return Batch information - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/SendSMS - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService#send(BatchRequest)} - * instead. - */ - @Deprecated - > T send(BaseBatch batch) throws ApiException; - - /** - * Dry run. - * - *

This operation will perform a dry run of a batch which calculates the bodies and number of - * parts for all messages in the batch without actually sending any messages. - * - * @param perRecipient Whether to include per recipient details in the response - * @param numberOfRecipient Max number of recipients to include per recipient details for in the - * response - * @param batch The batch to be send - * @return Details about dryRun execution - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/Dry_Run - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.BatchesService#dryRun(DryRunQueryParameters, - * BatchRequest)} instead. - */ - @Deprecated - DryRun dryRun(boolean perRecipient, int numberOfRecipient, BaseBatch batch) - throws ApiException; - - /** - * List Batches. - * - *

With the list operation you can list batch messages created in the last 14 days that you - * have created. This operation supports pagination. - * - * @param parameters Query parameters filtering returned batches - * @return Paginated list of Batches - * @since 1.0 - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ListBatches - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.BatchesService#list(ListBatchesQueryParameters)} instead - */ - @Deprecated - BatchesListResponse list(BatchesListRequestParameters parameters) throws ApiException; - - /** - * Update a Batch message. - * - *

This operation updates all specified parameters of a batch that matches the provided batch - * ID. - * - * @param batchId The batch ID you received from sending a message - * @param batch Batch parameters to be updated - * @param A type of Batch - * @return Batch information - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/UpdateBatchMessage - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService#update(String, - * UpdateBatchRequest)} instead. - */ - @Deprecated - > T update(String batchId, UpdateBaseBatchRequest batch) - throws ApiException; - - /** - * Replace a batch . - * - *

This operation will replace all the parameters of a batch with the provided values. It is - * the same as cancelling a batch and sending a new one instead. - * - * @param batchId The batch ID you received from sending a message - * @param batch Batch parameters to be used - * @param A type of Batch - * @return Batch information - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ReplaceBatch - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService#replace(String, - * BatchRequest)} instead. - */ - @Deprecated - > T replace(String batchId, BaseBatch batch) throws ApiException; - - /** - * Cancel a batch message. - * - *

A batch can be canceled at any point. If a batch is canceled while it's currently being - * delivered some messages currently being processed might still be delivered. The delivery report - * will indicate which messages were canceled and which weren't.
- * Canceling a batch scheduled in the future will result in an empty delivery report while - * canceling an already sent batch would result in no change to the completed delivery report. - * - * @param batchId The batch ID you received from sending a message - * @param A type of Batch - * @return Batch information - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/CancelBatchMessage - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.BatchesService#cancel(String)} instead. - */ - @Deprecated - > T cancel(String batchId) throws ApiException; - - /** - * Send delivery feedback for a message. - * - *

Send feedback if your system can confirm successful message delivery. - * - *

Feedback can only be provided if feedback_enabled was set when batch was submitted. - * - *

Batches: It is possible to submit feedback multiple times for the same batch for - * different recipients. Feedback without specified recipients is treated as successful message - * delivery to all recipients referenced in the batch. Note that the recipients key is still - * required even if the value is empty. - * - *

Groups: If the batch message was creating using a group ID, at least one recipient - * is required. Excluding recipients (an empty recipient list) does not work and will result in a - * failed request. - * - * @param batchId The batch ID you received from sending a message - * @param recipients A list of phone numbers (MSISDNs) that have successfully received the - * message. The key is required, however, the value can be an empty array ([]) for a batch. If - * the feedback was enabled for a group, at least one phone number is required. - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/deliveryFeedback - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.BatchesService#sendDeliveryFeedback(String, - * SendDeliveryFeedbackRequest)} instead. - */ - @Deprecated - void sendDeliveryFeedback(String batchId, Collection recipients) throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java b/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java deleted file mode 100644 index 66dd30ac0..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/DeliveryReportsService.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.sinch.sdk.domains.sms; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.sms.models.DeliveryReportBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipient; -import com.sinch.sdk.domains.sms.models.requests.DeliveryReportBatchGetRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.DeliveryReportListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.DeliveryReportsListResponse; -import com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.BatchDeliveryReportQueryParameters; -import com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.ListDeliveryReportsQueryParameters; - -/** - * Delivery reports Service. - * - *

The REST API uses message statuses and error codes in delivery reports, which refer to the - * state of the batch and can be present in either Retrieve - * a delivery report or sent as a callback. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService} instead. - */ -@Deprecated -public interface DeliveryReportsService { - - /** - * Retrieve a batch delivery report. - * - *

Delivery reports can be retrieved even if no callback was requested. The difference between - * a summary and a full report is only that the full report contains the phone numbers in E.164 format for each status - * code. - * - * @param batchId The batch ID you received from sending a message param type param status param - * code - * @param parameters Filtering parameters - * @return Delivery report related to batchId according to filters - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByBatchId - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#get(String, - * BatchDeliveryReportQueryParameters)} instead. - */ - @Deprecated - DeliveryReportBatch get(String batchId, DeliveryReportBatchGetRequestParameters parameters) - throws ApiException; - - /** - * Retrieve a recipient delivery report. - * - *

A recipient delivery report contains the message status for a single recipient phone number. - * - * @param batchId The batch ID you received from sending a message param type param status param - * code - * @param recipient Phone number for which you to want to search - * @return Delivery report related to batchId according to filters - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/GetDeliveryReportByPhoneNumber - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#getForNumber(String, String)} - * instead. - */ - @Deprecated - DeliveryReportRecipient getForNumber(String batchId, String recipient) throws ApiException; - - /** - * Get a list of finished delivery reports. - * - *

This operation supports pagination. - * - * @param parameters Filtering parameters - * @return Delivery report related to batchId according to filters - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#list(ListDeliveryReportsQueryParameters)} - * instead. - */ - @Deprecated - DeliveryReportsListResponse list(DeliveryReportListRequestParameters parameters) - throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java b/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java deleted file mode 100644 index fdc15e41c..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/GroupsService.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.sinch.sdk.domains.sms; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.sms.models.Group; -import com.sinch.sdk.domains.sms.models.requests.GroupCreateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupReplaceRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupUpdateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupsListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.GroupsListResponse; -import com.sinch.sdk.domains.sms.models.v1.groups.request.GroupRequest; -import com.sinch.sdk.domains.sms.models.v1.groups.request.GroupUpdateRequest; -import com.sinch.sdk.domains.sms.models.v1.groups.request.ListGroupsQueryParameters; -import java.util.Collection; - -/** - * Groups Service - * - *

A group is a set of phone numbers (or MSISDNs) that can be used as a target when sending an - * SMS. An phone number (MSISDN) can only occur once in a group and any attempts to add a duplicate - * are ignored but not rejected. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService} instead. - */ -@Deprecated -public interface GroupsService { - - /** - * Retrieve a group. - * - *

This operation retrieves a specific group with the provided group ID. - * - * @param groupId The inbound ID found when listing inbound messages - * @return Group associated to groupId - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/RetrieveGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#get(String)} instead. - */ - @Deprecated - Group get(String groupId) throws ApiException; - - /** - * Create a group. - * - *

A group is a set of phone numbers (MSISDNs) that can be used as a target in the - * send_batch_msg operation. An MSISDN can only occur once in a group and any attempts to - * add a duplicate would be ignored but not rejected. - * - * @param parameters Parameters to be used to define group onto creation - * @return Created group - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/CreateGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#create(GroupRequest)} - * instead. - */ - @Deprecated - Group create(GroupCreateRequestParameters parameters) throws ApiException; - - /** - * Create an unnamed and empty group - * - * @return See {@link #create(GroupCreateRequestParameters)} - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#create(GroupRequest)} - * instead. - */ - @Deprecated - Group create() throws ApiException; - - /** - * List Groups - * - *

With the list operation you can list all groups that you have created. This operation - * supports pagination. - * - *

Groups are returned in reverse chronological order. - * - * @param parameters Filtering parameters - * @return group list - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ListGroups - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.GroupsService#list(ListGroupsQueryParameters)} instead. - */ - @Deprecated - GroupsListResponse list(GroupsListRequestParameters parameters) throws ApiException; - - /** - * List groups with default parameters - * - * @return See {@link #list(GroupsListRequestParameters)} - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#list()} instead. - */ - @Deprecated - GroupsListResponse list() throws ApiException; - - /** - * Replace a group - * - *

The replace operation will replace all parameters, including members, of an existing group - * with new values. - * - *

Replacing a group targeted by a batch message scheduled in the future is allowed and changes - * will be reflected when the batch is sent. - * - * @param groupId ID of a group that you are interested in getting. - * @param parameters Parameters to be replaced for group - * @return Group associated to groupId - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ReplaceGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#replace(String, - * GroupRequest)} instead. - */ - @Deprecated - Group replace(String groupId, GroupReplaceRequestParameters parameters) throws ApiException; - - /** - * Update a group - * - * @param groupId ID of a group that you are interested in getting. - * @param parameters Parameters to be used to update group - * @return Modified group associated to groupId - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/UpdateGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#update(String, - * GroupUpdateRequest)} instead. - */ - @Deprecated - Group update(String groupId, GroupUpdateRequestParameters parameters) throws ApiException; - - /** - * Delete a group - * - * @param groupId ID of a group that you are interested in getting. - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#delete(String)} instead. - */ - @Deprecated - void delete(String groupId) throws ApiException; - - /** - * Get phone numbers for a group - * - * @param groupId ID of a group that you are interested in getting. - * @return A list of phone numbers in E.164 format. - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/deleteGroup - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.GroupsService#listMembers(String)} - * instead. - */ - @Deprecated - Collection listMembers(String groupId) throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/InboundsService.java b/client/src/main/com/sinch/sdk/domains/sms/InboundsService.java deleted file mode 100644 index e09029323..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/InboundsService.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.sinch.sdk.domains.sms; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.sms.models.Inbound; -import com.sinch.sdk.domains.sms.models.requests.InboundsListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.InboundsListResponse; -import com.sinch.sdk.domains.sms.models.v1.inbounds.request.ListInboundMessagesQueryParameters; - -/** - * Inbounds Service - * - *

Inbounds, or Mobile Originated (MO) messages, are incoming messages. Inbound messages can be - * listed and retrieved like batch messages and they can also be delivered by callback requests like - * delivery reports. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/ - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.InboundsService} instead. - */ -@Deprecated -public interface InboundsService { - - /** - * List incoming messages - * - *

With the list operation, you can list all inbound messages that you have received. This - * operation supports pagination. Inbounds are returned in reverse chronological order. - * - * @param parameters Filtering parameters - * @return Incoming messages - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.sms.api.v1.InboundsService#list(ListInboundMessagesQueryParameters)} - * instead. - */ - @Deprecated - InboundsListResponse list(InboundsListRequestParameters parameters) throws ApiException; - - /** - * Retrieve inbound message - * - *

This operation retrieves a specific inbound message with the provided inbound ID - * - * @param inboundId The inbound ID found when listing inbound messages - * @return Inbound messages- - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Inbounds/#tag/Inbounds/operation/RetrieveInboundMessage - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.InboundsService#get(String)} instead. - */ - @Deprecated - Inbound get(String inboundId) throws ApiException; -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java index edbb8caeb..5b7dfd7b1 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/SMSService.java @@ -17,54 +17,4 @@ public interface SMSService { * @since 1.5 */ com.sinch.sdk.domains.sms.api.v1.SMSService v1(); - - /** - * Batches Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.SMSService#batches()} instead. - */ - @Deprecated - BatchesService batches(); - - /** - * WebHooksService Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.SMSService#webhooks()} instead. - */ - @Deprecated - WebHooksService webHooks(); - - /** - * Delivery Reports Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.SMSService#deliveryReports()} instead. - */ - @Deprecated - DeliveryReportsService deliveryReports(); - - /** - * Inbounds Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.SMSService#inbounds()} instead. - */ - @Deprecated - InboundsService inbounds(); - - /** - * Groups Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.SMSService#groups()} instead. - */ - @Deprecated - GroupsService groups(); } diff --git a/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java deleted file mode 100644 index 211b5a308..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/WebHooksService.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.sms; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent; - -/** - * WebHooks - * - *

Callbacks - * - *

A callback is an HTTP POST request with a notification made by the Sinch SMS REST API to a URI - * of your choosing. - * - *

The REST API expects the receiving server to respond with a response code within the 2xx - * success range. For 5xx the callback will be retried. For 429 - * the callback will be retried and the throughput will be lowered. For other status codes in the - * 4xx range the callback will not be retried. The first initial retry will happen 5 - * seconds after the first try. The next attempt is after 10 seconds, then after 20 seconds, after - * 40 seconds, after 80 seconds, doubling on every attempt. The last retry will be at 81920 seconds - * (or 22 hours 45 minutes) after the initial failed attempt. - * - *

The SMS REST API offers the following callback options which can be configured for your - * account upon request to your account manager. - * - *

    - *
  • Callback with mutual authentication over TLS (HTTPS) connection by provisioning the - * callback URL with client keystore and password. - *
  • Callback with basic authentication by provisioning the callback URL with username and - * password. - *
  • Callback with OAuth 2.0 by provisioning the callback URL with username, password and the - * URL to fetch OAuth access token. - *
  • Callback using AWS SNS by provisioning the callback URL with an Access Key ID, Secret Key - * and Region. - *
- * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/ - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.WebHooksService} instead. - */ -@Deprecated -public interface WebHooksService { - - /** - * Parse and un-serialize incoming webhooks payload - * - * @param jsonPayload The incoming payload received onto webhooks call - * @return Un serialized object instance (see inherited classes) and {@link - * com.sinch.sdk.domains.sms.models.webhooks package documentation} - * @deprecated use {@link com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String)} - * instead. - */ - @Deprecated - WebhooksEvent parse(String jsonPayload) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java deleted file mode 100644 index 469b318ce..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/BatchesService.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.adapters.api.v1.BatchesApi; -import com.sinch.sdk.domains.sms.adapters.converters.BatchDtoConverter; -import com.sinch.sdk.domains.sms.adapters.converters.DryRunDtoConverter; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.Batch; -import com.sinch.sdk.domains.sms.models.DryRun; -import com.sinch.sdk.domains.sms.models.SMSCursorPageNavigator; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiBatchListDto; -import com.sinch.sdk.domains.sms.models.requests.BatchesListRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.UpdateBaseBatchRequest; -import com.sinch.sdk.domains.sms.models.responses.BatchesListResponse; -import com.sinch.sdk.models.SmsContext; -import java.time.Instant; -import java.util.Collection; -import java.util.Map; - -public class BatchesService implements com.sinch.sdk.domains.sms.BatchesService { - - private final String uriUUID; - private final BatchesApi api; - - public BatchesService( - String uriUUID, - SmsContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new BatchesApi(httpClient, context.getSmsServer(), authManagers, HttpMapper.getInstance()); - } - - protected BatchesApi getApi() { - return this.api; - } - - public > T get(String batchId) throws ApiException { - return BatchDtoConverter.convert(getApi().getBatchMessage(uriUUID, batchId)); - } - - public > T send(BaseBatch batch) throws ApiException { - return BatchDtoConverter.convert(getApi().sendSMS(uriUUID, BatchDtoConverter.convert(batch))); - } - - public DryRun dryRun(boolean perRecipient, int numberOfRecipient, BaseBatch batch) { - return DryRunDtoConverter.convert( - getApi() - .dryRun(uriUUID, perRecipient, numberOfRecipient, BatchDtoConverter.convert(batch))); - } - - public BatchesListResponse list() throws ApiException { - return this.list(null); - } - - public BatchesListResponse list(BatchesListRequestParameters parameters) throws ApiException { - - BatchesListRequestParameters guardParameters = - null != parameters ? parameters : BatchesListRequestParameters.builder().build(); - - ApiBatchListDto response = - getApi() - .listBatches( - uriUUID, - guardParameters.getPage().orElse(null), - guardParameters.getPageSize().orElse(null), - guardParameters.getFrom().orElse(null), - guardParameters.getStartDate().map(Instant::toString).orElse(null), - guardParameters.getEndDate().map(Instant::toString).orElse(null), - guardParameters.getClientReference().orElse(null)); - - Collection> content = BatchDtoConverter.convert(response); - SMSCursorPageNavigator navigator = - new SMSCursorPageNavigator(response.getPage(), response.getPageSize()); - - return new BatchesListResponse(this, new Page<>(guardParameters, content, navigator)); - } - - public > T update(String batchId, UpdateBaseBatchRequest batch) - throws ApiException { - return BatchDtoConverter.convert( - getApi().updateBatchMessage(uriUUID, batchId, BatchDtoConverter.convert(batch))); - } - - public > T replace(String batchId, BaseBatch batch) throws ApiException { - return BatchDtoConverter.convert( - getApi().replaceBatch(uriUUID, batchId, BatchDtoConverter.convert(batch))); - } - - public > T cancel(String batchId) throws ApiException { - return BatchDtoConverter.convert(getApi().cancelBatchMessage(uriUUID, batchId)); - } - - public void sendDeliveryFeedback(String batchId, Collection recipients) - throws ApiException { - getApi().deliveryFeedback(uriUUID, batchId, BatchDtoConverter.convert(recipients)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/DeliveryReportsService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/DeliveryReportsService.java deleted file mode 100644 index 49ce48646..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/DeliveryReportsService.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.domains.sms.adapters.api.v1.DeliveryReportsApi; -import com.sinch.sdk.domains.sms.adapters.converters.DeliveryReportDtoConverter; -import com.sinch.sdk.domains.sms.models.DeliveryReportBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipient; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.SMSCursorPageNavigator; -import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportListDto; -import com.sinch.sdk.domains.sms.models.requests.DeliveryReportBatchGetRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.DeliveryReportListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.DeliveryReportsListResponse; -import com.sinch.sdk.models.SmsContext; -import java.time.Instant; -import java.util.Collection; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * Delivery reports Service - * - *

The REST API uses message statuses and error codes in delivery reports, which refer to the - * state of the batch and can be present in either Retrieve - * a delivery report or sent as a callback. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports - * @since 1.0 - */ -public class DeliveryReportsService implements com.sinch.sdk.domains.sms.DeliveryReportsService { - - private final String uriUUID; - private final DeliveryReportsApi api; - - protected DeliveryReportsApi getApi() { - return this.api; - } - - public DeliveryReportsService( - String uriUUID, - SmsContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new DeliveryReportsApi( - httpClient, context.getSmsServer(), authManagers, HttpMapper.getInstance()); - } - - public DeliveryReportBatch get(String batchId, DeliveryReportBatchGetRequestParameters parameters) - throws ApiException { - - DeliveryReportBatchGetRequestParameters guardParameters = - null != parameters ? parameters : DeliveryReportBatchGetRequestParameters.builder().build(); - - return DeliveryReportDtoConverter.convert( - getApi() - .getDeliveryReportByBatchId( - uriUUID, - batchId, - guardParameters.getType().map(DeliveryReportType::value).orElse(null), - guardParameters - .geStatues() - .map(f -> f.stream().map(EnumDynamic::value).collect(Collectors.joining(","))) - .orElse(null), - guardParameters - .getCodes() - .map(f -> f.stream().map(Object::toString).collect(Collectors.joining(","))) - .orElse(null))); - } - - public DeliveryReportRecipient getForNumber(String batchId, String recipient) - throws ApiException { - return DeliveryReportDtoConverter.convert( - getApi().getDeliveryReportByPhoneNumber(uriUUID, batchId, recipient)); - } - - public DeliveryReportsListResponse list() throws ApiException { - return this.list(null); - } - - public DeliveryReportsListResponse list(DeliveryReportListRequestParameters parameters) - throws ApiException { - DeliveryReportListRequestParameters guardParameters = - null != parameters ? parameters : DeliveryReportListRequestParameters.builder().build(); - - DeliveryReportListDto response = - getApi() - .getDeliveryReports( - uriUUID, - guardParameters.getPage().orElse(null), - guardParameters.getPageSize().orElse(null), - guardParameters.getStartDate().map(Instant::toString).orElse(null), - guardParameters.getEndDate().map(Instant::toString).orElse(null), - guardParameters - .getStatuses() - .map(f -> f.stream().map(EnumDynamic::value).collect(Collectors.joining(","))) - .orElse(null), - guardParameters - .getCodes() - .map(f -> f.stream().map(Object::toString).collect(Collectors.joining(","))) - .orElse(null), - guardParameters.getClientReference().orElse(null)); - - Collection content = DeliveryReportDtoConverter.convert(response); - SMSCursorPageNavigator navigator = - new SMSCursorPageNavigator(response.getPage(), response.getPageSize()); - - return new DeliveryReportsListResponse(this, new Page<>(guardParameters, content, navigator)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/GroupsService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/GroupsService.java deleted file mode 100644 index 9e71b0104..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/GroupsService.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.adapters.api.v1.GroupsApi; -import com.sinch.sdk.domains.sms.adapters.converters.GroupsDtoConverter; -import com.sinch.sdk.domains.sms.models.Group; -import com.sinch.sdk.domains.sms.models.SMSCursorPageNavigator; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.CreateGroupResponseDto; -import com.sinch.sdk.domains.sms.models.requests.GroupCreateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupReplaceRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupUpdateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupsListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.GroupsListResponse; -import com.sinch.sdk.models.SmsContext; -import java.util.Collection; -import java.util.Map; - -public class GroupsService implements com.sinch.sdk.domains.sms.GroupsService { - - private final String uriUUID; - private final GroupsApi api; - - protected GroupsApi getApi() { - return this.api; - } - - public GroupsService( - String uriUUID, - SmsContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new GroupsApi(httpClient, context.getSmsServer(), authManagers, HttpMapper.getInstance()); - } - - public Group get(String groupId) throws ApiException { - - CreateGroupResponseDto response = getApi().retrieveGroup(uriUUID, groupId); - return GroupsDtoConverter.convert(response); - } - - public Group create() throws ApiException { - return this.create(null); - } - - public Group create(GroupCreateRequestParameters parameters) throws ApiException { - GroupCreateRequestParameters guardParameters = - null != parameters ? parameters : GroupCreateRequestParameters.builder().build(); - - CreateGroupResponseDto response = - getApi().createGroup(uriUUID, GroupsDtoConverter.convert(guardParameters)); - return GroupsDtoConverter.convert(response); - } - - public GroupsListResponse list() throws ApiException { - return this.list(null); - } - - public GroupsListResponse list(GroupsListRequestParameters parameters) throws ApiException { - GroupsListRequestParameters guardParameters = - null != parameters ? parameters : GroupsListRequestParameters.builder().build(); - - ApiGroupListDto response = - getApi() - .listGroups( - uriUUID, - guardParameters.getPage().orElse(null), - guardParameters.getPageSize().orElse(null)); - - Collection content = GroupsDtoConverter.convert(response); - SMSCursorPageNavigator navigator = - new SMSCursorPageNavigator(response.getPage(), response.getPageSize()); - - return new GroupsListResponse(this, new Page<>(guardParameters, content, navigator)); - } - - public Group replace(String groupId, GroupReplaceRequestParameters parameters) - throws ApiException { - GroupReplaceRequestParameters guardParameters = - null != parameters ? parameters : GroupReplaceRequestParameters.builder().build(); - - CreateGroupResponseDto response = - getApi().replaceGroup(uriUUID, groupId, GroupsDtoConverter.convert(guardParameters)); - return GroupsDtoConverter.convert(response); - } - - public Group update(String groupId, GroupUpdateRequestParameters parameters) throws ApiException { - GroupUpdateRequestParameters guardParameters = - null != parameters ? parameters : GroupUpdateRequestParameters.builder().build(); - - CreateGroupResponseDto response = - getApi().updateGroup(uriUUID, groupId, GroupsDtoConverter.convert(guardParameters)); - return GroupsDtoConverter.convert(response); - } - - public void delete(String groupId) throws ApiException { - getApi().deleteGroup(uriUUID, groupId); - } - - public Collection listMembers(String groupId) throws ApiException { - return getApi().getMembers(uriUUID, groupId); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/InboundsService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/InboundsService.java deleted file mode 100644 index 89a468f75..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/InboundsService.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.adapters.api.v1.InboundsApi; -import com.sinch.sdk.domains.sms.adapters.converters.InboundsDtoConverter; -import com.sinch.sdk.domains.sms.models.Inbound; -import com.sinch.sdk.domains.sms.models.SMSCursorPageNavigator; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiInboundListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.InboundDto; -import com.sinch.sdk.domains.sms.models.requests.InboundsListRequestParameters; -import com.sinch.sdk.domains.sms.models.responses.InboundsListResponse; -import com.sinch.sdk.models.SmsContext; -import java.time.Instant; -import java.util.Collection; -import java.util.Map; - -public class InboundsService implements com.sinch.sdk.domains.sms.InboundsService { - - private final String uriUUID; - private final InboundsApi api; - - protected InboundsApi getApi() { - return this.api; - } - - public InboundsService( - String uriUUID, - SmsContext context, - HttpClient httpClient, - Map authManagers) { - this.uriUUID = uriUUID; - this.api = - new InboundsApi(httpClient, context.getSmsServer(), authManagers, HttpMapper.getInstance()); - } - - public InboundsListResponse list() throws ApiException { - return this.list(null); - } - - public InboundsListResponse list(InboundsListRequestParameters parameters) throws ApiException { - InboundsListRequestParameters guardParameters = - null != parameters ? parameters : InboundsListRequestParameters.builder().build(); - - ApiInboundListDto response = - getApi() - .listInboundMessages( - uriUUID, - guardParameters.getPage().orElse(null), - guardParameters.getPageSize().orElse(null), - guardParameters.getTo().map(f -> String.join(",", f)).orElse(null), - guardParameters.getStartDate().map(Instant::toString).orElse(null), - guardParameters.getEndDate().map(Instant::toString).orElse(null), - guardParameters.getClientReference().orElse(null)); - - Collection> content = InboundsDtoConverter.convert(response); - SMSCursorPageNavigator navigator = - new SMSCursorPageNavigator(response.getPage(), response.getPageSize()); - - return new InboundsListResponse(this, new Page<>(guardParameters, content, navigator)); - } - - public Inbound get(String inboundId) throws ApiException { - - InboundDto response = getApi().retrieveInboundMessage(uriUUID, inboundId); - return InboundsDtoConverter.convert(response); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java index 654d9c66c..c178e9df8 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/adapters/SMSService.java @@ -1,152 +1,48 @@ package com.sinch.sdk.domains.sms.adapters; -import com.sinch.sdk.auth.adapters.BearerAuthManager; -import com.sinch.sdk.auth.adapters.OAuthManager; -import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpMapper; import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.domains.sms.BatchesService; -import com.sinch.sdk.domains.sms.DeliveryReportsService; -import com.sinch.sdk.domains.sms.InboundsService; -import com.sinch.sdk.domains.sms.WebHooksService; import com.sinch.sdk.models.SmsContext; import com.sinch.sdk.models.SmsServicePlanCredentials; import com.sinch.sdk.models.UnifiedCredentials; -import java.util.AbstractMap; -import java.util.Map; -import java.util.Objects; import java.util.function.Supplier; -import java.util.logging.Logger; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class SMSService implements com.sinch.sdk.domains.sms.SMSService { - private static final Logger LOGGER = Logger.getLogger(SMSService.class.getName()); + private final Supplier v1Initializer; - private static final String SECURITY_SCHEME_KEYWORD_SMS = "BearerAuth"; - private final String uriUUID; - private final SmsContext context; - private final Map authManagers; - private final Supplier httpClientSupplier; private volatile com.sinch.sdk.domains.sms.api.v1.SMSService v1; - private volatile BatchesService batches; - private volatile WebHooksService webHooks; - private volatile DeliveryReportsService deliveryReports; - private volatile InboundsService inbounds; - private volatile GroupsService groups; public SMSService( UnifiedCredentials credentials, SmsContext context, ServerConfiguration oAuthServer, Supplier httpClientSupplier) { - - Objects.requireNonNull(credentials, "Credentials must be defined"); - Objects.requireNonNull(context, "Context must be defined"); - StringUtil.requireNonEmpty(credentials.getKeyId(), "'keyId' must be defined"); - StringUtil.requireNonEmpty(credentials.getKeySecret(), "'keySecret' must be defined"); - StringUtil.requireNonEmpty(credentials.getProjectId(), "'projectId' must be defined"); - StringUtil.requireNonEmpty(context.getSmsUrl(), "'smsUrl' must be defined"); - - LOGGER.fine("Activate SMS API with server='" + context.getSmsServer().getUrl() + "'"); - - OAuthManager oAuthManager = - new OAuthManager(credentials, oAuthServer, HttpMapper.getInstance(), httpClientSupplier); - - this.uriUUID = credentials.getProjectId(); - this.context = context; - this.httpClientSupplier = httpClientSupplier; - this.authManagers = - Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, oAuthManager)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - this.v1 = - new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService( - credentials, context, oAuthServer, httpClientSupplier); + this.v1Initializer = + () -> + new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService( + credentials, context, oAuthServer, httpClientSupplier); } public SMSService( SmsServicePlanCredentials credentials, SmsContext context, Supplier httpClientSupplier) { - - Objects.requireNonNull(credentials, "Credentials must be defined"); - Objects.requireNonNull(context, "Context must be defined"); - StringUtil.requireNonEmpty(credentials.getServicePlanId(), "'servicePlanId' must be defined"); - StringUtil.requireNonEmpty(credentials.getApiToken(), "'apiToken' must be defined"); - - LOGGER.fine( - "Activate SMS API with service plan ID support and server='" - + context.getSmsServer().getUrl() - + "'"); - - BearerAuthManager authManager = new BearerAuthManager(credentials.getApiToken()); - - this.uriUUID = credentials.getServicePlanId(); - this.context = context; - this.httpClientSupplier = httpClientSupplier; - this.authManagers = - Stream.of(new AbstractMap.SimpleEntry<>(SECURITY_SCHEME_KEYWORD_SMS, authManager)) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - this.v1 = - new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService( - credentials, context, httpClientSupplier); + this.v1Initializer = + () -> + new com.sinch.sdk.domains.sms.api.v1.adapters.SMSService( + credentials, context, httpClientSupplier); } @Override public com.sinch.sdk.domains.sms.api.v1.SMSService v1() { - return this.v1; - } - - @Override - public BatchesService batches() { - if (null == this.batches) { - this.batches = - new com.sinch.sdk.domains.sms.adapters.BatchesService( - uriUUID, context, httpClientSupplier.get(), authManagers); + if (null == this.v1) { + synchronized (this) { + if (null == this.v1) { + this.v1 = v1Initializer.get(); + } + } } - return this.batches; - } - - @Override - public WebHooksService webHooks() { - if (null == this.webHooks) { - this.webHooks = new com.sinch.sdk.domains.sms.adapters.WebHooksService(); - } - return this.webHooks; - } - - @Override - public DeliveryReportsService deliveryReports() { - if (null == this.deliveryReports) { - this.deliveryReports = - new com.sinch.sdk.domains.sms.adapters.DeliveryReportsService( - uriUUID, context, httpClientSupplier.get(), authManagers); - } - return this.deliveryReports; - } - - @Override - public InboundsService inbounds() { - if (null == this.inbounds) { - this.inbounds = - new com.sinch.sdk.domains.sms.adapters.InboundsService( - uriUUID, context, httpClientSupplier.get(), authManagers); - } - return this.inbounds; - } - - @Override - public GroupsService groups() { - if (null == this.groups) { - this.groups = - new com.sinch.sdk.domains.sms.adapters.GroupsService( - uriUUID, context, httpClientSupplier.get(), authManagers); - } - return this.groups; + return this.v1; } } diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java deleted file mode 100644 index c5c64705d..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/WebHooksService.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.sms.adapters.converters.DeliveryReportDtoConverter; -import com.sinch.sdk.domains.sms.adapters.converters.InboundsDtoConverter; -import com.sinch.sdk.domains.sms.models.BaseDeliveryReport; -import com.sinch.sdk.domains.sms.models.Inbound; -import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportDto; -import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportDto.TypeEnum; -import com.sinch.sdk.domains.sms.models.dto.v1.MOBinaryDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MOTextDto; -import com.sinch.sdk.domains.sms.models.dto.v1.RecipientDeliveryReportDto; -import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent; -import java.util.Objects; - -public class WebHooksService implements com.sinch.sdk.domains.sms.WebHooksService { - - public WebhooksEvent parse(String jsonPayload) throws ApiMappingException { - - WebhooksEvent event; - try { - event = incomingSMS(jsonPayload); - if (null == event) { - event = deliveryReport(jsonPayload); - } - if (null == event) { - throw new ApiMappingException(jsonPayload, null); - } - } catch (JsonProcessingException e) { - throw new ApiMappingException(jsonPayload, e); - } - return event; - } - - private Inbound incomingSMS(String jsonPayload) throws JsonProcessingException { - MOBinaryDto binary = Mapper.getInstance().readValue(jsonPayload, MOBinaryDto.class); - if (null != binary - && (Objects.equals(binary.getType(), MOBinaryDto.TypeEnum.MO_BINARY.getValue()))) { - return InboundsDtoConverter.convert(binary); - } - MOTextDto text = Mapper.getInstance().readValue(jsonPayload, MOTextDto.class); - if (null != text && (Objects.equals(text.getType(), MOTextDto.TypeEnum.MO_TEXT.getValue()))) { - return InboundsDtoConverter.convert(text); - } - return null; - } - - private BaseDeliveryReport deliveryReport(String jsonPayload) throws JsonProcessingException { - // Can we convert payload to Recipient DeliveryReport or Batch Delivery Report ? - RecipientDeliveryReportDto recipient = - Mapper.getInstance().readValue(jsonPayload, RecipientDeliveryReportDto.class); - if (null != recipient - && (Objects.equals(recipient.getType(), RecipientDeliveryReportDto.TypeEnum.MMS.getValue()) - || Objects.equals( - recipient.getType(), RecipientDeliveryReportDto.TypeEnum.SMS.getValue()))) { - return DeliveryReportDtoConverter.convert(recipient); - } - - DeliveryReportDto deliveryReport = - Mapper.getInstance().readValue(jsonPayload, DeliveryReportDto.class); - if (null != deliveryReport - && (Objects.equals(deliveryReport.getType(), TypeEnum.MMS.getValue()) - || Objects.equals(deliveryReport.getType(), TypeEnum.SMS.getValue()))) { - return DeliveryReportDtoConverter.convert(deliveryReport); - } - return null; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java deleted file mode 100644 index 2044fd824..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/BatchDtoConverter.java +++ /dev/null @@ -1,299 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.models.AbstractOpenApiSchema; -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.Batch; -import com.sinch.sdk.domains.sms.models.BatchBinary; -import com.sinch.sdk.domains.sms.models.BatchMedia; -import com.sinch.sdk.domains.sms.models.BatchText; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.MediaBody; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiBatchListBatchesInnerDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiBatchListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiDeliveryFeedbackDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiUpdateBinaryMtMessageDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiUpdateMmsMtMessageDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiUpdateTextMtMessageDto; -import com.sinch.sdk.domains.sms.models.dto.v1.BinaryRequestDto; -import com.sinch.sdk.domains.sms.models.dto.v1.BinaryResponseDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MediaBodyDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MediaRequestDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MediaResponseDto; -import com.sinch.sdk.domains.sms.models.dto.v1.SendSMSRequestDto; -import com.sinch.sdk.domains.sms.models.dto.v1.TextRequestDto; -import com.sinch.sdk.domains.sms.models.dto.v1.TextResponseDto; -import com.sinch.sdk.domains.sms.models.dto.v1.UpdateBatchMessageRequestDto; -import com.sinch.sdk.domains.sms.models.requests.SendSmsBatchBinaryRequest; -import com.sinch.sdk.domains.sms.models.requests.SendSmsBatchMediaRequest; -import com.sinch.sdk.domains.sms.models.requests.SendSmsBatchTextRequest; -import com.sinch.sdk.domains.sms.models.requests.UpdateBaseBatchRequest; -import com.sinch.sdk.domains.sms.models.requests.UpdateSmsBatchBinaryRequest; -import com.sinch.sdk.domains.sms.models.requests.UpdateSmsBatchMediaRequest; -import com.sinch.sdk.domains.sms.models.requests.UpdateSmsBatchTextRequest; -import java.time.ZoneOffset; -import java.util.ArrayList; -import java.util.Collection; - -public class BatchDtoConverter { - - public static > T convert(AbstractOpenApiSchema dto) { - Object obj = dto.getActualInstance(); - if (obj instanceof BinaryResponseDto) { - @SuppressWarnings("unchecked") - T t = (T) convertBinary((BinaryResponseDto) obj); - return t; - } else if (obj instanceof MediaResponseDto) { - @SuppressWarnings("unchecked") - T t = (T) convertMedia((MediaResponseDto) obj); - return t; - } else if (obj instanceof TextResponseDto) { - @SuppressWarnings("unchecked") - T t = (T) convertText((TextResponseDto) obj); - return t; - } else { - throw new ApiException("Unexpected class:" + obj.getClass().getName()); - } - } - - private static BatchBinary convertBinary(BinaryResponseDto dto) { - return BatchBinary.builder() - .setId(dto.getId()) - .setTo(dto.getTo()) - .setFrom(dto.getFrom()) - .setCanceled(dto.getCanceled()) - .setBody(dto.getBody()) - .setUdh(dto.getUdh()) - .setCreatedAt(null != dto.getCreatedAt() ? dto.getCreatedAt().toInstant() : null) - .setModifiedAt(null != dto.getModifiedAt() ? dto.getModifiedAt().toInstant() : null) - .setDeliveryReport(DeliveryReportType.from(dto.getDeliveryReport())) - .setSendAt(null != dto.getSendAt() ? dto.getSendAt().toInstant() : null) - .setExpireAt(null != dto.getExpireAt() ? dto.getExpireAt().toInstant() : null) - .setCallbackUrl(dto.getCallbackUrl()) - .setClientReference(dto.getClientReference()) - .setFeedbackEnabled(dto.getFeedbackEnabled()) - .setFlashMessage(dto.getFlashMessage()) - .setTruncateConcat(dto.getTruncateConcat()) - .setMaxNumberOfMessageParts(dto.getMaxNumberOfMessageParts()) - .setFromTon(dto.getFromTon()) - .setFromNpi(dto.getFromNpi()) - .build(); - } - - private static BatchMedia convertMedia(MediaResponseDto dto) { - return BatchMedia.builder() - .setId(dto.getId()) - .setTo(dto.getTo()) - .setFrom(dto.getFrom()) - .setCanceled(dto.getCanceled()) - .setBody( - null != dto.getBody() - ? MediaBody.builder() - .setMessage(dto.getBody().getMessage()) - .setUrl(dto.getBody().getUrl()) - .build() - : null) - .setCreatedAt(null != dto.getCreatedAt() ? dto.getCreatedAt().toInstant() : null) - .setModifiedAt(null != dto.getModifiedAt() ? dto.getModifiedAt().toInstant() : null) - .setDeliveryReport(DeliveryReportType.from(dto.getDeliveryReport())) - .setSendAt(null != dto.getSendAt() ? dto.getSendAt().toInstant() : null) - .setExpireAt(null != dto.getExpireAt() ? dto.getExpireAt().toInstant() : null) - .setCallbackUrl(dto.getCallbackUrl()) - .setClientReference(dto.getClientReference()) - .setFeedbackEnabled(dto.getFeedbackEnabled()) - .setParameters(ParametersDtoConverter.convert(dto.getParameters())) - .build(); - } - - private static BatchText convertText(TextResponseDto dto) { - return BatchText.builder() - .setId(dto.getId()) - .setTo(dto.getTo()) - .setFrom(dto.getFrom()) - .setCanceled(dto.getCanceled()) - .setBody(dto.getBody()) - .setCreatedAt(null != dto.getCreatedAt() ? dto.getCreatedAt().toInstant() : null) - .setModifiedAt(null != dto.getModifiedAt() ? dto.getModifiedAt().toInstant() : null) - .setDeliveryReport(DeliveryReportType.from(dto.getDeliveryReport())) - .setSendAt(null != dto.getSendAt() ? dto.getSendAt().toInstant() : null) - .setExpireAt(null != dto.getExpireAt() ? dto.getExpireAt().toInstant() : null) - .setCallbackUrl(dto.getCallbackUrl()) - .setClientReference(dto.getClientReference()) - .setFeedbackEnabled(dto.getFeedbackEnabled()) - .setFlashMessage(dto.getFlashMessage()) - .setTruncateConcat(dto.getTruncateConcat()) - .setMaxNumberOfMessageParts(dto.getMaxNumberOfMessageParts()) - .setFromTon(dto.getFromTon()) - .setFromNpi(dto.getFromNpi()) - .setParameters(ParametersDtoConverter.convert(dto.getParameters())) - .build(); - } - - public static SendSMSRequestDto convert(BaseBatch value) { - if (value instanceof SendSmsBatchBinaryRequest) { - return convert((SendSmsBatchBinaryRequest) value); - } else if (value instanceof SendSmsBatchMediaRequest) { - return convert((SendSmsBatchMediaRequest) value); - } else if (value instanceof SendSmsBatchTextRequest) { - return convert((SendSmsBatchTextRequest) value); - } else { - throw new ApiException("Unexpected class:" + value.getClass().getName()); - } - } - - public static UpdateBatchMessageRequestDto convert(UpdateBaseBatchRequest value) { - if (value instanceof UpdateSmsBatchBinaryRequest) { - return convert((UpdateSmsBatchBinaryRequest) value); - } else if (value instanceof UpdateSmsBatchMediaRequest) { - return convert((UpdateSmsBatchMediaRequest) value); - } else if (value instanceof UpdateSmsBatchTextRequest) { - return convert((UpdateSmsBatchTextRequest) value); - } else { - throw new ApiException("Unexpected class:" + value.getClass().getName()); - } - } - - private static SendSMSRequestDto convert(SendSmsBatchBinaryRequest value) { - BinaryRequestDto dto = - new BinaryRequestDto() - .type(BinaryRequestDto.TypeEnum.MT_BINARY.getValue()) - .to(new ArrayList<>(value.getTo())) - .body(value.getBody()); - value.getFrom().ifPresent(dto::from); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getClientReference().ifPresent(dto::clientReference); - value.isFeedbackEnabled().ifPresent(dto::feedbackEnabled); - value.isFlashMessage().ifPresent(dto::flashMessage); - value.isTruncateConcat().ifPresent(dto::truncateConcat); - value.getMaxNumberOfMessageParts().ifPresent(dto::maxNumberOfMessageParts); - value.getFromTon().ifPresent(dto::fromTon); - value.getFromNpi().ifPresent(dto::fromNpi); - value.getUdh().ifPresent(dto::udh); - return new SendSMSRequestDto(dto); - } - - private static SendSMSRequestDto convert(SendSmsBatchMediaRequest value) { - MediaRequestDto dto = - new MediaRequestDto(MediaRequestDto.TypeEnum.MT_MEDIA.getValue()) - .to(new ArrayList<>(value.getTo())) - .body(convert(value.getBody())); - value.getFrom().ifPresent(dto::from); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getClientReference().ifPresent(dto::clientReference); - value.isFeedbackEnabled().ifPresent(dto::feedbackEnabled); - value.isStrictValidation().ifPresent(dto::strictValidation); - value.getParameters().ifPresent(f -> dto.setParameters(ParametersDtoConverter.convert(f))); - return new SendSMSRequestDto(dto); - } - - private static SendSMSRequestDto convert(SendSmsBatchTextRequest value) { - TextRequestDto dto = - new TextRequestDto() - .type(TextRequestDto.TypeEnum.MT_TEXT.getValue()) - .to(new ArrayList<>(value.getTo())) - .body(value.getBody()); - value.getFrom().ifPresent(dto::from); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getClientReference().ifPresent(dto::clientReference); - value.isFeedbackEnabled().ifPresent(dto::feedbackEnabled); - value.isFlashMessage().ifPresent(dto::flashMessage); - value.isTruncateConcat().ifPresent(dto::truncateConcat); - value.getMaxNumberOfMessageParts().ifPresent(dto::maxNumberOfMessageParts); - value.getFromTon().ifPresent(dto::fromTon); - value.getFromNpi().ifPresent(dto::fromNpi); - value.getParameters().ifPresent(f -> dto.setParameters(ParametersDtoConverter.convert(f))); - return new SendSMSRequestDto(dto); - } - - private static UpdateBatchMessageRequestDto convert(UpdateSmsBatchTextRequest value) { - ApiUpdateTextMtMessageDto dto = - new ApiUpdateTextMtMessageDto().type(ApiUpdateTextMtMessageDto.TypeEnum.MT_TEXT.getValue()); - - value.getToAdd().ifPresent(f -> dto.toAdd(new ArrayList<>(f))); - value.getToRemove().ifPresent(f -> dto.toRemove(new ArrayList<>(f))); - value.getFrom().ifPresent(dto::from); - value.getBody().ifPresent(dto::body); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getParameters().ifPresent(f -> dto.setParameters(ParametersDtoConverter.convert(f))); - return new UpdateBatchMessageRequestDto(dto); - } - - private static UpdateBatchMessageRequestDto convert(UpdateSmsBatchMediaRequest value) { - ApiUpdateMmsMtMessageDto dto = - new ApiUpdateMmsMtMessageDto().type(ApiUpdateMmsMtMessageDto.TypeEnum.MT_MEDIA.getValue()); - - value.getToAdd().ifPresent(f -> dto.toAdd(new ArrayList<>(f))); - value.getToRemove().ifPresent(f -> dto.toRemove(new ArrayList<>(f))); - value.getFrom().ifPresent(dto::from); - value.getBody().ifPresent(f -> dto.setBody(convert(f))); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getParameters().ifPresent(f -> dto.setParameters(ParametersDtoConverter.convert(f))); - value.isStrictValidation().ifPresent(dto::strictValidation); - return new UpdateBatchMessageRequestDto(dto); - } - - private static UpdateBatchMessageRequestDto convert(UpdateSmsBatchBinaryRequest value) { - ApiUpdateBinaryMtMessageDto dto = - new ApiUpdateBinaryMtMessageDto() - .type(ApiUpdateBinaryMtMessageDto.TypeEnum.MT_BINARY.getValue()); - value.getToAdd().ifPresent(f -> dto.toAdd(new ArrayList<>(f))); - value.getToRemove().ifPresent(f -> dto.toRemove(new ArrayList<>(f))); - value.getFrom().ifPresent(dto::from); - value.getBody().ifPresent(dto::setBody); - value - .getDeliveryReport() - .ifPresent(f -> dto.setDeliveryReport(EnumDynamicConverter.convert(f))); - value.getSendAt().ifPresent(f -> dto.setSendAt(f.atOffset(ZoneOffset.UTC))); - value.getExpireAt().ifPresent(f -> dto.setExpireAt(f.atOffset(ZoneOffset.UTC))); - value.getCallbackUrl().ifPresent(dto::callbackUrl); - value.getUdh().ifPresent(dto::udh); - return new UpdateBatchMessageRequestDto(dto); - } - - private static MediaBodyDto convert(MediaBody value) { - return new MediaBodyDto().url(value.getUrl()).message(value.getMessage().orElse(null)); - } - - public static > Collection convert(ApiBatchListDto dto) { - - Collection collection = dto.getBatches(); - Collection pageContent = new ArrayList<>(); - if (null != collection) { - for (ApiBatchListBatchesInnerDto apiBatchListBatchesInnerDto : collection) { - T convert = convert(apiBatchListBatchesInnerDto); - pageContent.add(convert); - } - } - return pageContent; - } - - public static ApiDeliveryFeedbackDto convert(Collection recipients) { - return new ApiDeliveryFeedbackDto().recipients(new ArrayList<>(recipients)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DeliveryReportDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DeliveryReportDtoConverter.java deleted file mode 100644 index a5c35b29b..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DeliveryReportDtoConverter.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.domains.sms.models.DeliveryReportBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportBatchMMS; -import com.sinch.sdk.domains.sms.models.DeliveryReportBatchSMS; -import com.sinch.sdk.domains.sms.models.DeliveryReportErrorCode; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipient; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipientEncoding; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipientMMS; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipientSMS; -import com.sinch.sdk.domains.sms.models.DeliveryReportStatus; -import com.sinch.sdk.domains.sms.models.DeliveryReportStatusDetails; -import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportDto; -import com.sinch.sdk.domains.sms.models.dto.v1.DeliveryReportListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MessageDeliveryStatusDto; -import com.sinch.sdk.domains.sms.models.dto.v1.RecipientDeliveryReportDto; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Objects; -import java.util.stream.Collectors; - -public class DeliveryReportDtoConverter { - - public static DeliveryReportBatch convert(DeliveryReportDto dto) { - DeliveryReportBatch.Builder builder; - - if (Objects.equals(dto.getType(), DeliveryReportDto.TypeEnum.MMS.getValue())) { - builder = DeliveryReportBatchMMS.builder(); - } else if (Objects.equals(dto.getType(), DeliveryReportDto.TypeEnum.SMS.getValue())) { - builder = DeliveryReportBatchSMS.builder(); - } else { - return null; - } - - return builder - .setBatchId(dto.getBatchId()) - .setClientReference(dto.getClientReference()) - .setStatuses( - null != dto.getStatuses() - ? dto.getStatuses().stream() - .map(DeliveryReportDtoConverter::convert) - .collect(Collectors.toList()) - : null) - .setTotalMessageCount(dto.getTotalMessageCount()) - .build(); - } - - public static DeliveryReportRecipient convert(RecipientDeliveryReportDto dto) { - DeliveryReportRecipient.Builder builder; - - if (Objects.equals(dto.getType(), RecipientDeliveryReportDto.TypeEnum.MMS.getValue())) { - builder = DeliveryReportRecipientMMS.builder(); - } else if (Objects.equals(dto.getType(), RecipientDeliveryReportDto.TypeEnum.SMS.getValue())) { - builder = DeliveryReportRecipientSMS.builder(); - } else { - return null; - } - - return builder - .setBatchId(dto.getBatchId()) - .setClientReference(dto.getClientReference()) - .setAt(null != dto.getAt() ? dto.getAt().toInstant() : null) - .setCode(DeliveryReportErrorCode.from(dto.getCode())) - .setRecipient(dto.getRecipient()) - .setStatus(DeliveryReportStatus.from(dto.getStatus())) - .setAppliedOriginator(dto.getAppliedOriginator()) - .setEncoding(DeliveryReportRecipientEncoding.from(dto.getEncoding())) - .setNumberOfMessageParts(dto.getNumberOfMessageParts()) - .setOperator(dto.getOperator()) - .setOperatorStatusAt( - null != dto.getOperatorStatusAt() ? dto.getOperatorStatusAt().toInstant() : null) - .build(); - } - - public static Collection convert(DeliveryReportListDto dto) { - Collection collection = dto.getDeliveryReports(); - Collection pageContent = new ArrayList<>(); - if (null != collection) { - for (RecipientDeliveryReportDto innerDto : collection) { - DeliveryReportRecipient convert = convert(innerDto); - pageContent.add(convert); - } - } - return pageContent; - } - - private static DeliveryReportStatusDetails convert(MessageDeliveryStatusDto dto) { - return DeliveryReportStatusDetails.builder() - .setCode(dto.getCode()) - .setCount(dto.getCount()) - .setStatus(DeliveryReportStatus.from(dto.getStatus())) - .setRecipients(dto.getRecipients()) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverter.java deleted file mode 100644 index 1b7669049..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/DryRunDtoConverter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.domains.sms.models.DryRun; -import com.sinch.sdk.domains.sms.models.DryRunPerRecipientDetails; -import com.sinch.sdk.domains.sms.models.dto.v1.DryRun200ResponseDto; -import com.sinch.sdk.domains.sms.models.dto.v1.DryRun200ResponsePerRecipientInnerDto; -import java.util.stream.Collectors; - -public class DryRunDtoConverter { - - public static DryRun convert(DryRun200ResponseDto dto) { - return DryRun.builder() - .setNumberOfRecipients(dto.getNumberOfRecipients()) - .setNumberOfMessages(dto.getNumberOfMessages()) - .setPerRecipient( - dto.getPerRecipient().stream() - .map(DryRunDtoConverter::convert) - .collect(Collectors.toList())) - .build(); - } - - private static DryRunPerRecipientDetails convert(DryRun200ResponsePerRecipientInnerDto dto) { - return DryRunPerRecipientDetails.builder() - .setRecipient(dto.getRecipient()) - .setNumberOfParts(dto.getNumberOfParts()) - .setBody(dto.getBody()) - .setEncoding(dto.getEncoding()) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/GroupsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/GroupsDtoConverter.java deleted file mode 100644 index 2ad137d63..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/GroupsDtoConverter.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.core.utils.DateUtil; -import com.sinch.sdk.domains.sms.models.Group; -import com.sinch.sdk.domains.sms.models.GroupAutoUpdate; -import com.sinch.sdk.domains.sms.models.GroupAutoUpdateKeyword; -import com.sinch.sdk.domains.sms.models.dto.v1.AddKeywordDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupAutoUpdateDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiGroupListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.CreateGroupResponseDto; -import com.sinch.sdk.domains.sms.models.dto.v1.GroupAutoUpdateDto; -import com.sinch.sdk.domains.sms.models.dto.v1.GroupObjectAutoUpdateDto; -import com.sinch.sdk.domains.sms.models.dto.v1.GroupObjectAutoUpdateRemoveDto; -import com.sinch.sdk.domains.sms.models.dto.v1.GroupObjectDto; -import com.sinch.sdk.domains.sms.models.dto.v1.RemoveKeywordDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ReplaceGroupRequestDto; -import com.sinch.sdk.domains.sms.models.dto.v1.UpdateGroupRequestAutoUpdateAddDto; -import com.sinch.sdk.domains.sms.models.dto.v1.UpdateGroupRequestAutoUpdateDto; -import com.sinch.sdk.domains.sms.models.dto.v1.UpdateGroupRequestAutoUpdateRemoveDto; -import com.sinch.sdk.domains.sms.models.dto.v1.UpdateGroupRequestDto; -import com.sinch.sdk.domains.sms.models.requests.GroupAutoUpdateKeywordRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupAutoUpdateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupCreateRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupReplaceRequestParameters; -import com.sinch.sdk.domains.sms.models.requests.GroupUpdateRequestParameters; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; -import java.util.stream.Collectors; - -public class GroupsDtoConverter { - - public static Group convert(CreateGroupResponseDto dto) { - return Group.builder() - .setId(dto.getId()) - .setName(dto.getName()) - .setSize(dto.getSize()) - .setCreatedAt(DateUtil.toInstant(dto.getCreatedAt())) - .setModifiedAt(DateUtil.toInstant(dto.getModifiedAt())) - .setChildGroupIds(convertChildGroups(dto.getChildGroups())) - .setAutoUpdate(convert(dto.getAutoUpdate())) - .build(); - } - - public static GroupObjectDto convert(GroupCreateRequestParameters client) { - GroupObjectDto dto = new GroupObjectDto(); - client.getName().ifPresent(dto::name); - client.getMembers().ifPresent(f -> dto.members(new ArrayList<>(f))); - client.getChildGroupIds().ifPresent(f -> dto.childGroups(new ArrayList<>(f))); - client.getAutoUpdate().ifPresent(f -> dto.autoUpdate(GroupsDtoConverter.convert(f))); - return dto; - } - - public static Collection convert(ApiGroupListDto dto) { - - Collection collection = dto.getGroups(); - Collection pageContent = new ArrayList<>(); - if (null != collection) { - for (ApiGroupDto innerDto : collection) { - Group convert = convert(innerDto); - pageContent.add(convert); - } - } - return pageContent; - } - - public static ReplaceGroupRequestDto convert(GroupReplaceRequestParameters client) { - ReplaceGroupRequestDto dto = new ReplaceGroupRequestDto(); - client.getName().ifPresent(dto::name); - client.getMembers().ifPresent(f -> dto.members(new ArrayList<>(f))); - return dto; - } - - public static UpdateGroupRequestDto convert(GroupUpdateRequestParameters client) { - UpdateGroupRequestDto dto = new UpdateGroupRequestDto(); - client.getName().ifPresent(dto::name); - client.getAdd().ifPresent(f -> dto.add(new ArrayList<>(f))); - client.getRemove().ifPresent(f -> dto.remove(new ArrayList<>(f))); - client.getAddFromGroup().ifPresent(dto::addFromGroup); - client.getRemoveFromGroup().ifPresent(dto::removeFromGroup); - client.getAutoUpdate().ifPresent(f -> dto.autoUpdate(GroupsDtoConverter.convertForUpdate(f))); - return dto; - } - - private static Group convert(ApiGroupDto dto) { - return Group.builder() - .setId(dto.getId()) - .setName(dto.getName()) - .setSize(dto.getSize()) - .setCreatedAt(DateUtil.toInstant(dto.getCreatedAt())) - .setModifiedAt(DateUtil.toInstant(dto.getModifiedAt())) - .setChildGroupIds(convertChildGroups(dto.getChildGroups())) - .setAutoUpdate(convert(dto.getAutoUpdate())) - .build(); - } - - private static Collection convertChildGroups(Set dto) { - if (null == dto) { - return null; - } - return dto.stream().map(f -> (String) f).collect(Collectors.toList()); - } - - private static GroupAutoUpdate convert(GroupAutoUpdateDto dto) { - if (null == dto) { - return null; - } - return GroupAutoUpdate.builder() - .setTo(dto.getTo()) - .setAdd(convert(dto.getAdd())) - .setRemove(convert(dto.getRemove())) - .build(); - } - - private static GroupAutoUpdate convert(ApiGroupAutoUpdateDto dto) { - if (null == dto) { - return null; - } - return GroupAutoUpdate.builder() - .setTo(dto.getTo()) - .setAdd(convert(dto.getAdd())) - .setRemove(convert(dto.getRemove())) - .build(); - } - - private static GroupObjectAutoUpdateDto convert(GroupAutoUpdateRequestParameters client) { - if (null == client) { - return null; - } - GroupObjectAutoUpdateDto dto = new GroupObjectAutoUpdateDto(); - client.getTo().ifPresent(dto::to); - client.getAdd().ifPresent(f -> dto.add(convertAdd(f))); - client.getRemove().ifPresent(f -> dto.remove(convertRemove(f))); - return dto; - } - - private static UpdateGroupRequestAutoUpdateDto convertForUpdate( - GroupAutoUpdateRequestParameters client) { - if (null == client) { - return null; - } - UpdateGroupRequestAutoUpdateDto dto = new UpdateGroupRequestAutoUpdateDto(); - - client.getTo().ifPresent(dto::to); - client.getAdd().ifPresent(f -> dto.add(convertAdd(f))); - client.getRemove().ifPresent(f -> dto.remove(convertRemoveForUpdate(f))); - return dto; - } - - private static GroupAutoUpdateKeyword convert(AddKeywordDto dto) { - if (null == dto) { - return null; - } - - GroupAutoUpdateKeyword.Builder builder = GroupAutoUpdateKeyword.builder(); - if (dto.getFirstWordDefined()) { - builder.setFirstWord(dto.getFirstWord()); - } - if (dto.getSecondWordDefined()) { - builder.setSecondWord(dto.getSecondWord()); - } - return builder.build(); - } - - private static UpdateGroupRequestAutoUpdateAddDto convertAdd( - GroupAutoUpdateKeywordRequestParameters client) { - if (null == client) { - return null; - } - - UpdateGroupRequestAutoUpdateAddDto dto = new UpdateGroupRequestAutoUpdateAddDto(); - client.getFirstWord().ifPresent(dto::firstWord); - client.getSecondWord().ifPresent(dto::secondWord); - return dto; - } - - private static GroupAutoUpdateKeyword convert(RemoveKeywordDto dto) { - if (null == dto) { - return null; - } - GroupAutoUpdateKeyword.Builder builder = GroupAutoUpdateKeyword.builder(); - if (dto.getFirstWordDefined()) { - builder.setFirstWord(dto.getFirstWord()); - } - if (dto.getSecondWordDefined()) { - builder.setSecondWord(dto.getSecondWord()); - } - return builder.build(); - } - - private static GroupObjectAutoUpdateRemoveDto convertRemove( - GroupAutoUpdateKeywordRequestParameters client) { - if (null == client) { - return null; - } - - GroupObjectAutoUpdateRemoveDto dto = new GroupObjectAutoUpdateRemoveDto(); - client.getFirstWord().ifPresent(dto::firstWord); - client.getSecondWord().ifPresent(dto::secondWord); - return dto; - } - - private static UpdateGroupRequestAutoUpdateRemoveDto convertRemoveForUpdate( - GroupAutoUpdateKeywordRequestParameters client) { - if (null == client) { - return null; - } - - UpdateGroupRequestAutoUpdateRemoveDto dto = new UpdateGroupRequestAutoUpdateRemoveDto(); - client.getFirstWord().ifPresent(dto::firstWord); - client.getSecondWord().ifPresent(dto::secondWord); - return dto; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/InboundsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/InboundsDtoConverter.java deleted file mode 100644 index c8cd25d9a..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/InboundsDtoConverter.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.models.AbstractOpenApiSchema; -import com.sinch.sdk.domains.sms.models.Inbound; -import com.sinch.sdk.domains.sms.models.InboundBinary; -import com.sinch.sdk.domains.sms.models.InboundText; -import com.sinch.sdk.domains.sms.models.dto.v1.ApiInboundListDto; -import com.sinch.sdk.domains.sms.models.dto.v1.InboundDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MOBinaryDto; -import com.sinch.sdk.domains.sms.models.dto.v1.MOTextDto; -import java.util.ArrayList; -import java.util.Collection; - -public class InboundsDtoConverter { - - public static Inbound convert(AbstractOpenApiSchema dto) { - Object obj = dto.getActualInstance(); - if (obj instanceof MOBinaryDto) { - return convert((MOBinaryDto) obj); - } else if (obj instanceof MOTextDto) { - return convert((MOTextDto) obj); - } else { - throw new ApiException("Unexpected class:" + obj.getClass().getName()); - } - } - - public static Collection> convert(ApiInboundListDto dto) { - - Collection collection = dto.getInbounds(); - Collection> pageContent = new ArrayList<>(); - if (null != collection) { - for (InboundDto innerDto : collection) { - Inbound convert = convert(innerDto); - pageContent.add(convert); - } - } - return pageContent; - } - - public static InboundBinary convert(MOBinaryDto dto) { - return InboundBinary.builder() - .setBody(dto.getBody()) - .setFrom(dto.getFrom()) - .setId(dto.getId()) - .setReceivedAt(null != dto.getReceivedAt() ? dto.getReceivedAt().toInstant() : null) - .setTo(dto.getTo()) - .setClientReference(dto.getClientReference()) - .setOperatorId(dto.getOperatorId()) - .setSentAt(null != dto.getSentAt() ? dto.getSentAt().toInstant() : null) - .setUdh(dto.getUdh()) - .build(); - } - - public static InboundText convert(MOTextDto dto) { - return InboundText.builder() - .setBody(dto.getBody()) - .setFrom(dto.getFrom()) - .setId(dto.getId()) - .setReceivedAt(null != dto.getReceivedAt() ? dto.getReceivedAt().toInstant() : null) - .setTo(dto.getTo()) - .setClientReference(dto.getClientReference()) - .setOperatorId(dto.getOperatorId()) - .setSentAt(null != dto.getSentAt() ? dto.getSentAt().toInstant() : null) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java b/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java deleted file mode 100644 index 95350fc2a..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/adapters/converters/ParametersDtoConverter.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.sms.adapters.converters; - -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.sms.models.Parameters; -import com.sinch.sdk.domains.sms.models.Parameters.Entry; -import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjDto; -import com.sinch.sdk.domains.sms.models.dto.v1.ParameterObjParameterKeyDto; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; - -public class ParametersDtoConverter { - - public static Parameters convert(ParameterObjDto dto) { - if (null == dto) { - return null; - } - - ArrayList client = new ArrayList<>(); - dto.forEach((key, value) -> client.addAll(convertParameters(key, value))); - - return new Parameters(client); - } - - public static ParameterObjDto convert(Parameters parameters) { - ParameterObjDto dto = new ParameterObjDto(); - - parameters - .entrySet() - .iterator() - .forEachRemaining(entries -> dto.put(entries.getKey(), convert(entries.getValue()))); - return dto; - } - - public static HashMap convert(Collection client) { - if (null == client) { - return null; - } - HashMap dto = new HashMap<>(); - - client.forEach( - entry -> { - dto.put(entry.getValue().getLeft(), entry.getValue().getRight()); - entry - .getDefaultValue() - .ifPresent(def -> dto.put(ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT, def)); - }); - return dto; - } - - public static Collection convertParameters(String parameterName, Object _dto) { - if (!(_dto instanceof Map)) { - return null; - } - ArrayList client = new ArrayList<>(); - - @SuppressWarnings("unchecked") - Map dto = (Map) _dto; - - AtomicReference> defValue = - new AtomicReference<>( - dto.entrySet().stream() - .filter( - entry -> - entry.getKey().equals(ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT)) - .map(Map.Entry::getValue) - .findFirst()); - - dto.forEach( - (key, value) -> { - if (!key.equals(ParameterObjParameterKeyDto.JSON_PROPERTY_DEFAULT)) { - client.add( - new Entry(parameterName, new Pair<>(key, value), defValue.get().orElse(null))); - defValue.set(Optional.empty()); - } - }); - return client; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java index 92f06fcce..f2500d985 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SMSService.java @@ -42,10 +42,10 @@ public interface SMSService { GroupsService groups(); /** - * WebHooksService Service instance + * Sinch Events helpers instance * - * @return service instance for project - * @since 1.5 + * @return instance service related to Sinch Events helpers + * @since 2.0 */ - WebHooksService webhooks(); + SinchEventsService sinchEvents(); } diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SinchEventsService.java new file mode 100644 index 000000000..a2a595587 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/SinchEventsService.java @@ -0,0 +1,47 @@ +package com.sinch.sdk.domains.sms.api.v1; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.sms.models.v1.sinchevents.SmsSinchEvent; +import java.util.Map; + +/** + * SMS Sinch Events service + * + *

Callbacks + * + *

A callback is an HTTP POST request with a notification made by the Sinch SMS REST API to a URI + * of your choosing. + * + *

The REST API expects the receiving server to respond with a response code within the 2xx + * success range. For 5xx the callback will be retried. For 429 + * the callback will be retried and the throughput will be lowered. For other status codes in the + * 4xx range the callback will not be retried. The first initial retry will happen 5 + * seconds after the first try. The next attempt is after 10 seconds, then after 20 seconds, after + * 40 seconds, after 80 seconds, doubling on every attempt. The last retry will be at 81920 seconds + * (or 22 hours 45 minutes) after the initial failed attempt. + * + *

The SMS REST API offers the following callback options which can be configured for your + * account upon request to your account manager. + * + *

    + *
  • Callback with mutual authentication over TLS (HTTPS) connection by provisioning the + * callback URL with client keystore and password. + *
  • Callback with basic authentication by provisioning the callback URL with username and + * password. + *
  • Callback with OAuth 2.0 by provisioning the callback URL with username, password and the + * URL to fetch OAuth access token. + *
  • Callback using AWS SNS by provisioning the callback URL with an Access Key ID, Secret Key + * and Region. + *
+ * + * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/ + * @since 2.0 + */ +public interface SinchEventsService { + + SmsSinchEvent parseEvent(String jsonPayload) throws ApiMappingException; + + boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload); +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/WebHooksService.java deleted file mode 100644 index 1cf62c36c..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/api/v1/WebHooksService.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.sinch.sdk.domains.sms.api.v1; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.sms.models.v1.webhooks.SmsEvent; -import java.util.Map; - -/** - * SMS WebHooks service - * - *

Callbacks - * - *

A callback is an HTTP POST request with a notification made by the Sinch SMS REST API to a URI - * of your choosing. - * - *

The REST API expects the receiving server to respond with a response code within the 2xx - * success range. For 5xx the callback will be retried. For 429 - * the callback will be retried and the throughput will be lowered. For other status codes in the - * 4xx range the callback will not be retried. The first initial retry will happen 5 - * seconds after the first try. The next attempt is after 10 seconds, then after 20 seconds, after - * 40 seconds, after 80 seconds, doubling on every attempt. The last retry will be at 81920 seconds - * (or 22 hours 45 minutes) after the initial failed attempt. - * - *

The SMS REST API offers the following callback options which can be configured for your - * account upon request to your account manager. - * - *

    - *
  • Callback with mutual authentication over TLS (HTTPS) connection by provisioning the - * callback URL with client keystore and password. - *
  • Callback with basic authentication by provisioning the callback URL with username and - * password. - *
  • Callback with OAuth 2.0 by provisioning the callback URL with username, password and the - * URL to fetch OAuth access token. - *
  • Callback using AWS SNS by provisioning the callback URL with an Access Key ID, Secret Key - * and Region. - *
- * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/ - * @since 1.5 - */ -public interface WebHooksService { - - SmsEvent parseEvent(String jsonPayload) throws ApiMappingException; - - boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload); -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java index 2699b0f07..3ab3ebba5 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SMSService.java @@ -40,7 +40,7 @@ public class SMSService implements com.sinch.sdk.domains.sms.api.v1.SMSService { private volatile InboundsService inbounds; private volatile DeliveryReportsService deliveryReports; private volatile GroupsService groups; - private volatile WebHooksService webhooks; + private volatile SinchEventsService sinchEvents; public SMSService( UnifiedCredentials credentials, @@ -66,14 +66,18 @@ public SMSService( @Override public BatchesService batches() { if (null == this.batches) { - instanceLazyInit(); - this.batches = - new BatchesServiceImpl( - httpClientSupplier.get(), - context.getSmsServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + synchronized (this) { + if (null == this.batches) { + instanceLazyInit(); + this.batches = + new BatchesServiceImpl( + httpClientSupplier.get(), + context.getSmsServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.batches; } @@ -81,14 +85,18 @@ public BatchesService batches() { @Override public InboundsService inbounds() { if (null == this.inbounds) { - instanceLazyInit(); - this.inbounds = - new InboundsServiceImpl( - httpClientSupplier.get(), - context.getSmsServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + synchronized (this) { + if (null == this.inbounds) { + instanceLazyInit(); + this.inbounds = + new InboundsServiceImpl( + httpClientSupplier.get(), + context.getSmsServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.inbounds; } @@ -96,14 +104,18 @@ public InboundsService inbounds() { @Override public DeliveryReportsService deliveryReports() { if (null == this.deliveryReports) { - instanceLazyInit(); - this.deliveryReports = - new DeliveryReportsServiceImpl( - httpClientSupplier.get(), - context.getSmsServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + synchronized (this) { + if (null == this.deliveryReports) { + instanceLazyInit(); + this.deliveryReports = + new DeliveryReportsServiceImpl( + httpClientSupplier.get(), + context.getSmsServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.deliveryReports; } @@ -111,24 +123,32 @@ public DeliveryReportsService deliveryReports() { @Override public GroupsService groups() { if (null == this.groups) { - instanceLazyInit(); - this.groups = - new GroupsServiceImpl( - httpClientSupplier.get(), - context.getSmsServer(), - authManagers, - HttpMapper.getInstance(), - uriUUID); + synchronized (this) { + if (null == this.groups) { + instanceLazyInit(); + this.groups = + new GroupsServiceImpl( + httpClientSupplier.get(), + context.getSmsServer(), + authManagers, + HttpMapper.getInstance(), + uriUUID); + } + } } return this.groups; } @Override - public WebHooksService webhooks() { - if (null == this.webhooks) { - this.webhooks = new WebHooksService(new HmacAuthenticationValidation()); + public SinchEventsService sinchEvents() { + if (null == this.sinchEvents) { + synchronized (this) { + if (null == this.sinchEvents) { + this.sinchEvents = new SinchEventsService(new HmacAuthenticationValidation()); + } + } } - return this.webhooks; + return this.sinchEvents; } private void instanceLazyInit() { @@ -140,18 +160,9 @@ private void instanceLazyInit() { AuthManager oAuthManager = null; Objects.requireNonNull(credentials, "Credentials must be defined"); Objects.requireNonNull(context, "Context must be defined"); - StringUtil.requireNonEmpty(context.getSmsUrl(), "'smsUrl' must be defined"); - - // To be deprecated with 2.0: no more defaulting to US region - if (Boolean.TRUE == context.regionAsDefault()) { - LOGGER.warning( - String.format( - "Using default region for SMS '%s'. This default fallback will be removed in next" - + " major release and will cause a runtime error. Please configure the region" - + " you want to be used (see" - + " https://www.javadoc.io/static/com.sinch.sdk/sinch-sdk-java/1.6.0/com/sinch/sdk/models/Configuration.Builder.html#setSmsRegion(com.sinch.sdk.models.SMSRegion))", - context.getSmsRegion())); - } + StringUtil.requireNonEmpty(context.getSmsUrl(), "'SMS Url' must be defined"); + Objects.requireNonNull(context.getSmsRegion(), "'SMS Region' must be defined"); + StringUtil.requireNonEmpty(context.getSmsRegion().value(), "'SMS Region' must be defined"); if (credentials instanceof UnifiedCredentials) { UnifiedCredentials unifiedCredentials = (UnifiedCredentials) credentials; diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SinchEventsService.java new file mode 100644 index 000000000..17ef68352 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/SinchEventsService.java @@ -0,0 +1,34 @@ +package com.sinch.sdk.domains.sms.api.v1.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.auth.HmacAuthenticationValidation; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.sms.models.v1.sinchevents.SmsSinchEvent; +import java.util.Map; + +public class SinchEventsService implements com.sinch.sdk.domains.sms.api.v1.SinchEventsService { + + private final HmacAuthenticationValidation authenticationChecker; + + public SinchEventsService(HmacAuthenticationValidation authenticationChecker) { + this.authenticationChecker = authenticationChecker; + } + + @Override + public SmsSinchEvent parseEvent(String jsonPayload) throws ApiMappingException { + + try { + return Mapper.getInstance().readValue(jsonPayload, SmsSinchEvent.class); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } + + @Override + public boolean validateAuthenticationHeader( + String secret, Map headers, String jsonPayload) { + + return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/WebHooksService.java deleted file mode 100644 index 962b1de71..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/api/v1/adapters/WebHooksService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.sinch.sdk.domains.sms.api.v1.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.auth.HmacAuthenticationValidation; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.sms.models.v1.webhooks.SmsEvent; -import java.util.Map; - -public class WebHooksService implements com.sinch.sdk.domains.sms.api.v1.WebHooksService { - - private final HmacAuthenticationValidation authenticationChecker; - - public WebHooksService(HmacAuthenticationValidation authenticationChecker) { - this.authenticationChecker = authenticationChecker; - } - - public SmsEvent parseEvent(String jsonPayload) throws ApiMappingException { - - try { - return Mapper.getInstance().readValue(jsonPayload, SmsEvent.class); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } - - public boolean validateAuthenticationHeader( - String secret, Map headers, String jsonPayload) { - - return authenticationChecker.validateAuthenticationHeader(secret, headers, jsonPayload); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BaseBatch.java b/client/src/main/com/sinch/sdk/domains/sms/models/BaseBatch.java deleted file mode 100644 index 9fe049854..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/BaseBatch.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.models.OptionalValue; -import java.time.Instant; -import java.util.Collection; -import java.util.Objects; - -/** - * Base class for Batch types - * - * @param Type of batch - * @since 1.0 - */ -public class BaseBatch { - - private final T body; - - private final Collection to; - - private final OptionalValue from; - - private final OptionalValue deliveryReport; - - private final OptionalValue sendAt; - - private final OptionalValue expireAt; - - private final OptionalValue callbackUrl; - - private final OptionalValue clientReference; - - private final OptionalValue feedbackEnabled; - - protected BaseBatch( - Collection to, - OptionalValue from, - T body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue clientReference, - OptionalValue feedbackEnabled) { - Objects.requireNonNull(to); - Objects.requireNonNull(body); - this.to = to; - this.from = from; - this.body = body; - this.deliveryReport = deliveryReport; - this.sendAt = sendAt; - this.expireAt = expireAt; - this.callbackUrl = callbackUrl; - this.clientReference = clientReference; - this.feedbackEnabled = feedbackEnabled; - } - - public Collection getTo() { - return to; - } - - public T getBody() { - return body; - } - - public OptionalValue getFrom() { - return from; - } - - public OptionalValue getDeliveryReport() { - return deliveryReport; - } - - public OptionalValue getSendAt() { - return sendAt; - } - - public OptionalValue getExpireAt() { - return expireAt; - } - - public OptionalValue getCallbackUrl() { - return callbackUrl; - } - - public OptionalValue getClientReference() { - return clientReference; - } - - public OptionalValue isFeedbackEnabled() { - return feedbackEnabled; - } - - @Override - public String toString() { - return "BaseBatch{" - + "body=" - + body - + ", to=" - + to - + ", from='" - + from - + '\'' - + ", deliveryReportType=" - + deliveryReport - + ", sendAt=" - + sendAt - + ", expireAt=" - + expireAt - + ", callbackUrl='" - + callbackUrl - + '\'' - + ", clientReference='" - + clientReference - + '\'' - + ", feedbackEnabled=" - + feedbackEnabled - + '}'; - } - - protected static class Builder> { - - public Collection to; - - public OptionalValue from = OptionalValue.empty(); - - public T body; - - public OptionalValue deliveryReport = OptionalValue.empty(); - - public OptionalValue sendAt = OptionalValue.empty(); - - public OptionalValue expireAt = OptionalValue.empty(); - - public OptionalValue callbackUrl = OptionalValue.empty(); - - public OptionalValue clientReference = OptionalValue.empty(); - - public OptionalValue feedbackEnabled = OptionalValue.empty(); - - /** - * @param to List of Phone numbers and group IDs that will receive the batch - * @return current builder - */ - public B setTo(Collection to) { - this.to = to; - return self(); - } - - /** - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required - * if Automatic Default Originator not configured. - * @return current builder - */ - public B setFrom(String from) { - this.from = OptionalValue.of(from); - return self(); - } - - /** - * @param body The message content - * @return current builder - */ - public B setBody(T body) { - this.body = body; - return self(); - } - - /** - * @param deliveryReport Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @return current builder - */ - public B setDeliveryReport(DeliveryReportType deliveryReport) { - this.deliveryReport = OptionalValue.of(deliveryReport); - return self(); - } - - /** - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @return current builder - */ - public B setSendAt(Instant sendAt) { - this.sendAt = OptionalValue.of(sendAt); - return self(); - } - - /** - * @param expireAt If set, the system will stop trying to deliver the message at this point. - * Must be after send_at. Default and max is 3 days after send_at - * @return current builder - */ - public B setExpireAt(Instant expireAt) { - this.expireAt = OptionalValue.of(expireAt); - return self(); - } - - /** - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @return current builder - */ - public B setCallbackUrl(String callbackUrl) { - this.callbackUrl = OptionalValue.of(callbackUrl); - return self(); - } - - /** - * @param clientReference The client identifier of a batch message. If set, the identifier will - * be added in the delivery report/callback of this batch - * @return current builder - */ - public B setClientReference(String clientReference) { - this.clientReference = OptionalValue.of(clientReference); - return self(); - } - - /** - * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. - * @return current builder - */ - public B setFeedbackEnabled(Boolean feedbackEnabled) { - this.feedbackEnabled = OptionalValue.of(feedbackEnabled); - return self(); - } - - public BaseBatch build() { - return new BaseBatch<>( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } - - public static class BatchBuilder extends BaseBatch.Builder> { - @Override - protected BatchBuilder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java deleted file mode 100644 index f78640d05..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/BaseDeliveryReport.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent; -import java.util.Objects; -import java.util.Optional; - -/** - * Base class for Delivery Report WebHook - * - * @since 1.0 - */ -public abstract class BaseDeliveryReport implements WebhooksEvent { - - private final String batchId; - private final String clientReference; - - /** - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - */ - public BaseDeliveryReport(String batchId, String clientReference) { - Objects.requireNonNull(batchId); - this.batchId = batchId; - this.clientReference = clientReference; - } - - public String getBatchId() { - return batchId; - } - - public Optional getClientReference() { - return Optional.ofNullable(clientReference); - } - - @Override - public String toString() { - return "BaseDeliveryReport{" - + "batchId='" - + batchId - + '\'' - + ", clientReference='" - + clientReference - + '\'' - + '}'; - } - - public abstract static class Builder> { - protected String batchId; - protected String clientReference; - - public B setBatchId(String batchId) { - this.batchId = batchId; - return self(); - } - - public B setClientReference(String clientReference) { - this.clientReference = clientReference; - return self(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java b/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java deleted file mode 100644 index 5d3d31651..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/Batch.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * Base class for Batch types - * - * @param Type of batch - * @since 1.0 - */ -public class Batch { - - private final String id; - - private final Collection to; - - private final String from; - - private final Boolean canceled; - - private final T body; - - private final Instant createdAt; - - private final Instant modifiedAt; - - private final DeliveryReportType deliveryReport; - - private final Instant sendAt; - - private final Instant expireAt; - - private final String callbackUrl; - - private final String clientReference; - - private final Boolean feedbackEnabled; - - /** - * @param id Unique identifier for batch - * @param to List of Phone numbers and group IDs that will receive the batch - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if - * Automatic Default Originator not configured. - * @param canceled Indicates if the batch has been canceled or not. - * @param body The message content - * @param createdAt when batch was created - * @param modifiedAt when batch was last updated - * @param deliveryReport Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @param expireAt If set, the system will stop trying to deliver the message at this point. Must - * be after send_at. Default and max is 3 days after send_at - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @param clientReference The client identifier of a batch message. If set, the identifier will be - * added in the delivery report/callback of this batch - * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. - */ - public Batch( - String id, - Collection to, - String from, - Boolean canceled, - T body, - Instant createdAt, - Instant modifiedAt, - DeliveryReportType deliveryReport, - Instant sendAt, - Instant expireAt, - String callbackUrl, - String clientReference, - Boolean feedbackEnabled) { - this.id = id; - this.to = to; - this.from = from; - this.canceled = canceled; - this.body = body; - this.createdAt = createdAt; - this.modifiedAt = modifiedAt; - this.deliveryReport = deliveryReport; - this.sendAt = sendAt; - this.expireAt = expireAt; - this.callbackUrl = callbackUrl; - this.clientReference = clientReference; - this.feedbackEnabled = feedbackEnabled; - } - - public static BatchBuilder batchBuilder() { - return new BatchBuilder<>(); - } - - public String getId() { - return id; - } - - public Collection getTo() { - return to; - } - - public String getFrom() { - return from; - } - - public Boolean isCanceled() { - return canceled; - } - - public T getBody() { - return body; - } - - public Instant getCreatedAt() { - return createdAt; - } - - public Instant getModifiedAt() { - return modifiedAt; - } - - public DeliveryReportType getDeliveryReport() { - return deliveryReport; - } - - public Instant getSendAt() { - return sendAt; - } - - public Instant getExpireAt() { - return expireAt; - } - - public String getCallbackUrl() { - return callbackUrl; - } - - public String getClientReference() { - return clientReference; - } - - public Boolean isFeedbackEnabled() { - return feedbackEnabled; - } - - @Override - public String toString() { - return "Batch{" - + "id='" - + id - + '\'' - + ", to=" - + to - + ", from='" - + from - + '\'' - + ", canceled=" - + canceled - + ", body=" - + body - + ", createdAt=" - + createdAt - + ", modifiedAt=" - + modifiedAt - + ", deliveryReportType=" - + deliveryReport - + ", sendAt=" - + sendAt - + ", expireAt=" - + expireAt - + ", callbackUrl='" - + callbackUrl - + '\'' - + ", clientReference='" - + clientReference - + '\'' - + ", feedbackEnabled=" - + feedbackEnabled - + '}'; - } - - protected static class Builder> { - - String id; - - Collection to; - - String from; - - Boolean canceled; - - T body; - - Instant createdAt; - - Instant modifiedAt; - - DeliveryReportType deliveryReport; - - Instant sendAt; - - Instant expireAt; - - String callbackUrl; - - String clientReference; - - Boolean feedbackEnabled; - - public B setId(String id) { - this.id = id; - return self(); - } - - public B setTo(Collection to) { - this.to = to; - return self(); - } - - public B setFrom(String from) { - this.from = from; - return self(); - } - - public B setCanceled(Boolean canceled) { - this.canceled = canceled; - return self(); - } - - public B setBody(T body) { - this.body = body; - return self(); - } - - public B setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - return self(); - } - - public B setModifiedAt(Instant modifiedAt) { - this.modifiedAt = modifiedAt; - return self(); - } - - public B setDeliveryReport(DeliveryReportType deliveryReport) { - this.deliveryReport = deliveryReport; - return self(); - } - - public B setSendAt(Instant sendAt) { - this.sendAt = sendAt; - return self(); - } - - public B setExpireAt(Instant expireAt) { - this.expireAt = expireAt; - return self(); - } - - public B setCallbackUrl(String callbackUrl) { - this.callbackUrl = callbackUrl; - return self(); - } - - public B setClientReference(String clientReference) { - this.clientReference = clientReference; - return self(); - } - - public B setFeedbackEnabled(Boolean feedbackEnabled) { - this.feedbackEnabled = feedbackEnabled; - return self(); - } - - public Batch build() { - return new Batch<>( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } - - public static class BatchBuilder extends Batch.Builder> { - @Override - protected BatchBuilder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java deleted file mode 100644 index 5d9a989e0..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/BatchBinary.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * BatchBinary type - * - * @since 1.0 - */ -public class BatchBinary extends Batch { - private final Boolean flashMessage; - private final Boolean truncateConcat; - private final Integer maxNumberOfMessageParts; - private final Integer fromTon; - private final Integer fromNpi; - private final String udh; - - /** - * @param id Unique identifier for batch - * @param to List of Phone numbers and group IDs that will receive the batch - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if - * Automatic Default Originator not configured. - * @param canceled Indicates if the batch has been canceled or not. - * @param body The message content - * @param createdAt when batch was created - * @param modifiedAt when batch was last updated - * @param deliveryReport Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @param expireAt If set, the system will stop trying to deliver the message at this point. Must - * be after send_at. Default and max is 3 days after send_at - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @param clientReference The client identifier of a batch message. If set, the identifier will be - * added in the delivery report/callback of this batch - * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. * - * @param flashMessage If sent as a flash message, displays true. - * @param truncateConcat If set to true, the message was shortened when exceeding one part. - * @param maxNumberOfMessageParts Displays the number of message parts set in the request. - * @param fromTon The type of number for the sender number. - * @param fromNpi Number Plan Indicator for the sender number. - * @param udh The UDH header of a binary message HEX encoded. Max 140 bytes including the body. - */ - public BatchBinary( - String id, - Collection to, - String from, - Boolean canceled, - String body, - Instant createdAt, - Instant modifiedAt, - DeliveryReportType deliveryReport, - Instant sendAt, - Instant expireAt, - String callbackUrl, - String clientReference, - Boolean feedbackEnabled, - Boolean flashMessage, - Boolean truncateConcat, - Integer maxNumberOfMessageParts, - Integer fromTon, - Integer fromNpi, - String udh) { - super( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.flashMessage = flashMessage; - this.truncateConcat = truncateConcat; - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - this.fromTon = fromTon; - this.fromNpi = fromNpi; - this.udh = udh; - } - - public Boolean isFlashMessage() { - return flashMessage; - } - - public Boolean isTruncateConcat() { - return truncateConcat; - } - - public Integer getMaxNumberOfMessageParts() { - return maxNumberOfMessageParts; - } - - public Integer getFromTon() { - return fromTon; - } - - public Integer getFromNpi() { - return fromNpi; - } - - public String getUdh() { - return udh; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "BatchBinary{" - + "flashMessage=" - + flashMessage - + ", truncateConcat=" - + truncateConcat - + ", maxNumberOfMessageParts=" - + maxNumberOfMessageParts - + ", fromTon=" - + fromTon - + ", fromNpi=" - + fromNpi - + ", udh='" - + udh - + '\'' - + "} " - + super.toString(); - } - - public static class Builder extends Batch.Builder { - - private Boolean flashMessage; - private Boolean truncateConcat; - private Integer maxNumberOfMessageParts; - private Integer fromTon; - private Integer fromNpi; - private String udh; - - private Builder() {} - - public Builder setFlashMessage(Boolean flashMessage) { - this.flashMessage = flashMessage; - return this; - } - - public Builder setTruncateConcat(Boolean truncateConcat) { - this.truncateConcat = truncateConcat; - return this; - } - - public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - return this; - } - - public Builder setFromTon(Integer fromTon) { - this.fromTon = fromTon; - return this; - } - - public Builder setFromNpi(Integer fromNpi) { - this.fromNpi = fromNpi; - return this; - } - - public Builder setUdh(String udh) { - this.udh = udh; - return this; - } - - public BatchBinary build() { - return new BatchBinary( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled, - flashMessage, - truncateConcat, - maxNumberOfMessageParts, - fromTon, - fromNpi, - udh); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java deleted file mode 100644 index f893963eb..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/BatchMedia.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * BatchMedia type - * - * @since 1.0 - */ -public class BatchMedia extends Batch { - private final Parameters parameters; - private final Boolean strictValidation; - - /** - * @param id Unique identifier for batch - * @param to List of Phone numbers and group IDs that will receive the batch - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if - * Automatic Default Originator not configured. - * @param canceled Indicates if the batch has been canceled or not. - * @param body The message content - * @param createdAt when batch was created - * @param modifiedAt when batch was last updated - * @param deliveryReport Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @param expireAt If set, the system will stop trying to deliver the message at this point. Must - * be after send_at. Default and max is 3 days after send_at - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @param clientReference The client identifier of a batch message. If set, the identifier will be - * added in the delivery report/callback of this batch - * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. * - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @param strictValidation Whether or not you want the media included in your message to be - * checked against Sinch MMS channel best practices. If set to true, your message will be - * rejected if it doesn't conform to the listed recommendations, otherwise no validation will - * be performed. - */ - public BatchMedia( - String id, - Collection to, - String from, - Boolean canceled, - MediaBody body, - Instant createdAt, - Instant modifiedAt, - DeliveryReportType deliveryReport, - Instant sendAt, - Instant expireAt, - String callbackUrl, - String clientReference, - Boolean feedbackEnabled, - Parameters parameters, - Boolean strictValidation) { - super( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.parameters = parameters; - this.strictValidation = strictValidation; - } - - public Parameters getParameters() { - return parameters; - } - - public Boolean isStrictValidation() { - return strictValidation; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "BatchMedia{" - + "parameters=" - + parameters - + ", strictValidation=" - + strictValidation - + "} " - + super.toString(); - } - - public static class Builder extends Batch.Builder { - private Parameters parameters; - private Boolean strictValidation; - - private Builder() {} - - public Builder setParameters(Parameters parameters) { - this.parameters = parameters; - return this; - } - - public Builder setStrictValidation(Boolean strictValidation) { - this.strictValidation = strictValidation; - return this; - } - - public BatchMedia build() { - return new BatchMedia( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled, - parameters, - strictValidation); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java b/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java deleted file mode 100644 index f79c8b089..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/BatchText.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Collection; - -/** - * BatchText type - * - * @since 1.0 - */ -public class BatchText extends Batch { - private final Boolean flashMessage; - private final Parameters parameters; - private final Boolean truncateConcat; - private final Integer maxNumberOfMessageParts; - private final Integer fromTon; - private final Integer fromNpi; - - /** - * @param id Unique identifier for batch - * @param to List of Phone numbers and group IDs that will receive the batch - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required if - * Automatic Default Originator not configured. - * @param canceled Indicates if the batch has been canceled or not. - * @param body The message content - * @param createdAt when batch was created - * @param modifiedAt when batch was last updated - * @param deliveryReport Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @param expireAt If set, the system will stop trying to deliver the message at this point. Must - * be after send_at. Default and max is 3 days after send_at - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @param clientReference The client identifier of a batch message. If set, the identifier will be - * added in the delivery report/callback of this batch - * @param feedbackEnabled If set to true, then feedback is expected after successful delivery. - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @param flashMessage If sent as a flash message, displays true. - * @param truncateConcat If set to true, the message was shortened when exceeding one part. - * @param maxNumberOfMessageParts Displays the number of message parts set in the request. - * @param fromTon The type of number for the sender number. - * @param fromNpi Number Plan Indicator for the sender number. - */ - public BatchText( - String id, - Collection to, - String from, - Boolean canceled, - String body, - Instant createdAt, - Instant modifiedAt, - DeliveryReportType deliveryReport, - Instant sendAt, - Instant expireAt, - String callbackUrl, - String clientReference, - Boolean flashMessage, - Boolean feedbackEnabled, - Parameters parameters, - Boolean truncateConcat, - Integer maxNumberOfMessageParts, - Integer fromTon, - Integer fromNpi) { - super( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.flashMessage = flashMessage; - this.parameters = parameters; - this.truncateConcat = truncateConcat; - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - this.fromTon = fromTon; - this.fromNpi = fromNpi; - } - - public Parameters getParameters() { - return parameters; - } - - public Boolean isFlashMessage() { - return flashMessage; - } - - public Boolean isTruncateConcat() { - return truncateConcat; - } - - public Integer getMaxNumberOfMessageParts() { - return maxNumberOfMessageParts; - } - - public Integer getFromTon() { - return fromTon; - } - - public Integer getFromNpi() { - return fromNpi; - } - - @Override - public String toString() { - return "BatchText{" - + "flashMessage=" - + flashMessage - + ", parameters=" - + parameters - + ", truncateConcat=" - + truncateConcat - + ", maxNumberOfMessageParts=" - + maxNumberOfMessageParts - + ", fromTon=" - + fromTon - + ", fromNpi=" - + fromNpi - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends Batch.Builder { - private Boolean flashMessage; - private Parameters parameters; - private Boolean truncateConcat; - private Integer maxNumberOfMessageParts; - private Integer fromTon; - private Integer fromNpi; - - private Builder() {} - - public Builder setFlashMessage(Boolean flashMessage) { - this.flashMessage = flashMessage; - return this; - } - - public Builder setParameters(Parameters parameters) { - this.parameters = parameters; - return this; - } - - public Builder setTruncateConcat(Boolean truncateConcat) { - this.truncateConcat = truncateConcat; - return this; - } - - public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - return this; - } - - public Builder setFromTon(Integer fromTon) { - this.fromTon = fromTon; - return this; - } - - public Builder setFromNpi(Integer fromNpi) { - this.fromNpi = fromNpi; - return this; - } - - public BatchText build() { - return new BatchText( - id, - to, - from, - canceled, - body, - createdAt, - modifiedAt, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - flashMessage, - feedbackEnabled, - parameters, - truncateConcat, - maxNumberOfMessageParts, - fromTon, - fromNpi); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatch.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatch.java deleted file mode 100644 index 8496c3c8f..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatch.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Collection; -import java.util.Objects; - -/** - * Common Definition to Delivery Report - * - * @since 1.0 - */ -public abstract class DeliveryReportBatch extends BaseDeliveryReport { - - private final Collection statuses; - private final Integer totalMessageCount; - - /** - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param statuses Required. Array with status objects. Only status codes with at - * least one recipient will be listed. - * @param totalMessageCount Required. The total number of messages in the batch. - */ - public DeliveryReportBatch( - String batchId, - String clientReference, - Collection statuses, - Integer totalMessageCount) { - super(batchId, clientReference); - Objects.requireNonNull(statuses); - Objects.requireNonNull(totalMessageCount); - this.statuses = statuses; - this.totalMessageCount = totalMessageCount; - } - - public Collection getStatuses() { - return statuses; - } - - public Integer getTotalMessageCount() { - return totalMessageCount; - } - - @Override - public String toString() { - return "DeliveryReportBatch{" - + "statuses=" - + statuses - + ", totalMessageCount=" - + totalMessageCount - + "} " - + super.toString(); - } - - public abstract static class Builder> extends BaseDeliveryReport.Builder { - protected Collection statuses; - protected Integer totalMessageCount; - - public B setStatuses(Collection statuses) { - this.statuses = statuses; - return self(); - } - - public B setTotalMessageCount(Integer totalMessageCount) { - this.totalMessageCount = totalMessageCount; - return self(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - public abstract DeliveryReportBatch build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchMMS.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchMMS.java deleted file mode 100644 index 291c0b57e..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchMMS.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Collection; - -/** - * MMS delivery Report - * - * @since 1.0 - */ -public class DeliveryReportBatchMMS extends DeliveryReportBatch { - - /** - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param statuses Required. Array with status objects. Only status codes with at - * least one recipient will be listed. - * @param totalMessageCount Required. The total number of messages in the batch. - */ - public DeliveryReportBatchMMS( - String batchId, - String clientReference, - Collection statuses, - Integer totalMessageCount) { - super(batchId, clientReference, statuses, totalMessageCount); - } - - @Override - public String toString() { - return "DeliveryReportBatchMMS{} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends DeliveryReportBatch.Builder { - - protected Builder() { - super(); - } - - public DeliveryReportBatchMMS build() { - return new DeliveryReportBatchMMS(batchId, clientReference, statuses, totalMessageCount); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchSMS.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchSMS.java deleted file mode 100644 index 2c78e7792..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportBatchSMS.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Collection; - -/** - * SMS delivery Report - * - * @since 1.0 - */ -public class DeliveryReportBatchSMS extends DeliveryReportBatch { - - /** - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param statuses Required. Array with status objects. Only status codes with at - * least one recipient will be listed. - * @param totalMessageCount Required. The total number of messages in the batch. - */ - public DeliveryReportBatchSMS( - String batchId, - String clientReference, - Collection statuses, - Integer totalMessageCount) { - super(batchId, clientReference, statuses, totalMessageCount); - } - - @Override - public String toString() { - return "DeliveryReportBatchSMS{} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends DeliveryReportBatch.Builder { - - private Builder() { - super(); - } - - public DeliveryReportBatchSMS build() { - return new DeliveryReportBatchSMS(batchId, clientReference, statuses, totalMessageCount); - } - } -} 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 deleted file mode 100644 index 72a5e50a9..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportErrorCode.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Applied encoding for message. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/deliveryReport!path=1/encoding&t=request - * @since 1.0 - */ -public class DeliveryReportErrorCode extends EnumDynamic { - - /** - * Message is queued within REST API system and will be dispatched according to the rate of the - * account. - */ - public static final DeliveryReportErrorCode QUEUED = new DeliveryReportErrorCode(400); - - /** Message has been dispatched to SMSC. */ - public static final DeliveryReportErrorCode DISPATCHED = new DeliveryReportErrorCode(401); - - /** SMSC rejected message. Retrying is likely to cause the same error. */ - public static final DeliveryReportErrorCode MESSAGE_UNROUTABLE = new DeliveryReportErrorCode(402); - - /** An unexpected error caused the message to fail. */ - public static final DeliveryReportErrorCode INTERNAL_ERROR = new DeliveryReportErrorCode(403); - - /** Message failed because of temporary delivery failure. Message can be retried. */ - public static final DeliveryReportErrorCode TEMPORARY_DELIVERY_FAILURE = - new DeliveryReportErrorCode(404); - - /** - * One or more parameters in the message body has no mapping for this recipient. See Message - * Parameterization - */ - public static final DeliveryReportErrorCode UNMATCHED_PARAMETER = - new DeliveryReportErrorCode(405); - - /** - * Message was expired before reaching SMSC. This may happen if the expiry time for the message - * was very short. - */ - public static final DeliveryReportErrorCode INTERNAL_EXPIRY = new DeliveryReportErrorCode(406); - - /** Message was cancelled by user before reaching SMSC. */ - public static final DeliveryReportErrorCode CANCELLED = new DeliveryReportErrorCode(407); - - /** SMSC rejected the message. Retrying is likely to cause the same error. */ - public static final DeliveryReportErrorCode INTERNAL_REJECT = new DeliveryReportErrorCode(408); - - /** - * No default originator exists/configured for this recipient when sending message without - * originator. - */ - public static final DeliveryReportErrorCode UNMATCHED_DEFAULT_ORIGINATOR = - new DeliveryReportErrorCode(410); - - /** - * Message failed as the number of message parts exceeds the defined max number of message parts. - */ - public static final DeliveryReportErrorCode EXCEEDED_PARTS_LIMIT = - new DeliveryReportErrorCode(411); - - /** SMSC rejected the message. The account hasn't been provisioned for this region. */ - public static final DeliveryReportErrorCode UNPROVISIONED_REGION = - new DeliveryReportErrorCode(412); - - /** The account is blocked. Reach out to support for help. Potentially out of credits. */ - public static final DeliveryReportErrorCode BLOCKED = new DeliveryReportErrorCode(413); - - /** - * MMS only, the request failed due to a bad media URL. It is possible that the URL was - * unreachable, or sent a bad response. - */ - public static final DeliveryReportErrorCode BAD_MEDIA = new DeliveryReportErrorCode(414); - - /** MMS only, message reached MMSC but was rejected by MMS gateway or mobile network. */ - public static final DeliveryReportErrorCode DELIVERY_REPORT_REJECTED = - new DeliveryReportErrorCode(415); - - /** MMS only, message reached MMSC but it is not supported. */ - public static final DeliveryReportErrorCode DELIVERY_REPORT_NOT_SUPPORTED = - new DeliveryReportErrorCode(416); - - /** - * MMS only, message reached MMSC but the destination network or the mobile subscriber cannot be - * reached. - */ - public static final DeliveryReportErrorCode DELIVERY_REPORT_UNREACHABLE = - new DeliveryReportErrorCode(417); - - /** - * MMS only, message reached MMSC but the handset of the mobile subscriber does not recognize the - * message content. - */ - public static final DeliveryReportErrorCode DELIVERY_REPORT_UNRECOGNIZED = - new DeliveryReportErrorCode(418); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DeliveryReportErrorCode.class, - DeliveryReportErrorCode::new, - Arrays.asList( - QUEUED, - DISPATCHED, - MESSAGE_UNROUTABLE, - INTERNAL_ERROR, - TEMPORARY_DELIVERY_FAILURE, - UNMATCHED_PARAMETER, - INTERNAL_EXPIRY, - CANCELLED, - INTERNAL_REJECT, - UNMATCHED_DEFAULT_ORIGINATOR, - EXCEEDED_PARTS_LIMIT, - UNPROVISIONED_REGION, - BLOCKED, - BAD_MEDIA, - DELIVERY_REPORT_REJECTED, - DELIVERY_REPORT_NOT_SUPPORTED, - DELIVERY_REPORT_UNREACHABLE, - DELIVERY_REPORT_UNRECOGNIZED)); - - private DeliveryReportErrorCode(Integer value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DeliveryReportErrorCode from(Integer value) { - return ENUM_SUPPORT.from(value); - } - - public static Integer valueOf(DeliveryReportErrorCode e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipient.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipient.java deleted file mode 100644 index 16cd51993..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipient.java +++ /dev/null @@ -1,197 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Optional; - -/** - * Common Definition to Delivery Report - * - * @since 1.0 - */ -public abstract class DeliveryReportRecipient extends BaseDeliveryReport { - - private final Instant at; - private final DeliveryReportErrorCode code; - private final String recipient; - private final DeliveryReportStatus status; - private final String appliedOriginator; - private final DeliveryReportRecipientEncoding encoding; - private final Integer numberOfMessageParts; - private final String operator; - private final Instant operatorStatusAt; - - /** - * Recipient Delivery Report Recipient - * - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param at Required. A timestamp of when the Delivery Report was created in the - * Sinch service - * @param code Required. The detailed status - * code. - * @param recipient Required. Phone number that was queried. - * @param status Required. The simplified status as described in Delivery Report - * Statuses - * @param appliedOriginator The default originator used for the recipient this delivery report - * belongs to, if default originator pool configured and no originator set when submitting - * batch. - * @param encoding Applied encoding for message. Present only if smart encoding is enabled. - * @param numberOfMessageParts The number of parts the message was split into. Present only if - * max_number_of_message_parts parameter was set. - * @param operator The operator that was used for delivering the message to this recipient, if - * enabled on the account by Sinch. - * @param operatorStatusAt A timestamp extracted from the Delivery Receipt from the originating - * SMSC - */ - public DeliveryReportRecipient( - String batchId, - String clientReference, - Instant at, - DeliveryReportErrorCode code, - String recipient, - DeliveryReportStatus status, - String appliedOriginator, - DeliveryReportRecipientEncoding encoding, - Integer numberOfMessageParts, - String operator, - Instant operatorStatusAt) { - super(batchId, clientReference); - this.at = at; - this.code = code; - this.recipient = recipient; - this.status = status; - this.appliedOriginator = appliedOriginator; - this.encoding = encoding; - this.numberOfMessageParts = numberOfMessageParts; - this.operator = operator; - this.operatorStatusAt = operatorStatusAt; - } - - public Instant getAt() { - return at; - } - - public DeliveryReportErrorCode getCode() { - return code; - } - - public String getRecipient() { - return recipient; - } - - public DeliveryReportStatus getStatus() { - return status; - } - - public Optional getAppliedOriginator() { - return Optional.ofNullable(appliedOriginator); - } - - public Optional getEncoding() { - return Optional.ofNullable(encoding); - } - - public Optional getNumberOfMessageParts() { - return Optional.ofNullable(numberOfMessageParts); - } - - public Optional getOperator() { - return Optional.ofNullable(operator); - } - - public Optional getOperatorStatusAt() { - return Optional.ofNullable(operatorStatusAt); - } - - @Override - public String toString() { - return "DeliveryReportRecipient{" - + "at=" - + at - + ", code='" - + code - + '\'' - + ", recipient='" - + recipient - + '\'' - + ", status=" - + status - + ", appliedOriginator='" - + appliedOriginator - + '\'' - + ", encoding='" - + encoding - + '\'' - + ", numberOfMessageParts=" - + numberOfMessageParts - + ", operator='" - + operator - + '\'' - + ", operatorStatusAt=" - + operatorStatusAt - + "} " - + super.toString(); - } - - public abstract static class Builder> extends BaseDeliveryReport.Builder { - - protected Instant at; - protected DeliveryReportErrorCode code; - protected String recipient; - protected DeliveryReportStatus status; - protected String appliedOriginator; - protected DeliveryReportRecipientEncoding encoding; - protected Integer numberOfMessageParts; - protected String operator; - protected Instant operatorStatusAt; - - public Builder setAt(Instant at) { - this.at = at; - return this; - } - - public Builder setCode(DeliveryReportErrorCode code) { - this.code = code; - return this; - } - - public Builder setRecipient(String recipient) { - this.recipient = recipient; - return this; - } - - public Builder setStatus(DeliveryReportStatus status) { - this.status = status; - return this; - } - - public Builder setAppliedOriginator(String appliedOriginator) { - this.appliedOriginator = appliedOriginator; - return this; - } - - public Builder setEncoding(DeliveryReportRecipientEncoding encoding) { - this.encoding = encoding; - return this; - } - - public Builder setNumberOfMessageParts(Integer numberOfMessageParts) { - this.numberOfMessageParts = numberOfMessageParts; - return this; - } - - public Builder setOperator(String operator) { - this.operator = operator; - return this; - } - - public Builder setOperatorStatusAt(Instant operatorStatusAt) { - this.operatorStatusAt = operatorStatusAt; - return this; - } - - public abstract DeliveryReportRecipient build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientEncoding.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientEncoding.java deleted file mode 100644 index 2726159b7..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientEncoding.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Applied encoding for message. - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/deliveryReport!path=1/encoding&t=request - * @since 1.0 - */ -public class DeliveryReportRecipientEncoding - extends EnumDynamic { - - public static final DeliveryReportRecipientEncoding GSM = - new DeliveryReportRecipientEncoding("GSM"); - public static final DeliveryReportRecipientEncoding UNICODE = - new DeliveryReportRecipientEncoding("UNICODE"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DeliveryReportRecipientEncoding.class, - DeliveryReportRecipientEncoding::new, - Arrays.asList(GSM, UNICODE)); - - private DeliveryReportRecipientEncoding(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DeliveryReportRecipientEncoding from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DeliveryReportRecipientEncoding e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientMMS.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientMMS.java deleted file mode 100644 index dc80daa78..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientMMS.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; - -/** - * SMS Delivery Report Recipient for MMS - * - * @since 1.0 - */ -public class DeliveryReportRecipientMMS extends DeliveryReportRecipient { - - /** - * Recipient Delivery Report for MMS - * - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param at Required. A timestamp of when the Delivery Report was created in the - * Sinch service - * @param code Required. The detailed status - * code. - * @param recipient Required. Phone number that was queried. - * @param status Required. The simplified status as described in Delivery Report - * Statuses - * @param appliedOriginator The default originator used for the recipient this delivery report - * belongs to, if default originator pool configured and no originator set when submitting - * batch. - * @param encoding Applied encoding for message. Present only if smart encoding is enabled. - * @param numberOfMessageParts The number of parts the message was split into. Present only if - * max_number_of_message_parts parameter was set. - * @param operator The operator that was used for delivering the message to this recipient, if - * enabled on the account by Sinch. - * @param operatorStatusAt A timestamp extracted from the Delivery Receipt from the originating - * SMSC - */ - public DeliveryReportRecipientMMS( - String batchId, - String clientReference, - Instant at, - DeliveryReportErrorCode code, - String recipient, - DeliveryReportStatus status, - String appliedOriginator, - DeliveryReportRecipientEncoding encoding, - Integer numberOfMessageParts, - String operator, - Instant operatorStatusAt) { - super( - batchId, - clientReference, - at, - code, - recipient, - status, - appliedOriginator, - encoding, - numberOfMessageParts, - operator, - operatorStatusAt); - } - - @Override - public String toString() { - return "DeliveryReportRecipientMMS{} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends DeliveryReportRecipient.Builder { - - protected Builder() { - super(); - } - - public DeliveryReportRecipientMMS build() { - return new DeliveryReportRecipientMMS( - batchId, - clientReference, - at, - code, - recipient, - status, - appliedOriginator, - encoding, - numberOfMessageParts, - operator, - operatorStatusAt); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientSMS.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientSMS.java deleted file mode 100644 index e32a1fd45..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportRecipientSMS.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; - -/** - * SMS Delivery Report Recipient for SMS - * - * @since 1.0 - */ -public class DeliveryReportRecipientSMS extends DeliveryReportRecipient { - - /** - * Recipient Delivery Report for SMS - * - * @param batchId Required. The ID of the batch this delivery report belongs to. - * @param clientReference The client identifier of the batch this delivery report belongs to, if - * set when submitting batch. - * @param at Required. A timestamp of when the Delivery Report was created in the - * Sinch service - * @param code Required. The detailed status - * code. - * @param recipient Required. Phone number that was queried. - * @param status Required. The simplified status as described in Delivery Report - * Statuses - * @param appliedOriginator The default originator used for the recipient this delivery report - * belongs to, if default originator pool configured and no originator set when submitting - * batch. - * @param encoding Applied encoding for message. Present only if smart encoding is enabled. - * @param numberOfMessageParts The number of parts the message was split into. Present only if - * max_number_of_message_parts parameter was set. - * @param operator The operator that was used for delivering the message to this recipient, if - * enabled on the account by Sinch. - * @param operatorStatusAt A timestamp extracted from the Delivery Receipt from the originating - * SMSC - */ - public DeliveryReportRecipientSMS( - String batchId, - String clientReference, - Instant at, - DeliveryReportErrorCode code, - String recipient, - DeliveryReportStatus status, - String appliedOriginator, - DeliveryReportRecipientEncoding encoding, - Integer numberOfMessageParts, - String operator, - Instant operatorStatusAt) { - super( - batchId, - clientReference, - at, - code, - recipient, - status, - appliedOriginator, - encoding, - numberOfMessageParts, - operator, - operatorStatusAt); - } - - @Override - public String toString() { - return "DeliveryReportRecipientSMS{} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends DeliveryReportRecipient.Builder { - - protected Builder() { - super(); - } - - public DeliveryReportRecipientSMS build() { - return new DeliveryReportRecipientSMS( - batchId, - clientReference, - at, - code, - recipient, - status, - appliedOriginator, - encoding, - numberOfMessageParts, - operator, - operatorStatusAt); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatus.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatus.java deleted file mode 100644 index 738eb970b..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatus.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * The status field describes which state a particular message is in. Note that statuses of type - * Intermediate will only be reported if you request a status per_recipient or - * per_recipient_final ( @see Retrieve - * a recipient delivery report). - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/section/Delivery-report-statuses - * @since 1.0 - */ -public class DeliveryReportStatus extends EnumDynamic { - - /** - * Message is queued within REST API system and will be dispatched according to the rate of the - * account. - */ - public static final DeliveryReportStatus QUEUED = new DeliveryReportStatus("Queued"); - - /** Message has been dispatched and accepted for delivery by the SMSC. */ - public static final DeliveryReportStatus DISPATCHED = new DeliveryReportStatus("Dispatched"); - - /** Message was aborted before reaching the SMSC. */ - public static final DeliveryReportStatus ABORTED = new DeliveryReportStatus("Aborted"); - - /** Message was cancelled by user before reaching SMSC. */ - public static final DeliveryReportStatus CANCELLED = new DeliveryReportStatus("Cancelled"); - - /** Message was rejected by the SMSC. */ - public static final DeliveryReportStatus REJECTED = new DeliveryReportStatus("Rejected"); - - /** - * Message has been deleted. Message was deleted by a remote SMSC. This may happen if the - * destination is an invalid MSISDN or opted out subscriber. - */ - public static final DeliveryReportStatus DELETED = new DeliveryReportStatus("Deleted"); - - /** Message has been delivered. */ - public static final DeliveryReportStatus DELIVERED = new DeliveryReportStatus("Delivered"); - - /** Message failed to be delivered. */ - public static final DeliveryReportStatus FAILED = new DeliveryReportStatus("Failed"); - - /** - * Message expired before delivery to the SMSC. This may happen if the expiry time for the message - * was very short. - */ - public static final DeliveryReportStatus EXPIRED = new DeliveryReportStatus("Expired"); - - /** - * Message was delivered to the SMSC but no Delivery Receipt has been received or a Delivery - * Receipt that couldn't be interpreted was received. - */ - public static final DeliveryReportStatus UNKNOWN = new DeliveryReportStatus("Unknown"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DeliveryReportStatus.class, - DeliveryReportStatus::new, - Arrays.asList( - QUEUED, - DISPATCHED, - ABORTED, - CANCELLED, - REJECTED, - DELETED, - DELIVERED, - FAILED, - EXPIRED, - UNKNOWN)); - - private DeliveryReportStatus(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DeliveryReportStatus from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DeliveryReportStatus e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatusDetails.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatusDetails.java deleted file mode 100644 index 1a7ae1d4e..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportStatusDetails.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Collection; - -/** - * Details related to a delivery report status - * - * @since 1.0 - */ -public class DeliveryReportStatusDetails { - - private final Integer code; - private final Integer count; - private final Collection recipients; - private final DeliveryReportStatus status; - - /** - * @param code Required. The detailed status - * code. - * @param count Required. The number of messages that currently has this code - * @param recipients Required. Only for full report. A list of the phone number - * recipients which messages has this status code - * @param status Required. The simplified status as described in Delivery Report - * Statuses - */ - public DeliveryReportStatusDetails( - Integer code, Integer count, Collection recipients, String status) { - this.code = code; - this.count = count; - this.recipients = recipients; - this.status = DeliveryReportStatus.from(status); - } - - public Integer getCode() { - return code; - } - - public Integer getCount() { - return count; - } - - public Collection getRecipients() { - return recipients; - } - - public DeliveryReportStatus getStatus() { - return status; - } - - @Override - public String toString() { - return "DeliveryReportStatusDetails{" - + "code=" - + code - + ", count=" - + count - + ", recipients=" - + recipients - + ", status=" - + status - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private Integer code; - private Integer count; - private Collection recipients; - private DeliveryReportStatus status; - - private Builder() {} - - public Builder setCode(Integer code) { - this.code = code; - return this; - } - - public Builder setCount(Integer count) { - this.count = count; - return this; - } - - public Builder setRecipients(Collection recipients) { - this.recipients = recipients; - return this; - } - - public Builder setStatus(DeliveryReportStatus status) { - this.status = status; - return this; - } - - public DeliveryReportStatusDetails build() { - return new DeliveryReportStatusDetails(code, count, recipients, status.value()); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportType.java b/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportType.java deleted file mode 100644 index ee2dc6cfd..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DeliveryReportType.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * DeliveryReportType authorized values - * - * @since 1.0 - */ -public class DeliveryReportType extends EnumDynamic { - - /** No delivery report callback will be sent. */ - public static final DeliveryReportType NONE = new DeliveryReportType("none"); - - /** A single delivery report callback will be sent. */ - public static final DeliveryReportType SUMMARY = new DeliveryReportType("summary"); - - /** - * A single delivery report callback will be sent which includes a list of recipients per delivery - * status. - */ - public static final DeliveryReportType FULL = new DeliveryReportType("full"); - - /** - * A delivery report callback will be sent for each status change of a message. This could result - * in a lot of callbacks and should be used with caution for larger batches. These delivery - * reports also include a timestamp of when the Delivery Report originated from the SMSC. - */ - public static final DeliveryReportType PER_RECIPIENT = new DeliveryReportType("per_recipient"); - - /** - * A delivery report callback representing the final status of a message will be sent for each - * recipient. This will send only one callback per recipient, compared to the multiple callbacks - * sent when using per_recipient. The delivery report will also include a timestamp of when it - * originated from the SMSC. - */ - public static final DeliveryReportType PER_RECIPIENT_FINAl = - new DeliveryReportType("per_recipient_final"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DeliveryReportType.class, - DeliveryReportType::new, - Arrays.asList(NONE, SUMMARY, FULL, PER_RECIPIENT, PER_RECIPIENT_FINAl)); - - private DeliveryReportType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DeliveryReportType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DeliveryReportType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DryRun.java b/client/src/main/com/sinch/sdk/domains/sms/models/DryRun.java deleted file mode 100644 index e80d2c984..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DryRun.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Collection; - -/** - * Information related to a dryRun request - * - * @since 1.0 - */ -public class DryRun { - - private final Integer numberOfRecipients; - private final Integer numberOfMessages; - private final Collection perRecipient; - - /** - * @param numberOfRecipients The number of recipients in the batch - * @param numberOfMessages The total number of SMS message parts to be sent in the batch - * @param perRecipient The recipient, the number of message parts to this recipient, the body of - * the message, and the encoding type of each message - */ - public DryRun( - Integer numberOfRecipients, - Integer numberOfMessages, - Collection perRecipient) { - this.numberOfRecipients = numberOfRecipients; - this.numberOfMessages = numberOfMessages; - this.perRecipient = perRecipient; - } - - public Integer getNumberOfRecipients() { - return numberOfRecipients; - } - - public Integer getNumberOfMessages() { - return numberOfMessages; - } - - public Collection getPerRecipient() { - return perRecipient; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "DryRun{" - + "numberOfRecipients=" - + numberOfRecipients - + ", numberOfMessages=" - + numberOfMessages - + ", perRecipient=" - + perRecipient - + '}'; - } - - public static class Builder { - - private Integer numberOfRecipients; - private Integer numberOfMessages; - private Collection perRecipient; - - public Builder setNumberOfRecipients(Integer numberOfRecipients) { - this.numberOfRecipients = numberOfRecipients; - return this; - } - - public Builder setNumberOfMessages(Integer numberOfMessages) { - this.numberOfMessages = numberOfMessages; - return this; - } - - public Builder setPerRecipient(Collection perRecipient) { - this.perRecipient = perRecipient; - return this; - } - - public DryRun build() { - return new DryRun(numberOfRecipients, numberOfMessages, perRecipient); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/DryRunPerRecipientDetails.java b/client/src/main/com/sinch/sdk/domains/sms/models/DryRunPerRecipientDetails.java deleted file mode 100644 index 895f7ca8a..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/DryRunPerRecipientDetails.java +++ /dev/null @@ -1,157 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -/** - * Details related to a dryRun recipient - * - * @since 1.0 - */ -public class DryRunPerRecipientDetails { - - private final String recipient; - private final Integer numberOfParts; - private final String body; - private final String encoding; - - /** - * Due to unused messagePart field, prefer the numberOfParts version - * usage. - * - *

This constructor will be removed in a next major release - * - * @deprecated - */ - @Deprecated - public DryRunPerRecipientDetails( - String recipient, String messagePart, String body, String encoding) { - this.recipient = recipient; - this.numberOfParts = null; - this.body = body; - this.encoding = encoding; - } - - public DryRunPerRecipientDetails( - String recipient, Integer numberOfParts, String body, String encoding) { - this.recipient = recipient; - this.numberOfParts = numberOfParts; - this.body = body; - this.encoding = encoding; - } - - /** - * Get recipient - * - * @return recipient - */ - public String getRecipient() { - return recipient; - } - - /** - * Due to unused messagePart field, prefer the {@link #getNumberOfParts()} usage. - * - *

This function will be removed in a next major release - * - * @deprecated - */ - @Deprecated - public String getMessagePart() { - return null; - } - - /** - * Get number of parts - * - * @return number of parts - */ - public Integer getNumberOfParts() { - return numberOfParts; - } - - /** - * Get body - * - * @return body - */ - public String getBody() { - return body; - } - - /** - * Get encoding - * - * @return encoding - */ - public String getEncoding() { - return encoding; - } - - @Override - public String toString() { - return "DryRunPerRecipientDetails{" - + "recipient='" - + recipient - + '\'' - + ", numberOfParts='" - + numberOfParts - + '\'' - + ", body='" - + body - + '\'' - + ", encoding='" - + encoding - + '\'' - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - private String recipient; - private Integer numberOfParts; - private String body; - private String encoding; - - public Builder setRecipient(String recipient) { - this.recipient = recipient; - return this; - } - - /** - * Due to unused messagePart field, prefer the {@link #setNumberOfParts(Integer)} - * usage. - * - *

This function will be removed in a next major release - * - * @deprecated - */ - @Deprecated - public Builder setMessagePart(String messageParts) { - // Do nothing - return this; - } - - public Builder setNumberOfParts(Integer numberOfParts) { - this.numberOfParts = numberOfParts; - return this; - } - - public Builder setBody(String body) { - this.body = body; - return this; - } - - public Builder setEncoding(String encoding) { - this.encoding = encoding; - return this; - } - - private Builder() {} - - public DryRunPerRecipientDetails build() { - return new DryRunPerRecipientDetails(recipient, numberOfParts, body, encoding); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Group.java b/client/src/main/com/sinch/sdk/domains/sms/models/Group.java deleted file mode 100644 index aa40e6e04..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/Group.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; -import java.util.Collection; - -public class Group { - - private final String id; - private final String name; - private final Integer size; - private final Instant createdAt; - private final Instant modifiedAt; - private final Collection childGroupIds; - private final GroupAutoUpdate autoUpdate; - - /** - * @param id Unique identifier for the group - * @param name Name of group if set - * @param size The number of members currently in the group - * @param createdAt Timestamp for when the group was created - * @param modifiedAt Timestamp for when the group was created - * @param childGroupIds MSISDNs of child group will be included in this group. If present then - * this group will be auto populated. Constraints: Elements must be group IDs - * @param autoUpdate Describes how this group is auto updated through user interaction. Is - * null if the group is not auto updated. - */ - public Group( - String id, - String name, - Integer size, - Instant createdAt, - Instant modifiedAt, - Collection childGroupIds, - GroupAutoUpdate autoUpdate) { - this.id = id; - this.name = name; - this.size = size; - this.createdAt = createdAt; - this.modifiedAt = modifiedAt; - this.childGroupIds = childGroupIds; - this.autoUpdate = autoUpdate; - } - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public Integer getSize() { - return size; - } - - public Instant getCreatedAt() { - return createdAt; - } - - public Instant getModifiedAt() { - return modifiedAt; - } - - public Collection getChildGroupIds() { - return childGroupIds; - } - - public GroupAutoUpdate getAutoUpdate() { - return autoUpdate; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "Group{" - + "id='" - + id - + '\'' - + ", name='" - + name - + '\'' - + ", size=" - + size - + ", createdAt=" - + createdAt - + ", modifiedAt=" - + modifiedAt - + ", childGroupIds=" - + childGroupIds - + ", autoUpdate=" - + autoUpdate - + '}'; - } - - public static class Builder { - - String id; - String name; - Integer size; - Instant createdAt; - Instant modifiedAt; - Collection childGroupIds; - GroupAutoUpdate autoUpdate; - - private Builder() {} - - public Builder setId(String id) { - this.id = id; - return this; - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public Builder setSize(Integer size) { - this.size = size; - return this; - } - - public Builder setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; - return this; - } - - public Builder setModifiedAt(Instant modifiedAt) { - this.modifiedAt = modifiedAt; - return this; - } - - public Builder setChildGroupIds(Collection childGroupIds) { - this.childGroupIds = childGroupIds; - return this; - } - - public Builder setAutoUpdate(GroupAutoUpdate autoUpdate) { - this.autoUpdate = autoUpdate; - return this; - } - - public Group build() { - return new Group(id, name, size, createdAt, modifiedAt, childGroupIds, autoUpdate); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdate.java b/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdate.java deleted file mode 100644 index 988e63b3b..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdate.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -public class GroupAutoUpdate { - private final String to; - private final GroupAutoUpdateKeyword add; - private final GroupAutoUpdateKeyword remove; - - /** - * @param to Short code or long number addressed in MO.
- * Constraints: Must be valid MSISDN or short code. - * @param add Keyword to be sent in MO to add MSISDN to a group - * @param remove Keyword to be sent in MO to remove MSISDN to a group - */ - public GroupAutoUpdate(String to, GroupAutoUpdateKeyword add, GroupAutoUpdateKeyword remove) { - this.to = to; - this.add = add; - this.remove = remove; - } - - public String getTo() { - return to; - } - - public GroupAutoUpdateKeyword getAdd() { - return add; - } - - public GroupAutoUpdateKeyword getRemove() { - return remove; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "GroupAutoUpdate{" + "to='" + to + '\'' + ", add=" + add + ", remove=" + remove + '}'; - } - - public static class Builder { - - String to; - GroupAutoUpdateKeyword add; - GroupAutoUpdateKeyword remove; - - private Builder() {} - - public Builder setTo(String to) { - this.to = to; - return this; - } - - public Builder setAdd(GroupAutoUpdateKeyword add) { - this.add = add; - return this; - } - - public Builder setRemove(GroupAutoUpdateKeyword remove) { - this.remove = remove; - return this; - } - - public GroupAutoUpdate build() { - return new GroupAutoUpdate(to, add, remove); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdateKeyword.java b/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdateKeyword.java deleted file mode 100644 index 8b88a5903..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/GroupAutoUpdateKeyword.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.models.OptionalValue; - -public class GroupAutoUpdateKeyword { - - private final OptionalValue firstWord; - private final OptionalValue secondWord; - - /** - * @param firstWord Opt-in keyword like "JOIN" if _auto_update.to_ is dedicated long/short number - * or unique brand keyword like "Sinch" if it is a shared short code. - * @param secondWord Opt-in keyword like "JOIN" if _auto_update.to_ is shared short code. - */ - private GroupAutoUpdateKeyword( - OptionalValue firstWord, OptionalValue secondWord) { - this.firstWord = firstWord; - this.secondWord = secondWord; - } - - public OptionalValue getFirstWord() { - return firstWord; - } - - public OptionalValue getSecondWord() { - return secondWord; - } - - @Override - public String toString() { - return "GroupAutoUpdateKeyword{" - + "firstWord='" - + firstWord - + '\'' - + ", secondWord='" - + secondWord - + '\'' - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue firstWord = OptionalValue.empty(); - OptionalValue secondWord = OptionalValue.empty(); - - private Builder() {} - - public Builder setFirstWord(String firstWord) { - this.firstWord = OptionalValue.of(firstWord); - return this; - } - - public Builder setSecondWord(String secondWord) { - this.secondWord = OptionalValue.of(secondWord); - return this; - } - - public GroupAutoUpdateKeyword build() { - return new GroupAutoUpdateKeyword(firstWord, secondWord); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java b/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java deleted file mode 100644 index c32a37d9a..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/Inbound.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.domains.sms.models.webhooks.WebhooksEvent; -import java.time.Instant; -import java.util.Optional; - -/** - * Base class for Incoming message - * - * @param Type of body - * @since 1.0 - */ -public abstract class Inbound implements WebhooksEvent { - - private final T body; - private final String from; - private final String id; - private final Instant receivedAt; - private final String to; - private final String clientReference; - private final String operatorId; - private final Instant sentAt; - - public Inbound( - T body, - String from, - String id, - Instant receivedAt, - String to, - String clientReference, - String operatorId, - Instant sentAt) { - this.body = body; - this.from = from; - this.id = id; - this.receivedAt = receivedAt; - this.to = to; - this.clientReference = clientReference; - this.operatorId = operatorId; - this.sentAt = sentAt; - } - - public T getBody() { - return body; - } - - public String getFrom() { - return from; - } - - public String getId() { - return id; - } - - public Instant getReceivedAt() { - return receivedAt; - } - - public String getTo() { - return to; - } - - public Optional getClientReference() { - return Optional.ofNullable(clientReference); - } - - public Optional getOperatorId() { - return Optional.ofNullable(operatorId); - } - - public Optional getSentAt() { - return Optional.ofNullable(sentAt); - } - - @Override - public String toString() { - return "Inbound{" - + "body=" - + body - + ", from='" - + from - + '\'' - + ", id='" - + id - + '\'' - + ", receivedAt=" - + receivedAt - + ", to='" - + to - + '\'' - + ", clientReference='" - + clientReference - + '\'' - + ", operatorId='" - + operatorId - + '\'' - + ", sentAt=" - + sentAt - + '}'; - } - - public abstract static class Builder> { - - T body; - String from; - String id; - Instant receivedAt; - String to; - String clientReference; - String operatorId; - Instant sentAt; - - public B setBody(T body) { - this.body = body; - return self(); - } - - public B setFrom(String from) { - this.from = from; - return self(); - } - - public B setId(String id) { - this.id = id; - return self(); - } - - public B setReceivedAt(Instant receivedAt) { - this.receivedAt = receivedAt; - return self(); - } - - public B setTo(String to) { - this.to = to; - return self(); - } - - public B setClientReference(String clientReference) { - this.clientReference = clientReference; - return self(); - } - - public B setOperatorId(String operatorId) { - this.operatorId = operatorId; - return self(); - } - - public B setSentAt(Instant sentAt) { - this.sentAt = sentAt; - return self(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - - public abstract Inbound build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/InboundBinary.java b/client/src/main/com/sinch/sdk/domains/sms/models/InboundBinary.java deleted file mode 100644 index 70081c01e..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/InboundBinary.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; - -/** - * Incoming SMS Binary - * - * @since 1.0 - */ -public class InboundBinary extends Inbound { - - private final String udh; - - /** - * Binary MO class - * - * @param body The message content Base64 encoded. Max 140 bytes together with udh. - * @param from The phone number that sent the message. @see https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628 - * @param id The ID of this inbound message. - * @param receivedAt When the system received the message. - * @param to The Sinch phone number or short code to which the message was sent. - * @param clientReference If this inbound message is in response to a previously sent message that - * contained a client reference, then this field contains that client reference. Utilizing - * this feature requires additional setup on your account. Contact your account manager to - * enable this feature. - * @param operatorId The MCC/MNC of the sender's operator if known. - * @param sendAt When the message left the originating device. Only available if provided by - * operator. - * @param udh The UDH header of a binary message HEX encoded. Max 140 bytes together with body. - */ - public InboundBinary( - String body, - String from, - String id, - Instant receivedAt, - String to, - String clientReference, - String operatorId, - Instant sendAt, - String udh) { - super(body, from, id, receivedAt, to, clientReference, operatorId, sendAt); - this.udh = udh; - } - - public String getUdh() { - return udh; - } - - @Override - public String toString() { - return "InboundBinary{" + "udh='" + udh + '\'' + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends Inbound.Builder { - - String udh; - - protected Builder() { - super(); - } - - public Builder setUdh(String udh) { - this.udh = udh; - return this; - } - - public InboundBinary build() { - return new InboundBinary( - body, from, id, receivedAt, to, clientReference, operatorId, sentAt, udh); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/InboundText.java b/client/src/main/com/sinch/sdk/domains/sms/models/InboundText.java deleted file mode 100644 index 9d68027fd..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/InboundText.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.time.Instant; - -/** - * Incoming SMS Text - * - * @since 1.0 - */ -public class InboundText extends Inbound { - - /** - * Text MO class - * - * @param body The message content Base64 encoded. Max 140 bytes together with udh. - * @param from The phone number that sent the message. @see https://community.sinch.com/t5/Glossary/MSISDN/ta-p/7628 - * @param id The ID of this inbound message. - * @param receivedAt When the system received the message. - * @param to The Sinch phone number or short code to which the message was sent. - * @param clientReference If this inbound message is in response to a previously sent message that - * contained a client reference, then this field contains that client reference. Utilizing - * this feature requires additional setup on your account. Contact your account manager to - * enable this feature. - * @param operatorId The MCC/MNC of the sender's operator if known. - * @param sentAt When the message left the originating device. Only available if provided by - * operator. - */ - public InboundText( - String body, - String from, - String id, - Instant receivedAt, - String to, - String clientReference, - String operatorId, - Instant sentAt) { - super(body, from, id, receivedAt, to, clientReference, operatorId, sentAt); - } - - @Override - public String toString() { - return "InboundText{} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends Inbound.Builder { - - protected Builder() { - super(); - } - - public InboundText build() { - return new InboundText(body, from, id, receivedAt, to, clientReference, operatorId, sentAt); - } - - @Override - protected InboundText.Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java b/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java deleted file mode 100644 index f12056cfd..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/MediaBody.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import java.util.Optional; - -/** - * MediaBody object - * - * @since 1.0 - */ -public class MediaBody { - private final String message; - private final String url; - - /** - * @param url URL to the media file - * @param message The message text. Text only media messages will be rejected, please use SMS - * instead. - */ - public MediaBody(String url, String message) { - this.message = message; - this.url = url; - } - - public MediaBody(String url) { - this(url, null); - } - - public String getUrl() { - return url; - } - - public Optional getMessage() { - return Optional.ofNullable(message); - } - - @Override - public String toString() { - return "MediaBody{" + "message='" + message + '\'' + ", url='" + url + '\'' + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String message; - private String url; - - private Builder() {} - - public Builder setMessage(String message) { - this.message = message; - return this; - } - - public Builder setUrl(String url) { - this.url = url; - return this; - } - - public MediaBody build() { - return new MediaBody(url, message); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java deleted file mode 100644 index c8e6b90a2..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/Parameters.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.utils.Pair; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; - -public class Parameters extends HashMap> { - - private static final long serialVersionUID = 1L; - - /** - * @throws NullPointerException – if the specified map is null - */ - public Parameters(Collection list) throws NullPointerException { - super(list.stream().collect(Collectors.groupingBy(Parameters.Entry::getKey))); - } - - public static class Entry { - private final String key; - private final Pair value; - private final String defaultValue; - - public Entry(String key, Pair value, String defaultValue) { - this.key = key; - this.value = value; - this.defaultValue = defaultValue; - } - - public Entry(String key, Pair value) { - this(key, value, null); - } - - public String getKey() { - return key; - } - - public Pair getValue() { - return value; - } - - public Optional getDefaultValue() { - return Optional.ofNullable(defaultValue); - } - - @Override - public String toString() { - return "Entry{" - + "key='" - + key - + '\'' - + ", value=" - + value - + ", defaultValue=" - + defaultValue - + '}'; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/SMSCursorPageNavigator.java b/client/src/main/com/sinch/sdk/domains/sms/models/SMSCursorPageNavigator.java deleted file mode 100644 index 29a988cd1..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/SMSCursorPageNavigator.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sinch.sdk.domains.sms.models; - -import com.sinch.sdk.core.models.pagination.PageNavigator; - -public class SMSCursorPageNavigator extends PageNavigator { - - private final Integer currentPage; - private final Integer pageSize; - - public SMSCursorPageNavigator(Integer currentPage, Integer pageSize) { - super(null); - this.currentPage = currentPage; - this.pageSize = pageSize; - } - - private Integer computeNextPageCursor() { - return null == pageSize || pageSize == 0 ? null : currentPage + 1; - } - - @Override - public Integer getToken() { - return computeNextPageCursor(); - } - - @Override - public String toString() { - return "SMSCursorPageNavigator{" - + "currentPage=" - + currentPage - + ", pageSize=" - + pageSize - + "} " - + super.toString(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/package-info.java deleted file mode 100644 index bc49635cc..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * SMS API related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.sms.models; diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/BatchesListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/BatchesListRequestParameters.java deleted file mode 100644 index c68d77bd5..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/BatchesListRequestParameters.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import java.time.Instant; - -/** - * Parameters request to list batches for a project - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Batches/#tag/Batches/operation/ListBatches/ - * @since 1.0 - */ -public class BatchesListRequestParameters { - - private final OptionalValue from; - private final OptionalValue startDate; - private final OptionalValue endDate; - private final OptionalValue clientReference; - private final OptionalValue page; - private final OptionalValue pageSize; - - private BatchesListRequestParameters( - OptionalValue from, - OptionalValue startDate, - OptionalValue endDate, - OptionalValue clientReference, - OptionalValue page, - OptionalValue pageSize) { - this.from = from; - this.startDate = startDate; - this.endDate = endDate; - this.clientReference = clientReference; - this.page = page; - this.pageSize = pageSize; - } - - public OptionalValue getFrom() { - return from; - } - - public OptionalValue getStartDate() { - return startDate; - } - - public OptionalValue getEndDate() { - return endDate; - } - - public OptionalValue getClientReference() { - return clientReference; - } - - public OptionalValue getPage() { - return page; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(BatchesListRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue from = OptionalValue.empty(); - OptionalValue startDate = OptionalValue.empty(); - OptionalValue endDate = OptionalValue.empty(); - OptionalValue clientReference = OptionalValue.empty(); - OptionalValue page = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - - private Builder() {} - - private Builder(BatchesListRequestParameters parameters) { - this.from = parameters.from; - this.startDate = parameters.startDate; - this.endDate = parameters.endDate; - this.clientReference = parameters.clientReference; - this.page = parameters.page; - this.pageSize = parameters.pageSize; - } - - /** - * @param from Only list messages sent from this sender number. Multiple originating numbers can - * be comma separated. Must be phone numbers or short code. - * @return current builder - */ - public Builder setFrom(String from) { - this.from = OptionalValue.of(from); - return this; - } - - /** - * @param startDate Only list messages received at or after this date/time. - * @return current builder - */ - public Builder setStartDate(Instant startDate) { - this.startDate = OptionalValue.of(startDate); - return this; - } - - /** - * @param endDate Only list messages received before this date/time - * @return current builder - */ - public Builder setEndDate(Instant endDate) { - this.endDate = OptionalValue.of(endDate); - return this; - } - - /** - * @param clientReference Client reference to include - * @return current builder - */ - public Builder setClientReference(String clientReference) { - this.clientReference = OptionalValue.of(clientReference); - return this; - } - - /** - * @param page The page number starting from 0 - * @return current builder - */ - public Builder setPage(Integer page) { - this.page = OptionalValue.of(page); - return this; - } - - /** - * @param pageSize Determines the size of a page - * @return current builder - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - public BatchesListRequestParameters build() { - return new BatchesListRequestParameters( - from, startDate, endDate, clientReference, page, pageSize); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportBatchGetRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportBatchGetRequestParameters.java deleted file mode 100644 index a76d07768..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportBatchGetRequestParameters.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportStatus; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import java.util.Collection; - -/** - * Parameters request to get a Batch Delivery Report - * - * @since 1.0 - */ -public class DeliveryReportBatchGetRequestParameters { - - private final OptionalValue type; - private final OptionalValue> statuses; - private final OptionalValue> codes; - - private DeliveryReportBatchGetRequestParameters( - OptionalValue type, - OptionalValue> statuses, - OptionalValue> codes) { - this.type = type; - this.statuses = statuses; - this.codes = codes; - } - - public OptionalValue getType() { - return type; - } - - public OptionalValue> geStatues() { - return statuses; - } - - public OptionalValue> getCodes() { - return codes; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(DeliveryReportBatchGetRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue type = OptionalValue.empty(); - OptionalValue> statuses = OptionalValue.empty(); - OptionalValue> codes = OptionalValue.empty(); - - private Builder() {} - - private Builder(DeliveryReportBatchGetRequestParameters parameters) { - this.type = parameters.type; - this.statuses = parameters.statuses; - this.codes = parameters.codes; - } - - /** - * @param type Filter by type of delivery report. - *

    - *
  • A summary will count the number of messages sent per status. - *
  • A full report give that of a summary report but in addition, lists - * phone numbers. - *
- * - * @return current builder - */ - public Builder setType(DeliveryReportType type) { - this.type = OptionalValue.of(type); - return this; - } - - /** - * @param statuses Filter by list of statuses - * to include - * @return current builder - */ - public Builder setStatuses(Collection statuses) { - this.statuses = OptionalValue.of(statuses); - return this; - } - - /** - * @param codes Filter by list of codes - * to include - * @return current builder - */ - public Builder setCodes(Collection codes) { - this.codes = OptionalValue.of(codes); - return this; - } - - public DeliveryReportBatchGetRequestParameters build() { - return new DeliveryReportBatchGetRequestParameters(type, statuses, codes); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportListRequestParameters.java deleted file mode 100644 index 54cc1d502..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/DeliveryReportListRequestParameters.java +++ /dev/null @@ -1,169 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportErrorCode; -import com.sinch.sdk.domains.sms.models.DeliveryReportStatus; -import java.time.Instant; -import java.util.Collection; - -/** - * Parameters request to list delivery reports for a project - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports - * @since 1.0 - */ -public class DeliveryReportListRequestParameters { - - private final OptionalValue startDate; - private final OptionalValue endDate; - private final OptionalValue clientReference; - private final OptionalValue page; - private final OptionalValue pageSize; - private final OptionalValue> statuses; - private final OptionalValue> codes; - - private DeliveryReportListRequestParameters( - OptionalValue startDate, - OptionalValue endDate, - OptionalValue clientReference, - OptionalValue page, - OptionalValue pageSize, - OptionalValue> statuses, - OptionalValue> codes) { - this.startDate = startDate; - this.endDate = endDate; - this.clientReference = clientReference; - this.page = page; - this.pageSize = pageSize; - this.statuses = statuses; - this.codes = codes; - } - - public OptionalValue getStartDate() { - return startDate; - } - - public OptionalValue getEndDate() { - return endDate; - } - - public OptionalValue getClientReference() { - return clientReference; - } - - public OptionalValue getPage() { - return page; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public OptionalValue> getStatuses() { - return statuses; - } - - public OptionalValue> getCodes() { - return codes; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(DeliveryReportListRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue startDate = OptionalValue.empty(); - OptionalValue endDate = OptionalValue.empty(); - OptionalValue clientReference = OptionalValue.empty(); - OptionalValue page = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - OptionalValue> statuses = OptionalValue.empty(); - OptionalValue> codes = OptionalValue.empty(); - - private Builder() {} - - private Builder(DeliveryReportListRequestParameters parameters) { - this.startDate = parameters.startDate; - this.endDate = parameters.endDate; - this.clientReference = parameters.clientReference; - this.page = parameters.page; - this.pageSize = parameters.pageSize; - this.statuses = parameters.statuses; - this.codes = parameters.codes; - } - - /** - * @param startDate Only list messages received at or after this date/time. Default: 24h ago - * @return current builder - */ - public Builder setStartDate(Instant startDate) { - this.startDate = OptionalValue.of(startDate); - return this; - } - - /** - * @param endDate Only list messages received before this date/time. - * @return current builder - */ - public Builder setEndDate(Instant endDate) { - this.endDate = OptionalValue.of(endDate); - return this; - } - - /** - * @param clientReference Client reference to include - * @return current builder - */ - public Builder setClientReference(String clientReference) { - this.clientReference = OptionalValue.of(clientReference); - return this; - } - - /** - * @param page The page number starting from 0. - * @return current builder - */ - public Builder setPage(Integer page) { - this.page = OptionalValue.of(page); - return this; - } - - /** - * @param pageSize Determines the size of a page. - * @return current builder - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - /** - * @param statuses List of delivery report statuses to include - * @return current builder - */ - public Builder setStatuses(Collection statuses) { - this.statuses = OptionalValue.of(statuses); - return this; - } - - /** - * @param codes List of delivery receipt error codes to include - * @return current builder - */ - public Builder setCodes(Collection codes) { - this.codes = OptionalValue.of(codes); - return this; - } - - public DeliveryReportListRequestParameters build() { - return new DeliveryReportListRequestParameters( - startDate, endDate, clientReference, page, pageSize, statuses, codes); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateKeywordRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateKeywordRequestParameters.java deleted file mode 100644 index ec9581db4..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateKeywordRequestParameters.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -public class GroupAutoUpdateKeywordRequestParameters { - - private final OptionalValue firstWord; - private final OptionalValue secondWord; - - /** - * @param firstWord Opt-in keyword like "JOIN" if _auto_update.to_ is dedicated long/short number - * or unique brand keyword like "Sinch" if it is a shared short code. - * @param secondWord Opt-in keyword like "JOIN" if _auto_update.to_ is shared short code. - */ - private GroupAutoUpdateKeywordRequestParameters( - OptionalValue firstWord, OptionalValue secondWord) { - this.firstWord = firstWord; - this.secondWord = secondWord; - } - - public OptionalValue getFirstWord() { - return firstWord; - } - - public OptionalValue getSecondWord() { - return secondWord; - } - - @Override - public String toString() { - return "GroupAutoUpdateKeywordRequestParameters{" - + "firstWord='" - + firstWord - + '\'' - + ", secondWord='" - + secondWord - + '\'' - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue firstWord = OptionalValue.empty(); - OptionalValue secondWord = OptionalValue.empty(); - - private Builder() {} - - public Builder setFirstWord(String firstWord) { - this.firstWord = OptionalValue.of(firstWord); - return this; - } - - public Builder setSecondWord(String secondWord) { - this.secondWord = OptionalValue.of(secondWord); - return this; - } - - public GroupAutoUpdateKeywordRequestParameters build() { - return new GroupAutoUpdateKeywordRequestParameters(firstWord, secondWord); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateRequestParameters.java deleted file mode 100644 index e1a41ffcb..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupAutoUpdateRequestParameters.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.GroupAutoUpdate.Builder; - -public class GroupAutoUpdateRequestParameters { - private final OptionalValue to; - private final OptionalValue add; - private final OptionalValue remove; - - private GroupAutoUpdateRequestParameters( - OptionalValue to, - OptionalValue add, - OptionalValue remove) { - this.to = to; - this.add = add; - this.remove = remove; - } - - public OptionalValue getTo() { - return to; - } - - public OptionalValue getAdd() { - return add; - } - - public OptionalValue getRemove() { - return remove; - } - - public static Builder builder() { - return new Builder(); - } - - @Override - public String toString() { - return "GroupAutoUpdateRequestParameters{" - + "to='" - + to - + '\'' - + ", add=" - + add - + ", remove=" - + remove - + '}'; - } - - public static class Builder { - - OptionalValue to = OptionalValue.empty(); - OptionalValue add = OptionalValue.empty(); - OptionalValue remove = OptionalValue.empty(); - - private Builder() {} - - /** - * @param to Short code or long number addressed in MO.
- * Constraints: Must be valid MSISDN or short code. - * @return current builder - */ - public Builder setTo(String to) { - this.to = OptionalValue.of(to); - return this; - } - - /*** - * - * @param add Keyword to be sent in MO to add MSISDN to a group - * @return current builder - */ - public Builder setAdd(GroupAutoUpdateKeywordRequestParameters add) { - this.add = OptionalValue.of(add); - return this; - } - - /** - * @param remove Keyword to be sent in MO to remove MSISDN to a group - * @return current builder - */ - public Builder setRemove(GroupAutoUpdateKeywordRequestParameters remove) { - this.remove = OptionalValue.of(remove); - return this; - } - - public GroupAutoUpdateRequestParameters build() { - return new GroupAutoUpdateRequestParameters(to, add, remove); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupCreateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupCreateRequestParameters.java deleted file mode 100644 index 7fc87d229..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupCreateRequestParameters.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -/** - * Parameters request to create a group - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/CreateGroup - * @since 1.0 - */ -public class GroupCreateRequestParameters { - - private final OptionalValue name; - private final OptionalValue> members; - private final OptionalValue> childGroupIds; - private final OptionalValue autoUpdate; - - private GroupCreateRequestParameters( - OptionalValue name, - OptionalValue> members, - OptionalValue> childGroupIds, - OptionalValue autoUpdate) { - this.name = name; - this.members = members; - this.childGroupIds = childGroupIds; - this.autoUpdate = autoUpdate; - } - - public OptionalValue getName() { - return name; - } - - public OptionalValue> getMembers() { - return members; - } - - public OptionalValue> getChildGroupIds() { - return childGroupIds; - } - - public OptionalValue getAutoUpdate() { - return autoUpdate; - } - - @Override - public String toString() { - return "GroupCreateRequestParameters{" - + "name='" - + name - + '\'' - + ", members=" - + members - + ", childGroupIds=" - + childGroupIds - + ", autoUpdate=" - + autoUpdate - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(GroupCreateRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue name = OptionalValue.empty(); - OptionalValue> members = OptionalValue.empty(); - OptionalValue> childGroupIds = OptionalValue.empty(); - OptionalValue autoUpdate = OptionalValue.empty(); - - private Builder() {} - - private Builder(GroupCreateRequestParameters parameters) { - this.name = parameters.getName(); - this.members = parameters.getMembers(); - this.childGroupIds = parameters.getChildGroupIds(); - this.autoUpdate = parameters.getAutoUpdate(); - } - - /** - * @param name Name of the group - * @return current builder - */ - public Builder setName(String name) { - this.name = OptionalValue.of(name); - return this; - } - - /** - * @param members Initial list of phone numbers in E.164 format MSISDNs for the group - * @return current builder - */ - public Builder setMembers(Collection members) { - this.members = OptionalValue.of(members); - return this; - } - - /** - * @param childGroupIds Child group IDs - * @return current builder - */ - public Builder setChildGroupIds(Collection childGroupIds) { - this.childGroupIds = OptionalValue.of(childGroupIds); - return this; - } - - /** - * @param autoUpdate Auto update settings - * @return current builder - */ - public Builder setAutoUpdate(GroupAutoUpdateRequestParameters autoUpdate) { - this.autoUpdate = OptionalValue.of(autoUpdate); - return this; - } - - public GroupCreateRequestParameters build() { - return new GroupCreateRequestParameters(name, members, childGroupIds, autoUpdate); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupReplaceRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupReplaceRequestParameters.java deleted file mode 100644 index b51982475..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupReplaceRequestParameters.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -/** - * Parameters request to replace a group - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ReplaceGroup - * @since 1.0 - */ -public class GroupReplaceRequestParameters { - - private final OptionalValue name; - private final OptionalValue> members; - - private GroupReplaceRequestParameters( - OptionalValue name, OptionalValue> members) { - this.name = name; - this.members = members; - } - - public OptionalValue getName() { - return name; - } - - public OptionalValue> getMembers() { - return members; - } - - @Override - public String toString() { - return "GroupCreateRequestParameters{" + "name='" + name + '\'' + ", members=" + members + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(GroupReplaceRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue name = OptionalValue.empty(); - OptionalValue> members = OptionalValue.empty(); - - private Builder() {} - - private Builder(GroupReplaceRequestParameters parameters) { - this.name = parameters.getName(); - this.members = parameters.getMembers(); - } - - /** - * @param name Name of the group - * @return current builder - */ - public Builder setName(String name) { - this.name = OptionalValue.of(name); - return this; - } - - /** - * @param members The initial members of the group. - *

Constraints: Elements must be phone numbers in E.164 format MSISDNs. - * @return current builder - */ - public Builder setMembers(Collection members) { - this.members = OptionalValue.of(members); - return this; - } - - public GroupReplaceRequestParameters build() { - return new GroupReplaceRequestParameters(name, members); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupUpdateRequestParameters.java deleted file mode 100644 index 1a9b17c10..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupUpdateRequestParameters.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -/** - * Parameters request to update" a group - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/UpdateGroup - * @since 1.0 - */ -public class GroupUpdateRequestParameters { - - private final OptionalValue name; - private final OptionalValue> add; - private final OptionalValue> remove; - private final OptionalValue addFromGroup; - private final OptionalValue removeFromGroup; - private final OptionalValue autoUpdate; - - private GroupUpdateRequestParameters( - OptionalValue name, - OptionalValue> add, - OptionalValue> remove, - OptionalValue addFromGroup, - OptionalValue removeFromGroup, - OptionalValue autoUpdate) { - this.name = name; - this.add = add; - this.remove = remove; - this.addFromGroup = addFromGroup; - this.removeFromGroup = removeFromGroup; - this.autoUpdate = autoUpdate; - } - - public OptionalValue getName() { - return name; - } - - public OptionalValue> getAdd() { - return add; - } - - public OptionalValue> getRemove() { - return remove; - } - - public OptionalValue getAddFromGroup() { - return addFromGroup; - } - - public OptionalValue getRemoveFromGroup() { - return removeFromGroup; - } - - public OptionalValue getAutoUpdate() { - return autoUpdate; - } - - @Override - public String toString() { - return "GroupUpdateRequestParameters{" - + "name='" - + name - + '\'' - + ", add=" - + add - + ", remove=" - + remove - + ", addFromGroup='" - + addFromGroup - + '\'' - + ", removeFromGroup='" - + removeFromGroup - + '\'' - + ", autoUpdate=" - + autoUpdate - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(GroupUpdateRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue name = OptionalValue.empty(); - - OptionalValue> add = OptionalValue.empty(); - - OptionalValue> remove = OptionalValue.empty(); - - OptionalValue addFromGroup = OptionalValue.empty(); - - OptionalValue removeFromGroup = OptionalValue.empty(); - - OptionalValue autoUpdate = OptionalValue.empty(); - - private Builder() {} - - private Builder(GroupUpdateRequestParameters parameters) { - this.name = parameters.getName(); - this.add = parameters.getAdd(); - this.remove = parameters.getRemove(); - this.addFromGroup = parameters.getAddFromGroup(); - this.removeFromGroup = parameters.getRemoveFromGroup(); - this.autoUpdate = parameters.getAutoUpdate(); - } - - /** - * @param name The name of the group. Omitting name from the JSON body will leave the name - * unchanged. To remove an existing name set, name explicitly to the JSON value null. - * @return current builder - */ - public Builder setName(String name) { - this.name = OptionalValue.of(name); - return this; - } - - /** - * @param add Add a list of phone numbers (MSISDNs) to this group. The phone numbers are a - * strings within an array and must be in E.164 format. - * @return current builder - */ - public Builder setAdd(Collection add) { - this.add = OptionalValue.of(add); - return this; - } - - /** - * @param remove Remove a list of phone numbers (MSISDNs) to this group.The phone numbers are a - * strings within an array and must be in E.164 format. - * @return current builder - */ - public Builder setRemove(Collection remove) { - this.remove = OptionalValue.of(remove); - return this; - } - - /** - * @param addFromGroup Copy the members from the another group into this group. Constraints: - * Must be valid group ID - * @return current builder - */ - public Builder setAddFromGroup(String addFromGroup) { - this.addFromGroup = OptionalValue.of(addFromGroup); - return this; - } - - /** - * @param removeFromGroup Remove the members in a specified group from this group. - *

Constraints: Must be valid group ID - * @return current builder - */ - public Builder setRemoveFromGroup(String removeFromGroup) { - this.removeFromGroup = OptionalValue.of(removeFromGroup); - return this; - } - - /** - * @param autoUpdate auto update settings - * @return current builder - */ - public Builder setAutoUpdate(GroupAutoUpdateRequestParameters autoUpdate) { - this.autoUpdate = OptionalValue.of(autoUpdate); - return this; - } - - public GroupUpdateRequestParameters build() { - return new GroupUpdateRequestParameters( - name, add, remove, addFromGroup, removeFromGroup, autoUpdate); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupsListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupsListRequestParameters.java deleted file mode 100644 index 5e72eed06..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/GroupsListRequestParameters.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Parameters request to list groups - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Groups/#tag/Groups/operation/ListGroups - * @since 1.0 - */ -public class GroupsListRequestParameters { - - private final OptionalValue page; - private final OptionalValue pageSize; - - public GroupsListRequestParameters(OptionalValue page, OptionalValue pageSize) { - this.page = page; - this.pageSize = pageSize; - } - - public OptionalValue getPage() { - return page; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(GroupsListRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue page = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - - private Builder() {} - - private Builder(GroupsListRequestParameters parameters) { - this.page = parameters.page; - this.pageSize = parameters.pageSize; - } - - /** - * @param page The page number starting from 0. - * @return current builder - */ - public Builder setPage(Integer page) { - this.page = OptionalValue.of(page); - return this; - } - - /** - * @param pageSize Determines the size of a page. - * @return current builder - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - public GroupsListRequestParameters build() { - return new GroupsListRequestParameters(page, pageSize); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/InboundsListRequestParameters.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/InboundsListRequestParameters.java deleted file mode 100644 index d72abcfef..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/InboundsListRequestParameters.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import java.time.Instant; -import java.util.Collection; - -/** - * Parameters request to list delivery reports for a project - * - * @see https://developers.sinch.com/docs/sms/api-reference/sms/tag/Delivery-reports/#tag/Delivery-reports/operation/getDeliveryReports - * @since 1.0 - */ -public class InboundsListRequestParameters { - - private final OptionalValue startDate; - private final OptionalValue endDate; - private final OptionalValue clientReference; - private final OptionalValue page; - private final OptionalValue pageSize; - private final OptionalValue> to; - - private InboundsListRequestParameters( - OptionalValue startDate, - OptionalValue endDate, - OptionalValue clientReference, - OptionalValue page, - OptionalValue pageSize, - OptionalValue> to) { - this.startDate = startDate; - this.endDate = endDate; - this.clientReference = clientReference; - this.page = page; - this.pageSize = pageSize; - this.to = to; - } - - public OptionalValue getStartDate() { - return startDate; - } - - public OptionalValue getEndDate() { - return endDate; - } - - public OptionalValue getClientReference() { - return clientReference; - } - - public OptionalValue getPage() { - return page; - } - - public OptionalValue getPageSize() { - return pageSize; - } - - public OptionalValue> getTo() { - return to; - } - - public static Builder builder() { - return new Builder(); - } - - public static Builder builder(InboundsListRequestParameters parameters) { - return new Builder(parameters); - } - - public static class Builder { - - OptionalValue startDate = OptionalValue.empty(); - OptionalValue endDate = OptionalValue.empty(); - OptionalValue clientReference = OptionalValue.empty(); - OptionalValue page = OptionalValue.empty(); - OptionalValue pageSize = OptionalValue.empty(); - OptionalValue> to = OptionalValue.empty(); - - private Builder() {} - - private Builder(InboundsListRequestParameters parameters) { - this.startDate = parameters.startDate; - this.endDate = parameters.endDate; - this.clientReference = parameters.clientReference; - this.page = parameters.page; - this.pageSize = parameters.pageSize; - this.to = parameters.to; - } - - /** - * @param startDate Only list messages received at or after this date/time - * @return current builder - */ - public Builder setStartDate(Instant startDate) { - this.startDate = OptionalValue.of(startDate); - return this; - } - - /** - * @param endDate Only list messages received before this date/time - * @return current builder - */ - public Builder setEndDate(Instant endDate) { - this.endDate = OptionalValue.of(endDate); - return this; - } - - /** - * @param clientReference Using a client reference in inbound messages requires additional setup - * on your account. Contact your account manager to enable this feature. Only list inbound - * messages that are in response to messages with a previously provided client reference. - * @return current builder - */ - public Builder setClientReference(String clientReference) { - this.clientReference = OptionalValue.of(clientReference); - return this; - } - - /** - * @param page The page number starting from 0. - * @return current builder - */ - public Builder setPage(Integer page) { - this.page = OptionalValue.of(page); - return this; - } - - /** - * @param pageSize Determines the size of a page. - * @return current builder - */ - public Builder setPageSize(Integer pageSize) { - this.pageSize = OptionalValue.of(pageSize); - return this; - } - - /** - * @param to Only list messages sent to these destinations - * @return current builder - */ - public Builder setTo(Collection to) { - this.to = OptionalValue.of(to); - return this; - } - - public InboundsListRequestParameters build() { - return new InboundsListRequestParameters( - startDate, endDate, clientReference, page, pageSize, to); - } - } -} 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 deleted file mode 100644 index a3b2ce2f6..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchBinaryRequest.java +++ /dev/null @@ -1,194 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import java.time.Instant; -import java.util.Collection; - -public class SendSmsBatchBinaryRequest extends BaseBatch { - private final OptionalValue flashMessage; - private final OptionalValue truncateConcat; - private final OptionalValue maxNumberOfMessageParts; - private final OptionalValue fromTon; - private final OptionalValue fromNpi; - private final OptionalValue udh; - - private SendSmsBatchBinaryRequest( - Collection to, - OptionalValue from, - String body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue clientReference, - OptionalValue flashMessage, - OptionalValue feedbackEnabled, - OptionalValue truncateConcat, - OptionalValue maxNumberOfMessageParts, - OptionalValue fromTon, - OptionalValue fromNpi, - OptionalValue udh) { - super( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.flashMessage = flashMessage; - this.truncateConcat = truncateConcat; - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - this.fromTon = fromTon; - this.fromNpi = fromNpi; - this.udh = udh; - } - - public OptionalValue isFlashMessage() { - return flashMessage; - } - - public OptionalValue isTruncateConcat() { - return truncateConcat; - } - - public OptionalValue getMaxNumberOfMessageParts() { - return maxNumberOfMessageParts; - } - - public OptionalValue getFromTon() { - return fromTon; - } - - public OptionalValue getFromNpi() { - return fromNpi; - } - - public OptionalValue getUdh() { - return udh; - } - - @Override - public String toString() { - return "SendSmsBatchBinaryRequest{" - + "flashMessage=" - + flashMessage - + ", truncateConcat=" - + truncateConcat - + ", maxNumberOfMessageParts=" - + maxNumberOfMessageParts - + ", fromTon=" - + fromTon - + ", fromNpi=" - + fromNpi - + ", udh='" - + udh - + '\'' - + ", base='" - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends BaseBatch.Builder { - private OptionalValue flashMessage = OptionalValue.empty(); - private OptionalValue truncateConcat = OptionalValue.empty(); - private OptionalValue maxNumberOfMessageParts = OptionalValue.empty(); - private OptionalValue fromTon = OptionalValue.empty(); - private OptionalValue fromNpi = OptionalValue.empty(); - private OptionalValue udh = OptionalValue.empty(); - - private Builder() { - super(); - } - - /** - * @param flashMessage If sent as a flash message, displays true. - * @return current builder - * @deprecated - */ - public Builder setFlashMessage(boolean flashMessage) { - this.flashMessage = OptionalValue.of(flashMessage); - return this; - } - - /** - * @param truncateConcat If set to true, the message was shortened when exceeding one part. - * @return current builder - * @deprecated - */ - public Builder setTruncateConcat(boolean truncateConcat) { - this.truncateConcat = OptionalValue.of(truncateConcat); - return this; - } - - /** - * @param maxNumberOfMessageParts Displays the number of message parts set in the request. - * @return current builder - * @deprecated - */ - public Builder setMaxNumberOfMessageParts(int maxNumberOfMessageParts) { - this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); - return this; - } - - /** - * @param fromTon The type of number for the sender number. - * @return current builder - */ - public Builder setFromTon(int fromTon) { - this.fromTon = OptionalValue.of(fromTon); - return this; - } - - /** - * @param fromNpi Number Plan Indicator for the sender number. - * @return current builder - */ - public Builder setFromNpi(int fromNpi) { - this.fromNpi = OptionalValue.of(fromNpi); - return this; - } - - /** - * @param udh The UDH header of a binary message HEX encoded. Max 140 bytes including the body. - * @return current builder - */ - public Builder setUdh(String udh) { - this.udh = OptionalValue.of(udh); - return this; - } - - @Override - public SendSmsBatchBinaryRequest build() { - return new SendSmsBatchBinaryRequest( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - flashMessage, - feedbackEnabled, - truncateConcat, - maxNumberOfMessageParts, - fromTon, - fromNpi, - udh); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchMediaRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchMediaRequest.java deleted file mode 100644 index 44fb01ff5..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchMediaRequest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.MediaBody; -import com.sinch.sdk.domains.sms.models.Parameters; -import java.time.Instant; -import java.util.Collection; - -public class SendSmsBatchMediaRequest extends BaseBatch { - private final OptionalValue parameters; - private final OptionalValue strictValidation; - - private SendSmsBatchMediaRequest( - Collection to, - OptionalValue from, - MediaBody body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue clientReference, - OptionalValue feedbackEnabled, - OptionalValue parameters, - OptionalValue strictValidation) { - super( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.parameters = parameters; - this.strictValidation = strictValidation; - } - - public OptionalValue getParameters() { - return parameters; - } - - public OptionalValue isStrictValidation() { - return strictValidation; - } - - @Override - public String toString() { - return "SendSmsBatchMediaRequest{" - + "parameters=" - + parameters - + ", strictValidation=" - + strictValidation - + ", base='" - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends BaseBatch.Builder { - private OptionalValue parameters = OptionalValue.empty(); - private OptionalValue strictValidation = OptionalValue.empty(); - - private Builder() {} - - /** - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @return current builder - */ - public Builder setParameters(Parameters parameters) { - this.parameters = OptionalValue.of(parameters); - return this; - } - - /** - * @param strictValidation Whether or not you want the media included in your message to be - * checked against Sinch MMS channel best practices. If set to true, your message will be - * rejected if it doesn't conform to the listed recommendations, otherwise no validation - * will be performed. - * @return current builder - */ - public Builder setStrictValidation(Boolean strictValidation) { - this.strictValidation = OptionalValue.of(strictValidation); - return this; - } - - public SendSmsBatchMediaRequest build() { - return new SendSmsBatchMediaRequest( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled, - parameters, - strictValidation); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchTextRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchTextRequest.java deleted file mode 100644 index 6abb4497b..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/SendSmsBatchTextRequest.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.BaseBatch; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.Parameters; -import java.time.Instant; -import java.util.Collection; - -public class SendSmsBatchTextRequest extends BaseBatch { - private final OptionalValue flashMessage; - private final OptionalValue parameters; - private final OptionalValue truncateConcat; - private final OptionalValue maxNumberOfMessageParts; - private final OptionalValue fromTon; - private final OptionalValue fromNpi; - - private SendSmsBatchTextRequest( - Collection to, - OptionalValue from, - String body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue clientReference, - OptionalValue flashMessage, - OptionalValue feedbackEnabled, - OptionalValue parameters, - OptionalValue truncateConcat, - OptionalValue maxNumberOfMessageParts, - OptionalValue fromTon, - OptionalValue fromNpi) { - super( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - feedbackEnabled); - this.flashMessage = flashMessage; - this.parameters = parameters; - this.truncateConcat = truncateConcat; - this.maxNumberOfMessageParts = maxNumberOfMessageParts; - this.fromTon = fromTon; - this.fromNpi = fromNpi; - } - - public OptionalValue getParameters() { - return parameters; - } - - public OptionalValue isFlashMessage() { - return flashMessage; - } - - public OptionalValue isTruncateConcat() { - return truncateConcat; - } - - public OptionalValue getMaxNumberOfMessageParts() { - return maxNumberOfMessageParts; - } - - public OptionalValue getFromTon() { - return fromTon; - } - - public OptionalValue getFromNpi() { - return fromNpi; - } - - @Override - public String toString() { - return "SendSmsBatchTextRequest{" - + "flashMessage=" - + flashMessage - + ", parameters=" - + parameters - + ", truncateConcat=" - + truncateConcat - + ", maxNumberOfMessageParts=" - + maxNumberOfMessageParts - + ", fromTon=" - + fromTon - + ", fromNpi=" - + fromNpi - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends BaseBatch.Builder { - private OptionalValue flashMessage = OptionalValue.empty(); - private OptionalValue parameters = OptionalValue.empty(); - private OptionalValue truncateConcat = OptionalValue.empty(); - private OptionalValue maxNumberOfMessageParts = OptionalValue.empty(); - private OptionalValue fromTon = OptionalValue.empty(); - private OptionalValue fromNpi = OptionalValue.empty(); - - private Builder() {} - - /** - * @param flashMessage If sent as a flash message, displays true. - * @return current builder - */ - public Builder setFlashMessage(boolean flashMessage) { - this.flashMessage = OptionalValue.of(flashMessage); - return this; - } - - /** - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @return current builder - */ - public Builder setParameters(Parameters parameters) { - this.parameters = OptionalValue.of(parameters); - return this; - } - - /** - * @param truncateConcat If set to true, the message was shortened when exceeding one part. - * @return current builder - */ - public Builder setTruncateConcat(Boolean truncateConcat) { - this.truncateConcat = OptionalValue.of(truncateConcat); - return this; - } - - /** - * @param maxNumberOfMessageParts Displays the number of message parts set in the request. - * @return current builder - */ - public Builder setMaxNumberOfMessageParts(Integer maxNumberOfMessageParts) { - this.maxNumberOfMessageParts = OptionalValue.of(maxNumberOfMessageParts); - return this; - } - - /** - * @param fromTon The type of number for the sender number. - * @return current builder - */ - public Builder setFromTon(Integer fromTon) { - this.fromTon = OptionalValue.of(fromTon); - return this; - } - - /** - * @param fromNpi Number Plan Indicator for the sender number. - * @return current builder - */ - public Builder setFromNpi(Integer fromNpi) { - this.fromNpi = OptionalValue.of(fromNpi); - return this; - } - - public SendSmsBatchTextRequest build() { - return new SendSmsBatchTextRequest( - to, - from, - body, - deliveryReport, - sendAt, - expireAt, - callbackUrl, - clientReference, - flashMessage, - feedbackEnabled, - parameters, - truncateConcat, - maxNumberOfMessageParts, - fromTon, - fromNpi); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateBaseBatchRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateBaseBatchRequest.java deleted file mode 100644 index 2901171ff..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateBaseBatchRequest.java +++ /dev/null @@ -1,222 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import java.time.Instant; -import java.util.Collection; - -/** - * Base class for Batch types - * - * @param Type of batch - * @since 1.0 - */ -public class UpdateBaseBatchRequest { - - private final OptionalValue from; - - private final OptionalValue body; - - private final OptionalValue> toAdd; - - private final OptionalValue> toRemove; - - private final OptionalValue deliveryReport; - - private final OptionalValue sendAt; - - private final OptionalValue expireAt; - - private final OptionalValue callbackUrl; - - protected UpdateBaseBatchRequest( - OptionalValue> toAdd, - OptionalValue> toRemove, - OptionalValue from, - OptionalValue body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl) { - this.toAdd = toAdd; - this.toRemove = toRemove; - this.from = from; - this.body = body; - this.deliveryReport = deliveryReport; - this.sendAt = sendAt; - this.expireAt = expireAt; - this.callbackUrl = callbackUrl; - } - - public static BatchBuilder batchBuilder() { - return new BatchBuilder<>(); - } - - public OptionalValue> getToAdd() { - return toAdd; - } - - public OptionalValue> getToRemove() { - return toRemove; - } - - public OptionalValue getBody() { - return body; - } - - public OptionalValue getFrom() { - return from; - } - - public OptionalValue getDeliveryReport() { - return deliveryReport; - } - - public OptionalValue getSendAt() { - return sendAt; - } - - public OptionalValue getExpireAt() { - return expireAt; - } - - public OptionalValue getCallbackUrl() { - return callbackUrl; - } - - @Override - public String toString() { - return "UpdateBaseBatchRequest{" - + "from='" - + from - + '\'' - + ", body=" - + body - + ", toAdd=" - + toAdd - + ", toRemove=" - + toRemove - + ", deliveryReportType=" - + deliveryReport - + ", sendAt=" - + sendAt - + ", expireAt=" - + expireAt - + ", callbackUrl='" - + callbackUrl - + '\'' - + '}'; - } - - protected static class Builder> { - - public OptionalValue> toAdd = OptionalValue.empty(); - - public OptionalValue> toRemove = OptionalValue.empty(); - - public OptionalValue from = OptionalValue.empty(); - - public OptionalValue body = OptionalValue.empty(); - - public OptionalValue deliveryReportType = OptionalValue.empty(); - - public OptionalValue sendAt = OptionalValue.empty(); - - public OptionalValue expireAt = OptionalValue.empty(); - - public OptionalValue callbackUrl = OptionalValue.empty(); - - /** - * @param toAdd List of phone numbers and group IDs to add to the batch. - * @return current builder - */ - public B setToAdd(Collection toAdd) { - this.toAdd = OptionalValue.of(toAdd); - return self(); - } - - /** - * @param toRemove List of phone numbers and group IDs to remove from the batch. - * @return current builder - */ - public B setToRemove(Collection toRemove) { - this.toRemove = OptionalValue.of(toRemove); - return self(); - } - - /** - * @param from Sender number. Must be valid phone number, short code or alphanumeric. Required - * if Automatic Default Originator not configured. - * @return current builder - */ - public B setFrom(String from) { - this.from = OptionalValue.of(from); - return self(); - } - - /** - * @param body The message content - * @return current builder - */ - public B setBody(T body) { - this.body = OptionalValue.of(body); - return self(); - } - - /** - * @param deliveryReportType Request delivery report callback. Note that delivery reports can be - * fetched from the API regardless of this setting - * @return current builder - */ - public B setDeliveryReport(DeliveryReportType deliveryReportType) { - this.deliveryReportType = OptionalValue.of(deliveryReportType); - return self(); - } - - /** - * @param sendAt If set in the future, the message will be delayed until send_at occurs. Must be - * before expire_at. If set in the past, messages will be sent immediately - * @return current builder - */ - public B setSendAt(Instant sendAt) { - this.sendAt = OptionalValue.of(sendAt); - return self(); - } - - /** - * @param expireAt If set, the system will stop trying to deliver the message at this point. - * Must be after send_at. Default and max is 3 days after send_at - * @return current builder - */ - public B setExpireAt(Instant expireAt) { - this.expireAt = OptionalValue.of(expireAt); - return self(); - } - - /** - * @param callbackUrl Override the default callback URL for this batch. Must be valid URL. - * @return current builder - */ - public B setCallbackUrl(String callbackUrl) { - this.callbackUrl = OptionalValue.of(callbackUrl); - return self(); - } - - public UpdateBaseBatchRequest build() { - return new UpdateBaseBatchRequest<>( - toAdd, toRemove, from, body, deliveryReportType, sendAt, expireAt, callbackUrl); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } - - public static class BatchBuilder extends UpdateBaseBatchRequest.Builder> { - @Override - protected BatchBuilder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchBinaryRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchBinaryRequest.java deleted file mode 100644 index 14417f512..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchBinaryRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import java.time.Instant; -import java.util.Collection; - -public class UpdateSmsBatchBinaryRequest extends UpdateBaseBatchRequest { - private final OptionalValue udh; - - private UpdateSmsBatchBinaryRequest( - OptionalValue> toAdd, - OptionalValue> toRemove, - OptionalValue from, - OptionalValue body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue udh) { - super(toAdd, toRemove, from, body, deliveryReport, sendAt, expireAt, callbackUrl); - this.udh = udh; - } - - public OptionalValue getUdh() { - return udh; - } - - @Override - public String toString() { - return "UpdateSmsBatchBinaryRequest{" + "udh='" + udh + '\'' + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends UpdateBaseBatchRequest.Builder { - - private OptionalValue udh; - - private Builder() {} - - /** - * @param udh The UDH header of a binary message HEX encoded. Max 140 bytes including the body. - * @return current builder - */ - public Builder setUdh(String udh) { - this.udh = OptionalValue.of(udh); - return this; - } - - public UpdateSmsBatchBinaryRequest build() { - return new UpdateSmsBatchBinaryRequest( - toAdd, toRemove, from, body, deliveryReportType, sendAt, expireAt, callbackUrl, udh); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchMediaRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchMediaRequest.java deleted file mode 100644 index b0bfc78f9..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchMediaRequest.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.MediaBody; -import com.sinch.sdk.domains.sms.models.Parameters; -import java.time.Instant; -import java.util.Collection; - -public class UpdateSmsBatchMediaRequest extends UpdateBaseBatchRequest { - private final OptionalValue parameters; - private final OptionalValue strictValidation; - - public UpdateSmsBatchMediaRequest( - OptionalValue> toAdd, - OptionalValue> toRemove, - OptionalValue from, - OptionalValue body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue parameters, - OptionalValue strictValidation) { - super(toAdd, toRemove, from, body, deliveryReport, sendAt, expireAt, callbackUrl); - this.parameters = parameters; - this.strictValidation = strictValidation; - } - - public OptionalValue getParameters() { - return parameters; - } - - public OptionalValue isStrictValidation() { - return strictValidation; - } - - @Override - public String toString() { - return "UpdateSmsBatchMediaRequest{" - + "parameters=" - + parameters - + ", strictValidation=" - + strictValidation - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends UpdateBaseBatchRequest.Builder { - private OptionalValue parameters = OptionalValue.empty(); - private OptionalValue strictValidation = OptionalValue.empty(); - - private Builder() {} - - /** - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @return current builder - */ - public Builder setParameters(Parameters parameters) { - this.parameters = OptionalValue.of(parameters); - return this; - } - - /** - * @param strictValidation Whether or not you want the media included in your message to be - * checked against Sinch MMS channel best practices. If set to true, your message will be - * rejected if it doesn't conform to the listed recommendations, otherwise no validation - * will be performed - * @return current builder - */ - public Builder setStrictValidation(Boolean strictValidation) { - this.strictValidation = OptionalValue.of(strictValidation); - return this; - } - - public UpdateSmsBatchMediaRequest build() { - return new UpdateSmsBatchMediaRequest( - toAdd, - toRemove, - from, - body, - deliveryReportType, - sendAt, - expireAt, - callbackUrl, - parameters, - strictValidation); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchTextRequest.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchTextRequest.java deleted file mode 100644 index 7a63004bf..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/UpdateSmsBatchTextRequest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.sinch.sdk.domains.sms.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.sms.models.DeliveryReportType; -import com.sinch.sdk.domains.sms.models.Parameters; -import java.time.Instant; -import java.util.Collection; - -public class UpdateSmsBatchTextRequest extends UpdateBaseBatchRequest { - private final OptionalValue parameters; - - public UpdateSmsBatchTextRequest( - OptionalValue> toAdd, - OptionalValue> toRemove, - OptionalValue from, - OptionalValue body, - OptionalValue deliveryReport, - OptionalValue sendAt, - OptionalValue expireAt, - OptionalValue callbackUrl, - OptionalValue parameters) { - super(toAdd, toRemove, from, body, deliveryReport, sendAt, expireAt, callbackUrl); - this.parameters = parameters; - } - - public OptionalValue getParameters() { - return parameters; - } - - @Override - public String toString() { - return "UpdateSmsBatchTextRequest{" + "parameters=" + parameters + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends UpdateBaseBatchRequest.Builder { - private OptionalValue parameters = OptionalValue.empty(); - - private Builder() {} - - /** - * @param parameters Contains the parameters that will be used for customizing the message for - * each recipient. - * @return current builder - */ - public Builder setParameters(Parameters parameters) { - this.parameters = OptionalValue.of(parameters); - return this; - } - - public UpdateSmsBatchTextRequest build() { - return new UpdateSmsBatchTextRequest( - toAdd, - toRemove, - from, - body, - deliveryReportType, - sendAt, - expireAt, - callbackUrl, - parameters); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/requests/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/requests/package-info.java deleted file mode 100644 index 853a20313..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/requests/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * SMS API requests related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.sms.models.requests; diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/responses/BatchesListResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/responses/BatchesListResponse.java deleted file mode 100644 index b8da8575f..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/responses/BatchesListResponse.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.sinch.sdk.domains.sms.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.BatchesService; -import com.sinch.sdk.domains.sms.models.Batch; -import com.sinch.sdk.domains.sms.models.requests.BatchesListRequestParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists batches response - * - * @since 1.0 - */ -public class BatchesListResponse extends ListResponse> { - - private final Page, Integer> page; - private final BatchesService service; - private BatchesListResponse nextPage; - - public BatchesListResponse( - BatchesService service, Page, Integer> page) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - - if (null == nextPage) { - BatchesListRequestParameters.Builder newParameters = - BatchesListRequestParameters.builder(page.getParameters()); - newParameters.setPage(page.getNextPageToken()); - nextPage = service.list(newParameters.build()); - } - return (null != nextPage.getContent() && !nextPage.getContent().isEmpty()); - } - - public BatchesListResponse nextPage() { - - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - - BatchesListResponse response = nextPage; - nextPage = null; - return response; - } - - public Collection> getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "BatchesListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/responses/DeliveryReportsListResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/responses/DeliveryReportsListResponse.java deleted file mode 100644 index a726156ab..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/responses/DeliveryReportsListResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.sinch.sdk.domains.sms.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.DeliveryReportsService; -import com.sinch.sdk.domains.sms.models.DeliveryReportRecipient; -import com.sinch.sdk.domains.sms.models.requests.DeliveryReportListRequestParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Lists batches response - * - * @since 1.0 - */ -public class DeliveryReportsListResponse extends ListResponse { - - private final Page page; - private final DeliveryReportsService service; - private DeliveryReportsListResponse nextPage; - - public DeliveryReportsListResponse( - DeliveryReportsService service, - Page page) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - - if (null == nextPage) { - DeliveryReportListRequestParameters.Builder newParameters = - DeliveryReportListRequestParameters.builder(page.getParameters()); - newParameters.setPage(page.getNextPageToken()); - nextPage = service.list(newParameters.build()); - } - return (null != nextPage.getContent() && !nextPage.getContent().isEmpty()); - } - - public DeliveryReportsListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - DeliveryReportsListResponse response = nextPage; - nextPage = null; - return response; - } - - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "DeliveryReportsListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/responses/GroupsListResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/responses/GroupsListResponse.java deleted file mode 100644 index c01217576..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/responses/GroupsListResponse.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.sinch.sdk.domains.sms.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.GroupsService; -import com.sinch.sdk.domains.sms.models.Group; -import com.sinch.sdk.domains.sms.models.requests.GroupsListRequestParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * Groups List response - * - * @since 1.0 - */ -public class GroupsListResponse extends ListResponse { - - private final Page page; - private final GroupsService service; - private GroupsListResponse nextPage; - - public GroupsListResponse( - GroupsService service, Page page) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - - if (null == nextPage) { - GroupsListRequestParameters.Builder newParameters = - GroupsListRequestParameters.builder(page.getParameters()); - newParameters.setPage(page.getNextPageToken()); - nextPage = service.list(newParameters.build()); - } - return (null != nextPage.getContent() && !nextPage.getContent().isEmpty()); - } - - public GroupsListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - GroupsListResponse response = nextPage; - nextPage = null; - return response; - } - - public Collection getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "GroupsListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/responses/InboundsListResponse.java b/client/src/main/com/sinch/sdk/domains/sms/models/responses/InboundsListResponse.java deleted file mode 100644 index e582fe54d..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/responses/InboundsListResponse.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.sms.models.responses; - -import com.sinch.sdk.core.models.pagination.ListResponse; -import com.sinch.sdk.core.models.pagination.Page; -import com.sinch.sdk.domains.sms.InboundsService; -import com.sinch.sdk.domains.sms.models.Inbound; -import com.sinch.sdk.domains.sms.models.requests.InboundsListRequestParameters; -import java.util.Collection; -import java.util.NoSuchElementException; - -/** - * List Incoming Messages response - * - * @since 1.0 - */ -public class InboundsListResponse extends ListResponse> { - - private final Page, Integer> page; - private final InboundsService service; - private InboundsListResponse nextPage; - - public InboundsListResponse( - InboundsService service, Page, Integer> page) { - this.service = service; - this.page = page; - } - - public boolean hasNextPage() { - if (null == nextPage) { - InboundsListRequestParameters.Builder newParameters = - InboundsListRequestParameters.builder(page.getParameters()); - newParameters.setPage(page.getNextPageToken()); - nextPage = service.list(newParameters.build()); - } - return (null != nextPage.getContent() && !nextPage.getContent().isEmpty()); - } - - public InboundsListResponse nextPage() { - if (!hasNextPage()) { - throw new NoSuchElementException("Reached the last page of the API response"); - } - InboundsListResponse response = nextPage; - nextPage = null; - return response; - } - - public Collection> getContent() { - return page.getEntities(); - } - - @Override - public String toString() { - return "InboundsListResponse{" + "page=" + page + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/responses/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/responses/package-info.java deleted file mode 100644 index d1d64f4d4..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/responses/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * SMS API responses related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.sms.models.responses; diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReport.java index 0bdf1319e..26879da5e 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReport.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/BatchDeliveryReport.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.sms.models.v1.deliveryreports; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.api.v1.SinchEventsService; import com.sinch.sdk.domains.sms.models.v1.deliveryreports.internal.BatchDeliveryReportOneOfImpl; import com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.BatchDeliveryReportQueryParameters; @@ -9,7 +10,7 @@ * * @see com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#get(String, * BatchDeliveryReportQueryParameters) - * @see com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String) + * @see SinchEventsService#parseEvent(String) * @since 1.5 */ @JsonDeserialize(using = BatchDeliveryReportOneOfImpl.Deserializer.class) diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReport.java index 75d30610d..c69b40ebb 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReport.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/DeliveryReport.java @@ -1,11 +1,12 @@ package com.sinch.sdk.domains.sms.models.v1.deliveryreports; -import com.sinch.sdk.domains.sms.models.v1.webhooks.SmsEvent; +import com.sinch.sdk.domains.sms.api.v1.SinchEventsService; +import com.sinch.sdk.domains.sms.models.v1.sinchevents.SmsSinchEvent; /** * Base class for all classes supporting DeliveryReport * - * @see com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String) + * @see SinchEventsService#parseEvent(String) * @since 1.5 */ -public interface DeliveryReport extends SmsEvent {} +public interface DeliveryReport extends SmsSinchEvent {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReport.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReport.java index 536cb2204..8f4c25904 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReport.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/deliveryreports/RecipientDeliveryReport.java @@ -1,6 +1,7 @@ package com.sinch.sdk.domains.sms.models.v1.deliveryreports; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.api.v1.SinchEventsService; import com.sinch.sdk.domains.sms.models.v1.deliveryreports.internal.RecipientDeliveryReportOneOfImpl; import com.sinch.sdk.domains.sms.models.v1.deliveryreports.request.ListDeliveryReportsQueryParameters; @@ -10,7 +11,7 @@ * @see com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#getForNumber(String, String) * @see * com.sinch.sdk.domains.sms.api.v1.DeliveryReportsService#list(ListDeliveryReportsQueryParameters) - * @see com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String) + * @see SinchEventsService#parseEvent(String) * @since 1.5 */ @JsonDeserialize(using = RecipientDeliveryReportOneOfImpl.Deserializer.class) diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/inbounds/InboundMessage.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/inbounds/InboundMessage.java index a24878770..420f298d4 100644 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/inbounds/InboundMessage.java +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/inbounds/InboundMessage.java @@ -1,17 +1,18 @@ package com.sinch.sdk.domains.sms.models.v1.inbounds; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.api.v1.SinchEventsService; import com.sinch.sdk.domains.sms.models.v1.inbounds.request.ListInboundMessagesQueryParameters; import com.sinch.sdk.domains.sms.models.v1.inbounds.response.internal.InboundInternalImpl; -import com.sinch.sdk.domains.sms.models.v1.webhooks.SmsEvent; +import com.sinch.sdk.domains.sms.models.v1.sinchevents.SmsSinchEvent; /** * Base class for all classes supporting InBounds * * @see com.sinch.sdk.domains.sms.api.v1.InboundsService#get(String) * @see com.sinch.sdk.domains.sms.api.v1.InboundsService#list(ListInboundMessagesQueryParameters) - * @see com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String) + * @see SinchEventsService#parseEvent(String) * @since 1.5 */ @JsonDeserialize(using = InboundInternalImpl.Deserializer.class) -public interface InboundMessage extends SmsEvent {} +public interface InboundMessage extends SmsSinchEvent {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/SmsSinchEvent.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/SmsSinchEvent.java new file mode 100644 index 000000000..5e80df4af --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/SmsSinchEvent.java @@ -0,0 +1,14 @@ +package com.sinch.sdk.domains.sms.models.v1.sinchevents; + +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.sinch.sdk.domains.sms.api.v1.SinchEventsService; +import com.sinch.sdk.domains.sms.models.v1.sinchevents.internal.SmsSinchEventOneOfImpl; + +/** + * Base class for all Sinch event's class + * + * @see SinchEventsService#parseEvent(String) + * @since 2.0 + */ +@JsonDeserialize(using = SmsSinchEventOneOfImpl.Deserializer.class) +public interface SmsSinchEvent {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/package-info.java new file mode 100644 index 000000000..4d5f62e7c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/sms/models/v1/sinchevents/package-info.java @@ -0,0 +1,57 @@ +/** + * SMS API Sinch Events related models + * + *

Incoming SMS Event

+ * + *

An inbound message is a message sent to one of your short codes or long numbers from a mobile + * phone. To receive inbound message callbacks, a URL needs to be added to your REST API. + * + *

This URL can be specified in your Dashboard. + * + *

See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/incomingSMS + * + *

Delivery Report Event

+ * + *

A delivery report contains the status and status code for each recipient of a batch. To get a + * delivery report callback for a message or batch of messages, set the delivery_report + * field accordingly when creating a batch. + * + *

The following is provided so you can better understand our Sinch Events. Configuration of both + * sinch events and the type of delivery report requested happens when sending a batch. + * + *

Callback URL + * + *

The callback URL can either be provided for each batch or provisioned globally for your + * account in your Sinch Customer Dashboard. + * Learn how to configure a Sinch Event here + * + *

Type + * + *

The type is the type of delivery report event. The response will vary depending + * on the event delivery report you selected when the batch was sent, so choose the appropriate + * selection under "One of". + * + *

    + *
  • The delivery_report_sms and delivery_report_mms types are + * documented under Delivery report. + *

    These are reports containing either + * a full report or summary report, depending on your selection at the time the batch was + * sent. + *

  • The recipient_delivery_report_sms and recipient_delivery_report_mms + * delivery report types are documented under Recipient delivery report. + *

    These are delivery reports for recipient phone numbers. If you set per_recipient + * for the delivery_report parameter when sending the batch, a recipient + * report gets sent to you for each status change for each recipient in your batch. If you set + * per_recipient_final, a recipient report gets sent to you for the final status + * of each recipient in your batch. + *

+ * + * See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/deliveryReport + * + * @since 2.0 + */ +package com.sinch.sdk.domains.sms.models.v1.sinchevents; diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/SmsEvent.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/SmsEvent.java deleted file mode 100644 index 6257897ec..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/SmsEvent.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sinch.sdk.domains.sms.models.v1.webhooks; - -import com.fasterxml.jackson.databind.annotation.JsonDeserialize; -import com.sinch.sdk.domains.sms.models.v1.webhooks.internal.WebhookEventOneOfImpl; - -/** - * Base class for all WebHook event's class - * - * @see com.sinch.sdk.domains.sms.api.v1.WebHooksService#parseEvent(String) - * @since 1.5 - */ -@JsonDeserialize(using = WebhookEventOneOfImpl.Deserializer.class) -public interface SmsEvent {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/package-info.java deleted file mode 100644 index f1aa66b4d..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/v1/webhooks/package-info.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * SMS API webhooks related models - * - *

Incoming SMS WebHook

- * - *

An inbound message is a message sent to one of your short codes or long numbers from a mobile - * phone. To receive inbound message callbacks, a URL needs to be added to your REST API. - * - *

This URL can be specified in your Dashboard. - * - *

See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/incomingSMS - * - *

Delivery Report WebHook

- * - *

A delivery report contains the status and status code for each recipient of a batch. To get a - * delivery report callback for a message or batch of messages, set the delivery_report - * field accordingly when creating a batch. - * - *

The following is provided so you can better understand our webhooks/callbacks. Configuration - * of both webhooks and the type of delivery report requested happens when sending a batch. - * - *

Callback URL - * - *

The callback URL can either be provided for each batch or provisioned globally for your - * account in your Sinch Customer Dashboard. - * Learn how to configure a webhook/callback here - * - *

Type - * - *

The type is the type of delivery report webhook. The response will vary depending - * on the webhook delivery report you selected when the batch was sent, so choose the appropriate - * selection under "One of". - * - *

    - *
  • The delivery_report_sms and delivery_report_mms types are - * documented under Delivery report. - *

    These are reports containing either - * a full report or summary report, depending on your selection at the time the batch was - * sent. - *

  • The recipient_delivery_report_sms and recipient_delivery_report_mms - * delivery report types are documented under Recipient delivery report. - *

    These are delivery reports for recipient phone numbers. If you set per_recipient - * for the delivery_report parameter when sending the batch, a recipient - * report gets sent to you for each status change for each recipient in your batch. If you set - * per_recipient_final, a recipient report gets sent to you for the final status - * of each recipient in your batch. - *

- * - * See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/deliveryReport - * - * @since 1.5 - */ -package com.sinch.sdk.domains.sms.models.v1.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/WebhooksEvent.java b/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/WebhooksEvent.java deleted file mode 100644 index 0c0630124..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/WebhooksEvent.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.sinch.sdk.domains.sms.models.webhooks; - -/** Interface defining a WebHook event */ -public interface WebhooksEvent {} diff --git a/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/package-info.java deleted file mode 100644 index 225045d4b..000000000 --- a/client/src/main/com/sinch/sdk/domains/sms/models/webhooks/package-info.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * SMS API webhooks related models - * - *

Incoming SMS WebHook

- * - *

An inbound message is a message sent to one of your short codes or long numbers from a mobile - * phone. To receive inbound message callbacks, a URL needs to be added to your REST API. - * - *

This URL can be specified in your Dashboard. - * - *

See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/incomingSMS - * - *

Delivery Report WebHook

- * - *

A delivery report contains the status and status code for each recipient of a batch. To get a - * delivery report callback for a message or batch of messages, set the delivery_report - * field accordingly when creating a batch. - * - *

The following is provided so you can better understand our webhooks/callbacks. Configuration - * of both webhooks and the type of delivery report requested happens when sending a batch. - * - *

Callback URL - * - *

The callback URL can either be provided for each batch or provisioned globally for your - * account in your Sinch Customer Dashboard. - * Learn how to configure a webhook/callback here - * - *

Type - * - *

The type is the type of delivery report webhook. The response will vary depending - * on the webhook delivery report you selected when the batch was sent, so choose the appropriate - * selection under "One of". - * - *

    - *
  • The delivery_report_sms and delivery_report_mms types are - * documented under Delivery report. - *

    These are reports containing either - * a full report or summary report, depending on your selection at the time the batch was - * sent. - *

  • The recipient_delivery_report_sms and recipient_delivery_report_mms - * delivery report types are documented under Recipient delivery report. - *

    These are delivery reports for recipient phone numbers. If you set per_recipient - * for the delivery_report parameter when sending the batch, a recipient - * report gets sent to you for each status change for each recipient in your batch. If you set - * per_recipient_final, a recipient report gets sent to you for the final status - * of each recipient in your batch. - *

- * - * See https://developers.sinch.com/docs/sms/api-reference/sms/tag/Webhooks/#tag/Webhooks/operation/deliveryReport - * - * @since 1.0 - */ -package com.sinch.sdk.domains.sms.models.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java index 88d47b492..d028020b3 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/VerificationService.java @@ -18,46 +18,4 @@ public interface VerificationService { * @since 1.1 */ com.sinch.sdk.domains.verification.api.v1.VerificationService v1(); - - /** - * Non versioned Verifications Service instance - * - * @return service instance for project - * @see Documentation - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationService#verificationReport()} and - * {@link com.sinch.sdk.domains.verification.api.v1.VerificationService#verificationStart()} - * instead. - */ - @Deprecated - VerificationsService verifications(); - - /** - * Non versioned Status Service instance - * - * @return service instance for project - * @see Documentation - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationService#verificationStatus()} - * instead. - */ - @Deprecated - VerificationStatusService verificationStatus(); - - /** - * Non versioned Webhooks helpers instance - * - * @return instance service related to webhooks helpers - * @see Documentation - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationService#webhooks()} instead. - */ - @Deprecated - WebHooksService webhooks(); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationStatusService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationStatusService.java deleted file mode 100644 index 78dee723a..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationStatusService.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.verification; - -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.VerificationStatus; -import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; - -/** - * 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 - * @deprecated use {@link com.sinch.sdk.domains.verification.api.v1.VerificationStatusService} - * instead. - */ -@Deprecated -public interface VerificationStatusService { - - /** - * 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 Currently Only {@link - * com.sinch.sdk.domains.verification.models.NumberIdentity NumberIdentity} is supported - * @param method Method used for verification - * @return Verification status response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStatusService#getByIdentity(com.sinch.sdk.domains.verification.models.v1.NumberIdentity, - * VerificationMethod)} instead. - */ - @Deprecated - VerificationStatus getByIdentity(NumberIdentity 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 status response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStatusService#getById(String)} - * instead. - */ - @Deprecated - VerificationStatus getById(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 status response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStatusService#getByReference(String)} - * instead. - */ - @Deprecated - VerificationStatus getByReference(VerificationReference reference); -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java b/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java deleted file mode 100644 index 5944ce48e..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/VerificationsService.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.sinch.sdk.domains.verification; - -import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationId; -import com.sinch.sdk.domains.verification.models.VerificationReportCallout; -import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; -import com.sinch.sdk.domains.verification.models.VerificationReportSMS; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSMSRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSeamlessRequestParameters; -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; -import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSeamless; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestSms; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms; - -/** - * 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 - * @deprecated use {@link com.sinch.sdk.domains.verification.api.v1.VerificationStartService} - * instead. - */ -@Deprecated -public interface VerificationsService { - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#SMS SMS} - * - *

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 a request. - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStartService#startSms(VerificationStartRequestSms)} - * instead. - * @since 1.0 - */ - @Deprecated - StartVerificationResponseSMS startSms(StartVerificationSMSRequestParameters parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#FLASH_CALL FLASH_CALL} - * - *

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 a request. - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStartService#startFlashCall(VerificationStartRequestFlashCall)} - * instead. - */ - @Deprecated - StartVerificationResponseFlashCall startFlashCall( - StartVerificationFlashCallRequestParameters parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#CALLOUT CALLOUT} - * - *

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 a request. - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStartService#startPhoneCall(VerificationStartRequestPhoneCall)} - * instead. - * @since 1.0 - */ - @Deprecated - StartVerificationResponseCallout startCallout( - StartVerificationCalloutRequestParameters parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#SEAMLESS SEAMLESS} - * - *

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 a request. - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationStartService#startData(VerificationStartRequestData)} - * instead. - */ - @Deprecated - StartVerificationResponseSeamless startSeamless( - StartVerificationSeamlessRequestParameters parameters); - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#SMS SMS} & Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportSmsByIdentity(com.sinch.sdk.domains.verification.models.v1.NumberIdentity, - * VerificationReportRequestSms)} instead. - */ - @Deprecated - VerificationReportSMS reportSmsByIdentity( - NumberIdentity identity, VerificationReportSMSRequestParameters parameters); - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#FLASH_CALL FLASH_CALL} & - * Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportFlashCallByIdentity(com.sinch.sdk.domains.verification.models.v1.NumberIdentity, - * VerificationReportRequestFlashCall)} instead. - */ - @Deprecated - VerificationReportFlashCall reportFlashCallByIdentity( - NumberIdentity identity, VerificationReportFlashCallRequestParameters parameters); - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#CALLOUT CALLOUT} & - * Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportPhoneCallByIdentity(com.sinch.sdk.domains.verification.models.v1.NumberIdentity, - * VerificationReportRequestPhoneCall)} instead. - */ - @Deprecated - VerificationReportCallout reportCalloutByIdentity( - NumberIdentity identity, VerificationReportCalloutRequestParameters parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#SMS SMS} 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 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportSmsById(String, - * VerificationReportRequestSms)} instead. - */ - @Deprecated - VerificationReportSMS reportSmsById( - VerificationId id, VerificationReportSMSRequestParameters parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#FLASH_CALL FLASH_CALL} - * 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 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportFlashCallById(String, - * VerificationReportRequestFlashCall)} instead. - */ - @Deprecated - VerificationReportFlashCall reportFlashCallById( - VerificationId id, VerificationReportFlashCallRequestParameters parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.VerificationMethodType#CALLOUT CALLOUT} 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 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.VerificationReportService#reportPhoneCallByIdentity(com.sinch.sdk.domains.verification.models.v1.NumberIdentity, - * VerificationReportRequestPhoneCall)} instead. - */ - @Deprecated - VerificationReportCallout reportCalloutById( - VerificationId id, VerificationReportCalloutRequestParameters parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java deleted file mode 100644 index 45f117c59..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.sinch.sdk.domains.verification; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationEvent; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponse; -import java.util.Map; - -/** - * Webhooks service - * - *

Callback events are used to authorize and manage your verification requests and return - * verification results. - * - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/#tag/Verification-callbacks/paths/VerificationRequestEvent/post - * - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.verification.api.v1.WebHooksService} instead. - */ -@Deprecated -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed using your Application key and secret pair - * found on your dashboard. The signature is included in the Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param method The HTTP method used ot handle the callback - * @param path The path to you backend endpoint used for callback - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see https://developers.sinch.com/docs/verification/api-reference/authentication/callback-signed-request - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.WebHooksService#validateAuthenticationHeader(String, - * String, Map, String)} instead. - */ - @Deprecated - boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback onto proper java - * verification event class - * - * @param jsonPayload Received payload to be deserialized - * @return The verification event instance class - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.WebHooksService#parseEvent(String)} instead. - */ - @Deprecated - VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException; - - /** - * This function can be called to serialize a verification response to be sent as JSON - * - * @param response The response to be serialized - * @return The JSON string to be sent - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.verification.api.v1.WebHooksService#serializeResponse(VerificationRequestEventResponse)} - * instead. - */ - @Deprecated - String serializeResponse(VerificationResponse response) throws ApiMappingException; -} 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 ac4331c2e..c1947b4ca 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 @@ -1,78 +1,37 @@ package com.sinch.sdk.domains.verification.adapters; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.verification.VerificationStatusService; -import com.sinch.sdk.domains.verification.VerificationsService; -import com.sinch.sdk.domains.verification.WebHooksService; import com.sinch.sdk.models.ApplicationCredentials; import com.sinch.sdk.models.VerificationContext; import java.util.function.Supplier; public class VerificationService implements com.sinch.sdk.domains.verification.VerificationService { - private final com.sinch.sdk.domains.verification.api.v1.VerificationService v1; + private final ApplicationCredentials credentials; + private final VerificationContext context; + private final Supplier httpClientSupplier; - private VerificationsService verifications; - private VerificationStatusService verificationStatus; - private WebHooksService webhooks; - - static { - LocalLazyInit.init(); - } + private volatile com.sinch.sdk.domains.verification.api.v1.VerificationService v1; public VerificationService( ApplicationCredentials credentials, VerificationContext context, Supplier httpClientSupplier) { - - this.v1 = - new com.sinch.sdk.domains.verification.api.v1.adapters.VerificationService( - credentials, context, httpClientSupplier); + this.credentials = credentials; + this.context = context; + this.httpClientSupplier = httpClientSupplier; } public com.sinch.sdk.domains.verification.api.v1.VerificationService v1() { - return this.v1; - } - - public VerificationsService verifications() { - if (null == this.verifications) { - this.verifications = - new com.sinch.sdk.domains.verification.adapters.VerificationsService( - v1.verificationStart(), v1.verificationReport()); - } - return this.verifications; - } - - public VerificationStatusService verificationStatus() { - if (null == this.verificationStatus) { - this.verificationStatus = - new com.sinch.sdk.domains.verification.adapters.VerificationStatusService( - v1.verificationStatus()); - } - return this.verificationStatus; - } - - public WebHooksService webhooks() { - if (null == this.webhooks) { - this.webhooks = - new com.sinch.sdk.domains.verification.adapters.WebHooksService(v1.webhooks()); - } - return this.webhooks; - } - - static final class LocalLazyInit { - - private LocalLazyInit() { - IdentityMapper.initMapper(); - } - - public static LocalLazyInit init() { - return LocalLazyInit.LazyHolder.INSTANCE; - } - - private static class LazyHolder { - - public static final LocalLazyInit INSTANCE = new LocalLazyInit(); + if (null == this.v1) { + synchronized (this) { + if (null == this.v1) { + this.v1 = + new com.sinch.sdk.domains.verification.api.v1.adapters.VerificationService( + credentials, context, httpClientSupplier); + } + } } + return this.v1; } } diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationStatusService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationStatusService.java deleted file mode 100644 index f0a32b0bc..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationStatusService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters; - -import com.sinch.sdk.domains.verification.adapters.converters.StatusDtoConverter; -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.VerificationStatus; -import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; - -public class VerificationStatusService - implements com.sinch.sdk.domains.verification.VerificationStatusService { - - private final com.sinch.sdk.domains.verification.api.v1.VerificationStatusService v1; - - public VerificationStatusService( - com.sinch.sdk.domains.verification.api.v1.VerificationStatusService v1) { - this.v1 = v1; - } - - public VerificationStatus getByIdentity(NumberIdentity identity, VerificationMethodType method) { - - return StatusDtoConverter.convert( - v1.getByIdentity( - com.sinch.sdk.domains.verification.models.v1.NumberIdentity.valueOf( - identity.getEndpoint()), - VerificationMethod.from(method.value()))); - } - - public VerificationStatus getById(VerificationId id) { - - return StatusDtoConverter.convert(v1.getById(id.getId())); - } - - public VerificationStatus getByReference(VerificationReference reference) { - - return StatusDtoConverter.convert(v1.getByReference(reference.getReference())); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsReportService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsReportService.java deleted file mode 100644 index 2f241aec9..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsReportService.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters; - -import com.sinch.sdk.domains.verification.adapters.converters.IdentityDtoConverter; -import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; -import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationId; -import com.sinch.sdk.domains.verification.models.VerificationReportCallout; -import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; -import com.sinch.sdk.domains.verification.models.VerificationReportSMS; -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.v1.report.response.VerificationReportResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSms; - -public class VerificationsReportService { - - private final com.sinch.sdk.domains.verification.api.v1.VerificationReportService v1; - - public VerificationsReportService( - com.sinch.sdk.domains.verification.api.v1.VerificationReportService v1) { - this.v1 = v1; - } - - public VerificationReportSMS reportSmsByIdentity( - NumberIdentity identity, VerificationReportSMSRequestParameters parameters) { - - VerificationReportResponseSms response = - v1.reportSmsByIdentity( - IdentityDtoConverter.convert(identity), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportSMS) VerificationsDtoConverter.convert(response); - } - - public VerificationReportFlashCall reportFlashCallByIdentity( - NumberIdentity identity, VerificationReportFlashCallRequestParameters parameters) { - VerificationReportResponseFlashCall response = - v1.reportFlashCallByIdentity( - IdentityDtoConverter.convert(identity), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportFlashCall) VerificationsDtoConverter.convert(response); - } - - public VerificationReportCallout reportCalloutByIdentity( - NumberIdentity identity, VerificationReportCalloutRequestParameters parameters) { - VerificationReportResponsePhoneCall response = - v1.reportPhoneCallByIdentity( - IdentityDtoConverter.convert(identity), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportCallout) VerificationsDtoConverter.convert(response); - } - - public VerificationReportSMS reportSmsById( - VerificationId id, VerificationReportSMSRequestParameters parameters) { - VerificationReportResponseSms response = - v1.reportSmsById(id.getId(), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportSMS) VerificationsDtoConverter.convert(response); - } - - public VerificationReportFlashCall reportFlashCallById( - VerificationId id, VerificationReportFlashCallRequestParameters parameters) { - VerificationReportResponseFlashCall response = - v1.reportFlashCallById(id.getId(), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportFlashCall) VerificationsDtoConverter.convert(response); - } - - public VerificationReportCallout reportCalloutById( - VerificationId id, VerificationReportCalloutRequestParameters parameters) { - VerificationReportResponsePhoneCall response = - v1.reportPhoneCallById(id.getId(), VerificationsDtoConverter.convert(parameters)); - return (VerificationReportCallout) VerificationsDtoConverter.convert(response); - } -} 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 deleted file mode 100644 index 59f198814..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsService.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters; - -import com.sinch.sdk.domains.verification.models.NumberIdentity; -import com.sinch.sdk.domains.verification.models.VerificationId; -import com.sinch.sdk.domains.verification.models.VerificationReportCallout; -import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; -import com.sinch.sdk.domains.verification.models.VerificationReportSMS; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSMSRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSeamlessRequestParameters; -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; -import com.sinch.sdk.domains.verification.models.response.StartVerificationResponseSeamless; - -public class VerificationsService - implements com.sinch.sdk.domains.verification.VerificationsService { - - private final VerificationsReportService reportService; - private final VerificationsStartService startService; - - public VerificationsService( - com.sinch.sdk.domains.verification.api.v1.VerificationStartService startV1, - com.sinch.sdk.domains.verification.api.v1.VerificationReportService reportV1) { - this.reportService = new VerificationsReportService(reportV1); - this.startService = new VerificationsStartService(startV1); - } - - public StartVerificationResponseSMS startSms(StartVerificationSMSRequestParameters parameters) { - return startService.startSms(parameters); - } - - public StartVerificationResponseFlashCall startFlashCall( - StartVerificationFlashCallRequestParameters parameters) { - return startService.startFlashCall(parameters); - } - - public StartVerificationResponseCallout startCallout( - StartVerificationCalloutRequestParameters parameters) { - return startService.startCallout(parameters); - } - - public StartVerificationResponseSeamless startSeamless( - StartVerificationSeamlessRequestParameters parameters) { - return startService.startSeamless(parameters); - } - - public VerificationReportSMS reportSmsByIdentity( - NumberIdentity identity, VerificationReportSMSRequestParameters parameters) { - return reportService.reportSmsByIdentity(identity, parameters); - } - - public VerificationReportFlashCall reportFlashCallByIdentity( - NumberIdentity identity, VerificationReportFlashCallRequestParameters parameters) { - return reportService.reportFlashCallByIdentity(identity, parameters); - } - - public VerificationReportCallout reportCalloutByIdentity( - NumberIdentity identity, VerificationReportCalloutRequestParameters parameters) { - return reportService.reportCalloutByIdentity(identity, parameters); - } - - public VerificationReportSMS reportSmsById( - VerificationId id, VerificationReportSMSRequestParameters parameters) { - return reportService.reportSmsById(id, parameters); - } - - public VerificationReportFlashCall reportFlashCallById( - VerificationId id, VerificationReportFlashCallRequestParameters parameters) { - return reportService.reportFlashCallById(id, parameters); - } - - public VerificationReportCallout reportCalloutById( - VerificationId id, VerificationReportCalloutRequestParameters parameters) { - return reportService.reportCalloutById(id, parameters); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsStartService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsStartService.java deleted file mode 100644 index 9a680b750..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/VerificationsStartService.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters; - -import com.sinch.sdk.domains.verification.adapters.converters.VerificationsDtoConverter; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSMSRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSeamlessRequestParameters; -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 com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms; - -public class VerificationsStartService { - - private final com.sinch.sdk.domains.verification.api.v1.VerificationStartService v1; - - public VerificationsStartService( - com.sinch.sdk.domains.verification.api.v1.VerificationStartService v1) { - this.v1 = v1; - } - - public StartVerificationResponseSMS startSms(StartVerificationSMSRequestParameters parameters) { - - VerificationStartResponseSms response = - v1.startSms((VerificationStartRequestSms) VerificationsDtoConverter.convert(parameters)); - return (StartVerificationResponseSMS) VerificationsDtoConverter.convert(response); - } - - public StartVerificationResponseFlashCall startFlashCall( - StartVerificationFlashCallRequestParameters parameters) { - - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseFlashCall - response = - v1.startFlashCall( - (VerificationStartRequestFlashCall) VerificationsDtoConverter.convert(parameters)); - return (StartVerificationResponseFlashCall) VerificationsDtoConverter.convert(response); - } - - public StartVerificationResponseCallout startCallout( - StartVerificationCalloutRequestParameters parameters) { - - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponsePhoneCall - response = - v1.startPhoneCall( - (VerificationStartRequestPhoneCall) VerificationsDtoConverter.convert(parameters)); - return (StartVerificationResponseCallout) VerificationsDtoConverter.convert(response); - } - - public StartVerificationResponseSeamless startSeamless( - StartVerificationSeamlessRequestParameters parameters) { - - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData - response = - v1.startData( - (VerificationStartRequestData) VerificationsDtoConverter.convert(parameters)); - return (StartVerificationResponseSeamless) VerificationsDtoConverter.convert(response); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/WebHooksService.java deleted file mode 100644 index ae227656c..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/WebHooksService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.verification.adapters.converters.WebHooksDtoConverter; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationEvent; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponse; -import java.util.Map; -import java.util.logging.Logger; - -public class WebHooksService implements com.sinch.sdk.domains.verification.WebHooksService { - - private static final Logger LOGGER = Logger.getLogger(WebHooksService.class.getName()); - - private final com.sinch.sdk.domains.verification.api.v1.WebHooksService v1; - - public WebHooksService(com.sinch.sdk.domains.verification.api.v1.WebHooksService v1) { - this.v1 = v1; - } - - public boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload) { - - return v1.validateAuthenticationHeader(method, path, headers, jsonPayload); - } - - @Override - public VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException { - - com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent dto = - v1.parseEvent(jsonPayload); - - return WebHooksDtoConverter.convert(dto); - } - - @Override - public String serializeResponse(VerificationResponse response) throws ApiMappingException { - return v1.serializeResponse(WebHooksDtoConverter.convert(response)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/IdentityDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/IdentityDtoConverter.java deleted file mode 100644 index a7d67a7be..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/IdentityDtoConverter.java +++ /dev/null @@ -1,46 +0,0 @@ -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.v1.internal.IdentityInternal; -import java.util.logging.Logger; - -public class IdentityDtoConverter { - private static final Logger LOGGER = Logger.getLogger(IdentityDtoConverter.class.getName()); - - public static Identity convert(IdentityInternal dto) { - Identity identity = null; - if (IdentityInternal.TypeEnum.NUMBER.equals(dto.getType())) { - identity = NumberIdentity.valueOf(dto.getEndpoint()); - } else { - LOGGER.severe(String.format("Unexpected '%s'", dto)); - } - return identity; - } - - public static com.sinch.sdk.domains.verification.models.Identity convert( - com.sinch.sdk.domains.verification.models.v1.Identity dto) { - com.sinch.sdk.domains.verification.models.Identity client = null; - if (dto instanceof com.sinch.sdk.domains.verification.models.v1.NumberIdentity) { - client = - com.sinch.sdk.domains.verification.models.NumberIdentity.valueOf( - ((com.sinch.sdk.domains.verification.models.v1.NumberIdentity) dto).getEndpoint()); - } else { - LOGGER.severe(String.format("Unexpected '%s'", client)); - } - return client; - } - - public static com.sinch.sdk.domains.verification.models.v1.NumberIdentity convert( - com.sinch.sdk.domains.verification.models.Identity client) { - com.sinch.sdk.domains.verification.models.v1.NumberIdentity dto = null; - if (client instanceof com.sinch.sdk.domains.verification.models.NumberIdentity) { - dto = - com.sinch.sdk.domains.verification.models.v1.NumberIdentity.valueOf( - ((com.sinch.sdk.domains.verification.models.NumberIdentity) client).getEndpoint()); - } else { - LOGGER.severe(String.format("Unexpected '%s'", client)); - } - return dto; - } -} 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 deleted file mode 100644 index 154be3777..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/LinkDtoConverter.java +++ /dev/null @@ -1,23 +0,0 @@ -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 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(com.sinch.sdk.domains.verification.models.v1.start.response.Link dto) { - return Link.builder() - .setRel(LinkRelType.from(dto.getRel().value())) - .setHref(dto.getHref()) - .setMethod(HttpMethod.valueOf(dto.getMethod())) - .build(); - } -} 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 deleted file mode 100644 index 87417f227..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/PriceDtoConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters.converters; - -import com.sinch.sdk.domains.verification.models.Price; - -public class PriceDtoConverter { - - public static Price convert(com.sinch.sdk.domains.verification.models.v1.Price 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/StatusDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/StatusDtoConverter.java deleted file mode 100644 index 9158a3d2c..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/StatusDtoConverter.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters.converters; - -import com.sinch.sdk.domains.verification.models.VerificationId; -import com.sinch.sdk.domains.verification.models.VerificationReference; -import com.sinch.sdk.domains.verification.models.VerificationSourceType; -import com.sinch.sdk.domains.verification.models.VerificationStatus; -import com.sinch.sdk.domains.verification.models.VerificationStatusCallout; -import com.sinch.sdk.domains.verification.models.VerificationStatusFlashCall; -import com.sinch.sdk.domains.verification.models.VerificationStatusReasonType; -import com.sinch.sdk.domains.verification.models.VerificationStatusSMS; -import com.sinch.sdk.domains.verification.models.VerificationStatusType; -import com.sinch.sdk.domains.verification.models.v1.status.StatusPriceImpl; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponse; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseFlashCallImpl; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponsePhoneCallImpl; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseSms; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseSmsImpl; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseSmsPriceImpl; -import java.util.logging.Logger; - -public class StatusDtoConverter { - - private static final Logger LOGGER = Logger.getLogger(VerificationsDtoConverter.class.getName()); - - public static VerificationStatus convert(VerificationStatusResponse dto) { - - VerificationStatus.Builder builder; - - if (dto instanceof VerificationStatusResponseSms) { - builder = convert((VerificationStatusResponseSmsImpl) dto); - } else if (dto instanceof VerificationStatusResponseFlashCall) { - builder = convert((VerificationStatusResponseFlashCallImpl) dto); - } else if (dto instanceof VerificationStatusResponsePhoneCall) { - builder = convert((VerificationStatusResponsePhoneCallImpl) dto); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - builder = VerificationStatus.builder(); - } - return builder.build(); - } - - private static VerificationStatusFlashCall.Builder convert( - VerificationStatusResponseFlashCallImpl dto) { - - VerificationStatusFlashCall.Builder builder = VerificationStatusFlashCall.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status().ifPresent(f -> builder.setStatus(VerificationStatusType.from(f.value()))); - dto.reason().ifPresent(f -> builder.setReason(VerificationStatusReasonType.from(f.value()))); - dto.reference().ifPresent(f -> builder.setReference(VerificationReference.valueOf(f))); - dto.identity().ifPresent(f -> builder.setIdentity(IdentityDtoConverter.convert(f))); - dto.countryId().ifPresent(f -> builder.setCountryId(dto.getCountryId())); - - dto.verificationTimestamp().ifPresent(builder::setVerificationTimeStamp); - dto.source().ifPresent(f -> builder.setSource(VerificationSourceType.from(f.value()))); - - dto.price() - .ifPresent( - f -> { - StatusPriceImpl price = (StatusPriceImpl) f; - price - .verificationPrice() - .ifPresent(p -> builder.setVerificationPrice(PriceDtoConverter.convert(p))); - price - .terminationPrice() - .ifPresent(p -> builder.setTerminationPrice(PriceDtoConverter.convert(p))); - price.billableDuration().ifPresent(builder::setBillableDuration); - }); - return builder; - } - - private static VerificationStatusSMS.Builder convert(VerificationStatusResponseSmsImpl dto) { - - VerificationStatusSMS.Builder builder = VerificationStatusSMS.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status().ifPresent(f -> builder.setStatus(VerificationStatusType.from(f.value()))); - dto.reason().ifPresent(f -> builder.setReason(VerificationStatusReasonType.from(f.value()))); - dto.reference().ifPresent(f -> builder.setReference(VerificationReference.valueOf(f))); - dto.identity().ifPresent(f -> builder.setIdentity(IdentityDtoConverter.convert(f))); - dto.countryId().ifPresent(f -> builder.setCountryId(dto.getCountryId())); - - dto.verificationTimestamp().ifPresent(builder::setVerificationTimeStamp); - dto.source().ifPresent(f -> builder.setSource(VerificationSourceType.from(f.value()))); - - dto.price() - .ifPresent( - f -> { - VerificationStatusResponseSmsPriceImpl price = - (VerificationStatusResponseSmsPriceImpl) f; - price - .verificationPrice() - .ifPresent(p -> builder.setVerificationPrice(PriceDtoConverter.convert(p))); - }); - return builder; - } - - private static VerificationStatusCallout.Builder convert( - VerificationStatusResponsePhoneCallImpl dto) { - - VerificationStatusCallout.Builder builder = VerificationStatusCallout.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status().ifPresent(f -> builder.setStatus(VerificationStatusType.from(f.value()))); - dto.reason().ifPresent(f -> builder.setReason(VerificationStatusReasonType.from(f.value()))); - dto.reference().ifPresent(f -> builder.setReference(VerificationReference.valueOf(f))); - dto.identity().ifPresent(f -> builder.setIdentity(IdentityDtoConverter.convert(f))); - dto.countryId().ifPresent(f -> builder.setCountryId(dto.getCountryId())); - - dto.verificationTimestamp().ifPresent(builder::setVerificationTimeStamp); - dto.callComplete().ifPresent(builder::setCallComplete); - - dto.price() - .ifPresent( - f -> { - StatusPriceImpl price = (StatusPriceImpl) f; - price - .verificationPrice() - .ifPresent(p -> builder.setVerificationPrice(PriceDtoConverter.convert(p))); - price - .terminationPrice() - .ifPresent(p -> builder.setTerminationPrice(PriceDtoConverter.convert(p))); - price.billableDuration().ifPresent(builder::setBillableDuration); - }); - return builder; - } -} 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 deleted file mode 100644 index 9f35fe996..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/VerificationsDtoConverter.java +++ /dev/null @@ -1,359 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -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.VerificationReport; -import com.sinch.sdk.domains.verification.models.VerificationReportCallout; -import com.sinch.sdk.domains.verification.models.VerificationReportFlashCall; -import com.sinch.sdk.domains.verification.models.VerificationReportSMS; -import com.sinch.sdk.domains.verification.models.VerificationStatusType; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutOptions; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutSpeechOptions; -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.StartVerificationSMSOptions; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSMSRequestParameters; -import com.sinch.sdk.domains.verification.models.requests.StartVerificationSeamlessRequestParameters; -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.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; -import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; -import com.sinch.sdk.domains.verification.models.v1.internal.IdentityInternal; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestSms; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponse; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseFlashCallImpl; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCallImpl; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSms; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSmsImpl; -import com.sinch.sdk.domains.verification.models.v1.start.request.PhoneCallSpeech; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms; -import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseDataContentImpl; -import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseFlashCallContentImpl; -import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseSmsContentImpl; -import java.util.logging.Logger; - -public class VerificationsDtoConverter { - - private static final Logger LOGGER = Logger.getLogger(VerificationsDtoConverter.class.getName()); - - public static com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequest - convert(StartVerificationRequestParameters client) { - - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequest.Builder dto; - - if (client instanceof StartVerificationFlashCallRequestParameters) { - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall - .Builder - flashCallBuilder = - com.sinch.sdk.domains.verification.models.v1.start.request - .VerificationStartRequestFlashCall.builder(); - dto = flashCallBuilder; - StartVerificationFlashCallRequestParameters options = - (StartVerificationFlashCallRequestParameters) client; - options.getDialTimeOut().ifPresent(flashCallBuilder::setDialTimeout); - } else if (client instanceof StartVerificationSMSRequestParameters) { - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms.Builder - smsBuilder = - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms - .builder(); - dto = smsBuilder; - StartVerificationSMSRequestParameters options = - (StartVerificationSMSRequestParameters) client; - options.getOptions().ifPresent(f -> convert(smsBuilder, f)); - } else if (client instanceof StartVerificationCalloutRequestParameters) { - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall - .Builder - phoneCallBuilder = - com.sinch.sdk.domains.verification.models.v1.start.request - .VerificationStartRequestPhoneCall.builder(); - dto = phoneCallBuilder; - StartVerificationCalloutRequestParameters options = - (StartVerificationCalloutRequestParameters) client; - options.getOptions().ifPresent(f -> convert(phoneCallBuilder, f)); - } else if (client instanceof StartVerificationSeamlessRequestParameters) { - dto = - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData - .builder(); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); - return null; - } - - client.getIdentity().ifPresent(f -> dto.setIdentity(IdentityDtoConverter.convert(f))); - client.getReference().ifPresent(f -> dto.setReference(f.getReference())); - client.getCustom().ifPresent(dto::setCustom); - - return dto.build(); - } - - private static void convert( - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms.Builder - smsBuilder, - StartVerificationSMSOptions client) { - - client.getExpiry().ifPresent(smsBuilder::setExpiry); - client - .getCodeType() - .ifPresent( - f -> smsBuilder.setCodeType(VerificationStartRequestSms.CodeTypeEnum.from(f.value()))); - client.getTemplate().ifPresent(smsBuilder::setTemplate); - client.getAcceptLanguage().ifPresent(smsBuilder::setAcceptLanguage); - } - - private static void convert( - com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall - .Builder - phoneCallBuilder, - StartVerificationCalloutOptions client) { - client.getSpeech().ifPresent(f -> phoneCallBuilder.setSpeech(convert(f))); - } - - private static PhoneCallSpeech convert(StartVerificationCalloutSpeechOptions client) { - PhoneCallSpeech.Builder dto = PhoneCallSpeech.builder(); - client.getLocale().ifPresent(dto::setLocale); - return dto.build(); - } - - public static IdentityInternal convert(Identity client) { - IdentityInternal.Builder dto = IdentityInternal.builder(); - if (client instanceof NumberIdentity) { - dto.setType(IdentityInternal.TypeEnum.NUMBER) - .setEndpoint(((NumberIdentity) client).getEndpoint()); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); - } - return dto.build(); - } - - public static Identity convert(IdentityInternal dto) { - Identity identity = null; - if (IdentityInternal.TypeEnum.NUMBER.equals(dto.getType())) { - identity = NumberIdentity.valueOf(dto.getEndpoint()); - } else { - LOGGER.severe(String.format("Unexpected '%s'", dto)); - } - return identity; - } - - public static VerificationMethod convert(VerificationMethodType client) { - return VerificationMethod.from(EnumDynamicConverter.convert(client)); - } - - public static StartVerificationResponse convert( - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponse dto) { - - StartVerificationResponse.Builder builder; - - if (dto - instanceof - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms) { - builder = - convert( - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseSms) - dto); - } else if (dto - instanceof - com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseFlashCall) { - builder = - convert( - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseFlashCall) - dto); - } else if (dto - instanceof - com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponsePhoneCall) { - builder = - convert( - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponsePhoneCall) - dto); - } else if (dto - instanceof - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData) { - builder = - convert( - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseData) - dto); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - builder = StartVerificationResponse.builder(); - } - return builder.build(); - } - - private static StartVerificationResponseSMS.Builder convert( - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms - _dto) { - - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSmsImpl - dto = - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseSmsImpl) - _dto; - StartVerificationResponseSMS.Builder builder = StartVerificationResponseSMS.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.links().ifPresent(f -> builder.setLinks(LinkDtoConverter.convert(f))); - - dto.sms() - .ifPresent( - _sms -> { - VerificationStartResponseSmsContentImpl sms = - (VerificationStartResponseSmsContentImpl) _sms; - sms.template().ifPresent(builder::setTemplate); - sms.interceptionTimeout().ifPresent(builder::setInterceptionTimeOut); - }); - - return builder; - } - - private static StartVerificationResponseFlashCall.Builder convert( - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseFlashCall - _dto) { - - com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseFlashCallImpl - dto = - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseFlashCallImpl) - _dto; - StartVerificationResponseFlashCall.Builder builder = - StartVerificationResponseFlashCall.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.links().ifPresent(f -> builder.setLinks(LinkDtoConverter.convert(f))); - - dto.flashCall() - .ifPresent( - _flashCall -> { - VerificationStartResponseFlashCallContentImpl flashCall = - (VerificationStartResponseFlashCallContentImpl) _flashCall; - flashCall.cliFilter().ifPresent(builder::setCliFilter); - flashCall.interceptionTimeout().ifPresent(builder::setInterceptionTimeOut); - flashCall.reportTimeout().ifPresent(builder::setReportTimeout); - flashCall.denyCallAfter().ifPresent(builder::setDenyCallAfter); - }); - return builder; - } - - private static StartVerificationResponseCallout.Builder convert( - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponsePhoneCall - _dto) { - - com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponsePhoneCallImpl - dto = - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponsePhoneCallImpl) - _dto; - StartVerificationResponseCallout.Builder builder = StartVerificationResponseCallout.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.links().ifPresent(f -> builder.setLinks(LinkDtoConverter.convert(f))); - - return builder; - } - - private static StartVerificationResponseSeamless.Builder convert( - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData - _dto) { - - com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseDataImpl - dto = - (com.sinch.sdk.domains.verification.models.v1.start.response - .VerificationStartResponseDataImpl) - _dto; - StartVerificationResponseSeamless.Builder builder = StartVerificationResponseSeamless.builder(); - - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.links().ifPresent(f -> builder.setLinks(LinkDtoConverter.convert(f))); - - dto.seamless() - .ifPresent( - _seamless -> { - VerificationStartResponseDataContentImpl seamless = - (VerificationStartResponseDataContentImpl) _seamless; - seamless.targetUri().ifPresent(builder::setTargetUri); - }); - return builder; - } - - public static VerificationReportRequestFlashCall convert( - VerificationReportFlashCallRequestParameters client) { - - VerificationReportRequestFlashCall.Builder builder = - VerificationReportRequestFlashCall.builder(); - - client.getCli().ifPresent(builder::setCli); - - return builder.build(); - } - - public static VerificationReportRequestSms convert( - VerificationReportSMSRequestParameters client) { - - VerificationReportRequestSms.Builder builder = VerificationReportRequestSms.builder(); - - client.getCode().ifPresent(builder::setCode); - client.getCli().ifPresent(builder::setCli); - - return builder.build(); - } - - public static VerificationReportRequestPhoneCall convert( - VerificationReportCalloutRequestParameters client) { - - VerificationReportRequestPhoneCall.Builder builder = - VerificationReportRequestPhoneCall.builder(); - - client.getCode().ifPresent(builder::setCode); - - return builder.build(); - } - - public static VerificationReport convert(VerificationReportResponse _dto) { - - VerificationReport.Builder builder; - if (_dto instanceof VerificationReportResponseSms) { - builder = VerificationReportSMS.builder(); - VerificationReportResponseSmsImpl dto = (VerificationReportResponseSmsImpl) _dto; - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status() - .ifPresent(f -> builder.setStatus(VerificationStatusType.from(dto.getStatus().value()))); - } else if (_dto instanceof VerificationReportResponseFlashCall) { - builder = VerificationReportFlashCall.builder(); - VerificationReportResponseFlashCallImpl dto = (VerificationReportResponseFlashCallImpl) _dto; - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status() - .ifPresent(f -> builder.setStatus(VerificationStatusType.from(dto.getStatus().value()))); - } else if (_dto instanceof VerificationReportResponsePhoneCall) { - builder = VerificationReportCallout.builder(); - VerificationReportResponsePhoneCallImpl dto = (VerificationReportResponsePhoneCallImpl) _dto; - dto.id().ifPresent(f -> builder.setId(VerificationId.valueOf(f))); - dto.status() - .ifPresent(f -> builder.setStatus(VerificationStatusType.from(dto.getStatus().value()))); - } else { - LOGGER.severe(String.format("Unexpected value '%s'", _dto)); - return VerificationReport.builder().build(); - } - - return builder.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/WebHooksDtoConverter.java b/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/WebHooksDtoConverter.java deleted file mode 100644 index c4628dfe8..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/adapters/converters/WebHooksDtoConverter.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.sinch.sdk.domains.verification.adapters.converters; - -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; -import com.sinch.sdk.domains.verification.models.VerificationSourceType; -import com.sinch.sdk.domains.verification.models.VerificationStatusReasonType; -import com.sinch.sdk.domains.verification.models.VerificationStatusType; -import com.sinch.sdk.domains.verification.models.v1.start.request.PhoneCallSpeech; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEventResponseAction; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventImpl; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponseSms; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationResultEventImpl; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationEvent; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationRequestEvent; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponse; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponseCallout; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponseCalloutSpeech; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponseFlashCall; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResponseSMS; -import com.sinch.sdk.domains.verification.models.webhooks.VerificationResultEvent; -import java.util.ArrayList; -import java.util.logging.Logger; - -public class WebHooksDtoConverter { - - private static final Logger LOGGER = Logger.getLogger(WebHooksDtoConverter.class.getName()); - - public static VerificationEvent convert( - com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent dto) { - - if (dto instanceof VerificationRequestEventImpl) { - return convert((VerificationRequestEventImpl) dto); - } else if (dto instanceof VerificationResultEventImpl) { - return convert((VerificationResultEventImpl) dto); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - return null; - } - } - - static VerificationRequestEvent convert(VerificationRequestEventImpl dto) { - - return new VerificationRequestEvent( - dto.getId(), - dto.method().isPresent() ? VerificationMethodType.from(dto.getMethod().value()) : null, - dto.identity().isPresent() ? IdentityDtoConverter.convert(dto.getIdentity()) : null, - dto.price().isPresent() ? PriceDtoConverter.convert(dto.getPrice()) : null, - dto.reference().isPresent() ? VerificationReference.valueOf(dto.getReference()) : null, - dto.getCustom(), - dto.getAcceptLanguage()); - } - - static VerificationResultEvent convert(VerificationResultEventImpl dto) { - - return new VerificationResultEvent( - dto.getId(), - dto.method().isPresent() ? VerificationMethodType.from(dto.getMethod().value()) : null, - dto.identity().isPresent() ? IdentityDtoConverter.convert(dto.getIdentity()) : null, - dto.reference().isPresent() ? VerificationReference.valueOf(dto.getReference()) : null, - dto.getCustom(), - dto.status().isPresent() ? VerificationStatusType.from(dto.getStatus().value()) : null, - dto.reason().isPresent() - ? VerificationStatusReasonType.from(dto.getReason().value()) - : null, - dto.source().isPresent() ? VerificationSourceType.from(dto.getSource().value()) : null); - } - - public static VerificationRequestEventResponse convert(VerificationResponse client) { - - if (null == client) { - return null; - } - if (client instanceof VerificationResponseCallout) { - return convert((VerificationResponseCallout) client); - } else if (client instanceof VerificationResponseFlashCall) { - return convert((VerificationResponseFlashCall) client); - } else if (client instanceof VerificationResponseSMS) { - return convert((VerificationResponseSMS) client); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", client)); - return null; - } - } - - static VerificationRequestEventResponsePhoneCall convert(VerificationResponseCallout client) { - VerificationRequestEventResponsePhoneCall.Builder dto = - VerificationRequestEventResponsePhoneCall.builder(); - - if (null != client.getAction()) { - dto.setAction(VerificationEventResponseAction.from(client.getAction().getValue())); - } - if (null != client.getCode()) { - dto.setCode(client.getCode()); - } - if (null != client.getSpeech()) { - dto.setSpeech(convert(client.getSpeech())); - } - return dto.build(); - } - - static PhoneCallSpeech convert(VerificationResponseCalloutSpeech client) { - if (null == client) { - return null; - } - return PhoneCallSpeech.builder().setLocale(client.getLocale()).build(); - } - - static VerificationRequestEventResponseFlashCall convert(VerificationResponseFlashCall client) { - VerificationRequestEventResponseFlashCall.Builder dto = - VerificationRequestEventResponseFlashCall.builder(); - - if (null != client.getAction()) { - dto.setAction(VerificationEventResponseAction.from(client.getAction().getValue())); - } - if (null != client.getCli()) { - dto.setCli(client.getCli()); - } - if (null != client.getDialTimeout()) { - dto.setDialTimeout(client.getDialTimeout()); - } - return dto.build(); - } - - static VerificationRequestEventResponseSms convert(VerificationResponseSMS client) { - VerificationRequestEventResponseSms.Builder dto = VerificationRequestEventResponseSms.builder(); - - if (null != client.getAction()) { - dto.setAction(VerificationEventResponseAction.from(client.getAction().getValue())); - } - if (null != client.getCode()) { - dto.setCode(client.getCode()); - } - if (null != client.getAcceptLanguage()) { - dto.setAcceptLanguage(new ArrayList<>(client.getAcceptLanguage())); - } - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.java new file mode 100644 index 000000000..5b0f829bd --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.java @@ -0,0 +1,63 @@ +package com.sinch.sdk.domains.verification.api.v1; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent; +import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse; +import java.util.Map; + +/** + * Sinch Events service + * + *

Callback events are used to authorize and manage your verification requests and return + * verification results. + * + *

See https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/#tag/Verification-callbacks/paths/VerificationRequestEvent/post + * + * @since 1.1 + */ +public interface SinchEventsService { + + /** + * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request + * and result events. All callback requests are signed using your Application key and secret pair + * found on your dashboard. The signature is included in the Authorization header of the request + * + *

By using following function, you can ensure authentication according to received payload + * from your backend + * + * @param method The HTTP method used ot handle the callback + * @param path The path to you backend endpoint used for callback + * @param headers Received headers + * @param jsonPayload Received payload + * @return Is authentication is validated (true) or not (false) + *

see https://developers.sinch.com/docs/verification/api-reference/authentication/callback-signed-request + * @since 1.1 + */ + boolean validateAuthenticationHeader( + String method, String path, Map headers, String jsonPayload); + + /** + * This function can be called to deserialize received payload onto callback onto proper java + * verification event class + * + * @param jsonPayload Received payload to be deserialized + * @return The verification event instance class + *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ + * @since 1.1 + */ + VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException; + + /** + * This function can be called to serialize a verification response to be sent as JSON + * + * @param response The response to be serialized + * @return The JSON string to be sent + *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ + * @since 1.1 + */ + String serializeResponse(VerificationStartEventResponse response) throws ApiMappingException; +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationReportService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationReportService.java deleted file mode 100644 index e82266886..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationReportService.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1; - -import com.sinch.sdk.domains.verification.models.v1.NumberIdentity; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestSms; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSms; - -/** - * Verification Report Service - * - *

Report about a verification request - * - * @see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verifications - * @since 1.1 - */ -public interface VerificationReportService { - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#SMS} & Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.v1.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponseSms reportSmsByIdentity( - NumberIdentity identity, VerificationReportRequestSms parameters); - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#FLASH_CALL} & Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.v1.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponseFlashCall reportFlashCallByIdentity( - NumberIdentity identity, VerificationReportRequestFlashCall parameters); - - /** - * Report a verification using {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#PHONE_CALL} & Identity - * - *

Report the received verification code to verify it, using the identity of the user - * - * @param identity Currently Only {@link - * com.sinch.sdk.domains.verification.models.v1.NumberIdentity NumberIdentity} is supported - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponsePhoneCall reportPhoneCallByIdentity( - NumberIdentity identity, VerificationReportRequestPhoneCall parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#SMS} Verification request - * - * @param id ID returned from start verification - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponseSms reportSmsById(String id, VerificationReportRequestSms parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#FLASH_CALL} Verification - * request - * - * @param id ID returned from start verification - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponseFlashCall reportFlashCallById( - String id, VerificationReportRequestFlashCall parameters); - - /** - * Report the received verification code to verify it, using the Verification ID of the {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#PHONE_CALL} Verification - * request - * - * @param id ID returned from start verification - * @param parameters Parameters to be used to get report - * @return Verification report response - * @since 1.1 - */ - VerificationReportResponsePhoneCall reportPhoneCallById( - String id, VerificationReportRequestPhoneCall parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationService.java index a09e7c397..5ab475d51 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationService.java @@ -17,7 +17,7 @@ public interface VerificationService { * href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verifications">Documentation * @since 1.1 */ - VerificationStartService verificationStart(); + VerificationsStartService verificationStart(); /** * Verifications Report Service instance @@ -27,7 +27,7 @@ public interface VerificationService { * href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verifications">Documentation * @since 1.1 */ - VerificationReportService verificationReport(); + VerificationsReportService verificationReport(); /** * Verifications Status Service instance @@ -37,15 +37,15 @@ public interface VerificationService { * href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-status">Documentation * @since 1.1 */ - VerificationStatusService verificationStatus(); + VerificationsStatusService verificationStatus(); /** - * Webhooks helpers instance + * Sinch Events helpers instance * * @return service instance for project * @see Documentation - * @since 1.1 + * @since 2.0 */ - WebHooksService webhooks(); + SinchEventsService sinchEvents(); } diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStartService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStartService.java deleted file mode 100644 index d26bc7e48..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStartService.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1; - -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms; - -/** - * Verification Start Service - * - *

Start new verification requests - * - *

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 a request. - * - * @see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verifications - * @since 1.1 - */ -public interface VerificationStartService { - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#SMS} - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.1 - */ - VerificationStartResponseSms startSms(VerificationStartRequestSms parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#FLASH_CALL} - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.1 - */ - VerificationStartResponseFlashCall startFlashCall(VerificationStartRequestFlashCall parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#PHONE_CALL} - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.1 - */ - VerificationStartResponsePhoneCall startPhoneCall(VerificationStartRequestPhoneCall parameters); - - /** - * Start verification by {@link - * com.sinch.sdk.domains.verification.models.v1.VerificationMethod#DATA} - * - * @param parameters Parameters to be used to start verification - * @return Verification response - * @since 1.1 - */ - VerificationStartResponseData startData(VerificationStartRequestData parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStatusService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStatusService.java deleted file mode 100644 index 3b5081d9a..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationStatusService.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1; - -import com.sinch.sdk.domains.verification.models.v1.NumberIdentity; -import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponse; - -/** - * 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.1 - */ -public interface VerificationStatusService { - - /** - * 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 Currently Only {@link - * com.sinch.sdk.domains.verification.models.v1.NumberIdentity} is supported - * @param method Method used for verification - * @return Verification status response - * @since 1.1 - */ - VerificationStatusResponse getByIdentity(NumberIdentity identity, VerificationMethod 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 status response - * @since 1.1 - */ - VerificationStatusResponse getById(String 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 status response - * @since 1.1 - */ - VerificationStatusResponse getByReference(String reference); -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/WebHooksService.java deleted file mode 100644 index 0fbe0cfc4..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/WebHooksService.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse; -import java.util.Map; - -/** - * Webhooks service - * - *

Callback events are used to authorize and manage your verification requests and return - * verification results. - * - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/#tag/Verification-callbacks/paths/VerificationRequestEvent/post - * - * @since 1.1 - */ -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed using your Application key and secret pair - * found on your dashboard. The signature is included in the Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param method The HTTP method used ot handle the callback - * @param path The path to you backend endpoint used for callback - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see https://developers.sinch.com/docs/verification/api-reference/authentication/callback-signed-request - * @since 1.1 - */ - boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback onto proper java - * verification event class - * - * @param jsonPayload Received payload to be deserialized - * @return The verification event instance class - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ - * @since 1.1 - */ - VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException; - - /** - * This function can be called to serialize a verification response to be sent as JSON - * - * @param response The response to be serialized - * @return The JSON string to be sent - *

see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/ - * @since 1.1 - */ - String serializeResponse(VerificationRequestEventResponse response) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/SinchEventsService.java new file mode 100644 index 000000000..acda8c3c3 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/SinchEventsService.java @@ -0,0 +1,71 @@ +package com.sinch.sdk.domains.verification.api.v1.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.MapUtils; +import com.sinch.sdk.core.utils.StringUtil; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent; +import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse; +import com.sinch.sdk.domains.verification.models.v1.sinchevents.internal.VerificationEventInternalImpl; +import java.util.Map; +import java.util.logging.Logger; + +public class SinchEventsService + implements com.sinch.sdk.domains.verification.api.v1.SinchEventsService { + + private static final Logger LOGGER = Logger.getLogger(SinchEventsService.class.getName()); + + private final Map authManagers; + + public SinchEventsService(Map authManagers) { + this.authManagers = authManagers; + } + + @Override + public boolean validateAuthenticationHeader( + String method, String path, Map headers, String jsonPayload) { + + // convert header keys to use case-insensitive map keys + String authorizationHeader = MapUtils.getCaseInsensitiveMap(headers).get("Authorization"); + + // no authorization required + if (StringUtil.isEmpty(authorizationHeader)) { + return false; + } + + String[] split = authorizationHeader.split(" "); + String authorizationKeyword = split.length > 0 ? split[0] : ""; + + AuthManager authManager = authManagers.get(authorizationKeyword); + if (null == authManager) { + // unknown auth manager + LOGGER.severe( + String.format("Auth manager for authorization '%s' not found", authorizationKeyword)); + return false; + } + return authManager.validateAuthenticatedRequest(method, path, headers, jsonPayload); + } + + @Override + public VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException { + try { + VerificationEventInternalImpl dto = + Mapper.getInstance().readValue(jsonPayload, VerificationEventInternalImpl.class); + return (VerificationSinchEvent) dto.getActualInstance(); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } + + @Override + public String serializeResponse(VerificationStartEventResponse response) + throws ApiMappingException { + try { + return Mapper.getInstance().writeValueAsString(response); + } catch (JsonProcessingException e) { + throw new ApiMappingException(response.toString(), e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationReportService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationReportService.java deleted file mode 100644 index 64c2175c0..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationReportService.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1.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.api.v1.internal.VerificationsReportApi; -import com.sinch.sdk.domains.verification.models.v1.NumberIdentity; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequest; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.request.VerificationReportRequestSms; -import com.sinch.sdk.domains.verification.models.v1.report.request.internal.VerificationReportRequestInternalImpl; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponse; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseSms; -import com.sinch.sdk.domains.verification.models.v1.report.response.internal.VerificationReportResponseInternalImpl; -import com.sinch.sdk.models.VerificationContext; -import java.util.Map; - -public class VerificationReportService - implements com.sinch.sdk.domains.verification.api.v1.VerificationReportService { - - private final VerificationsReportApi api; - - public VerificationReportService( - VerificationContext context, HttpClient httpClient, Map authManagers) { - this.api = - new VerificationsReportApi( - httpClient, context.getVerificationServer(), authManagers, HttpMapper.getInstance()); - } - - protected VerificationsReportApi getApi() { - return this.api; - } - - public VerificationReportResponseSms reportSmsByIdentity( - NumberIdentity identity, VerificationReportRequestSms parameters) { - - return (VerificationReportResponseSms) reportByIdentity(identity, parameters); - } - - public VerificationReportResponseFlashCall reportFlashCallByIdentity( - NumberIdentity identity, VerificationReportRequestFlashCall parameters) { - - return (VerificationReportResponseFlashCall) reportByIdentity(identity, parameters); - } - - public VerificationReportResponsePhoneCall reportPhoneCallByIdentity( - NumberIdentity identity, VerificationReportRequestPhoneCall parameters) { - - return (VerificationReportResponsePhoneCall) reportByIdentity(identity, parameters); - } - - public VerificationReportResponseSms reportSmsById( - String id, VerificationReportRequestSms parameters) { - - return (VerificationReportResponseSms) reportById(id, parameters); - } - - public VerificationReportResponseFlashCall reportFlashCallById( - String id, VerificationReportRequestFlashCall parameters) { - - return (VerificationReportResponseFlashCall) reportById(id, parameters); - } - - public VerificationReportResponsePhoneCall reportPhoneCallById( - String id, VerificationReportRequestPhoneCall parameters) { - - return (VerificationReportResponsePhoneCall) reportById(id, parameters); - } - - private VerificationReportResponse reportByIdentity( - NumberIdentity identity, VerificationReportRequest parameters) { - VerificationReportRequestInternalImpl internal = new VerificationReportRequestInternalImpl(); - internal.setActualInstance(parameters); - VerificationReportResponseInternalImpl response = - (VerificationReportResponseInternalImpl) - getApi().reportVerificationByIdentity(identity.getEndpoint(), internal); - return (VerificationReportResponse) response.getActualInstance(); - } - - private VerificationReportResponse reportById(String id, VerificationReportRequest parameters) { - VerificationReportRequestInternalImpl internal = new VerificationReportRequestInternalImpl(); - internal.setActualInstance(parameters); - VerificationReportResponseInternalImpl response = - (VerificationReportResponseInternalImpl) getApi().reportVerificationById(id, internal); - return (VerificationReportResponse) response.getActualInstance(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationService.java index 0de1679c8..e189f365a 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationService.java @@ -4,8 +4,15 @@ import com.sinch.sdk.auth.adapters.BasicAuthManager; 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.utils.StringUtil; import com.sinch.sdk.domains.verification.adapters.IdentityMapper; +import com.sinch.sdk.domains.verification.api.v1.VerificationsReportService; +import com.sinch.sdk.domains.verification.api.v1.VerificationsStartService; +import com.sinch.sdk.domains.verification.api.v1.VerificationsStatusService; +import com.sinch.sdk.domains.verification.models.v1.report.response.VerificationReportResponseMapper; +import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseMapper; +import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponseMapper; import com.sinch.sdk.models.ApplicationCredentials; import com.sinch.sdk.models.VerificationContext; import java.util.Map; @@ -28,13 +35,13 @@ public class VerificationService private final VerificationContext context; private final Supplier httpClientSupplier; - private volatile VerificationStartService startService; - private volatile VerificationReportService reportService; - private volatile VerificationStatusService statusService; - private volatile WebHooksService webhooks; + private volatile VerificationsStartService startService; + private volatile VerificationsReportService reportService; + private volatile VerificationsStatusService statusService; + private volatile SinchEventsService sinchEvents; private volatile Map clientAuthManagers; - private volatile Map webhooksAuthManagers; + private volatile Map sinchEventsAuthManagers; static { LocalLazyInit.init(); @@ -59,65 +66,96 @@ private void createAuthManagers(ApplicationCredentials credentials) { credentials.getApplicationKey(), credentials.getApplicationSecret()); boolean useApplicationAuth = true; - // to handle request from client we can only have "Basic" keyword behind the auth managers + // To handle request from client we can only have "Basic" keyword behind the auth managers // because of the OAS file only contains it; so we need to trick the application auth manager // hidden behind the "Basic" keyword - // we need both auth manager to handle webhooks because of customer will choose from his + // We need both auth manager to handle Sinch Events because of customer will choose from his // dashboard which scheme to be used - clientAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - clientAuthManagers.put( + Map localClientAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + localClientAuthManagers.put( BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, useApplicationAuth ? applicationAuthManager : basicAuthManager); - - // here we need both auth managers to handle webhooks because we are receiving an Authorization - // header with "Application" keyword - webhooksAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - webhooksAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, basicAuthManager); - webhooksAuthManagers.put( + clientAuthManagers = localClientAuthManagers; + + // here we need both auth managers to handle Sinch Events because we are receiving an + // Authorization header with "Application" keyword + Map localSinchEventsAuthManagers = + new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + localSinchEventsAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, basicAuthManager); + localSinchEventsAuthManagers.put( APPLICATION_SECURITY_SCHEME_KEYWORD_VERIFICATION, applicationAuthManager); + sinchEventsAuthManagers = localSinchEventsAuthManagers; } - public VerificationStartService verificationStart() { + public VerificationsStartService verificationStart() { if (null == this.startService) { - instanceLazyInit(); - this.startService = - new VerificationStartService(context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.startService) { + instanceLazyInit(); + this.startService = + new VerificationsStartServiceImpl( + httpClientSupplier.get(), + context.getVerificationServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.startService; } - public VerificationReportService verificationReport() { + public VerificationsReportService verificationReport() { if (null == this.reportService) { - instanceLazyInit(); - this.reportService = - new VerificationReportService(context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.reportService) { + instanceLazyInit(); + this.reportService = + new VerificationsReportServiceImpl( + httpClientSupplier.get(), + context.getVerificationServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.reportService; } - public VerificationStatusService verificationStatus() { + public VerificationsStatusService verificationStatus() { if (null == this.statusService) { - instanceLazyInit(); - this.statusService = - new VerificationStatusService(context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.statusService) { + instanceLazyInit(); + this.statusService = + new VerificationsStatusServiceImpl( + httpClientSupplier.get(), + context.getVerificationServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.statusService; } - public WebHooksService webhooks() { - if (null == this.webhooks) { - instanceLazyInit(); - this.webhooks = new WebHooksService(webhooksAuthManagers); + public SinchEventsService sinchEvents() { + if (null == this.sinchEvents) { + synchronized (this) { + if (null == this.sinchEvents) { + instanceLazyInit(); + this.sinchEvents = new SinchEventsService(sinchEventsAuthManagers); + } + } } - return this.webhooks; + return this.sinchEvents; } private void instanceLazyInit() { - if (null != this.clientAuthManagers && null != this.webhooksAuthManagers) { + if (null != this.clientAuthManagers && null != this.sinchEventsAuthManagers) { return; } synchronized (this) { - if (null == this.clientAuthManagers || null == this.webhooksAuthManagers) { + if (null == this.clientAuthManagers || null == this.sinchEventsAuthManagers) { // Currently, we are not supporting unified credentials: ensure application credentials are // defined @@ -147,6 +185,9 @@ static final class LocalLazyInit { private LocalLazyInit() { IdentityMapper.initMapper(); + VerificationStartResponseMapper.initMapper(); + VerificationStatusResponseMapper.initMapper(); + VerificationReportResponseMapper.initMapper(); } public static LocalLazyInit init() { diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStartService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStartService.java deleted file mode 100644 index 328099cc1..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStartService.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1.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.api.v1.internal.VerificationsStartApi; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequest; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestData; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestPhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.request.VerificationStartRequestSms; -import com.sinch.sdk.domains.verification.models.v1.start.request.internal.VerificationStartRequestInternalImpl; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponse; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseData; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseFlashCall; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponsePhoneCall; -import com.sinch.sdk.domains.verification.models.v1.start.response.VerificationStartResponseSms; -import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseInternalImpl; -import com.sinch.sdk.models.VerificationContext; -import java.util.Map; -import java.util.Optional; - -public class VerificationStartService - implements com.sinch.sdk.domains.verification.api.v1.VerificationStartService { - - private final VerificationsStartApi api; - - public VerificationStartService( - VerificationContext context, HttpClient httpClient, Map authManagers) { - this.api = - new VerificationsStartApi( - httpClient, context.getVerificationServer(), authManagers, HttpMapper.getInstance()); - } - - protected VerificationsStartApi getApi() { - return this.api; - } - - public VerificationStartResponseSms startSms(VerificationStartRequestSms parameters) { - String acceptLanguage = parameters.getAcceptLanguage(); - return (VerificationStartResponseSms) start(parameters, acceptLanguage).orElse(null); - } - - public VerificationStartResponseFlashCall startFlashCall( - VerificationStartRequestFlashCall parameters) { - return (VerificationStartResponseFlashCall) start(parameters).orElse(null); - } - - public VerificationStartResponsePhoneCall startPhoneCall( - VerificationStartRequestPhoneCall parameters) { - return (VerificationStartResponsePhoneCall) start(parameters).orElse(null); - } - - public VerificationStartResponseData startData(VerificationStartRequestData parameters) { - return (VerificationStartResponseData) start(parameters).orElse(null); - } - - private Optional start(VerificationStartRequest parameters) { - return start(parameters, null); - } - - private Optional start( - VerificationStartRequest parameters, String acceptLanguage) { - VerificationStartRequestInternalImpl impl = new VerificationStartRequestInternalImpl(); - impl.setActualInstance(parameters); - VerificationStartResponseInternalImpl response = - (VerificationStartResponseInternalImpl) getApi().startVerification(impl, acceptLanguage); - if (null == response) { - return Optional.empty(); - } - return Optional.ofNullable((VerificationStartResponse) response.getActualInstance()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStatusService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStatusService.java deleted file mode 100644 index 8a2c63a78..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationStatusService.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1.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.api.v1.internal.VerificationStatusApi; -import com.sinch.sdk.domains.verification.models.v1.NumberIdentity; -import com.sinch.sdk.domains.verification.models.v1.VerificationMethod; -import com.sinch.sdk.domains.verification.models.v1.status.response.VerificationStatusResponse; -import com.sinch.sdk.domains.verification.models.v1.status.response.internal.VerificationStatusResponseInternalImpl; -import com.sinch.sdk.models.VerificationContext; -import java.util.Map; - -public class VerificationStatusService - implements com.sinch.sdk.domains.verification.api.v1.VerificationStatusService { - - private final VerificationStatusApi api; - - public VerificationStatusService( - VerificationContext context, HttpClient httpClient, Map authManagers) { - this.api = - new VerificationStatusApi( - httpClient, context.getVerificationServer(), authManagers, HttpMapper.getInstance()); - } - - protected VerificationStatusApi getApi() { - return this.api; - } - - public VerificationStatusResponse getByIdentity( - NumberIdentity identity, VerificationMethod method) { - - VerificationStatusResponseInternalImpl response = - (VerificationStatusResponseInternalImpl) - getApi().verificationStatusByIdentity(identity.getEndpoint(), method.value()); - if (null == response) { - return null; - } - return (VerificationStatusResponse) response.getActualInstance(); - } - - public VerificationStatusResponse getById(String id) { - - VerificationStatusResponseInternalImpl response = - (VerificationStatusResponseInternalImpl) getApi().verificationStatusById(id); - if (null == response) { - return null; - } - return (VerificationStatusResponse) response.getActualInstance(); - } - - public VerificationStatusResponse getByReference(String reference) { - - VerificationStatusResponseInternalImpl response = - (VerificationStatusResponseInternalImpl) getApi().verificationStatusByReference(reference); - if (null == response) { - return null; - } - return (VerificationStatusResponse) response.getActualInstance(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/WebHooksService.java deleted file mode 100644 index 980d5596e..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/WebHooksService.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.sinch.sdk.domains.verification.api.v1.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.utils.MapUtils; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent; -import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse; -import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationEventInternalImpl; -import java.util.Map; -import java.util.logging.Logger; - -public class WebHooksService implements com.sinch.sdk.domains.verification.api.v1.WebHooksService { - - private static final Logger LOGGER = Logger.getLogger(WebHooksService.class.getName()); - - private final Map authManagers; - - public WebHooksService(Map authManagers) { - this.authManagers = authManagers; - } - - @Override - public boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload) { - - // convert header keys to use case-insensitive map keys - String authorizationHeader = MapUtils.getCaseInsensitiveMap(headers).get("Authorization"); - - // no authorization required - if (StringUtil.isEmpty(authorizationHeader)) { - return false; - } - - String[] split = authorizationHeader.split(" "); - String authorizationKeyword = split.length > 0 ? split[0] : ""; - - AuthManager authManager = authManagers.get(authorizationKeyword); - if (null == authManager) { - // unknown auth manager - LOGGER.severe( - String.format("Auth manager for authorization '%s' not found", authorizationKeyword)); - return false; - } - return authManager.validateAuthenticatedRequest(method, path, headers, jsonPayload); - } - - @Override - public VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException { - try { - VerificationEventInternalImpl dto = - Mapper.getInstance().readValue(jsonPayload, VerificationEventInternalImpl.class); - return (VerificationEvent) dto.getActualInstance(); - } catch (JsonProcessingException e) { - throw new ApiMappingException(jsonPayload, e); - } - } - - @Override - public String serializeResponse(VerificationRequestEventResponse response) - throws ApiMappingException { - try { - return Mapper.getInstance().writeValueAsString(response); - } catch (JsonProcessingException e) { - throw new ApiMappingException(response.toString(), e); - } - } -} 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 deleted file mode 100644 index 9363ad662..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/Identity.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** Base class for Identity objects */ -public abstract class Identity { - - private final String type; - - /** - * Create an instance of identity with type - * - * @param type Identity type - */ - protected Identity(String type) { - this.type = type; - } - - @Override - public String toString() { - return "Identity{" + "type='" + type + '\'' + '}'; - } -} 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 deleted file mode 100644 index 1f717c9c2..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/Link.java +++ /dev/null @@ -1,127 +0,0 @@ -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 - * - * @since 1.0 - */ -public class Link { - private final LinkRelType rel; - private final String href; - private final HttpMethod method; - - private Link(LinkRelType rel, String href, HttpMethod method) { - this.rel = rel; - this.href = href; - this.method = method; - } - - /** - * The related action that can be performed on the initiated Verification - * - * @return Related type - * @since 1.0 - */ - public LinkRelType getRel() { - return rel; - } - - /** - * The complete URL to perform the specified action, localized to the DataCenter which handled the - * original Verification request - * - * @return URL value - * @since 1.0 - */ - public String getHref() { - return href; - } - - /** - * The HTTP method to use when performing the action using the linked localized URL - * - * @return HTTP method - * @since 1.0 - */ - public HttpMethod getMethod() { - return method; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "Link{" + "rel='" + rel + '\'' + ", href='" + href + '\'' + ", method=" + method + '}'; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder { - - LinkRelType rel; - String href; - HttpMethod method; - - private Builder() {} - - /** - * Setter - * - * @param rel See {@link #getRel()} getter - * @return Current builder - * @since 1.0 - */ - public Builder setRel(LinkRelType rel) { - this.rel = rel; - return this; - } - - /** - * Setter - * - * @param href See {@link #getHref()} getter - * @return Current builder - * @since 1.0 - */ - public Builder setHref(String href) { - this.href = href; - return this; - } - - /** - * Setter - * - * @param method See {@link #getMethod()} getter - * @return Current builder - * @since 1.0 - */ - public Builder setMethod(HttpMethod method) { - this.method = method; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 867737101..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/LinkRelType.java +++ /dev/null @@ -1,56 +0,0 @@ -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); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static LinkRelType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum 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 deleted file mode 100644 index e3cf83e2d..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/NumberIdentity.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -import com.sinch.sdk.models.E164PhoneNumber; -import java.util.Objects; - -/** Identity based onto a phone number */ -public class NumberIdentity extends Identity { - - private final String endpoint; - - /** - * Get related endpoint - * - *

See {@link Builder#setEndpoint(String)} setter - * - * @return Phone number value - */ - public String getEndpoint() { - return endpoint; - } - - /** - * @param endpoint An E.164-compatible phone number. - */ - private NumberIdentity(String endpoint) { - super("number"); - this.endpoint = endpoint; - } - - @Override - public String toString() { - return "NumberIdentity{" + "endpoint='" + endpoint + '\'' + "} " + super.toString(); - } - - /** - * Create a NumberIdentity from a phone number as a String - * - * @param phoneNumber String representation of phone number - * @return Instance of NumberIdentity - * @since 1.0 - */ - public static NumberIdentity valueOf(String phoneNumber) { - return builder().setEndpoint(phoneNumber).build(); - } - - /** - * Create a NumberIdentity from a phone number as a E164PhoneNumber - * - * @param phoneNumber E164PhoneNumber representation of phone number - * @return Instance of NumberIdentity - * @since 1.0 - */ - public static NumberIdentity valueOf(E164PhoneNumber phoneNumber) { - return builder().setEndpoint(phoneNumber.stringValue()).build(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof NumberIdentity)) { - return false; - } - NumberIdentity that = (NumberIdentity) o; - return Objects.equals(getEndpoint(), that.getEndpoint()); - } - - @Override - public int hashCode() { - return Objects.hash(getEndpoint()); - } - - /** - * Getting Builder - * - * @return New Builder instance - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder { - - String endpoint; - - private Builder() {} - - /** - * Endpoint to be used for number identity (the phone number) - * - * @param endpoint Phone number value - * @return Current builder - */ - public Builder setEndpoint(String endpoint) { - this.endpoint = endpoint; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - */ - public NumberIdentity build() { - return new NumberIdentity(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 deleted file mode 100644 index 6e7f163ec..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/Price.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** Price object representation */ -public class Price { - private final String currencyId; - private final Float amount; - - private Price(String currencyId, Float amount) { - this.currencyId = currencyId; - this.amount = amount; - } - - /** - * ISO 4217 currency code - * - * @return Currency value - * @since 1.0 - */ - public String getCurrencyId() { - return currencyId; - } - - /** - * Amount value - * - * @return The amount - * @since 1.0 - */ - public Float getAmount() { - return amount; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "Price{" + "currencyId='" + currencyId + '\'' + ", amount=" + amount + '}'; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder { - - String currencyId; - Float amount; - - private Builder() {} - - /** - * Setter - * - * @param currencyId See {@link Price#getCurrencyId()} getter - * @return Current builder - * @since 1.0 - */ - public Builder setCurrencyId(String currencyId) { - this.currencyId = currencyId; - return this; - } - - /** - * Setter - * - * @param amount See {@link Price#getAmount()} getter - * @return Current builder - * @since 1.0 - */ - public Builder setAmount(Float amount) { - this.amount = amount; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 3353281f9..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationId.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** Verification ID related to a Verification request */ -public class VerificationId { - - private final String id; - - private VerificationId(String id) { - this.id = id; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationId{" + "id='" + id + '\'' + '}'; - } - - /** - * Get the verification Id value - * - * @return Id Value - * @since 1.0 - */ - public String getId() { - return id; - } - - /** - * Create a new verification id from a String - * - * @param id The id value - * @return The newly created VerificationId instance - * @since 1.0 - */ - public static VerificationId valueOf(String id) { - return new VerificationId(id); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java deleted file mode 100644 index 38e9bf5a8..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationMethodType.java +++ /dev/null @@ -1,75 +0,0 @@ -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 VerificationMethodType extends EnumDynamic { - - /** Verification by SMS message with a PIN code */ - 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 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 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 VerificationMethodType SEAMLESS = new VerificationMethodType("seamless"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - VerificationMethodType.class, - VerificationMethodType::new, - Arrays.asList(SMS, FLASH_CALL, CALLOUT, SEAMLESS)); - - private VerificationMethodType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static VerificationMethodType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - 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 deleted file mode 100644 index c8dbc7367..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReference.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** Verification reference related to a Verification request */ -public class VerificationReference { - - private final String reference; - - private VerificationReference(String reference) { - this.reference = reference; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationReference{" + "reference='" + reference + '\'' + '}'; - } - - /** - * Get the verification reference value - * - * @return reference Value - * @since 1.0 - */ - public String getReference() { - return reference; - } - - /** - * Create a new verification reference from a String - * - * @param reference The id value - * @return The newly created VerificationReference instance - * @since 1.0 - */ - 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 deleted file mode 100644 index 7a8c04671..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReport.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** - * Common class to all verification report responses - * - * @since 1.1 - */ -public class VerificationReport { - - private final VerificationId id; - private final VerificationStatusType status; - - protected VerificationReport(VerificationId id, VerificationStatusType status) { - this.id = id; - this.status = status; - } - - /** - * ID related to verification request - * - * @return Verification ID - * @since 1.1 - */ - public VerificationId getId() { - return id; - } - - /** - * Current verification status - * - * @return The status value - * @since 1.1 - */ - public VerificationStatusType getStatus() { - return status; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationReport{" + "id=" + id + ", status=" + status + '}'; - } - - public static Builder builder() { - return new Builder<>(); - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.1 - */ - public static class Builder> { - - VerificationId id; - VerificationStatusType status; - - protected Builder() {} - - /** - * Setter - * - *

See {@link VerificationReport#getId()} getter - * - * @param id See getter - * @return Current builder - * @since 1.1 - */ - public B setId(VerificationId id) { - this.id = id; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationReport#getStatus()} getter - * - * @param status See getter - * @return Current builder - * @since 1.1 - */ - public B setStatus(VerificationStatusType status) { - this.status = status; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public VerificationReport build() { - return new VerificationReport(id, status); - } - - @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 deleted file mode 100644 index 87c24f401..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportCallout.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** - * Dedicated report type for a callout verification - * - *

Verification report when using {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportCalloutById} or {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportCalloutByIdentity} - * - * @since 1.1 - */ -public class VerificationReportCallout extends VerificationReport { - - protected VerificationReportCallout(VerificationId id, VerificationStatusType status) { - super(id, status); - } - - @Override - public String toString() { - return "VerificationReportCallout{} " + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationReport.Builder { - - private Builder() {} - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public VerificationReportCallout build() { - return new VerificationReportCallout(id, status); - } - - @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 deleted file mode 100644 index 1a00bf565..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportFlashCall.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** - * Dedicated report type for a flashcall verification - * - *

Verification report when using {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportFlashCallById} or {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportFlashCallByIdentity} - * - * @since 1.1 - */ -public class VerificationReportFlashCall extends VerificationReport { - - protected VerificationReportFlashCall(VerificationId id, VerificationStatusType status) { - super(id, status); - } - - @Override - public String toString() { - return "VerificationReportFlashCall{} " + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationReport.Builder { - - private Builder() {} - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public VerificationReportFlashCall build() { - return new VerificationReportFlashCall(id, status); - } - - @Override - protected Builder self() { - return this; - } - } -} 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 deleted file mode 100644 index 5a45f3026..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationReportSMS.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -/** - * Dedicated report type for a SMS verification - * - *

Verification report when using {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportSmsById} or {@link - * com.sinch.sdk.domains.verification.VerificationsService#reportSmsByIdentity} - * - * @since 1.1 - */ -public class VerificationReportSMS extends VerificationReport { - - protected VerificationReportSMS(VerificationId id, VerificationStatusType status) { - super(id, status); - } - - @Override - public String toString() { - return "VerificationReportSMS{} " + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationReport.Builder { - - private Builder() {} - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public VerificationReportSMS build() { - return new VerificationReportSMS(id, status); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationSourceType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationSourceType.java deleted file mode 100644 index b30aeb28f..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationSourceType.java +++ /dev/null @@ -1,61 +0,0 @@ -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.1 - */ -public class VerificationSourceType extends EnumDynamic { - - /** Show if the call/SMS was intercepted or not. */ - public static final VerificationSourceType INTERCEPTED = - new VerificationSourceType("intercepted"); - - /** Show if the call/SMS was intercepted or not. */ - public static final VerificationSourceType MANUAL = new VerificationSourceType("manual"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - VerificationSourceType.class, - VerificationSourceType::new, - Arrays.asList(INTERCEPTED, MANUAL)); - - private VerificationSourceType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static VerificationSourceType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(VerificationSourceType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatus.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatus.java deleted file mode 100644 index 4fddf8e53..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatus.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -import java.time.Instant; - -/** - * Common class to all verification status responses - * - * @since 1.0 - */ -public class VerificationStatus { - - private final VerificationId id; - private final VerificationStatusType status; - private final VerificationStatusReasonType reason; - private final VerificationReference reference; - private final Identity identity; - private final String countryId; - private final Instant verificationTimeStamp; - - protected VerificationStatus( - VerificationId id, - VerificationStatusType status, - VerificationStatusReasonType reason, - VerificationReference reference, - Identity identity, - String countryId, - Instant verificationTimeStamp) { - this.id = id; - this.status = status; - this.reason = reason; - this.reference = reference; - this.identity = identity; - this.countryId = countryId; - this.verificationTimeStamp = verificationTimeStamp; - } - - /** - * ID related to verification request - * - * @return Verification ID - * @since 1.0 - */ - public VerificationId getId() { - return id; - } - - /** - * Current verification status - * - * @return The status value - * @since 1.0 - */ - public VerificationStatusType getStatus() { - return status; - } - - /** - * The reason why a verification has {@link VerificationStatusType#FAIL FAIL}, was {@link - * VerificationStatusType#DENIED DENIED}, or was {@link VerificationStatusType#ABORTED ABORTED}. - * - * @return The reason value - * @since 1.0 - */ - public VerificationStatusReasonType getReason() { - return reason; - } - - /** - * The reference value that was optionally passed together with the verification request. - * - * @return The reference value - * @since 1.0 - */ - public VerificationReference getReference() { - return reference; - } - - /** - * @see Identity - * @return The identity - * @since 1.1 - */ - public Identity getIdentity() { - return identity; - } - - /** - * The ID of the country to which the verification was sent - * - * @return Country ID value - * @since 1.1 - */ - public String getCountryId() { - return countryId; - } - - /** - * Verification time stamp - * - * @return Verification timestamp value - * @since 1.1 - */ - public Instant getVerificationTimeStamp() { - return verificationTimeStamp; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationStatus{" - + "id=" - + id - + ", status=" - + status - + ", reason=" - + reason - + ", reference=" - + reference - + ", identity=" - + identity - + ", countryId='" - + countryId - + '\'' - + ", verificationTimeStamp=" - + verificationTimeStamp - + '}'; - } - - public static Builder builder() { - return new Builder<>(); - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.0 - */ - public static class Builder> { - - VerificationId id; - VerificationStatusType status; - VerificationStatusReasonType reason; - VerificationReference reference; - Identity identity; - String countryId; - Instant verificationTimeStamp; - - protected Builder() {} - - /** - * Setter - * - *

See {@link VerificationStatus#getId()} getter - * - * @param id See getter - * @return Current builder - * @since 1.0 - */ - public B setId(VerificationId id) { - this.id = id; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getStatus()} getter - * - * @param status See getter - * @return Current builder - * @since 1.0 - */ - public B setStatus(VerificationStatusType status) { - this.status = status; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getReason()} getter - * - * @param reason See getter - * @return Current builder - * @since 1.0 - */ - public B setReason(VerificationStatusReasonType reason) { - this.reason = reason; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getReference()} getter - * - * @param reference See getter - * @return Current builder - * @since 1.0 - */ - public B setReference(VerificationReference reference) { - this.reference = reference; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getIdentity()} ()} getter - * - * @param identity See getter - * @return Current builder - * @since 1.1 - */ - public B setIdentity(Identity identity) { - this.identity = identity; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getCountryId()} ()} getter - * - * @param countryId See getter - * @return Current builder - * @since 1.1 - */ - public B setCountryId(String countryId) { - this.countryId = countryId; - return self(); - } - - /** - * Setter - * - *

See {@link VerificationStatus#getVerificationTimeStamp()} ()} ()} getter - * - * @param verificationTimeStamp See getter - * @return Current builder - * @since 1.1 - */ - public B setVerificationTimeStamp(Instant verificationTimeStamp) { - this.verificationTimeStamp = verificationTimeStamp; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationStatus build() { - return new VerificationStatus( - id, status, reason, reference, identity, countryId, verificationTimeStamp); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusCallout.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusCallout.java deleted file mode 100644 index 01f29ac84..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusCallout.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -import java.time.Instant; - -/** - * Verification report related to a {@link - * com.sinch.sdk.domains.verification.VerificationsService#startCallout} - * - * @since 1.0 - */ -public class VerificationStatusCallout extends VerificationStatus { - - private final Price verificationPrice; - private final Price terminationPrice; - private final Integer billableDuration; - private final Boolean callComplete; - - private VerificationStatusCallout( - VerificationId id, - VerificationStatusType status, - VerificationStatusReasonType reason, - VerificationReference reference, - Identity identity, - String countryId, - Instant verificationTimeStamp, - Price verificationPrice, - Price terminationPrice, - Integer billableDuration, - Boolean callComplete) { - super(id, status, reason, reference, identity, countryId, verificationTimeStamp); - this.verificationPrice = verificationPrice; - this.terminationPrice = terminationPrice; - this.billableDuration = billableDuration; - this.callComplete = callComplete; - } - - /** - * 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 {@link VerificationStatusType#PENDING PENDING} - * - * @return Verification price object - * @since 1.0 - */ - public Price getVerificationPrice() { - return verificationPrice; - } - - /** - * 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. - * - * @return The termination price object - * @since 1.0 - */ - public Price getTerminationPrice() { - return terminationPrice; - } - - /** - * 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. - * - * @return The billable price object - * @since 1.0 - */ - public Integer getBillableDuration() { - return billableDuration; - } - - /** - * Shows whether the call is complete or not. - * - * @return TRUE.FALSE - * @since 1.0 - */ - public Boolean getCallComplete() { - return callComplete; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationStatusCallout{" - + "verificationPrice=" - + verificationPrice - + ", terminationPrice=" - + terminationPrice - + ", billableDuration=" - + billableDuration - + ", callComplete=" - + callComplete - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationStatus.Builder { - - Price verificationPrice; - Price terminationPrice; - Integer billableDuration; - Boolean callComplete; - - private Builder() {} - - /** - * See {@link VerificationStatusCallout#getVerificationPrice()} getter - * - * @param verificationPrice See getter - * @return Current builder - * @since 1.0 - */ - public Builder setVerificationPrice(Price verificationPrice) { - this.verificationPrice = verificationPrice; - return this; - } - - /** - * See {@link VerificationStatusCallout#getTerminationPrice()} getter - * - * @param terminationPrice See getter - * @return Current builder - * @since 1.0 - */ - public Builder setTerminationPrice(Price terminationPrice) { - this.terminationPrice = terminationPrice; - return this; - } - - /** - * See {@link VerificationStatusCallout#getBillableDuration()} getter - * - * @param billableDuration See getter - * @return Current builder - * @since 1.0 - */ - public Builder setBillableDuration(Integer billableDuration) { - this.billableDuration = billableDuration; - return this; - } - - /** - * See {@link VerificationStatusCallout#getCallComplete()} getter - * - * @param callComplete See getter - * @return Current builder - * @since 1.0 - */ - public Builder setCallComplete(Boolean callComplete) { - this.callComplete = callComplete; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationStatusCallout build() { - return new VerificationStatusCallout( - id, - status, - reason, - reference, - identity, - countryId, - verificationTimeStamp, - verificationPrice, - terminationPrice, - billableDuration, - callComplete); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusFlashCall.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusFlashCall.java deleted file mode 100644 index b8f0efb54..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusFlashCall.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -import java.time.Instant; - -/** - * Verification report related to a {@link - * com.sinch.sdk.domains.verification.VerificationsService#startFlashCall} - * - * @since 1.0 - */ -public class VerificationStatusFlashCall extends VerificationStatus { - - private final Price verificationPrice; - private final Price terminationPrice; - private final Integer billableDuration; - private final VerificationSourceType source; - - private VerificationStatusFlashCall( - VerificationId id, - VerificationStatusType status, - VerificationStatusReasonType reason, - VerificationReference reference, - Identity identity, - String countryId, - Instant verificationTimeStamp, - Price verificationPrice, - Price terminationPrice, - Integer billableDuration, - VerificationSourceType source) { - super(id, status, reason, reference, identity, countryId, verificationTimeStamp); - this.verificationPrice = verificationPrice; - this.terminationPrice = terminationPrice; - this.billableDuration = billableDuration; - this.source = source; - } - - /** - * 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 {@link VerificationStatusType#PENDING PENDING} - * - * @return Verification price object - * @since 1.0 - */ - public Price getVerificationPrice() { - return verificationPrice; - } - - /** - * 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. - * - * @return The termination price object - * @since 1.0 - */ - public Price getTerminationPrice() { - return terminationPrice; - } - - /** - * 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. - * - * @return The billable price object - * @since 1.0 - */ - public Integer getBillableDuration() { - return billableDuration; - } - - /** - * Free text that the client is sending, used to show if the call/SMS was intercepted or not. - * - * @return source value - */ - public VerificationSourceType getSource() { - return source; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationStatusFlashCall{" - + "verificationPrice=" - + verificationPrice - + ", terminationPrice=" - + terminationPrice - + ", billableDuration=" - + billableDuration - + ", source='" - + source - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationStatus.Builder { - - Price verificationPrice; - Price terminationPrice; - Integer billableDuration; - VerificationSourceType source; - - private Builder() {} - - /** - * See {@link VerificationStatusFlashCall#getVerificationPrice()} getter - * - * @param verificationPrice See getter - * @return Current builder - * @since 1.0 - */ - public Builder setVerificationPrice(Price verificationPrice) { - this.verificationPrice = verificationPrice; - return this; - } - - /** - * See {@link VerificationStatusFlashCall#getTerminationPrice()} getter - * - * @param terminationPrice See getter - * @return Current builder - * @since 1.0 - */ - public Builder setTerminationPrice(Price terminationPrice) { - this.terminationPrice = terminationPrice; - return this; - } - - /** - * See {@link VerificationStatusFlashCall#getBillableDuration()} getter - * - * @param billableDuration See getter - * @return Current builder - * @since 1.0 - */ - public Builder setBillableDuration(Integer billableDuration) { - this.billableDuration = billableDuration; - return this; - } - - /** - * See {@link VerificationStatusFlashCall#getSource()} getter - * - * @param source See getter - * @return Current builder - * @since 1.0 - */ - public Builder setSource(VerificationSourceType source) { - this.source = source; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationStatusFlashCall build() { - return new VerificationStatusFlashCall( - id, - status, - reason, - reference, - identity, - countryId, - verificationTimeStamp, - verificationPrice, - terminationPrice, - billableDuration, - source); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusReasonType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusReasonType.java deleted file mode 100644 index 8163b90e3..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusReasonType.java +++ /dev/null @@ -1,124 +0,0 @@ -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 VerificationStatusReasonType - extends EnumDynamic { - - /** FRAUD */ - public static final VerificationStatusReasonType FRAUD = - new VerificationStatusReasonType("Fraud"); - - /** NOT_ENOUGH_CREDIT */ - public static final VerificationStatusReasonType NOT_ENOUGH_CREDIT = - new VerificationStatusReasonType("Not enough credit"); - - /** BLOCKED */ - public static final VerificationStatusReasonType BLOCKED = - new VerificationStatusReasonType("Blocked"); - - /** DENIED_BY_CALLBACK */ - public static final VerificationStatusReasonType DENIED_BY_CALLBACK = - new VerificationStatusReasonType("Denied by callback"); - - /** INVALID_CALLBACK */ - public static final VerificationStatusReasonType INVALID_CALLBACK = - new VerificationStatusReasonType("Invalid callback"); - - /** INTERNAL_ERROR */ - public static final VerificationStatusReasonType INTERNAL_ERROR = - new VerificationStatusReasonType("Internal error"); - - /** DESTINATION_DENIED */ - public static final VerificationStatusReasonType DESTINATION_DENIED = - new VerificationStatusReasonType("Destination denied"); - - /** NETWORK_ERROR_OR_NUMBER_UNREACHABLE */ - public static final VerificationStatusReasonType NETWORK_ERROR_OR_NUMBER_UNREACHABLE = - new VerificationStatusReasonType("Network error or number unreachable"); - - /** FAILED_PENDING */ - public static final VerificationStatusReasonType FAILED_PENDING = - new VerificationStatusReasonType("Failed pending"); - - /** SMS_DELIVERY_FAILURE */ - public static final VerificationStatusReasonType SMS_DELIVERY_FAILURE = - new VerificationStatusReasonType("SMS delivery failure"); - - /** INVALID_CLI */ - public static final VerificationStatusReasonType INVALID_CLI = - new VerificationStatusReasonType("Invalid CLI"); - - /** INVALID_CODE */ - public static final VerificationStatusReasonType INVALID_CODE = - new VerificationStatusReasonType("Invalid code"); - - /** EXPIRED */ - public static final VerificationStatusReasonType EXPIRED = - new VerificationStatusReasonType("Expired"); - - /** HUNG_UP_WITHOUT_ENTERING_VALID_CODE */ - public static final VerificationStatusReasonType HUNG_UP_WITHOUT_ENTERING_VALID_CODE = - new VerificationStatusReasonType("Hung up without entering valid code"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - VerificationStatusReasonType.class, - VerificationStatusReasonType::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 VerificationStatusReasonType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static VerificationStatusReasonType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(VerificationStatusReasonType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusSMS.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusSMS.java deleted file mode 100644 index 4ceb7336d..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusSMS.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.sinch.sdk.domains.verification.models; - -import java.time.Instant; - -/** - * Verification report related to a {@link - * com.sinch.sdk.domains.verification.VerificationsService#startSms} - * - * @since 1.0 - */ -public class VerificationStatusSMS extends VerificationStatus { - - private final Price verificationPrice; - private final VerificationSourceType source; - - private VerificationStatusSMS( - VerificationId id, - VerificationStatusType status, - VerificationStatusReasonType reason, - VerificationReference reference, - Identity identity, - String countryId, - Instant verificationTimeStamp, - Price verificationPrice, - VerificationSourceType source) { - super(id, status, reason, reference, identity, countryId, verificationTimeStamp); - this.verificationPrice = verificationPrice; - this.source = source; - } - - /** - * 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 {@link VerificationStatusType#PENDING PENDING} - * - * @return Verification price object - * @since 1.0 - */ - public Price getVerificationPrice() { - return verificationPrice; - } - - /** - * Used to show if the SMS was intercepted or not - * - * @return Source type value - * @since 1.0 - */ - public VerificationSourceType getSource() { - return source; - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "VerificationStatusSMS{" - + "verificationPrice=" - + verificationPrice - + ", source='" - + source - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** Dedicated Builder */ - public static class Builder extends VerificationStatus.Builder { - - Price verificationPrice; - VerificationSourceType source; - - private Builder() {} - - /** - * See {@link VerificationStatusSMS#getVerificationPrice() getter} - * - * @param verificationPrice Price object value - * @return Current builder - * @since 1.0 - */ - public Builder setVerificationPrice(Price verificationPrice) { - this.verificationPrice = verificationPrice; - return this; - } - - /** - * See {@link VerificationStatusSMS#getSource() getter} - * - * @param source Source to be set - * @return Current builder - * @since 1.0 - */ - public Builder setSource(VerificationSourceType source) { - this.source = source; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationStatusSMS build() { - return new VerificationStatusSMS( - id, - status, - reason, - reference, - identity, - countryId, - verificationTimeStamp, - verificationPrice, - source); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusType.java b/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusType.java deleted file mode 100644 index 793918b9c..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/VerificationStatusType.java +++ /dev/null @@ -1,73 +0,0 @@ -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 VerificationStatusType extends EnumDynamic { - - /** The verification is ongoing */ - public static final VerificationStatusType PENDING = new VerificationStatusType("PENDING"); - - /** The verification was successful */ - public static final VerificationStatusType SUCCESSFUL = new VerificationStatusType("SUCCESSFUL"); - - /** The verification attempt was made, but the number wasn't verified */ - public static final VerificationStatusType FAIL = new VerificationStatusType("FAIL"); - - /** The verification attempt was denied by Sinch or your backend */ - public static final VerificationStatusType DENIED = new VerificationStatusType("DENIED"); - - /** The verification attempt was aborted by requesting a new verification */ - public static final VerificationStatusType ABORTED = new VerificationStatusType("ABORTED"); - - /** - * The verification couldn't be completed due to a network error or the number being unreachable - */ - public static final VerificationStatusType ERROR = new VerificationStatusType("ERROR"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - VerificationStatusType.class, - VerificationStatusType::new, - Arrays.asList(PENDING, SUCCESSFUL, FAIL, DENIED, ABORTED, ERROR)); - - private VerificationStatusType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static VerificationStatusType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(VerificationStatusType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/SMSCodeType.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/SMSCodeType.java deleted file mode 100644 index 1964fd8a9..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/SMSCodeType.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Accepted values for the type of code to be generated are Numeric, Alpha, and Alphanumeric. - * - * @since 1.1 - */ -public class SMSCodeType extends EnumDynamic { - - public static final SMSCodeType NUMERIC = new SMSCodeType("Numeric"); - - public static final SMSCodeType ALPHA = new SMSCodeType("Alpha"); - - public static final SMSCodeType ALPHANUMERIC = new SMSCodeType("Alphanumeric"); - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - SMSCodeType.class, SMSCodeType::new, Arrays.asList(NUMERIC, ALPHA, ALPHANUMERIC)); - - private SMSCodeType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static SMSCodeType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(SMSCodeType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutOptions.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutOptions.java deleted file mode 100644 index 40367fa21..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutOptions.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Dedicated options related to {@link StartVerificationCalloutRequestParameters - * StartVerificationCalloutRequestParameters} - * - * @since 1.1 - */ -public class StartVerificationCalloutOptions { - - private final OptionalValue speech; - - private StartVerificationCalloutOptions( - OptionalValue speech) { - this.speech = speech; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - public OptionalValue getSpeech() { - return speech; - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder { - - OptionalValue speech = OptionalValue.empty(); - - private Builder() {} - - /** - * Speech settings - * - * @param speech Set speech settings - * @return current builder - * @since 1.0 - */ - public Builder setSpeech(StartVerificationCalloutSpeechOptions speech) { - this.speech = OptionalValue.of(speech); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public StartVerificationCalloutOptions build() { - return new StartVerificationCalloutOptions(speech); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutRequestParameters.java deleted file mode 100644 index 269fe5bb3..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutRequestParameters.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; - -/** - * Dedicated request parameters to be used for a CALLOUT verification - * - * @since 1.0 - */ -public class StartVerificationCalloutRequestParameters extends StartVerificationRequestParameters { - - private final OptionalValue options; - - private StartVerificationCalloutRequestParameters( - OptionalValue identity, - OptionalValue reference, - OptionalValue custom, - OptionalValue options) { - super(identity, VerificationMethodType.CALLOUT, reference, custom); - this.options = options; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - public OptionalValue getOptions() { - return options; - } - - @Override - public String toString() { - return "StartVerificationCalloutRequestParameters{} " + super.toString(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationRequestParameters.Builder { - - OptionalValue options = OptionalValue.empty(); - - private Builder() {} - - /** - * Callout options to be used - * - * @param options Specifies options - * @return current builder - * @since 1.0 - */ - public Builder setOptions(StartVerificationCalloutOptions options) { - this.options = OptionalValue.of(options); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - @Override - public StartVerificationCalloutRequestParameters build() { - return new StartVerificationCalloutRequestParameters(identity, reference, custom, options); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutSpeechOptions.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutSpeechOptions.java deleted file mode 100644 index e7dc80568..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationCalloutSpeechOptions.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Text-To-Speech engine settings - * - *

Dedicated options related to {@link StartVerificationCalloutOptions - * StartVerificationCalloutOptions} - * - * @since 1.1 - */ -public class StartVerificationCalloutSpeechOptions { - - private final OptionalValue locale; - - private StartVerificationCalloutSpeechOptions(OptionalValue locale) { - this.locale = locale; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - public OptionalValue getLocale() { - return locale; - } - - /** - * Dedicated Builder - * - * @since 1.1 - */ - public static class Builder { - - private OptionalValue locale = OptionalValue.empty(); - - private Builder() {} - - /** - * A language-region identifier according to IANA. Only a subset of those identifiers is - * accepted to be used for Text To Speech engine - * - * @param locale Specifies expiry time - * @return current builder - * @since 1.1 - */ - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public StartVerificationCalloutSpeechOptions build() { - return new StartVerificationCalloutSpeechOptions(locale); - } - } -} 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 deleted file mode 100644 index e59570ca7..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationFlashCallRequestParameters.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; - -/** - * Dedicated request parameters to be used for a FLASH_CALL verification - * - * @since 1.0 - */ -public class StartVerificationFlashCallRequestParameters - extends StartVerificationRequestParameters { - - private final OptionalValue dialTimeOut; - - private StartVerificationFlashCallRequestParameters( - OptionalValue identity, - OptionalValue reference, - OptionalValue custom, - OptionalValue dialTimeOut) { - super(identity, VerificationMethodType.FLASH_CALL, reference, custom); - this.dialTimeOut = dialTimeOut; - } - - /** - * See {@link StartVerificationFlashCallRequestParameters.Builder#setDialTimeOut(Integer) builder - * setter} - * - * @return Dial Time Out value - * @since 1.0 - */ - public OptionalValue getDialTimeOut() { - return dialTimeOut; - } - - @Override - public String toString() { - return "StartVerificationFlashCallRequestParameters{" - + "dialTimeOut=" - + dialTimeOut - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationRequestParameters.Builder { - - OptionalValue dialTimeOut = OptionalValue.empty(); - - private Builder() {} - - /** - * Set the dial timeout - * - * @param dialTimeOut The dial timeout in seconds. - * @return current builder - * @since 1.0 - */ - public Builder setDialTimeOut(Integer dialTimeOut) { - this.dialTimeOut = OptionalValue.of(dialTimeOut); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - @Override - public StartVerificationFlashCallRequestParameters build() { - return new StartVerificationFlashCallRequestParameters( - 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 deleted file mode 100644 index 0678bf7ef..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationRequestParameters.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -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.VerificationReference; - -/** - * Base class for start verification request parameters - * - * @since 1.0 - */ -public abstract class StartVerificationRequestParameters { - - private final VerificationMethodType method; - private final OptionalValue identity; - private final OptionalValue reference; - private final OptionalValue custom; - - protected StartVerificationRequestParameters( - OptionalValue identity, - VerificationMethodType method, - OptionalValue reference, - OptionalValue custom) { - this.identity = identity; - this.method = method; - this.reference = reference; - this.custom = custom; - } - - /** - * See {@link StartVerificationRequestParameters.Builder#setIdentity(NumberIdentity) builder - * setter} - * - * @return The reference value - * @since 1.0 - */ - public OptionalValue getIdentity() { - return identity; - } - - /** - * The type of the verification request. - * - * @return The method value - * @since 1.0 - */ - public VerificationMethodType getMethod() { - return method; - } - - /** - * See {@link StartVerificationRequestParameters.Builder#setReference(VerificationReference) - * builder setter} - * - * @return The reference value - * @since 1.0 - */ - public OptionalValue getReference() { - return reference; - } - - /** - * See {@link StartVerificationRequestParameters.Builder#setCustom(String) builder setter} - * - * @return The custom value - * @since 1.0 - */ - public OptionalValue getCustom() { - return custom; - } - - @Override - public String toString() { - return "StartVerificationRequestParameters{" - + "method=" - + method - + ", identity=" - + identity - + ", reference='" - + reference - + '\'' - + ", custom='" - + custom - + '\'' - + '}'; - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.0 - */ - public abstract static class Builder> { - - OptionalValue identity = OptionalValue.empty(); - OptionalValue reference = OptionalValue.empty(); - OptionalValue custom = OptionalValue.empty(); - - /** - * Specifies the type of endpoint that will be verified and the particular endpoint. - * NumberIdentity is currently the only supported endpoint type - * - * @param identity Specifies the type of endpoint that will be verified and the particular - * endpoint. number is currently the only supported endpoint type - * @return current builder - * @since 1.0 - */ - public B setIdentity(NumberIdentity identity) { - this.identity = OptionalValue.of(identity); - return self(); - } - - /** - * Used to pass your own reference in the request for tracking purposes - * - * @param reference your own reference to be used - * @return current builder - * @since 1.0 - */ - public B setReference(VerificationReference reference) { - this.reference = OptionalValue.of(reference); - return self(); - } - - /** - * Pass custom data in the request - * - * @param custom custom data - * @return current builder - * @since 1.0 - */ - public B setCustom(String custom) { - this.custom = OptionalValue.of(custom); - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public abstract StartVerificationRequestParameters build(); - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSOptions.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSOptions.java deleted file mode 100644 index 0a851cec5..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSOptions.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Dedicated options related to {@link StartVerificationSMSRequestParameters - * StartVerificationSMSRequestParameters} - * - * @since 1.1 - */ -public class StartVerificationSMSOptions { - - private final OptionalValue expiry; - private final OptionalValue codeType; - private final OptionalValue template; - private final OptionalValue acceptLanguage; - - private StartVerificationSMSOptions( - OptionalValue expiry, - OptionalValue codeType, - OptionalValue template, - OptionalValue acceptLanguage) { - this.expiry = expiry; - this.codeType = codeType; - this.template = template; - this.acceptLanguage = acceptLanguage; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - public OptionalValue getExpiry() { - return expiry; - } - - public OptionalValue getCodeType() { - return codeType; - } - - public OptionalValue getTemplate() { - return template; - } - - public OptionalValue getAcceptLanguage() { - return acceptLanguage; - } - - /** - * Dedicated Builder - * - * @since 1.1 - */ - public static class Builder { - - private OptionalValue expiry = OptionalValue.empty(); - private OptionalValue codeType = OptionalValue.empty(); - private OptionalValue template = OptionalValue.empty(); - private OptionalValue acceptLanguage = OptionalValue.empty(); - - private Builder() {} - - /** - * The expiration time for a verification process is represented in the format HH:MM:SS. - * - * @param expiry Specifies expiry time - * @return current builder - * @since 1.1 - */ - public Builder setExpiry(String expiry) { - this.expiry = OptionalValue.of(expiry); - return this; - } - - /** - * The type of code to be generated - * - * @param codeType Specifies code type - * @return current builder - * @since 1.1 - */ - public Builder setCodeType(SMSCodeType codeType) { - this.codeType = OptionalValue.of(codeType); - return this; - } - - /** - * The SMS template must include a placeholder {{CODE}} where the verification code will be - * inserted, and it can otherwise be customized as desired - * - * @param template Template string - * @return current builder - * @since 1.1 - */ - public Builder setTemplate(String template) { - this.template = OptionalValue.of(template); - return this; - } - - /** - * Value of accept language is used to determine the language of an SMS message - * - * @param acceptLanguage locale string - * @return current builder - * @since 1.1 - */ - public Builder setAcceptLanguage(String acceptLanguage) { - this.acceptLanguage = OptionalValue.of(acceptLanguage); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public StartVerificationSMSOptions build() { - return new StartVerificationSMSOptions(expiry, codeType, template, acceptLanguage); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSRequestParameters.java deleted file mode 100644 index 85a312db4..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSMSRequestParameters.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; - -/** - * Dedicated request parameters to be used for an SMS verification - * - * @since 1.0 - */ -public class StartVerificationSMSRequestParameters extends StartVerificationRequestParameters { - - private final OptionalValue options; - - private StartVerificationSMSRequestParameters( - OptionalValue identity, - OptionalValue reference, - OptionalValue custom, - OptionalValue options) { - super(identity, VerificationMethodType.SMS, reference, custom); - this.options = options; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - public OptionalValue getOptions() { - return options; - } - - @Override - public String toString() { - return "StartVerificationSMSRequestParameters{} " + super.toString(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationRequestParameters.Builder { - - OptionalValue acceptLanguage = OptionalValue.empty(); - OptionalValue options = OptionalValue.empty(); - - private Builder() {} - - /** - * SMS options to be used - * - * @param options Specifies options - * @return current builder - * @since 1.0 - */ - public Builder setOptions(StartVerificationSMSOptions options) { - this.options = OptionalValue.of(options); - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - @Override - public StartVerificationSMSRequestParameters build() { - return new StartVerificationSMSRequestParameters(identity, reference, custom, options); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSeamlessRequestParameters.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSeamlessRequestParameters.java deleted file mode 100644 index b11e623f4..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/StartVerificationSeamlessRequestParameters.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; - -/** - * Dedicated request parameters to be used for a SEAMLESS verification - * - * @since 1.0 - */ -public class StartVerificationSeamlessRequestParameters extends StartVerificationRequestParameters { - - private StartVerificationSeamlessRequestParameters( - OptionalValue identity, - OptionalValue reference, - OptionalValue custom) { - super(identity, VerificationMethodType.SEAMLESS, reference, custom); - } - - @Override - public String toString() { - return "StartVerificationSeamlessRequestParameters{} " + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationRequestParameters.Builder { - - private Builder() {} - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - @Override - public StartVerificationSeamlessRequestParameters build() { - return new StartVerificationSeamlessRequestParameters(identity, reference, custom); - } - - @Override - protected Builder self() { - return this; - } - } -} 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 deleted file mode 100644 index fde2660ef..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportCalloutRequestParameters.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; - -/** - * Dedicated request parameters to be used to start a verification report by callout (Verification - * by placing a PSTN call to the user's phone) - * - * @since 1.0 - */ -public class VerificationReportCalloutRequestParameters - extends VerificationReportRequestParameters { - - private final OptionalValue code; - - private VerificationReportCalloutRequestParameters(OptionalValue code) { - super(OptionalValue.of(VerificationMethodType.CALLOUT)); - this.code = code; - } - - /** - * See {@link VerificationReportCalloutRequestParameters.Builder#setCode(String) builder setter} - * - * @return Code value - * @since 1.0 - */ - public OptionalValue getCode() { - return code; - } - - @Override - public String toString() { - return "VerificationReportCalloutRequestParameters{" - + "code='" - + code - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationReportRequestParameters.Builder { - - OptionalValue code = OptionalValue.empty(); - - protected Builder() { - super(VerificationMethodType.CALLOUT); - } - - /** - * The code which was received by the user submitting the SMS verification. - * - * @param code The code which was received by the user submitting the Phone Call verification. - * @return current builder - */ - public Builder setCode(String code) { - this.code = OptionalValue.of(code); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 2a76d317e..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportFlashCallRequestParameters.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; - -/** - * Dedicated request parameters to be used to start a verification report by flash call (missed - * call) - * - * @since 1.0 - */ -public class VerificationReportFlashCallRequestParameters - extends VerificationReportRequestParameters { - - private final OptionalValue cli; - - private VerificationReportFlashCallRequestParameters(OptionalValue cli) { - super(OptionalValue.of(VerificationMethodType.FLASH_CALL)); - this.cli = cli; - } - - /** - * See {@link VerificationReportFlashCallRequestParameters.Builder#setCli(String) builder setter} - * - * @return CLI value - * @since 1.0 - */ - public OptionalValue getCli() { - return cli; - } - - @Override - public String toString() { - return "VerificationReportFlashCallRequestParameters{" - + "cli='" - + cli - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationReportRequestParameters.Builder { - - OptionalValue cli = OptionalValue.empty(); - - protected Builder() { - super(VerificationMethodType.FLASH_CALL); - } - - /** - * The caller ID of the FlashCall - * - * @param cli The caller ID value - * @return current builder - * @since 1.0 - */ - public Builder setCli(String cli) { - this.cli = OptionalValue.of(cli); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 3cecabcfe..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportRequestParameters.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; - -/** - * Base class for verification report request parameters - * - * @since 1.0 - */ -public class VerificationReportRequestParameters { - - private final OptionalValue method; - - protected VerificationReportRequestParameters(OptionalValue method) { - this.method = method; - } - - /** - * The type of the verification request. - * - * @return method value - * @since 1.0 - */ - public OptionalValue getMethod() { - return method; - } - - @Override - public String toString() { - return "VerificationReportRequestParameters{" + "method=" + method + '}'; - } - - protected static Builder builder() { - return new Builder<>(); - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.0 - */ - public static class Builder> { - - OptionalValue method; - - protected Builder() {} - - protected Builder(VerificationMethodType method) { - this.method = OptionalValue.of(method); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 07f0a01f3..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/VerificationReportSMSRequestParameters.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.sinch.sdk.domains.verification.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; - -/** - * Dedicated request parameters to be used to start a verification report by SMS - * - * @since 1.0 - */ -public class VerificationReportSMSRequestParameters extends VerificationReportRequestParameters { - - private final OptionalValue code; - private final OptionalValue cli; - - private VerificationReportSMSRequestParameters( - OptionalValue code, OptionalValue cli) { - super(OptionalValue.of(VerificationMethodType.SMS)); - this.code = code; - this.cli = cli; - } - - /** - * See {@link VerificationReportSMSRequestParameters.Builder#setCode(String) builder setter} - * - * @return Code value - * @since 1.0 - */ - public OptionalValue getCode() { - return code; - } - - /** - * See {@link VerificationReportSMSRequestParameters.Builder#setCli(String) builder setter} - * - * @return CLI value - * @since 1.0 - */ - public OptionalValue getCli() { - return cli; - } - - @Override - public String toString() { - return "VerificationReportSMSRequestParameters{" - + "code='" - + code - + '\'' - + ", cli='" - + cli - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationReportRequestParameters.Builder { - - OptionalValue code = OptionalValue.empty(); - OptionalValue cli = OptionalValue.empty(); - - protected Builder() { - super(VerificationMethodType.SMS); - } - - /** - * The code which was received by the user submitting the SMS verification. - * - * @param code The code value - * @return current builder - * @since 1.0 - */ - public Builder setCode(String code) { - this.code = OptionalValue.of(code); - return this; - } - - /** - * The sender ID of the SMS. - * - * @param cli The sender ID value - * @return current builder - * @since 1.0 - */ - public Builder setCli(String cli) { - this.cli = OptionalValue.of(cli); - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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/requests/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/requests/package-info.java deleted file mode 100644 index 0e7e95264..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/requests/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Verification API requests related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.verification.models.requests; 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 deleted file mode 100644 index 06f1ba452..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponse.java +++ /dev/null @@ -1,110 +0,0 @@ -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; - -/** - * Base class to all Start verification requests - * - * @since 1.0 - */ -public class StartVerificationResponse { - - private final VerificationId id; - private final Collection links; - - protected StartVerificationResponse(VerificationId id, Collection links) { - this.id = id; - this.links = links; - } - - /** - * Verification identifier used to query for status. - * - * @return Id value - * @since 1.0 - */ - public VerificationId getId() { - return id; - } - - /** - * Available methods and actions which can be done after a successful Verification - * - * @return Links value - * @since 1.0 - */ - public Collection getLinks() { - return links; - } - - @Override - public String toString() { - return "StartVerificationResponse{" + "id='" + id + '\'' + ", links=" + links + '}'; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder<>(); - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.0 - */ - public static class Builder> { - - VerificationId id; - Collection links; - - protected Builder() {} - ; - - /** - * See {@link StartVerificationResponse#getId() getter} - * - * @param id see getter - * @return The current builder - * @since 1.0 - */ - public B setId(VerificationId id) { - this.id = id; - return self(); - } - - /** - * See {@link StartVerificationResponse#getLinks() getter} - * - * @param links see getter - * @return The current builder - * @since 1.0 - */ - public B setLinks(Collection links) { - this.links = links; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 93e78f663..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseCallout.java +++ /dev/null @@ -1,67 +0,0 @@ -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 com.sinch.sdk.domains.verification.models.requests.StartVerificationCalloutRequestParameters; -import java.util.Collection; - -/** - * Dedicated response type for a callout verification - * - *

Verification response when started using {@link - * com.sinch.sdk.domains.verification.VerificationsService#startCallout(StartVerificationCalloutRequestParameters)} - * - * @since 1.0 - */ -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 - */ - private StartVerificationResponseCallout(VerificationId id, Collection links) { - super(id, links); - } - - @Override - public String toString() { - return "StartVerificationResponseCallout{} " + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationResponse.Builder { - - private Builder() { - super(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index eded98f55..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseFlashCall.java +++ /dev/null @@ -1,184 +0,0 @@ -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 com.sinch.sdk.domains.verification.models.requests.StartVerificationFlashCallRequestParameters; -import java.util.Collection; - -/** - * Dedicated response type for a flash call verification - * - *

Verification response when started using {@link - * com.sinch.sdk.domains.verification.VerificationsService#startFlashCall(StartVerificationFlashCallRequestParameters)} - * - * @since 1.0 - */ -public class StartVerificationResponseFlashCall extends StartVerificationResponse { - - private final String cliFilter; - private final Integer interceptionTimeOut; - private final Integer reportTimeout; - private final Integer denyCallAfter; - - private StartVerificationResponseFlashCall( - VerificationId 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; - } - - /** - * Filter that should be applied for incoming calls to intercept the Flashcall. - * - * @return Filter value - * @since 1.0 - */ - public String getCliFilter() { - return cliFilter; - } - - /** - * Amount of seconds client should wait for the Flashcall. - * - * @return time out value - * @since 1.0 - */ - public Integer getInterceptionTimeOut() { - return interceptionTimeOut; - } - - /** - * The time in seconds allowed for reporting the code after which the verification will expire. - * - * @return time out value - * @since 1.0 - */ - public Integer getReportTimeout() { - return reportTimeout; - } - - /** - * Used by the SDKs, this setting makes the handset deny the flashcall after the set time in - * seconds. - * - * @return Deny value - * @since 1.0 - */ - public Integer getDenyCallAfter() { - return denyCallAfter; - } - - @Override - public String toString() { - return "StartVerificationResponseFlashCall{" - + "cliFilter='" - + cliFilter - + '\'' - + ", interceptionTimeOut=" - + interceptionTimeOut - + ", reportTimeout=" - + reportTimeout - + ", denyCallAfter=" - + denyCallAfter - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationResponse.Builder { - - String cliFilter; - Integer interceptionTimeOut; - Integer reportTimeout; - Integer denyCallAfter; - - private Builder() { - super(); - } - - /** - * See {@link StartVerificationResponseFlashCall#getCliFilter() getter} - * - * @param cliFilter see getter - * @return The current builder - * @since 1.0 - */ - public Builder setCliFilter(String cliFilter) { - this.cliFilter = cliFilter; - return self(); - } - - /** - * See {@link StartVerificationResponseFlashCall#getInterceptionTimeOut() getter} - * - * @param interceptionTimeOut see getter - * @return The current builder - * @since 1.0 - */ - public Builder setInterceptionTimeOut(Integer interceptionTimeOut) { - this.interceptionTimeOut = interceptionTimeOut; - return self(); - } - - /** - * See {@link StartVerificationResponseFlashCall#getReportTimeout() getter} - * - * @param reportTimeout see getter - * @return The current builder - * @since 1.0 - */ - public Builder setReportTimeout(Integer reportTimeout) { - this.reportTimeout = reportTimeout; - return self(); - } - - /** - * See {@link StartVerificationResponseFlashCall#getDenyCallAfter() getter} - * - * @param denyCallAfter see getter - * @return The current builder - * @since 1.0 - */ - public Builder setDenyCallAfter(Integer denyCallAfter) { - this.denyCallAfter = denyCallAfter; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index 8dba1710b..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSMS.java +++ /dev/null @@ -1,123 +0,0 @@ -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 com.sinch.sdk.domains.verification.models.requests.StartVerificationSMSRequestParameters; -import java.util.Collection; - -/** - * Dedicated response type for a SMS verification - * - *

Verification response when started using {@link - * com.sinch.sdk.domains.verification.VerificationsService#startSms(StartVerificationSMSRequestParameters)} - * - * @since 1.0 - */ -public class StartVerificationResponseSMS extends StartVerificationResponse { - - private final String template; - private final Integer interceptionTimeOut; - - private StartVerificationResponseSMS( - VerificationId id, Collection links, String template, Integer interceptionTimeOut) { - super(id, links); - this.template = template; - this.interceptionTimeOut = interceptionTimeOut; - } - - /** - * The expected template for the SMS response - * - * @return Template value - * @since 1.0 - */ - public String getTemplate() { - return template; - } - - /** - * The amount of time in seconds that the client should wait for the SMS. - * - * @return Timeout value - * @since 1.0 - */ - public Integer getInterceptionTimeOut() { - return interceptionTimeOut; - } - - @Override - public String toString() { - return "StartVerificationResponseSMS{" - + "template='" - + template - + '\'' - + ", interceptionTimeOut=" - + interceptionTimeOut - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationResponse.Builder { - - String template; - Integer interceptionTimeOut; - - private Builder() { - super(); - } - - /** - * See {@link StartVerificationResponseSMS#getTemplate() getter} - * - * @param template see getter - * @return The current builder - * @since 1.0 - */ - public Builder setTemplate(String template) { - this.template = template; - return this; - } - - /** - * See {@link StartVerificationResponseSMS#getInterceptionTimeOut() getter} - * - * @param interceptionTimeOut see getter - * @return The current builder - * @since 1.0 - */ - public Builder setInterceptionTimeOut(Integer interceptionTimeOut) { - this.interceptionTimeOut = interceptionTimeOut; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - 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 deleted file mode 100644 index d2dce9ef5..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/StartVerificationResponseSeamless.java +++ /dev/null @@ -1,96 +0,0 @@ -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 com.sinch.sdk.domains.verification.models.requests.StartVerificationSeamlessRequestParameters; -import java.util.Collection; - -/** - * Dedicated response type for a seamless call verification - * - *

Verification response when started using with {@link - * com.sinch.sdk.domains.verification.VerificationsService#startSeamless(StartVerificationSeamlessRequestParameters)} - * - * @since 1.0 - */ -public class StartVerificationResponseSeamless extends StartVerificationResponse { - - private final String targetUri; - - private StartVerificationResponseSeamless( - VerificationId id, Collection links, String targetUri) { - super(id, links); - this.targetUri = targetUri; - } - - /** - * The target URI - * - * @return The target URI - * @since 1.0 - */ - public String getTargetUri() { - return targetUri; - } - - @Override - public String toString() { - return "StartVerificationResponseSeamless{" - + "targetUri='" - + targetUri - + '\'' - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends StartVerificationResponse.Builder { - - String targetUri; - - private Builder() { - super(); - } - - /** - * See {@link StartVerificationResponseSeamless#getLinks() getter} - * - * @param targetUri see getter - * @return The current builder - * @since 1.0 - */ - public Builder setTargetUri(String targetUri) { - this.targetUri = targetUri; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public StartVerificationResponseSeamless build() { - return new StartVerificationResponseSeamless(id, links, targetUri); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/response/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/response/package-info.java deleted file mode 100644 index 7b16cb3f0..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/response/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Verification API responses related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.verification.models.response; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/package-info.java index 95ecc0d23..1747fe377 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/request/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Report requests * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationReportService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsReportService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.report.request; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponseMapper.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponseMapper.java new file mode 100644 index 000000000..4c20acc91 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/VerificationReportResponseMapper.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.verification.models.v1.report.response; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.verification.models.v1.report.response.internal.VerificationReportResponseInternalImpl; +import java.io.IOException; + +public class VerificationReportResponseMapper { + + public static void initMapper() { + SimpleModule module = + new SimpleModule().addDeserializer(VerificationReportResponse.class, new Deserializer()); + Mapper.getInstance().registerModule(module); + } + + private static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public VerificationReportResponse deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationReportResponseInternalImpl deserialized = + jp.readValueAs(VerificationReportResponseInternalImpl.class); + return (VerificationReportResponse) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/package-info.java index b320a6bdd..93167c09c 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/report/response/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Report responses * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationReportService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsReportService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.report.response; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/sinchevents/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/sinchevents/package-info.java new file mode 100644 index 000000000..a695f5170 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/sinchevents/package-info.java @@ -0,0 +1,6 @@ +/** + * Models related to Verifications Sinch Events + * + * @since 2.0 + */ +package com.sinch.sdk.domains.verification.models.v1.sinchevents; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/package-info.java index cb23c9614..6bda06389 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/request/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Start requests * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationStartService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsStartService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.start.request; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseMapper.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseMapper.java new file mode 100644 index 000000000..62d094849 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/VerificationStartResponseMapper.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.verification.models.v1.start.response; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.verification.models.v1.start.response.internal.VerificationStartResponseInternalImpl; +import java.io.IOException; + +public class VerificationStartResponseMapper { + + public static void initMapper() { + SimpleModule module = + new SimpleModule().addDeserializer(VerificationStartResponse.class, new Deserializer()); + Mapper.getInstance().registerModule(module); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public VerificationStartResponse deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStartResponseInternalImpl deserialized = + jp.readValueAs(VerificationStartResponseInternalImpl.class); + return (VerificationStartResponse) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/package-info.java index 7ff0bcdcd..447a85453 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/start/response/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Start responses * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationStartService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsStartService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.start.response; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/package-info.java index d78059223..3d1029f5b 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Status * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationStatusService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsStatusService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.status; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponseMapper.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponseMapper.java new file mode 100644 index 000000000..78584940e --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/VerificationStatusResponseMapper.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.verification.models.v1.status.response; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.module.SimpleModule; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.verification.models.v1.status.response.internal.VerificationStatusResponseInternalImpl; +import java.io.IOException; + +public class VerificationStatusResponseMapper { + + public static void initMapper() { + SimpleModule module = + new SimpleModule().addDeserializer(VerificationStatusResponse.class, new Deserializer()); + Mapper.getInstance().registerModule(module); + } + + static class Deserializer extends StdDeserializer { + + public Deserializer() { + this(null); + } + + public Deserializer(Class vc) { + super(vc); + } + + @Override + public VerificationStatusResponse deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException { + + VerificationStatusResponseInternalImpl deserialized = + jp.readValueAs(VerificationStatusResponseInternalImpl.class); + return (VerificationStatusResponse) deserialized.getActualInstance(); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/package-info.java index ad9b886c5..9a96b634b 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/verification/models/v1/status/response/package-info.java @@ -1,7 +1,7 @@ /** * Models related to Verifications Status responses * - * @see com.sinch.sdk.domains.verification.api.v1.VerificationStatusService + * @see com.sinch.sdk.domains.verification.api.v1.VerificationsStatusService * @since 1.1 */ package com.sinch.sdk.domains.verification.models.v1.status.response; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/package-info.java deleted file mode 100644 index b7ef2f8e4..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Models related to Verifications WebHooks - * - * @since 1.1 - */ -package com.sinch.sdk.domains.verification.models.v1.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationEvent.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationEvent.java deleted file mode 100644 index 63facc25f..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationEvent.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -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 java.util.Optional; - -/** - * Base class for received Verification Events onto webhooks callback - * - * @see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks - */ -public class VerificationEvent { - private final VerificationId id; - private final VerificationMethodType method; - private final Identity identity; - private final VerificationReference reference; - private final String custom; - - public VerificationEvent( - String id, - VerificationMethodType method, - Identity identity, - VerificationReference reference, - String custom) { - this.id = VerificationId.valueOf(id); - this.method = method; - this.identity = identity; - this.reference = reference; - this.custom = custom; - } - - /** - * The ID of the verification request. - * - * @return Id value - * @since 1.0 - */ - public VerificationId getId() { - return id; - } - - /** - * The verification method - * - * @return The method value - * @since 1.0 - */ - public VerificationMethodType getMethod() { - return method; - } - - /** - * Specifies the type of endpoint that will be verified and the particular endpoint. {@link - * NumberIdentity} is currently the only supported endpoint type - * - * @return identity - * @since 1.0 - */ - public Identity getIdentity() { - return identity; - } - - /** - * The reference that was optionally passed together with the verification request - * - * @return Reference value - * @since 1.0 - */ - public Optional getReference() { - return Optional.ofNullable(reference); - } - - /** - * A custom string that can be provided during a verification request - * - * @return The custom value - * @since 1.0 - */ - public Optional getCustom() { - return Optional.ofNullable(custom); - } - - @Override - public String toString() { - return "VerificationEvent{" - + "id=" - + id - + ", method=" - + method - + ", identity=" - + identity - + ", reference=" - + reference - + ", custom='" - + custom - + '\'' - + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationRequestEvent.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationRequestEvent.java deleted file mode 100644 index 0b31f3c53..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationRequestEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.Price; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; -import java.util.Collection; -import java.util.Optional; - -/** - * Event received onto verification request - * - *

This event is received onto a POST request to the specified verification callback URL and is - * triggered when a new verification request is made from the SDK client or the Verification Request - * API. This callback event is only triggered when a verification callback URL is specified in your - * dashboard. - */ -public class VerificationRequestEvent extends VerificationEvent { - - private final Price price; - private final Collection acceptLanguage; - - public VerificationRequestEvent( - String id, - VerificationMethodType method, - Identity identity, - Price price, - VerificationReference reference, - String custom, - @Deprecated Collection acceptLanguage) { - super(id, method, identity, reference, custom); - this.price = price; - this.acceptLanguage = acceptLanguage; - } - - /** - * The amount of money and currency of the verification request - * - * @return Price value - * @since 1.0 - */ - public Optional getPrice() { - return Optional.ofNullable(price); - } - - /** - * Allows you to set or override if provided in the API request, the SMS verification content - * language. Only used with the SMS verification method. The content language specified in the API - * request or in the callback can be overridden by carrier provider specific templates, due to - * compliance and legal requirements, such as US shortcode requirements see https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/#tag/Verification-callbacks/paths/VerificationRequestEvent/post - * - * @return Values collection list - * @since 1.0 - * @deprecated - */ - @Deprecated - public Optional> getAcceptLanguage() { - return Optional.ofNullable(acceptLanguage); - } - - @Override - public String toString() { - return "VerificationRequestEvent{" - + "price=" - + price - + ", acceptLanguage=" - + acceptLanguage - + "} " - + super.toString(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponse.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponse.java deleted file mode 100644 index 7c97d19e1..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponse.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -/** - * Base class for verification callback response - * - * @since 1.0 - */ -public class VerificationResponse { - - private final VerificationResponseActionType action; - - VerificationResponse(VerificationResponseActionType action) { - this.action = action; - } - - /** - * Determines whether the verification can be executed - * - * @return action type to be performed - * @since 1.0 - */ - public VerificationResponseActionType getAction() { - return action; - } - - @Override - public String toString() { - return "VerificationResponseActionType{" + "action=" + action + '}'; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder<>(); - } - - /** - * Dedicated Builder - * - * @param Builder - * @since 1.0 - */ - public static class Builder> { - - VerificationResponseActionType action; - - protected Builder() { - super(); - } - - /** - * See {@link VerificationResponse#getAction() getter} - * - * @param action see getter - * @return The current builder - * @since 1.0 - */ - public B setAction(VerificationResponseActionType action) { - this.action = action; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationResponse build() { - return new VerificationResponse(action); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseActionType.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseActionType.java deleted file mode 100644 index bc3f2fd0e..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseActionType.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -import com.fasterxml.jackson.annotation.JsonValue; -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Determines whether the verification can be executed. See action - * type response documentation - * - * @since 1.0 - */ -public class VerificationResponseActionType - extends EnumDynamic { - - /** Action is allowed */ - public static final VerificationResponseActionType ALLOW = - new VerificationResponseActionType("allow"); - - /** Action is denied */ - public static final VerificationResponseActionType DENY = - new VerificationResponseActionType("deny"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - VerificationResponseActionType.class, - VerificationResponseActionType::new, - Arrays.asList(ALLOW, DENY)); - - private VerificationResponseActionType(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static VerificationResponseActionType from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param e The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(VerificationResponseActionType e) { - return ENUM_SUPPORT.valueOf(e); - } - - /** - * Value of the enum as String - * - * @return String identifier of the enum value # @since 1.0 - */ - @JsonValue - public String getValue() { - return this.value(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCallout.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCallout.java deleted file mode 100644 index 0614f05a4..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCallout.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -/** Verification response related to a call out */ -public class VerificationResponseCallout extends VerificationResponse { - - private final String code; - private final VerificationResponseCalloutSpeech speech; - - /** - * @param action Determines whether the verification can be executed. - * @param code see {@link #getCode() getter} - * @param speech see {@link #getSpeech() getter} - */ - VerificationResponseCallout( - VerificationResponseActionType action, - String code, - VerificationResponseCalloutSpeech speech) { - super(action); - this.code = code; - this.speech = speech; - } - - /** - * The Phone Call PIN that should be entered by the user. Sinch servers automatically generate PIN - * codes for Phone Call verification. If you want to set your own code, you can specify it in the - * response to the Verification Request Event. - * - * @return The code value - * @since 1.0 - */ - public String getCode() { - return code; - } - - /** - * Speech related information - * - * @return Speech information - * @since 1.0 - */ - public VerificationResponseCalloutSpeech getSpeech() { - return speech; - } - - @Override - public String toString() { - return "VerificationResponseCallout{" - + "code='" - + code - + '\'' - + ", speech=" - + speech - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationResponse.Builder { - - String code; - - VerificationResponseCalloutSpeech speech; - - private Builder() {} - - /** - * See {@link VerificationResponseCallout#getCode()} - * - * @param code {@link VerificationResponseCallout#getCode()} - * @return The current builder - * @since 1.0 - */ - public Builder setCode(String code) { - this.code = code; - return self(); - } - - /** - * See {@link VerificationResponseCallout#getSpeech()} - * - * @param speech {@link VerificationResponseCallout#getSpeech()} - * @return The current builder - * @since 1.0 - */ - public Builder setSpeech(VerificationResponseCalloutSpeech speech) { - this.speech = speech; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationResponseCallout build() { - return new VerificationResponseCallout(action, code, speech); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCalloutSpeech.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCalloutSpeech.java deleted file mode 100644 index e10ceed28..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseCalloutSpeech.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -/** Verification response details related to call out speech */ -public class VerificationResponseCalloutSpeech { - - private final String locale; - - /** - * Indicates the language that should be used for the text-to-speech message. Currently, only - * en-US is supported. - * - * @param locale Locale value - */ - VerificationResponseCalloutSpeech(String locale) { - this.locale = locale; - } - - /** - * Indicates the language that should be used for the text-to-speech message. Currently, only - * en-US is supported. - * - * @return locale value - * @since 1.1 - */ - public String getLocale() { - return locale; - } - - @Override - public String toString() { - return "VerificationResponseCalloutSpeech{" + "locale='" + locale + '\'' + '}'; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.1 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.1 - */ - public static class Builder { - - String locale; - - private Builder() {} - - /** - * See {@link VerificationResponseCalloutSpeech#VerificationResponseCalloutSpeech(String) - * constructor} - * - * @param locale see constructor - * @return The current builder - * @since 1.1 - */ - public Builder setLocale(String locale) { - this.locale = locale; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.1 - */ - public VerificationResponseCalloutSpeech build() { - return new VerificationResponseCalloutSpeech(locale); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseFlashCall.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseFlashCall.java deleted file mode 100644 index 44791040a..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseFlashCall.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -/** Verification response related to a flash call */ -public class VerificationResponseFlashCall extends VerificationResponse { - - private final String cli; - - private final Integer dialTimeout; - - /** - * Flash call response related information - * - * @param action Determines whether the verification can be executed. - * @param cli see {@link #getCli() getter} - * @param dialTimeout see {@link #getDialTimeout() getter} - */ - public VerificationResponseFlashCall( - VerificationResponseActionType action, String cli, Integer dialTimeout) { - super(action); - this.cli = cli; - this.dialTimeout = dialTimeout; - } - - /** - * The phone number that will be displayed to the user when the flashcall is received on the - * user's phone. By default, the Sinch dashboard will randomly select the CLI that will be - * displayed during a flashcall from a pool of numbers. If you want to set your own CLI, you can - * specify it in the response to the Verification Request Event. - * - * @return CLI value - * @since 1.0 - */ - public String getCli() { - return cli; - } - - /** - * The maximum time that a flashcall verification will be active and can be completed. If the - * phone number hasn't been verified successfully during this time, then the verification request - * will fail. By default, the Sinch dashboard will automatically optimize dial time out during a - * flashcall. If you want to set your own dial time out for the flashcall, you can specify it in - * the response to the Verification Request Event. - * - * @return The dial timeout value - * @since 1.0 - */ - public Integer getDialTimeout() { - return dialTimeout; - } - - @Override - public String toString() { - return "VerificationResponseFlashCall{" - + "cli='" - + cli - + '\'' - + ", dialTimeout=" - + dialTimeout - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationResponse.Builder { - - String cli; - - Integer dialTimeout; - - private Builder() {} - - /** - * See {@link VerificationResponseFlashCall#getCli()} - * - * @param cli See {@link VerificationResponseFlashCall#getCli()} - * @return The current builder - * @since 1.0 - */ - public Builder setCli(String cli) { - this.cli = cli; - return self(); - } - - /** - * See {@link VerificationResponseFlashCall#getDialTimeout()} - * - * @param dialTimeout See {@link VerificationResponseFlashCall#getDialTimeout()} - * @return The current builder - * @since 1.0 - */ - public Builder setDialTimeout(Integer dialTimeout) { - this.dialTimeout = dialTimeout; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationResponseFlashCall build() { - return new VerificationResponseFlashCall(action, cli, dialTimeout); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseSMS.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseSMS.java deleted file mode 100644 index 5906227c8..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResponseSMS.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -import java.util.Collection; - -/** Verification response related to a SMS */ -public class VerificationResponseSMS extends VerificationResponse { - - private final String code; - - private final Collection acceptLanguage; - - /** - * SMS response related information - * - * @param action Determines whether the verification can be executed. - * @param code see {@link #getCode() getter} - * @param acceptLanguage see {@link #getAcceptLanguage() getter} - */ - public VerificationResponseSMS( - VerificationResponseActionType action, String code, Collection acceptLanguage) { - super(action); - this.code = code; - this.acceptLanguage = acceptLanguage; - } - - /** - * The SMS PIN that should be used. By default, the Sinch dashboard will automatically generate - * PIN codes for SMS verification. If you want to set your own PIN, you can specify it in the - * response to the Verification Request Event. - * - * @return Code value - */ - public String getCode() { - return code; - } - - /** - * The SMS verification content languages. Set in the verification request. - * - * @return Accepted languages list - */ - public Collection getAcceptLanguage() { - return acceptLanguage; - } - - @Override - public String toString() { - return "VerificationResponseSMS{" - + "code='" - + code - + '\'' - + ", acceptLanguage=" - + acceptLanguage - + "} " - + super.toString(); - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Dedicated Builder - * - * @since 1.0 - */ - public static class Builder extends VerificationResponse.Builder { - - String code; - Collection acceptLanguage; - - private Builder() {} - - /** - * See {@link VerificationResponseSMS#getCode()} - * - * @param code See {@link VerificationResponseSMS#getCode()} - * @return The current builder - * @since 1.0 - */ - public Builder setCode(String code) { - this.code = code; - return self(); - } - - /** - * See {@link VerificationResponseSMS#getAcceptLanguage()} - * - * @param acceptLanguage See {@link VerificationResponseSMS#getAcceptLanguage()} - * @return The current builder - * @since 1.0 - */ - public Builder setAcceptLanguage(Collection acceptLanguage) { - this.acceptLanguage = acceptLanguage; - return self(); - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.0 - */ - public VerificationResponseSMS build() { - return new VerificationResponseSMS(action, code, acceptLanguage); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResultEvent.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResultEvent.java deleted file mode 100644 index 7342fb425..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/VerificationResultEvent.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.sinch.sdk.domains.verification.models.webhooks; - -import com.sinch.sdk.domains.verification.models.Identity; -import com.sinch.sdk.domains.verification.models.VerificationMethodType; -import com.sinch.sdk.domains.verification.models.VerificationReference; -import com.sinch.sdk.domains.verification.models.VerificationSourceType; -import com.sinch.sdk.domains.verification.models.VerificationStatusReasonType; -import com.sinch.sdk.domains.verification.models.VerificationStatusType; -import java.util.Optional; - -/** - * Event received when a verification has been completed - * - *

This event is received onto a POST request to the specified verification callback URL and - * triggered when a verification has been completed and the result is known. It's used to report the - * verification result to the developer's backend application. This callback event is only triggered - * when the verification callback URL is specified in your dashboard. - */ -public class VerificationResultEvent extends VerificationEvent { - - private final VerificationStatusType status; - private final VerificationStatusReasonType reason; - private final VerificationSourceType source; - - public VerificationResultEvent( - String id, - VerificationMethodType method, - Identity identity, - VerificationReference reference, - String custom, - VerificationStatusType status, - VerificationStatusReasonType reason, - VerificationSourceType source) { - super(id, method, identity, reference, custom); - - this.status = status; - this.reason = reason; - this.source = source; - } - - /** - * The status of the verification request - * - * @return Status value - * @since 1.0 - */ - public VerificationStatusType getStatus() { - return status; - } - - /** - * Displays the reason why a verification has FAILED, was DENIED, or was ABORTED - * - * @return reason value - * @since 1.0 - */ - public Optional getReason() { - return Optional.ofNullable(reason); - } - - /** - * Used to show if the call/SMS was intercepted or not - * - * @return Type value - * @since 1.0 - */ - public Optional getSource() { - return Optional.ofNullable(source); - } - - @Override - public String toString() { - return "VerificationResultEvent{" - + "status=" - + status - + ", reason=" - + reason - + ", source='" - + source - + '\'' - + "} " - + super.toString(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/package-info.java deleted file mode 100644 index 6cc0c7fbb..000000000 --- a/client/src/main/com/sinch/sdk/domains/verification/models/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Verification API webhooks (callback) related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.verification.models.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/voice/ApplicationsService.java b/client/src/main/com/sinch/sdk/domains/voice/ApplicationsService.java deleted file mode 100644 index 0dcb9fd75..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/ApplicationsService.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.sinch.sdk.domains.voice; - -import com.sinch.sdk.domains.voice.models.CallbackUrls; -import com.sinch.sdk.domains.voice.models.NumberInformation; -import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters; -import com.sinch.sdk.domains.voice.models.response.AssignedNumbers; -import com.sinch.sdk.domains.voice.models.v1.applications.Callbacks; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UnAssignNumberRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UpdateNumbersRequest; -import com.sinch.sdk.models.E164PhoneNumber; - -/** - * You can use the API to manage features of applications in your project. - * - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.ApplicationsService} instead. - */ -@Deprecated -public interface ApplicationsService { - - /** - * Get information about your numbers. - * - *

It returns a list of numbers that you own, as well as their capability (voice or SMS). For - * the ones that are assigned to an app, it returns the application key of the app. - * - * @return Your numbers - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.ApplicationsService#listNumbers()} - * instead. - */ - @Deprecated - AssignedNumbers listNumbers(); - - /** - * Returns any callback URLs configured for the specified application - * - * @param applicationKey The unique identifying key of the application - * @return Assigned callback to application - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ApplicationsService#getCallbackUrls(String)} instead. - */ - @Deprecated - CallbackUrls getCallbackUrls(String applicationKey); - - /** - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ApplicationsService#updateCallbackUrls(String, - * Callbacks)} instead. - */ - @Deprecated - void updateCallbackUrls(String applicationKey, CallbackUrls parameters); - - /** - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ApplicationsService#queryNumber(String)} instead. - */ - @Deprecated - NumberInformation queryNumber(E164PhoneNumber number); - - /** - * Update or assign a list of numbers to an application. - * - * @param parameters Request parameters - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ApplicationsService#assignNumbers(UpdateNumbersRequest)} - * instead. - */ - @Deprecated - void assignNumbers(ApplicationsAssignNumbersRequestParameters parameters); - - /** - * Un-assign a number from an application. - * - * @param phoneNumber The phone number - * @param applicationKey Indicates the application where the number was assigned. - *

If empty, the application key that is used to authenticate - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ApplicationsService#unassignNumber(UnAssignNumberRequest)} - * instead. - * @since 1.0 - */ - @Deprecated - public void unassignNumber(E164PhoneNumber phoneNumber, String applicationKey); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/CalloutsService.java b/client/src/main/com/sinch/sdk/domains/voice/CalloutsService.java deleted file mode 100644 index 8944637bd..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/CalloutsService.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.sinch.sdk.domains.voice; - -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParameters; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersCustom; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersTTS; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequest; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS; - -/** - * A callout is a call made to a phone number or app using the API. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callouts - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.CalloutsService} instead. - */ -@Deprecated -public interface CalloutsService { - - /** - * The text-to-speech callout calls a phone number and plays a synthesized text messages or - * pre-recorded sound files. - * - * @param parameters Text to speech parameters - * @return The returned call identifier (callId) - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.CalloutsService#textToSpeech(CalloutRequestTTS)} - * instead. - */ - @Deprecated - String textToSpeech(CalloutRequestParametersTTS parameters); - - /** - * The conference callout calls a phone number or a user. When the call is answered, it's - * connected to a conference room. - * - * @param parameters Conference parameters - * @return The returned call identifier (callId) - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.CalloutsService#conference(CalloutRequestConference)} - * instead. - */ - @Deprecated - String conference(CalloutRequestParametersConference parameters); - - /** - * The custom callout, the server initiates a call from the servers that can be controlled by - * specifying how the call should progress at each call event. - * - * @param parameters Custom parameters - * @return The returned call identifier (callId) - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.CalloutsService#custom(CalloutRequestCustom)} instead. - */ - @Deprecated - String custom(CalloutRequestParametersCustom parameters); - - /** - * Makes a call out to a phone number. The types of callouts currently supported are conference - * callouts, text-to-speech callouts, and custom callouts. The custom callout is the most - * flexible, but text-to-speech and conference callouts are more convenient. - * - * @param parameters Callout type to be performed - * @return The returned call identifier (callId) - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.CalloutsService#call(CalloutRequest)} - * instead. - */ - @Deprecated - String call(CalloutRequestParameters parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/CallsService.java deleted file mode 100644 index ec9a2d58f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/CallsService.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.voice; - -import com.sinch.sdk.domains.voice.models.CallLegType; -import com.sinch.sdk.domains.voice.models.response.CallInformation; -import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; -import com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; - -/** - * Using the Calls service, you can manage on-going calls or retrieve information about a call. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Calls - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.CallsService} instead. - */ -@Deprecated -public interface CallsService { - - /** - * You can retrieve information about an ongoing or completed call using a call ID. You can find - * the call ID of an ongoing call by viewing the response object from a callout request. You can - * find the call ID of a completed call by looking at your call logs in your Sinch Dashboard. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @return Information about the call - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.CallsService#get(String)} instead. - */ - @Deprecated - CallInformation get(String callId); - - /** - * This method is used to manage ongoing, connected calls. This method uses SVAML in the request - * body to perform various tasks related to the call. For more information about SVAML, see the - * Callback API documentation. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Tasks to be used related to this call - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.CallsService#update(String, - * SvamlControl)} instead. - */ - @Deprecated - void update(String callId, SVAMLControl parameters); - - /** - * This method is used to manage ongoing, connected calls. This method is only used when using the - * PlayFiles and Say instructions in the request body. This method uses SVAML in the request body - * to perform various tasks related to the call. For more information about SVAML, see the - * Callback API documentation. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Tasks to be used related to this call - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.CallsService#manageWithCallLeg(String, CallLeg, - * SvamlControl)} instead. - */ - @Deprecated - void manageWithCallLeg(String callId, CallLegType callLeg, SVAMLControl parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/ConferencesService.java b/client/src/main/com/sinch/sdk/domains/voice/ConferencesService.java deleted file mode 100644 index aee8aef8c..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/ConferencesService.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.sinch.sdk.domains.voice; - -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; -import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantRequestParameters; -import com.sinch.sdk.domains.voice.models.response.ConferenceParticipant; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest; -import java.util.Collection; - -/** - * Using the Conferences endpoint, you can perform tasks like retrieving information about an - * on-going conference, muting or unmuting participants, or removing participants from a conference. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Conferences - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.ConferencesService} instead. - */ -@Deprecated -public interface ConferencesService { - - /** - * Calls a phone number or a user to join a conference. When the call is answered, it's connected - * to a conference room. - * - * @param parameters Conference parameters - * @return The returned call identifier (callId) - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ConferencesService#call(CalloutRequestConference)} - * instead. - */ - @Deprecated - String call(CalloutRequestParametersConference parameters); - - /** - * Returns information about a conference that matches the provided conference ID. - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @return The list of participants joined the conference - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.ConferencesService#get(String)} - * instead. - */ - @Deprecated - Collection get(String conferenceId); - - /** - * Removes all participants from a conference - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.ConferencesService#kickAll(String)} - * instead. - */ - @Deprecated - void kickAll(String conferenceId); - - /** - * Remove a specified conference participant from a specified conference - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @param callId The unique identifier of the call. This value is generated by the system - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ConferencesService#kickParticipant(String, String)} - * instead. - */ - @Deprecated - void kickParticipant(String conferenceId, String callId); - - /** - * Manages conference participant in a specified conference: - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Parameters to manage participant - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.ConferencesService#manageParticipant(String, String, - * ManageConferenceParticipantRequest)} instead. - */ - @Deprecated - void manageParticipant( - String conferenceId, String callId, ConferenceManageParticipantRequestParameters parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java index 7235c4e90..3f386380f 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java @@ -17,54 +17,4 @@ public interface VoiceService { * @since 1.1 */ com.sinch.sdk.domains.voice.api.v1.VoiceService v1(); - - /** - * Callouts Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.VoiceService#callouts()} instead. - */ - @Deprecated - CalloutsService callouts(); - - /** - * Conference Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.VoiceService#conferences()} instead. - */ - @Deprecated - ConferencesService conferences(); - - /** - * Calls Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.VoiceService#calls()} instead. - */ - @Deprecated - CallsService calls(); - - /** - * Applications Service instance - * - * @return service instance for project - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.VoiceService#applications()} instead. - */ - @Deprecated - ApplicationsService applications(); - - /** - * Webhooks helpers instance - * - * @return instance service related to webhooks helpers - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.VoiceService#webhooks()} instead. - */ - @Deprecated - WebHooksService webhooks(); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java deleted file mode 100644 index 16c7c7557..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.sinch.sdk.domains.voice; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; -import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; -import java.util.Map; - -/** - * Webhooks service - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.WebHooksService} instead. - */ -@Deprecated -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed using your Application key and secret pair - * found on your dashboard. The signature is included in the Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param method The HTTP method used ot handle the callback - * @param path The path to you backend endpoint used for callback - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see https://developers.sinch.com/docs/voice/api-reference/authentication/callback-signed-request/ - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.WebHooksService#validateAuthenticationHeader(String, - * String, Map, String)} instead. - */ - @Deprecated - boolean validateAuthenticatedRequest( - String method, String path, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback onto proper java - * Voice event class - * - * @param jsonPayload Received payload to be deserialized - * @return The Voice event instance class - *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.0 - * @deprecated use {@link com.sinch.sdk.domains.voice.api.v1.WebHooksService#parseEvent(String)} - * instead. - */ - @Deprecated - WebhooksEvent unserializeWebhooksEvent(String jsonPayload) throws ApiMappingException; - - /** - * This function can be called to serialize a Voice response to be sent as JSON - * - * @param response The response to be serialized - * @return The JSON string to be sent - *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.0 - * @deprecated use {@link - * com.sinch.sdk.domains.voice.api.v1.WebHooksService#serializeResponse(SvamlControl)} - * instead. - */ - @Deprecated - String serializeWebhooksResponse(SVAMLControl response) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/ApplicationsService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/ApplicationsService.java deleted file mode 100644 index 5ad7b1189..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/ApplicationsService.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters; - -import com.sinch.sdk.domains.voice.adapters.converters.ApplicationsDtoConverter; -import com.sinch.sdk.domains.voice.models.CallbackUrls; -import com.sinch.sdk.domains.voice.models.NumberInformation; -import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters; -import com.sinch.sdk.domains.voice.models.response.AssignedNumbers; -import com.sinch.sdk.models.E164PhoneNumber; - -public class ApplicationsService implements com.sinch.sdk.domains.voice.ApplicationsService { - - private final com.sinch.sdk.domains.voice.api.v1.ApplicationsService v1; - - public ApplicationsService(com.sinch.sdk.domains.voice.api.v1.ApplicationsService v1) { - this.v1 = v1; - } - - public AssignedNumbers listNumbers() { - return ApplicationsDtoConverter.convert(v1.listNumbers()); - } - - public CallbackUrls getCallbackUrls(String applicationKey) { - return ApplicationsDtoConverter.convert(v1.getCallbackUrls(applicationKey)); - } - - public void updateCallbackUrls(String applicationKey, CallbackUrls parameters) { - v1.updateCallbackUrls(applicationKey, ApplicationsDtoConverter.convert(parameters)); - } - - public NumberInformation queryNumber(E164PhoneNumber number) { - return ApplicationsDtoConverter.convert(v1.queryNumber(number.stringValue())); - } - - public void assignNumbers(ApplicationsAssignNumbersRequestParameters parameters) { - v1.assignNumbers(ApplicationsDtoConverter.convert(parameters)); - } - - public void unassignNumber(E164PhoneNumber phoneNumber, String applicationKey) { - v1.unassignNumber(ApplicationsDtoConverter.convert(phoneNumber, applicationKey)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/CalloutsService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/CalloutsService.java deleted file mode 100644 index d8c844801..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/CalloutsService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters; - -import com.sinch.sdk.domains.voice.adapters.converters.CalloutsDtoConverter; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParameters; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersCustom; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersTTS; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS; - -public class CalloutsService implements com.sinch.sdk.domains.voice.CalloutsService { - - private final com.sinch.sdk.domains.voice.api.v1.CalloutsService v1; - - public CalloutsService(com.sinch.sdk.domains.voice.api.v1.CalloutsService v1) { - this.v1 = v1; - } - - public String textToSpeech(CalloutRequestParametersTTS parameters) { - - return v1.textToSpeech((CalloutRequestTTS) CalloutsDtoConverter.convert(parameters)); - } - - public String conference(CalloutRequestParametersConference parameters) { - - return v1.conference((CalloutRequestConference) CalloutsDtoConverter.convert(parameters)); - } - - public String custom(CalloutRequestParametersCustom parameters) { - - return v1.custom((CalloutRequestCustom) CalloutsDtoConverter.convert(parameters)); - } - - public String call(CalloutRequestParameters parameters) { - - return v1.call(CalloutsDtoConverter.convert(parameters)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java deleted file mode 100644 index 7742f210b..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters; - -import com.sinch.sdk.domains.voice.adapters.converters.CallsDtoConverter; -import com.sinch.sdk.domains.voice.adapters.converters.ControlDtoConverter; -import com.sinch.sdk.domains.voice.models.CallLegType; -import com.sinch.sdk.domains.voice.models.response.CallInformation; -import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; -import com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg; - -public class CallsService implements com.sinch.sdk.domains.voice.CallsService { - - private final com.sinch.sdk.domains.voice.api.v1.CallsService v1; - - public CallsService(com.sinch.sdk.domains.voice.api.v1.CallsService v1) { - this.v1 = v1; - } - - public CallInformation get(String callId) { - return CallsDtoConverter.convert(v1.get(callId)); - } - - public void update(String callId, SVAMLControl parameters) { - v1.update(callId, ControlDtoConverter.convertControl(parameters)); - } - - public void manageWithCallLeg(String callId, CallLegType callLeg, SVAMLControl parameters) { - v1.manageWithCallLeg( - callId, CallLeg.from(callLeg.value()), ControlDtoConverter.convertControl(parameters)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/ConferencesService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/ConferencesService.java deleted file mode 100644 index f1801d432..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/ConferencesService.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters; - -import com.sinch.sdk.domains.voice.adapters.converters.CalloutsDtoConverter; -import com.sinch.sdk.domains.voice.adapters.converters.ConferencesDtoConverter; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; -import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantRequestParameters; -import com.sinch.sdk.domains.voice.models.response.ConferenceParticipant; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import java.util.Collection; - -public class ConferencesService implements com.sinch.sdk.domains.voice.ConferencesService { - - private final com.sinch.sdk.domains.voice.api.v1.ConferencesService v1; - - public ConferencesService(com.sinch.sdk.domains.voice.api.v1.ConferencesService v1) { - this.v1 = v1; - } - - public String call(CalloutRequestParametersConference parameters) { - return v1.call((CalloutRequestConference) CalloutsDtoConverter.convert(parameters)); - } - - public Collection get(String conferenceId) { - return ConferencesDtoConverter.convert(v1.get(conferenceId)); - } - - public void kickAll(String conferenceId) { - v1.kickAll(conferenceId); - } - - public void kickParticipant(String conferenceId, String callId) { - v1.kickParticipant(conferenceId, callId); - } - - public void manageParticipant( - String conferenceId, String callId, ConferenceManageParticipantRequestParameters parameters) { - v1.manageParticipant(conferenceId, callId, ConferencesDtoConverter.convert(parameters)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java index b541ff0c9..8037bf697 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java @@ -1,71 +1,37 @@ package com.sinch.sdk.domains.voice.adapters; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.voice.ApplicationsService; -import com.sinch.sdk.domains.voice.CalloutsService; -import com.sinch.sdk.domains.voice.WebHooksService; import com.sinch.sdk.models.ApplicationCredentials; import com.sinch.sdk.models.VoiceContext; import java.util.function.Supplier; public class VoiceService implements com.sinch.sdk.domains.voice.VoiceService { - private CalloutsService callouts; - private ConferencesService conferences; - private CallsService calls; - private ApplicationsService applications; - private WebHooksService webhooks; + private final ApplicationCredentials credentials; + private final VoiceContext context; + private final Supplier httpClientSupplier; - private final com.sinch.sdk.domains.voice.api.v1.VoiceService v1; + private volatile com.sinch.sdk.domains.voice.api.v1.VoiceService v1; public VoiceService( ApplicationCredentials credentials, VoiceContext context, Supplier httpClientSupplier) { - - this.v1 = - new com.sinch.sdk.domains.voice.api.v1.adapters.VoiceService( - credentials, context, httpClientSupplier); - } - - public CalloutsService callouts() { - if (null == this.callouts) { - this.callouts = new com.sinch.sdk.domains.voice.adapters.CalloutsService(v1().callouts()); - } - return this.callouts; - } - - public ConferencesService conferences() { - if (null == this.conferences) { - this.conferences = - new com.sinch.sdk.domains.voice.adapters.ConferencesService(v1.conferences()); - } - return this.conferences; - } - - public CallsService calls() { - if (null == this.calls) { - this.calls = new com.sinch.sdk.domains.voice.adapters.CallsService(v1.calls()); - } - return this.calls; - } - - public ApplicationsService applications() { - if (null == this.applications) { - this.applications = - new com.sinch.sdk.domains.voice.adapters.ApplicationsService(v1.applications()); - } - return this.applications; - } - - public WebHooksService webhooks() { - if (null == this.webhooks) { - this.webhooks = new com.sinch.sdk.domains.voice.adapters.WebHooksService(v1.webhooks()); - } - return this.webhooks; + this.credentials = credentials; + this.context = context; + this.httpClientSupplier = httpClientSupplier; } public com.sinch.sdk.domains.voice.api.v1.VoiceService v1() { + if (null == this.v1) { + synchronized (this) { + if (null == this.v1) { + this.v1 = + new com.sinch.sdk.domains.voice.api.v1.adapters.VoiceService( + credentials, context, httpClientSupplier); + } + } + } return this.v1; } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java deleted file mode 100644 index aee3781e3..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.voice.adapters.converters.ControlDtoConverter; -import com.sinch.sdk.domains.voice.adapters.converters.WebhooksEventDtoConverter; -import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; -import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; -import java.util.Map; - -public class WebHooksService implements com.sinch.sdk.domains.voice.WebHooksService { - - private final com.sinch.sdk.domains.voice.api.v1.WebHooksService v1; - - public WebHooksService(com.sinch.sdk.domains.voice.api.v1.WebHooksService v1) { - this.v1 = v1; - } - - public boolean validateAuthenticatedRequest( - String method, String path, Map headers, String jsonPayload) { - - return v1.validateAuthenticationHeader(method, path, headers, jsonPayload); - } - - @Override - public WebhooksEvent unserializeWebhooksEvent(String jsonPayload) throws ApiMappingException { - return WebhooksEventDtoConverter.convert(v1.parseEvent(jsonPayload)); - } - - @Override - public String serializeWebhooksResponse(SVAMLControl response) throws ApiMappingException { - return v1.serializeResponse(ControlDtoConverter.convertControl(response)); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ApplicationsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ApplicationsDtoConverter.java deleted file mode 100644 index ff6708b3f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ApplicationsDtoConverter.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.voice.models.ApplicationAssignedNumber; -import com.sinch.sdk.domains.voice.models.ApplicationURL; -import com.sinch.sdk.domains.voice.models.CallbackUrls; -import com.sinch.sdk.domains.voice.models.NumberInformation; -import com.sinch.sdk.domains.voice.models.requests.ApplicationsAssignNumbersRequestParameters; -import com.sinch.sdk.domains.voice.models.response.AssignedNumbers; -import com.sinch.sdk.domains.voice.models.v1.applications.Callbacks; -import com.sinch.sdk.domains.voice.models.v1.applications.CallbacksUrl; -import com.sinch.sdk.domains.voice.models.v1.applications.Capability; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UnAssignNumberRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UpdateNumbersRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.response.OwnedNumberInformation; -import com.sinch.sdk.domains.voice.models.v1.applications.response.OwnedNumbersResponse; -import com.sinch.sdk.domains.voice.models.v1.applications.response.QueryNumberInformation; -import com.sinch.sdk.domains.voice.models.v1.applications.response.QueryNumberResponse; -import com.sinch.sdk.models.E164PhoneNumber; -import java.util.List; -import java.util.stream.Collectors; - -public class ApplicationsDtoConverter { - - public static AssignedNumbers convert(OwnedNumbersResponse dto) { - if (null == dto) { - return null; - } - List list = dto.getNumbers(); - if (null == list) { - return null; - } - return AssignedNumbers.builder() - .setNumbers( - list.stream().map(ApplicationsDtoConverter::convert).collect(Collectors.toList())) - .build(); - } - - public static CallbackUrls convert(Callbacks dto) { - if (null == dto) { - return null; - } - - return CallbackUrls.builder().setUrl(convert(dto.getUrl())).build(); - } - - public static Callbacks convert(CallbackUrls client) { - if (null == client || null == client.getUrl()) { - return null; - } - return Callbacks.builder() - .setUrl( - CallbacksUrl.builder() - .setPrimary(client.getUrl().getPrimary()) - .setFallback(client.getUrl().getFallback()) - .build()) - .build(); - } - - public static NumberInformation convert(QueryNumberResponse dto) { - if (null == dto) { - return null; - } - NumberInformation.Builder builder = NumberInformation.builder(); - QueryNumberInformation item = dto.getNumber(); - if (null == item) { - return builder.build(); - } - - return builder - .setCountryId(item.getCountryId()) - .setNumberType(NumberTypeDtoConverter.convert(item.getNumberType())) - .setNormalizedNumber(E164PhoneNumberDtoConverter.convert(item.getNormalizedNumber())) - .setRestricted(item.getRestricted()) - .setRate(PriceDtoConverter.convert(item.getRate())) - .build(); - } - - public static UpdateNumbersRequest convert(ApplicationsAssignNumbersRequestParameters client) { - if (null == client) { - return null; - } - UpdateNumbersRequest.Builder dto = UpdateNumbersRequest.builder(); - client - .getNumbers() - .ifPresent( - f -> - dto.setNumbers( - f.stream().map(E164PhoneNumber::stringValue).collect(Collectors.toList()))); - client.getApplicationKey().ifPresent(dto::setApplicationKey); - client - .getCapability() - .ifPresent(f -> dto.setCapability(Capability.from(EnumDynamicConverter.convert(f)))); - return dto.build(); - } - - public static UnAssignNumberRequest convert(E164PhoneNumber phoneNumber, String applicationKey) { - - UnAssignNumberRequest.Builder dto = UnAssignNumberRequest.builder(); - if (null != phoneNumber) { - dto.setNumber(phoneNumber.stringValue()); - } - dto.setApplicationKey(applicationKey); - return dto.build(); - } - - private static ApplicationURL convert(CallbacksUrl dto) { - if (null == dto) { - return null; - } - - return ApplicationURL.builder() - .setPrimary(dto.getPrimary()) - .setFallback(dto.getFallback()) - .build(); - } - - private static ApplicationAssignedNumber convert(OwnedNumberInformation dto) { - if (null == dto) { - return null; - } - - return ApplicationAssignedNumber.builder() - .setNumber(E164PhoneNumberDtoConverter.convert(dto.getNumber())) - .setApplicationKey(dto.getApplicationKey()) - .setCapability(CapabilityDtoConverter.convert(dto.getCapability())) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java deleted file mode 100644 index 8c3af8186..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParameters; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersCustom; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersTTS; -import com.sinch.sdk.domains.voice.models.v1.Domain; -import com.sinch.sdk.domains.voice.models.v1.MusicOnHold; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequest; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS; -import com.sinch.sdk.domains.voice.models.v1.callouts.response.CalloutResponse; -import com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceDtmfOptions; -import com.sinch.sdk.domains.voice.models.v1.destination.Destination; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationConference; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationCustom; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationTextToSpeech; -import com.sinch.sdk.models.DualToneMultiFrequency; -import java.util.logging.Logger; - -public class CalloutsDtoConverter { - - private static final Logger LOGGER = Logger.getLogger(CalloutsDtoConverter.class.getName()); - - public static CalloutRequest convert(CalloutRequestParameters client) { - - if (client instanceof CalloutRequestParametersConference) { - CalloutRequestParametersConference parameters = (CalloutRequestParametersConference) client; - return convert(parameters); - } else if (client instanceof CalloutRequestParametersTTS) { - CalloutRequestParametersTTS parameters = (CalloutRequestParametersTTS) client; - return convert(parameters); - } else if (client instanceof CalloutRequestParametersCustom) { - CalloutRequestParametersCustom parameters = (CalloutRequestParametersCustom) client; - return convert(parameters); - } - return null; - } - - public static String convert(CalloutResponse dto) { - if (null == dto) { - return null; - } - return dto.getCallId(); - } - - private static CalloutRequestConference convert(CalloutRequestParametersConference client) { - - CalloutRequestConference.Builder dto = CalloutRequestConference.builder(); - - client - .getDestination() - .ifPresent( - f -> { - Destination destination = DestinationDtoConverter.convert(f); - if (destination instanceof DestinationConference) { - dto.setDestination((DestinationConference) destination); - return; - } - LOGGER.severe(String.format("Unexpected class: %s", f)); - }); - client.getCli().ifPresent(f -> dto.setCli(f.stringValue())); - client.getDtfm().ifPresent(f -> dto.setDtmf(DualToneMultiFrequency.valueOf(f.stringValue()))); - client.getCustom().ifPresent(dto::setCustom); - - client.getConferenceId().ifPresent(dto::setConferenceId); - client.getDtfmOptions().ifPresent(f -> dto.setConferenceDtmfOptions(convert(f))); - - client.getMaxDuration().ifPresent(dto::setMaxDuration); - client.getEnableAce().ifPresent(dto::setEnableAce); - client.getEnableDice().ifPresent(dto::setEnableDice); - client.getEnablePie().ifPresent(dto::setEnablePie); - client.getLocale().ifPresent(dto::setLocale); - client.getGreeting().ifPresent(dto::setGreeting); - client - .getMusicOnHold() - .ifPresent(f -> dto.setMusicOnHold(MusicOnHold.from(EnumDynamicConverter.convert(f)))); - client.getDomain().ifPresent(f -> dto.setDomain(Domain.from(EnumDynamicConverter.convert(f)))); - - return dto.build(); - } - - private static CalloutRequestTTS convert(CalloutRequestParametersTTS client) { - - CalloutRequestTTS.Builder dto = CalloutRequestTTS.builder(); - - client - .getDestination() - .ifPresent( - f -> { - Destination destination = DestinationDtoConverter.convert(f); - if (destination instanceof DestinationTextToSpeech) { - dto.setDestination((DestinationTextToSpeech) destination); - return; - } - LOGGER.severe(String.format("Unexpected class: %s", f)); - }); - client.getCli().ifPresent(f -> dto.setCli(f.stringValue())); - client.getDtfm().ifPresent(f -> dto.setDtmf(DualToneMultiFrequency.valueOf(f.stringValue()))); - client.getCustom().ifPresent(dto::setCustom); - client.getEnableAce().ifPresent(dto::setEnableAce); - client.getEnableDice().ifPresent(dto::setEnableDice); - client.getEnablePie().ifPresent(dto::setEnablePie); - client.getLocale().ifPresent(dto::setLocale); - client.getDomain().ifPresent(f -> dto.setDomain(Domain.from(EnumDynamicConverter.convert(f)))); - client.getText().ifPresent(dto::setText); - client.getPrompts().ifPresent(dto::setPrompts); - return dto.build(); - } - - private static CalloutRequestCustom convert(CalloutRequestParametersCustom client) { - - CalloutRequestCustom.Builder dto = CalloutRequestCustom.builder(); - - client - .getDestination() - .ifPresent( - f -> { - Destination destination = DestinationDtoConverter.convert(f); - if (destination instanceof DestinationCustom) { - dto.setDestination((DestinationCustom) destination); - return; - } - LOGGER.severe(String.format("Unexpected class: %s", f)); - }); - client.getCli().ifPresent(f -> dto.setCli(f.stringValue())); - client.getDtfm().ifPresent(f -> dto.setDtmf(DualToneMultiFrequency.valueOf(f.stringValue()))); - client.getCustom().ifPresent(dto::setCustom); - client.getMaxDuration().ifPresent(dto::setMaxDuration); - client.getIce().ifPresent(f -> dto.setIce(ControlDtoConverter.convertControl(f))); - client.getAce().ifPresent(f -> dto.setAce(ControlDtoConverter.convertControl(f))); - client.getPie().ifPresent(f -> dto.setPie(ControlDtoConverter.convertControl(f))); - return dto.build(); - } - - private static ConferenceDtmfOptions convert(ConferenceDtfmOptions client) { - ConferenceDtmfOptions.Builder dto = ConferenceDtmfOptions.builder(); - client - .getMode() - .ifPresent( - f -> dto.setMode(ConferenceDtmfOptions.ModeEnum.from(EnumDynamicConverter.convert(f)))); - client.getMaxDigits().ifPresent(dto::setMaxDigits); - client.getTimeoutMills().ifPresent(dto::setTimeoutMills); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java deleted file mode 100644 index 1e013b120..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.CallReasonType; -import com.sinch.sdk.domains.voice.models.CallResultType; -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.response.CallInformation; -import com.sinch.sdk.domains.voice.models.response.CallStatusType; - -public class CallsDtoConverter { - - public static CallInformation convert( - com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation dto) { - if (null == dto) { - return null; - } - return CallInformation.builder() - .setFrom(DestinationDtoConverter.convert(dto.getFrom())) - .setTo(DestinationDtoConverter.convert(dto.getTo())) - .setDomain(null != dto.getDomain() ? DomainType.from(dto.getDomain().value()) : null) - .setCallId(dto.getCallId()) - .setDuration(dto.getDuration()) - .setStatus(null != dto.getStatus() ? CallStatusType.from(dto.getStatus().value()) : null) - .setResult(null != dto.getResult() ? CallResultType.from(dto.getResult().value()) : null) - .setReason(null != dto.getReason() ? CallReasonType.from(dto.getReason().value()) : null) - .setTimeStamp(null != dto.getTimestamp() ? dto.getTimestamp() : null) - .setCustom(null != dto.getCustom() ? dto.getCustom() : null) - .setUserRate(PriceDtoConverter.convert(dto.getUserRate())) - .setDebit(PriceDtoConverter.convert(dto.getDebit())) - .build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CapabilityDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CapabilityDtoConverter.java deleted file mode 100644 index 3b8d265bc..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CapabilityDtoConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.CapabilityType; -import com.sinch.sdk.domains.voice.models.v1.applications.Capability; - -public class CapabilityDtoConverter { - - public static CapabilityType convert(Capability dto) { - if (null == dto) { - return null; - } - return CapabilityType.from(dto.value()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java deleted file mode 100644 index 775bb4af9..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantRequestParameters; -import com.sinch.sdk.domains.voice.models.response.ConferenceParticipant; -import com.sinch.sdk.domains.voice.models.v1.MusicOnHold; -import com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest; -import com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest.CommandEnum; -import com.sinch.sdk.domains.voice.models.v1.conferences.response.GetConferenceInfoResponse; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -public class ConferencesDtoConverter { - - public static Collection convert(GetConferenceInfoResponse dto) { - if (null == dto) { - return null; - } - List list = - dto.getParticipants(); - - return list.stream().map(ConferencesDtoConverter::convert).collect(Collectors.toList()); - } - - private static ConferenceParticipant convert( - com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceParticipant dto) { - - return ConferenceParticipant.builder() - .setCli(dto.getCli()) - .setId(dto.getId()) - .setDuration(dto.getDuration()) - .setMuted(dto.getMuted()) - .setOnhold(dto.getOnHold()) - .build(); - } - - public static ManageConferenceParticipantRequest convert( - ConferenceManageParticipantRequestParameters client) { - - ManageConferenceParticipantRequest.Builder dto = ManageConferenceParticipantRequest.builder(); - client - .getCommand() - .ifPresent(f -> dto.setCommand(CommandEnum.from(EnumDynamicConverter.convert(f)))); - client - .getMusicOnHold() - .ifPresent(f -> dto.setMusicOnHold(MusicOnHold.from(EnumDynamicConverter.convert(f)))); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java deleted file mode 100644 index 3f1fa2bf4..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.requests.Control; -import com.sinch.sdk.domains.voice.models.requests.ControlUrl; -import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; - -public class ControlDtoConverter { - - public static com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl convertControl( - SVAMLControl _client) { - return (com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl) - convertControl((Control) _client); - } - - public static com.sinch.sdk.domains.voice.models.v1.svaml.Control convertControl( - Control _client) { - if (null == _client) { - return null; - } - - if (_client instanceof SVAMLControl) { - SVAMLControl client = (SVAMLControl) _client; - SvamlControl.Builder dto = SvamlControl.builder(); - client - .getInstructions() - .ifPresent(f -> dto.setInstructions(SVAMLInstructionDtoConverter.convert(f))); - client.getAction().ifPresent(f -> dto.setAction(SVAMLActionDtoConverter.convert(f))); - return dto.build(); - } - - if (_client instanceof ControlUrl) { - ControlUrl client = (ControlUrl) _client; - return com.sinch.sdk.domains.voice.models.v1.svaml.ControlUrl.from(client.getURL()); - } - return null; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java deleted file mode 100644 index 143bb3196..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.DestinationNumber; -import com.sinch.sdk.domains.voice.models.DestinationNumberType; -import com.sinch.sdk.domains.voice.models.DestinationSip; -import com.sinch.sdk.domains.voice.models.DestinationUser; -import com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformationFrom; -import com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformationTo; -import com.sinch.sdk.domains.voice.models.v1.destination.Destination; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationDid; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationMxp; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationPstn; -import com.sinch.sdk.models.E164PhoneNumber; -import java.util.logging.Logger; - -public class DestinationDtoConverter { - - private static final Logger LOGGER = Logger.getLogger(DestinationDtoConverter.class.getName()); - - public static Destination convert(com.sinch.sdk.domains.voice.models.Destination client) { - - if (null == client) { - return null; - } - - if (client instanceof DestinationNumber) { - DestinationNumber destination = (DestinationNumber) client; - if (DestinationNumberType.DID.equals(destination.getType())) { - return DestinationDid.from( - null != destination.getPhoneNumber() - ? destination.getPhoneNumber().stringValue() - : null); - } - if (DestinationNumberType.PSTN.equals(destination.getType())) { - return DestinationPstn.from( - null != destination.getPhoneNumber() - ? destination.getPhoneNumber().stringValue() - : null); - } - LOGGER.severe(String.format("Unexpected type '%s': %s", destination.getType(), client)); - return null; - } - - if (client instanceof DestinationUser) { - return DestinationMxp.from(((DestinationUser) client).getUserName()); - } - - if (client instanceof DestinationSip) { - return com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip.from( - ((DestinationSip) client).getSIPAddress()); - } - - LOGGER.severe(String.format("Unexpected class '%s': '%s'", client.getClass(), client)); - return null; - } - - public static com.sinch.sdk.domains.voice.models.Destination convert(Destination dto) { - if (null == dto) { - return null; - } - if (dto instanceof DestinationPstn) { - return new DestinationNumber( - E164PhoneNumber.valueOf(((DestinationPstn) dto).getEndpoint()), - DestinationNumberType.PSTN); - } - if (dto instanceof DestinationMxp) { - return new DestinationUser(((DestinationMxp) dto).getEndpoint()); - } - if (dto instanceof com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip) { - return new DestinationSip( - ((com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip) dto).getEndpoint()); - } - if (dto instanceof DestinationDid) { - return new DestinationNumber( - E164PhoneNumber.valueOf(((DestinationDid) dto).getEndpoint()), DestinationNumberType.DID); - } - - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - return null; - } - - public static com.sinch.sdk.domains.voice.models.Destination convert(CallInformationFrom dto) { - if (null == dto) { - return null; - } - if (!(dto instanceof Destination)) { - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - return null; - } - return convert((Destination) dto); - } - - public static com.sinch.sdk.domains.voice.models.Destination convert(CallInformationTo dto) { - if (null == dto) { - return null; - } - if (!(dto instanceof Destination)) { - LOGGER.severe(String.format("Unexpected class '%s'", dto)); - return null; - } - return convert((Destination) dto); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java deleted file mode 100644 index 7de97808e..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.v1.Domain; - -public class DomainTypeDtoConverter { - - public static DomainType convert(String dto) { - if (null == dto) { - return null; - } - return DomainType.from(dto.toLowerCase()); - } - - public static DomainType convert(Domain dto) { - if (null == dto) { - return null; - } - return DomainType.from(dto.value().toLowerCase()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DualToneMultiFrequencyDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DualToneMultiFrequencyDtoConverter.java deleted file mode 100644 index 163c18456..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DualToneMultiFrequencyDtoConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.models.DualToneMultiFrequency; - -public class DualToneMultiFrequencyDtoConverter { - - public static String convert(DualToneMultiFrequency client) { - if (null == client) { - return null; - } - return client.stringValue(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/E164PhoneNumberDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/E164PhoneNumberDtoConverter.java deleted file mode 100644 index 5b3205b70..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/E164PhoneNumberDtoConverter.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.models.E164PhoneNumber; - -public class E164PhoneNumberDtoConverter { - - public static String convert(E164PhoneNumber client) { - if (null == client) { - return null; - } - return client.stringValue(); - } - - public static E164PhoneNumber convert(String dto) { - if (null == dto) { - return null; - } - return E164PhoneNumber.valueOf(dto); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/NumberTypeDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/NumberTypeDtoConverter.java deleted file mode 100644 index f446da50d..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/NumberTypeDtoConverter.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.NumberType; -import com.sinch.sdk.domains.voice.models.v1.applications.response.QueryNumberInformation.NumberTypeEnum; - -public class NumberTypeDtoConverter { - - public static NumberType convert(NumberTypeEnum dto) { - if (null == dto) { - return null; - } - return NumberType.from(dto.value()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/PriceDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/PriceDtoConverter.java deleted file mode 100644 index caa4a7cb0..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/PriceDtoConverter.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.Price; - -public class PriceDtoConverter { - - public static Price convert(com.sinch.sdk.domains.voice.models.v1.Price 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/voice/adapters/converters/SVAMLActionDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverter.java deleted file mode 100644 index 60a88ead7..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverter.java +++ /dev/null @@ -1,287 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.common.adapters.converters.EnumDynamicConverter; -import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; -import com.sinch.sdk.domains.voice.models.svaml.Action; -import com.sinch.sdk.domains.voice.models.svaml.ActionConnectConference; -import com.sinch.sdk.domains.voice.models.svaml.ActionConnectMxp; -import com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn; -import com.sinch.sdk.domains.voice.models.svaml.ActionConnectSip; -import com.sinch.sdk.domains.voice.models.svaml.ActionContinue; -import com.sinch.sdk.domains.voice.models.svaml.ActionHangUp; -import com.sinch.sdk.domains.voice.models.svaml.ActionPark; -import com.sinch.sdk.domains.voice.models.svaml.ActionRunMenu; -import com.sinch.sdk.domains.voice.models.svaml.AnsweringMachineDetection; -import com.sinch.sdk.domains.voice.models.svaml.MenuOptionAction; -import com.sinch.sdk.domains.voice.models.v1.MusicOnHold; -import com.sinch.sdk.domains.voice.models.v1.conferences.ConferenceDtmfOptions; -import com.sinch.sdk.domains.voice.models.v1.destination.Destination; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationMxp; -import com.sinch.sdk.domains.voice.models.v1.destination.DestinationSip; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.CallHeader; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.ConnectPstnAnsweringMachineDetection; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.Menu; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.MenuOption; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlAction; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectConference; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectMxp; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectPstn; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectPstn.IndicationsEnum; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectSip; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionConnectSip.TransportEnum; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionContinue; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionHangup; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionPark; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.SvamlActionRunMenu; -import java.util.Collection; -import java.util.List; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -public class SVAMLActionDtoConverter { - private static final Logger LOGGER = Logger.getLogger(SVAMLActionDtoConverter.class.getName()); - - public static SvamlAction convert(Action client) { - if (null == client) { - return null; - } - - SvamlAction convertedDto = null; - if (client instanceof ActionConnectConference) { - ActionConnectConference typedClient = (ActionConnectConference) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionConnectMxp) { - ActionConnectMxp typedClient = (ActionConnectMxp) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionConnectPstn) { - ActionConnectPstn typedClient = (ActionConnectPstn) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionConnectSip) { - ActionConnectSip typedClient = (ActionConnectSip) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionContinue) { - ActionContinue typedClient = (ActionContinue) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionHangUp) { - ActionHangUp typedClient = (ActionHangUp) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionPark) { - ActionPark typedClient = (ActionPark) client; - convertedDto = convertAction(typedClient); - } else if (client instanceof ActionRunMenu) { - ActionRunMenu typedClient = (ActionRunMenu) client; - convertedDto = convertAction(typedClient); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); - } - - return convertedDto; - } - - private static SvamlActionConnectConference convertAction(ActionConnectConference client) { - if (null == client) { - return null; - } - SvamlActionConnectConference.Builder dto = SvamlActionConnectConference.builder(); - client.getConferenceId().ifPresent(dto::setConferenceId); - client - .getMusicOnHold() - .ifPresent(f -> dto.setMusicOnHold(MusicOnHold.from(EnumDynamicConverter.convert(f)))); - client.getDtfmOptions().ifPresent(f -> dto.setConferenceDtmfOptions(convert(f))); - return dto.build(); - } - - private static SvamlActionConnectMxp convertAction(ActionConnectMxp client) { - if (null == client) { - return null; - } - SvamlActionConnectMxp.Builder dto = SvamlActionConnectMxp.builder(); - client - .getDestination() - .ifPresent( - f -> { - Destination destination = DestinationDtoConverter.convert(f); - if (!(destination instanceof DestinationMxp)) { - LOGGER.severe(String.format("Unexpected class '%s'", destination)); - return; - } - dto.setDestination((DestinationMxp) destination); - }); - client.getCallheaders().ifPresent(f -> dto.setCallheaders(convertHeaderCollection(f))); - return dto.build(); - } - - private static SvamlActionConnectPstn convertAction(ActionConnectPstn client) { - if (null == client) { - return null; - } - SvamlActionConnectPstn.Builder dto = SvamlActionConnectPstn.builder(); - client.getNumber().ifPresent(f -> dto.setNumber(E164PhoneNumberDtoConverter.convert(f))); - client.getLocale().ifPresent(dto::setLocale); - client.getMaxDuration().ifPresent(dto::setMaxDuration); - client.getDialTimeout().ifPresent(dto::setDialTimeout); - client.getCli().ifPresent(dto::setCli); - client.getSuppressCallbacks().ifPresent(dto::setSuppressCallbacks); - client.getDualToneMultiFrequency().ifPresent(dto::setDtmf); - client - .getIndications() - .ifPresent(f -> dto.setIndications(IndicationsEnum.from(EnumDynamicConverter.convert(f)))); - client.getAnsweringMachineDetection().ifPresent(f -> dto.setAmd(convert(f))); - return dto.build(); - } - - private static SvamlActionConnectSip convertAction(ActionConnectSip client) { - if (null == client) { - return null; - } - SvamlActionConnectSip.Builder dto = SvamlActionConnectSip.builder(); - client - .getDestination() - .ifPresent( - f -> { - Destination destination = DestinationDtoConverter.convert(f); - if (!(destination instanceof DestinationSip)) { - LOGGER.severe(String.format("Unexpected class '%s'", destination)); - return; - } - dto.setDestination((DestinationSip) destination); - }); - client.getMaxDuration().ifPresent(dto::setMaxDuration); - client.getCli().ifPresent(dto::setCli); - client - .getTransport() - .ifPresent(f -> dto.setTransport(TransportEnum.from(EnumDynamicConverter.convert(f)))); - client.getSuppressCallbacks().ifPresent(dto::setSuppressCallbacks); - client.getCallHeaders().ifPresent(f -> dto.setCallHeaders(convertHeaderCollection(f))); - client - .getMusicOnHold() - .ifPresent(f -> dto.setMusicOnHold(MusicOnHold.from(EnumDynamicConverter.convert(f)))); - return dto.build(); - } - - private static SvamlActionContinue convertAction(ActionContinue client) { - if (null == client) { - return null; - } - return SvamlActionContinue.DEFAULT; - } - - private static SvamlActionHangup convertAction(ActionHangUp client) { - if (null == client) { - return null; - } - return SvamlActionHangup.DEFAULT; - } - - private static SvamlActionPark convertAction(ActionPark client) { - if (null == client) { - return null; - } - SvamlActionPark.Builder dto = SvamlActionPark.builder(); - client.getLocale().ifPresent(dto::setLocale); - client.getIntroPrompt().ifPresent(dto::setIntroPrompt); - client.getHoldPrompt().ifPresent(dto::setHoldPrompt); - client.getMaxDuration().ifPresent(dto::setMaxDuration); - - return dto.build(); - } - - private static SvamlActionRunMenu convertAction(ActionRunMenu client) { - if (null == client) { - return null; - } - SvamlActionRunMenu.Builder dto = SvamlActionRunMenu.builder(); - client.getBarge().ifPresent(dto::setBarge); - client.getLocale().ifPresent(dto::setLocale); - client.getMainMenu().ifPresent(dto::setMainMenu); - client.getEnableVoice().ifPresent(dto::setEnableVoice); - client.getMenus().ifPresent(f -> dto.setMenus(convertMenuCollection(f))); - return dto.build(); - } - - private static ConferenceDtmfOptions convert(ConferenceDtfmOptions client) { - if (null == client) { - return null; - } - ConferenceDtmfOptions.Builder builder = ConferenceDtmfOptions.builder(); - client - .getMode() - .ifPresent( - f -> - builder.setMode( - ConferenceDtmfOptions.ModeEnum.from(EnumDynamicConverter.convert(f)))); - client.getMaxDigits().ifPresent(builder::setMaxDigits); - client.getTimeoutMills().ifPresent(builder::setTimeoutMills); - return builder.build(); - } - - private static List convertHeaderCollection(Collection> client) { - if (null == client) { - return null; - } - return client.stream() - .map(f -> CallHeader.builder().setKey(f.getLeft()).setValue(f.getRight()).build()) - .collect(Collectors.toList()); - } - - private static ConnectPstnAnsweringMachineDetection convert(AnsweringMachineDetection client) { - if (null == client) { - return null; - } - - ConnectPstnAnsweringMachineDetection.Builder dto = - ConnectPstnAnsweringMachineDetection.builder(); - - client.getEnabled().ifPresent(dto::setEnabled); - return dto.build(); - } - - private static List

convertMenuCollection( - Collection client) { - if (null == client) { - return null; - } - return client.stream().map(SVAMLActionDtoConverter::convert).collect(Collectors.toList()); - } - - private static Menu convert(com.sinch.sdk.domains.voice.models.svaml.Menu client) { - if (null == client) { - return null; - } - Menu.Builder dto = Menu.builder(); - - client.getId().ifPresent(dto::setId); - client.getMainPrompt().ifPresent(dto::setMainPrompt); - client.getRepeatPrompt().ifPresent(dto::setRepeatPrompt); - client.getRepeats().ifPresent(dto::setRepeats); - client.getMaxDigits().ifPresent(dto::setMaxDigits); - client.getTimeoutMills().ifPresent(dto::setTimeoutMills); - client.getMaxTimeoutMills().ifPresent(dto::setMaxTimeoutMills); - client.getOptions().ifPresent(f -> dto.setOptions(convertMenuOptionCollection(f))); - return dto.build(); - } - - private static List convertMenuOptionCollection( - Collection client) { - if (null == client) { - return null; - } - return client.stream() - .map( - f -> { - MenuOption.Builder dto = MenuOption.builder(); - f.getAction().ifPresent(f2 -> dto.setAction(convert(f2))); - f.getDtfm().ifPresent(dto::setDtmf); - return dto.build(); - }) - .collect(Collectors.toList()); - } - - private static String convert(MenuOptionAction client) { - if (null == client || null == client.getType()) { - return null; - } - return String.format("%s(%s)", client.getType().value(), client.getId()); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java deleted file mode 100644 index 0a1b95f10..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.domains.voice.models.svaml.Instruction; -import com.sinch.sdk.domains.voice.models.svaml.InstructionAnswer; -import com.sinch.sdk.domains.voice.models.svaml.InstructionPlayFiles; -import com.sinch.sdk.domains.voice.models.svaml.InstructionSay; -import com.sinch.sdk.domains.voice.models.svaml.InstructionSendDtfm; -import com.sinch.sdk.domains.voice.models.svaml.InstructionSetCookie; -import com.sinch.sdk.domains.voice.models.svaml.InstructionStartRecording; -import com.sinch.sdk.domains.voice.models.svaml.InstructionStopRecording; -import com.sinch.sdk.domains.voice.models.svaml.StartRecordingOptions; -import com.sinch.sdk.domains.voice.models.svaml.TranscriptionOptions; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstruction; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionAnswer; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionPlayFiles; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSay; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSendDtmf; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionSetCookie; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionStartRecording; -import com.sinch.sdk.domains.voice.models.v1.svaml.instruction.SvamlInstructionStopRecording; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.logging.Logger; -import java.util.stream.Collectors; - -public class SVAMLInstructionDtoConverter { - - private static final Logger LOGGER = - Logger.getLogger(SVAMLInstructionDtoConverter.class.getName()); - - public static List convert(Collection instructions) { - if (null == instructions) { - return null; - } - return instructions.stream() - .map(SVAMLInstructionDtoConverter::convertInstruction) - .collect(Collectors.toList()); - } - - private static SvamlInstruction convertInstruction(Instruction client) { - if (null == client) { - return null; - } - - SvamlInstruction convertedDto = null; - if (client instanceof InstructionAnswer) { - InstructionAnswer typedClient = (InstructionAnswer) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionPlayFiles) { - InstructionPlayFiles typedClient = (InstructionPlayFiles) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionSay) { - InstructionSay typedClient = (InstructionSay) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionSendDtfm) { - InstructionSendDtfm typedClient = (InstructionSendDtfm) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionSetCookie) { - InstructionSetCookie typedClient = (InstructionSetCookie) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionStartRecording) { - InstructionStartRecording typedClient = (InstructionStartRecording) client; - convertedDto = convert(typedClient); - } else if (client instanceof InstructionStopRecording) { - InstructionStopRecording typedClient = (InstructionStopRecording) client; - convertedDto = convert(typedClient); - } else { - LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); - } - - return convertedDto; - } - - private static SvamlInstructionAnswer convert(InstructionAnswer client) { - if (null == client) { - return null; - } - return SvamlInstructionAnswer.DEFAULT; - } - - private static SvamlInstructionPlayFiles convert(InstructionPlayFiles client) { - if (null == client) { - return null; - } - SvamlInstructionPlayFiles.Builder dto = SvamlInstructionPlayFiles.builder(); - client.getIds().ifPresent(f -> dto.setIds(new ArrayList<>(f))); - client.getLocale().ifPresent(dto::setLocale); - return dto.build(); - } - - private static SvamlInstructionSay convert(InstructionSay client) { - if (null == client) { - return null; - } - SvamlInstructionSay.Builder dto = SvamlInstructionSay.builder(); - client.getText().ifPresent(dto::setText); - client.getLocale().ifPresent(dto::setLocale); - return dto.build(); - } - - private static SvamlInstructionSendDtmf convert(InstructionSendDtfm client) { - if (null == client) { - return null; - } - SvamlInstructionSendDtmf.Builder dto = SvamlInstructionSendDtmf.builder(); - client.getTDtfm().ifPresent(f -> dto.setValue(f.stringValue())); - return dto.build(); - } - - private static SvamlInstructionSetCookie convert(InstructionSetCookie client) { - if (null == client) { - return null; - } - SvamlInstructionSetCookie.Builder dto = SvamlInstructionSetCookie.builder(); - dto.setKey(client.getKey()); - dto.setValue(client.getValue()); - return dto.build(); - } - - private static SvamlInstructionStartRecording convert(InstructionStartRecording client) { - if (null == client) { - return null; - } - SvamlInstructionStartRecording.Builder dto = SvamlInstructionStartRecording.builder(); - client.getOptions().ifPresent(f -> dto.setOptions(convert(f))); - return dto.build(); - } - - private static SvamlInstructionStopRecording convert(InstructionStopRecording client) { - if (null == client) { - return null; - } - return SvamlInstructionStopRecording.DEFAULT; - } - - private static com.sinch.sdk.domains.voice.models.v1.svaml.instruction.StartRecordingOptions - convert(StartRecordingOptions client) { - if (null == client) { - return null; - } - com.sinch.sdk.domains.voice.models.v1.svaml.instruction.StartRecordingOptions.Builder dto = - com.sinch.sdk.domains.voice.models.v1.svaml.instruction.StartRecordingOptions.builder(); - - client.getDestinationUrl().ifPresent(dto::setDestinationUrl); - client.getCredentials().ifPresent(dto::setCredentials); - client.getFormat().ifPresent(dto::setFormat); - client.getNotificationEvents().ifPresent(dto::setNotificationEvents); - client.getTranscriptionOptions().ifPresent(f -> dto.setTranscriptionOptions(convert(f))); - return dto.build(); - } - - private static com.sinch.sdk.domains.voice.models.v1.svaml.instruction.TranscriptionOptions - convert(TranscriptionOptions client) { - if (null == client) { - return null; - } - com.sinch.sdk.domains.voice.models.v1.svaml.instruction.TranscriptionOptions.Builder dto = - com.sinch.sdk.domains.voice.models.v1.svaml.instruction.TranscriptionOptions.builder(); - client.getEnabled().ifPresent(dto::setEnabled); - client.getLocale().ifPresent(dto::setLocale); - return dto.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java deleted file mode 100644 index 84a680585..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.sinch.sdk.domains.voice.adapters.converters; - -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.voice.models.CallReasonType; -import com.sinch.sdk.domains.voice.models.CallResultType; -import com.sinch.sdk.domains.voice.models.v1.svaml.action.CallHeader; -import com.sinch.sdk.domains.voice.models.v1.webhooks.AnsweringMachineDetection; -import com.sinch.sdk.domains.voice.models.v1.webhooks.DisconnectedCallEvent; -import com.sinch.sdk.domains.voice.models.v1.webhooks.NotificationEvent; -import com.sinch.sdk.domains.voice.models.v1.webhooks.VoiceWebhookEvent; -import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswer; -import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerReasonType; -import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerStatusType; -import com.sinch.sdk.domains.voice.models.webhooks.AnsweredCallEvent; -import com.sinch.sdk.domains.voice.models.webhooks.DisconnectCallEvent; -import com.sinch.sdk.domains.voice.models.webhooks.IncomingCallEvent; -import com.sinch.sdk.domains.voice.models.webhooks.MenuInputType; -import com.sinch.sdk.domains.voice.models.webhooks.MenuResult; -import com.sinch.sdk.domains.voice.models.webhooks.MenuResultInputMethodType; -import com.sinch.sdk.domains.voice.models.webhooks.NotifyEvent; -import com.sinch.sdk.domains.voice.models.webhooks.PromptInputEvent; -import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -public class WebhooksEventDtoConverter { - - public static WebhooksEvent convert(VoiceWebhookEvent dto) { - - if (null == dto) { - return null; - } - - WebhooksEvent.Builder builder; - - if (dto instanceof com.sinch.sdk.domains.voice.models.v1.webhooks.IncomingCallEvent) { - builder = convert((com.sinch.sdk.domains.voice.models.v1.webhooks.IncomingCallEvent) dto); - } else if (dto instanceof DisconnectedCallEvent) { - builder = convert((DisconnectedCallEvent) dto); - } else if (dto instanceof com.sinch.sdk.domains.voice.models.v1.webhooks.AnsweredCallEvent) { - builder = convert((com.sinch.sdk.domains.voice.models.v1.webhooks.AnsweredCallEvent) dto); - } else if (dto instanceof com.sinch.sdk.domains.voice.models.v1.webhooks.PromptInputEvent) { - builder = convert((com.sinch.sdk.domains.voice.models.v1.webhooks.PromptInputEvent) dto); - } else if (dto instanceof NotificationEvent) { - builder = convert((NotificationEvent) dto); - } else { - throw new ApiException("Unexpected event:" + dto); - } - - return builder.setCallId(dto.getCallid()).setVersion(dto.getVersion()).build(); - } - - private static IncomingCallEvent.Builder convert( - com.sinch.sdk.domains.voice.models.v1.webhooks.IncomingCallEvent dto) { - - IncomingCallEvent.Builder builder = IncomingCallEvent.builder(); - if (null == dto) { - return builder; - } - - return builder - .setTimestamp(dto.getTimestamp()) - .setCustom(dto.getCustom()) - .setCallResourceUrl(dto.getCallResourceUrl()) - .setUserRate(PriceDtoConverter.convert(dto.getUserRate())) - .setCli(dto.getCli()) - .setTo(DestinationDtoConverter.convert(dto.getTo())) - .setDomain(DomainTypeDtoConverter.convert(dto.getDomain())) - .setApplicationKey(dto.getApplicationKey()) - .setOriginationType(DomainTypeDtoConverter.convert(dto.getOriginationType())) - .setDuration(dto.getDuration()) - .setRdnis(dto.getRdnis()) - .setCallHeaders(convertHeaderCollection(dto.getCallHeaders())); - } - - private static DisconnectCallEvent.Builder convert( - com.sinch.sdk.domains.voice.models.v1.webhooks.DisconnectedCallEvent dto) { - - DisconnectCallEvent.Builder builder = DisconnectCallEvent.builder(); - if (null == dto) { - return builder; - } - return builder - .setTimestamp(dto.getTimestamp()) - .setCustom(dto.getCustom()) - .setReason(null != dto.getReason() ? CallReasonType.from(dto.getReason().value()) : null) - .setResult(null != dto.getResult() ? CallResultType.from(dto.getResult().value()) : null) - .setDebit(PriceDtoConverter.convert(dto.getDebit())) - .setUserRate(PriceDtoConverter.convert(dto.getUserRate())) - .setTo(DestinationDtoConverter.convert(dto.getTo())) - .setApplicationKey(dto.getApplicationKey()) - .setDuration(dto.getDuration()) - .setFrom(dto.getFrom()); - } - - private static AnsweredCallEvent.Builder convert( - com.sinch.sdk.domains.voice.models.v1.webhooks.AnsweredCallEvent dto) { - - AnsweredCallEvent.Builder builder = AnsweredCallEvent.builder(); - if (null == dto) { - return builder; - } - return builder - .setTimestamp(dto.getTimestamp()) - .setCustom(dto.getCustom()) - .setAmd(convert(dto.getAmd())); - } - - private static PromptInputEvent.Builder convert( - com.sinch.sdk.domains.voice.models.v1.webhooks.PromptInputEvent dto) { - - PromptInputEvent.Builder builder = PromptInputEvent.builder(); - if (null == dto) { - return builder; - } - return builder - .setTimestamp(dto.getTimestamp()) - .setCustom(dto.getCustom()) - .setApplicationKey(dto.getApplicationKey()) - .setCallId(dto.getCallid()) - .setVersion(dto.getVersion()) - .setMenuResult(convert(dto.getMenuResult())); - } - - private static NotifyEvent.Builder convert( - com.sinch.sdk.domains.voice.models.v1.webhooks.NotificationEvent dto) { - - NotifyEvent.Builder builder = NotifyEvent.builder(); - if (null == dto) { - return builder; - } - return builder - .setCustom(dto.getCustom()) - .setCallId(dto.getCallid()) - .setVersion(dto.getVersion()) - .setType(dto.getType()); - } - - private static AmdAnswer convert(AnsweringMachineDetection dto) { - - if (null == dto) { - return null; - } - AmdAnswer.Builder builder = AmdAnswer.builder().setDuration(dto.getDuration()); - - if (null != dto.getReason()) { - builder.setReason(convertReason(dto.getReason().value())); - } - if (null != dto.getStatus()) { - builder.setStatus(convertStatus(dto.getStatus().value())); - } - return builder.build(); - } - - private static AmdAnswerReasonType convertReason(String dto) { - if (null == dto) { - return null; - } - return AmdAnswerReasonType.from(dto); - } - - private static AmdAnswerStatusType convertStatus(String dto) { - if (null == dto) { - return null; - } - return AmdAnswerStatusType.from(dto); - } - - private static Collection> convertHeaderCollection(List dto) { - if (null == dto) { - return null; - } - return dto.stream().map(f -> new Pair<>(f.getKey(), f.getValue())).collect(Collectors.toList()); - } - - private static MenuResult convert(com.sinch.sdk.domains.voice.models.v1.webhooks.MenuResult dto) { - - MenuResult.Builder builder = - MenuResult.builder().setMenuId(dto.getMenuId()).setValue(dto.getValue()); - - if (null != dto.getType()) { - builder.setType(MenuInputType.from(dto.getType().value())); - } - if (null != dto.getInputMethod()) { - builder.setInputMethod(MenuResultInputMethodType.from(dto.getInputMethod().value())); - } - return builder.build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.java deleted file mode 100644 index 356604b3b..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/ApplicationsService.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1; - -import com.sinch.sdk.domains.voice.models.v1.applications.Callbacks; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UnAssignNumberRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UpdateNumbersRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.response.OwnedNumbersResponse; -import com.sinch.sdk.domains.voice.models.v1.applications.response.QueryNumberResponse; - -/** - * You can use the API to manage features of applications in your project. - * - * @since 1.4 - */ -public interface ApplicationsService { - - /** - * Get information about your numbers. - * - *

It returns a list of numbers that you own, as well as their capability (Voice or SMS). For - * the ones that are assigned to an app, it returns the application key of the app. - * - * @return Your numbers - * @since 1.4 - */ - OwnedNumbersResponse listNumbers(); - - /** - * Returns any callback URLs configured for the specified application - * - * @param applicationKey The unique identifying key of the application - * @return Assigned callback to application - * @since 1.4 - */ - Callbacks getCallbackUrls(String applicationKey); - - /** - * Update the configured callback URLs for the specified application. - * - * @param applicationKey The unique identifying key of the application - * @param parameters Callbacks settings - * @since 1.4 - */ - void updateCallbackUrls(String applicationKey, Callbacks parameters); - - /** - * Returns information about the requested number - * - * @param number The phone number you want to query - * @return Number information - */ - QueryNumberResponse queryNumber(String number); - - /** - * Update or assign a list of numbers to an application. - * - * @param parameters Request parameters - * @since 1.4 - */ - void assignNumbers(UpdateNumbersRequest parameters); - - /** - * Un-assign a number from an application. - * - * @param parameters Request parameters - * @since 1.4 - */ - public void unassignNumber(UnAssignNumberRequest parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/CalloutsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/CalloutsService.java deleted file mode 100644 index 12a71528f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/CalloutsService.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1; - -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequest; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS; - -/** - * A callout is a call made to a phone number or app using the API. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callouts - * @since 1.4 - */ -public interface CalloutsService { - - /** - * The text-to-speech callout calls a phone number and plays a synthesized text messages or - * pre-recorded sound files. - * - * @param parameters Text to speech parameters - * @return The returned call identifier (callId) - * @since 1.4 - */ - String textToSpeech(CalloutRequestTTS parameters); - - /** - * The conference callout calls a phone number or a user. When the call is answered, it's - * connected to a conference room. - * - * @param parameters Conference parameters - * @return The returned call identifier (callId) - * @since 1.4 - */ - String conference(CalloutRequestConference parameters); - - /** - * The custom callout, the server initiates a call from the servers that can be controlled by - * specifying how the call should progress at each call event. - * - * @param parameters Custom parameters - * @return The returned call identifier (callId) - * @since 1.4 - */ - String custom(CalloutRequestCustom parameters); - - /** - * Makes a call out to a phone number. The types of callouts currently supported are conference - * callouts, text-to-speech callouts, and custom callouts. The custom callout is the most - * flexible, but text-to-speech and conference callouts are more convenient. - * - * @param parameters Callout type to be performed - * @return The returned call identifier (callId) - * @since 1.4 - */ - String call(CalloutRequest parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/CallsService.java deleted file mode 100644 index 70cd10e55..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/CallsService.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1; - -import com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg; -import com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; - -/** - * Using the Calls service, you can manage on-going calls or retrieve information about a call. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Calls - * @since 1.4 - */ -public interface CallsService { - - /** - * You can retrieve information about an ongoing or completed call using a call ID. You can find - * the call ID of an ongoing call by viewing the response object from a callout request. You can - * find the call ID of a completed call by looking at your call logs in your Sinch Dashboard. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @return Information about the call - * @since 1.4 - */ - CallInformation get(String callId); - - /** - * This method is used to manage ongoing, connected calls. This method uses SVAML in the request - * body to perform various tasks related to the call. For more information about SVAML, see the - * Callback API documentation. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Tasks to be used related to this call - * @since 1.4 - */ - void update(String callId, SvamlControl parameters); - - /** - * This method is used to manage ongoing, connected calls. This method is only used when using the - * PlayFiles and Say instructions in the request body. This method uses SVAML in the request body - * to perform various tasks related to the call. For more information about SVAML, see the - * Callback API documentation. - * - *

Note: You can only use this method for calls that terminate to PSTN or SIP networks from an - * In-app call. - * - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Tasks to be used related to this call - * @since 1.4 - */ - void manageWithCallLeg(String callId, CallLeg callLeg, SvamlControl parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/ConferencesService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/ConferencesService.java deleted file mode 100644 index 4d30b0821..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/ConferencesService.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1; - -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest; -import com.sinch.sdk.domains.voice.models.v1.conferences.response.GetConferenceInfoResponse; - -/** - * Using the Conferences endpoint, you can perform tasks like retrieving information about an - * on-going conference, muting or unmuting participants, or removing participants from a conference. - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Conferences - * @since 1.4 - */ -public interface ConferencesService { - - /** - * Calls a phone number or a user to join a conference. When the call is answered, it's connected - * to a conference room. - * - * @param parameters Conference parameters - * @return The returned call identifier (callId) - * @since 1.4 - */ - String call(CalloutRequestConference parameters); - - /** - * Returns information about a conference that matches the provided conference ID. - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @return The list of participants joined the conference - * @since 1.4 - */ - GetConferenceInfoResponse get(String conferenceId); - - /** - * Removes all participants from a conference - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @since 1.4 - */ - void kickAll(String conferenceId); - - /** - * Remove a specified conference participant from a specified conference - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @param callId The unique identifier of the call. This value is generated by the system - * @since 1.4 - */ - void kickParticipant(String conferenceId, String callId); - - /** - * Manages conference participant in a specified conference: - * - * @param conferenceId The unique identifier of the conference. The user sets this value. - * @param callId The unique identifier of the call. This value is generated by the system - * @param parameters Parameters to manage participant - * @since 1.4 - */ - void manageParticipant( - String conferenceId, String callId, ManageConferenceParticipantRequest parameters); -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/SinchEventsService.java new file mode 100644 index 000000000..1dc053dc9 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/api/v1/SinchEventsService.java @@ -0,0 +1,59 @@ +package com.sinch.sdk.domains.voice.api.v1; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.voice.models.v1.sinchevents.VoiceSinchEvent; +import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; +import java.util.Map; + +/** + * Sinch Events service + * + * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 2.0 + */ +public interface SinchEventsService { + + /** + * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request + * and result events. All callback requests are signed using your Application key and secret pair + * found on your dashboard. The signature is included in the Authorization header of the request + * + *

By using following function, you can ensure authentication according to received payload + * from your backend + * + * @param method The HTTP method used ot handle the callback + * @param path The path to you backend endpoint used for callback + * @param headers Received headers + * @param jsonPayload Received payload + * @return Is authentication validated (true) or not (false) + *

see https://developers.sinch.com/docs/voice/api-reference/authentication/callback-signed-request/ + * @since 2.0 + */ + boolean validateAuthenticationHeader( + String method, String path, Map headers, String jsonPayload); + + /** + * This function can be called to deserialize received payload onto callback onto proper java + * Voice event class + * + * @param jsonPayload Received payload to be deserialized + * @return The Voice event instance class + *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 2.0 + */ + VoiceSinchEvent parseEvent(String jsonPayload) throws ApiMappingException; + + /** + * This function can be called to serialize a Voice response to be sent as JSON + * + * @param response The response to be serialized + * @return The JSON string to be sent + *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 2.0 + */ + String serializeResponse(SvamlControl response) throws ApiMappingException; +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/VoiceService.java index 21ec5834e..fb60dd24f 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/api/v1/VoiceService.java @@ -42,10 +42,10 @@ public interface VoiceService { ApplicationsService applications(); /** - * Webhooks helpers instance + * Sinch Events helpers instance * - * @return instance service related to webhooks helpers - * @since 1.4 + * @return service instance for project + * @since 2.0 */ - WebHooksService webhooks(); + SinchEventsService sinchEvents(); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/WebHooksService.java deleted file mode 100644 index fca05fc90..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/WebHooksService.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1; - -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; -import com.sinch.sdk.domains.voice.models.v1.webhooks.VoiceWebhookEvent; -import java.util.Map; - -/** - * Webhooks service - * - * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.4 - */ -public interface WebHooksService { - - /** - * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request - * and result events. All callback requests are signed using your Application key and secret pair - * found on your dashboard. The signature is included in the Authorization header of the request - * - *

By using following function, you can ensure authentication according to received payload - * from your backend - * - * @param method The HTTP method used ot handle the callback - * @param path The path to you backend endpoint used for callback - * @param headers Received headers - * @param jsonPayload Received payload - * @return Is authentication is validated (true) or not (false) - *

see https://developers.sinch.com/docs/voice/api-reference/authentication/callback-signed-request/ - * @since 1.4 - */ - boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload); - - /** - * This function can be called to deserialize received payload onto callback onto proper java - * Voice event class - * - * @param jsonPayload Received payload to be deserialized - * @return The Voice event instance class - *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.4 - */ - VoiceWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException; - - /** - * This function can be called to serialize a Voice response to be sent as JSON - * - * @param response The response to be serialized - * @return The JSON string to be sent - *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ - * @since 1.4 - */ - String serializeResponse(SvamlControl response) throws ApiMappingException; -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ApplicationsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ApplicationsService.java deleted file mode 100644 index 13279b3d1..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ApplicationsService.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1.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.voice.api.v1.internal.ApplicationsApi; -import com.sinch.sdk.domains.voice.models.v1.applications.Callbacks; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UnAssignNumberRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.request.UpdateNumbersRequest; -import com.sinch.sdk.domains.voice.models.v1.applications.response.OwnedNumbersResponse; -import com.sinch.sdk.domains.voice.models.v1.applications.response.QueryNumberResponse; -import com.sinch.sdk.models.VoiceContext; -import java.util.Map; - -public class ApplicationsService implements com.sinch.sdk.domains.voice.api.v1.ApplicationsService { - - private final ApplicationsApi api; - - public ApplicationsService( - VoiceContext context, HttpClient httpClient, Map authManagers) { - this.api = - new ApplicationsApi( - httpClient, - context.getVoiceApplicationManagementServer(), - authManagers, - HttpMapper.getInstance()); - } - - protected ApplicationsApi getApi() { - return this.api; - } - - public OwnedNumbersResponse listNumbers() { - return getApi().configurationGetNumbers(); - } - - public Callbacks getCallbackUrls(String applicationKey) { - return getApi().configurationGetCallbackURLs(applicationKey); - } - - public void updateCallbackUrls(String applicationKey, Callbacks parameters) { - - getApi().configurationUpdateCallbackURLs(applicationKey, parameters); - } - - public QueryNumberResponse queryNumber(String number) { - return getApi().callingQueryNumber(number); - } - - public void assignNumbers(UpdateNumbersRequest parameters) { - getApi().configurationUpdateNumbers(parameters); - } - - public void unassignNumber(UnAssignNumberRequest parameters) { - getApi().configurationUnassignNumber(parameters); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CalloutsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CalloutsService.java deleted file mode 100644 index 0608e6555..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CalloutsService.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1.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.voice.api.v1.adapters.mapper.CalloutRequestCustomMapper; -import com.sinch.sdk.domains.voice.api.v1.internal.CalloutsApi; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequest; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestCustom; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestTTS; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.internal.CalloutRequestInternalImpl; -import com.sinch.sdk.domains.voice.models.v1.callouts.response.CalloutResponse; -import com.sinch.sdk.models.VoiceContext; -import java.util.Map; - -public class CalloutsService implements com.sinch.sdk.domains.voice.api.v1.CalloutsService { - - private final CalloutsApi api; - - static { - LocalLazyInit.init(); - } - - public CalloutsService( - VoiceContext context, HttpClient httpClient, Map authManagers) { - this.api = - new CalloutsApi( - httpClient, context.getVoiceServer(), authManagers, HttpMapper.getInstance()); - } - - protected CalloutsApi getApi() { - return this.api; - } - - public String textToSpeech(CalloutRequestTTS parameters) { - - return call(parameters); - } - - public String conference(CalloutRequestConference parameters) { - - return call(parameters); - } - - public String custom(CalloutRequestCustom parameters) { - - return call(parameters); - } - - public String call(CalloutRequest parameters) { - - CalloutRequestInternalImpl request = new CalloutRequestInternalImpl(); - request.setActualInstance(parameters); - CalloutResponse response = getApi().callouts(request); - if (null == response) { - return null; - } - return response.getCallId(); - } - - public static final class LocalLazyInit { - - private LocalLazyInit() { - CalloutRequestCustomMapper.initMapper(); - } - - public static LocalLazyInit init() { - return LazyHolder.INSTANCE; - } - - private static class LazyHolder { - - public static final LocalLazyInit INSTANCE = new LocalLazyInit(); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CallsService.java deleted file mode 100644 index 85bd56b55..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/CallsService.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1.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.voice.api.v1.adapters.mapper.CallInformationMapper; -import com.sinch.sdk.domains.voice.api.v1.internal.CallsApi; -import com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg; -import com.sinch.sdk.domains.voice.models.v1.calls.response.CallInformation; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; -import com.sinch.sdk.models.VoiceContext; -import java.util.Map; - -public class CallsService implements com.sinch.sdk.domains.voice.api.v1.CallsService { - - private final CallsApi api; - - static { - LocalLazyInit.init(); - } - - public CallsService( - VoiceContext context, HttpClient httpClient, Map authManagers) { - this.api = - new CallsApi(httpClient, context.getVoiceServer(), authManagers, HttpMapper.getInstance()); - } - - protected CallsApi getApi() { - return this.api; - } - - public CallInformation get(String callId) { - return getApi().callingGetCallResult(callId); - } - - public void update(String callId, SvamlControl parameters) { - getApi().callingUpdateCall(callId, parameters); - } - - public void manageWithCallLeg(String callId, CallLeg callLeg, SvamlControl parameters) { - getApi().callingManageCallWithCallLeg(callId, callLeg.value(), parameters); - } - - public static final class LocalLazyInit { - - private LocalLazyInit() { - CallInformationMapper.initMapper(); - } - - public static CallsService.LocalLazyInit init() { - return CallsService.LocalLazyInit.LazyHolder.INSTANCE; - } - - private static class LazyHolder { - - public static final CallsService.LocalLazyInit INSTANCE = new LocalLazyInit(); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ConferencesService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ConferencesService.java deleted file mode 100644 index afd7e6dc9..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/ConferencesService.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1.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.voice.api.v1.internal.ConferencesApi; -import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference; -import com.sinch.sdk.domains.voice.models.v1.conferences.request.ManageConferenceParticipantRequest; -import com.sinch.sdk.domains.voice.models.v1.conferences.response.GetConferenceInfoResponse; -import com.sinch.sdk.models.VoiceContext; -import java.util.Map; - -public class ConferencesService implements com.sinch.sdk.domains.voice.api.v1.ConferencesService { - - private final ConferencesApi api; - private final CalloutsService calloutsService; - - public ConferencesService( - VoiceContext context, - HttpClient httpClient, - Map authManagers, - CalloutsService calloutsService) { - this.api = - new ConferencesApi( - httpClient, context.getVoiceServer(), authManagers, HttpMapper.getInstance()); - this.calloutsService = calloutsService; - } - - protected ConferencesApi getApi() { - return this.api; - } - - public String call(CalloutRequestConference parameters) { - return calloutsService.conference(parameters); - } - - public GetConferenceInfoResponse get(String conferenceId) { - return getApi().callingGetConferenceInfo(conferenceId); - } - - public void kickAll(String conferenceId) { - getApi().callingKickConferenceAll(conferenceId); - } - - public void kickParticipant(String conferenceId, String callId) { - getApi().callingKickConferenceParticipant(callId, conferenceId); - } - - public void manageParticipant( - String conferenceId, String callId, ManageConferenceParticipantRequest parameters) { - getApi().callingManageConferenceParticipant(callId, conferenceId, parameters); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/SinchEventsService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/SinchEventsService.java new file mode 100644 index 000000000..d22ec3e9f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/SinchEventsService.java @@ -0,0 +1,68 @@ +package com.sinch.sdk.domains.voice.api.v1.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.MapUtils; +import com.sinch.sdk.core.utils.StringUtil; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.voice.models.v1.sinchevents.VoiceSinchEvent; +import com.sinch.sdk.domains.voice.models.v1.sinchevents.internal.SinchEventInternalImpl; +import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; +import java.util.Map; +import java.util.logging.Logger; + +public class SinchEventsService implements com.sinch.sdk.domains.voice.api.v1.SinchEventsService { + private static final Logger LOGGER = Logger.getLogger(SinchEventsService.class.getName()); + + private final Map authManagers; + + public SinchEventsService(Map authManagers) { + this.authManagers = authManagers; + } + + public boolean validateAuthenticationHeader( + String method, String path, Map headers, String jsonPayload) { + + // convert header keys to use case-insensitive map keys + Map caseInsensitiveHeaders = MapUtils.getCaseInsensitiveMap(headers); + + String authorizationHeader = caseInsensitiveHeaders.get("Authorization"); + + if (StringUtil.isEmpty(authorizationHeader)) { + return false; + } + + String[] split = authorizationHeader.split(" "); + String authorizationKeyword = split.length > 0 ? split[0] : ""; + + AuthManager authManager = authManagers.get(authorizationKeyword); + if (null == authManager) { + // unknown auth manager + LOGGER.severe( + String.format("Auth manager for authorization '%s' not found", authorizationKeyword)); + return false; + } + return authManager.validateAuthenticatedRequest(method, path, headers, jsonPayload); + } + + @Override + public VoiceSinchEvent parseEvent(String jsonPayload) throws ApiMappingException { + try { + SinchEventInternalImpl o = + Mapper.getInstance().readValue(jsonPayload, SinchEventInternalImpl.class); + return (VoiceSinchEvent) o.getActualInstance(); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } + + @Override + public String serializeResponse(SvamlControl response) throws ApiMappingException { + try { + return Mapper.getInstance().writeValueAsString(response); + } catch (JsonProcessingException e) { + throw new ApiMappingException(response.toString(), e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/VoiceService.java index e7a14c233..38d3a45f1 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/VoiceService.java @@ -4,8 +4,14 @@ import com.sinch.sdk.auth.adapters.BasicAuthManager; 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.utils.StringUtil; -import com.sinch.sdk.domains.voice.api.v1.adapters.CallsService.LocalLazyInit; +import com.sinch.sdk.domains.voice.api.v1.ApplicationsService; +import com.sinch.sdk.domains.voice.api.v1.CalloutsService; +import com.sinch.sdk.domains.voice.api.v1.CallsService; +import com.sinch.sdk.domains.voice.api.v1.ConferencesService; +import com.sinch.sdk.domains.voice.api.v1.adapters.mapper.CallInformationMapper; +import com.sinch.sdk.domains.voice.api.v1.adapters.mapper.CalloutRequestCustomMapper; import com.sinch.sdk.domains.voice.api.v1.adapters.mapper.DestinationMapper; import com.sinch.sdk.models.ApplicationCredentials; import com.sinch.sdk.models.VoiceContext; @@ -31,10 +37,10 @@ public class VoiceService implements com.sinch.sdk.domains.voice.api.v1.VoiceSer private volatile ConferencesService conferences; private volatile CallsService calls; private volatile ApplicationsService applications; - private volatile WebHooksService webhooks; + private volatile SinchEventsService sinchEvents; private volatile Map clientAuthManagers; - private volatile Map webhooksAuthManagers; + private volatile Map sinchEventsAuthManagers; static { LocalLazyInit.init(); @@ -58,66 +64,104 @@ private void createAuthManagers(ApplicationCredentials credentials) { new ApplicationAuthManager( credentials.getApplicationKey(), credentials.getApplicationSecret()); - clientAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - clientAuthManagers.put(SECURITY_SCHEME_KEYWORD, applicationAuthManager); + Map localClientAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + localClientAuthManagers.put(SECURITY_SCHEME_KEYWORD, applicationAuthManager); + clientAuthManagers = localClientAuthManagers; - // here we need both auth managers to handle webhooks because we are receiving an Authorization - // header with "Application" keyword - webhooksAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - webhooksAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD, basicAuthManager); - webhooksAuthManagers.put(APPLICATION_SECURITY_SCHEME_KEYWORD, applicationAuthManager); + // here we need both auth managers to handle Sinch Events because we are receiving an + // Authorization header with "Application" keyword + Map sinchEventsAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + sinchEventsAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD, basicAuthManager); + sinchEventsAuthManagers.put(APPLICATION_SECURITY_SCHEME_KEYWORD, applicationAuthManager); + this.sinchEventsAuthManagers = sinchEventsAuthManagers; } public CalloutsService callouts() { if (null == this.callouts) { - instanceLazyInit(); - this.callouts = new CalloutsService(context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.callouts) { + instanceLazyInit(); + this.callouts = + new CalloutsServiceImpl( + httpClientSupplier.get(), + context.getVoiceServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.callouts; } public ConferencesService conferences() { if (null == this.conferences) { - instanceLazyInit(); - this.conferences = - new ConferencesService( - context, httpClientSupplier.get(), clientAuthManagers, this.callouts()); + synchronized (this) { + if (null == this.conferences) { + instanceLazyInit(); + this.conferences = + new ConferencesServiceImpl( + httpClientSupplier.get(), + context.getVoiceServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.conferences; } public CallsService calls() { if (null == this.calls) { - instanceLazyInit(); - this.calls = new CallsService(context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.calls) { + instanceLazyInit(); + this.calls = + new CallsServiceImpl( + httpClientSupplier.get(), + context.getVoiceServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.calls; } public ApplicationsService applications() { if (null == this.applications) { - instanceLazyInit(); - this.applications = - new com.sinch.sdk.domains.voice.api.v1.adapters.ApplicationsService( - context, httpClientSupplier.get(), clientAuthManagers); + synchronized (this) { + if (null == this.applications) { + instanceLazyInit(); + this.applications = + new ApplicationsServiceImpl( + httpClientSupplier.get(), + context.getVoiceApplicationManagementServer(), + clientAuthManagers, + HttpMapper.getInstance()); + } + } } return this.applications; } - public WebHooksService webhooks() { - if (null == this.webhooks) { - instanceLazyInit(); - this.webhooks = new WebHooksService(webhooksAuthManagers); + public SinchEventsService sinchEvents() { + if (null == this.sinchEvents) { + synchronized (this) { + if (null == this.sinchEvents) { + instanceLazyInit(); + this.sinchEvents = new SinchEventsService(sinchEventsAuthManagers); + } + } } - return this.webhooks; + return this.sinchEvents; } private void instanceLazyInit() { - if (null != this.clientAuthManagers && null != this.webhooksAuthManagers) { + if (null != this.clientAuthManagers && null != this.sinchEventsAuthManagers) { return; } synchronized (this) { - if (null == this.clientAuthManagers || null == this.webhooksAuthManagers) { + if (null == this.clientAuthManagers || null == this.sinchEventsAuthManagers) { // Currently, we are not supporting unified credentials: ensure application credentials are // defined @@ -142,7 +186,10 @@ private void instanceLazyInit() { public static final class LocalLazyInit { private LocalLazyInit() { + DestinationMapper.initMapper(); + CallInformationMapper.initMapper(); + CalloutRequestCustomMapper.initMapper(); } public static LocalLazyInit init() { diff --git a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/WebHooksService.java deleted file mode 100644 index 4457caac2..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/api/v1/adapters/WebHooksService.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.sinch.sdk.domains.voice.api.v1.adapters; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.sinch.sdk.core.exceptions.ApiMappingException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.utils.MapUtils; -import com.sinch.sdk.core.utils.StringUtil; -import com.sinch.sdk.core.utils.databind.Mapper; -import com.sinch.sdk.domains.voice.models.v1.svaml.SvamlControl; -import com.sinch.sdk.domains.voice.models.v1.webhooks.VoiceWebhookEvent; -import com.sinch.sdk.domains.voice.models.v1.webhooks.internal.WebhooksEventInternalImpl; -import java.util.Map; -import java.util.logging.Logger; - -public class WebHooksService implements com.sinch.sdk.domains.voice.api.v1.WebHooksService { - private static final Logger LOGGER = Logger.getLogger(WebHooksService.class.getName()); - - private final Map authManagers; - - public WebHooksService(Map authManagers) { - this.authManagers = authManagers; - } - - public boolean validateAuthenticationHeader( - String method, String path, Map headers, String jsonPayload) { - - // convert header keys to use case-insensitive map keys - Map caseInsensitiveHeaders = MapUtils.getCaseInsensitiveMap(headers); - - String authorizationHeader = caseInsensitiveHeaders.get("Authorization"); - - if (StringUtil.isEmpty(authorizationHeader)) { - return false; - } - - String[] split = authorizationHeader.split(" "); - String authorizationKeyword = split.length > 0 ? split[0] : ""; - - AuthManager authManager = authManagers.get(authorizationKeyword); - if (null == authManager) { - // unknown auth manager - LOGGER.severe( - String.format("Auth manager for authorization '%s' not found", authorizationKeyword)); - return false; - } - return authManager.validateAuthenticatedRequest(method, path, headers, jsonPayload); - } - - @Override - public VoiceWebhookEvent parseEvent(String jsonPayload) throws ApiMappingException { - try { - WebhooksEventInternalImpl o = - Mapper.getInstance().readValue(jsonPayload, WebhooksEventInternalImpl.class); - return (VoiceWebhookEvent) o.getActualInstance(); - } catch (JsonProcessingException e) { - throw new ApiMappingException(jsonPayload, e); - } - } - - @Override - public String serializeResponse(SvamlControl response) throws ApiMappingException { - try { - return Mapper.getInstance().writeValueAsString(response); - } catch (JsonProcessingException e) { - throw new ApiMappingException(response.toString(), e); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java b/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java deleted file mode 100644 index b45908dc9..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.models.E164PhoneNumber; - -/** Information about your number. */ -public class ApplicationAssignedNumber { - - private final E164PhoneNumber number; - private final String applicationKey; - private final CapabilityType capability; - - private ApplicationAssignedNumber( - E164PhoneNumber number, String applicationKey, CapabilityType capability) { - this.number = number; - this.applicationKey = applicationKey; - this.capability = capability; - } - - /** - * The phone number - * - * @return The phone number - */ - public E164PhoneNumber getNumber() { - return number; - } - - /** - * Indicates the application where the number was assigned. - * - * @return Application key value - */ - public String getApplicationKey() { - return applicationKey; - } - - /** - * Indicates the DID (Direct Inward CapabilityType) capabilityType that was assigned to the chosen - * application. - * - *

Please note that the DID needs to support the selected capabilityType. - * - * @return The capabilityType - */ - public CapabilityType getCapability() { - return capability; - } - - @Override - public String toString() { - return "ApplicationAssignedNumber{" - + "number=" - + number - + ", applicationKey='" - + applicationKey - + '\'' - + ", capabilityType=" - + capability - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - E164PhoneNumber number; - String applicationKey; - CapabilityType capabilityType; - - /** - * @param number the number value - * @return Current builder - * @see ApplicationAssignedNumber#getNumber() () getter - */ - public Builder setNumber(E164PhoneNumber number) { - this.number = number; - return this; - } - - /** - * @param applicationKey the application key - * @return Current builder - * @see ApplicationAssignedNumber#getApplicationKey() getter - */ - public Builder setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - return this; - } - - /** - * @param capabilityType the capabilityType value - * @return Current builder - * @see ApplicationAssignedNumber#getCapability() getter - */ - public Builder setCapability(CapabilityType capabilityType) { - this.capabilityType = capabilityType; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public ApplicationAssignedNumber build() { - return new ApplicationAssignedNumber(number, applicationKey, capabilityType); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationURL.java b/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationURL.java deleted file mode 100644 index 07bd679ea..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationURL.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -/** primary and if configured fallback callback URLs for an application */ -public class ApplicationURL { - - private final String primary; - private final String fallback; - - private ApplicationURL(String primary, String fallback) { - this.primary = primary; - this.fallback = fallback; - } - - /** - * Primary callback URL for application - * - * @return callback URL value - * @since 1.0 - */ - public String getPrimary() { - return primary; - } - - /** - * Fallback callback URL (returned if configured). - * - *

It is used only if Sinch platform gets a timeout or error from your primary callback URL. - * - * @return callback URL value - * @since 1.0 - */ - public String getFallback() { - return fallback; - } - - @Override - public String toString() { - return "ApplicationURL{" - + "primary='" - + primary - + '\'' - + ", fallback='" - + fallback - + '\'' - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - String primary; - String fallback; - - /** - * @param primary The primary URL to be used - * @return Current builder - * @see ApplicationURL#getPrimary() getter - */ - public Builder setPrimary(String primary) { - this.primary = primary; - return this; - } - - /** - * @param fallback The fallback URL to be used - * @return Current builder - * @see ApplicationURL#getFallback() () getter - */ - public Builder setFallback(String fallback) { - this.fallback = fallback; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public ApplicationURL build() { - return new ApplicationURL(primary, fallback); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CallLegType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallLegType.java deleted file mode 100644 index b87d1c4f4..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CallLegType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Specifies which part of the call will be managed. This option is used only by the PlayFiles and - * Say instructions to indicate which channel the sound will be played on. Valid options are caller, - * callee or both. If not specified, the default value is caller. - * - *

The callLeg identifier is ignored for calls that are part of a conference and calls initiated - * using the Callout API. - */ -public class CallLegType extends EnumDynamic { - - public static final CallLegType CALLER = new CallLegType("caller"); - public static final CallLegType CALLEE = new CallLegType("callee"); - public static final CallLegType BOTH = new CallLegType("both"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CallLegType.class, CallLegType::new, Arrays.asList(CALLER, CALLEE, BOTH)); - - private CallLegType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CallLegType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CallLegType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java deleted file mode 100644 index faed1c979..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Describe the reason why a call ended */ -public class CallReasonType extends EnumDynamic { - - public static final CallReasonType NA = new CallReasonType("N/A"); - public static final CallReasonType TIMEOUT = new CallReasonType("TIMEOUT"); - public static final CallReasonType CALLER_HANGUP = new CallReasonType("CALLERHANGUP"); - public static final CallReasonType CALLEE_HANGUP = new CallReasonType("CALLEEHANGUP"); - public static final CallReasonType BLOCKED = new CallReasonType("BLOCKED"); - public static final CallReasonType NO_CREDIT_PARTNER = new CallReasonType("NOCREDITPARTNER"); - public static final CallReasonType MANAGER_HANGUP = new CallReasonType("MANAGERHANGUP"); - public static final CallReasonType CANCEL = new CallReasonType("CANCEL"); - public static final CallReasonType GENERAL_ERROR = new CallReasonType("GENERALERROR"); - public static final CallReasonType INVALID_SVAMLACTION = new CallReasonType("INVALIDSVAMLACTION"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CallReasonType.class, - CallReasonType::new, - Arrays.asList( - NA, - TIMEOUT, - CALLER_HANGUP, - CALLEE_HANGUP, - BLOCKED, - NO_CREDIT_PARTNER, - MANAGER_HANGUP, - CANCEL, - GENERAL_ERROR, - INVALID_SVAMLACTION)); - - private CallReasonType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CallReasonType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CallReasonType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java deleted file mode 100644 index 6f311ec91..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Describe the result of a call */ -public class CallResultType extends EnumDynamic { - - public static final CallResultType NA = new CallResultType("N/A"); - public static final CallResultType ANSWERED = new CallResultType("ANSWERED"); - public static final CallResultType BUSY = new CallResultType("BUSY"); - public static final CallResultType NOANSWER = new CallResultType("NOANSWER"); - public static final CallResultType FAILED = new CallResultType("FAILED"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CallResultType.class, - CallResultType::new, - Arrays.asList(NA, ANSWERED, BUSY, NOANSWER, FAILED)); - - private CallResultType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CallResultType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CallResultType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CallbackUrls.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallbackUrls.java deleted file mode 100644 index 95f435f5f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CallbackUrls.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -/** - * Returns any callback URLs configured for the specified application - * - * @since 1.0 - */ -public class CallbackUrls { - private final ApplicationURL url; - - private CallbackUrls(ApplicationURL url) { - this.url = url; - } - - /** - * Associated application URL - * - * @return The URL - * @since 1.0 - */ - public ApplicationURL getUrl() { - return url; - } - - @Override - public String toString() { - return "CallbackUrls{" + "url=" + url + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - * @since 1.0 - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - ApplicationURL url; - - /** - * @param url the numbers list - * @return Current builder - * @see CallbackUrls#getUrl() getter - */ - public Builder setUrl(ApplicationURL url) { - this.url = url; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public CallbackUrls build() { - return new CallbackUrls(url); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CapabilityType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CapabilityType.java deleted file mode 100644 index 4d115ee06..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CapabilityType.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * CapabilityType of a phone number - * - *

DID: Direct Inward CapabilityType - * - * @since 1.0 - */ -public final class CapabilityType extends EnumDynamic { - /** The SMS product can use the number. */ - public static final CapabilityType SMS = new CapabilityType("sms"); - - /** The Voice product can use the number. */ - public static final CapabilityType VOICE = new CapabilityType("voice"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CapabilityType.class, CapabilityType::new, Arrays.asList(SMS, VOICE)); - - private CapabilityType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CapabilityType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CapabilityType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/ConferenceDtfmOptions.java b/client/src/main/com/sinch/sdk/domains/voice/models/ConferenceDtfmOptions.java deleted file mode 100644 index 31ce40b75..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/ConferenceDtfmOptions.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.models.OptionalValue; - -/** - * Options to control how DTMF signals are used by the participant in the conference. For - * information on how to use this feature, read more - * - * @see Using DTMF - * in conferences - */ -public class ConferenceDtfmOptions { - - OptionalValue mode; - OptionalValue maxDigits; - OptionalValue timeoutMills; - - public ConferenceDtfmOptions( - OptionalValue mode, - OptionalValue maxDigits, - OptionalValue timeoutMills) { - this.mode = mode; - this.maxDigits = maxDigits; - this.timeoutMills = timeoutMills; - } - - public OptionalValue getMode() { - return mode; - } - - public OptionalValue getMaxDigits() { - return maxDigits; - } - - public OptionalValue getTimeoutMills() { - return timeoutMills; - } - - @Override - public String toString() { - return "ConferenceDtfmOptions{" - + "mode=" - + mode - + ", maxDigits=" - + maxDigits - + ", timeoutMills=" - + timeoutMills - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue mode = OptionalValue.empty(); - OptionalValue maxDigits = OptionalValue.empty(); - OptionalValue timeoutMills = OptionalValue.empty(); - - public Builder() {} - - /** - * Determines what DTMF mode the participant will use in the call. - * - * @param mode DTFM mode - * @return current builder - */ - public Builder setMode(DtfmModeType mode) { - this.mode = OptionalValue.of(mode); - return this; - } - - /** - * The maximum number of accepted digits before sending the collected input via a PIE callback. - * The default value is 1. If the value is greater than 1, the PIE callback is triggered by one - * of the three following events: - * - *

- No additional digit is entered before the timeoutMills timeout period has elapsed. - The - * # character is entered. - The maximum number of digits has been entered. - * - * @param maxDigits Max digits - * @return current builder - */ - public Builder setMaxDigits(Integer maxDigits) { - this.maxDigits = OptionalValue.of(maxDigits); - return this; - } - - /** - * The number of milliseconds that the system will wait between entered digits before triggering - * the PIE callback - * - * @param timeoutMills Timeout in milliseconds - * @return current builder - */ - public Builder setTimeoutMills(Integer timeoutMills) { - this.timeoutMills = OptionalValue.of(timeoutMills); - return this; - } - - public ConferenceDtfmOptions build() { - return new ConferenceDtfmOptions(mode, maxDigits, timeoutMills); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/Destination.java b/client/src/main/com/sinch/sdk/domains/voice/models/Destination.java deleted file mode 100644 index d0f517ed8..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/Destination.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -/** Can be of type number for PSTN endpoints or of type username for data endpoints. */ -public abstract class Destination { - - @Override - public String toString() { - return ""; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java deleted file mode 100644 index f435c1191..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.models.E164PhoneNumber; -import java.util.Objects; - -/** Destination of numbers type */ -public class DestinationNumber extends Destination { - - private final E164PhoneNumber phoneNumber; - private final DestinationNumberType type; - - /** - * Create a destination instance of type PSTN - * - * @param phoneNumber Valid E164 phone number - */ - public DestinationNumber(E164PhoneNumber phoneNumber) { - this(phoneNumber, DestinationNumberType.PSTN); - } - - /** - * Create a destination instance of specified type - * - * @param phoneNumber Valid E164 phone number - * @param type Phone number type - */ - public DestinationNumber(E164PhoneNumber phoneNumber, DestinationNumberType type) { - Objects.requireNonNull(phoneNumber); - this.phoneNumber = phoneNumber; - this.type = type; - } - - public E164PhoneNumber getPhoneNumber() { - return phoneNumber; - } - - public DestinationNumberType getType() { - return type; - } - - @Override - public String toString() { - return "DestinationNumber{" - + "phoneNumber=" - + phoneNumber - + ", type=" - + type - + "} " - + super.toString(); - } - - public static DestinationNumber valueOf(String e164PhoneNumber) { - return new DestinationNumber(E164PhoneNumber.valueOf(e164PhoneNumber)); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DestinationNumber that = (DestinationNumber) o; - return Objects.equals(phoneNumber, that.phoneNumber) && type == that.type; - } - - @Override - public int hashCode() { - return Objects.hash(phoneNumber, type); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java deleted file mode 100644 index 5ffd8c378..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Destination types */ -public class DestinationNumberType extends EnumDynamic { - - /** * Public Switched Telephone Network */ - public static final DestinationNumberType PSTN = new DestinationNumberType("PSTN"); - - /** * Direct Inward Dialing */ - public static final DestinationNumberType DID = new DestinationNumberType("DID"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DestinationNumberType.class, DestinationNumberType::new, Arrays.asList(PSTN, DID)); - - private DestinationNumberType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DestinationNumberType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DestinationNumberType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationSip.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationSip.java deleted file mode 100644 index bd5ceba96..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationSip.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import java.util.Objects; - -/** Destination of type SIP */ -public class DestinationSip extends Destination { - private final String sipAddress; - - public DestinationSip(String sipAddress) { - Objects.requireNonNull(sipAddress); - this.sipAddress = sipAddress; - } - - public String getSIPAddress() { - return sipAddress; - } - - @Override - public String toString() { - return "DestinationSip{" + "sipAddress='" + sipAddress + '\'' + "} " + super.toString(); - } - - public static DestinationSip valueOf(String sipAddress) { - return new DestinationSip(sipAddress); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DestinationSip that = (DestinationSip) o; - return Objects.equals(sipAddress, that.sipAddress); - } - - @Override - public int hashCode() { - return Objects.hash(sipAddress); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationUser.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationUser.java deleted file mode 100644 index acf6ae6bf..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationUser.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import java.util.Objects; - -/** Destination of type username for data endpoints. */ -public class DestinationUser extends Destination { - private final String userName; - - public DestinationUser(String userName) { - Objects.requireNonNull(userName); - this.userName = userName; - } - - public String getUserName() { - return userName; - } - - @Override - public String toString() { - return "DestinationUser{" + "userName='" + userName + '\'' + "} " + super.toString(); - } - - public static DestinationUser valueOf(String user) { - return new DestinationUser(user); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DestinationUser that = (DestinationUser) o; - return Objects.equals(userName, that.userName); - } - - @Override - public int hashCode() { - return Objects.hash(userName); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java b/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java deleted file mode 100644 index b5f433c48..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Domains type */ -public class DomainType extends EnumDynamic { - - /** PSTN endpoint */ - public static final DomainType PSTN = new DomainType("pstn"); - - /** data (app or web) clients */ - public static final DomainType MXP = new DomainType("mxp"); - - /** Conference */ - public static final DomainType CONFERENCE = new DomainType("conference"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DomainType.class, DomainType::new, Arrays.asList(PSTN, MXP, CONFERENCE)); - - private DomainType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DomainType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DomainType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DtfmModeType.java b/client/src/main/com/sinch/sdk/domains/voice/models/DtfmModeType.java deleted file mode 100644 index 11d75e983..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DtfmModeType.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Determines what DTMF mode the participant will use in the call. */ -public class DtfmModeType extends EnumDynamic { - - /** - * Nothing is done with the participant's DTMF signals. This is the default mode. Any DTMF signals - * that the participant sends can still be heard by all participants, but no action will be - * performed. - */ - public static final DtfmModeType IGNORE = new DtfmModeType("ignore"); - - /** The participant's DTMF signals are forwarded to all other participants in the conference */ - public static final DtfmModeType FORWARD = new DtfmModeType("forward"); - - /** - * The participant's DTMF signals are detected by the conference and sent to your backend server - * using a Prompt Input Event (PIE) callback. - * - * @see Prompt - * Input Event (PIE) - */ - public static final DtfmModeType DETECT = new DtfmModeType("detect"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - DtfmModeType.class, DtfmModeType::new, Arrays.asList(IGNORE, FORWARD, DETECT)); - - private DtfmModeType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static DtfmModeType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(DtfmModeType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java b/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java deleted file mode 100644 index e4669681b..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Means "music-on-hold." */ -public class MusicOnHoldType extends EnumDynamic { - - /** progress tone */ - public static final MusicOnHoldType RING = new MusicOnHoldType("ring"); - - /** Music file */ - public static final MusicOnHoldType MUSIC1 = new MusicOnHoldType("music1"); - - /** Music file */ - public static final MusicOnHoldType MUSIC2 = new MusicOnHoldType("music2"); - - /** Music file */ - public static final MusicOnHoldType MUSIC3 = new MusicOnHoldType("music3"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - MusicOnHoldType.class, MusicOnHoldType::new, Arrays.asList(RING, MUSIC1, MUSIC2, MUSIC3)); - - private MusicOnHoldType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static MusicOnHoldType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(MusicOnHoldType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/NumberInformation.java b/client/src/main/com/sinch/sdk/domains/voice/models/NumberInformation.java deleted file mode 100644 index 38a0f86f5..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/NumberInformation.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.models.E164PhoneNumber; - -/** Detailed information about a number */ -public class NumberInformation { - private final String countryId; - private final NumberType numberType; - private final E164PhoneNumber normalizedNumber; - private final Boolean restricted; - private final Price rate; - - public NumberInformation( - String countryId, - NumberType numberType, - E164PhoneNumber normalizedNumber, - Boolean restricted, - Price rate) { - this.countryId = countryId; - this.numberType = numberType; - this.normalizedNumber = normalizedNumber; - this.restricted = restricted; - this.rate = rate; - } - - /** - * The ISO 3166-1 formatted country code - * - * @return Country Id - */ - public String getCountryId() { - return countryId; - } - - /** - * The type of the number - * - * @return Number type - */ - public NumberType getNumberType() { - return numberType; - } - - /** - * The number in E.164 format - * - * @return The number - */ - public E164PhoneNumber getNormalizedNumber() { - return normalizedNumber; - } - - /** - * Concerns whether the number is restricted or not - * - * @return Restricted or not - */ - public Boolean getRestricted() { - return restricted; - } - - /** - * The cost per minute to call the destination number - * - * @return Price - */ - public Price getRate() { - return rate; - } - - @Override - public String toString() { - return "NumberInformation{" - + "countryId='" - + countryId - + '\'' - + ", numberType='" - + numberType - + '\'' - + ", normalizedNumber='" - + normalizedNumber - + '\'' - + ", restricted=" - + restricted - + ", rate=" - + rate - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - String countryId; - NumberType numberType; - E164PhoneNumber normalizedNumber; - Boolean restricted; - Price rate; - - public Builder setCountryId(String countryId) { - this.countryId = countryId; - return this; - } - - public Builder setNumberType(NumberType numberType) { - this.numberType = numberType; - return this; - } - - public Builder setNormalizedNumber(E164PhoneNumber normalizedNumber) { - this.normalizedNumber = normalizedNumber; - return this; - } - - public Builder setRestricted(Boolean restricted) { - this.restricted = restricted; - return this; - } - - public Builder setRate(Price rate) { - this.rate = rate; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public NumberInformation build() { - return new NumberInformation(countryId, numberType, normalizedNumber, restricted, rate); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/NumberType.java b/client/src/main/com/sinch/sdk/domains/voice/models/NumberType.java deleted file mode 100644 index 566cd4e83..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/NumberType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.voice.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 number - * - * @since 1.0 - */ -public final class NumberType extends EnumDynamic { - public static final NumberType UNKNOWN = new NumberType("Unknown"); - public static final NumberType FIXED = new NumberType("Fixed"); - public static final NumberType MOBILE = new NumberType("Mobile"); - public static final NumberType OTHER = new NumberType("Other"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - NumberType.class, NumberType::new, Arrays.asList(UNKNOWN, FIXED, MOBILE, OTHER)); - - private NumberType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static NumberType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(NumberType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/Price.java b/client/src/main/com/sinch/sdk/domains/voice/models/Price.java deleted file mode 100644 index c8a04e7b0..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/Price.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.sinch.sdk.domains.voice.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/voice/models/TransportType.java b/client/src/main/com/sinch/sdk/domains/voice/models/TransportType.java deleted file mode 100644 index 72019e5e4..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/TransportType.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Transport Protocol type */ -public class TransportType extends EnumDynamic { - - /** User Datagram Protocol */ - public static final TransportType UDP = new TransportType("UDP"); - - /** Transmission Control Protocol */ - public static final TransportType TCP = new TransportType("TCP"); - - /** Transport Layer Security */ - public static final TransportType TLS = new TransportType("TLS"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - TransportType.class, TransportType::new, Arrays.asList(UDP, TCP, TLS)); - - private TransportType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static TransportType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(TransportType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ApplicationsAssignNumbersRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ApplicationsAssignNumbersRequestParameters.java deleted file mode 100644 index d4271dec1..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ApplicationsAssignNumbersRequestParameters.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.CapabilityType; -import com.sinch.sdk.models.E164PhoneNumber; -import java.util.Collection; - -/** - * Request parameters when updating a numbers list - * - * @since 1.0 - */ -public class ApplicationsAssignNumbersRequestParameters { - - private final OptionalValue> numbers; - private final OptionalValue applicationKey; - private final OptionalValue capability; - - private ApplicationsAssignNumbersRequestParameters( - OptionalValue> numbers, - OptionalValue applicationKey, - OptionalValue capability) { - this.numbers = numbers; - this.applicationKey = applicationKey; - this.capability = capability; - } - - /** - * Number list to be edited - * - * @return The numbers list - * @see Builder#setNumbers setter - * @since 1.0 - */ - public OptionalValue> getNumbers() { - return numbers; - } - - /** - * Application key to be assigned to numbers - * - * @return The application key - * @see Builder#setApplicationKey setter - * @since 1.0 - */ - public OptionalValue getApplicationKey() { - return applicationKey; - } - - /** - * Capability to be set - * - * @return The capability - * @see Builder#setCapability setter - * @since 1.0 - */ - public OptionalValue getCapability() { - return capability; - } - - @Override - public String toString() { - return "ApplicationsAssignNumbersRequestParameters{" - + "numbers=" - + numbers - + ", applicationKey='" - + applicationKey - + '\'' - + ", capability=" - + capability - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue> numbers = OptionalValue.empty(); - OptionalValue applicationKey = OptionalValue.empty(); - OptionalValue capability = OptionalValue.empty(); - - /** - * The phone number list to be updated or assigned to application - * - * @param numbers The phone number list - * @return Current builder - * @since 1.0 - */ - public Builder setNumbers(Collection numbers) { - this.numbers = OptionalValue.of(numbers); - return this; - } - - /** - * Indicates the application where the numbers will be assigned. - * - *

If empty, the application key that is used to authenticate - * - * @param applicationKey The application where the numbers will be assigned - * @return Current builder - * @since 1.0 - */ - public Builder setApplicationKey(String applicationKey) { - this.applicationKey = OptionalValue.of(applicationKey); - return this; - } - - /** - * Indicates the DID capability that needs to be assigned to the chosen application. - * - *

Please note that the DID needs to support the selected capability. - * - * @param capability The capability value - * @return Current builder - * @since 1.0 - */ - public Builder setCapability(CapabilityType capability) { - this.capability = OptionalValue.of(capability); - return this; - } - - public ApplicationsAssignNumbersRequestParameters build() { - return new ApplicationsAssignNumbersRequestParameters(numbers, applicationKey, capability); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java deleted file mode 100644 index f17289a96..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.models.DualToneMultiFrequency; -import com.sinch.sdk.models.E164PhoneNumber; - -public class CalloutRequestParameters { - private final OptionalValue destination; - private final OptionalValue cli; - private final OptionalValue dtfm; - private final OptionalValue custom; - - protected CalloutRequestParameters( - OptionalValue destination, - OptionalValue cli, - OptionalValue dtfm, - OptionalValue custom) { - - this.destination = destination; - this.cli = cli; - this.dtfm = dtfm; - this.custom = custom; - } - - /** - * Destination getter - * - * @see Builder#setDestination(Destination) - */ - public OptionalValue getDestination() { - return destination; - } - - /** - * Cli getter - * - * @see Builder#setCli(E164PhoneNumber) - */ - public OptionalValue getCli() { - return cli; - } - - /** - * Dual Tone Multi Frequency getter - * - * @see Builder#setDtfm(DualToneMultiFrequency) - */ - public OptionalValue getDtfm() { - return dtfm; - } - - /** - * Custom value getter - * - * @see Builder#setCustom(String) - */ - public OptionalValue getCustom() { - return custom; - } - - @Override - public String toString() { - return "CalloutRequestParameters{" - + "destination=" - + destination - + ", cli=" - + cli - + ", dtfm=" - + dtfm - + ", custom=" - + custom - + '}'; - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue destination = OptionalValue.empty(); - OptionalValue cli = OptionalValue.empty(); - OptionalValue dtfm = OptionalValue.empty(); - OptionalValue custom = OptionalValue.empty(); - - public Builder() {} - - /** - * @param destination The type of device and number or endpoint to call - * @return current builder - */ - public B setDestination(Destination destination) { - this.destination = OptionalValue.of(destination); - return self(); - } - - /** - * @param cli The number that will be displayed as the incoming caller. To set your own CLI, you - * may use your verified number or your Dashboard number - * @return current builder - */ - public B setCli(E164PhoneNumber cli) { - this.cli = OptionalValue.of(cli); - return self(); - } - - /** - * @param dtfm When the destination picks up, this DTMF tones will be played to the callee. - * @return current builder - */ - public B setDtfm(DualToneMultiFrequency dtfm) { - this.dtfm = OptionalValue.of(dtfm); - return self(); - } - - /** - * @param custom Custom data - * @return current builder - */ - public B setCustom(String custom) { - this.custom = OptionalValue.of(custom); - return self(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java deleted file mode 100644 index c90c1445d..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java +++ /dev/null @@ -1,330 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.MusicOnHoldType; -import com.sinch.sdk.models.DualToneMultiFrequency; -import com.sinch.sdk.models.E164PhoneNumber; - -/** - * The conference callout calls a phone number or a user. When the call is answered, it's connected - * to a conference room - */ -public class CalloutRequestParametersConference extends CalloutRequestParameters { - - private final OptionalValue conferenceId; - private final OptionalValue dtfmOptions; - private final OptionalValue maxDuration; - private final OptionalValue enableAce; - private final OptionalValue enableDice; - private final OptionalValue enablePie; - private final OptionalValue locale; - private final OptionalValue greeting; - private final OptionalValue musicOnHold; - private final OptionalValue domain; - - private CalloutRequestParametersConference( - OptionalValue destination, - OptionalValue cli, - OptionalValue dtfm, - OptionalValue custom, - OptionalValue conferenceId, - OptionalValue dtfmOptions, - OptionalValue maxDuration, - OptionalValue enableAce, - OptionalValue enableDice, - OptionalValue enablePie, - OptionalValue locale, - OptionalValue greeting, - OptionalValue musicOnHold, - OptionalValue domain) { - super(destination, cli, dtfm, custom); - - this.conferenceId = conferenceId; - this.dtfmOptions = dtfmOptions; - this.maxDuration = maxDuration; - this.enableAce = enableAce; - this.enableDice = enableDice; - this.enablePie = enablePie; - this.locale = locale; - this.greeting = greeting; - this.musicOnHold = musicOnHold; - this.domain = domain; - } - - /** - * @see Builder#setConferenceId(String) - */ - public OptionalValue getConferenceId() { - return conferenceId; - } - - /** - * @see Builder#setDtfm(DualToneMultiFrequency) - */ - public OptionalValue getDtfmOptions() { - return dtfmOptions; - } - - /** - * @see Builder#setMaxDuration(Integer) - */ - public OptionalValue getMaxDuration() { - return maxDuration; - } - - /** - * @see Builder#setEnableAce(Boolean) - */ - public OptionalValue getEnableAce() { - return enableAce; - } - - /** - * @see Builder#setEnableDice(Boolean) - */ - public OptionalValue getEnableDice() { - return enableDice; - } - - /** - * @see Builder#setEnablePie(Boolean) - */ - public OptionalValue getEnablePie() { - return enablePie; - } - - /** - * @see Builder#setLocale(String) - */ - public OptionalValue getLocale() { - return locale; - } - - /** - * @see Builder#setGreeting(String) - */ - public OptionalValue getGreeting() { - return greeting; - } - - /** - * @see Builder#setMusicOnHold(MusicOnHoldType) (MusicOnHoldType) - */ - public OptionalValue getMusicOnHold() { - return musicOnHold; - } - - /** - * @see Builder#setDomain(DomainType) - */ - public OptionalValue getDomain() { - return domain; - } - - @Override - public String toString() { - return "CalloutRequestParametersConference{" - + "conferenceId='" - + conferenceId - + '\'' - + ", dtfmOptions=" - + dtfmOptions - + ", maxDuration=" - + maxDuration - + ", enableAce=" - + enableAce - + ", enableDice=" - + enableDice - + ", enablePie=" - + enablePie - + ", locale='" - + locale - + '\'' - + ", greeting='" - + greeting - + '\'' - + ", musicOnHold=" - + musicOnHold - + ", domain=" - + domain - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends CalloutRequestParameters.Builder { - - OptionalValue conferenceId = OptionalValue.empty(); - OptionalValue dtfmOptions = OptionalValue.empty(); - OptionalValue maxDuration = OptionalValue.empty(); - OptionalValue enableAce = OptionalValue.empty(); - OptionalValue enableDice = OptionalValue.empty(); - OptionalValue enablePie = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - OptionalValue greeting = OptionalValue.empty(); - OptionalValue musicOnHold = OptionalValue.empty(); - OptionalValue domain = OptionalValue.empty(); - - public Builder() { - super(); - } - - /** - * The conferenceId of the conference to which you want the callee to join. * If the * - * conferenceId doesn't exist a conference room will be created. - * - * @param conferenceId The conference value - * @return current builder - */ - public Builder setConferenceId(String conferenceId) { - this.conferenceId = OptionalValue.of(conferenceId); - return self(); - } - - /** - * Define Dual Tone Multi Frequency options to control how DTMF signals are used by the - * participant in the conference - * - * @param dtfmOptions DTFM definition - * @return current builder - */ - public Builder setDtfmOptions(ConferenceDtfmOptions dtfmOptions) { - this.dtfmOptions = OptionalValue.of(dtfmOptions); - return self(); - } - - /** - * The maximum amount of time in seconds that the call will last. - * - * @param maxDuration Max duration value - * @return current builder - */ - public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = OptionalValue.of(maxDuration); - return self(); - } - - /** - * If enableAce is set to true and the application has a callback URL specified, you will - * receive an ACE callback when the call is answered. When the callback is received, your - * platform must respond with a svamlet containing the connectConf action in order to add the - * call to a conference or create the conference if it's the first call. If it's set to false, - * no ACE event will be sent to your backend. Note if the call is towards an InApp destination - * type: username, then no ACE will be issued when the call is connected, even if enableAce is - * present in the callout request. - * - * @param enableAce is enabled or not - * @return current builder - */ - public Builder setEnableAce(Boolean enableAce) { - this.enableAce = OptionalValue.of(enableAce); - return self(); - } - - /** - * If enableDice is set to true and the application has a callback URL specified, you will - * receive a DiCE callback when the call is disconnected. If it's set to false, no DiCE event - * will be sent to your backend. Note if the call is towards an InApp destination type: - * username, then no DICE will be issued at the end of the call, even if enableDice is present - * in the callout request. - * - * @param enableDice is enabled or not - * @return current builder - */ - public Builder setEnableDice(Boolean enableDice) { - this.enableDice = OptionalValue.of(enableDice); - return self(); - } - - /** - * If enablePie is set to true and the application has a callback URL specified, you will - * receive a PIE callback after a runMenu action, with the information of the action that the - * user took. If it's set to false, no PIE event will be sent to your backend. - * - * @param enablePie is enabled or not - * @return current builder - */ - public Builder setEnablePie(Boolean enablePie) { - this.enablePie = OptionalValue.of(enablePie); - return self(); - } - - /** - * The voice and language you want to use for the prompts. This can either be defined by the ISO - * 639 locale and language code or by specifying a particular voice. - * - * @see Supported - * languages and voices are detailed here - * @param locale The locale to be used - * @return current builder - */ - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return self(); - } - - /** - * Set the text that will be spoken as a greeting. - * - * @param greeting the text value - * @return current builder - */ - public Builder setGreeting(String greeting) { - this.greeting = OptionalValue.of(greeting); - return self(); - } - - /** - * Means "music-on-hold." It's an optional parameter that specifies what the first participant - * should listen to while they're alone in the conference, waiting for other participants to - * join. - * - * @param musicOnHold The music-on-hold to be used - * @return current builder - */ - public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { - this.musicOnHold = OptionalValue.of(musicOnHold); - return self(); - } - - /** - * Domain related call - * - * @param domain Domain to be used - * @return current builder - */ - public Builder setDomain(DomainType domain) { - this.domain = OptionalValue.of(domain); - return self(); - } - - public CalloutRequestParametersConference build() { - return new CalloutRequestParametersConference( - destination, - cli, - dtfm, - custom, - conferenceId, - dtfmOptions, - maxDuration, - enableAce, - enableDice, - enablePie, - locale, - greeting, - musicOnHold, - domain); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java deleted file mode 100644 index 30d1ef180..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference.Builder; -import com.sinch.sdk.models.DualToneMultiFrequency; -import com.sinch.sdk.models.E164PhoneNumber; - -/** - * The custom callout, the server initiates a call from the servers that can be controlled by - * specifying how the call should progress at each call event. - */ -public class CalloutRequestParametersCustom extends CalloutRequestParameters { - - private final OptionalValue maxDuration; - private final OptionalValue ice; - private final OptionalValue ace; - private final OptionalValue pie; - - private CalloutRequestParametersCustom( - OptionalValue destination, - OptionalValue cli, - OptionalValue dtfm, - OptionalValue custom, - OptionalValue maxDuration, - OptionalValue ice, - OptionalValue ace, - OptionalValue pie) { - super(destination, cli, dtfm, custom); - - this.maxDuration = maxDuration; - this.ice = ice; - this.ace = ace; - this.pie = pie; - } - - /** - * See builder - * - * @see Builder#setMaxDuration(Integer) - */ - public OptionalValue getMaxDuration() { - return maxDuration; - } - - /** - * See builder - * - * @see Builder#setIce(Control) - */ - public OptionalValue getIce() { - return ice; - } - - /** - * See builder - * - * @see Builder#setAce(Control) - */ - public OptionalValue getAce() { - return ace; - } - - /** - * See builder - * - * @see Builder#setPie(Control) - */ - public OptionalValue getPie() { - return pie; - } - - @Override - public String toString() { - return "CalloutRequestParametersCustom{" - + "maxDuration=" - + maxDuration - + ", ice='" - + ice - + '\'' - + ", ace='" - + ace - + '\'' - + ", pie='" - + pie - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends CalloutRequestParameters.Builder { - - OptionalValue maxDuration = OptionalValue.empty(); - OptionalValue ice = OptionalValue.empty(); - OptionalValue ace = OptionalValue.empty(); - OptionalValue pie = OptionalValue.empty(); - - public Builder() { - super(); - } - - /** - * The maximum amount of time in seconds that the call will last. - * - * @param maxDuration Max duration value - * @return current builder - */ - public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = OptionalValue.of(maxDuration); - return self(); - } - - /** - * You can use inline SVAML to replace a - * callback URL when using custom callouts. - * - *

Ensure that the JSON object is escaped correctly - * - *

If inline ICE SVAML is passed, exclude cli and destination properties from the - * customCallout request body. Example: - * "{\"action\": {\"name\": \"RunMenu\",\"locale\": \"en-US\",\"menus\": [{\"id\": \"main\",\"mainPrompt\": \"#tts[ Welcome to the main menu. Press 1 for a callback or 2 for a cancel<\/speak>]\",\"timeoutMills\": 5000,\"options\": [ {\"dtmf\": \"1\",\"action\": \"return(callback)\"}, {\"dtmf\": \"2\",\"action\": \"return(cancel)\"}]}]}}"" - * - * - * @param ice The Incoming Call Event value - * @return current builder - */ - public Builder setIce(Control ice) { - this.ice = OptionalValue.of(ice); - return self(); - } - - /** - * You can use inline SVAML to replace a - * callback URL when using custom callouts. - * - *

Ensure that the JSON object is escaped correctly Example: - * "{\"action\":{\"name\":\"connectPstn\",\"number\":\"46000000001\",\"maxDuration\":90}}" - * - * - * @param ace The Answered Call Event value - * @return current builder - */ - public Builder setAce(Control ace) { - this.ace = OptionalValue.of(ace); - return self(); - } - - /** - * Note: PIE callbacks are not available for DATA Calls; only PSTN and SIP calls. - * - *

You can use inline SVAML to replace a - * callback URL when using custom callouts. - * - *

Ensure that the JSON object is escaped correctly. A PIE event will contain a value chosen - * from an IVR choice. Usually a PIE event wil contain a URL to a callback sever that will - * receive the choice and be able to parse it. This could result in further SVAML or some other - * application logic function. - * - * @param pie Prompt Input Event value - * @return current builder - */ - public Builder setPie(Control pie) { - this.pie = OptionalValue.of(pie); - return self(); - } - - public CalloutRequestParametersCustom build() { - return new CalloutRequestParametersCustom( - destination, cli, dtfm, custom, maxDuration, ice, ace, pie); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java deleted file mode 100644 index fe6dee04a..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersCustom.Builder; -import com.sinch.sdk.models.DualToneMultiFrequency; -import com.sinch.sdk.models.E164PhoneNumber; - -/** - * The text-to-speech callout calls a phone number and plays a synthesized text messages or - * pre-recorded sound files. - */ -public class CalloutRequestParametersTTS extends CalloutRequestParameters { - - private final OptionalValue enableAce; - private final OptionalValue enableDice; - private final OptionalValue enablePie; - private final OptionalValue locale; - private final OptionalValue text; - private final OptionalValue prompts; - private final OptionalValue domain; - - private CalloutRequestParametersTTS( - OptionalValue destination, - OptionalValue cli, - OptionalValue dtfm, - OptionalValue custom, - OptionalValue enableAce, - OptionalValue enableDice, - OptionalValue enablePie, - OptionalValue locale, - OptionalValue domain, - OptionalValue text, - OptionalValue prompts) { - super(destination, cli, dtfm, custom); - - this.enableAce = enableAce; - this.enableDice = enableDice; - this.enablePie = enablePie; - this.locale = locale; - this.text = text; - this.prompts = prompts; - this.domain = domain; - } - - /** - * @see Builder#setEnableAce(Boolean) - */ - public OptionalValue getEnableAce() { - return enableAce; - } - - /** - * @see Builder#setEnableDice(Boolean) - */ - public OptionalValue getEnableDice() { - return enableDice; - } - - /** - * @see Builder#setEnablePie(Boolean) - */ - public OptionalValue getEnablePie() { - return enablePie; - } - - /** - * @see Builder#setLocale(String) - */ - public OptionalValue getLocale() { - return locale; - } - - /** - * @see Builder#setDomain(DomainType) - */ - public OptionalValue getDomain() { - return domain; - } - - /** - * @see Builder#setText(String) - */ - public OptionalValue getText() { - return text; - } - - /** - * @see Builder#setPrompts(String) - */ - public OptionalValue getPrompts() { - return prompts; - } - - @Override - public String toString() { - return "CalloutRequestParametersTTS{" - + "enableAce=" - + enableAce - + ", enableDice=" - + enableDice - + ", enablePie=" - + enablePie - + ", locale='" - + locale - + '\'' - + ", text='" - + text - + '\'' - + ", prompts='" - + prompts - + '\'' - + ", domain=" - + domain - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder extends CalloutRequestParameters.Builder { - - OptionalValue enableAce = OptionalValue.empty(); - OptionalValue enableDice = OptionalValue.empty(); - OptionalValue enablePie = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - OptionalValue domain = OptionalValue.empty(); - OptionalValue text = OptionalValue.empty(); - OptionalValue prompts = OptionalValue.empty(); - - public Builder() { - super(); - } - - /** - * If enableAce is set to true and the application has a callback URL specified, you will - * receive an ACE callback when the call is answered. When the callback is received, your - * platform must respond with a svamlet containing the connectConf action in order to add the - * call to a conference or create the conference if it's the first call. If it's set to false, - * no ACE event will be sent to your backend. Note if the call is towards an InApp destination - * type: username, then no ACE will be issued when the call is connected, even if enableAce is - * present in the callout request. - * - * @param enableAce set if enabled or not - * @return current builder - */ - public Builder setEnableAce(Boolean enableAce) { - this.enableAce = OptionalValue.of(enableAce); - return self(); - } - - /** - * If enableDice is set to true and the application has a callback URL specified, you will - * receive a DiCE callback when the call is disconnected. If it's set to false, no DiCE event - * will be sent to your backend. Note if the call is towards an InApp destination type: - * username, then no DICE will be issued at the end of the call, even if enableDice is present - * in the callout request. - * - * @param enableDice set if enabled or not - * @return current builder - */ - public Builder setEnableDice(Boolean enableDice) { - this.enableDice = OptionalValue.of(enableDice); - return self(); - } - - /** - * If enablePie is set to true and the application has a callback URL specified, you will - * receive a PIE callback after a runMenu action, with the information of the action that the - * user took. If it's set to false, no PIE event will be sent to your backend. - * - * @param enablePie set if enabled or not - * @return current builder - */ - public Builder setEnablePie(Boolean enablePie) { - this.enablePie = OptionalValue.of(enablePie); - return self(); - } - - /** - * The voice and language you want to use for the prompts. This can either be defined by the ISO - * 639 locale and language code or by specifying a particular voice. - * - * @see Supported - * languages and voices are detailed here - * @param locale The locale to be used - * @return current builder - */ - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return self(); - } - - /** - * @param domain Domain value to be used - * @return current builder - */ - public Builder setDomain(DomainType domain) { - this.domain = OptionalValue.of(domain); - return self(); - } - - /** - * Every application's default maximum characters allowed in text-to-speech is 600 characters. - * Contact support if you wish this limit to be changed. - * - * @param text The text that will be spoken in the text-to-speech message - * @return current builder - */ - public Builder setText(String text) { - this.text = OptionalValue.of(text); - return self(); - } - - /** - * An advanced alternative to using text. - * - *

- *
TTS Text To Speech - *
The equivalent of text but within the prompt property. - *

Example: #tts[Hello from Sinch] - *

TTS with SSML Text To Speech with Speech Synthesis Markup Language (SSML) - *
This is an XML-based markup language for assisting the generation of synthetic speech - * in the Web and other applications. AWS Polly supports a sub-set of SSML. This allows us - * to use SSML-enhanced text for additional control over how Polly generates speech from - * the text. Details and examples of supported tags @link are here - *
Externally hosted media - *
Provide a URL to your own hosted media. Please check @link here - * to read about audio content type and usage limits. - *
- * - *

Every application's default maximum allowed in TTS or TTS SSML is 600 characters. Contact - * support if you wish this limit to be changed. Several prompts can be used, separated by a - * semi-colon ; - * - *

Example: - * #tts[Hello from Sinch];#ssml[<speak><break time="250ms"/>Have a great day!</speak>] - * - * - * @param prompts The text to be used - * @return current builder - */ - public Builder setPrompts(String prompts) { - this.prompts = OptionalValue.of(prompts); - return self(); - } - - public CalloutRequestParametersTTS build() { - return new CalloutRequestParametersTTS( - destination, - cli, - dtfm, - custom, - enableAce, - enableDice, - enablePie, - locale, - domain, - text, - prompts); - } - - @Override - protected Builder self() { - return this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantCommandType.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantCommandType.java deleted file mode 100644 index 7aad144ce..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantCommandType.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Action to apply on conference participant" */ -public class ConferenceManageParticipantCommandType - extends EnumDynamic { - - /** Mutes participant */ - public static final ConferenceManageParticipantCommandType MUTE = - new ConferenceManageParticipantCommandType("mute"); - - /** Unmutes participant */ - public static final ConferenceManageParticipantCommandType UNMUTE = - new ConferenceManageParticipantCommandType("unmute"); - - /** Puts participant on hold */ - public static final ConferenceManageParticipantCommandType ONHOLD = - new ConferenceManageParticipantCommandType("onhold"); - - /** Returns participant to conference */ - public static final ConferenceManageParticipantCommandType RESUME = - new ConferenceManageParticipantCommandType("resume"); - - /** */ - private static final EnumSupportDynamic - ENUM_SUPPORT = - new EnumSupportDynamic<>( - ConferenceManageParticipantCommandType.class, - ConferenceManageParticipantCommandType::new, - Arrays.asList(MUTE, UNMUTE, ONHOLD, RESUME)); - - private ConferenceManageParticipantCommandType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static ConferenceManageParticipantCommandType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(ConferenceManageParticipantCommandType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java deleted file mode 100644 index af8d27d8f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.MusicOnHoldType; - -/** Use to configure conference participant settings */ -public class ConferenceManageParticipantRequestParameters { - - private final OptionalValue command; - private final OptionalValue musicOnHold; - - private ConferenceManageParticipantRequestParameters( - OptionalValue command, - OptionalValue musicOnHold) { - this.command = command; - this.musicOnHold = musicOnHold; - } - - /** - * @see Builder#setCommand(ConferenceManageParticipantCommandType) - */ - public OptionalValue getCommand() { - return command; - } - - /** - * @see Builder#setMusicOnHold(MusicOnHoldType) (MusicOnHoldType) - */ - public OptionalValue getMusicOnHold() { - return musicOnHold; - } - - @Override - public String toString() { - return "ConferenceManageParticipantRequestParameters{" - + "command=" - + command - + ", musicOnHold=" - + musicOnHold - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue command = OptionalValue.empty(); - OptionalValue musicOnHold = OptionalValue.empty(); - - /** - * @param command Action to apply on conference participant. - * @return current builder - */ - public Builder setCommand(ConferenceManageParticipantCommandType command) { - this.command = OptionalValue.of(command); - return this; - } - - /** - * @param musicOnHold If this optional parameter is included, plays music to the first - * participant in a conference while they're alone and waiting for other participants to - * join. If musicOnHold isn't specified, the user will only hear silence while alone in the - * conference. This property is only available to use with the onhold command. - * @return current builder - */ - public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { - this.musicOnHold = OptionalValue.of(musicOnHold); - return this; - } - - public ConferenceManageParticipantRequestParameters build() { - return new ConferenceManageParticipantRequestParameters(command, musicOnHold); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java deleted file mode 100644 index c3ed0483f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -/** - * Base class related to a control - * - *

Could be a URL or a SVAML control object - */ -public abstract class Control {} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java deleted file mode 100644 index 8f38600f8..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -/** - * Control URL used during a custom callout - * - * @see Custom - * Callout Description - */ -public class ControlUrl extends Control { - - private final String URL; - - private ControlUrl(String URL) { - this.URL = URL; - } - - /** - * @see #from(String) - */ - public String getURL() { - return URL; - } - - @Override - public String toString() { - return "ControlUrl{" + "URL='" + URL + '\'' + "} " + super.toString(); - } - - /** - * Create a Custom URL instance from String - * - * @param URL URL representation - * @return A newly created instance - */ - public static ControlUrl from(String URL) { - return new ControlUrl(URL); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/package-info.java deleted file mode 100644 index cbb964438..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Voice API requests related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.voice.models.requests; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/AssignedNumbers.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/AssignedNumbers.java deleted file mode 100644 index 03438ba00..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/AssignedNumbers.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.sinch.sdk.domains.voice.models.response; - -import com.sinch.sdk.domains.voice.models.ApplicationAssignedNumber; -import java.util.Collection; - -/** - * Get information about your numbers. It returns a list of numbers that you own, as well as their - * capability (voice or SMS). For the ones that are assigned to an app, it returns the application - * key of the app - */ -public class AssignedNumbers { - - private final Collection numbers; - - private AssignedNumbers(Collection numbers) { - this.numbers = numbers; - } - - /** - * Associated application numbers - * - * @return The numbers list - */ - public Collection getNumbers() { - return numbers; - } - - @Override - public String toString() { - return "AssignedNumbers{" + "numbers=" + numbers + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - Collection numbers; - - /** - * @param numbers the numbers list - * @return Current builder - * @see AssignedNumbers#getNumbers() getter - */ - public Builder setNumbers(Collection numbers) { - this.numbers = numbers; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public AssignedNumbers build() { - return new AssignedNumbers(numbers); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java deleted file mode 100644 index 7bb1d9f27..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java +++ /dev/null @@ -1,338 +0,0 @@ -package com.sinch.sdk.domains.voice.models.response; - -import com.sinch.sdk.domains.voice.models.CallReasonType; -import com.sinch.sdk.domains.voice.models.CallResultType; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.Price; -import java.time.Instant; - -/** Information related to a specific call */ -public class CallInformation { - private final Destination from; - private final Destination to; - private final DomainType domain; - private final String callId; - private final Integer duration; - private final CallStatusType status; - private final CallResultType result; - private final CallReasonType reason; - private final Instant timeStamp; - private final String custom; - private final Price userRate; - private final Price debit; - - private CallInformation( - Destination from, - Destination to, - DomainType domain, - String callId, - Integer duration, - CallStatusType status, - CallResultType result, - CallReasonType reason, - Instant timeStamp, - String custom, - Price userRate, - Price debit) { - this.from = from; - this.to = to; - this.domain = domain; - this.callId = callId; - this.duration = duration; - this.status = status; - this.result = result; - this.reason = reason; - this.timeStamp = timeStamp; - this.custom = custom; - this.userRate = userRate; - this.debit = debit; - } - - /** - * The caller information - * - * @return Destination instance describing caller - */ - public Destination getFrom() { - return from; - } - - /** - * The callee information - * - * @return Destination instance describing callee - */ - public Destination getTo() { - return to; - } - - /** - * The domain type - * - * @return Domain type - */ - public DomainType getDomain() { - return domain; - } - - /** - * The unique identifier of the call - * - * @return Call identifier - */ - public String getCallId() { - return callId; - } - - /** - * The duration of the call in seconds - * - * @return Call duration - */ - public Integer getDuration() { - return duration; - } - - /** - * The status of the call. - * - * @return Call status - */ - public CallStatusType getStatus() { - return status; - } - - /** - * Contains the result of a call. - * - * @return Call result - */ - public CallResultType getResult() { - return result; - } - - /** - * Contains the reason why a call ended - * - * @return Call ended reason - */ - public CallReasonType getReason() { - return reason; - } - - /** - * The date and time of the call - * - * @return Date time information related to call - */ - public Instant getTimeStamp() { - return timeStamp; - } - - /** - * Custom data passed onto callout - * - * @return The custom data value - */ - public String getCustom() { - return custom; - } - - /** - * The rate per minute that was charged for the call. - * - * @return Price information - */ - public Price getUserRate() { - return userRate; - } - - /** - * The total amount charged for the call - * - * @return Price information - */ - public Price getDebit() { - return debit; - } - - @Override - public String toString() { - return "CallInformation{" - + "from='" - + from - + '\'' - + ", to='" - + to - + '\'' - + ", domain=" - + domain - + ", callId='" - + callId - + '\'' - + ", duration=" - + duration - + ", status=" - + status - + ", result=" - + result - + ", reason=" - + reason - + ", timeStamp=" - + timeStamp - + ", custom='" - + custom - + '\'' - + ", userRate='" - + userRate - + '\'' - + ", debit='" - + debit - + '\'' - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - Destination from; - Destination to; - DomainType domain; - String callId; - Integer duration; - CallStatusType status; - CallResultType result; - CallReasonType reason; - Instant timeStamp; - String custom; - Price userRate; - Price debit; - - /** - * @see CallInformation#getFrom getter - * @return Current builder - */ - public Builder setFrom(Destination from) { - this.from = from; - return this; - } - - /** - * @see CallInformation#getTo() getter - * @return Current builder - */ - public Builder setTo(Destination to) { - this.to = to; - return this; - } - - /** - * @see CallInformation#getDomain() getter - * @return Current builder - */ - public Builder setDomain(DomainType domain) { - this.domain = domain; - return this; - } - - /** - * @see CallInformation#getCallId() getter - * @return Current builder - */ - public Builder setCallId(String callId) { - this.callId = callId; - return this; - } - - /** - * @see CallInformation#getDuration() getter - * @return Current builder - */ - public Builder setDuration(Integer duration) { - this.duration = duration; - return this; - } - - /** - * @see CallInformation#getStatus() getter - * @return Current builder - */ - public Builder setStatus(CallStatusType status) { - this.status = status; - return this; - } - - /** - * @see CallInformation#getResult() getter - * @return Current builder - */ - public Builder setResult(CallResultType result) { - this.result = result; - return this; - } - - /** - * @see CallInformation#getReason() getter - * @return Current builder - */ - public Builder setReason(CallReasonType reason) { - this.reason = reason; - return this; - } - - /** - * @see CallInformation#getTimeStamp() getter - * @return Current builder - */ - public Builder setTimeStamp(Instant timeStamp) { - this.timeStamp = timeStamp; - return this; - } - - /** - * @see CallInformation#getCustom() getter - * @return Current builder - */ - public Builder setCustom(String custom) { - this.custom = custom; - return this; - } - - /** - * @see CallInformation#getUserRate() getter - * @return Current builder - */ - public Builder setUserRate(Price userRate) { - this.userRate = userRate; - return this; - } - - /** - * @see CallInformation#getDebit() getter - * @return Current builder - */ - public Builder setDebit(Price debit) { - this.debit = debit; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public CallInformation build() { - return new CallInformation( - from, to, domain, callId, duration, status, result, reason, timeStamp, custom, userRate, - debit); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallStatusType.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/CallStatusType.java deleted file mode 100644 index 1c6530b62..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallStatusType.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.sinch.sdk.domains.voice.models.response; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** The status of a call */ -public class CallStatusType extends EnumDynamic { - - public static final CallStatusType ONGOING = new CallStatusType("ONGOING"); - - public static final CallStatusType FINAL = new CallStatusType("FINAL"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CallStatusType.class, CallStatusType::new, Arrays.asList(ONGOING, FINAL)); - - private CallStatusType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CallStatusType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CallStatusType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/ConferenceParticipant.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/ConferenceParticipant.java deleted file mode 100644 index bba3bd92a..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/ConferenceParticipant.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.sinch.sdk.domains.voice.models.response; - -/** Information about a conference's participant */ -public class ConferenceParticipant { - private final String cli; - private final String id; - private final Integer duration; - private final Boolean muted; - private final Boolean onhold; - - private ConferenceParticipant( - String cli, String id, Integer duration, Boolean muted, Boolean onhold) { - this.cli = cli; - this.id = id; - this.duration = duration; - this.muted = muted; - this.onhold = onhold; - } - - /** - * The phone number of the PSTN participant that was connected in the conference, or whatever was - * passed as CLI for data originated/terminated calls. - * - * @return The value - */ - public String getCli() { - return cli; - } - - /** - * The callId of the call leg that the participant joined the conference. - * - * @return Uniq identifier related toi the call - */ - public String getId() { - return id; - } - - /** - * The number of seconds that the participant has been connected to the conference - * - * @return Duration value - */ - public Integer getDuration() { - return duration; - } - - /** - * Is participant is muted or not - * - * @return Muted state - */ - public Boolean getMuted() { - return muted; - } - - /** - * Is participant is on hold or not - * - * @return The on hold state - */ - public Boolean getOnhold() { - return onhold; - } - - @Override - public String toString() { - return "ConferenceParticipant{" - + "cli='" - + cli - + '\'' - + ", id='" - + id - + '\'' - + ", duration=" - + duration - + ", muted=" - + muted - + ", onhold=" - + onhold - + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - String cli; - String id; - Integer duration; - Boolean muted; - Boolean onhold; - - /** - * @see ConferenceParticipant#getCli() getter - * @return Current builder - */ - public Builder setCli(String cli) { - this.cli = cli; - return this; - } - - /** - * @see ConferenceParticipant#getId() getter - * @return Current builder - */ - public Builder setId(String id) { - this.id = id; - return this; - } - - /** - * @see ConferenceParticipant#getDuration() getter - * @return Current builder - */ - public Builder setDuration(Integer duration) { - this.duration = duration; - return this; - } - - /** - * @see ConferenceParticipant#getMuted() getter - * @return Current builder - */ - public Builder setMuted(Boolean muted) { - this.muted = muted; - return this; - } - - /** - * @see ConferenceParticipant#getOnhold() getter - * @return Current builder - */ - public Builder setOnhold(Boolean onhold) { - this.onhold = onhold; - return this; - } - - public ConferenceParticipant build() { - return new ConferenceParticipant(cli, id, duration, muted, onhold); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/QueryNumber.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/QueryNumber.java deleted file mode 100644 index d9d96f224..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/QueryNumber.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.sinch.sdk.domains.voice.models.response; - -import com.sinch.sdk.domains.voice.models.NumberInformation; - -/** Information related to a number */ -public class QueryNumber { - - private final NumberInformation numberInformation; - - public QueryNumber(NumberInformation numberInformation) { - this.numberInformation = numberInformation; - } - - /** - * Get information details about number - * - * @return Information details - */ - public NumberInformation getNumberInformation() { - return numberInformation; - } - - @Override - public String toString() { - return "QueryNumber{" + "numberInformation=" + numberInformation + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - NumberInformation numberInformation; - - public Builder setNumberInformation(NumberInformation numberInformation) { - this.numberInformation = numberInformation; - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public QueryNumber build() { - return new QueryNumber(numberInformation); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/package-info.java deleted file mode 100644 index c104a0ff0..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Voice API specific responses related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.voice.models.response; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java deleted file mode 100644 index f1aa461d6..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -/** Base class for SVAML Action */ -public abstract class Action { - - @Override - public String toString() { - return ""; - } - - public abstract static class Builder> { - - /** - * Build the instance - * - * @return Built instance - */ - public abstract Action build(); - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java deleted file mode 100644 index 849befc34..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; -import com.sinch.sdk.domains.voice.models.MusicOnHoldType; - -public class ActionConnectConference extends Action { - - private final OptionalValue conferenceId; - private final OptionalValue dtfmOptions; - private final OptionalValue musicOnHold; - - private ActionConnectConference( - OptionalValue conferenceId, - OptionalValue dtfmOptions, - OptionalValue musicOnHold) { - this.conferenceId = conferenceId; - this.dtfmOptions = dtfmOptions; - this.musicOnHold = musicOnHold; - } - - public OptionalValue getConferenceId() { - return conferenceId; - } - - public OptionalValue getDtfmOptions() { - return dtfmOptions; - } - - public OptionalValue getMusicOnHold() { - return musicOnHold; - } - - @Override - public String toString() { - return "ActionConnectConference{" - + "conferenceId='" - + conferenceId - + '\'' - + ", dtfmOptions=" - + dtfmOptions - + ", musicOnHold=" - + musicOnHold - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue conferenceId = OptionalValue.empty(); - OptionalValue dtfmOptions = OptionalValue.empty(); - OptionalValue musicOnHold = OptionalValue.empty(); - - public Builder setConferenceId(String conferenceId) { - this.conferenceId = OptionalValue.of(conferenceId); - return this; - } - - public Builder setDtfmOptions(ConferenceDtfmOptions dtfmOptions) { - this.dtfmOptions = OptionalValue.of(dtfmOptions); - return this; - } - - public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { - this.musicOnHold = OptionalValue.of(musicOnHold); - return this; - } - - public ActionConnectConference build() { - return new ActionConnectConference(conferenceId, dtfmOptions, musicOnHold); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java deleted file mode 100644 index c7c9308d0..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.voice.models.Destination; -import java.util.Collection; - -public class ActionConnectMxp extends Action { - - private final OptionalValue destination; - private final OptionalValue>> callheaders; - - private ActionConnectMxp( - OptionalValue destination, - OptionalValue>> callheaders) { - this.destination = destination; - this.callheaders = callheaders; - } - - public OptionalValue getDestination() { - return destination; - } - - public OptionalValue>> getCallheaders() { - return callheaders; - } - - @Override - public String toString() { - return "ActionConnectMxp{" - + "destination=" - + destination - + ", callheaders=" - + callheaders - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue destination = OptionalValue.empty(); - OptionalValue>> callheaders = OptionalValue.empty(); - - public Builder setDestination(Destination destination) { - this.destination = OptionalValue.of(destination); - return this; - } - - public Builder setCallheaders(Collection> callheaders) { - this.callheaders = OptionalValue.of(callheaders); - return this; - } - - public ActionConnectMxp build() { - return new ActionConnectMxp(destination, callheaders); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java deleted file mode 100644 index c896f3ad7..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.models.DualToneMultiFrequency; -import com.sinch.sdk.models.E164PhoneNumber; - -public class ActionConnectPstn extends Action { - - private final OptionalValue number; - private final OptionalValue locale; - private final OptionalValue maxDuration; - private final OptionalValue dialTimeout; - private final OptionalValue cli; - private final OptionalValue suppressCallbacks; - private final OptionalValue dualToneMultiFrequency; - private final OptionalValue indications; - private final OptionalValue answeringMachineDetection; - - private ActionConnectPstn( - OptionalValue number, - OptionalValue locale, - OptionalValue maxDuration, - OptionalValue dialTimeout, - OptionalValue cli, - OptionalValue suppressCallbacks, - OptionalValue dualToneMultiFrequency, - OptionalValue indications, - OptionalValue answeringMachineDetection) { - this.number = number; - this.locale = locale; - this.maxDuration = maxDuration; - this.dialTimeout = dialTimeout; - this.cli = cli; - this.suppressCallbacks = suppressCallbacks; - this.dualToneMultiFrequency = dualToneMultiFrequency; - this.indications = indications; - this.answeringMachineDetection = answeringMachineDetection; - } - - public OptionalValue getNumber() { - return number; - } - - public OptionalValue getLocale() { - return locale; - } - - public OptionalValue getMaxDuration() { - return maxDuration; - } - - public OptionalValue getDialTimeout() { - return dialTimeout; - } - - public OptionalValue getCli() { - return cli; - } - - public OptionalValue getSuppressCallbacks() { - return suppressCallbacks; - } - - public OptionalValue getDualToneMultiFrequency() { - return dualToneMultiFrequency; - } - - public OptionalValue getIndications() { - return indications; - } - - public OptionalValue getAnsweringMachineDetection() { - return answeringMachineDetection; - } - - @Override - public String toString() { - return "ActionConnectPstn{" - + "number=" - + number - + ", locale='" - + locale - + '\'' - + ", maxDuration=" - + maxDuration - + ", dialTimeout=" - + dialTimeout - + ", cli='" - + cli - + '\'' - + ", suppressCallbacks=" - + suppressCallbacks - + ", dualToneMultiFrequency=" - + dualToneMultiFrequency - + ", indications=" - + indications - + ", answeringMachineDetection=" - + answeringMachineDetection - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue number = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - OptionalValue maxDuration = OptionalValue.empty(); - OptionalValue dialTimeout = OptionalValue.empty(); - OptionalValue cli = OptionalValue.empty(); - OptionalValue suppressCallbacks = OptionalValue.empty(); - OptionalValue dualToneMultiFrequency = OptionalValue.empty(); - OptionalValue indications = OptionalValue.empty(); - OptionalValue answeringMachineDetection = OptionalValue.empty(); - - public Builder setNumber(E164PhoneNumber number) { - this.number = OptionalValue.of(number); - return this; - } - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public Builder setMaxDuration(Integer duration) { - this.maxDuration = OptionalValue.of(duration); - return this; - } - - public Builder setDialTimeout(Integer dialTimeout) { - this.dialTimeout = OptionalValue.of(dialTimeout); - return this; - } - - public Builder setCli(String cli) { - this.cli = OptionalValue.of(cli); - return this; - } - - public Builder setSuppressCallbacks(Boolean suppressCallbacks) { - this.suppressCallbacks = OptionalValue.of(suppressCallbacks); - return this; - } - - public Builder setDualToneMultiFrequency(DualToneMultiFrequency dualToneMultiFrequency) { - this.dualToneMultiFrequency = OptionalValue.of(dualToneMultiFrequency); - return this; - } - - public Builder setIndications(IndicationType indications) { - this.indications = OptionalValue.of(indications); - return this; - } - - public Builder setAnsweringMachineDetection( - AnsweringMachineDetection answeringMachineDetection) { - this.answeringMachineDetection = OptionalValue.of(answeringMachineDetection); - return this; - } - - public ActionConnectPstn build() { - return new ActionConnectPstn( - number, - locale, - maxDuration, - dialTimeout, - cli, - suppressCallbacks, - dualToneMultiFrequency, - indications, - answeringMachineDetection); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java deleted file mode 100644 index c731f34fa..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.voice.models.DestinationSip; -import com.sinch.sdk.domains.voice.models.MusicOnHoldType; -import com.sinch.sdk.domains.voice.models.TransportType; -import java.util.Collection; - -public class ActionConnectSip extends Action { - - private final OptionalValue destination; - private final OptionalValue maxDuration; - private final OptionalValue cli; - private final OptionalValue transport; - private final OptionalValue suppressCallbacks; - private final OptionalValue>> callHeaders; - private final OptionalValue musicOnHold; - - private ActionConnectSip( - OptionalValue destination, - OptionalValue maxDuration, - OptionalValue cli, - OptionalValue transport, - OptionalValue suppressCallbacks, - OptionalValue>> callHeaders, - OptionalValue musicOnHold) { - this.destination = destination; - this.maxDuration = maxDuration; - this.cli = cli; - this.transport = transport; - this.suppressCallbacks = suppressCallbacks; - this.callHeaders = callHeaders; - this.musicOnHold = musicOnHold; - } - - public OptionalValue getDestination() { - return destination; - } - - public OptionalValue getMaxDuration() { - return maxDuration; - } - - public OptionalValue getCli() { - return cli; - } - - public OptionalValue getTransport() { - return transport; - } - - public OptionalValue getSuppressCallbacks() { - return suppressCallbacks; - } - - public OptionalValue>> getCallHeaders() { - return callHeaders; - } - - public OptionalValue getMusicOnHold() { - return musicOnHold; - } - - @Override - public String toString() { - return "ActionConnectSip{" - + "destination=" - + destination - + ", maxDuration=" - + maxDuration - + ", cli='" - + cli - + '\'' - + ", transport=" - + transport - + ", suppressCallbacks=" - + suppressCallbacks - + ", callHeaders=" - + callHeaders - + ", musicOnHold=" - + musicOnHold - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue destination = OptionalValue.empty(); - OptionalValue maxDuration = OptionalValue.empty(); - OptionalValue cli = OptionalValue.empty(); - OptionalValue transport = OptionalValue.empty(); - OptionalValue suppressCallbacks = OptionalValue.empty(); - OptionalValue>> callHeaders = OptionalValue.empty(); - OptionalValue musicOnHold = OptionalValue.empty(); - - public Builder setDestination(DestinationSip destination) { - this.destination = OptionalValue.of(destination); - return this; - } - - public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = OptionalValue.of(maxDuration); - return this; - } - - public Builder setCli(String cli) { - this.cli = OptionalValue.of(cli); - return this; - } - - public Builder setTransport(TransportType transport) { - this.transport = OptionalValue.of(transport); - return this; - } - - public Builder setSuppressCallbacks(Boolean suppressCallbacks) { - this.suppressCallbacks = OptionalValue.of(suppressCallbacks); - return this; - } - - public Builder setCallHeaders(Collection> callHeaders) { - this.callHeaders = OptionalValue.of(callHeaders); - return this; - } - - public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { - this.musicOnHold = OptionalValue.of(musicOnHold); - return this; - } - - public ActionConnectSip build() { - return new ActionConnectSip( - destination, maxDuration, cli, transport, suppressCallbacks, callHeaders, musicOnHold); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionContinue.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionContinue.java deleted file mode 100644 index 63803e871..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionContinue.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public class ActionContinue extends Action { - - private ActionContinue() {} - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - public ActionContinue build() { - return new ActionContinue(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionHangUp.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionHangUp.java deleted file mode 100644 index 477168c1a..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionHangUp.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public class ActionHangUp extends Action { - - private ActionHangUp() {} - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - public ActionHangUp build() { - return new ActionHangUp(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java deleted file mode 100644 index d67e792ae..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class ActionPark extends Action { - - private final OptionalValue locale; - private final OptionalValue introPrompt; - private final OptionalValue holdPrompt; - private final OptionalValue maxDuration; - - private ActionPark( - OptionalValue locale, - OptionalValue introPrompt, - OptionalValue holdPrompt, - OptionalValue maxDuration) { - this.locale = locale; - this.introPrompt = introPrompt; - this.holdPrompt = holdPrompt; - this.maxDuration = maxDuration; - } - - public OptionalValue getLocale() { - return locale; - } - - public OptionalValue getIntroPrompt() { - return introPrompt; - } - - public OptionalValue getHoldPrompt() { - return holdPrompt; - } - - public OptionalValue getMaxDuration() { - return maxDuration; - } - - @Override - public String toString() { - return "ActionPark{" - + "locale='" - + locale - + '\'' - + ", introPrompt='" - + introPrompt - + '\'' - + ", holdPrompt='" - + holdPrompt - + '\'' - + ", maxDuration=" - + maxDuration - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue locale = OptionalValue.empty(); - OptionalValue introPrompt = OptionalValue.empty(); - OptionalValue holdPrompt = OptionalValue.empty(); - OptionalValue maxDuration = OptionalValue.empty(); - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public Builder setIntroPrompt(String introPrompt) { - this.introPrompt = OptionalValue.of(introPrompt); - return this; - } - - public Builder setHoldPrompt(String holdPrompt) { - this.holdPrompt = OptionalValue.of(holdPrompt); - return this; - } - - public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = OptionalValue.of(maxDuration); - return this; - } - - public ActionPark build() { - return new ActionPark(locale, introPrompt, holdPrompt, maxDuration); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java deleted file mode 100644 index bdf252e6d..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -public class ActionRunMenu extends Action { - - private final OptionalValue barge; - private final OptionalValue locale; - private final OptionalValue mainMenu; - private final OptionalValue enableVoice; - private final OptionalValue> menus; - - private ActionRunMenu( - OptionalValue barge, - OptionalValue locale, - OptionalValue mainMenu, - OptionalValue enableVoice, - OptionalValue> menus) { - this.barge = barge; - this.locale = locale; - this.mainMenu = mainMenu; - this.enableVoice = enableVoice; - this.menus = menus; - } - - public OptionalValue getBarge() { - return barge; - } - - public OptionalValue getLocale() { - return locale; - } - - public OptionalValue getMainMenu() { - return mainMenu; - } - - public OptionalValue getEnableVoice() { - return enableVoice; - } - - public OptionalValue> getMenus() { - return menus; - } - - @Override - public String toString() { - return "ActionRunMenu{" - + "barge=" - + barge - + ", locale='" - + locale - + '\'' - + ", mainMenu='" - + mainMenu - + '\'' - + ", enableVoice=" - + enableVoice - + ", menus=" - + menus - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue barge = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - OptionalValue mainMenu = OptionalValue.empty(); - OptionalValue enableVoice = OptionalValue.empty(); - OptionalValue> menus = OptionalValue.empty(); - - public Builder setBarge(Boolean barge) { - this.barge = OptionalValue.of(barge); - return this; - } - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public Builder setMainMenu(String mainMenu) { - this.mainMenu = OptionalValue.of(mainMenu); - return this; - } - - public Builder setEnableVoice(Boolean enableVoice) { - this.enableVoice = OptionalValue.of(enableVoice); - return this; - } - - public Builder setMenus(Collection

menus) { - this.menus = OptionalValue.of(menus); - return this; - } - - public ActionRunMenu build() { - return new ActionRunMenu(barge, locale, mainMenu, enableVoice, menus); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java deleted file mode 100644 index 753c3c67e..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class AnsweringMachineDetection { - - private final OptionalValue enabled; - - private AnsweringMachineDetection(OptionalValue enabled) { - this.enabled = enabled; - } - - public OptionalValue getEnabled() { - return enabled; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue enabled = OptionalValue.empty(); - - public Builder setEnabled(Boolean enabled) { - this.enabled = OptionalValue.of(enabled); - return this; - } - - public AnsweringMachineDetection build() { - return new AnsweringMachineDetection(enabled); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/IndicationType.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/IndicationType.java deleted file mode 100644 index 65e7d389c..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/IndicationType.java +++ /dev/null @@ -1,112 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Domains type */ -public class IndicationType extends EnumDynamic { - - public static final IndicationType AUSTRIA = new IndicationType("at"); - public static final IndicationType AUSTRALIA = new IndicationType("au"); - public static final IndicationType BULGARIA = new IndicationType("bg"); - public static final IndicationType BRAZIL = new IndicationType("br"); - public static final IndicationType BELGIUM = new IndicationType("be"); - public static final IndicationType SWITZERLAND = new IndicationType("ch"); - public static final IndicationType CHILE = new IndicationType("cl"); - public static final IndicationType CHINA = new IndicationType("cn"); - public static final IndicationType CZECH_REPUBLIC = new IndicationType("cz"); - public static final IndicationType GERMANY = new IndicationType("de"); - public static final IndicationType DENMARK = new IndicationType("dk"); - public static final IndicationType ESTONIA = new IndicationType("ee"); - public static final IndicationType SPAIN = new IndicationType("es"); - public static final IndicationType FINLAND = new IndicationType("fi"); - public static final IndicationType FRANCE = new IndicationType("fr"); - public static final IndicationType GREECE = new IndicationType("gr"); - public static final IndicationType HUNGARY = new IndicationType("hu"); - public static final IndicationType ISRAEL = new IndicationType("il"); - public static final IndicationType INDIA = new IndicationType("in"); - public static final IndicationType ITALY = new IndicationType("it"); - public static final IndicationType LITHUANIA = new IndicationType("lt"); - public static final IndicationType JAPAN = new IndicationType("jp"); - public static final IndicationType MEXICO = new IndicationType("mx"); - public static final IndicationType MALAYSIA = new IndicationType("my"); - public static final IndicationType NETHERLANDS = new IndicationType("nl"); - public static final IndicationType NORWAY = new IndicationType("no"); - public static final IndicationType NEW_ZEALAND = new IndicationType("nz"); - public static final IndicationType PHILIPPINES = new IndicationType("ph"); - public static final IndicationType POLAND = new IndicationType("pl"); - public static final IndicationType PORTUGAL = new IndicationType("pt"); - public static final IndicationType RUSSIA = new IndicationType("ru"); - public static final IndicationType SWEDEN = new IndicationType("se"); - public static final IndicationType SINGAPORE = new IndicationType("sg"); - public static final IndicationType THAILAND = new IndicationType("th"); - public static final IndicationType UNITED_KINGDOM = new IndicationType("uk"); - public static final IndicationType UNITED_STATES = new IndicationType("us"); - public static final IndicationType TAIWAN = new IndicationType("tw"); - public static final IndicationType VENEZUELA = new IndicationType("ve"); - public static final IndicationType SOUTH_AFRICA = new IndicationType("za"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - IndicationType.class, - IndicationType::new, - Arrays.asList( - AUSTRIA, - AUSTRALIA, - BULGARIA, - BRAZIL, - BELGIUM, - SWITZERLAND, - CHILE, - CHINA, - CZECH_REPUBLIC, - GERMANY, - DENMARK, - ESTONIA, - SPAIN, - FINLAND, - FRANCE, - GREECE, - HUNGARY, - ISRAEL, - INDIA, - ITALY, - LITHUANIA, - JAPAN, - MEXICO, - MALAYSIA, - NETHERLANDS, - NORWAY, - NEW_ZEALAND, - PHILIPPINES, - POLAND, - PORTUGAL, - RUSSIA, - SWEDEN, - SINGAPORE, - THAILAND, - UNITED_KINGDOM, - UNITED_STATES, - TAIWAN, - VENEZUELA, - SOUTH_AFRICA)); - - private IndicationType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static IndicationType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(IndicationType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Instruction.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Instruction.java deleted file mode 100644 index 18c8275da..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Instruction.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public abstract class Instruction { - - @Override - public String toString() { - return ""; - } - - public abstract static class Builder> { - - public abstract Instruction build(); - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionAnswer.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionAnswer.java deleted file mode 100644 index aa0c5449f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionAnswer.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public class InstructionAnswer extends Instruction { - - private InstructionAnswer() {} - - @Override - public String toString() { - return "InstructionAnswer{} " + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - public InstructionAnswer build() { - return new InstructionAnswer(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java deleted file mode 100644 index d463bd33b..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -public class InstructionPlayFiles extends Instruction { - - private final OptionalValue> ids; - private final OptionalValue locale; - - private InstructionPlayFiles( - OptionalValue> ids, OptionalValue locale) { - this.ids = ids; - this.locale = locale; - } - - public OptionalValue> getIds() { - return ids; - } - - public OptionalValue getLocale() { - return locale; - } - - @Override - public String toString() { - return "InstructionPlayFiles{" - + "ids=" - + ids - + ", locale='" - + locale - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue> ids = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - - public Builder setIds(Collection ids) { - this.ids = OptionalValue.of(ids); - return this; - } - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public InstructionPlayFiles build() { - return new InstructionPlayFiles(ids, locale); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java deleted file mode 100644 index 49f7f2818..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class InstructionSay extends Instruction { - - private final OptionalValue text; - private final OptionalValue locale; - - private InstructionSay(OptionalValue text, OptionalValue locale) { - this.text = text; - this.locale = locale; - } - - public OptionalValue getText() { - return text; - } - - public OptionalValue getLocale() { - return locale; - } - - @Override - public String toString() { - return "InstructionSay{" - + "text=" - + text - + ", locale='" - + locale - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue text = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - - public Builder setText(String text) { - this.text = OptionalValue.of(text); - return this; - } - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public InstructionSay build() { - return new InstructionSay(text, locale); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java deleted file mode 100644 index 47cb0ebd9..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.models.DualToneMultiFrequency; - -public class InstructionSendDtfm extends Instruction { - - private final OptionalValue dtfm; - - private InstructionSendDtfm(OptionalValue dtfm) { - this.dtfm = dtfm; - } - - public OptionalValue getTDtfm() { - return dtfm; - } - - @Override - public String toString() { - return "InstructionSendDtfm{" + "dtfm=" + dtfm + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue dtfm = OptionalValue.empty(); - - public Builder setDtfm(DualToneMultiFrequency dtfm) { - this.dtfm = OptionalValue.of(dtfm); - return this; - } - - public InstructionSendDtfm build() { - return new InstructionSendDtfm(dtfm); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSetCookie.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSetCookie.java deleted file mode 100644 index 188001957..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSetCookie.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public class InstructionSetCookie extends Instruction { - - private final String key; - private final String value; - - private InstructionSetCookie(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public String getValue() { - return value; - } - - @Override - public String toString() { - return "InstructionSetCookie{" - + "key='" - + key - + '\'' - + ", value='" - + value - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - String key; - String value; - - public Builder setKey(String key) { - this.key = key; - return this; - } - - public Builder setValue(String value) { - this.value = value; - return this; - } - - public InstructionSetCookie build() { - return new InstructionSetCookie(key, value); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java deleted file mode 100644 index ed41960f2..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class InstructionStartRecording extends Instruction { - - private final OptionalValue options; - - private InstructionStartRecording(OptionalValue options) { - this.options = options; - } - - public OptionalValue getOptions() { - return options; - } - - @Override - public String toString() { - return "InstructionStartRecording{" + "options=" + options + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - OptionalValue options = OptionalValue.empty(); - - public Builder setOptions(StartRecordingOptions options) { - this.options = OptionalValue.of(options); - return this; - } - - public InstructionStartRecording build() { - return new InstructionStartRecording(options); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java deleted file mode 100644 index fc41a5c0a..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -public class InstructionStopRecording extends Instruction { - - private InstructionStopRecording() {} - - @Override - public String toString() { - return "InstructionStopRecording{" + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - public InstructionStopRecording build() { - return new InstructionStopRecording(); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java deleted file mode 100644 index ad07347b5..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import java.util.Collection; - -public class Menu { - - private final OptionalValue id; - private final OptionalValue mainPrompt; - private final OptionalValue repeatPrompt; - private final OptionalValue repeats; - private final OptionalValue maxDigits; - private final OptionalValue timeoutMills; - private final OptionalValue maxTimeoutMills; - private final OptionalValue> options; - - private Menu( - OptionalValue id, - OptionalValue mainPrompt, - OptionalValue repeatPrompt, - OptionalValue repeats, - OptionalValue maxDigits, - OptionalValue timeoutMills, - OptionalValue maxTimeoutMills, - OptionalValue> options) { - this.id = id; - this.mainPrompt = mainPrompt; - this.repeatPrompt = repeatPrompt; - this.repeats = repeats; - this.maxDigits = maxDigits; - this.timeoutMills = timeoutMills; - this.maxTimeoutMills = maxTimeoutMills; - this.options = options; - } - - public OptionalValue getId() { - return id; - } - - public OptionalValue getMainPrompt() { - return mainPrompt; - } - - public OptionalValue getRepeatPrompt() { - return repeatPrompt; - } - - public OptionalValue getRepeats() { - return repeats; - } - - public OptionalValue getMaxDigits() { - return maxDigits; - } - - public OptionalValue getTimeoutMills() { - return timeoutMills; - } - - public OptionalValue getMaxTimeoutMills() { - return maxTimeoutMills; - } - - public OptionalValue> getOptions() { - return options; - } - - @Override - public String toString() { - return "Menu{" - + "id='" - + id - + '\'' - + ", mainPrompt='" - + mainPrompt - + '\'' - + ", repeatPrompt='" - + repeatPrompt - + '\'' - + ", repeats=" - + repeats - + ", maxDigits=" - + maxDigits - + ", timeoutMills=" - + timeoutMills - + ", maxTimeoutMills=" - + maxTimeoutMills - + ", options=" - + options - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue id = OptionalValue.empty(); - OptionalValue mainPrompt = OptionalValue.empty(); - OptionalValue repeatPrompt = OptionalValue.empty(); - OptionalValue repeats = OptionalValue.empty(); - OptionalValue maxDigits = OptionalValue.empty(); - OptionalValue timeoutMills = OptionalValue.empty(); - OptionalValue maxTimeoutMills = OptionalValue.empty(); - OptionalValue> options = OptionalValue.empty(); - - public Builder setId(String id) { - this.id = OptionalValue.of(id); - return this; - } - - public Builder setMainPrompt(String mainPrompt) { - this.mainPrompt = OptionalValue.of(mainPrompt); - return this; - } - - public Builder setRepeatPrompt(String repeatPrompt) { - this.repeatPrompt = OptionalValue.of(repeatPrompt); - return this; - } - - public Builder setRepeats(Integer repeats) { - this.repeats = OptionalValue.of(repeats); - return this; - } - - public Builder setMaxDigits(Integer maxDigits) { - this.maxDigits = OptionalValue.of(maxDigits); - return this; - } - - public Builder setTimeoutMills(Integer timeoutMills) { - this.timeoutMills = OptionalValue.of(timeoutMills); - return this; - } - - public Builder setMaxTimeoutMills(Integer maxTimeoutMills) { - this.maxTimeoutMills = OptionalValue.of(maxTimeoutMills); - return this; - } - - public Builder setOptions(Collection options) { - this.options = OptionalValue.of(options); - return this; - } - - public Menu build() { - return new Menu( - id, mainPrompt, repeatPrompt, repeats, maxDigits, timeoutMills, maxTimeoutMills, options); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java deleted file mode 100644 index 54e4f5e78..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.models.DualToneMultiFrequency; - -public class MenuOption { - - private final OptionalValue dtfm; - private final OptionalValue action; - - private MenuOption( - OptionalValue dtfm, OptionalValue action) { - this.dtfm = dtfm; - this.action = action; - } - - public OptionalValue getDtfm() { - return dtfm; - } - - public OptionalValue getAction() { - return action; - } - - @Override - public String toString() { - return "MenuOption{" + "dtfm=" + dtfm + ", action=" + action + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue dtfm = OptionalValue.empty(); - OptionalValue action = OptionalValue.empty(); - - public Builder setDtfm(DualToneMultiFrequency dtfm) { - this.dtfm = OptionalValue.of(dtfm); - return this; - } - - public Builder setAction(MenuOptionAction action) { - this.action = OptionalValue.of(action); - return this; - } - - public MenuOption build() { - return new MenuOption(dtfm, action); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java deleted file mode 100644 index 44b3a111d..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import java.util.Objects; - -/** Navigates to the named menu */ -public class MenuOptionAction { - - private final MenuOptionActionType type; - private final String id; - - private MenuOptionAction(MenuOptionActionType type, String id) { - Objects.requireNonNull(type, "Action type cannot be null"); - this.type = type; - this.id = id; - } - - public String getId() { - return id; - } - - public MenuOptionActionType getType() { - return type; - } - - public static MenuOptionAction from(MenuOptionActionType type, String id) { - return new MenuOptionAction(type, id); - } - - @Override - public String toString() { - return "MenuOptionAction{" + "type=" + type + ", id='" + id + '\'' + '}'; - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionType.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionType.java deleted file mode 100644 index 1b1965fa3..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Menu Action type */ -public class MenuOptionActionType extends EnumDynamic { - - /** - * Triggers a Prompt Input Event (PIE) - * - * @see Prompt - * Input Event - */ - public static final MenuOptionActionType RETURN = new MenuOptionActionType("return"); - - /** Navigates to the named menu */ - public static final MenuOptionActionType MENU = new MenuOptionActionType("menu"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - MenuOptionActionType.class, MenuOptionActionType::new, Arrays.asList(RETURN, MENU)); - - private MenuOptionActionType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static MenuOptionActionType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(MenuOptionActionType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java deleted file mode 100644 index 4dc0c1ace..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.requests.Control; -import java.util.Collection; - -/** - * Class enabling to define SVAML actions and instructions - * - * @see SVAML - * Dcoumentation - */ -public class SVAMLControl extends Control { - private final OptionalValue> instructions; - private final OptionalValue action; - - private SVAMLControl( - OptionalValue> instructions, OptionalValue action) { - this.instructions = instructions; - this.action = action; - } - - /** - * Get instructions related to request - * - * @return See builder {@link Builder#setInstructions setter} - */ - public OptionalValue> getInstructions() { - return instructions; - } - - /** - * Get action related to request - * - * @return See builder {@link Builder#setAction setter} - */ - public OptionalValue getAction() { - return action; - } - - @Override - public String toString() { - return "SVAMLControl{" + "instructions=" + instructions + ", action=" + action + '}'; - } - - /** - * Create a builder instance - * - * @return Dedicated builder - */ - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue> instructions = OptionalValue.empty(); - OptionalValue action = OptionalValue.empty(); - - public Builder() {} - - /** - * The collection of instructions that can perform various tasks during the call - * - * @param instructions Instructions list - * @return Current builder - */ - public Builder setInstructions(Collection instructions) { - this.instructions = OptionalValue.of(instructions); - return this; - } - - /** - * The action that will control the call - * - * @param action The action description - * @return Current builder - */ - public Builder setAction(Action action) { - this.action = OptionalValue.of(action); - return this; - } - - /** - * Build the instance - * - * @return Built instance - */ - public SVAMLControl build() { - return new SVAMLControl(instructions, action); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java deleted file mode 100644 index 71fd8abb5..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class StartRecordingOptions { - - private final OptionalValue destinationUrl; - private final OptionalValue credentials; - private final OptionalValue format; - private final OptionalValue notificationEvents; - private final OptionalValue transcriptionOptions; - - private StartRecordingOptions( - OptionalValue destinationUrl, - OptionalValue credentials, - OptionalValue format, - OptionalValue notificationEvents, - OptionalValue transcriptionOptions) { - this.destinationUrl = destinationUrl; - this.credentials = credentials; - this.format = format; - this.notificationEvents = notificationEvents; - this.transcriptionOptions = transcriptionOptions; - } - - public OptionalValue getDestinationUrl() { - return destinationUrl; - } - - public OptionalValue getCredentials() { - return credentials; - } - - public OptionalValue getFormat() { - return format; - } - - public OptionalValue getNotificationEvents() { - return notificationEvents; - } - - public OptionalValue getTranscriptionOptions() { - return transcriptionOptions; - } - - @Override - public String toString() { - return "StartRecordingOptions{" - + "destinationUrl='" - + destinationUrl - + '\'' - + ", credentials='" - + credentials - + '\'' - + ", format='" - + format - + '\'' - + ", notificationEvents=" - + notificationEvents - + ", transcriptionOptions=" - + transcriptionOptions - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue destinationUrl = OptionalValue.empty(); - OptionalValue credentials = OptionalValue.empty(); - OptionalValue format = OptionalValue.empty(); - OptionalValue notificationEvents = OptionalValue.empty(); - OptionalValue transcriptionOptions = OptionalValue.empty(); - - public Builder setDestinationUrl(String destinationUrl) { - this.destinationUrl = OptionalValue.of(destinationUrl); - return this; - } - - public Builder setCredentials(String credentials) { - this.credentials = OptionalValue.of(credentials); - return this; - } - - public Builder setFormat(String format) { - this.format = OptionalValue.of(format); - return this; - } - - public Builder setNotificationEvents(Boolean notificationEvents) { - this.notificationEvents = OptionalValue.of(notificationEvents); - return this; - } - - public Builder setTranscriptionOptions(TranscriptionOptions transcriptionOptions) { - this.transcriptionOptions = OptionalValue.of(transcriptionOptions); - return this; - } - - public StartRecordingOptions build() { - return new StartRecordingOptions( - destinationUrl, credentials, format, notificationEvents, transcriptionOptions); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java deleted file mode 100644 index 5589b73d5..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.sinch.sdk.domains.voice.models.svaml; - -import com.sinch.sdk.core.models.OptionalValue; - -public class TranscriptionOptions { - - private final OptionalValue enabled; - private final OptionalValue locale; - - private TranscriptionOptions(OptionalValue enabled, OptionalValue locale) { - this.enabled = enabled; - this.locale = locale; - } - - public OptionalValue getEnabled() { - return enabled; - } - - public OptionalValue getLocale() { - return locale; - } - - @Override - public String toString() { - return "TranscriptionOptions{" + "enabled=" + enabled + ", locale='" + locale + '\'' + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - OptionalValue enabled = OptionalValue.empty(); - OptionalValue locale = OptionalValue.empty(); - - public Builder setEnabled(Boolean enabled) { - this.enabled = OptionalValue.of(enabled); - return this; - } - - public Builder setLocale(String locale) { - this.locale = OptionalValue.of(locale); - return this; - } - - public TranscriptionOptions build() { - return new TranscriptionOptions(enabled, locale); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java deleted file mode 100644 index f6b66e8e9..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Sinch Voice Application Markup Language (SVAML) related models - * - * @see SVAML - * documentation - * @since 1.0 - */ -package com.sinch.sdk.domains.voice.models.svaml; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetection.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetection.java deleted file mode 100644 index beec8937d..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetection.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - */ - -package com.sinch.sdk.domains.voice.models.v1.svaml.action; - -/** - * @deprecated use {@link - * com.sinch.sdk.domains.voice.models.v1.svaml.action.AnsweringMachineDetectionQuery} instead. - */ -@Deprecated -public interface ConnectPstnAnsweringMachineDetection extends AnsweringMachineDetectionQuery { - - /** - * Getting builder - * - * @return New Builder instance - */ - static Builder builder() { - return new ConnectPstnAnsweringMachineDetectionImpl.Builder(); - } - - /** - * Dedicated Builder - * - * @deprecated use {@link - * com.sinch.sdk.domains.voice.models.v1.svaml.action.AnsweringMachineDetectionQuery} instead. - */ - @Deprecated - interface Builder extends AnsweringMachineDetectionQuery.Builder { - - /** - * Create instance - * - * @return The instance build with current builder values - */ - ConnectPstnAnsweringMachineDetection build(); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetectionImpl.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetectionImpl.java deleted file mode 100644 index a4550cce7..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/ConnectPstnAnsweringMachineDetectionImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sinch.sdk.domains.voice.models.v1.svaml.action; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.sinch.sdk.core.models.OptionalValue; - -@Deprecated -public class ConnectPstnAnsweringMachineDetectionImpl extends AnsweringMachineDetectionQueryImpl - implements ConnectPstnAnsweringMachineDetection { - - public ConnectPstnAnsweringMachineDetectionImpl( - OptionalValue enabled, OptionalValue async) { - super(enabled, async); - } - - @Deprecated - static class Builder implements ConnectPstnAnsweringMachineDetection.Builder { - - OptionalValue enabled = OptionalValue.empty(); - OptionalValue async = OptionalValue.empty(); - - @JsonProperty(JSON_PROPERTY_ENABLED) - public Builder setEnabled(Boolean enabled) { - this.enabled = OptionalValue.of(enabled); - return this; - } - - @JsonProperty(JSON_PROPERTY_ASYNC) - public Builder setAsync(Boolean async) { - this.async = OptionalValue.of(async); - return this; - } - - public ConnectPstnAnsweringMachineDetectionImpl build() { - return new ConnectPstnAnsweringMachineDetectionImpl(enabled, async); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.java index 9bc3bf03c..2cc628ee3 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/v1/svaml/action/MenuOptionActionFactory.java @@ -2,7 +2,6 @@ import com.sinch.sdk.core.utils.EnumDynamic; import com.sinch.sdk.core.utils.EnumSupportDynamic; -import com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType; import java.util.Arrays; import java.util.Objects; import java.util.stream.Stream; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetection.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetection.java deleted file mode 100644 index 948e6a071..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetection.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.sinch.sdk.domains.voice.models.v1.webhooks; - -/** - * @deprecated - * @see AnsweringMachineDetection to be used in place of - */ -@Deprecated -public interface AnsweredCallEventAnsweringMachineDetection extends AnsweringMachineDetection { - - /** The determination by the system of who answered the call. */ - public class StatusEnum { - public static final AnsweringMachineDetection.StatusEnum MACHINE = - AnsweringMachineDetection.StatusEnum.MACHINE; - public static final AnsweringMachineDetection.StatusEnum HUMAN = - AnsweringMachineDetection.StatusEnum.HUMAN; - public static final AnsweringMachineDetection.StatusEnum NOTSURE = - AnsweringMachineDetection.StatusEnum.NOTSURE; - public static final AnsweringMachineDetection.StatusEnum HANGUP = - AnsweringMachineDetection.StatusEnum.HANGUP; - } - - /** - * Getting builder - * - * @return New Builder instance - */ - static Builder builder() { - return new AnsweredCallEventAnsweringMachineDetectionImpl.Builder(); - } - - /** Dedicated Builder */ - interface Builder extends AnsweringMachineDetection.Builder {} -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetectionImpl.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetectionImpl.java deleted file mode 100644 index fab3b2dd7..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/AnsweredCallEventAnsweringMachineDetectionImpl.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.sinch.sdk.domains.voice.models.v1.webhooks; - -public class AnsweredCallEventAnsweringMachineDetectionImpl extends AnsweringMachineDetectionImpl - implements AnsweredCallEventAnsweringMachineDetection { - - static class Builder extends AnsweringMachineDetectionImpl.Builder - implements AnsweredCallEventAnsweringMachineDetection.Builder {} -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/package-info.java deleted file mode 100644 index 2f6c91da4..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/v1/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Models related to Voice WebHooks - * - * @since 1.4 - */ -package com.sinch.sdk.domains.voice.models.v1.webhooks; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java deleted file mode 100644 index ab7de2661..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -/** - * If Answering Machine Detection (see AMD) is enabled, this - * object contains information about whether the call was answered by a machine. - */ -public class AmdAnswer { - - private final AmdAnswerStatusType status; - private final AmdAnswerReasonType reason; - private final Integer duration; - - private AmdAnswer(AmdAnswerStatusType status, AmdAnswerReasonType reason, Integer duration) { - this.status = status; - this.reason = reason; - this.duration = duration; - } - - /** - * Get the status - * - * @return Status value - */ - public AmdAnswerStatusType getStatus() { - return status; - } - - /** - * Get the reason - * - * @return Reason value - */ - public AmdAnswerReasonType getReason() { - return reason; - } - - /** - * Get the length of the call - * - * @return Call length - */ - public Integer getDuration() { - return duration; - } - - @Override - public String toString() { - return "AmdAnswer{" - + "status=" - + status - + ", reason=" - + reason - + ", duration=" - + duration - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - AmdAnswerStatusType status; - AmdAnswerReasonType reason; - Integer duration; - - public Builder setStatus(AmdAnswerStatusType status) { - this.status = status; - return this; - } - - public Builder setReason(AmdAnswerReasonType reason) { - this.reason = reason; - return this; - } - - public Builder setDuration(Integer duration) { - this.duration = duration; - return this; - } - - public AmdAnswer build() { - return new AmdAnswer(status, reason, duration); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java deleted file mode 100644 index b73d8fb99..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** The reason that the system used to determine who answered the call. */ -public class AmdAnswerReasonType extends EnumDynamic { - - /** If the greeting is too long, this could be indicative of an answering machine. */ - public static final AmdAnswerReasonType LONG_GREETING = new AmdAnswerReasonType("longgreeting"); - - /** - * If there is an initial silence after the call is answered before the greeting starts, this - * could be indicative of an answering machine. - */ - public static final AmdAnswerReasonType INITIAL_SILENCE = - new AmdAnswerReasonType("initialsilence"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - AmdAnswerReasonType.class, - AmdAnswerReasonType::new, - Arrays.asList(LONG_GREETING, INITIAL_SILENCE)); - - private AmdAnswerReasonType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static AmdAnswerReasonType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(AmdAnswerReasonType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java deleted file mode 100644 index 711d4c653..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** The status of a call */ -public class AmdAnswerStatusType extends EnumDynamic { - - /** An answering machine was detected as answering the call. */ - public static final AmdAnswerStatusType MACHINE = new AmdAnswerStatusType("machine"); - - /** A human was detected as answering the call. */ - public static final AmdAnswerStatusType HUMAN = new AmdAnswerStatusType("human"); - - /** The system was unable to determine who answered the call. */ - public static final AmdAnswerStatusType NOTSURE = new AmdAnswerStatusType("notsure"); - - /** The call was hung up. */ - public static final AmdAnswerStatusType HANGUP = new AmdAnswerStatusType("hangup"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - AmdAnswerStatusType.class, - AmdAnswerStatusType::new, - Arrays.asList(MACHINE, HUMAN, NOTSURE, HANGUP)); - - private AmdAnswerStatusType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static AmdAnswerStatusType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(AmdAnswerStatusType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java deleted file mode 100644 index 6ebdec096..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import java.time.Instant; - -/** - * This callback is made when the call is picked up by the callee (person receiving the call). - * - *

It's a POST request to the specified calling callback URL. Look here for allowed {@link - * com.sinch.sdk.domains.voice.models.svaml.Action instructions} and {@link - * com.sinch.sdk.domains.voice.models.svaml.Instruction actions}. - * - *

If there is no response to the callback within the timeout period, the call is connected. - * - *

If you have Answering Machine Detection (AMD) enabled, the amd - * object will also be present on ACE callbacks. - * - *

Note: ACE Callbacks are not issued for InApp Calls (destination: username), only PSTN and SIP - * calls. - * - * @see ACE - */ -public class AnsweredCallEvent extends CallEvent { - - private final AmdAnswer amd; - - private AnsweredCallEvent( - String callId, Instant timestamp, Integer version, String custom, AmdAnswer amd) { - super(callId, timestamp, version, custom); - this.amd = amd; - } - - /** - * If Answering Machine Detection is enabled, this object contains information about whether the - * call was answered by a machine. - * - * @return AMD Answer value - */ - public AmdAnswer getAmd() { - return amd; - } - - @Override - public String toString() { - return "AnsweredCallEvent{" + "amd=" + amd + "} " + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends CallEvent.Builder> { - - AmdAnswer amd; - - public Builder setAmd(AmdAnswer amd) { - this.amd = amd; - return this; - } - - public AnsweredCallEvent build() { - return new AnsweredCallEvent(callId, timestamp, version, custom, amd); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java deleted file mode 100644 index 9f741bb7b..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import com.sinch.sdk.domains.sms.models.DeliveryReportBatch.Builder; -import java.time.Instant; - -/** Base class for webhooks call event */ -public class CallEvent extends WebhooksEvent { - - private final Instant timestamp; - private final String custom; - - protected CallEvent(String callId, Instant timestamp, Integer version, String custom) { - super(callId, version); - this.timestamp = timestamp; - this.custom = custom; - } - - /** - * Event timestamp - * - * @return Timestamp value - */ - public Instant getTimestamp() { - return timestamp; - } - - /** - * A string that can be used to pass custom information related to the call. - * - * @return The custom value used for call - */ - public String getCustom() { - return custom; - } - - @Override - public String toString() { - return "CallEvent{" + "timestamp=" + timestamp + ", custom='" + custom + '\'' + '}'; - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends WebhooksEvent.Builder { - - Instant timestamp; - String custom; - - public B setTimestamp(Instant timestamp) { - this.timestamp = timestamp; - return self(); - } - - public B setCustom(String custom) { - this.custom = custom; - return self(); - } - - public CallEvent build() { - return new CallEvent(callId, timestamp, version, custom); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java deleted file mode 100644 index 7429a2d1f..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java +++ /dev/null @@ -1,229 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import com.sinch.sdk.domains.voice.models.CallReasonType; -import com.sinch.sdk.domains.voice.models.CallResultType; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.Price; -import java.time.Instant; - -/** - * This callback is made when the call is disconnected. - * - *

It's a POST request to the specified calling callback URL. This event doesn't support - * instructions and only supports the hangup action. - * - * @see DICE - */ -public class DisconnectCallEvent extends CallEvent { - - private final CallReasonType reason; - private final CallResultType result; - private final Price debit; - private final Price userRate; - private final Destination to; - private final String applicationKey; - private final Integer duration; - private final String from; - - private DisconnectCallEvent( - String callId, - Instant timestamp, - Integer version, - String custom, - CallReasonType reason, - CallResultType result, - Price debit, - Price userRate, - Destination to, - String applicationKey, - Integer duration, - String from) { - super(callId, timestamp, version, custom); - this.reason = reason; - this.result = result; - this.debit = debit; - this.userRate = userRate; - this.to = to; - this.applicationKey = applicationKey; - this.duration = duration; - this.from = from; - } - - /** - * The reason the call was disconnected - * - * @return Reason value - */ - public CallReasonType getReason() { - return reason; - } - - /** - * The result of the call - * - * @return Result value - */ - public CallResultType getResult() { - return result; - } - - /** - * Amount charged for the call - * - * @return charge value - */ - public Price getDebit() { - return debit; - } - - /** - * Rate per minute for the call - * - * @return rate value - */ - public Price getUserRate() { - return userRate; - } - - /** - * Information about the recipient of the call - * - * @return Recipient information - */ - public Destination getTo() { - return to; - } - - /** - * The unique application key - * - * @return Application key value - */ - public String getApplicationKey() { - return applicationKey; - } - - /** - * The duration of the call in seconds - * - * @return Call duration - */ - public Integer getDuration() { - return duration; - } - - /** - * Information about the initiator of the call. - * - * @return Initiator information - */ - public String getFrom() { - return from; - } - - @Override - public String toString() { - return "DisconnectCallEvent{" - + "reason='" - + reason - + '\'' - + ", result='" - + result - + '\'' - + ", debit=" - + debit - + ", userRate=" - + userRate - + ", to=" - + to - + ", applicationKey='" - + applicationKey - + '\'' - + ", duration=" - + duration - + ", from='" - + from - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends CallEvent.Builder> { - - CallReasonType reason; - CallResultType result; - Price debit; - Price userRate; - Destination to; - String applicationKey; - Integer duration; - String from; - - public B setReason(CallReasonType reason) { - this.reason = reason; - return self(); - } - - public B setResult(CallResultType result) { - this.result = result; - return self(); - } - - public B setDebit(Price debit) { - this.debit = debit; - return self(); - } - - public B setUserRate(Price userRate) { - this.userRate = userRate; - return self(); - } - - public B setTo(Destination to) { - this.to = to; - return self(); - } - - public B setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - return self(); - } - - public B setDuration(Integer duration) { - this.duration = duration; - return self(); - } - - public B setFrom(String from) { - this.from = from; - return self(); - } - - public DisconnectCallEvent build() { - return new DisconnectCallEvent( - callId, - timestamp, - version, - custom, - reason, - result, - debit, - userRate, - to, - applicationKey, - duration, - from); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java deleted file mode 100644 index f250db15c..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java +++ /dev/null @@ -1,285 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.voice.models.Destination; -import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.Price; -import com.sinch.sdk.domains.voice.models.webhooks.CallEvent.Builder; -import java.time.Instant; -import java.util.Collection; - -/** - * This event, called the ICE event, can be triggered by either an incoming data call or an incoming - * PSTN call. - * - *

It's a POST request to the specified calling callback URL. Look here for allowed {@link - * com.sinch.sdk.domains.voice.models.svaml.Action instructions} and {@link - * com.sinch.sdk.domains.voice.models.svaml.Instruction actions}. - * - *

If there is no response to the callback within the timeout period, an error message is played, - * and the call is disconnected. - * - * @see ICE - */ -public class IncomingCallEvent extends CallEvent { - - private final String callResourceUrl; - private final Price userRate; - private final String cli; - private final Destination to; - private final DomainType domain; - private final String applicationKey; - private final DomainType originationType; - private final Integer duration; - private final String rdnis; - private final Collection> callHeaders; - - private IncomingCallEvent( - String callId, - Instant timestamp, - Integer version, - String custom, - String callResourceUrl, - Price userRate, - String cli, - Destination to, - DomainType domain, - String applicationKey, - DomainType originationType, - Integer duration, - String rdnis, - Collection> callHeaders) { - super(callId, timestamp, version, custom); - this.callResourceUrl = callResourceUrl; - this.userRate = userRate; - this.cli = cli; - this.to = to; - this.domain = domain; - this.applicationKey = applicationKey; - this.originationType = originationType; - this.duration = duration; - this.rdnis = rdnis; - this.callHeaders = callHeaders; - } - - /** - * The path of the API resource - * - * @return path value - */ - public String getCallResourceUrl() { - return callResourceUrl; - } - - /** - * Charged for the call established to the original destination. If the SVAML response specifies - * another destination, the same rate may not apply. - * - * @return charged value - */ - public Price getUserRate() { - return userRate; - } - - /** - * The number that will be displayed to the recipient of the call. - * - *

To set your own CLI, you may use your verified number or your Dashboard virtual number and - * add it to the {@link com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn - * ActionConnectPstn} SVAML response to the Incoming Call Event request. - * - * @return - */ - public String getCli() { - return cli; - } - - /** - * Information about the recipient of the call - * - * @return information value - */ - public Destination getTo() { - return to; - } - - /** - * The domain destination of the incoming call - * - * @return Domain value - */ - public DomainType getDomain() { - return domain; - } - - /** - * The unique application key - * - * @return Application key value - */ - public String getApplicationKey() { - return applicationKey; - } - - /** - * The origination domain of the incoming call - * - * @return Origin type - */ - public DomainType getOriginationType() { - return originationType; - } - - /** - * The duration of the call in seconds - * - * @return Duration value - */ - public Integer getDuration() { - return duration; - } - - /** - * The redirected dialled number identification service - * - * @return RDNIS value - */ - public String getRdnis() { - return rdnis; - } - - /** - * If the call is initiated by a Sinch SDK client, call headers are the headers specified by the - * caller client. Read more about call headers here - * - * @return Headers - */ - public Collection> getCallHeaders() { - return callHeaders; - } - - @Override - public String toString() { - return "IncomingCallEvent{" - + "callResourceUrl='" - + callResourceUrl - + '\'' - + ", userRate=" - + userRate - + ", cli='" - + cli - + '\'' - + ", to=" - + to - + ", domain=" - + domain - + ", applicationKey='" - + applicationKey - + '\'' - + ", originationType=" - + originationType - + ", duration=" - + duration - + ", rdnis='" - + rdnis - + '\'' - + ", callHeaders=" - + callHeaders - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends CallEvent.Builder> { - - String callResourceUrl; - Price userRate; - String cli; - Destination to; - DomainType domain; - String applicationKey; - DomainType originationType; - Integer duration; - String rdnis; - Collection> callHeaders; - - public B setCallResourceUrl(String callResourceUrl) { - this.callResourceUrl = callResourceUrl; - return self(); - } - - public B setUserRate(Price userRate) { - this.userRate = userRate; - return self(); - } - - public B setCli(String cli) { - this.cli = cli; - return self(); - } - - public B setTo(Destination to) { - this.to = to; - return self(); - } - - public B setDomain(DomainType domain) { - this.domain = domain; - return self(); - } - - public B setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - return self(); - } - - public B setOriginationType(DomainType originationType) { - this.originationType = originationType; - return self(); - } - - public B setDuration(Integer duration) { - this.duration = duration; - return self(); - } - - public B setRdnis(String rdnis) { - this.rdnis = rdnis; - return self(); - } - - public B setCallHeaders(Collection> callHeaders) { - this.callHeaders = callHeaders; - return self(); - } - - public IncomingCallEvent build() { - return new IncomingCallEvent( - callId, - timestamp, - version, - custom, - callResourceUrl, - userRate, - cli, - to, - domain, - applicationKey, - originationType, - duration, - rdnis, - callHeaders); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java deleted file mode 100644 index 9308885d3..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -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 information that's returned */ -public class MenuInputType extends EnumDynamic { - - /** Returned if there's an error with the input. */ - public static final MenuInputType ERROR = new MenuInputType("error"); - - /** Returned when the event has been triggered from a return command */ - public static final MenuInputType RETURN = new MenuInputType("return"); - - /** Returned when the event has been triggered from collecting DTMF digits */ - public static final MenuInputType SEQUENCE = new MenuInputType("sequence"); - - /** Returned when the timeout period has elapsed */ - public static final MenuInputType TIMEOUT = new MenuInputType("timeout"); - - /** Returned when the call is hung up */ - public static final MenuInputType HANGUP = new MenuInputType("hangup"); - - /** InvalidInput */ - public static final MenuInputType INVALID_INPUT = new MenuInputType("invalidinput"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - MenuInputType.class, - MenuInputType::new, - Arrays.asList(ERROR, RETURN, SEQUENCE, TIMEOUT, HANGUP, INVALID_INPUT)); - - private MenuInputType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static MenuInputType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(MenuInputType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java deleted file mode 100644 index 2a3c0a9ed..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -public class MenuResult { - - private final String menuId; - private final MenuInputType type; - private final String value; - private final MenuResultInputMethodType inputMethod; - - private MenuResult( - String menuId, MenuInputType type, String value, MenuResultInputMethodType inputMethod) { - this.menuId = menuId; - this.type = type; - this.value = value; - this.inputMethod = inputMethod; - } - - public String getMenuId() { - return menuId; - } - - public MenuInputType getType() { - return type; - } - - public String getValue() { - return value; - } - - public MenuResultInputMethodType getInputMethod() { - return inputMethod; - } - - @Override - public String toString() { - return "MenuResult{" - + "menuId='" - + menuId - + '\'' - + ", type=" - + type - + ", value='" - + value - + '\'' - + ", inputMethod=" - + inputMethod - + '}'; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - - String menuId; - MenuInputType type; - String value; - MenuResultInputMethodType inputMethod; - - public Builder setMenuId(String menuId) { - this.menuId = menuId; - return this; - } - - public Builder setType(MenuInputType type) { - this.type = type; - return this; - } - - public Builder setValue(String value) { - this.value = value; - return this; - } - - public Builder setInputMethod(MenuResultInputMethodType inputMethod) { - this.inputMethod = inputMethod; - return this; - } - - public MenuResult build() { - return new MenuResult(menuId, type, value, inputMethod); - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java deleted file mode 100644 index 0c4965eef..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -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 input received. */ -public class MenuResultInputMethodType extends EnumDynamic { - - /** The input is key presses of specified digits */ - public static final MenuResultInputMethodType DTMF = new MenuResultInputMethodType("dtmf"); - - /** The input is voice answers */ - public static final MenuResultInputMethodType VOICE = new MenuResultInputMethodType("voice"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - MenuResultInputMethodType.class, - MenuResultInputMethodType::new, - Arrays.asList(VOICE, DTMF)); - - private MenuResultInputMethodType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static MenuResultInputMethodType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(MenuResultInputMethodType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java deleted file mode 100644 index a48be7115..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -/** - * This is the general callback used to send notifications. It's a POST request to the specified - * calling callback URL. - * - *

If there is no response to the callback within the timeout period, the notification is - * discarded. - */ -public class NotifyEvent extends WebhooksEvent { - - private final String custom; - private final String type; - - private NotifyEvent(String callId, Integer version, String custom, String type) { - super(callId, version); - this.custom = custom; - this.type = type; - } - - /** - * An optional parameter containing notification-specific information - * - * @return custom value - */ - public String getCustom() { - return custom; - } - - /** - * The type of information communicated in the notification - * - * @return type value - */ - public String getType() { - return type; - } - - @Override - public String toString() { - return "NotifyEvent{" - + "custom='" - + custom - + '\'' - + ", type='" - + type - + '\'' - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends WebhooksEvent.Builder> { - - String custom; - String type; - - public B setCustom(String custom) { - this.custom = custom; - return self(); - } - - public B setType(String type) { - this.type = type; - return self(); - } - - public NotifyEvent build() { - return new NotifyEvent(callId, version, custom, type); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java deleted file mode 100644 index d22141437..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -import java.time.Instant; - -/** - * This callback is triggered as a result of a {@link - * com.sinch.sdk.domains.voice.models.svaml.ActionRunMenu runMenu} action. It can be triggered from - * either a user pressing a number of DTMF digits, or by the {@link - * com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType#RETURN return} command. - * - *

It's a POST request to the specified calling callback URL. Your application can respond with - * {@link com.sinch.sdk.domains.voice.models.svaml SVAML} logic. - * - *

Note: PIE callbacks are not issued for DATA Calls, only PSTN and SIP calls. - * - * @see PIE - */ -public class PromptInputEvent extends CallEvent { - - private final String applicationKey; - private final MenuResult menuResult; - - private PromptInputEvent( - String callId, - Instant timestamp, - Integer version, - String custom, - String applicationKey, - MenuResult menuResult) { - super(callId, timestamp, version, custom); - this.applicationKey = applicationKey; - this.menuResult = menuResult; - } - - /** - * The unique application key - * - * @return Application key value - */ - public String getApplicationKey() { - return applicationKey; - } - - /** - * Information about the returned menu result - * - * @return Menu - */ - public MenuResult getMenuResult() { - return menuResult; - } - - @Override - public String toString() { - return "PromptInputEvent{" - + "applicationKey='" - + applicationKey - + '\'' - + ", menuResult=" - + menuResult - + "} " - + super.toString(); - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> extends CallEvent.Builder> { - - String applicationKey; - MenuResult menuResult; - - public Builder setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - return this; - } - - public Builder setMenuResult(MenuResult menuResult) { - this.menuResult = menuResult; - return this; - } - - public PromptInputEvent build() { - return new PromptInputEvent(callId, timestamp, version, custom, applicationKey, menuResult); - } - - @Override - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java deleted file mode 100644 index a8160e755..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.sinch.sdk.domains.voice.models.webhooks; - -public class WebhooksEvent { - - private final String callId; - private final Integer version; - - protected WebhooksEvent(String callId, Integer version) { - this.callId = callId; - this.version = version; - } - - /** - * The unique ID assigned to call related to this event - * - * @return Call ID value - */ - public String getCallId() { - return callId; - } - - /** - * The current API version - * - * @return API version sending the event - */ - public Integer getVersion() { - return version; - } - - @Override - public String toString() { - return "CallEvent{" + "callId='" + callId + '\'' + ", version=" + version + '}'; - } - - public static Builder builder() { - return new Builder<>(); - } - - public static class Builder> { - - String callId; - Integer version; - - public B setCallId(String callId) { - this.callId = callId; - return self(); - } - - public B setVersion(Integer version) { - this.version = version; - return self(); - } - - public WebhooksEvent build() { - return new WebhooksEvent(callId, version); - } - - @SuppressWarnings("unchecked") - protected B self() { - return (B) this; - } - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java deleted file mode 100644 index d21f6bf50..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Voice API webhooks related models - * - * @since 1.0 - */ -package com.sinch.sdk.domains.voice.models.webhooks; diff --git a/client/src/main/com/sinch/sdk/http/HttpClientApache.java b/client/src/main/com/sinch/sdk/http/HttpClientApache.java index b08eb037b..ed4918628 100644 --- a/client/src/main/com/sinch/sdk/http/HttpClientApache.java +++ b/client/src/main/com/sinch/sdk/http/HttpClientApache.java @@ -49,7 +49,7 @@ public class HttpClientApache implements com.sinch.sdk.core.http.HttpClient { private Map headersToBeAdded; - private CloseableHttpClient client; + private volatile CloseableHttpClient client; public HttpClientApache() { this.client = HttpClients.createDefault(); @@ -200,7 +200,8 @@ private boolean processUnauthorizedResponse( Map> responseHeaders = response.getHeaders(); Collection header = responseHeaders.get(BEARER_AUTHENTICATE_RESPONSE_HEADER_KEYWORD); - boolean headerPresent = header.stream().anyMatch(e -> e.contains(BEARER_EXPIRED_KEYWORD)); + boolean headerPresent = + header != null && header.stream().anyMatch(e -> e.contains(BEARER_EXPIRED_KEYWORD)); if (headerPresent) { bearerAuthManager.resetToken(); } @@ -332,7 +333,7 @@ private void addAuth( } } - private HttpResponse processRequest(CloseableHttpClient client, ClassicHttpRequest request) + HttpResponse processRequest(CloseableHttpClient client, ClassicHttpRequest request) throws IOException { return client.execute(request, HttpClientApache::processResponse); } diff --git a/client/src/main/com/sinch/sdk/models/Configuration.java b/client/src/main/com/sinch/sdk/models/Configuration.java index ff051686b..913a52713 100644 --- a/client/src/main/com/sinch/sdk/models/Configuration.java +++ b/client/src/main/com/sinch/sdk/models/Configuration.java @@ -9,38 +9,32 @@ public class Configuration { private final UnifiedCredentials unifiedCredentials; private final ApplicationCredentials applicationCredentials; private final SmsServicePlanCredentials smsServicePlanCredentials; - private final MailgunCredentials mailgunCredentials; private final String oauthUrl; private final NumbersContext numbersContext; private final SmsContext smsContext; private final VerificationContext verificationContext; private final VoiceContext voiceContext; private final ConversationContext conversationContext; - private final MailgunContext mailgunContext; private Configuration( UnifiedCredentials unifiedCredentials, ApplicationCredentials applicationCredentials, SmsServicePlanCredentials smsServicePlanCredentials, - MailgunCredentials mailgunCredentials, String oauthUrl, NumbersContext numbersContext, SmsContext smsContext, VerificationContext verificationContext, VoiceContext voiceContext, - ConversationContext conversationContext, - MailgunContext mailgunContext) { + ConversationContext conversationContext) { this.unifiedCredentials = unifiedCredentials; this.applicationCredentials = applicationCredentials; this.smsServicePlanCredentials = smsServicePlanCredentials; - this.mailgunCredentials = mailgunCredentials; this.oauthUrl = oauthUrl; this.numbersContext = numbersContext; this.smsContext = smsContext; this.voiceContext = voiceContext; this.verificationContext = verificationContext; this.conversationContext = conversationContext; - this.mailgunContext = mailgunContext; } @Override @@ -61,8 +55,6 @@ public String toString() { + conversationContext + ", conversationContext=" + conversationContext - + ", mailgunContext=" - + mailgunContext + "}"; } @@ -77,16 +69,6 @@ public Optional getUnifiedCredentials() { return Optional.ofNullable(unifiedCredentials); } - /** - * Get Mailgun service credentials - * - * @return Credentials - * @since 1.6 - */ - public Optional getMailgunCredentials() { - return Optional.ofNullable(mailgunCredentials); - } - /** * Get SMS service plan ID credentials * @@ -180,16 +162,6 @@ public Optional getConversationContext() { return Optional.ofNullable(conversationContext); } - /** - * Get Mailgun domain related execution context - * - * @return Current Voice context - * @since 1.6 - */ - public Optional getMailgunContext() { - return Optional.ofNullable(mailgunContext); - } - /** * Getting Builder * @@ -227,8 +199,6 @@ public static class Builder { VerificationContext.Builder verificationContext; VoiceContext.Builder voiceContext; ConversationContext.Builder conversationContext; - MailgunCredentials.Builder mailgunCredentials; - MailgunContext.Builder mailgunContext; protected Builder() {} @@ -260,11 +230,6 @@ protected Builder(Configuration configuration) { this.voiceContext = configuration.getVoiceContext().map(VoiceContext::builder).orElse(null); this.conversationContext = configuration.getConversationContext().map(ConversationContext::builder).orElse(null); - - this.mailgunCredentials = - configuration.getMailgunCredentials().map(MailgunCredentials::builder).orElse(null); - this.mailgunContext = - configuration.getMailgunContext().map(MailgunContext::builder).orElse(null); } /** @@ -523,63 +488,6 @@ public Builder setConversationContext(ConversationContext context) { return this; } - /** - * Set Mailgun related api key - * - * @param apiKey {@link MailgunCredentials#getApiKey()} - * @return Current builder - * @since 1.6 - */ - public Builder setMailgunApiKey(String apiKey) { - if (null == this.mailgunCredentials) { - this.mailgunCredentials = MailgunCredentials.builder(); - } - this.mailgunCredentials.setApiKey(apiKey); - return this; - } - - /** - * Set Mailgun API URL - * - * @param url Mailgun API URL - * @return Current builder - * @since 1.6 - */ - public Builder setMailgunUrl(String url) { - if (null == this.mailgunContext) { - this.mailgunContext = MailgunContext.builder(); - } - this.mailgunContext.setUrl(url); - return this; - } - - /** - * Set Mailgun related region - * - * @param region {@link MailgunContext#getRegion()} - * @return Current builder - * @since 1.0 - */ - public Builder setMailgunRegion(MailgunRegion region) { - if (null == this.mailgunContext) { - this.mailgunContext = MailgunContext.builder(); - } - this.mailgunContext.setRegion(region); - return this; - } - - /** - * Set Mailgun related context - * - * @param context {@link #getMailgunContext()} - * @return Current builder - * @since 1.6 - */ - public Builder setMailgunContext(MailgunContext context) { - this.mailgunContext = null != context ? MailgunContext.builder(context) : null; - return this; - } - /** * Build a Configuration instance from builder current state * @@ -592,14 +500,12 @@ public Configuration build() { null != unifiedCredentials ? unifiedCredentials.build() : null, null != applicationCredentials ? applicationCredentials.build() : null, null != smsServicePlanCredentials ? smsServicePlanCredentials.build() : null, - null != mailgunCredentials ? mailgunCredentials.build() : null, oauthUrl, null != numbersContext ? numbersContext.build() : null, null != smsContext ? smsContext.build() : null, null != verificationContext ? verificationContext.build() : null, null != voiceContext ? voiceContext.build() : null, - null != conversationContext ? conversationContext.build() : null, - null != mailgunContext ? mailgunContext.build() : null); + null != conversationContext ? conversationContext.build() : null); } } } diff --git a/client/src/main/com/sinch/sdk/models/ConversationContext.java b/client/src/main/com/sinch/sdk/models/ConversationContext.java index c42f0bff4..8406cb76a 100644 --- a/client/src/main/com/sinch/sdk/models/ConversationContext.java +++ b/client/src/main/com/sinch/sdk/models/ConversationContext.java @@ -1,7 +1,6 @@ package com.sinch.sdk.models; import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.models.SmsContext.Builder; /** Execution context related to Conversation domains */ public class ConversationContext { @@ -9,17 +8,11 @@ public class ConversationContext { private final ConversationRegion region; private final String url; private final String templateManagementUrl; - private final Boolean regionAsDefault; - private ConversationContext( - ConversationRegion region, - String url, - String templateManagementUrl, - Boolean regionAsDefault) { + private ConversationContext(ConversationRegion region, String url, String templateManagementUrl) { this.region = region; this.url = url; this.templateManagementUrl = templateManagementUrl; - this.regionAsDefault = regionAsDefault; } /** @@ -72,14 +65,6 @@ public ServerConfiguration getTemplateManagementServer() { return new ServerConfiguration(getTemplateManagementUrl()); } - /** - * @deprecated Helper for transition period until 2.0 release - */ - @Deprecated - public Boolean regionAsDefault() { - return regionAsDefault; - } - /** * Getting Builder * @@ -111,7 +96,6 @@ public static class Builder { ConversationRegion region; String url; String templateManagementUrl; - Boolean regionAsDefault; protected Builder() {} @@ -125,7 +109,6 @@ protected Builder(ConversationContext context) { this.region = null != context ? context.getRegion() : null; this.url = null != context ? context.getUrl() : null; this.templateManagementUrl = null != context ? context.getTemplateManagementUrl() : null; - this.regionAsDefault = null != context ? context.regionAsDefault() : null; } /** @@ -164,14 +147,6 @@ public Builder setTemplateManagementUrl(String templateManagementUrl) { return this; } - /** - * @deprecated Helper for transition period until 2.0 release - */ - public Builder setRegionAsDefault(Boolean regionAsDefault) { - this.regionAsDefault = regionAsDefault; - return this; - } - public ConversationRegion getRegion() { return region; } @@ -184,10 +159,6 @@ public String getTemplateManagementUrl() { return templateManagementUrl; } - public Boolean getRegionAsDefault() { - return regionAsDefault; - } - /** * Create instance * @@ -196,7 +167,7 @@ public Boolean getRegionAsDefault() { */ public ConversationContext build() { - return new ConversationContext(region, url, templateManagementUrl, regionAsDefault); + return new ConversationContext(region, url, templateManagementUrl); } } } diff --git a/client/src/main/com/sinch/sdk/models/MailgunContext.java b/client/src/main/com/sinch/sdk/models/MailgunContext.java deleted file mode 100644 index a76672e7f..000000000 --- a/client/src/main/com/sinch/sdk/models/MailgunContext.java +++ /dev/null @@ -1,199 +0,0 @@ -package com.sinch.sdk.models; - -import com.sinch.sdk.core.models.ServerConfiguration; -import java.util.Collection; -import java.util.Collections; -import java.util.stream.Collectors; - -/** - * Execution context related to Mailgun domains - * - * @since 1.6 - */ -public class MailgunContext { - - private final MailgunRegion region; - private final String url; - private final Collection storageUrls; - private final Boolean regionAsDefault; - - private MailgunContext( - MailgunRegion region, String url, Collection storageUrls, Boolean regionAsDefault) { - this.region = region; - this.url = url; - this.storageUrls = null == storageUrls ? Collections.emptyList() : storageUrls; - this.regionAsDefault = regionAsDefault; - } - - /** - * Mailgun region - * - * @return Selected Region - * @since 1.6 - */ - public MailgunRegion getRegion() { - return region; - } - - /** - * Mailgun Server Configuration - * - * @return Mailgun Server configuration to be used - * @since 1.6 - */ - public ServerConfiguration getServer() { - return new ServerConfiguration(getUrl()); - } - - /** - * Mailgun Storage Servers Configuration - * - * @return Mailgun Storage Server configuration to be used - * @since 1.6 - */ - public Collection getStorageServers() { - return storageUrls.stream().map(ServerConfiguration::new).collect(Collectors.toList()); - } - - /** - * Mailgun URL - * - * @return Mailgun Server URL - * @since 1.6 - */ - public String getUrl() { - return url; - } - - /** - * Mailgun Storage URLs - * - * @return Mailgun Storage Server URLs - * @since 1.6 - */ - public Collection getStorageUrls() { - return storageUrls; - } - - /** - * @deprecated Helper for transition period until 2.0 release - */ - @Deprecated - public Boolean getRegionAsDefault() { - return regionAsDefault; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.6 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Getting Builder - * - * @param context Source context to fill initial builder state - * @return New Builder instance - * @since 1.6 - */ - public static Builder builder(MailgunContext context) { - return new Builder(context); - } - - /** - * Dedicated Builder - * - * @since 1.6 - */ - public static class Builder { - - MailgunRegion region; - String url; - Collection storageUrls; - Boolean regionAsDefault; - - protected Builder() {} - - protected Builder(MailgunContext context) { - this.region = null != context ? context.getRegion() : null; - this.url = null != context ? context.getUrl() : null; - this.storageUrls = null != context ? context.getStorageUrls() : null; - this.regionAsDefault = null != context ? context.getRegionAsDefault() : null; - } - - /** - * Set region to be used for Mailgun service - * - * @param region The region - * @return Current builder - * @since 1.0 - */ - public Builder setRegion(MailgunRegion region) { - this.region = region; - return this; - } - - /** - * Set Mailgun API URL - * - * @param url Mailgun API URL - * @return Current builder - * @since 1.6 - */ - public Builder setUrl(String url) { - this.url = url; - return this; - } - - /** - * Set Mailgun Storage URLs - * - * @param storageUrls List of storage URLs - * @return Current builder - * @since 1.6 - */ - public Builder setStorageUrls(Collection storageUrls) { - this.storageUrls = storageUrls; - return this; - } - - public MailgunRegion getRegion() { - return region; - } - - public String getUrl() { - return url; - } - - public Collection getStorageUrls() { - return storageUrls; - } - - public Boolean getRegionAsDefault() { - return regionAsDefault; - } - - /** - * @deprecated Helper for transition period until 2.0 release - */ - public Builder setRegionAsDefault(Boolean regionAsDefault) { - this.regionAsDefault = regionAsDefault; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.6 - */ - public MailgunContext build() { - - return new MailgunContext(region, url, storageUrls, regionAsDefault); - } - } -} diff --git a/client/src/main/com/sinch/sdk/models/MailgunCredentials.java b/client/src/main/com/sinch/sdk/models/MailgunCredentials.java deleted file mode 100644 index c3af4d27b..000000000 --- a/client/src/main/com/sinch/sdk/models/MailgunCredentials.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.sinch.sdk.models; - -/** - * Credentials related to Mailgun authentication - * - * @since 1.6 - */ -public class MailgunCredentials { - - private final String apiUser; - private final String apiKey; - - private MailgunCredentials(String apiKey) { - apiUser = "api"; - this.apiKey = apiKey; - } - - /** - * @since 1.6 - */ - public String getApiUser() { - return apiUser; - } - - /** - * @since 1.6 - */ - public String getApiKey() { - return apiKey; - } - - /** - * Getting Builder - * - * @return New Builder instance - * @since 1.6 - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Getting Builder - * - * @param credentials Source credentials to fill initial builder state - * @return New Builder instance - * @since 1.6 - */ - public static Builder builder(MailgunCredentials credentials) { - return new Builder(credentials); - } - - /** - * Dedicated Builder - * - * @since 1.6 - */ - public static class Builder { - - String apiKey; - - protected Builder() {} - - /** - * Initialize a builder with existing credentials - * - * @param credentials Credentials to be used as initial builder state - * @since 1.6 - */ - protected Builder(MailgunCredentials credentials) { - this.apiKey = null != credentials ? credentials.getApiKey() : null; - } - - /** - * Set Mailgun api key - * - * @param apiKey api key to be used - * @return Current builder - * @since 1.6 - */ - public Builder setApiKey(String apiKey) { - this.apiKey = apiKey; - return this; - } - - /** - * Create instance - * - * @return The instance build with current builder values - * @since 1.6 - */ - public MailgunCredentials build() { - return new MailgunCredentials(apiKey); - } - } -} diff --git a/client/src/main/com/sinch/sdk/models/MailgunRegion.java b/client/src/main/com/sinch/sdk/models/MailgunRegion.java deleted file mode 100644 index 3afe48f2d..000000000 --- a/client/src/main/com/sinch/sdk/models/MailgunRegion.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.sinch.sdk.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** - * Mailgun Regions - * - * @see Mailgun - * Regions - * @since 1.6 - */ -public class MailgunRegion extends EnumDynamic { - - /** United States - default */ - public static final MailgunRegion US = new MailgunRegion("us"); - - /** Europe */ - public static final MailgunRegion EUROPE = new MailgunRegion("eu"); - - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>(MailgunRegion.class, MailgunRegion::new, Arrays.asList(US, EUROPE)); - - private MailgunRegion(String value) { - super(value); - } - - /** - * Get declared values - * - * @return Stream of values - */ - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - /** - * Get value from a string - * - * @param value String identifier - * @return Dynamic enum from value. A new enum is created if value is not yet registered - */ - public static MailgunRegion from(String value) { - return ENUM_SUPPORT.from(value); - } - - /** - * Value of the enum as String - * - * @param value The enum identifier - * @return String identifier of the enum value - */ - public static String valueOf(MailgunRegion value) { - return ENUM_SUPPORT.valueOf(value); - } -} diff --git a/client/src/main/com/sinch/sdk/models/SmsContext.java b/client/src/main/com/sinch/sdk/models/SmsContext.java index 70c0fbcc1..93e693c46 100644 --- a/client/src/main/com/sinch/sdk/models/SmsContext.java +++ b/client/src/main/com/sinch/sdk/models/SmsContext.java @@ -2,17 +2,15 @@ import com.sinch.sdk.core.models.ServerConfiguration; -/** Execution context related to Voice domains */ +/** Execution context related to SMS domains */ public class SmsContext { private final SMSRegion smsRegion; private final String smsUrl; - private final Boolean regionAsDefault; - private SmsContext(SMSRegion smsRegion, String smsUrl, Boolean regionAsDefault) { + private SmsContext(SMSRegion smsRegion, String smsUrl) { this.smsRegion = smsRegion; this.smsUrl = smsUrl; - this.regionAsDefault = regionAsDefault; } /** @@ -49,14 +47,6 @@ public String getSmsUrl() { return smsUrl; } - /** - * @deprecated Helper for transition period until 2.0 release - */ - @Deprecated - public Boolean regionAsDefault() { - return regionAsDefault; - } - /** * Getting Builder * @@ -87,7 +77,6 @@ public static class Builder { SMSRegion smsRegion; String smsUrl; - Boolean regionAsDefault; protected Builder() {} @@ -100,7 +89,6 @@ protected Builder() {} protected Builder(SmsContext context) { this.smsRegion = null != context ? context.getSmsRegion() : null; this.smsUrl = null != context ? context.getSmsUrl() : null; - this.regionAsDefault = null != context ? context.regionAsDefault() : null; } public SMSRegion getSmsRegion() { @@ -111,10 +99,6 @@ public String getSmsUrl() { return smsUrl; } - public Boolean getRegionAsDefault() { - return regionAsDefault; - } - /** * Set SMS region * @@ -139,14 +123,6 @@ public Builder setSmsUrl(String smsUrl) { return this; } - /** - * @deprecated Helper for transition period until 2.0 release - */ - public Builder setRegionAsDefault(Boolean regionAsDefault) { - this.regionAsDefault = regionAsDefault; - return this; - } - /** * Create instance * @@ -155,7 +131,7 @@ public Builder setRegionAsDefault(Boolean regionAsDefault) { */ public SmsContext build() { - return new SmsContext(smsRegion, smsUrl, regionAsDefault); + return new SmsContext(smsRegion, smsUrl); } } } diff --git a/client/src/test/java/com/sinch/sdk/SinchClientTest.java b/client/src/test/java/com/sinch/sdk/SinchClientTest.java index 868660637..7a9610b4c 100644 --- a/client/src/test/java/com/sinch/sdk/SinchClientTest.java +++ b/client/src/test/java/com/sinch/sdk/SinchClientTest.java @@ -5,12 +5,9 @@ import com.sinch.sdk.core.utils.StringUtil; import com.sinch.sdk.models.Configuration; import com.sinch.sdk.models.ConversationRegion; -import com.sinch.sdk.models.MailgunContext; -import com.sinch.sdk.models.MailgunRegion; import com.sinch.sdk.models.SMSRegion; import com.sinch.sdk.models.VoiceContext; import com.sinch.sdk.models.VoiceRegion; -import java.util.Collections; import org.junit.jupiter.api.Test; class SinchClientTest { @@ -52,10 +49,10 @@ void defaultSmsUrlAvailable() { } @Test - void defaultSmsRegionIsUS() { + void smsRegionIsNullWhenNotSet() { Configuration configuration = Configuration.builder().build(); SinchClient client = new SinchClient(configuration); - assertEquals(SMSRegion.US, client.getConfiguration().getSmsContext().get().getSmsRegion()); + assertNull(client.getConfiguration().getSmsContext().get().getSmsRegion()); } @Test @@ -67,11 +64,30 @@ void smsRegion() { } @Test - void defaultConversationUrlAvailable() { + void smsUrlFromRegion() { + Configuration configuration = Configuration.builder().setSmsRegion(SMSRegion.AU).build(); + SinchClient client = new SinchClient(configuration); + assertEquals( + "https://zt.au.sms.api.sinch.com", + client.getConfiguration().getSmsContext().get().getSmsServer().getUrl()); + } + + @Test + void smsUrlFromRegionWithServicePlanId() { + Configuration configuration = + Configuration.builder().setSmsServicePlanId("foo").setSmsRegion(SMSRegion.AU).build(); + SinchClient client = new SinchClient(configuration); + assertEquals( + "https://au.sms.api.sinch.com", + client.getConfiguration().getSmsContext().get().getSmsServer().getUrl()); + } + + @Test + void conversationUrlIsNullWhenRegionNotSet() { Configuration configuration = Configuration.builder().setKeyId("foo").setKeySecret("foo").setProjectId("foo").build(); SinchClient client = new SinchClient(configuration); - assertNotNull(client.getConfiguration().getConversationContext().get().getUrl()); + assertNull(client.getConfiguration().getConversationContext().get().getUrl()); } @Test @@ -85,12 +101,10 @@ void conversationUrlFromRegion() { } @Test - void defaultConversationTemplateUrlAvailable() { - Configuration configuration = - Configuration.builder().setConversationRegion(ConversationRegion.EU).build(); + void conversationTemplateUrlIsNullWhenRegionNotSet() { + Configuration configuration = Configuration.builder().build(); SinchClient client = new SinchClient(configuration); - assertNotNull( - client.getConfiguration().getConversationContext().get().getTemplateManagementUrl()); + assertNull(client.getConfiguration().getConversationContext().get().getTemplateManagementUrl()); } @Test @@ -104,12 +118,10 @@ void templateConversationUrlFromRegion() { } @Test - void defaultConversationRegionIsUS() { + void conversationRegionIsNullWhenNotSet() { Configuration configuration = Configuration.builder().build(); SinchClient client = new SinchClient(configuration); - assertEquals( - ConversationRegion.US, - client.getConfiguration().getConversationContext().get().getRegion()); + assertNull(client.getConfiguration().getConversationContext().get().getRegion()); } @Test @@ -206,96 +218,4 @@ void voiceApplicationManagementUrlFromUrl() { client.getConfiguration().getVoiceContext().get().getVoiceApplicationManagementUrl(), "my foo url"); } - - @Test - void defaultMailgunUrlAvailable() { - Configuration configuration = Configuration.builder().build(); - SinchClient client = new SinchClient(configuration); - assertNotNull(client.getConfiguration().getMailgunContext().get().getUrl()); - } - - @Test - void defaultMailgunRegionIsUS() { - Configuration configuration = Configuration.builder().build(); - SinchClient client = new SinchClient(configuration); - assertEquals(client.getConfiguration().getMailgunContext().get().getRegion(), MailgunRegion.US); - } - - @Test - void defaultMailgunStorages() { - Configuration configuration = Configuration.builder().build(); - SinchClient client = new SinchClient(configuration); - assertNotNull(client.getConfiguration().getMailgunContext().get().getStorageServers()); - assertFalse(client.getConfiguration().getMailgunContext().get().getStorageServers().isEmpty()); - } - - @Test - void mailgunUrlFromRegion() { - Configuration configuration = - Configuration.builder() - .setMailgunContext( - MailgunContext.builder().setRegion(MailgunRegion.from("foo value")).build()) - .build(); - SinchClient client = new SinchClient(configuration); - assertEquals( - client.getConfiguration().getMailgunContext().get().getUrl(), - "https://api.foo value.mailgun.net"); - } - - @Test - void mailgunUrlFromUrl() { - Configuration configuration = - Configuration.builder() - .setMailgunContext( - MailgunContext.builder() - .setRegion(MailgunRegion.from("foo value")) - .setUrl("my foo url") - .build()) - .build(); - SinchClient client = new SinchClient(configuration); - assertEquals(client.getConfiguration().getMailgunContext().get().getUrl(), "my foo url"); - } - - @Test - void mailgunStoragesUrlFromRegion() { - Configuration configuration = - Configuration.builder() - .setMailgunContext(MailgunContext.builder().setRegion(MailgunRegion.from("EU")).build()) - .build(); - SinchClient client = new SinchClient(configuration); - assertEquals( - Collections.singletonList("https://storage-europe-west1.api.mailgun.net"), - client.getConfiguration().getMailgunContext().get().getStorageUrls()); - } - - @Test - void mailgunStoragesUrlFromStorageUrlWithoutRegion() { - Configuration configuration = - Configuration.builder() - .setMailgunContext( - MailgunContext.builder() - .setStorageUrls(Collections.singletonList("my foo URL")) - .build()) - .build(); - SinchClient client = new SinchClient(configuration); - assertEquals( - Collections.singletonList("my foo URL"), - client.getConfiguration().getMailgunContext().get().getStorageUrls()); - } - - @Test - void mailgunStoragesUrlFromStorageUrlWithRegion() { - Configuration configuration = - Configuration.builder() - .setMailgunContext( - MailgunContext.builder() - .setRegion(MailgunRegion.from("EU")) - .setStorageUrls(Collections.singletonList("my foo URL")) - .build()) - .build(); - SinchClient client = new SinchClient(configuration); - assertEquals( - Collections.singletonList("my foo URL"), - client.getConfiguration().getMailgunContext().get().getStorageUrls()); - } } diff --git a/client/src/test/java/com/sinch/sdk/SinchClientTestIT.java b/client/src/test/java/com/sinch/sdk/SinchClientTestIT.java index 5075c6c19..c95624e5e 100644 --- a/client/src/test/java/com/sinch/sdk/SinchClientTestIT.java +++ b/client/src/test/java/com/sinch/sdk/SinchClientTestIT.java @@ -47,7 +47,7 @@ void sdkUserAgent() throws InterruptedException { new MockResponse().setBody("foo").addHeader("Content-Type", "application/json")); try { - sinchClient.numbers().available().checkAvailability("foo"); + sinchClient.numbers().v1().checkAvailability("foo"); } catch (ApiException ae) { // noop } diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/CredentialsValidationHelper.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/CredentialsValidationHelper.java index 67bec5848..ad883f9ac 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/CredentialsValidationHelper.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/CredentialsValidationHelper.java @@ -6,7 +6,9 @@ import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.templates.api.adapters.TemplatesService; import com.sinch.sdk.models.ConversationContext; +import com.sinch.sdk.models.ConversationRegion; import com.sinch.sdk.models.UnifiedCredentials; import java.util.function.Consumer; import java.util.function.Supplier; @@ -23,6 +25,8 @@ static void checkCredentialsTemplates( doNotAcceptNullContextTemplates(httpClientSupplier, service); doNotAcceptEmptyURLTemplates(httpClientSupplier, service); doNotAcceptNullURLTemplates(httpClientSupplier, service); + doNotAcceptNullRegionTemplates(httpClientSupplier, service); + doNotAcceptEmptyRegionTemplates(httpClientSupplier, service); passInitTemplates(httpClientSupplier, service); } @@ -110,7 +114,8 @@ private static void doNotAcceptEmptyURLTemplates( .setKeySecret("foo") .setProjectId("foo") .build(); - ConversationContext context = ConversationContext.builder().setUrl("").build(); + ConversationContext context = + ConversationContext.builder().setUrl("").setRegion(ConversationRegion.BR).build(); ServerConfiguration server = new ServerConfiguration(""); Exception exception = assertThrows( @@ -132,7 +137,8 @@ private static void doNotAcceptNullURLTemplates( .setKeySecret("foo") .setProjectId("foo") .build(); - ConversationContext context = ConversationContext.builder().build(); + ConversationContext context = + ConversationContext.builder().setRegion(ConversationRegion.BR).build(); ServerConfiguration server = new ServerConfiguration(""); Exception exception = assertThrows( @@ -146,6 +152,47 @@ private static void doNotAcceptNullURLTemplates( .contains("Templates service requires 'templateManagementUrl' to be defined")); } + private static void doNotAcceptNullRegionTemplates( + Supplier httpClientSupplier, Consumer service) { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + ConversationContext context = ConversationContext.builder().build(); + ServerConfiguration server = new ServerConfiguration(""); + Exception exception = + assertThrows( + NullPointerException.class, + () -> + service.accept( + new TemplatesService(credentials, context, server, httpClientSupplier))); + assertTrue( + exception.getMessage().contains("Templates service requires 'region' to be defined")); + } + + private static void doNotAcceptEmptyRegionTemplates( + Supplier httpClientSupplier, Consumer service) { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + ConversationContext context = + ConversationContext.builder().setRegion(ConversationRegion.from("")).build(); + ServerConfiguration server = new ServerConfiguration(""); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> + service.accept( + new TemplatesService(credentials, context, server, httpClientSupplier))); + assertTrue( + exception.getMessage().contains("Templates service requires 'region' to be defined")); + } + private static void passInitTemplates( Supplier httpClientSupplier, Consumer service) { UnifiedCredentials credentials = @@ -155,7 +202,10 @@ private static void passInitTemplates( .setProjectId("foo") .build(); ConversationContext context = - ConversationContext.builder().setTemplateManagementUrl("foo").build(); + ConversationContext.builder() + .setTemplateManagementUrl("foo") + .setRegion(ConversationRegion.from("foo")) + .build(); ServerConfiguration server = new ServerConfiguration("foo"); assertDoesNotThrow( () -> diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplateServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplateServiceTest.java index cffaf26dd..423f3a9ea 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplateServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/TemplateServiceTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.domains.conversation.templates.api.adapters.TemplatesService; import org.junit.jupiter.api.Test; import org.mockito.Mock; @@ -10,11 +11,6 @@ class TemplateServiceTest { @Mock HttpClient httpClient; - @Test - void checkCredentialsV1() { - CredentialsValidationHelper.checkCredentialsTemplates(() -> httpClient, TemplatesService::v1); - } - @Test void checkCredentialsV2() { CredentialsValidationHelper.checkCredentialsTemplates(() -> httpClient, TemplatesService::v2); diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1Test.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1Test.java deleted file mode 100644 index cdff473f0..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v1/TemplatesServiceV1Test.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.adapters.v1; - -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.templates.adapters.TemplatesBaseTest; -import com.sinch.sdk.domains.conversation.models.templates.v1.TemplateV1DtoTest; -import com.sinch.sdk.domains.conversation.models.templates.v1.internal.V1ListTemplatesResponseInternalDtoTest; -import com.sinch.sdk.domains.conversation.templates.api.internal.V1Api; -import com.sinch.sdk.domains.conversation.templates.models.v1.TemplateV1; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; - -@TestWithResources -public class TemplatesServiceV1Test extends TemplatesBaseTest { - - @Mock ConversationContext context; - @Mock V1Api api; - @Mock HttpClient httpClient; - @Mock Map authManagers; - @Captor ArgumentCaptor uriPartIDCaptor; - @Captor ArgumentCaptor idCaptor; - - TemplatesServiceV1 service; - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = spy(new TemplatesServiceV1(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } - - @Test - void create() throws ApiException { - - when(api.templatesCreateTemplate(eq(uriPartID), eq(TemplateV1DtoTest.expectedDto))) - .thenReturn(TemplateV1DtoTest.expectedDto); - - TemplateV1 response = service.create(TemplateV1DtoTest.expectedDto); - - TestHelpers.recursiveEquals(response, TemplateV1DtoTest.expectedDto); - } - - @Test - void get() throws ApiException { - - when(api.templatesGetTemplate(eq(uriPartID), eq(TemplateV1DtoTest.expectedDto.getId()))) - .thenReturn(TemplateV1DtoTest.expectedDto); - - TemplateV1 response = service.get(TemplateV1DtoTest.expectedDto.getId()); - - TestHelpers.recursiveEquals(response, TemplateV1DtoTest.expectedDto); - } - - @Test - void list() throws ApiException { - - when(api.templatesListTemplates(eq(uriPartID))) - .thenReturn(V1ListTemplatesResponseInternalDtoTest.expectedDto); - - Collection response = service.list(); - - Iterator iterator = response.iterator(); - Assertions.assertThat(iterator.hasNext()).isEqualTo(true); - TemplateV1 item = iterator.next(); - TestHelpers.recursiveEquals( - item, V1ListTemplatesResponseInternalDtoTest.expectedDto.getTemplates().get(0)); - Assertions.assertThat(iterator.hasNext()).isEqualTo(false); - } - - @Test - void update() throws ApiException { - - when(api.templatesUpdateTemplate( - eq(uriPartID), - eq(TemplateV1DtoTest.expectedDto.getId()), - eq(TemplateV1DtoTest.expectedDto), - eq(null))) - .thenReturn(TemplateV1DtoTest.expectedDto); - - TemplateV1 response = - service.update(TemplateV1DtoTest.expectedDto.getId(), TemplateV1DtoTest.expectedDto); - - TestHelpers.recursiveEquals(response, TemplateV1DtoTest.expectedDto); - } - - @Test - void delete() throws ApiException { - - service.delete(TemplateV1DtoTest.expectedDto.getId()); - - verify(api).templatesDeleteTemplate(uriPartIDCaptor.capture(), idCaptor.capture()); - - Assertions.assertThat(uriPartIDCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(idCaptor.getValue()).isEqualTo(TemplateV1DtoTest.expectedDto.getId()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2Test.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2Test.java deleted file mode 100644 index 7c452f099..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesServiceV2Test.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.templates.adapters.v2; - -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.templates.adapters.TemplatesBaseTest; -import com.sinch.sdk.domains.conversation.models.templates.v2.TemplateV2DtoTest; -import com.sinch.sdk.domains.conversation.models.templates.v2.internal.V2ListTemplatesResponseInternalDtoTest; -import com.sinch.sdk.domains.conversation.models.templates.v2.internal.V2ListTranslationsResponseInternalDtoTest; -import com.sinch.sdk.domains.conversation.templates.api.internal.V2Api; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslation; -import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateV2; -import com.sinch.sdk.domains.conversation.templates.models.v2.request.TranslationListRequest; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; - -@TestWithResources -public class TemplatesServiceV2Test extends TemplatesBaseTest { - - @Mock ConversationContext context; - @Mock V2Api api; - @Mock HttpClient httpClient; - @Mock Map authManagers; - @Captor ArgumentCaptor uriPartIDCaptor; - @Captor ArgumentCaptor idCaptor; - - TemplatesServiceV2 service; - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = spy(new TemplatesServiceV2(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } - - @Test - void create() throws ApiException { - - when(api.templatesV2CreateTemplate(eq(uriPartID), eq(TemplateV2DtoTest.expectedRequestDto))) - .thenReturn(TemplateV2DtoTest.expectedRequestDto); - - TemplateV2 response = service.create(TemplateV2DtoTest.expectedRequestDto); - - TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedRequestDto); - } - - @Test - void get() throws ApiException { - - when(api.templatesV2GetTemplate( - eq(uriPartID), eq(TemplateV2DtoTest.expectedRequestDto.getId()))) - .thenReturn(TemplateV2DtoTest.expectedRequestDto); - - TemplateV2 response = service.get(TemplateV2DtoTest.expectedRequestDto.getId()); - - TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedRequestDto); - } - - @Test - void list() throws ApiException { - - when(api.templatesV2ListTemplates(eq(uriPartID))) - .thenReturn(V2ListTemplatesResponseInternalDtoTest.expectedDto); - - Collection response = service.list(); - - Iterator iterator = response.iterator(); - Assertions.assertThat(iterator.hasNext()).isEqualTo(true); - TemplateV2 item = iterator.next(); - TestHelpers.recursiveEquals( - item, V2ListTemplatesResponseInternalDtoTest.expectedDto.getTemplates().get(0)); - Assertions.assertThat(iterator.hasNext()).isEqualTo(false); - } - - @Test - void listTranslations() throws ApiException { - - when(api.templatesV2ListTranslations( - eq(uriPartID), - eq(TemplateV2DtoTest.expectedRequestDto.getId()), - eq("language code"), - eq("translation version"))) - .thenReturn(V2ListTranslationsResponseInternalDtoTest.expectedDto); - - Collection response = - service.listTranslations( - TemplateV2DtoTest.expectedRequestDto.getId(), - TranslationListRequest.builder() - .setLanguageCode("language code") - .setTranslationVersion("translation version") - .build()); - - Iterator iterator = response.iterator(); - Assertions.assertThat(iterator.hasNext()).isEqualTo(true); - TemplateTranslation item = iterator.next(); - TestHelpers.recursiveEquals( - item, V2ListTranslationsResponseInternalDtoTest.expectedDto.getTranslations().get(0)); - Assertions.assertThat(iterator.hasNext()).isEqualTo(false); - } - - @Test - void update() throws ApiException { - - when(api.templatesV2UpdateTemplate( - eq(uriPartID), - eq(TemplateV2DtoTest.expectedRequestDto.getId()), - eq(TemplateV2DtoTest.expectedRequestDto))) - .thenReturn(TemplateV2DtoTest.expectedRequestDto); - - TemplateV2 response = - service.update( - TemplateV2DtoTest.expectedRequestDto.getId(), TemplateV2DtoTest.expectedRequestDto); - - TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedRequestDto); - } - - @Test - void delete() throws ApiException { - - service.delete(TemplateV2DtoTest.expectedRequestDto.getId()); - - verify(api).templatesV2DeleteTemplate(uriPartIDCaptor.capture(), idCaptor.capture()); - - Assertions.assertThat(uriPartIDCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(idCaptor.getValue()) - .isEqualTo(TemplateV2DtoTest.expectedRequestDto.getId()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesV2ServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesV2ServiceTest.java new file mode 100644 index 000000000..47e1d1f6c --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/templates/adapters/v2/TemplatesV2ServiceTest.java @@ -0,0 +1,323 @@ +package com.sinch.sdk.domains.conversation.api.templates.adapters.v2; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameter.STYLE; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.domains.conversation.templates.api.adapters.TemplatesBaseTest; +import com.sinch.sdk.domains.conversation.templates.api.v2.TemplatesV2Service; +import com.sinch.sdk.domains.conversation.templates.api.v2.adapters.TemplatesV2ServiceImpl; +import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateTranslation; +import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateV2; +import com.sinch.sdk.domains.conversation.templates.models.v2.TemplateV2DtoTest; +import com.sinch.sdk.domains.conversation.templates.models.v2.request.ListTranslationsQueryParameters; +import com.sinch.sdk.domains.conversation.templates.models.v2.response.TemplatesV2ListResponse; +import com.sinch.sdk.domains.conversation.templates.models.v2.response.TemplatesV2ListResponseDtoTest; +import com.sinch.sdk.domains.conversation.templates.models.v2.response.TranslationsV2ListResponse; +import com.sinch.sdk.domains.conversation.templates.models.v2.response.TranslationsV2ListResponseDtoTest; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +@TestWithResources +public class TemplatesV2ServiceTest extends TemplatesBaseTest { + @Mock HttpClient httpClient; + + @Mock ServerConfiguration serverConfiguration; + @Mock Map authManagers; + + String uriPartID = "foovalue"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + TemplatesV2Service service; + + @GivenTextResource("/domains/conversation/templates/v2/request/TemplateV2RequestDto.json") + String jsonTemplateV2RequestDto; + + @GivenTextResource("/domains/conversation/templates/v2/TemplateV2Dto.json") + String jsonTemplateV2Dto; + + @GivenTextResource("/domains/conversation/templates/v2/response/TemplatesV2ListResponseDto.json") + String jsonTemplatesV2ListResponseDto; + + @GivenTextResource( + "/domains/conversation/templates/v2/response/TranslationsV2ListResponseDto.json") + String jsonTranslationsV2ListResponseDto; + + @BeforeEach + public void initMocks() { + service = + new TemplatesV2ServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriPartID); + } + + @Test + void create() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v2/projects/%s/templates", URLPathUtils.encodePathSegment(uriPartID)), + HttpMethod.POST, + Collections.emptyList(), + jsonTemplateV2RequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonTemplateV2Dto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TemplateV2 response = service.create(TemplateV2DtoTest.expectedDto); + + TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedDto); + } + + @Test + void get() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v2/projects/%s/templates/%s", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(TemplateV2DtoTest.expectedDto.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonTemplateV2Dto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TemplateV2 response = service.get(TemplateV2DtoTest.expectedDto.getId()); + + TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedDto); + } + + @Test + void list() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v2/projects/%s/templates", URLPathUtils.encodePathSegment(uriPartID)), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonTemplatesV2ListResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TemplatesV2ListResponse response = service.list(); + Iterator iterator = response.iterator(); + + TemplatesV2ListResponse expectedListResponse = + new TemplatesV2ListResponse( + new Page<>(TemplatesV2ListResponseDtoTest.expectedDto.getTemplates(), null)); + Iterator expectedIterator = expectedListResponse.iterator(); + + while (iterator.hasNext()) { + TemplateV2 item = iterator.next(); + TemplateV2 expectedItem = expectedIterator.next(); + TestHelpers.recursiveEquals(item, expectedItem); + } + Assertions.assertThat(expectedIterator.hasNext()).isEqualTo(false); + } + + @Test + void listTranslations() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v2/projects/%s/templates/%s/translations", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(TemplateV2DtoTest.expectedDto.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonTranslationsV2ListResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TranslationsV2ListResponse response = + service.listTranslations(TemplateV2DtoTest.expectedDto.getId()); + Iterator iterator = response.iterator(); + + TranslationsV2ListResponse expectedListResponse = + new TranslationsV2ListResponse( + new Page<>(TranslationsV2ListResponseDtoTest.expectedDto.getTranslations(), null)); + Iterator expectedIterator = expectedListResponse.iterator(); + + while (iterator.hasNext()) { + TemplateTranslation item = iterator.next(); + TemplateTranslation expectedItem = expectedIterator.next(); + TestHelpers.recursiveEquals(item, expectedItem); + } + Assertions.assertThat(expectedIterator.hasNext()).isEqualTo(false); + } + + @Test + void listTranslationsWithParameters() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v2/projects/%s/templates/%s/translations", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(TemplateV2DtoTest.expectedDto.getId())), + HttpMethod.GET, + Arrays.asList( + new URLParameter("language_code", "language code", STYLE.FORM, true), + new URLParameter("translation_version", "translation version", STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonTranslationsV2ListResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TranslationsV2ListResponse response = + service.listTranslations( + TemplateV2DtoTest.expectedDto.getId(), + ListTranslationsQueryParameters.builder() + .setLanguageCode("language code") + .setTranslationVersion("translation version") + .build()); + Iterator iterator = response.iterator(); + + TranslationsV2ListResponse expectedListResponse = + new TranslationsV2ListResponse( + new Page<>(TranslationsV2ListResponseDtoTest.expectedDto.getTranslations(), null)); + Iterator expectedIterator = expectedListResponse.iterator(); + + while (iterator.hasNext()) { + TemplateTranslation item = iterator.next(); + TemplateTranslation expectedItem = expectedIterator.next(); + TestHelpers.recursiveEquals(item, expectedItem); + } + Assertions.assertThat(expectedIterator.hasNext()).isEqualTo(false); + } + + @Test + void update() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v2/projects/%s/templates/%s", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(TemplateV2DtoTest.expectedDto.getId())), + HttpMethod.PUT, + Collections.emptyList(), + jsonTemplateV2RequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonTemplateV2Dto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + TemplateV2 response = + service.update(TemplateV2DtoTest.expectedDto.getId(), TemplateV2DtoTest.expectedDto); + + TestHelpers.recursiveEquals(response, TemplateV2DtoTest.expectedDto); + } + + @Test + void delete() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v2/projects/%s/templates/%s", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(TemplateV2DtoTest.expectedDto.getId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(TemplateV2DtoTest.expectedDto.getId()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppServiceTest.java deleted file mode 100644 index 28ba2b5e0..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppServiceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.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.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.AppApi; -import com.sinch.sdk.domains.conversation.models.v1.AppDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.app.response.AppResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Collection; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -@TestWithResources -public class AppServiceTest extends BaseTest { - - @Mock ConversationContext context; - @Mock AppApi api; - @Mock HttpClient httpClient; - @Mock Map authManagers; - - AppService service; - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = spy(new AppService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } - - @Test - void list() throws ApiException { - - when(api.appListApps(eq(uriPartID))).thenReturn(AppDtoTest.expectedListAppsResponseDto); - - Collection response = service.list(); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(AppDtoTest.expectedListAppsResponseDto.getApps()); - } - - @Test - void get() throws ApiException { - - when(api.appGetApp(eq(uriPartID), eq(AppDtoTest.expectedAppResponseDto.getId()))) - .thenReturn(AppDtoTest.expectedAppResponseDto); - - AppResponse response = service.get(AppDtoTest.expectedAppResponseDto.getId()); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(AppDtoTest.expectedAppResponseDto); - } - - @Test - void create() throws ApiException { - - when(api.appCreateApp(eq(uriPartID), eq(AppDtoTest.appCreateRequestDto))) - .thenReturn(AppDtoTest.expectedAppResponseDto); - - AppResponse response = service.create(AppDtoTest.appCreateRequestDto); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(AppDtoTest.expectedAppResponseDto); - } - - @Test - void update() throws ApiException { - - when(api.appUpdateApp( - eq(uriPartID), - eq(AppDtoTest.expectedAppResponseDto.getId()), - eq(AppDtoTest.appUpdateRequestDto), - eq(null))) - .thenReturn(AppDtoTest.expectedAppResponseDto); - - AppResponse response = - service.update(AppDtoTest.expectedAppResponseDto.getId(), AppDtoTest.appUpdateRequestDto); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(AppDtoTest.expectedAppResponseDto); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppsServiceTest.java new file mode 100644 index 000000000..53ee28721 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/AppsServiceTest.java @@ -0,0 +1,219 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.domains.conversation.api.v1.AppsService; +import com.sinch.sdk.domains.conversation.models.v1.apps.AppDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.apps.response.AppResponse; +import com.sinch.sdk.domains.conversation.models.v1.apps.response.AppsListResponse; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +@TestWithResources +public class AppsServiceTest extends BaseTest { + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + @Mock Map authManagers; + + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + AppsService service; + + @GivenTextResource("/domains/conversation/v1/apps/AppListResponseDto.json") + String jsonListAppsResponseDto; + + @GivenTextResource("/domains/conversation/v1/apps/AppResponseDto.json") + String jsonLoadedAppsResponseDto; + + @GivenTextResource("/domains/conversation/v1/apps/AppCreateRequestDto.json") + String jsonAppCreateRequestDto; + + @GivenTextResource("/domains/conversation/v1/apps/AppUpdateRequestDto.json") + String jsonAppUpdateRequestDto; + + @BeforeEach + public void initMocks() { + service = + new AppsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); + } + + @Test + void list() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/apps", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonListAppsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + AppsListResponse response = service.list(); + Iterator iterator = response.iterator(); + + AppsListResponse expectedAppsListResponse = + new AppsListResponse(new Page<>(AppDtoTest.expectedListAppsResponseDto.getApps(), null)); + Iterator expectedIterator = expectedAppsListResponse.iterator(); + + while (iterator.hasNext()) { + AppResponse item = iterator.next(); + AppResponse expectedItem = expectedIterator.next(); + TestHelpers.recursiveEquals(item, expectedItem); + } + Assertions.assertThat(expectedIterator.hasNext()).isEqualTo(false); + } + + @Test + void get() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/apps/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(AppDtoTest.expectedAppResponseDto.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonLoadedAppsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + AppResponse response = service.get(AppDtoTest.expectedAppResponseDto.getId()); + + TestHelpers.recursiveEquals(response, AppDtoTest.expectedAppResponseDto); + } + + @Test + void create() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/apps", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonAppCreateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonLoadedAppsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + AppResponse response = service.create(AppDtoTest.appCreateRequestDto); + + TestHelpers.recursiveEquals(response, AppDtoTest.expectedAppResponseDto); + } + + @Test + void update() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/apps/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(AppDtoTest.expectedAppResponseDto.getId())), + HttpMethod.PATCH, + Collections.emptyList(), + jsonAppUpdateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonLoadedAppsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + AppResponse response = + service.update(AppDtoTest.expectedAppResponseDto.getId(), AppDtoTest.appUpdateRequestDto); + + TestHelpers.recursiveEquals(response, AppDtoTest.expectedAppResponseDto); + } + + @Test + void delete() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/apps/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(AppDtoTest.expectedAppResponseDto.getId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(AppDtoTest.expectedAppResponseDto.getId()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityServiceTest.java index f5f451ecf..0876b2763 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CapabilityServiceTest.java @@ -1,20 +1,30 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.CapabilityApi; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.CapabilityService; import com.sinch.sdk.domains.conversation.models.v1.capability.request.QueryCapabilityRequestDtoTest; import com.sinch.sdk.domains.conversation.models.v1.capability.response.QueryCapabilityResponse; import com.sinch.sdk.domains.conversation.models.v1.capability.response.QueryCapabilityResponseDtoTest; -import com.sinch.sdk.models.ConversationContext; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -23,26 +33,51 @@ @TestWithResources public class CapabilityServiceTest extends ConversationBaseTest { - @Mock ConversationContext context; - @Mock CapabilityApi api; @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; @Mock Map authManagers; + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + CapabilityService service; - String uriPartID = "foovalue"; + + @GivenTextResource("/domains/conversation/v1/capability/request/QueryCapabilityRequestDto.json") + static String jsonQueryCapabilityRequestDto; + + @GivenTextResource("domains/conversation/v1/capability/response/QueryCapabilityResponseDto.json") + String jsonQueryCapabilityResponseDto; @BeforeEach public void initMocks() { - service = spy(new CapabilityService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); + service = + new CapabilityServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); } @Test void lookup() throws ApiException { - when(api.capabilityQueryCapability( - eq(uriPartID), eq(QueryCapabilityRequestDtoTest.queryCapabilityRequestDto))) - .thenReturn(QueryCapabilityResponseDtoTest.expectedQueryCapabilityResponseDto); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/capability:query", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonQueryCapabilityRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonQueryCapabilityResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); QueryCapabilityResponse response = service.lookup(QueryCapabilityRequestDtoTest.queryCapabilityRequestDto); diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactServiceTest.java deleted file mode 100644 index 16a4bde10..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactServiceTest.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -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.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.ContactApi; -import com.sinch.sdk.domains.conversation.models.v1.ChannelRecipientIdentities; -import com.sinch.sdk.domains.conversation.models.v1.ContactId; -import com.sinch.sdk.domains.conversation.models.v1.contact.Contact; -import com.sinch.sdk.domains.conversation.models.v1.contact.ContactDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByChannelIdentityRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.ContactGetChannelProfileByContactIdRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.request.MergeContactRequest; -import com.sinch.sdk.domains.conversation.models.v1.contact.response.ContactListResponse; -import com.sinch.sdk.models.ConversationContext; -import java.util.Iterator; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -@TestWithResources -class ContactServiceTest extends BaseTest { - - @Mock ConversationContext context; - @Mock ContactApi api; - @Mock HttpClient httpClient; - @Mock Map authManagers; - - ContactService service; - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = spy(new ContactService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } - - @Test - void list() throws ApiException { - - when(api.contactListContacts(eq(uriPartID), eq(null), eq(null), eq(null), eq(null), eq(null))) - .thenReturn(ContactDtoTest.expectedContactListResponseDtoPage0); - - when(api.contactListContacts( - eq(uriPartID), eq(null), eq("the next page token value"), eq(null), eq(null), eq(null))) - .thenReturn(ContactDtoTest.expectedContactListResponseDtoPage1); - - ContactListResponse response = service.list(null); - - Iterator iterator = response.iterator(); - Assertions.assertThat(iterator.hasNext()).isEqualTo(true); - Contact item = iterator.next(); - Assertions.assertThat(item) - .usingRecursiveComparison() - .isEqualTo(ContactDtoTest.expectedContactResponseDto); - - Assertions.assertThat(iterator.hasNext()).isEqualTo(false); - } - - @Test - void create() throws ApiException { - - when(api.contactCreateContact(eq(uriPartID), eq(ContactDtoTest.createContactRequestDto))) - .thenReturn(ContactDtoTest.expectedCreatedContactResponseDto); - - Contact response = service.create(ContactDtoTest.createContactRequestDto); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ContactDtoTest.expectedCreatedContactResponseDto); - } - - @Test - void get() throws ApiException { - - when(api.contactGetContact( - eq(uriPartID), eq(ContactDtoTest.expectedContactResponseDto.getId()))) - .thenReturn(ContactDtoTest.expectedContactResponseDto); - - Contact response = service.get(ContactDtoTest.expectedContactResponseDto.getId()); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ContactDtoTest.expectedContactResponseDto); - } - - @Test - void update() throws ApiException { - - when(api.contactUpdateContact( - eq(uriPartID), - eq(ContactDtoTest.expectedContactResponseDto.getId()), - eq(ContactDtoTest.expectedContactResponseDto), - eq(null))) - .thenReturn(ContactDtoTest.expectedContactResponseDto); - - Contact response = - service.update( - ContactDtoTest.expectedContactResponseDto.getId(), - ContactDtoTest.expectedContactResponseDto); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ContactDtoTest.expectedContactResponseDto); - } - - @Test - void merge() throws ApiException { - - when(api.contactMergeContact( - eq(uriPartID), - eq("foo 1"), - eq(MergeContactRequest.builder().setSourceId("foo 2").build()))) - .thenReturn(ContactDtoTest.expectedContactResponseDto); - - Contact response = service.mergeContact("foo 1", "foo 2"); - - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ContactDtoTest.expectedContactResponseDto); - } - - @Test - void channelProfileByContactId() throws ApiException { - - when(api.contactGetChannelProfile(eq(uriPartID), any())) - .thenReturn(ContactDtoTest.expectedChannelProfileResponseDto); - - ContactId contactId = - (ContactId) ContactDtoTest.contactGetChannelProfileByContactRequestDto.getRecipient(); - String response = - service.getChannelProfileByContactId( - ContactGetChannelProfileByContactIdRequest.builder() - .setChannel(ContactDtoTest.contactGetChannelProfileByContactRequestDto.getChannel()) - .setContactId(contactId.getContactId()) - .setAppId(ContactDtoTest.contactGetChannelProfileByContactRequestDto.getAppId()) - .build()); - - Assertions.assertThat(response) - .isEqualTo(ContactDtoTest.expectedChannelProfileResponseDto.getProfileName()); - } - - @Test - void channelProfileByChannelIdentity() throws ApiException { - - when(api.contactGetChannelProfile(eq(uriPartID), any())) - .thenReturn(ContactDtoTest.expectedChannelProfileResponseDto); - - ChannelRecipientIdentities channelIdentities = - (ChannelRecipientIdentities) - ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getRecipient(); - String response = - service.getChannelProfileByChannelIdentity( - ContactGetChannelProfileByChannelIdentityRequest.builder() - .setChannelIdentities(channelIdentities) - .setChannel(ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getChannel()) - .setAppId(ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getAppId()) - .build()); - - Assertions.assertThat(response) - .isEqualTo(ContactDtoTest.expectedChannelProfileResponseDto.getProfileName()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactsServiceTest.java new file mode 100644 index 000000000..7ddec8bbe --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ContactsServiceTest.java @@ -0,0 +1,363 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameter.STYLE; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.ContactsService; +import com.sinch.sdk.domains.conversation.models.v1.ChannelRecipientIdentities; +import com.sinch.sdk.domains.conversation.models.v1.ContactId; +import com.sinch.sdk.domains.conversation.models.v1.contacts.Contact; +import com.sinch.sdk.domains.conversation.models.v1.contacts.ContactDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.contacts.request.ContactGetChannelProfileByChannelIdentityRequest; +import com.sinch.sdk.domains.conversation.models.v1.contacts.request.ContactGetChannelProfileByContactIdRequest; +import com.sinch.sdk.domains.conversation.models.v1.contacts.response.ContactsListResponse; +import com.sinch.sdk.domains.conversation.models.v1.contacts.response.GetChannelProfileResponse; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +@TestWithResources +class ContactsServiceTest extends BaseTest { + + @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; + @Mock Map authManagers; + + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + ContactsService service; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactListResponseDtoPage0.json") + String jsonContactsListResponseDto1; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactListResponseDtoPage1.json") + String jsonContactsListResponseDto2; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactCreateRequestDto.json") + String jsonContactCreateRequestDto; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactUpdateRequestDto.json") + String jsonContactUpdateRequestDto; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactDto.json") + String jsonContactResponseDto; + + @GivenTextResource("/domains/conversation/v1/contacts/ContactGetChannelResponseDto.json") + String jsonContactGetChannelResponseDto; + + @BeforeEach + public void initMocks() { + service = + new ContactsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); + } + + @Test + void list() throws ApiException { + + HttpRequest httpRequest1 = + new HttpRequest( + String.format("/v1/projects/%s/contacts", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format("/v1/projects/%s/contacts", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("page_token", "the next page token value", STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonContactsListResponseDto1.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonContactsListResponseDto2.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + + ContactsListResponse response = service.list(); + + Iterator iterator = response.iterator(); + Assertions.assertThat(iterator.hasNext()).isEqualTo(true); + Contact item = iterator.next(); + TestHelpers.recursiveEquals(item, ContactDtoTest.expectedContactsListItemResponseDto); + + Assertions.assertThat(iterator.hasNext()).isEqualTo(false); + } + + @Test + void create() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/contacts", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonContactCreateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonContactResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + Contact response = service.create(ContactDtoTest.createContactRequestDto); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedContactResponseDto); + } + + @Test + void get() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ContactDtoTest.expectedContactsListItemResponseDto.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonContactResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + Contact response = service.get(ContactDtoTest.expectedContactsListItemResponseDto.getId()); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedContactResponseDto); + } + + @Test + void update() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ContactDtoTest.expectedContactResponseDto.getId())), + HttpMethod.PATCH, + Collections.emptyList(), + jsonContactUpdateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonContactResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + Contact response = + service.update( + ContactDtoTest.expectedContactResponseDto.getId(), + ContactDtoTest.updateContactRequestDto); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedContactResponseDto); + } + + @Test + void merge() throws ApiException { + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts/%s:merge", + URLPathUtils.encodePathSegment(uriUUID), URLPathUtils.encodePathSegment("foo 1")), + HttpMethod.POST, + Collections.emptyList(), + HttpMapper.getInstance() + .serialize( + Collections.singletonList(HttpContentType.APPLICATION_JSON), + ContactDtoTest.mergeContactRequestDto), + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonContactResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + Contact response = service.mergeContact("foo 1", ContactDtoTest.mergeContactRequestDto); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedContactResponseDto); + } + + @Test + void channelProfileByContactId() throws ApiException { + + ContactId contactId = + (ContactId) ContactDtoTest.contactGetChannelProfileByContactRequestDto.getRecipient(); + + ContactGetChannelProfileByContactIdRequest request = + ContactGetChannelProfileByContactIdRequest.builder() + .setChannel(ContactDtoTest.contactGetChannelProfileByContactRequestDto.getChannel()) + .setContactId(contactId.getContactId()) + .setAppId(ContactDtoTest.contactGetChannelProfileByContactRequestDto.getAppId()) + .build(); + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts:getChannelProfile", + URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + HttpMapper.getInstance() + .serialize(Collections.singletonList(HttpContentType.APPLICATION_JSON), request), + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonContactGetChannelResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + GetChannelProfileResponse response = service.getChannelProfileByContactId(request); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedChannelProfileResponseDto); + } + + @Test + void channelProfileByChannelIdentity() throws ApiException { + + ChannelRecipientIdentities channelIdentities = + (ChannelRecipientIdentities) + ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getRecipient(); + + ContactGetChannelProfileByChannelIdentityRequest request = + ContactGetChannelProfileByChannelIdentityRequest.builder() + .setChannelIdentities(channelIdentities) + .setChannel(ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getChannel()) + .setAppId(ContactDtoTest.contactGetChannelProfileByChannelRequestDto.getAppId()) + .build(); + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts:getChannelProfile", + URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + HttpMapper.getInstance() + .serialize(Collections.singletonList(HttpContentType.APPLICATION_JSON), request), + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonContactGetChannelResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + GetChannelProfileResponse response = service.getChannelProfileByChannelIdentity(request); + + TestHelpers.recursiveEquals(response, ContactDtoTest.expectedChannelProfileResponseDto); + } + + @Test + void delete() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/contacts/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ContactDtoTest.expectedContactResponseDto.getId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(ContactDtoTest.expectedContactResponseDto.getId()); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationServiceTest.java index 5098f28d7..0897fc301 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationServiceTest.java @@ -1,22 +1,8 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; -import com.sinch.sdk.LogRecorder; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.domains.conversation.api.templates.adapters.TemplatesService; -import com.sinch.sdk.models.ConversationContext; -import com.sinch.sdk.models.ConversationRegion; -import com.sinch.sdk.models.UnifiedCredentials; -import java.util.Optional; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; import org.junit.jupiter.api.Test; import org.mockito.Mock; @@ -26,7 +12,7 @@ class ConversationServiceTest { @Test void checkCredentialsApp() { - CredentialsValidationHelper.checkCredentials(() -> httpClient, ConversationService::app); + CredentialsValidationHelper.checkCredentials(() -> httpClient, ConversationService::apps); } @Test @@ -36,7 +22,7 @@ void checkCredentialsCapability() { @Test void checkCredentialsContact() { - CredentialsValidationHelper.checkCredentials(() -> httpClient, ConversationService::contact); + CredentialsValidationHelper.checkCredentials(() -> httpClient, ConversationService::contacts); } @Test @@ -56,149 +42,25 @@ void checkCredentialsMessages() { } @Test - void checkCredentialsTranscoding() { + void checkCredentialsProjectSettings() { CredentialsValidationHelper.checkCredentials( - () -> httpClient, ConversationService::transcoding); + () -> httpClient, ConversationService::projectSettings); } @Test - void passInitWithoutSettings() { - assertDoesNotThrow(() -> new TemplatesService(null, null, null, null), "Init passed"); - } - - @Test - void defaultRegionWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - UnifiedCredentials credentials = - UnifiedCredentials.builder() - .setKeyId("foo key ") - .setKeySecret("foo secret") - .setProjectId("foo project") - .build(); - ConversationContext context = - ConversationContext.builder() - .setUrl("https://foo.url") - .setRegion(ConversationRegion.US) - .setRegionAsDefault(true) - .build(); - ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); - - new ConversationService(credentials, context, server, () -> httpClient).app(); - - Optional record = - logRecorder.records.stream() - .filter(r -> r.getMessage().contains("Using default region for Conversation 'us")) - .findFirst(); - - assertTrue(record.isPresent()); - assertEquals(record.get().getLevel(), Level.WARNING); - LogManager.getLogManager().reset(); - } - - @Test - void regionNoWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - UnifiedCredentials credentials = - UnifiedCredentials.builder() - .setKeyId("foo key ") - .setKeySecret("foo secret") - .setProjectId("foo project") - .build(); - ConversationContext context = - ConversationContext.builder() - .setUrl("https://foo.url") - .setRegion(ConversationRegion.BR) - .setRegionAsDefault(false) - .build(); - ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); - - new ConversationService(credentials, context, server, () -> httpClient).app(); - - Optional record = - logRecorder.records.stream() - .filter(r -> r.getMessage().contains("Using default region for Conversation 'us")) - .findFirst(); - - assertFalse(record.isPresent()); - LogManager.getLogManager().reset(); + void checkCredentialsTranscoding() { + CredentialsValidationHelper.checkCredentials( + () -> httpClient, ConversationService::transcoding); } @Test - void defaultRegionTemplateWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - UnifiedCredentials credentials = - UnifiedCredentials.builder() - .setKeyId("foo key ") - .setKeySecret("foo secret") - .setProjectId("foo project") - .build(); - ConversationContext context = - ConversationContext.builder() - .setTemplateManagementUrl("https://foo.url") - .setRegion(ConversationRegion.US) - .setRegionAsDefault(true) - .build(); - ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); - - new ConversationService(credentials, context, server, () -> httpClient).templates().v2(); - - Optional record = - logRecorder.records.stream() - .filter( - r -> r.getMessage().contains("Using default region for Conversation Template 'us")) - .findFirst(); - - assertTrue(record.isPresent()); - assertEquals(record.get().getLevel(), Level.WARNING); - LogManager.getLogManager().reset(); + void checkCredentialsSinchEvents() { + assertDoesNotThrow( + () -> new ConversationService(null, null, null, null).sinchEvents(), "Init passed"); } @Test - void regionTemplateNoWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - UnifiedCredentials credentials = - UnifiedCredentials.builder() - .setKeyId("foo key ") - .setKeySecret("foo secret") - .setProjectId("foo project") - .build(); - ConversationContext context = - ConversationContext.builder() - .setTemplateManagementUrl("https://foo.url") - .setRegion(ConversationRegion.BR) - .setRegionAsDefault(false) - .build(); - ServerConfiguration server = new ServerConfiguration("https://oauth.foo.url"); - - new ConversationService(credentials, context, server, () -> httpClient).templates().v2(); - - Optional record = - logRecorder.records.stream() - .filter( - r -> r.getMessage().contains("Using default region for Conversation Template 'us")) - .findFirst(); - - assertFalse(record.isPresent()); - LogManager.getLogManager().reset(); + void passInitWithoutSettings() { + assertDoesNotThrow(() -> new ConversationService(null, null, null, null), "Init passed"); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsServiceTest.java index 00e067784..cb26239b1 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ConversationsServiceTest.java @@ -1,93 +1,126 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.ConversationApi; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameter.STYLE; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.ConversationsService; import com.sinch.sdk.domains.conversation.models.v1.ConversationChannel; -import com.sinch.sdk.domains.conversation.models.v1.conversation.Conversation; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListConversationsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.conversation.internal.ListRecentConversationsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRecentRequest.OrderEnum; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.ConversationsListRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectEventRequest; -import com.sinch.sdk.domains.conversation.models.v1.conversation.request.InjectMessageRequestBase; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationRecentMessage; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListRecentResponse; -import com.sinch.sdk.domains.conversation.models.v1.conversation.response.ConversationsListResponse; +import com.sinch.sdk.domains.conversation.models.v1.conversations.Conversation; import com.sinch.sdk.domains.conversation.models.v1.conversations.ConversationDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.conversations.request.ConversationsListQueryParameters; +import com.sinch.sdk.domains.conversation.models.v1.conversations.request.ConversationsUpdateQueryParameters; import com.sinch.sdk.domains.conversation.models.v1.conversations.request.CreateConversationRequestTest; import com.sinch.sdk.domains.conversation.models.v1.conversations.request.InjectEventDtoTest; import com.sinch.sdk.domains.conversation.models.v1.conversations.request.InjectMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.conversations.request.RecentConversationsListQueryParameters; +import com.sinch.sdk.domains.conversation.models.v1.conversations.request.RecentConversationsListQueryParameters.OrderEnum; +import com.sinch.sdk.domains.conversation.models.v1.conversations.response.ConversationRecentMessage; import com.sinch.sdk.domains.conversation.models.v1.conversations.response.ConversationRecentMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.conversations.response.ConversationsListResponse; +import com.sinch.sdk.domains.conversation.models.v1.conversations.response.RecentConversationsListResponse; import com.sinch.sdk.domains.conversation.models.v1.request.MetadataUpdateStrategy; -import com.sinch.sdk.models.ConversationContext; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Map; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.Mock; @TestWithResources public class ConversationsServiceTest extends ConversationBaseTest { - - @Mock ConversationContext context; - @Mock ConversationApi api; @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; @Mock Map authManagers; - @Captor ArgumentCaptor projectIdCaptor; - @Captor ArgumentCaptor conversationIdCaptor; - @Captor ArgumentCaptor injectMessageCaptor; - @Captor ArgumentCaptor injectEventCaptor; + + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); ConversationsService service; - String uriPartID = "foovalue"; - @BeforeEach - public void initMocks() { - service = spy(new ConversationsService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } + @GivenTextResource( + "/domains/conversation/v1/conversations/request/CreateConversationRequestDto.json") + String jsonCreateConversationRequestDto; + + @GivenTextResource("domains/conversation/v1/conversations/ConversationRequestDto.json") + String jsonConversationRequest; - @GivenJsonResource( + @GivenTextResource("domains/conversation/v1/conversations/ConversationResponseDto.json") + String jsonConversationResponse; + + @GivenTextResource( "/domains/conversation/v1/conversations/response/ConversationsListResponse-page-0.json") - ListConversationsResponseInternal conversationsListPage0; + String conversationsListPage0; - @GivenJsonResource( + @GivenTextResource( "/domains/conversation/v1/conversations/response/ConversationsListResponse-page-1.json") - ListConversationsResponseInternal conversationsListPage1; + String conversationsListPage1; - @GivenJsonResource( + @GivenTextResource( "/domains/conversation/v1/conversations/response/ConversationsListResponse-page-2.json") - ListConversationsResponseInternal conversationsListPage2; + String conversationsListPage2; - @GivenJsonResource( + @GivenTextResource( "/domains/conversation/v1/conversations/response/ConversationsListRecentResponse-page-0.json") - ListRecentConversationsResponseInternal conversationsRecentListPage0; + String conversationsRecentListPage0; - @GivenJsonResource( + @GivenTextResource( "/domains/conversation/v1/conversations/response/ConversationsListRecentResponse-page-1.json") - ListRecentConversationsResponseInternal conversationsRecentListPage1; + String conversationsRecentListPage1; + + @GivenTextResource( + "/domains/conversation/v1/conversations/request/InjectContactMessageRequestDto.json") + static String jsonInjectContactMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/conversations/request/InjectEventRequestDto.json") + static String jsonInjectEventRequestDto; + + @BeforeEach + public void initMocks() { + service = + new ConversationsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); + } @Test void create() throws ApiException { - when(api.conversationCreateConversation( - eq(uriPartID), eq(CreateConversationRequestTest.createConversationRequestDto))) - .thenReturn(ConversationDtoTest.conversationResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/conversations", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonCreateConversationRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonConversationResponse.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); Conversation response = service.create(CreateConversationRequestTest.createConversationRequestDto); @@ -98,9 +131,27 @@ void create() throws ApiException { @Test void get() throws ApiException { - when(api.conversationGetConversation( - eq(uriPartID), eq(ConversationDtoTest.conversationRequest.getId()))) - .thenReturn(ConversationDtoTest.conversationResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ConversationDtoTest.conversationRequest.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonConversationResponse.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); Conversation response = service.get(ConversationDtoTest.conversationRequest.getId()); @@ -110,83 +161,173 @@ void get() throws ApiException { @Test void list() throws ApiException { - when(api.conversationListConversations( - eq(uriPartID), - eq("conversation app Id"), - eq("contact id"), - eq(null), - eq(1), - eq(null), - eq(ConversationChannel.MESSENGER))) - .thenReturn(conversationsListPage0); - - when(api.conversationListConversations( - eq(uriPartID), - eq("conversation app Id"), - eq("contact id"), - eq(null), - eq(1), - eq("ChowMUo1NUVOVERUSFlGQVlKMFE1WFpaSktSVhIaMDFITkIzMzY0UFdCQkcyR1paV1ZWVDNERDI="), - eq(ConversationChannel.MESSENGER))) - .thenReturn(conversationsListPage1); - - when(api.conversationListConversations( - eq(uriPartID), - eq("conversation app Id"), - eq("contact id"), - eq(null), - eq(1), - eq("ChowMUo1NUVBSk1FNDZQMlI4SFIxRjVZRjYxWhIaMDFITkIzMzY0UFdCQkcyR1paV1ZWVDNERDI="), - eq(ConversationChannel.MESSENGER))) - .thenReturn(conversationsListPage2); - ConversationsListRequest request = - ConversationsListRequest.builder() + HttpRequest httpRequest1 = + new HttpRequest( + String.format("/v1/projects/%s/conversations", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("app_id", "conversation app Id", STYLE.FORM, true), + new URLParameter("contact_id", "contact id", STYLE.FORM, true), + new URLParameter("page_size", 1, STYLE.FORM, true), + new URLParameter( + "active_channel", ConversationChannel.MESSENGER, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format("/v1/projects/%s/conversations", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("app_id", "conversation app Id", STYLE.FORM, true), + new URLParameter("contact_id", "contact id", STYLE.FORM, true), + new URLParameter("page_size", 1, STYLE.FORM, true), + new URLParameter( + "page_token", + "ChowMUo1NUVOVERUSFlGQVlKMFE1WFpaSktSVhIaMDFITkIzMzY0UFdCQkcyR1paV1ZWVDNERDI=", + STYLE.FORM, + true), + new URLParameter( + "active_channel", ConversationChannel.MESSENGER, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest3 = + new HttpRequest( + String.format("/v1/projects/%s/conversations", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("app_id", "conversation app Id", STYLE.FORM, true), + new URLParameter("contact_id", "contact id", STYLE.FORM, true), + new URLParameter("page_size", 1, STYLE.FORM, true), + new URLParameter( + "page_token", + "ChowMUo1NUVBSk1FNDZQMlI4SFIxRjVZRjYxWhIaMDFITkIzMzY0UFdCQkcyR1paV1ZWVDNERDI=", + STYLE.FORM, + true), + new URLParameter( + "active_channel", ConversationChannel.MESSENGER, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse(200, null, Collections.emptyMap(), conversationsListPage0.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse(200, null, Collections.emptyMap(), conversationsListPage1.getBytes()); + HttpResponse httpResponse3 = + new HttpResponse(200, null, Collections.emptyMap(), conversationsListPage2.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest3)))) + .thenReturn(httpResponse3); + + ConversationsListQueryParameters request = + ConversationsListQueryParameters.builder() .setAppId("conversation app Id") .setContactId("contact id") .setPageSize(1) .setActiveChannel(ConversationChannel.MESSENGER) .build(); - ConversationsListResponse response0 = service.list(request); - Collection content = response0.getContent(); + ConversationsListResponse response1 = service.list(request); + Collection content = response1.getContent(); Assertions.assertThat(content.size()).isEqualTo(1); TestHelpers.recursiveEquals( content.stream().findFirst().orElse(null), ConversationDtoTest.conversationResponse); - Assertions.assertThat(response0.hasNextPage()).isEqualTo(true); + Assertions.assertThat(response1.hasNextPage()).isEqualTo(true); - ConversationsListResponse response1 = response0.nextPage(); - content = response1.getContent(); + ConversationsListResponse response2 = response1.nextPage(); + content = response2.getContent(); Assertions.assertThat(content.size()).isEqualTo(1); TestHelpers.recursiveEquals( content.stream().findFirst().orElse(null), ConversationDtoTest.conversationResponse); - Assertions.assertThat(response1.hasNextPage()).isEqualTo(true); + Assertions.assertThat(response2.hasNextPage()).isEqualTo(true); - ConversationsListResponse response2 = response1.nextPage(); - content = response2.getContent(); + ConversationsListResponse response3 = response2.nextPage(); + content = response3.getContent(); Assertions.assertThat(content.size()).isEqualTo(0); - Assertions.assertThat(response2.hasNextPage()).isEqualTo(false); + Assertions.assertThat(response3.hasNextPage()).isEqualTo(false); } @Test void listRecent() throws ApiException { - when(api.conversationListRecentConversations( - eq(uriPartID), eq("conversation app Id"), eq(true), eq(1), eq(null), eq("ASC"))) - .thenReturn(conversationsRecentListPage0); - - when(api.conversationListRecentConversations( - eq(uriPartID), eq("conversation app Id"), eq(true), eq(1), eq("1"), eq("ASC"))) - .thenReturn(conversationsRecentListPage1); - - ConversationsListRecentRequest request = - ConversationsListRecentRequest.builder() + HttpRequest httpRequest1 = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations:recent", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("app_id", "conversation app Id", STYLE.FORM, true), + new URLParameter("only_active", true, STYLE.FORM, true), + new URLParameter("page_size", 1, STYLE.FORM, true), + new URLParameter("order", OrderEnum.ASC, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations:recent", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("app_id", "conversation app Id", STYLE.FORM, true), + new URLParameter("only_active", true, STYLE.FORM, true), + new URLParameter("page_size", 1, STYLE.FORM, true), + new URLParameter("page_token", "1", STYLE.FORM, true), + new URLParameter("order", OrderEnum.ASC, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse( + 200, null, Collections.emptyMap(), conversationsRecentListPage0.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse( + 200, null, Collections.emptyMap(), conversationsRecentListPage1.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + + RecentConversationsListQueryParameters request = + RecentConversationsListQueryParameters.builder() .setAppId("conversation app Id") .setOnlyActive(true) .setPageSize(1) .setOrder(OrderEnum.ASC) .build(); - ConversationsListRecentResponse response0 = service.listRecent(request); + RecentConversationsListResponse response0 = service.listRecent(request); Collection content = response0.getContent(); Assertions.assertThat(content.size()).isEqualTo(1); TestHelpers.recursiveEquals( @@ -194,7 +335,7 @@ void listRecent() throws ApiException { ConversationRecentMessageDtoTest.conversationRecentMessage); Assertions.assertThat(response0.hasNextPage()).isEqualTo(true); - ConversationsListRecentResponse response1 = response0.nextPage(); + RecentConversationsListResponse response1 = response0.nextPage(); content = response1.getContent(); Assertions.assertThat(content.size()).isEqualTo(1); TestHelpers.recursiveEquals( @@ -204,46 +345,97 @@ void listRecent() throws ApiException { } @Test - void stopActive() throws ApiException { - - service.stopActive(ConversationDtoTest.conversationRequest.getId()); + void delete() throws ApiException { - verify(api) - .conversationStopActiveConversation( - projectIdCaptor.capture(), conversationIdCaptor.capture()); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ConversationDtoTest.conversationRequest.getId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(conversationIdCaptor.getValue()) - .isEqualTo(ConversationDtoTest.conversationResponse.getId()); + service.delete(ConversationDtoTest.conversationRequest.getId()); } @Test - void delete() throws ApiException { - - service.delete(ConversationDtoTest.conversationRequest.getId()); + void stopActive() throws ApiException { - verify(api) - .conversationDeleteConversation(projectIdCaptor.capture(), conversationIdCaptor.capture()); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s:stop", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ConversationDtoTest.conversationRequest.getId())), + HttpMethod.POST, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(conversationIdCaptor.getValue()) - .isEqualTo(ConversationDtoTest.conversationResponse.getId()); + service.stopActive(ConversationDtoTest.conversationRequest.getId()); } @Test void update() throws ApiException { - when(api.conversationUpdateConversation( - eq(uriPartID), - eq(ConversationDtoTest.conversationRequest.getId()), - eq(ConversationDtoTest.conversationRequest), - eq(null), - eq(MetadataUpdateStrategy.MERGE_PATCH))) - .thenReturn(ConversationDtoTest.conversationResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(ConversationDtoTest.conversationRequest.getId())), + HttpMethod.PATCH, + Arrays.asList( + new URLParameter( + "metadata_update_strategy", + MetadataUpdateStrategy.MERGE_PATCH, + STYLE.FORM, + true)), + jsonConversationRequest, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonConversationResponse.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + ConversationsUpdateQueryParameters queryParameters = + ConversationsUpdateQueryParameters.builder() + .setMetadataUpdateStrategy(MetadataUpdateStrategy.MERGE_PATCH) + .build(); Conversation response = service.update( ConversationDtoTest.conversationRequest.getId(), - MetadataUpdateStrategy.MERGE_PATCH, + queryParameters, ConversationDtoTest.conversationRequest); TestHelpers.recursiveEquals(response, ConversationDtoTest.conversationResponse); @@ -252,36 +444,59 @@ void update() throws ApiException { @Test void injectMessage() throws ApiException { + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s:inject-message", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + InjectMessageDtoTest.injectContactMessage.getConversationId())), + HttpMethod.POST, + Collections.emptyList(), + jsonInjectContactMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + service.injectMessage( InjectMessageDtoTest.injectContactMessage.getConversationId(), InjectMessageDtoTest.injectContactMessage); - - verify(api) - .conversationInjectMessage( - projectIdCaptor.capture(), - conversationIdCaptor.capture(), - injectMessageCaptor.capture()); - - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(conversationIdCaptor.getValue()) - .isEqualTo(InjectMessageDtoTest.injectContactMessage.getConversationId()); - TestHelpers.recursiveEquals( - injectMessageCaptor.getValue(), InjectMessageDtoTest.injectContactMessage); } @Test void injectEvent() throws ApiException { + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/conversations/%s:inject-event", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment(InjectEventDtoTest.injectEvent.getConversationId())), + HttpMethod.POST, + Collections.emptyList(), + jsonInjectEventRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + service.injectEvent( InjectEventDtoTest.injectEvent.getConversationId(), InjectEventDtoTest.injectEvent); - - verify(api) - .eventsInjectEvent( - projectIdCaptor.capture(), conversationIdCaptor.capture(), injectEventCaptor.capture()); - - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(conversationIdCaptor.getValue()) - .isEqualTo(InjectEventDtoTest.injectEvent.getConversationId()); - TestHelpers.recursiveEquals(injectEventCaptor.getValue(), InjectEventDtoTest.injectEvent); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CredentialsValidationHelper.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CredentialsValidationHelper.java index 892da8ff3..ad9c6fd30 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CredentialsValidationHelper.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/CredentialsValidationHelper.java @@ -7,6 +7,7 @@ import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.core.models.ServerConfiguration; import com.sinch.sdk.models.ConversationContext; +import com.sinch.sdk.models.ConversationRegion; import com.sinch.sdk.models.UnifiedCredentials; import java.util.function.Consumer; import java.util.function.Supplier; @@ -22,6 +23,8 @@ static void checkCredentials( doNotAcceptNullContext(httpClientSupplier, service); doNotAcceptEmptyURL(httpClientSupplier, service); doNotAcceptNullURL(httpClientSupplier, service); + doNotAcceptNullRegion(httpClientSupplier, service); + doNotAcceptEmptyRegion(httpClientSupplier, service); passInit(httpClientSupplier, service); } @@ -111,7 +114,8 @@ private static void doNotAcceptEmptyURL( .setKeySecret("foo") .setProjectId("foo") .build(); - ConversationContext context = ConversationContext.builder().setUrl("").build(); + ConversationContext context = + ConversationContext.builder().setUrl("").setRegion(ConversationRegion.BR).build(); ServerConfiguration server = new ServerConfiguration(""); Exception exception = assertThrows( @@ -131,7 +135,8 @@ private static void doNotAcceptNullURL( .setKeySecret("foo") .setProjectId("foo") .build(); - ConversationContext context = ConversationContext.builder().build(); + ConversationContext context = + ConversationContext.builder().setRegion(ConversationRegion.BR).build(); ServerConfiguration server = new ServerConfiguration(""); Exception exception = assertThrows( @@ -143,6 +148,50 @@ private static void doNotAcceptNullURL( exception.getMessage().contains("Conversation service requires 'url' to be defined")); } + private static void doNotAcceptNullRegion( + Supplier httpClientSupplier, Consumer service) { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + ConversationContext context = ConversationContext.builder().setUrl("https://foo.url").build(); + ServerConfiguration server = new ServerConfiguration(""); + Exception exception = + assertThrows( + NullPointerException.class, + () -> + service.accept( + new ConversationService(credentials, context, server, httpClientSupplier))); + assertTrue( + exception.getMessage().contains("Conversation service requires 'region' to be defined")); + } + + private static void doNotAcceptEmptyRegion( + Supplier httpClientSupplier, Consumer service) { + UnifiedCredentials credentials = + UnifiedCredentials.builder() + .setKeyId("foo") + .setKeySecret("foo") + .setProjectId("foo") + .build(); + ConversationContext context = + ConversationContext.builder() + .setUrl("https://foo.url") + .setRegion(ConversationRegion.from("")) + .build(); + ServerConfiguration server = new ServerConfiguration(""); + Exception exception = + assertThrows( + IllegalArgumentException.class, + () -> + service.accept( + new ConversationService(credentials, context, server, httpClientSupplier))); + assertTrue( + exception.getMessage().contains("Conversation service requires 'region' to be defined")); + } + private static void passInit( Supplier httpClientSupplier, Consumer service) { UnifiedCredentials credentials = @@ -151,7 +200,11 @@ private static void passInit( .setKeySecret("foo") .setProjectId("foo") .build(); - ConversationContext context = ConversationContext.builder().setUrl("foo").build(); + ConversationContext context = + ConversationContext.builder() + .setUrl("foo") + .setRegion(ConversationRegion.from("foo")) + .build(); ServerConfiguration server = new ServerConfiguration("foo"); assertDoesNotThrow( () -> diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventDestinationsApiServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventDestinationsApiServiceTest.java new file mode 100644 index 000000000..352447936 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventDestinationsApiServiceTest.java @@ -0,0 +1,218 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.core.models.pagination.Page; +import com.sinch.sdk.domains.conversation.api.v1.EventDestinationsService; +import com.sinch.sdk.domains.conversation.models.v1.eventdestinations.EventDestination; +import com.sinch.sdk.domains.conversation.models.v1.eventdestinations.EventDestinationDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.eventdestinations.response.EventDestinationsListResponse; +import com.sinch.sdk.domains.conversation.models.v1.eventdestinations.response.EventDestinationsListResponseDtoTest; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +@TestWithResources +public class EventDestinationsApiServiceTest extends ConversationBaseTest { + + @Mock ServerConfiguration serverConfiguration; + @Mock HttpClient httpClient; + @Mock Map authManagers; + EventDestinationsService service; + String uriPartID = "foovalue"; + String fooEventDestinationId = "barEventDestinationId"; + String fooAppId = "barAppId"; + + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + @GivenTextResource( + "domains/conversation/v1/eventdestinations/request/EventDestinationRequestDto.json") + String eventDestinationRequestDto; + + @GivenTextResource( + "/domains/conversation/v1/eventdestinations/response/EventDestinationResponseDto.json") + String eventDestinationResponseDto; + + @GivenTextResource( + "domains/conversation/v1/eventdestinations/response/EventDestinationsListResponseDto.json") + String eventDestinationsListResponseDto; + + @BeforeEach + public void initMocks() { + service = + new EventDestinationsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriPartID); + } + + @Test + void list() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/apps/%s/webhooks", + URLPathUtils.encodePathSegment(uriPartID), + URLPathUtils.encodePathSegment(fooAppId)), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), eventDestinationsListResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + EventDestinationsListResponse response = service.list(fooAppId); + Iterator iterator = response.iterator(); + + EventDestinationsListResponse expectedListResponse = + new EventDestinationsListResponse( + new Page<>( + EventDestinationsListResponseDtoTest.expectedResponseDto.getEventDestinations(), + null)); + Iterator expectedIterator = expectedListResponse.iterator(); + + while (iterator.hasNext()) { + EventDestination item = iterator.next(); + EventDestination expectedItem = expectedIterator.next(); + TestHelpers.recursiveEquals(item, expectedItem); + } + Assertions.assertThat(expectedIterator.hasNext()).isEqualTo(false); + } + + @Test + void get() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/webhooks/%s", uriPartID, fooEventDestinationId), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), eventDestinationResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + EventDestination response = service.get(fooEventDestinationId); + + TestHelpers.recursiveEquals(response, EventDestinationDtoTest.expectedResponseDto); + } + + @Test + void create() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/webhooks", uriPartID), + HttpMethod.POST, + Collections.emptyList(), + eventDestinationRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), eventDestinationResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + EventDestination response = service.create(EventDestinationDtoTest.expectedRequestDto); + + TestHelpers.recursiveEquals(response, EventDestinationDtoTest.expectedResponseDto); + } + + @Test + void update() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/webhooks/%s", uriPartID, fooEventDestinationId), + HttpMethod.PATCH, + Collections.emptyList(), + eventDestinationRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), eventDestinationResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + EventDestination response = + service.update(fooEventDestinationId, EventDestinationDtoTest.expectedResponseDto); + + TestHelpers.recursiveEquals(response, EventDestinationDtoTest.expectedResponseDto); + } + + @Test + void delete() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/webhooks/%s", uriPartID, fooEventDestinationId), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(204, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(fooEventDestinationId); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsServiceTest.java index 9f0c9326a..659dda1a8 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/EventsServiceTest.java @@ -1,117 +1,212 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.EventsApi; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameter.STYLE; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.EventsService; import com.sinch.sdk.domains.conversation.models.v1.events.ConversationEvent; import com.sinch.sdk.domains.conversation.models.v1.events.ConversationEventDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.events.internal.ListEventsResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.events.request.EventsListRequest; +import com.sinch.sdk.domains.conversation.models.v1.events.request.EventsListQueryParameters; import com.sinch.sdk.domains.conversation.models.v1.events.request.SendEventRequestDtoTest; import com.sinch.sdk.domains.conversation.models.v1.events.response.EventsListResponse; import com.sinch.sdk.domains.conversation.models.v1.events.response.SendEventResponse; -import com.sinch.sdk.models.ConversationContext; -import java.time.Instant; +import com.sinch.sdk.domains.conversation.models.v1.events.response.SendEventResponseDtoTest; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.Map; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.Mock; @TestWithResources public class EventsServiceTest extends ConversationBaseTest { - @Mock ConversationContext context; - @Mock EventsApi api; @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; @Mock Map authManagers; - @Captor ArgumentCaptor projectIdCaptor; - @Captor ArgumentCaptor eventIdCaptor; + + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); EventsService service; - String uriPartID = "foovalue"; - @BeforeEach - public void initMocks() { - service = spy(new EventsService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } + @GivenTextResource("domains/conversation/v1/events/ConversationEventGenericEventDto.json") + String jsonConversationEvent; + + @GivenTextResource("/domains/conversation/v1/events/response/EventsListResponse-page-0.json") + String eventsListPage0; - SendEventResponse expectedResponse = - SendEventResponse.builder().setEventId("event id").setAcceptedTime(Instant.now()).build(); + @GivenTextResource("/domains/conversation/v1/events/response/EventsListResponse-page-1.json") + String eventsListPage1; - @GivenJsonResource("/domains/conversation/v1/events/response/EventsListResponse-page-0.json") - ListEventsResponseInternal eventsListPage0; + @GivenTextResource("/domains/conversation/v1/events/request/SendEventRequestDto.json") + String jsonSendEventRequestDto; - @GivenJsonResource("/domains/conversation/v1/events/response/EventsListResponse-page-1.json") - ListEventsResponseInternal eventsListPage1; + @GivenTextResource("domains/conversation/v1/events/response/SendEventResponseDto.json") + String jsonSendEventResponseDto; + + @BeforeEach + public void initMocks() { + service = + new EventsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); + } @Test void get() throws ApiException { - when(api.eventsGetEvent( - eq(uriPartID), eq(ConversationEventDtoTest.expectedConversationEventDto.getId()))) - .thenReturn(ConversationEventDtoTest.expectedConversationEventDto); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/events/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationEventDtoTest.expectedConversationEventDto.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonConversationEvent.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); ConversationEvent response = service.get(ConversationEventDtoTest.expectedConversationEventDto.getId()); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ConversationEventDtoTest.expectedConversationEventDto); + TestHelpers.recursiveEquals(response, ConversationEventDtoTest.expectedConversationEventDto); } @Test void send() throws ApiException { - when(api.eventsSendEvent(eq(uriPartID), eq(SendEventRequestDtoTest.sendEventDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/events:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendEventRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), jsonSendEventResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendEventResponse response = service.send(SendEventRequestDtoTest.sendEventDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendEventResponseDtoTest.expectedResponse); } @Test void delete() throws ApiException { - service.delete(ConversationEventDtoTest.expectedConversationEventDto.getId()); - - verify(api).eventsDeleteEvents(projectIdCaptor.capture(), eventIdCaptor.capture()); - - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(eventIdCaptor.getValue()) - .isEqualTo(ConversationEventDtoTest.expectedConversationEventDto.getId()); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/events/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + SendEventResponseDtoTest.expectedResponse.getEventId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(SendEventResponseDtoTest.expectedResponse.getEventId()); } @Test - void list() throws ApiException, JsonProcessingException { - - when(api.eventsListEvents(eq(uriPartID), eq("conversation id"), eq(null), eq(null), eq(null))) - .thenReturn(eventsListPage0); - - when(api.eventsListEvents( - eq(uriPartID), - eq("conversation id"), - eq(null), - eq(null), - eq(eventsListPage0.getNextPageToken()))) - .thenReturn(eventsListPage1); - - EventsListRequest request = - EventsListRequest.builder().setConversationId("conversation id").build(); + void list() throws ApiException { + + HttpRequest httpRequest1 = + new HttpRequest( + String.format("/v1/projects/%s/events", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList(new URLParameter("conversation_id", "conversation id", STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format("/v1/projects/%s/events", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter("conversation_id", "conversation id", STYLE.FORM, true), + new URLParameter( + "page_token", + "ChowMUhRN1c0WjFSMTI2N0RCQlI4UzQ3TlZQOEoGCP70264G", + STYLE.FORM, + true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse(200, null, Collections.emptyMap(), eventsListPage0.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse(200, null, Collections.emptyMap(), eventsListPage1.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + + EventsListQueryParameters request = + EventsListQueryParameters.builder().setConversationId("conversation id").build(); EventsListResponse response0 = service.list(request); diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java index 91a237352..28ab8e4c6 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/MessagesServiceTest.java @@ -1,363 +1,751 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.MessagesService.MessageSource; -import com.sinch.sdk.domains.conversation.api.v1.adapters.messages.ConversationMessageMapper; -import com.sinch.sdk.domains.conversation.api.v1.internal.MessagesApi; -import com.sinch.sdk.domains.conversation.models.v1.internal.ConversationMessageInternal; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.http.URLParameter; +import com.sinch.sdk.core.http.URLParameter.STYLE; +import com.sinch.sdk.core.http.URLPathUtils; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.MessagesService; import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessage; import com.sinch.sdk.domains.conversation.models.v1.messages.ConversationMessageDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.messages.internal.ListMessagesResponseInternal; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessageUpdateRequest; -import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesListRequest; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.LastMessagesByChannelIdentityListQueryParameters; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessageSource; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesDeleteQueryParameters; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesGetQueryParameters; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.MessagesUpdateQueryParameters; import com.sinch.sdk.domains.conversation.models.v1.messages.request.SendMessageDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.messages.request.UpdateMessageDtoTest; import com.sinch.sdk.domains.conversation.models.v1.messages.response.MessagesListResponse; import com.sinch.sdk.domains.conversation.models.v1.messages.response.SendMessageResponse; -import com.sinch.sdk.models.ConversationContext; -import java.time.Instant; +import com.sinch.sdk.domains.conversation.models.v1.messages.response.SendMessageResponseDtoTest; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; import java.util.Map; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.Mock; @TestWithResources public class MessagesServiceTest extends ConversationBaseTest { - - @Mock ConversationContext context; - @Mock MessagesApi api; @Mock HttpClient httpClient; + @Mock ServerConfiguration serverConfiguration; @Mock Map authManagers; - @Captor ArgumentCaptor projectIdCaptor; - @Captor ArgumentCaptor messageIdCaptor; - @Captor ArgumentCaptor messageSourceCaptor; + + static final String uriUUID = "foo"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); MessagesService service; - String uriPartID = "foovalue"; @BeforeEach public void initMocks() { - service = spy(new MessagesService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); + service = + new MessagesServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); } - SendMessageResponse expectedResponse = - SendMessageResponse.builder() - .setMessageId("message id") - .setAcceptedTime(Instant.now()) - .build(); + @GivenTextResource("/domains/conversation/v1/messages/ConversationMessageAppTextResponseDto.json") + String jsonConversationMessageAppTextResponseDto; + + @GivenTextResource("domains/conversation/v1/messages/response/SendMessageResponseDto.json") + String sendMessageResponseDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/SendTemplateMessageRequestDto.json") + String jsonSendTemplateMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/SendCardMessageRequestDto.json") + String jsonSendCardMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/SendCarouselMessageRequestDto.json") + String jsonSendCarouselMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/SendChoiceMessageRequestDto.json") + String jsonSendChoiceMessageRequestDto; + + @GivenTextResource( + "/domains/conversation/v1/messages/request/SendContactInfoMessageRequestDto.json") + String jsonSendContactInfoMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/SendListMessageRequestDto.json") + String jsonSendListMessageRequestDto; - @GivenTextResource("/domains/conversation/v1/messages/ConversationMessageAppTextRequestDto.json") - static String jsonConversationMessageAppTextDto; + @GivenTextResource("/domains/conversation/v1/messages/request/SendLocationMessageRequestDto.json") + String jsonSendLocationMessageRequestDto; - @GivenJsonResource("/domains/conversation/v1/messages/response/MessagesListResponse-page-0.json") - ListMessagesResponseInternal messageListPage0; + @GivenTextResource("/domains/conversation/v1/messages/request/SendMediaMessageRequestDto.json") + String jsonSendMediaMessageRequestDto; - @GivenJsonResource("/domains/conversation/v1/messages/response/MessagesListResponse-page-1.json") - ListMessagesResponseInternal messageListPage1; + @GivenTextResource("/domains/conversation/v1/messages/request/SendTextMessageRequestDto.json") + String jsonSendTextMessageRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/request/MessageUpdateRequestDto.json") + String jsonMessageUpdateRequestDto; + + @GivenTextResource("/domains/conversation/v1/messages/response/MessagesListResponse-page-0.json") + String messageListPage0; + + @GivenTextResource("/domains/conversation/v1/messages/response/MessagesListResponse-page-1.json") + String messageListPage1; @Test void getDefault() throws ApiException { - when(api.messagesGetMessage( - eq(uriPartID), - eq(ConversationMessageDtoTest.appConversationMessageRequest.getId()), - eq(null))) - .thenReturn( - ConversationMessageMapper.convert( - ConversationMessageDtoTest.appConversationMessageRequest)); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); ConversationMessage response = service.get(ConversationMessageDtoTest.appConversationMessageRequest.getId()); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest); + TestHelpers.recursiveEquals( + response, ConversationMessageDtoTest.appConversationMessageResponse); } @Test void getBySource() throws ApiException { - when(api.messagesGetMessage( - eq(uriPartID), - eq(ConversationMessageDtoTest.appConversationMessageRequest.getId()), - eq("CONVERSATION_SOURCE"))) - .thenReturn( - ConversationMessageMapper.convert( - ConversationMessageDtoTest.appConversationMessageRequest)); - + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.GET, + Arrays.asList( + new URLParameter( + "messages_source", MessageSource.CONVERSATION_SOURCE, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + MessagesGetQueryParameters queryParameters = + MessagesGetQueryParameters.builder() + .setMessagesSource(MessageSource.CONVERSATION_SOURCE) + .build(); ConversationMessage response = service.get( - ConversationMessageDtoTest.appConversationMessageRequest.getId(), - MessageSource.CONVERSATION_SOURCE); + ConversationMessageDtoTest.appConversationMessageRequest.getId(), queryParameters); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest); + TestHelpers.recursiveEquals( + response, ConversationMessageDtoTest.appConversationMessageResponse); } @Test void send() throws ApiException { - when(api.messagesSendMessage( - eq(uriPartID), eq(SendMessageDtoTest.sendTemplateMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendTemplateMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendMessage(SendMessageDtoTest.sendTemplateMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + TestHelpers.recursiveEquals(response, SendMessageResponseDtoTest.expectedResponse); } @Test void sendCardMessage() throws ApiException { - when(api.messagesSendMessage(eq(uriPartID), eq(SendMessageDtoTest.sendCardMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendCardMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendCardMessage(SendMessageDtoTest.sendCardMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendCarouselMessage() throws ApiException { - when(api.messagesSendMessage( - eq(uriPartID), eq(SendMessageDtoTest.sendCarouselMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendCarouselMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendCarouselMessage(SendMessageDtoTest.sendCarouselMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendChoiceMessage() throws ApiException { - when(api.messagesSendMessage(eq(uriPartID), eq(SendMessageDtoTest.sendChoiceMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendChoiceMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendChoiceMessage(SendMessageDtoTest.sendChoiceMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendContactInfoMessage() throws ApiException { - when(api.messagesSendMessage( - eq(uriPartID), eq(SendMessageDtoTest.sendContactInfoMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendContactInfoMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendContactInfoMessage(SendMessageDtoTest.sendContactInfoMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendListMessage() throws ApiException { - when(api.messagesSendMessage(eq(uriPartID), eq(SendMessageDtoTest.sendListMessageRequestDto))) - .thenReturn(expectedResponse); - + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendListMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendListMessage(SendMessageDtoTest.sendListMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendLocationMessage() throws ApiException { - when(api.messagesSendMessage( - eq(uriPartID), eq(SendMessageDtoTest.sendLocationMessageRequestDto))) - .thenReturn(expectedResponse); - + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendLocationMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendLocationMessage(SendMessageDtoTest.sendLocationMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendMediaMessage() throws ApiException { - when(api.messagesSendMessage(eq(uriPartID), eq(SendMessageDtoTest.sendMediaMessageRequestDto))) - .thenReturn(expectedResponse); - + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendMediaMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendMediaMessage(SendMessageDtoTest.sendMediaMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendTemplateMessage() throws ApiException { - when(api.messagesSendMessage( - eq(uriPartID), eq(SendMessageDtoTest.sendTemplateMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendTemplateMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendTemplateMessage(SendMessageDtoTest.sendTemplateMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void sendTextMessage() throws ApiException { - when(api.messagesSendMessage(eq(uriPartID), eq(SendMessageDtoTest.sendTextMessageRequestDto))) - .thenReturn(expectedResponse); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:send", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + jsonSendTextMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse(200, null, Collections.emptyMap(), sendMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); SendMessageResponse response = service.sendTextMessage(SendMessageDtoTest.sendTextMessageRequestDto); - Assertions.assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse); + Assertions.assertThat(response) + .usingRecursiveComparison() + .isEqualTo(SendMessageResponseDtoTest.expectedResponse); } @Test void deleteDefault() throws ApiException { - service.delete(ConversationMessageDtoTest.appConversationMessageRequest.getId()); - - verify(api) - .messagesDeleteMessage( - projectIdCaptor.capture(), messageIdCaptor.capture(), messageSourceCaptor.capture()); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(messageIdCaptor.getValue()) - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest.getId()); - Assertions.assertThat(messageSourceCaptor.getValue()).isNull(); + service.delete(ConversationMessageDtoTest.appConversationMessageRequest.getId()); } @Test void deleteBySource() throws ApiException { - service.delete( - ConversationMessageDtoTest.appConversationMessageRequest.getId(), - MessageSource.DISPATCH_SOURCE); + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.DELETE, + Arrays.asList( + new URLParameter( + "messages_source", MessageSource.DISPATCH_SOURCE, STYLE.FORM, true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + MessagesDeleteQueryParameters queryParameters = + MessagesDeleteQueryParameters.builder() + .setMessagesSource(MessageSource.DISPATCH_SOURCE) + .build(); - verify(api) - .messagesDeleteMessage( - projectIdCaptor.capture(), messageIdCaptor.capture(), messageSourceCaptor.capture()); - - Assertions.assertThat(projectIdCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(messageIdCaptor.getValue()) - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest.getId()); - Assertions.assertThat(messageSourceCaptor.getValue()).isEqualTo("DISPATCH_SOURCE"); + service.delete( + ConversationMessageDtoTest.appConversationMessageRequest.getId(), queryParameters); } @Test - void updateDefault() throws ApiException, JsonProcessingException { - - MessageUpdateRequest request = - MessageUpdateRequest.builder().setMetadata("metadata value").build(); - - ConversationMessageInternal deserialized = - objectMapper.readValue( - jsonConversationMessageAppTextDto, ConversationMessageInternal.class); - - when(api.messagesUpdateMessageMetadata( - eq(uriPartID), - eq(ConversationMessageDtoTest.appConversationMessageRequest.getId()), - eq(request), - eq(null))) - .thenReturn(deserialized); + void updateDefault() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.PATCH, + Collections.emptyList(), + jsonMessageUpdateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); ConversationMessage response = - service.update(ConversationMessageDtoTest.appConversationMessageRequest.getId(), request); + service.update( + ConversationMessageDtoTest.appConversationMessageRequest.getId(), + UpdateMessageDtoTest.updateMessageRequestDto); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest); + TestHelpers.recursiveEquals( + response, ConversationMessageDtoTest.appConversationMessageResponse); } @Test - void updateBySource() throws ApiException, JsonProcessingException { - - MessageUpdateRequest request = - MessageUpdateRequest.builder().setMetadata("metadata value").build(); - - ConversationMessageInternal deserialized = - objectMapper.readValue( - jsonConversationMessageAppTextDto, ConversationMessageInternal.class); - - when(api.messagesUpdateMessageMetadata( - eq(uriPartID), - eq(ConversationMessageDtoTest.appConversationMessageRequest.getId()), - eq(request), - eq("DISPATCH_SOURCE"))) - .thenReturn(deserialized); + void updateBySource() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format( + "/v1/projects/%s/messages/%s", + URLPathUtils.encodePathSegment(uriUUID), + URLPathUtils.encodePathSegment( + ConversationMessageDtoTest.appConversationMessageRequest.getId())), + HttpMethod.PATCH, + Arrays.asList( + new URLParameter( + "messages_source", MessageSource.DISPATCH_SOURCE, STYLE.FORM, true)), + jsonMessageUpdateRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, + null, + Collections.emptyMap(), + jsonConversationMessageAppTextResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + MessagesUpdateQueryParameters queryParameters = + MessagesUpdateQueryParameters.builder() + .setMessagesSource(MessageSource.DISPATCH_SOURCE) + .build(); ConversationMessage response = service.update( ConversationMessageDtoTest.appConversationMessageRequest.getId(), - MessageSource.DISPATCH_SOURCE, - request); + queryParameters, + UpdateMessageDtoTest.updateMessageRequestDto); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(ConversationMessageDtoTest.appConversationMessageRequest); + TestHelpers.recursiveEquals( + response, ConversationMessageDtoTest.appConversationMessageResponse); + } + + @Test + void list() throws ApiException { + + HttpRequest httpRequest1 = + new HttpRequest( + String.format("/v1/projects/%s/messages", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format("/v1/projects/%s/messages", URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.GET, + Arrays.asList( + new URLParameter( + "page_token", + "ChowMUhRN1c0WjFSMTI2N0RCQlI4UzQ3TlZQOEoGCP70264G", + STYLE.FORM, + true)), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse(200, null, Collections.emptyMap(), messageListPage0.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse(200, null, Collections.emptyMap(), messageListPage1.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + + MessagesListResponse response0 = service.list(); + + Assertions.assertThat(response0.getContent().size()).isEqualTo(1); + Assertions.assertThat(response0.hasNextPage()).isEqualTo(true); + + MessagesListResponse response1 = response0.nextPage(); + Assertions.assertThat(response1.getContent().size()).isEqualTo(1); + Assertions.assertThat(response1.hasNextPage()).isEqualTo(false); } @Test - void list() throws ApiException, JsonProcessingException { - - when(api.messagesListMessages( - eq(uriPartID), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null))) - .thenReturn(messageListPage0); - - when(api.messagesListMessages( - eq(uriPartID), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(null), - eq(messageListPage0.getNextPageToken()), - eq(null), - eq(null), - eq(null), - eq(null))) - .thenReturn(messageListPage1); - - MessagesListRequest request = MessagesListRequest.builder().build(); - - MessagesListResponse response0 = service.list(request); + void listLastMessagesByChannelIdentity() throws ApiException { + + HttpRequest httpRequest1 = + new HttpRequest( + String.format( + "/v1/projects/%s/messages:fetch-last-message", + URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + "{\"channel_identities\":[\"CHANNEL_IDENTITY1\", \"CHANNEL_IDENTITY2\"]}", + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpRequest httpRequest2 = + new HttpRequest( + String.format( + "/v1/projects/%s/messages:fetch-last-message", + URLPathUtils.encodePathSegment(uriUUID)), + HttpMethod.POST, + Collections.emptyList(), + "{\"channel_identities\":[\"CHANNEL_IDENTITY1\", \"CHANNEL_IDENTITY2\"]," + + " \"page_token\":\"ChowMUhRN1c0WjFSMTI2N0RCQlI4UzQ3TlZQOEoGCP70264G\"}", + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse1 = + new HttpResponse(200, null, Collections.emptyMap(), messageListPage0.getBytes()); + HttpResponse httpResponse2 = + new HttpResponse(200, null, Collections.emptyMap(), messageListPage1.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest1)))) + .thenReturn(httpResponse1); + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest2)))) + .thenReturn(httpResponse2); + + List channelIdentities = Arrays.asList("CHANNEL_IDENTITY1", "CHANNEL_IDENTITY2"); + + LastMessagesByChannelIdentityListQueryParameters request = + LastMessagesByChannelIdentityListQueryParameters.builder() + .setChannelIdentities(channelIdentities) + .build(); + + MessagesListResponse response0 = service.listLastMessagesByChannelIdentity(request); Assertions.assertThat(response0.getContent().size()).isEqualTo(1); Assertions.assertThat(response0.hasNextPage()).isEqualTo(true); diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ProjectSettingsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ProjectSettingsServiceTest.java new file mode 100644 index 000000000..760052f45 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/ProjectSettingsServiceTest.java @@ -0,0 +1,167 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.TestHelpers; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.http.HttpClient; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.ProjectSettingsService; +import com.sinch.sdk.domains.conversation.models.v1.projectsettings.request.ProjectSettingsRequestDtoTest; +import com.sinch.sdk.domains.conversation.models.v1.projectsettings.response.ProjectSettingsResponse; +import com.sinch.sdk.domains.conversation.models.v1.projectsettings.response.ProjectSettingsResponseDtoTest; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; + +@TestWithResources +class ProjectSettingsServiceTest extends BaseTest { + + @Mock ServerConfiguration serverConfiguration; + @Mock HttpClient httpClient; + @Mock Map authManagers; + + ProjectSettingsService service; + String uriUUID = "foovalue"; + + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + @GivenTextResource( + "domains/conversation/v1/projectsettings/request/ProjectSettingsRequestDto.json") + String jsonProjectSettingsRequestDto; + + @GivenTextResource( + "domains/conversation/v1/projectsettings/response/ProjectSettingsResponseDto.json") + String jsonProjectSettingsResponseDto; + + @BeforeEach + public void initMocks() { + service = + new ProjectSettingsServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriUUID); + } + + @Test + void create() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/settings", uriUUID), + HttpMethod.POST, + Collections.emptyList(), + jsonProjectSettingsRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonProjectSettingsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + ProjectSettingsResponse response = service.create(ProjectSettingsRequestDtoTest.expectedDto); + + TestHelpers.recursiveEquals(response, ProjectSettingsResponseDtoTest.expectedDto); + } + + @Test + void get() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/settings", uriUUID), + HttpMethod.GET, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonProjectSettingsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + ProjectSettingsResponse response = service.get(); + + TestHelpers.recursiveEquals(response, ProjectSettingsResponseDtoTest.expectedDto); + } + + @Test + void update() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/settings", uriUUID), + HttpMethod.PATCH, + Collections.emptyList(), + jsonProjectSettingsRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonProjectSettingsResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + ProjectSettingsResponse response = service.update(ProjectSettingsRequestDtoTest.expectedDto); + + TestHelpers.recursiveEquals(response, ProjectSettingsResponseDtoTest.expectedDto); + } + + @Test + void delete() throws ApiException { + + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/settings", uriUUID), + HttpMethod.DELETE, + Collections.emptyList(), + (String) null, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.emptyList(), + AUTH_NAMES); + HttpResponse httpResponse = new HttpResponse(204, null, Collections.emptyMap(), null); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); + + service.delete(); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsServiceTest.java new file mode 100644 index 000000000..a5061f9dd --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/SinchEventsServiceTest.java @@ -0,0 +1,267 @@ +package com.sinch.sdk.domains.conversation.api.v1.adapters; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.SinchClient; +import com.sinch.sdk.auth.HmacAuthenticationValidation; +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.domains.conversation.api.v1.SinchEventsService; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.capability.CapabilityEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.channel.ChannelEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact.ContactCreateEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact.ContactDeleteEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact.ContactIdentitiesDuplicationEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact.ContactMergeEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.contact.ContactUpdateEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.conversation.ConversationDeleteEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.conversation.ConversationStartEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.conversation.ConversationStopEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.delivery.EventDeliveryReceiptEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.delivery.MessageDeliveryReceiptEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.inbound.InboundEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.message.MessageInboundEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.message.MessageSubmitEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.opting.OptInEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.opting.OptOutEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.record.RecordNotificationEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.smartconversations.MessageInboundSmartConversationRedactionEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.smartconversations.SmartConversationsEvent; +import com.sinch.sdk.domains.conversation.models.v1.sinchevents.unsupported.UnsupportedCallbackEvent; +import java.util.AbstractMap; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class SinchEventsServiceTest extends ConversationBaseTest { + + SinchEventsService serverService; + + @GivenTextResource("domains/conversation/v1/sinchevents/capability/CapabilityEventDto.json") + String jsonCapabilityEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/channel/ChannelEventDto.json") + String jsonChannelEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/contact/ContactCreateEventDto.json") + String jsonContactCreateEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/contact/ContactDeleteEventDto.json") + String jsonContactDeleteEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/contact/ContactIdentitiesDuplicationEventDto.json") + String jsonContactIdentitiesDuplicationEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/contact/ContactMergeEventDto.json") + String jsonContactMergeEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/contact/ContactUpdateEventDto.json") + String jsonContactUpdateEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/conversation/ConversationDeleteEventDto.json") + String jsonConversationDeleteEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/conversation/ConversationStartEventDto.json") + String jsonConversationStartEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/conversation/ConversationStopEventDto.json") + String jsonConversationStopEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/delivery/EventDeliveryReceiptEventDto.json") + String jsonEventDeliveryReport; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/delivery/MessageDeliveryReceiptEventDto.json") + String jsonMessageDeliveryReceiptEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/inbound/InboundContactEventDto.json") + String jsonInboundEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/message/MessageInboundEventDto.json") + String jsonMessageInboundEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/message/MessageSubmitEventDto.json") + String jsonMessageSubmitEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/opting/OptInEventDto.json") + String jsonOptInEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/opting/OptOutEventDto.json") + String jsonOptOutEvent; + + @GivenTextResource("domains/conversation/v1/sinchevents/record/RecordNotificationEventDto.json") + String jsonRecordNotificationEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/smartconversations/MessageInboundSmartConversationRedactionEventDto.json") + String jsonMessageInboundSmartConversationRedactionEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/smartconversations/SmartConversationsEventDto.json") + String jsonSmartConversationsEvent; + + @GivenTextResource( + "domains/conversation/v1/sinchevents/unsupported/UnsupportedCallbackEventDto.json") + String jsonUnsupportedCallbackEvent; + + @BeforeEach + public void setUp() { + // Get a service without any parameters to ensure webhooks callback + // service can be used without them nor any performing any HTTP calls. + serverService = new SinchClient().conversation().v1().sinchEvents(); + } + + @Test + void checkApplicationAuthentication() throws ApiException { + + Map headers = + Stream.of( + new AbstractMap.SimpleEntry<>( + HmacAuthenticationValidation.SIGNATURE_HEADER, + "6bpJoRmFoXVjfJIVglMoJzYXxnoxRujzR4k2GOXewOE="), + new AbstractMap.SimpleEntry<>( + HmacAuthenticationValidation.ALGORITHM_HEADER, "HmacSHA256"), + new AbstractMap.SimpleEntry<>( + HmacAuthenticationValidation.NONCE_HEADER, "01FJA8B4A7BM43YGWSG9GBV067"), + new AbstractMap.SimpleEntry<>( + HmacAuthenticationValidation.TIMESTAMP_HEADER, "1634579353")) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + boolean authenticationResult = + serverService.validateAuthenticationHeader( + "foo_secret1234", + headers, + "{\"app_id\":\"\",\"accepted_time\":\"2021-10-18T17:49:13.813615Z\",\"project_id\":\"e2df3a34-a71b-4448-9db5-a8d2baad28e4\",\"contact_create_notification\":{\"contact\":{\"id\":\"01FJA8B466Y0R2GNXD78MD9SM1\",\"channel_identities\":[{\"channel\":\"SMS\",\"identity\":\"48123456789\",\"app_id\":\"\"}],\"display_name\":\"New" + + " Test" + + " Contact\",\"email\":\"new.contact@email.com\",\"external_id\":\"\",\"metadata\":\"\",\"language\":\"EN_US\"}},\"message_metadata\":\"\"}"); + + assertTrue(authenticationResult); + } + + @Test + void checkParsedCapabilityEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonCapabilityEvent) instanceof CapabilityEvent); + } + + @Test + void checkParsedChannelEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonChannelEvent) instanceof ChannelEvent); + } + + @Test + void checkParsedContactCreateEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonContactCreateEvent) instanceof ContactCreateEvent); + } + + @Test + void checkParsedContactDeleteEventEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonContactDeleteEvent) instanceof ContactDeleteEvent); + } + + @Test + void checkParsedContactIdentitiesDuplicationEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonContactIdentitiesDuplicationEvent) + instanceof ContactIdentitiesDuplicationEvent); + } + + @Test + void checkParsedContactMergeEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonContactMergeEvent) instanceof ContactMergeEvent); + } + + @Test + void checkParsedContactUpdateEventEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonContactUpdateEvent) instanceof ContactUpdateEvent); + } + + @Test + void checkParsedConversationDeleteEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonConversationDeleteEvent) instanceof ConversationDeleteEvent); + } + + @Test + void checkParsedConversationStartEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonConversationStartEvent) instanceof ConversationStartEvent); + } + + @Test + void checkParsedConversationStopEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonConversationStopEvent) instanceof ConversationStopEvent); + } + + @Test + void checkParsedEventDeliveryReportDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonEventDeliveryReport) instanceof EventDeliveryReceiptEvent); + } + + @Test + void checkParsedMessageDeliveryReceiptEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonMessageDeliveryReceiptEvent) + instanceof MessageDeliveryReceiptEvent); + } + + @Test + void checkParsedInboundEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonInboundEvent) instanceof InboundEvent); + } + + @Test + void checkMessageInboundEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonMessageInboundEvent) instanceof MessageInboundEvent); + } + + @Test + void checkMessageSubmitEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonMessageSubmitEvent) instanceof MessageSubmitEvent); + } + + @Test + void checkOptInEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonOptInEvent) instanceof OptInEvent); + } + + @Test + void checkOptOutEventDto() throws ApiException { + assertTrue(serverService.parseEvent(jsonOptOutEvent) instanceof OptOutEvent); + } + + @Test + void checkRecordNotificationEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonRecordNotificationEvent) instanceof RecordNotificationEvent); + } + + @Test + void checkMessageInboundSmartConversationRedactionEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonMessageInboundSmartConversationRedactionEvent) + instanceof MessageInboundSmartConversationRedactionEvent); + } + + @Test + void checkSmartConversationsEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonSmartConversationsEvent) instanceof SmartConversationsEvent); + } + + @Test + void checkUnsupportedCallbackEventDto() throws ApiException { + assertTrue( + serverService.parseEvent(jsonUnsupportedCallbackEvent) instanceof UnsupportedCallbackEvent); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingServiceTest.java index f3abc7ced..534e66992 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/TranscodingServiceTest.java @@ -1,54 +1,85 @@ package com.sinch.sdk.domains.conversation.api.v1.adapters; +import static org.mockito.ArgumentMatchers.argThat; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.core.TestHelpers; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.core.http.AuthManager; import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.TranscodingApi; +import com.sinch.sdk.core.http.HttpContentType; +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.HttpRequestTest.HttpRequestMatcher; +import com.sinch.sdk.core.http.HttpResponse; +import com.sinch.sdk.core.models.ServerConfiguration; +import com.sinch.sdk.domains.conversation.api.v1.TranscodingService; import com.sinch.sdk.domains.conversation.models.v1.transcoding.request.TranscodeMessageRequestDtoTest; import com.sinch.sdk.domains.conversation.models.v1.transcoding.response.TranscodeMessageResponse; import com.sinch.sdk.domains.conversation.models.v1.transcoding.response.TranscodeMessageResponseDtoTest; -import com.sinch.sdk.models.ConversationContext; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; import java.util.Map; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; @TestWithResources public class TranscodingServiceTest extends ConversationBaseTest { - - @Mock ConversationContext context; - @Mock TranscodingApi api; + @Mock ServerConfiguration serverConfiguration; @Mock HttpClient httpClient; @Mock Map authManagers; - TranscodingService service; String uriPartID = "foovalue"; + static final Collection AUTH_NAMES = Arrays.asList("Basic", "oAuth2"); + + @GivenTextResource("/domains/conversation/v1/transcoding/request/TranscodeMessageRequestDto.json") + String jsonTranscodeMessageRequestDto; + + @GivenTextResource( + "domains/conversation/v1/transcoding/response/TranscodeMessageResponseDto.json") + String jsonTranscodeMessageResponseDto; + @BeforeEach public void initMocks() { - service = spy(new TranscodingService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); + service = + new TranscodingServiceImpl( + httpClient, serverConfiguration, authManagers, HttpMapper.getInstance(), uriPartID); } @Test void transcode() throws ApiException { - when(api.transcodingTranscodeMessage( - eq(uriPartID), eq(TranscodeMessageRequestDtoTest.transcodeMessageRequestDto))) - .thenReturn(TranscodeMessageResponseDtoTest.expectedTranscodeMessageResponseDto); + HttpRequest httpRequest = + new HttpRequest( + String.format("/v1/projects/%s/messages:transcode", uriPartID), + HttpMethod.POST, + Collections.emptyList(), + jsonTranscodeMessageRequestDto, + Collections.emptyMap(), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + Collections.singletonList(HttpContentType.APPLICATION_JSON), + AUTH_NAMES); + HttpResponse httpResponse = + new HttpResponse( + 200, null, Collections.emptyMap(), jsonTranscodeMessageResponseDto.getBytes()); + + when(httpClient.invokeAPI( + eq(serverConfiguration), + eq(authManagers), + argThat(new HttpRequestMatcher(httpRequest)))) + .thenReturn(httpResponse); TranscodeMessageResponse response = service.transcodeMessage(TranscodeMessageRequestDtoTest.transcodeMessageRequestDto); - Assertions.assertThat(response) - .usingRecursiveComparison() - .isEqualTo(TranscodeMessageResponseDtoTest.expectedTranscodeMessageResponseDto); + TestHelpers.recursiveEquals( + response, TranscodeMessageResponseDtoTest.expectedTranscodeMessageResponseDto); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorServiceTest.java deleted file mode 100644 index 7f0d824b2..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksAdaptorServiceTest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import com.adelean.inject.resources.junit.jupiter.GivenTextResource; -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.models.ConversationContext; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -@TestWithResources -public class WebHooksAdaptorServiceTest extends ConversationBaseTest { - - @GivenTextResource("domains/conversation/v1/webhooks/events/capability/CapabilityEventDto.json") - String jsonCapabilityEvent; - - WebHooksAdaptorService service; - - @Mock WebHooksApiService api; - @Mock ConversationContext context; - @Mock Runnable credentialValidation; - @Mock Supplier httpClient; - @Mock Supplier> authManagers; - - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = - spy( - new WebHooksAdaptorService( - uriPartID, context, credentialValidation, httpClient, authManagers)); - } - - @Test - void list() throws ApiException { - doReturn(api).when(service).getApiService(); - - service.list("foo"); - - verify(credentialValidation, times(1)).run(); - } - - @Test - void get() throws ApiException { - doReturn(api).when(service).getApiService(); - - service.get("foo"); - - verify(credentialValidation, times(1)).run(); - } - - @Test - void create() throws ApiException { - doReturn(api).when(service).getApiService(); - - service.create(Webhook.builder().build()); - - verify(credentialValidation, times(1)).run(); - } - - @Test - void update() throws ApiException { - doReturn(api).when(service).getApiService(); - - service.update("foo", Webhook.builder().build()); - - verify(credentialValidation, times(1)).run(); - } - - @Test - void delete() throws ApiException { - doReturn(api).when(service).getApiService(); - - service.delete("foo"); - - verify(credentialValidation, times(1)).run(); - } - - @Test - void validateAuthenticationHeader() throws ApiException { - - service.validateAuthenticationHeader("", new HashMap<>(), ""); - - verify(credentialValidation, times(0)).run(); - } - - @Test - void parseEvent() throws ApiException { - - service.parseEvent(jsonCapabilityEvent); - - verify(credentialValidation, times(0)).run(); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiServiceTest.java deleted file mode 100644 index bcdc48cd6..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksApiServiceTest.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.domains.conversation.api.v1.internal.WebhooksApi; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.ClientCredentialsDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.Webhook; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.WebhookDtoTest; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.WebhookImpl; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.WebhookTargetType; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.WebhookTrigger; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.internal.CreateWebhookRequestInternal; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.response.ListWebhookResponseDtoTest; -import com.sinch.sdk.models.ConversationContext; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.ArgumentCaptor; -import org.mockito.Captor; -import org.mockito.Mock; - -@TestWithResources -public class WebHooksApiServiceTest extends ConversationBaseTest { - @Mock ConversationContext context; - @Mock WebhooksApi api; - @Mock HttpClient httpClient; - @Mock Map authManagers; - - @Captor ArgumentCaptor uriPartIDCaptor; - @Captor ArgumentCaptor idCaptor; - @Captor ArgumentCaptor webhookCaptor; - @Captor ArgumentCaptor webhookCreateRequestCaptor; - - @Captor ArgumentCaptor> maskCaptor; - - WebHooksApiService service; - String uriPartID = "foovalue"; - - @BeforeEach - public void initMocks() { - service = spy(new WebHooksApiService(uriPartID, context, httpClient, authManagers)); - doReturn(api).when(service).getApi(); - } - - @Test - void list() throws ApiException { - when(api.webhooksListWebhooks( - eq(uriPartID), - eq(ListWebhookResponseDtoTest.expectedRequestDto.getWebhooks().get(0).getAppId()))) - .thenReturn(ListWebhookResponseDtoTest.expectedResponseDto); - - Collection response = - service.list(ListWebhookResponseDtoTest.expectedRequestDto.getWebhooks().get(0).getAppId()); - - TestHelpers.recursiveEquals( - response, ListWebhookResponseDtoTest.expectedResponseDto.getWebhooks()); - } - - @Test - void get() throws ApiException { - when(api.webhooksGetWebhook(eq(uriPartID), eq(WebhookDtoTest.expectedRequestDto.getId()))) - .thenReturn(WebhookDtoTest.expectedRequestDto); - - Webhook response = service.get(WebhookDtoTest.expectedRequestDto.getId()); - - TestHelpers.recursiveEquals(response, WebhookDtoTest.expectedRequestDto); - } - - @Test - void create() throws ApiException { - - when(api.webhooksCreateWebhook(eq(uriPartID), any(CreateWebhookRequestInternal.class))) - .thenReturn(WebhookDtoTest.expectedRequestDto); - - Webhook response = service.create(WebhookDtoTest.expectedRequestDto); - - verify(api) - .webhooksCreateWebhook(uriPartIDCaptor.capture(), webhookCreateRequestCaptor.capture()); - - WebhookImpl webhook = (WebhookImpl) WebhookDtoTest.expectedRequestDto; - CreateWebhookRequestInternal.Builder builder = CreateWebhookRequestInternal.builder(); - webhook.appId().ifPresent(builder::setAppId); - webhook.clientCredentials().ifPresent(builder::setClientCredentials); - webhook.secret().ifPresent(builder::setSecret); - webhook.target().ifPresent(builder::setTarget); - webhook.targetType().ifPresent(builder::setTargetType); - webhook.triggers().ifPresent(builder::setTriggers); - - Assertions.assertThat(uriPartIDCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(webhookCreateRequestCaptor.getValue()).isEqualTo(builder.build()); - - TestHelpers.recursiveEquals(response, WebhookDtoTest.expectedRequestDto); - } - - @Test - void update() throws ApiException { - Webhook update = - Webhook.builder() - .setAppId("my app id") - .setTarget("my target") - .setTriggers(Arrays.asList(WebhookTrigger.from("my trigger"))) - .setClientCredentials(ClientCredentialsDtoTest.expectedDto) - .setTargetType(WebhookTargetType.HTTP) - .build(); - - List mask = - new ArrayList<>( - Arrays.asList( - WebhookImpl.JSON_PROPERTY_APP_ID, - WebhookImpl.JSON_PROPERTY_CLIENT_CREDENTIALS, - WebhookImpl.JSON_PROPERTY_TARGET, - WebhookImpl.JSON_PROPERTY_TARGET_TYPE, - WebhookImpl.JSON_PROPERTY_TRIGGERS)); - - when(api.webhooksUpdateWebhook( - eq(uriPartID), - eq(WebhookDtoTest.expectedRequestDto.getId()), - eq(update), - any(List.class))) - .thenReturn(WebhookDtoTest.expectedRequestDto); - - Webhook response = service.update(WebhookDtoTest.expectedRequestDto.getId(), update); - - verify(api) - .webhooksUpdateWebhook( - uriPartIDCaptor.capture(), - idCaptor.capture(), - webhookCaptor.capture(), - maskCaptor.capture()); - - TestHelpers.recursiveEquals(maskCaptor.getValue(), mask); - - TestHelpers.recursiveEquals(response, WebhookDtoTest.expectedRequestDto); - } - - @Test - void delete() throws ApiException { - - service.delete(WebhookDtoTest.expectedRequestDto.getId()); - - verify(api).webhooksDeleteWebhook(uriPartIDCaptor.capture(), idCaptor.capture()); - - Assertions.assertThat(uriPartIDCaptor.getValue()).isEqualTo(uriPartID); - Assertions.assertThat(idCaptor.getValue()).isEqualTo(WebhookDtoTest.expectedRequestDto.getId()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackServiceTest.java deleted file mode 100644 index ac1b7ceef..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/api/v1/adapters/WebHooksCallbackServiceTest.java +++ /dev/null @@ -1,265 +0,0 @@ -package com.sinch.sdk.domains.conversation.api.v1.adapters; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.adelean.inject.resources.junit.jupiter.GivenTextResource; -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.SinchClient; -import com.sinch.sdk.auth.HmacAuthenticationValidation; -import com.sinch.sdk.core.exceptions.ApiException; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.capability.CapabilityEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.channel.ChannelEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact.ContactCreateEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact.ContactDeleteEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact.ContactIdentitiesDuplicationEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact.ContactMergeEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.contact.ContactUpdateEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.conversation.ConversationDeleteEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.conversation.ConversationStartEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.conversation.ConversationStopEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.delivery.EventDeliveryReceiptEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.delivery.MessageDeliveryReceiptEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.inbound.InboundEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message.MessageInboundEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.message.MessageSubmitEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.opting.OptInEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.opting.OptOutEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.record.RecordNotificationEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.smartconversations.MessageInboundSmartConversationRedactionEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.smartconversations.SmartConversationsEvent; -import com.sinch.sdk.domains.conversation.models.v1.webhooks.events.unsupported.UnsupportedCallbackEvent; -import java.util.AbstractMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - -@TestWithResources -public class WebHooksCallbackServiceTest extends ConversationBaseTest { - - com.sinch.sdk.domains.conversation.api.v1.WebHooksService serverService; - - @GivenTextResource("domains/conversation/v1/webhooks/events/capability/CapabilityEventDto.json") - String jsonCapabilityEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/channel/ChannelEventDto.json") - String jsonChannelEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/contact/ContactCreateEventDto.json") - String jsonContactCreateEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/contact/ContactDeleteEventDto.json") - String jsonContactDeleteEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/contact/ContactIdentitiesDuplicationEventDto.json") - String jsonContactIdentitiesDuplicationEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/contact/ContactMergeEventDto.json") - String jsonContactMergeEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/contact/ContactUpdateEventDto.json") - String jsonContactUpdateEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/conversation/ConversationDeleteEventDto.json") - String jsonConversationDeleteEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/conversation/ConversationStartEventDto.json") - String jsonConversationStartEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/conversation/ConversationStopEventDto.json") - String jsonConversationStopEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/delivery/EventDeliveryReceiptEventDto.json") - String jsonEventDeliveryReport; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/delivery/MessageDeliveryReceiptEventDto.json") - String jsonMessageDeliveryReceiptEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/inbound/InboundContactEventDto.json") - String jsonInboundEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/message/MessageInboundEventDto.json") - String jsonMessageInboundEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/message/MessageSubmitEventDto.json") - String jsonMessageSubmitEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/opting/OptInEventDto.json") - String jsonOptInEvent; - - @GivenTextResource("domains/conversation/v1/webhooks/events/opting/OptOutEventDto.json") - String jsonOptOutEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/record/RecordNotificationEventDto.json") - String jsonRecordNotificationEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/smartconversations/MessageInboundSmartConversationRedactionEventDto.json") - String jsonMessageInboundSmartConversationRedactionEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/smartconversations/SmartConversationsEventDto.json") - String jsonSmartConversationsEvent; - - @GivenTextResource( - "domains/conversation/v1/webhooks/events/unsupported/UnsupportedCallbackEventDto.json") - String jsonUnsupportedCallbackEvent; - - @Test - void checkApplicationAuthentication() throws ApiException { - - Map headers = - Stream.of( - new AbstractMap.SimpleEntry<>( - HmacAuthenticationValidation.SIGNATURE_HEADER, - "6bpJoRmFoXVjfJIVglMoJzYXxnoxRujzR4k2GOXewOE="), - new AbstractMap.SimpleEntry<>( - HmacAuthenticationValidation.ALGORITHM_HEADER, "HmacSHA256"), - new AbstractMap.SimpleEntry<>( - HmacAuthenticationValidation.NONCE_HEADER, "01FJA8B4A7BM43YGWSG9GBV067"), - new AbstractMap.SimpleEntry<>( - HmacAuthenticationValidation.TIMESTAMP_HEADER, "1634579353")) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - boolean authenticationResult = - serverService.validateAuthenticationHeader( - "foo_secret1234", - headers, - "{\"app_id\":\"\",\"accepted_time\":\"2021-10-18T17:49:13.813615Z\",\"project_id\":\"e2df3a34-a71b-4448-9db5-a8d2baad28e4\",\"contact_create_notification\":{\"contact\":{\"id\":\"01FJA8B466Y0R2GNXD78MD9SM1\",\"channel_identities\":[{\"channel\":\"SMS\",\"identity\":\"48123456789\",\"app_id\":\"\"}],\"display_name\":\"New" - + " Test" - + " Contact\",\"email\":\"new.contact@email.com\",\"external_id\":\"\",\"metadata\":\"\",\"language\":\"EN_US\"}},\"message_metadata\":\"\"}"); - - assertTrue(authenticationResult); - } - - @Test - void checkParsedCapabilityEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonCapabilityEvent) instanceof CapabilityEvent); - } - - @Test - void checkParsedChannelEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonChannelEvent) instanceof ChannelEvent); - } - - @Test - void checkParsedContactCreateEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonContactCreateEvent) instanceof ContactCreateEvent); - } - - @Test - void checkParsedContactDeleteEventEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonContactDeleteEvent) instanceof ContactDeleteEvent); - } - - @Test - void checkParsedContactIdentitiesDuplicationEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonContactIdentitiesDuplicationEvent) - instanceof ContactIdentitiesDuplicationEvent); - } - - @Test - void checkParsedContactMergeEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonContactMergeEvent) instanceof ContactMergeEvent); - } - - @Test - void checkParsedContactUpdateEventEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonContactUpdateEvent) instanceof ContactUpdateEvent); - } - - @Test - void checkParsedConversationDeleteEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonConversationDeleteEvent) instanceof ConversationDeleteEvent); - } - - @Test - void checkParsedConversationStartEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonConversationStartEvent) instanceof ConversationStartEvent); - } - - @Test - void checkParsedConversationStopEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonConversationStopEvent) instanceof ConversationStopEvent); - } - - @Test - void checkParsedEventDeliveryReportDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonEventDeliveryReport) instanceof EventDeliveryReceiptEvent); - } - - @Test - void checkParsedMessageDeliveryReceiptEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonMessageDeliveryReceiptEvent) - instanceof MessageDeliveryReceiptEvent); - } - - @Test - void checkParsedInboundEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonInboundEvent) instanceof InboundEvent); - } - - @Test - void checkMessageInboundEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonMessageInboundEvent) instanceof MessageInboundEvent); - } - - @Test - void checkMessageSubmitEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonMessageSubmitEvent) instanceof MessageSubmitEvent); - } - - @Test - void checkOptInEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonOptInEvent) instanceof OptInEvent); - } - - @Test - void checkOptOutEventDto() throws ApiException { - assertTrue(serverService.parseEvent(jsonOptOutEvent) instanceof OptOutEvent); - } - - @Test - void checkRecordNotificationEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonRecordNotificationEvent) instanceof RecordNotificationEvent); - } - - @Test - void checkMessageInboundSmartConversationRedactionEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonMessageInboundSmartConversationRedactionEvent) - instanceof MessageInboundSmartConversationRedactionEvent); - } - - @Test - void checkSmartConversationsEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonSmartConversationsEvent) instanceof SmartConversationsEvent); - } - - @Test - void checkUnsupportedCallbackEventDto() throws ApiException { - assertTrue( - serverService.parseEvent(jsonUnsupportedCallbackEvent) instanceof UnsupportedCallbackEvent); - } - - @BeforeEach - public void setUp() { - serverService = new SinchClient().conversation().v1().webhooks(); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactoryTest.java b/client/src/test/java/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactoryTest.java index 451a3ba51..073add9c7 100644 --- a/client/src/test/java/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactoryTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/conversation/models/v1/credentials/ConversationChannelCredentialsBuilderFactoryTest.java @@ -108,16 +108,6 @@ void telegram() { TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials); } - @Test - void viber() { - StaticTokenCredentials credentials = StaticTokenCredentials.builder().build(); - ConversationChannelCredentials conversationChannelCredentials = - ConversationChannelCredentialsBuilderFactory.viber(credentials).build(); - - assertEquals(conversationChannelCredentials.getChannel(), ConversationChannel.VIBER); - TestHelpers.recursiveEquals(conversationChannelCredentials.getCredentials(), credentials); - } - @Test void viberBm() { StaticBearerCredentials credentials = StaticBearerCredentials.builder().build(); diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializerTest.java deleted file mode 100644 index 28fffd495..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/BooleanFormSerializerTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import java.util.HashMap; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class BooleanFormSerializerTest { - BooleanFormSerializer serializer = new BooleanFormSerializer(); - - @Test - void serializeTrue() { - - HashMap map = new HashMap<>(); - - serializer.serialize(true, "key name", map); - - TestHelpers.recursiveEquals("true", map.get("key name")); - } - - @Test - void serializeFalse() { - - HashMap map = new HashMap<>(); - - serializer.serialize(false, "key name", map); - - TestHelpers.recursiveEquals("false", map.get("key name")); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, "key name", map); - - Assertions.assertNull(map.get("key name")); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializerTest.java deleted file mode 100644 index c9a6d6e95..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomHeadersFormSerializerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.utils.Pair; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class CustomHeadersFormSerializerTest { - CustomHeadersFormSerializer serializer = new CustomHeadersFormSerializer(); - - @Test - void serialize() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList( - Pair.of("my-header-key1", "a-header-value1"), - Pair.of("my-header-key1", "a-header-value2"), - Pair.of("my-header-key2", "a-header-value3")), - null, - map); - - Map expected = - Stream.of( - new AbstractMap.SimpleEntry<>( - "h:my-header-key1", Arrays.asList("a-header-value1", "a-header-value2")), - new AbstractMap.SimpleEntry<>("h:my-header-key2", Arrays.asList("a-header-value3"))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, null, map); - - Assertions.assertTrue(map.isEmpty()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializerTest.java deleted file mode 100644 index 1fc30b9db..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/CustomVariablesFormSerializerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.utils.Pair; -import java.util.AbstractMap; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class CustomVariablesFormSerializerTest { - CustomVariablesFormSerializer serializer = new CustomVariablesFormSerializer(); - - @Test - void serialize() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList( - Pair.of("my-var-key1", "a-var-value1"), - Pair.of("my-var-key1", "a-var-value2"), - Pair.of("my-var-key2", "a-var-value3")), - null, - map); - - Map expected = - Stream.of( - new AbstractMap.SimpleEntry<>( - "v:my-var-key1", Arrays.asList("a-var-value1", "a-var-value2")), - new AbstractMap.SimpleEntry<>("v:my-var-key2", Arrays.asList("a-var-value3"))) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, null, map); - - Assertions.assertTrue(map.isEmpty()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializerTest.java deleted file mode 100644 index f3ee48b15..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/DeliveryTimeFormSerializerTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import java.util.HashMap; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class DeliveryTimeFormSerializerTest { - - DeliveryTimeFormSerializer serializer = new DeliveryTimeFormSerializer(); - - @Test - void serialize() { - - HashMap map = new HashMap<>(); - - serializer.serialize(10, "key name", map); - - TestHelpers.recursiveEquals("10h", map.get("key name")); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, "key name", map); - - Assertions.assertNull(map.get("key name")); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/EmailsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/EmailsServiceTest.java deleted file mode 100644 index 46cd8513e..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/EmailsServiceTest.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import static org.mockito.ArgumentMatchers.argThat; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.when; - -import com.adelean.inject.resources.junit.jupiter.GivenTextResource; -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.BaseTest; -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.http.AuthManager; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.core.http.HttpContentType; -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.HttpRequestTest.HttpRequestMatcher; -import com.sinch.sdk.core.http.HttpResponse; -import com.sinch.sdk.core.http.URLPathUtils; -import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.core.models.ServerConfigurationTest.ServerConfigurationMatcher; -import com.sinch.sdk.domains.mailgun.api.v1.EmailsService; -import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendEmailRequestTest; -import com.sinch.sdk.domains.mailgun.models.v1.emails.request.SendMimeEmailRequestTest; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.GetStoredEmailResponse; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.GetStoredEmailResponseTest; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendEmailResponse; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendEmailResponseTest; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendingQueuesStatusResponse; -import com.sinch.sdk.domains.mailgun.models.v1.emails.response.SendingQueuesStatusResponseTest; -import java.util.Collections; -import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -@TestWithResources -class EmailsServiceTest extends BaseTest { - - static final String AUTH_NAME = "basicAuth"; - - @GivenTextResource("/domains/mailgun/v1/emails/response/GetStoredEmailResponseDto.json") - String jsonGetEmailResponseDto; - - @GivenTextResource("/domains/mailgun/v1/emails/response/SendingQueuesStatusResponseDto.json") - String jsonSendingQueuesStatusResponseDto; - - @GivenTextResource("/domains/mailgun/v1/emails/response/SendEmailResponseDto.json") - String jsonSendEmailResponseDto; - - @Mock ServerConfiguration serverConfiguration; - @Mock HttpClient httpClient; - @Mock Map authManagers; - - EmailsService service; - - String domainName = "foo Domain"; - String storageKey = "foo StorageKey"; - - @BeforeEach - public void initMocks() { - service = - new EmailsServiceImpl( - httpClient, serverConfiguration, authManagers, HttpMapper.getInstance()); - } - - @Test - void send() { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/" + URLPathUtils.encodePathSegment(domainName) + "/messages", - HttpMethod.POST, - Collections.emptyList(), - SendEmailRequestTest.expectedEmailHtmlInline, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.singletonList(HttpContentType.MULTIPART_FORM_DATA), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse(200, null, Collections.emptyMap(), jsonSendEmailResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - SendEmailResponse response = - service.sendEmail(domainName, SendEmailRequestTest.sendEmailHtmlInlineRequest); - - TestHelpers.recursiveEquals(response, SendEmailResponseTest.expectedSendEmailResponse); - } - - @Test - void sendMime() { - HttpRequest httpRequest = - new HttpRequest( - "/v3/" + URLPathUtils.encodePathSegment(domainName) + "/messages.mime", - HttpMethod.POST, - Collections.emptyList(), - SendMimeEmailRequestTest.expected, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.singletonList(HttpContentType.MULTIPART_FORM_DATA), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse(200, null, Collections.emptyMap(), jsonSendEmailResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - SendEmailResponse response = - service.sendMimeEmail(domainName, SendMimeEmailRequestTest.sendMimEmailRequest); - - TestHelpers.recursiveEquals(response, SendEmailResponseTest.expectedSendEmailResponse); - } - - @Test - void get() { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/domains/" - + URLPathUtils.encodePathSegment(domainName) - + "/messages/foo%20StorageKey", - HttpMethod.GET, - Collections.emptyList(), - (Map) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse(200, null, Collections.emptyMap(), jsonGetEmailResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - GetStoredEmailResponse response = service.getStoredEmail(domainName, storageKey); - - TestHelpers.recursiveEquals(response, GetStoredEmailResponseTest.expectedGetEmailResponse); - } - - @Test - void getSendingQueuesStatus() { - HttpRequest httpRequest = - new HttpRequest( - "/v3/domains/" + URLPathUtils.encodePathSegment(domainName) + "/sending_queues", - HttpMethod.GET, - Collections.emptyList(), - (Map) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonSendingQueuesStatusResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - SendingQueuesStatusResponse response = service.getSendingQueuesStatus(domainName); - - TestHelpers.recursiveEquals( - response, SendingQueuesStatusResponseTest.expectedSendingQueuesStatusResponse); - } - - @Test - void purgeSendingQueue() { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/" + URLPathUtils.encodePathSegment(domainName) + "/envelopes", - HttpMethod.DELETE, - Collections.emptyList(), - (String) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = new HttpResponse(200, null, Collections.emptyMap(), null); - - when(httpClient.invokeAPI( - argThat(new ServerConfigurationMatcher(new ServerConfiguration("my foo URL"))), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - service.purgeSendingQueue(domainName, "my foo URL"); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializerTest.java deleted file mode 100644 index f7173e851..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/ListOfPairFormSerializerTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.utils.Pair; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class ListOfPairFormSerializerTest { - ListOfPairFormSerializer serializer = new ListOfPairFormSerializer(); - - @Test - void serialize() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList(Pair.of("key1", 12345), Pair.of("key2", 789)), "field_name", map); - - Map expected = - new HashMap<>(Collections.singletonMap("field_name", "{\"key1\":12345,\"key2\":789}")); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeLong() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList(Pair.of("key1", 12345678901L), Pair.of("key2", 10234567891L)), - "field_name", - map); - - Map expected = - new HashMap<>( - Collections.singletonMap("field_name", "{\"key1\":12345678901,\"key2\":10234567891}")); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeDouble() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList(Pair.of("key1", 0.12345678901d), Pair.of("key2", 0.0123456789d)), - "field_name", - map); - - Map expected = - new HashMap<>( - Collections.singletonMap( - "field_name", "{\"key1\":0.12345678901,\"key2\":0.0123456789}")); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeFloat() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList(Pair.of("key1", 0.123456), Pair.of("key2", 0.012345)), "field_name", map); - - Map expected = - new HashMap<>( - Collections.singletonMap("field_name", "{\"key1\":0.123456,\"key2\":0.012345}")); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeBoolean() { - - HashMap map = new HashMap<>(); - - serializer.serialize( - Arrays.asList(Pair.of("key1", true), Pair.of("key2", false)), "field_name", map); - - Map expected = - new HashMap<>(Collections.singletonMap("field_name", "{\"key1\":true,\"key2\":false}")); - - TestHelpers.recursiveEquals(expected, map); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, "field_name", map); - - Assertions.assertEquals(map.keySet().size(), 1); - Assertions.assertNull(map.get("field_name")); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunServiceTest.java deleted file mode 100644 index 77b324d73..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MailgunServiceTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import static org.junit.jupiter.api.Assertions.*; - -import com.sinch.sdk.LogRecorder; -import com.sinch.sdk.core.http.HttpClient; -import com.sinch.sdk.models.MailgunContext; -import com.sinch.sdk.models.MailgunCredentials; -import com.sinch.sdk.models.MailgunRegion; -import java.util.Optional; -import java.util.logging.Level; -import java.util.logging.LogManager; -import java.util.logging.LogRecord; -import java.util.logging.Logger; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -class MailgunServiceTest { - @Mock HttpClient httpClient; - - @Test - void doNotAcceptNullKey() { - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey(null).build(); - MailgunContext context = MailgunContext.builder().build(); - Exception exception = - assertThrows( - IllegalArgumentException.class, - () -> new MailgunService(credentials, context, httpClient)); - assertTrue(exception.getMessage().contains("apiKey")); - } - - @Test - void doNotAcceptNullContext() { - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - Exception exception = - assertThrows( - NullPointerException.class, () -> new MailgunService(credentials, null, httpClient)); - assertTrue(exception.getMessage().contains("Mailgun service requires context to be defined")); - } - - @Test - void doNotAcceptEmptyURL() { - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - MailgunContext context = MailgunContext.builder().setUrl("").build(); - Exception exception = - assertThrows( - IllegalArgumentException.class, - () -> new MailgunService(credentials, context, httpClient)); - assertTrue(exception.getMessage().contains("Mailgun service requires 'url' to be defined")); - } - - @Test - void doNotAcceptNullURL() { - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - MailgunContext context = MailgunContext.builder().build(); - Exception exception = - assertThrows( - IllegalArgumentException.class, - () -> new MailgunService(credentials, context, httpClient)); - assertTrue(exception.getMessage().contains("Mailgun service requires 'url' to be defined")); - } - - @Test - void passInit() { - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - MailgunContext context = MailgunContext.builder().setUrl("foo").build(); - assertDoesNotThrow(() -> new MailgunService(credentials, context, httpClient), "Init passed"); - } - - @Test - void defaultRegionWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - MailgunContext context = - MailgunContext.builder() - .setUrl("foo value") - .setRegion(MailgunRegion.US) - .setRegionAsDefault(true) - .build(); - - new MailgunService(credentials, context, httpClient); - - Optional record = - logRecorder.records.stream() - .filter(r -> r.getMessage().contains("Using default region for Mailgun 'us")) - .findFirst(); - - assertTrue(record.isPresent()); - assertEquals(record.get().getLevel(), Level.WARNING); - LogManager.getLogManager().reset(); - } - - @Test - void regionNoWarning() { - - LogRecorder logRecorder = new LogRecorder(); - LogManager.getLogManager().reset(); - Logger rootLogger = LogManager.getLogManager().getLogger(""); - rootLogger.addHandler(logRecorder); - - MailgunCredentials credentials = MailgunCredentials.builder().setApiKey("foo").build(); - - MailgunContext context = - MailgunContext.builder() - .setUrl("foo value") - .setRegion(MailgunRegion.EUROPE) - .setRegionAsDefault(false) - .build(); - new MailgunService(credentials, context, httpClient); - - Optional record = - logRecorder.records.stream() - .filter(r -> r.getMessage().contains("Using default region for Mailgun 'us")) - .findFirst(); - - assertFalse(record.isPresent()); - LogManager.getLogManager().reset(); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelperTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelperTest.java deleted file mode 100644 index edf0f0b01..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapOfPairsToJSONHelperTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.utils.Pair; -import java.util.Collections; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class MapOfPairsToJSONHelperTest { - - @Test - void serialize() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonList(Pair.of("variable1", "value1")))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":\"value1\"}}"; - - Assertions.assertEquals(expected, serialized); - } - - @Test - void serializeInteger() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonList(Pair.of("variable1", 123)))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":123}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeLong() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", - Collections.singletonList(Pair.of("variable1", 12345678901L)))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":12345678901}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeDouble() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", - Collections.singletonList(Pair.of("variable1", 0.12345678901d)))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":0.12345678901}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeFloat() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonList(Pair.of("variable1", 0.123456)))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":0.123456}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeBoolean() { - - String serialized = - MapOfPairsToJSONHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonList(Pair.of("variable1", true)))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":true}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeNull() { - - Assertions.assertNull(MapOfPairsToJSONHelper.serialize(null)); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelperTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelperTest.java deleted file mode 100644 index 11005c0d4..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/MapToJSONStringHelperTest.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.TestHelpers; -import java.util.Arrays; -import java.util.Collections; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class MapToJSONStringHelperTest { - - @Test - void serialize() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "level1", - Collections.singletonMap("level2", Collections.singletonMap("level3", "value")))); - - String expected = "{\"level1\":{\"level2\":{\"level3\":\"value\"}}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeInteger() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonMap("variable1", 123))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":123}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeLong() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonMap("variable1", 12345678901L))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":12345678901}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeDouble() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonMap("variable1", 0.12345678901d))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":0.12345678901}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeFloat() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonMap("variable1", 0.123456))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":0.123456}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeBoolean() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", Collections.singletonMap("variable1", true))); - - String expected = "{\"cc-dest@sinch.com\":{\"variable1\":true}}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeArray() { - - String serialized = - MapToJSONStringHelper.serialize( - Collections.singletonMap( - "cc-dest@sinch.com", - Arrays.asList( - Collections.singletonMap("variable.1", true), - Collections.singletonMap("variable2", "value2")))); - - String expected = "{\"cc-dest@sinch.com\":[{\"variable.1\":true},{\"variable2\":\"value2\"}]}"; - - TestHelpers.recursiveEquals(expected, serialized); - } - - @Test - void serializeNull() { - - Assertions.assertNull(MapToJSONStringHelper.serialize(null)); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializerTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializerTest.java deleted file mode 100644 index 3b03d7d5f..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/NestedFieldFormSerializerTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import com.sinch.sdk.core.databind.multipart.ObjectMapperTest; -import java.util.HashMap; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; - -class NestedFieldFormSerializerTest { - NestedFieldFormSerializer serializer = new NestedFieldFormSerializer(); - - @Test - void serialize() { - - HashMap map = new HashMap<>(); - - serializer.serialize(ObjectMapperTest.object, null, map); - - Assertions.assertFalse(map.isEmpty()); - } - - @Test - void serializeNull() { - - HashMap map = new HashMap<>(); - - serializer.serialize(null, null, map); - - Assertions.assertTrue(map.isEmpty()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/TemplatesServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/TemplatesServiceTest.java deleted file mode 100644 index ba42eeaed..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/mailgun/api/v1/adapters/TemplatesServiceTest.java +++ /dev/null @@ -1,769 +0,0 @@ -package com.sinch.sdk.domains.mailgun.api.v1.adapters; - -import static org.mockito.ArgumentMatchers.argThat; -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.GivenTextResource; -import com.adelean.inject.resources.junit.jupiter.TestWithResources; -import com.sinch.sdk.BaseTest; -import com.sinch.sdk.core.TestHelpers; -import com.sinch.sdk.core.databind.multipart.ObjectMapperTest; -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.HttpContentType; -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.HttpRequestTest.HttpRequestMatcher; -import com.sinch.sdk.core.http.HttpResponse; -import com.sinch.sdk.core.http.URLParameter; -import com.sinch.sdk.core.http.URLParameter.STYLE; -import com.sinch.sdk.core.http.URLPathUtils; -import com.sinch.sdk.core.models.ServerConfiguration; -import com.sinch.sdk.core.utils.Pair; -import com.sinch.sdk.domains.mailgun.api.v1.TemplatesService; -import com.sinch.sdk.domains.mailgun.models.v1.templates.Template; -import com.sinch.sdk.domains.mailgun.models.v1.templates.TemplateImpl; -import com.sinch.sdk.domains.mailgun.models.v1.templates.TemplateTest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.Version; -import com.sinch.sdk.domains.mailgun.models.v1.templates.VersionDetails; -import com.sinch.sdk.domains.mailgun.models.v1.templates.VersionTest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.request.CopyVersionQueryParameters; -import com.sinch.sdk.domains.mailgun.models.v1.templates.request.CreateTemplateRequest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.request.CreateVersionRequest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.request.UpdateTemplateRequest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.request.UpdateVersionRequest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.CopyVersionResponseTest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.CreateTemplateResponseTest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.GetTemplateResponseTest; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.ListTemplatesResponse; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.ListVersionsResponse; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.internal.ListTemplatesResponseInternal; -import com.sinch.sdk.domains.mailgun.models.v1.templates.response.internal.ListVersionResponseInternal; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.mockito.Mock; - -@TestWithResources -class TemplatesServiceTest extends BaseTest { - - static final String AUTH_NAME = "basicAuth"; - - @GivenTextResource("/domains/mailgun/v1/templates/response/GetTemplateResponseDto.json") - String jsonGetTemplateResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/GetTemplateWithActiveResponseDto.json") - String jsonGetTemplateWithActiveResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListTemplatesResponseDtoPage0.json") - String jsonListTemplatesResponseDtoPage0; - - @GivenJsonResource("/domains/mailgun/v1/templates/response/ListTemplatesResponseDtoPage0.json") - ListTemplatesResponseInternal listTemplatesResponseDtoPage0; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListTemplatesResponseDtoPage1.json") - String jsonListTemplatesResponseDtoPage1; - - @GivenJsonResource("/domains/mailgun/v1/templates/response/ListTemplatesResponseDtoPage1.json") - ListTemplatesResponseInternal listTemplatesResponseDtoPage1; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListTemplatesResponseDtoPage2.json") - String jsonListTemplatesResponseDtoPage2; - - @GivenTextResource("/domains/mailgun/v1/templates/response/CreateTemplateResponseDto.json") - String jsonCreateTemplateResponseDto; - - @GivenTextResource( - "/domains/mailgun/v1/templates/response/CreateTemplateWithActiveResponseDto.json") - String jsonCreateTemplateWithActiveResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/DeleteTemplateResponseDto.json") - String jsonDeleteTemplateResponseDto; - - @GivenTextResource("/domains/mailgun/v1/response/GenericResponseDto.json") - String jsonDeleteAllTemplatesResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/UpdateTemplateResponseDto.json") - String jsonUpdateTemplateResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/CreateVersionResponseDto.json") - String jsonCreateVersionResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/UpdateVersionResponseDto.json") - String jsonUpdateVersionResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/GetVersionResponseDto.json") - String jsonGetVersionResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/DeleteVersionResponseDto.json") - String jsonDeleteVersionResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/CopyVersionResponseDto.json") - String jsonCopyVersionResponseDto; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListVersionsResponseDtoPage0.json") - String jsonListVersionsResponseDtoPage0; - - @GivenJsonResource("/domains/mailgun/v1/templates/response/ListVersionsResponseDtoPage0.json") - ListVersionResponseInternal listVersionsResponseDtoPage0; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListVersionsResponseDtoPage1.json") - String jsonListVersionsResponseDtoPage1; - - @GivenJsonResource("/domains/mailgun/v1/templates/response/ListVersionsResponseDtoPage1.json") - ListVersionResponseInternal listVersionsResponseDtoPage1; - - @GivenTextResource("/domains/mailgun/v1/templates/response/ListVersionsResponseDtoPage2.json") - String jsonListVersionsResponseDtoPage2; - - @Mock ServerConfiguration serverConfiguration; - @Mock HttpClient httpClient; - @Mock Map authManagers; - - TemplatesService service; - - String domainName = "foo Domain"; - // template name with path separator by purpose: the / should be encoded properly - String templateName = "template/test"; - String versionName = "version name value"; - - @BeforeEach - public void initMocks() { - service = - new TemplatesServiceImpl( - httpClient, serverConfiguration, authManagers, HttpMapper.getInstance()); - } - - @Test - void get() { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/" - + URLPathUtils.encodePathSegment(domainName) - + "/templates/" - + URLPathUtils.encodePathSegment(templateName), - HttpMethod.GET, - Collections.emptyList(), - (Map) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse(200, null, Collections.emptyMap(), jsonGetTemplateResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - Template response = service.get(domainName, templateName); - - TestHelpers.recursiveEquals(response, GetTemplateResponseTest.expectedTemplate.getTemplate()); - } - - @Test - void getWithActive() { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/" - + URLPathUtils.encodePathSegment(domainName) - + "/templates/" - + URLPathUtils.encodePathSegment(templateName), - HttpMethod.GET, - Arrays.asList(new URLParameter("active", true, STYLE.FORM, true)), - (Map) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonGetTemplateWithActiveResponseDto.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - VersionDetails response = service.getActiveVersion(domainName, templateName); - - TestHelpers.recursiveEquals( - response, - ((TemplateImpl) GetTemplateResponseTest.expectedTemplateWithActive.getTemplate()) - .getVersion()); - } - - @Test - void listDefault() throws ApiException { - - HttpRequest httpRequest = - new HttpRequest( - "/v3/" + URLPathUtils.encodePathSegment(domainName) + "/templates", - HttpMethod.GET, - Collections.emptyList(), - (String) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - HttpResponse httpResponse = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonListTemplatesResponseDtoPage0.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest)))) - .thenReturn(httpResponse); - - ListTemplatesResponse response = service.list(domainName); - - TestHelpers.recursiveEquals(response.getContent(), listTemplatesResponseDtoPage0.getItems()); - } - - @Test - void list() throws ApiException { - - HttpRequest httpRequest0 = - new HttpRequest( - "/v3/" + URLPathUtils.encodePathSegment(domainName) + "/templates", - HttpMethod.GET, - Collections.emptyList(), - (Map) null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - - HttpRequest httpRequest1 = - new HttpRequest( - "https://api.mailgun.net/v3/foo%20Domain.mailgun.org/templates?page=next&p=letter+template+from+dashboard&limit=2", - HttpMethod.GET, - null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - - HttpRequest httpRequest2 = - new HttpRequest( - "https://api.mailgun.net/v3/foo%20Domain.mailgun.org/templates?page=next&p=template.test&limit=2", - HttpMethod.GET, - null, - Collections.emptyMap(), - Collections.singletonList(HttpContentType.APPLICATION_JSON), - Collections.emptyList(), - Collections.singletonList(AUTH_NAME)); - - HttpResponse httpResponse0 = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonListTemplatesResponseDtoPage0.getBytes()); - HttpResponse httpResponse1 = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonListTemplatesResponseDtoPage1.getBytes()); - HttpResponse httpResponse2 = - new HttpResponse( - 200, null, Collections.emptyMap(), jsonListTemplatesResponseDtoPage2.getBytes()); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest0)))) - .thenReturn(httpResponse0); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest1)))) - .thenReturn(httpResponse1); - - when(httpClient.invokeAPI( - eq(serverConfiguration), - eq(authManagers), - argThat(new HttpRequestMatcher(httpRequest2)))) - .thenReturn(httpResponse2); - - ListTemplatesResponse response = service.list(domainName); - - Iterator