Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions MIGRATION-GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,11 @@ Use the new versioned API under `verification().v1()` to get access to [Verifica
| 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().webhooks()](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/WebHooksService.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 | [WebhooksService](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/api/v1/WebhooksService.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
Expand Down Expand Up @@ -461,17 +461,16 @@ Use the new versioned API under `verification().v1()` to get access to [Verifica
| 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.webhooks.VerificationEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationEvent.html) |
| models/webhooks/VerificationRequestEvent | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEvent.html) |
| models/webhooks/VerificationResponse | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponse.html) |
| models/webhooks/VerificationResponseActionType | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEventResponseAction](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationEventResponseAction.html) |
| models/webhooks/VerificationResponseCallout | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponsePhoneCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponsePhoneCall.html) |
| models/webhooks/VerificationResponseCalloutSpeech | [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/webhooks/VerificationResponseFlashCall | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponseFlashCall](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseFlashCall.html) |
| models/webhooks/VerificationResponseSMS | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponseSms](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationRequestEventResponseSms.html) |
| models/webhooks/VerificationResultEvent | [com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationResultEvent](https://www.javadoc.io/doc/com.sinch.sdk/sinch-sdk-java/2.0.0/com/sinch/sdk/domains/verification/models/v1/webhooks/VerificationResultEvent.html) |
| 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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 com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent;
import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse;
import java.util.Map;

/**
* Webhooks service
* Sinch Events service
*
* <p>Callback events are used to authorize and manage your verification requests and return
* verification results.
Expand All @@ -16,7 +16,7 @@
*
* @since 1.1
*/
public interface WebhooksService {
public interface SinchEventsService {

/**
* The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request
Expand Down Expand Up @@ -48,7 +48,7 @@ boolean validateAuthenticationHeader(
* href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/">https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/</a>
* @since 1.1
*/
VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException;
VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException;

/**
* This function can be called to serialize a verification response to be sent as JSON
Expand All @@ -59,5 +59,5 @@ boolean validateAuthenticationHeader(
* href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/">https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks/</a>
* @since 1.1
*/
String serializeResponse(VerificationRequestEventResponse response) throws ApiMappingException;
String serializeResponse(VerificationStartEventResponse response) throws ApiMappingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ public interface VerificationService {
VerificationsStatusService verificationStatus();

/**
* Webhooks helpers instance
* Sinch Events helpers instance
*
* @return service instance for project
* @see <a
* href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks">Documentation</a>
* @since 1.1
* @since 2.0
*/
WebhooksService webhooks();
SinchEventsService sinchEvents();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@
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 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 WebhooksService implements com.sinch.sdk.domains.verification.api.v1.WebhooksService {
public class SinchEventsService
implements com.sinch.sdk.domains.verification.api.v1.SinchEventsService {

private static final Logger LOGGER = Logger.getLogger(WebhooksService.class.getName());
private static final Logger LOGGER = Logger.getLogger(SinchEventsService.class.getName());

private final Map<String, AuthManager> authManagers;

public WebhooksService(Map<String, AuthManager> authManagers) {
public SinchEventsService(Map<String, AuthManager> authManagers) {
this.authManagers = authManagers;
}

Expand Down Expand Up @@ -48,18 +49,18 @@ public boolean validateAuthenticationHeader(
}

@Override
public VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException {
public VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException {
try {
VerificationEventInternalImpl dto =
Mapper.getInstance().readValue(jsonPayload, VerificationEventInternalImpl.class);
return (VerificationEvent) dto.getActualInstance();
return (VerificationSinchEvent) dto.getActualInstance();
} catch (JsonProcessingException e) {
throw new ApiMappingException(jsonPayload, e);
}
}

@Override
public String serializeResponse(VerificationRequestEventResponse response)
public String serializeResponse(VerificationStartEventResponse response)
throws ApiMappingException {
try {
return Mapper.getInstance().writeValueAsString(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class VerificationService
private volatile VerificationsStartService startService;
private volatile VerificationsReportService reportService;
private volatile VerificationsStatusService statusService;
private volatile WebhooksService webhooks;
private volatile SinchEventsService sinchEvents;

private volatile Map<String, AuthManager> clientAuthManagers;
private volatile Map<String, AuthManager> webhooksAuthManagers;
private volatile Map<String, AuthManager> sinchEventsAuthManagers;

static {
LocalLazyInit.init();
Expand All @@ -66,21 +66,22 @@ 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(
BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION,
useApplicationAuth ? applicationAuthManager : basicAuthManager);

// here we need both auth managers to handle webhooks because we are receiving an Authorization
// here we need both auth managers to handle Sinch Events 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(
sinchEventsAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
sinchEventsAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, basicAuthManager);
sinchEventsAuthManagers.put(
APPLICATION_SECURITY_SCHEME_KEYWORD_VERIFICATION, applicationAuthManager);
}

Expand Down Expand Up @@ -123,20 +124,20 @@ public VerificationsStatusService verificationStatus() {
return this.statusService;
}

public WebhooksService webhooks() {
if (null == this.webhooks) {
public SinchEventsService sinchEvents() {
if (null == this.sinchEvents) {
instanceLazyInit();
this.webhooks = new WebhooksService(webhooksAuthManagers);
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Models related to Verifications Sinch Events
*
* @since 2.0
*/
package com.sinch.sdk.domains.verification.models.v1.sinchevents;

This file was deleted.

Loading
Loading