Skip to content

Commit 5485d43

Browse files
authored
DEVEXP-1309: use event destinations and sinch events (Verification)
2 parents 46feac1 + 64e48c3 commit 5485d43

56 files changed

Lines changed: 795 additions & 779 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

MIGRATION-GUIDE.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,11 @@ Use the new versioned API under `verification().v1()` to get access to [Verifica
426426
| 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) |
427427
| 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) |
428428
| 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) |
429-
| 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) |
429+
| 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) |
430430
| 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) |
431431
| 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) |
432432
| 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) |
433-
| 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) |
433+
| 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) |
434434

435435
#### Replacement models
436436
##### Common Report
@@ -488,17 +488,16 @@ Use the new versioned API under `verification().v1()` to get access to [Verifica
488488
| 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) |
489489

490490
##### Webhooks
491-
| Old class | New class |
492-
|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
493-
| 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) |
494-
| 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) |
495-
| 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) |
496-
| 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) |
497-
| 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) |
498-
| 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) |
499-
| 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) |
500-
| 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) |
501-
| 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) |
491+
| Old class | New class |
492+
|-----------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
493+
| 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) |
494+
| 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) |
495+
| 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) |
496+
| 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) |
497+
| 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) |
498+
| 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) |
499+
| 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) |
500+
| 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) |
502501

503502
- `event` field removed from `VerificationRequestEvent`, `VerificationResultEvent` events.
504503
- `method` values based onto common `VerificationMethod` class.

client/src/main/com/sinch/sdk/domains/verification/api/v1/WebhooksService.java renamed to client/src/main/com/sinch/sdk/domains/verification/api/v1/SinchEventsService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.sinch.sdk.domains.verification.api.v1;
22

33
import com.sinch.sdk.core.exceptions.ApiMappingException;
4-
import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent;
5-
import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse;
4+
import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent;
5+
import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse;
66
import java.util.Map;
77

88
/**
9-
* Webhooks service
9+
* Sinch Events service
1010
*
1111
* <p>Callback events are used to authorize and manage your verification requests and return
1212
* verification results.
@@ -16,7 +16,7 @@
1616
*
1717
* @since 1.1
1818
*/
19-
public interface WebhooksService {
19+
public interface SinchEventsService {
2020

2121
/**
2222
* The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request
@@ -48,7 +48,7 @@ boolean validateAuthenticationHeader(
4848
* 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>
4949
* @since 1.1
5050
*/
51-
VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException;
51+
VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException;
5252

5353
/**
5454
* This function can be called to serialize a verification response to be sent as JSON
@@ -59,5 +59,5 @@ boolean validateAuthenticationHeader(
5959
* 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>
6060
* @since 1.1
6161
*/
62-
String serializeResponse(VerificationRequestEventResponse response) throws ApiMappingException;
62+
String serializeResponse(VerificationStartEventResponse response) throws ApiMappingException;
6363
}

client/src/main/com/sinch/sdk/domains/verification/api/v1/VerificationService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public interface VerificationService {
4040
VerificationsStatusService verificationStatus();
4141

4242
/**
43-
* Webhooks helpers instance
43+
* Sinch Events helpers instance
4444
*
4545
* @return service instance for project
4646
* @see <a
4747
* href="https://developers.sinch.com/docs/verification/api-reference/verification/tag/Verification-callbacks">Documentation</a>
48-
* @since 1.1
48+
* @since 2.0
4949
*/
50-
WebhooksService webhooks();
50+
SinchEventsService sinchEvents();
5151
}

client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/WebhooksService.java renamed to client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/SinchEventsService.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
import com.sinch.sdk.core.utils.MapUtils;
77
import com.sinch.sdk.core.utils.StringUtil;
88
import com.sinch.sdk.core.utils.databind.Mapper;
9-
import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationEvent;
10-
import com.sinch.sdk.domains.verification.models.v1.webhooks.VerificationRequestEventResponse;
11-
import com.sinch.sdk.domains.verification.models.v1.webhooks.internal.VerificationEventInternalImpl;
9+
import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationSinchEvent;
10+
import com.sinch.sdk.domains.verification.models.v1.sinchevents.VerificationStartEventResponse;
11+
import com.sinch.sdk.domains.verification.models.v1.sinchevents.internal.VerificationEventInternalImpl;
1212
import java.util.Map;
1313
import java.util.logging.Logger;
1414

15-
public class WebhooksService implements com.sinch.sdk.domains.verification.api.v1.WebhooksService {
15+
public class SinchEventsService
16+
implements com.sinch.sdk.domains.verification.api.v1.SinchEventsService {
1617

17-
private static final Logger LOGGER = Logger.getLogger(WebhooksService.class.getName());
18+
private static final Logger LOGGER = Logger.getLogger(SinchEventsService.class.getName());
1819

1920
private final Map<String, AuthManager> authManagers;
2021

21-
public WebhooksService(Map<String, AuthManager> authManagers) {
22+
public SinchEventsService(Map<String, AuthManager> authManagers) {
2223
this.authManagers = authManagers;
2324
}
2425

@@ -48,18 +49,18 @@ public boolean validateAuthenticationHeader(
4849
}
4950

5051
@Override
51-
public VerificationEvent parseEvent(String jsonPayload) throws ApiMappingException {
52+
public VerificationSinchEvent parseEvent(String jsonPayload) throws ApiMappingException {
5253
try {
5354
VerificationEventInternalImpl dto =
5455
Mapper.getInstance().readValue(jsonPayload, VerificationEventInternalImpl.class);
55-
return (VerificationEvent) dto.getActualInstance();
56+
return (VerificationSinchEvent) dto.getActualInstance();
5657
} catch (JsonProcessingException e) {
5758
throw new ApiMappingException(jsonPayload, e);
5859
}
5960
}
6061

6162
@Override
62-
public String serializeResponse(VerificationRequestEventResponse response)
63+
public String serializeResponse(VerificationStartEventResponse response)
6364
throws ApiMappingException {
6465
try {
6566
return Mapper.getInstance().writeValueAsString(response);

client/src/main/com/sinch/sdk/domains/verification/api/v1/adapters/VerificationService.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ public class VerificationService
3838
private volatile VerificationsStartService startService;
3939
private volatile VerificationsReportService reportService;
4040
private volatile VerificationsStatusService statusService;
41-
private volatile WebhooksService webhooks;
41+
private volatile SinchEventsService sinchEvents;
4242

4343
private volatile Map<String, AuthManager> clientAuthManagers;
44-
private volatile Map<String, AuthManager> webhooksAuthManagers;
44+
private volatile Map<String, AuthManager> sinchEventsAuthManagers;
4545

4646
static {
4747
LocalLazyInit.init();
@@ -66,21 +66,22 @@ private void createAuthManagers(ApplicationCredentials credentials) {
6666
credentials.getApplicationKey(), credentials.getApplicationSecret());
6767

6868
boolean useApplicationAuth = true;
69-
// to handle request from client we can only have "Basic" keyword behind the auth managers
69+
// To handle request from client we can only have "Basic" keyword behind the auth managers
7070
// because of the OAS file only contains it; so we need to trick the application auth manager
7171
// hidden behind the "Basic" keyword
72-
// we need both auth manager to handle webhooks because of customer will choose from his
72+
// We need both auth manager to handle Sinch Events because of customer will choose from his
7373
// dashboard which scheme to be used
7474
clientAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
7575
clientAuthManagers.put(
7676
BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION,
7777
useApplicationAuth ? applicationAuthManager : basicAuthManager);
7878

79-
// here we need both auth managers to handle webhooks because we are receiving an Authorization
79+
// here we need both auth managers to handle Sinch Events because we are receiving an
80+
// Authorization
8081
// header with "Application" keyword
81-
webhooksAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
82-
webhooksAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, basicAuthManager);
83-
webhooksAuthManagers.put(
82+
sinchEventsAuthManagers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
83+
sinchEventsAuthManagers.put(BASIC_SECURITY_SCHEME_KEYWORD_VERIFICATION, basicAuthManager);
84+
sinchEventsAuthManagers.put(
8485
APPLICATION_SECURITY_SCHEME_KEYWORD_VERIFICATION, applicationAuthManager);
8586
}
8687

@@ -123,20 +124,20 @@ public VerificationsStatusService verificationStatus() {
123124
return this.statusService;
124125
}
125126

126-
public WebhooksService webhooks() {
127-
if (null == this.webhooks) {
127+
public SinchEventsService sinchEvents() {
128+
if (null == this.sinchEvents) {
128129
instanceLazyInit();
129-
this.webhooks = new WebhooksService(webhooksAuthManagers);
130+
this.sinchEvents = new SinchEventsService(sinchEventsAuthManagers);
130131
}
131-
return this.webhooks;
132+
return this.sinchEvents;
132133
}
133134

134135
private void instanceLazyInit() {
135-
if (null != this.clientAuthManagers && null != this.webhooksAuthManagers) {
136+
if (null != this.clientAuthManagers && null != this.sinchEventsAuthManagers) {
136137
return;
137138
}
138139
synchronized (this) {
139-
if (null == this.clientAuthManagers || null == this.webhooksAuthManagers) {
140+
if (null == this.clientAuthManagers || null == this.sinchEventsAuthManagers) {
140141

141142
// Currently, we are not supporting unified credentials: ensure application credentials are
142143
// defined
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Models related to Verifications Sinch Events
3+
*
4+
* @since 2.0
5+
*/
6+
package com.sinch.sdk.domains.verification.models.v1.sinchevents;

client/src/main/com/sinch/sdk/domains/verification/models/v1/webhooks/package-info.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)