Skip to content

Commit c3ab981

Browse files
authored
DEVEXP-1309: use event destinations and sinch events (numbers) (#322)
* feat (Numbers): Refactor 'callback configuration' and 'webhooks' to 'Event Destinations' and 'Sinch Events'
1 parent 82fa5d0 commit c3ab981

51 files changed

Lines changed: 429 additions & 405 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: 71 additions & 63 deletions
Large diffs are not rendered by default.

client/src/main/com/sinch/sdk/domains/conversation/api/v1/ConversationService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public interface ConversationService {
7676
ProjectSettingsService projectSettings();
7777

7878
/**
79-
* WebHooksService Service instance
79+
* SinchEventsService Service instance
8080
*
8181
* @return service instance for project
8282
* @since 1.3

client/src/main/com/sinch/sdk/domains/numbers/api/v1/NumbersService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ public interface NumbersService extends ActiveNumberService, AvailableNumberServ
3131
AvailableRegionsService regions();
3232

3333
/**
34-
* Callbacks Configuration Service instance
34+
* Event Destinations Configuration Service instance
3535
*
3636
* @return service instance for project
3737
* @since 2.0
3838
*/
39-
CallbackConfigurationService callbackConfiguration();
39+
EventDestinationsService eventDestinations();
4040

4141
/**
42-
* Webhooks helpers instance
42+
* Sinch Events helpers instance
4343
*
44-
* @return instance service related to webhooks helpers
45-
* @since 1.2
44+
* @return instance service related to Sinch Events helpers
45+
* @since 2.0
4646
*/
47-
WebHooksService webhooks();
47+
SinchEventsService sinchEvents();
4848
}

client/src/main/com/sinch/sdk/domains/numbers/api/v1/WebHooksService.java renamed to client/src/main/com/sinch/sdk/domains/numbers/api/v1/SinchEventsService.java

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

33
import com.sinch.sdk.core.exceptions.ApiMappingException;
4-
import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent;
4+
import com.sinch.sdk.domains.numbers.models.v1.sinchevents.NumberSinchEvent;
55
import java.util.Map;
66

77
/**
8-
* Webhooks service
8+
* Sinch Events service
99
*
1010
* <p>Callback events are used to get notified about Numbers usage according to your configured
1111
* callback URL
@@ -16,7 +16,7 @@
1616
*
1717
* @since 1.2
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
@@ -47,5 +47,5 @@ boolean validateAuthenticationHeader(
4747
* @return The decoded event notification instance class
4848
* @since 1.2
4949
*/
50-
NumberEvent parseEvent(String jsonPayload) throws ApiMappingException;
50+
NumberSinchEvent parseEvent(String jsonPayload) throws ApiMappingException;
5151
}

client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersService.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import com.sinch.sdk.core.models.ServerConfiguration;
99
import com.sinch.sdk.core.utils.StringUtil;
1010
import com.sinch.sdk.domains.numbers.api.v1.AvailableRegionsService;
11-
import com.sinch.sdk.domains.numbers.api.v1.CallbackConfigurationService;
11+
import com.sinch.sdk.domains.numbers.api.v1.EventDestinationsService;
1212
import com.sinch.sdk.domains.numbers.models.v1.ActiveNumber;
1313
import com.sinch.sdk.domains.numbers.models.v1.EmergencyAddress;
1414
import com.sinch.sdk.domains.numbers.models.v1.request.ActiveNumberUpdateRequest;
@@ -46,8 +46,8 @@ public class NumbersService implements com.sinch.sdk.domains.numbers.api.v1.Numb
4646
private volatile AvailableNumberServiceFacade available;
4747
private volatile ActiveNumberServiceFacade active;
4848
private volatile AvailableRegionsService regions;
49-
private volatile CallbackConfigurationService callbackConfiguration;
50-
private volatile WebHooksService webhooks;
49+
private volatile EventDestinationsService eventDestinations;
50+
private volatile SinchEventsService sinchEvents;
5151

5252
static {
5353
LocalLazyInit.init();
@@ -96,26 +96,26 @@ ActiveNumberServiceFacade active() {
9696
return this.active;
9797
}
9898

99-
public CallbackConfigurationService callbackConfiguration() {
100-
if (null == this.callbackConfiguration) {
99+
public EventDestinationsService eventDestinations() {
100+
if (null == this.eventDestinations) {
101101
instanceLazyInit();
102-
this.callbackConfiguration =
103-
new CallbackConfigurationServiceImpl(
102+
this.eventDestinations =
103+
new EventDestinationsServiceImpl(
104104
httpClientSupplier.get(),
105105
context.getNumbersServer(),
106106
authManagers,
107107
HttpMapper.getInstance(),
108108
uriUUID);
109109
}
110-
return this.callbackConfiguration;
110+
return this.eventDestinations;
111111
}
112112

113-
public WebHooksService webhooks() {
113+
public SinchEventsService sinchEvents() {
114114

115-
if (null == this.webhooks) {
116-
this.webhooks = new WebHooksService(new NumbersWebhooksAuthenticationValidation());
115+
if (null == this.sinchEvents) {
116+
this.sinchEvents = new SinchEventsService(new SinchEventsAuthenticationValidation());
117117
}
118-
return this.webhooks;
118+
return this.sinchEvents;
119119
}
120120

121121
@Override

client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/NumbersWebhooksAuthenticationValidation.java renamed to client/src/main/com/sinch/sdk/domains/numbers/api/v1/adapters/SinchEventsAuthenticationValidation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import javax.crypto.Mac;
1212
import javax.crypto.spec.SecretKeySpec;
1313

14-
public class NumbersWebhooksAuthenticationValidation {
14+
public class SinchEventsAuthenticationValidation {
1515

1616
public static final String SIGNATURE_HEADER = "X-Sinch-Signature";
1717
static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
@@ -39,7 +39,7 @@ private String encode(String secret, String stringToSign) {
3939
Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
4040
mac.init(secretKeySpec);
4141
byte[] hmacSha256 = mac.doFinal(stringToSign.getBytes(StandardCharsets.UTF_8));
42-
return NumbersWebhooksAuthenticationValidation.bytesToHex(hmacSha256);
42+
return SinchEventsAuthenticationValidation.bytesToHex(hmacSha256);
4343
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
4444
throw new ApiAuthException(e);
4545
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.sinch.sdk.core.exceptions.ApiMappingException;
55
import com.sinch.sdk.core.utils.databind.Mapper;
6-
import com.sinch.sdk.domains.numbers.models.v1.webhooks.NumberEvent;
6+
import com.sinch.sdk.domains.numbers.models.v1.sinchevents.NumberSinchEvent;
77
import java.util.Map;
88

9-
public class WebHooksService implements com.sinch.sdk.domains.numbers.api.v1.WebHooksService {
10-
private final NumbersWebhooksAuthenticationValidation authenticationChecker;
9+
public class SinchEventsService implements com.sinch.sdk.domains.numbers.api.v1.SinchEventsService {
10+
private final SinchEventsAuthenticationValidation authenticationChecker;
1111

12-
public WebHooksService(NumbersWebhooksAuthenticationValidation authenticationChecker) {
12+
public SinchEventsService(SinchEventsAuthenticationValidation authenticationChecker) {
1313
this.authenticationChecker = authenticationChecker;
1414
}
1515

@@ -20,10 +20,10 @@ public boolean validateAuthenticationHeader(
2020
}
2121

2222
@Override
23-
public NumberEvent parseEvent(String jsonPayload) throws ApiMappingException {
23+
public NumberSinchEvent parseEvent(String jsonPayload) throws ApiMappingException {
2424

2525
try {
26-
return Mapper.getInstance().readValue(jsonPayload, NumberEvent.class);
26+
return Mapper.getInstance().readValue(jsonPayload, NumberSinchEvent.class);
2727
} catch (JsonProcessingException e) {
2828
throw new ApiMappingException(jsonPayload, e);
2929
}

client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/request/package-info.java

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

client/src/main/com/sinch/sdk/domains/numbers/models/v1/callbacks/response/package-info.java

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/**
2+
* Numbers API Event Destinations related models
3+
*
4+
* @since 1.2
5+
*/
6+
package com.sinch.sdk.domains.numbers.models.v1.eventdestinations;

0 commit comments

Comments
 (0)