Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/DEVEXP-470: Voice V1 design #164

Merged
merged 37 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6643417
feat (Voice): Add Voice v1 package & generated sources
JPPortier Oct 8, 2024
9a1a0fb
test (Voice): refactoring test files based onto v1 tree hierarchy
JPPortier Oct 8, 2024
e7f0f07
feat (Voice/SVAML action): Move to v1.svaml.action usage
JPPortier Oct 8, 2024
1615dbc
feat (Voice/SVAML instruction): Move to v1.svaml.instruction usage
JPPortier Oct 8, 2024
cdb8b30
feat (Voice/Price): Move to 'models.v1.Price' usage
JPPortier Oct 9, 2024
cd503e6
feat (Voice/Destination): Move to 'models.v1.Destination' usage
JPPortier Oct 9, 2024
2c96a97
feat (Voice/Domain): Move to 'models.v1.Domain' usage
JPPortier Oct 9, 2024
4cced12
feat (Voice/SVAML): Move to 'models.v1.svaml.SvamlControl' usage
JPPortier Oct 9, 2024
de705c0
refactor (Voice/Error): Remove unused schema
JPPortier Oct 9, 2024
05e4b22
feat (Voice): Add 'DualToneMultiFrequency' dedicated mapper
JPPortier Oct 9, 2024
151328a
feat (Voice/Callouts): Move to 'models.v1.callouts.request' usage
JPPortier Oct 9, 2024
052629f
feat (Voice/Callouts): Move to 'models.v1.callouts.response' usage
JPPortier Oct 9, 2024
9c5c00e
feat (Voice/Calls): Move to 'models.v1.calls.response' usage
JPPortier Oct 9, 2024
fc9486f
refactor (Voice/Webhook): Synch with destination/price and domain usage
JPPortier Oct 9, 2024
e33218c
feat (Voice/Callouts): Create Voice 'v1' service, 'v1.callouts' and …
JPPortier Oct 9, 2024
b0ed65c
feat (Voice/Calls): Create 'v1.calls' service and use 'v1.calls' APIs…
JPPortier Oct 9, 2024
9fb0587
feat (Voice/Conferences): Create 'v1.conferences' service and use 'v1…
JPPortier Oct 9, 2024
e138c06
feat (Voice/Webhooks): Move to 'models.v1.webhooks' usage
JPPortier Oct 10, 2024
a8b7108
feat (Voice/Webhooks): Create 'v1.webhooks' service and use 'v1.webho…
JPPortier Oct 10, 2024
afd8a80
feat (Voice/Applications): Move to 'models.v1.applications' usage
JPPortier Oct 10, 2024
038d5bf
feat (Voice/Applications): Create 'v1.applications' service and use '…
JPPortier Oct 10, 2024
83f2652
feat (Voice/E2E): Support E2E tests for both 'V0' and' V1'
JPPortier Oct 11, 2024
236dc3e
feat (Voice/CalloutCustom): Define ace/ice/pie fields as 'Control' to…
JPPortier Oct 11, 2024
2a35d46
feat (Voice/MenuOption): Provide factory helper for 'menu'/'return' a…
JPPortier Oct 11, 2024
2bafab3
feat (Voice): Generalize 'DualToneMultiFrequency' type usage for 'dtm…
JPPortier Oct 11, 2024
741eb02
feat (Voice): Generalize 'MusicOnHold' field name usage
JPPortier Oct 11, 2024
e41531c
refactor (Voice/Samples): Move samples to 'V1' usage
JPPortier Oct 11, 2024
f3f7c57
refactor (Voice/CalloutRequest): Move 'callouts.CalloutRequest' onto …
JPPortier Oct 11, 2024
1982954
docs (Voice): javadoc
JPPortier Oct 11, 2024
a8440ff
feat (Voice/Destination): Synch with OAS file updated for 'Destinatio…
JPPortier Oct 12, 2024
91f5c01
feat (Voice/Destination): Synch client with latest OAS 'destination' …
JPPortier Oct 15, 2024
9c63184
test (Voice/E2E): Extends 2E2 tests for ICE
JPPortier Oct 15, 2024
154859a
docs (Voice): javadoc update
JPPortier Oct 16, 2024
0890b65
refactor (Voice): Rename 'unAssign' to 'unassign'
JPPortier Oct 28, 2024
058147d
feat (Webhooks): A missing 'Authorization' header means request is no…
JPPortier Oct 28, 2024
b56389e
refactor (Voice/Test): Synch function name
JPPortier Oct 29, 2024
d6dd32a
test (Voice): Extend unit test coverage for 'no failure' when credent…
JPPortier Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 21 additions & 0 deletions client/src/main/com/sinch/sdk/SinchClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.sinch.sdk.models.VerificationContext;
import com.sinch.sdk.models.VoiceContext;
import com.sinch.sdk.models.VoiceRegion;
import com.sinch.sdk.models.adapters.DualToneMultiFrequencyMapper;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
Expand Down Expand Up @@ -410,4 +411,24 @@ private String formatAuxiliaryFlag() {
}
return String.join(",", values);
}

static {
LocalLazyInit.init();
}

static final class LocalLazyInit {

private LocalLazyInit() {
DualToneMultiFrequencyMapper.initMapper();
}

public static LocalLazyInit init() {
return LocalLazyInit.LazyHolder.INSTANCE;
}

private static class LazyHolder {

public static final LocalLazyInit INSTANCE = new LocalLazyInit();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
import com.sinch.sdk.domains.voice.models.response.AssignedNumbers;
import com.sinch.sdk.models.E164PhoneNumber;

/** You can use the API to manage features of applications in your project. */
/**
* You can use the API to manage features of applications in your project.
*
* @since 1.0
*/
public interface ApplicationsService {

/**
Expand Down
9 changes: 9 additions & 0 deletions client/src/main/com/sinch/sdk/domains/voice/VoiceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
*/
public interface VoiceService {

/**
* Voice Service V1
*
* @return V1 service instance for project
* @see <a href="https://developers.sinch.com/docs/voice">Documentation</a>
* @since 1.1
*/
com.sinch.sdk.domains.voice.api.v1.VoiceService v1();

/**
* Callouts Service instance
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,63 +1,41 @@
package com.sinch.sdk.domains.voice.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.adapters.api.v1.ApplicationsApi;
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;
import com.sinch.sdk.models.VoiceContext;
import java.util.Map;

public class ApplicationsService implements com.sinch.sdk.domains.voice.ApplicationsService {

private final ApplicationsApi api;
private final com.sinch.sdk.domains.voice.api.v1.ApplicationsService v1;

public ApplicationsService(
VoiceContext context, HttpClient httpClient, Map<String, AuthManager> authManagers) {
this.api =
new ApplicationsApi(
httpClient,
context.getVoiceApplicationManagementServer(),
authManagers,
new HttpMapper());
}

protected ApplicationsApi getApi() {
return this.api;
public ApplicationsService(com.sinch.sdk.domains.voice.api.v1.ApplicationsService v1) {
this.v1 = v1;
}

public AssignedNumbers listNumbers() {

return ApplicationsDtoConverter.convert(getApi().configurationGetNumbers());
return ApplicationsDtoConverter.convert(v1.listNumbers());
}

public CallbackUrls getCallbackUrls(String applicationKey) {

return ApplicationsDtoConverter.convert(getApi().configurationGetCallbackURLs(applicationKey));
return ApplicationsDtoConverter.convert(v1.getCallbackUrls(applicationKey));
}

public void updateCallbackUrls(String applicationKey, CallbackUrls parameters) {
getApi()
.configurationUpdateCallbackURLs(
applicationKey, ApplicationsDtoConverter.convert(parameters));
v1.updateCallbackUrls(applicationKey, ApplicationsDtoConverter.convert(parameters));
}

public NumberInformation queryNumber(E164PhoneNumber number) {
return ApplicationsDtoConverter.convert(getApi().callingQueryNumber(number.stringValue()));
return ApplicationsDtoConverter.convert(v1.queryNumber(number.stringValue()));
}

public void assignNumbers(ApplicationsAssignNumbersRequestParameters parameters) {
getApi().configurationUpdateNumbers(ApplicationsDtoConverter.convert(parameters));
v1.assignNumbers(ApplicationsDtoConverter.convert(parameters));
}

public void unassignNumber(E164PhoneNumber phoneNumber, String applicationKey) {

getApi()
.configurationUnassignNumber(ApplicationsDtoConverter.convert(phoneNumber, applicationKey));
v1.unassignNumber(ApplicationsDtoConverter.convert(phoneNumber, applicationKey));
}
}
Original file line number Diff line number Diff line change
@@ -1,49 +1,39 @@
package com.sinch.sdk.domains.voice.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.adapters.api.v1.CalloutsApi;
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.models.VoiceContext;
import java.util.Map;
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 CalloutsApi api;
private final com.sinch.sdk.domains.voice.api.v1.CalloutsService v1;

public CalloutsService(
VoiceContext context, HttpClient httpClient, Map<String, AuthManager> authManagers) {
this.api =
new CalloutsApi(httpClient, context.getVoiceServer(), authManagers, new HttpMapper());
}

protected CalloutsApi getApi() {
return this.api;
public CalloutsService(com.sinch.sdk.domains.voice.api.v1.CalloutsService v1) {
this.v1 = v1;
}

public String textToSpeech(CalloutRequestParametersTTS parameters) {

return call(parameters);
return v1.textToSpeech((CalloutRequestTTS) CalloutsDtoConverter.convert(parameters));
}

public String conference(CalloutRequestParametersConference parameters) {

return call(parameters);
return v1.conference((CalloutRequestConference) CalloutsDtoConverter.convert(parameters));
}

public String custom(CalloutRequestParametersCustom parameters) {

return call(parameters);
return v1.custom((CalloutRequestCustom) CalloutsDtoConverter.convert(parameters));
}

public String call(CalloutRequestParameters parameters) {

return CalloutsDtoConverter.convert(
getApi().callouts(CalloutsDtoConverter.convert(parameters)));
return v1.call(CalloutsDtoConverter.convert(parameters));
}
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,30 @@
package com.sinch.sdk.domains.voice.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.adapters.api.v1.CallsApi;
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.models.VoiceContext;
import java.util.Map;
import com.sinch.sdk.domains.voice.models.v1.calls.request.CallLeg;

public class CallsService implements com.sinch.sdk.domains.voice.CallsService {

private final CallsApi api;
private final com.sinch.sdk.domains.voice.api.v1.CallsService v1;

public CallsService(
VoiceContext context, HttpClient httpClient, Map<String, AuthManager> authManagers) {
this.api = new CallsApi(httpClient, context.getVoiceServer(), authManagers, new HttpMapper());
}

protected CallsApi getApi() {
return this.api;
public CallsService(com.sinch.sdk.domains.voice.api.v1.CallsService v1) {
this.v1 = v1;
}

public CallInformation get(String callId) {

return CallsDtoConverter.convert(getApi().callingGetCallResult(callId));
return CallsDtoConverter.convert(v1.get(callId));
}

public void update(String callId, SVAMLControl parameters) {
getApi().callingUpdateCall(callId, CallsDtoConverter.convert(parameters));
v1.update(callId, ControlDtoConverter.convertControl(parameters));
}

public void manageWithCallLeg(String callId, CallLegType callLeg, SVAMLControl parameters) {
getApi()
.callingManageCallWithCallLeg(
callId, callLeg.value(), CallsDtoConverter.convert(parameters));
v1.manageWithCallLeg(
callId, CallLeg.from(callLeg.value()), ControlDtoConverter.convertControl(parameters));
}
}
Original file line number Diff line number Diff line change
@@ -1,53 +1,39 @@
package com.sinch.sdk.domains.voice.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.adapters.api.v1.ConferencesApi;
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.models.VoiceContext;
import com.sinch.sdk.domains.voice.models.v1.callouts.request.CalloutRequestConference;
import java.util.Collection;
import java.util.Map;

public class ConferencesService implements com.sinch.sdk.domains.voice.ConferencesService {

private final ConferencesApi api;
private final com.sinch.sdk.domains.voice.api.v1.ConferencesService v1;

public ConferencesService(
VoiceContext context, HttpClient httpClient, Map<String, AuthManager> authManagers) {
this.api =
new ConferencesApi(httpClient, context.getVoiceServer(), authManagers, new HttpMapper());
}

protected ConferencesApi getApi() {
return this.api;
public ConferencesService(com.sinch.sdk.domains.voice.api.v1.ConferencesService v1) {
this.v1 = v1;
}

public String call(CalloutRequestParametersConference parameters) {
return CalloutsDtoConverter.convert(
getApi().callouts(CalloutsDtoConverter.convert(parameters)));
return v1.call((CalloutRequestConference) CalloutsDtoConverter.convert(parameters));
}

public Collection<ConferenceParticipant> get(String conferenceId) {
return ConferencesDtoConverter.convert(getApi().callingGetConferenceInfo(conferenceId));
return ConferencesDtoConverter.convert(v1.get(conferenceId));
}

public void kickAll(String conferenceId) {
getApi().callingKickConferenceAll(conferenceId);
v1.kickAll(conferenceId);
}

public void kickParticipant(String conferenceId, String callId) {
getApi().callingKickConferenceParticipant(callId, conferenceId);
v1.kickParticipant(conferenceId, callId);
}

public void manageParticipant(
String conferenceId, String callId, ConferenceManageParticipantRequestParameters parameters) {
getApi()
.callingManageConferenceParticipant(
callId, conferenceId, ConferencesDtoConverter.convert(parameters));
v1.manageParticipant(conferenceId, callId, ConferencesDtoConverter.convert(parameters));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public class VoiceService implements com.sinch.sdk.domains.voice.VoiceService {
private Map<String, AuthManager> clientAuthManagers;
private Map<String, AuthManager> webhooksAuthManagers;

private final com.sinch.sdk.domains.voice.api.v1.VoiceService v1;

public VoiceService(
ApplicationCredentials credentials, VoiceContext context, HttpClient httpClient) {

Expand All @@ -52,6 +54,10 @@ public VoiceService(
this.context = context;
this.httpClient = httpClient;
setApplicationCredentials(credentials);

this.v1 =
new com.sinch.sdk.domains.voice.api.v1.adapters.VoiceService(
credentials, context, httpClient);
}

private void setApplicationCredentials(ApplicationCredentials credentials) {
Expand All @@ -75,9 +81,7 @@ private void setApplicationCredentials(ApplicationCredentials credentials) {
public CalloutsService callouts() {
if (null == this.callouts) {
checkCredentials();
this.callouts =
new com.sinch.sdk.domains.voice.adapters.CalloutsService(
context, httpClient, clientAuthManagers);
this.callouts = new com.sinch.sdk.domains.voice.adapters.CalloutsService(v1().callouts());
}
return this.callouts;
}
Expand All @@ -86,18 +90,15 @@ public ConferencesService conferences() {
if (null == this.conferences) {
checkCredentials();
this.conferences =
new com.sinch.sdk.domains.voice.adapters.ConferencesService(
context, httpClient, clientAuthManagers);
new com.sinch.sdk.domains.voice.adapters.ConferencesService(v1.conferences());
}
return this.conferences;
}

public CallsService calls() {
if (null == this.calls) {
checkCredentials();
this.calls =
new com.sinch.sdk.domains.voice.adapters.CallsService(
context, httpClient, clientAuthManagers);
this.calls = new com.sinch.sdk.domains.voice.adapters.CallsService(v1.calls());
}
return this.calls;
}
Expand All @@ -106,21 +107,23 @@ public ApplicationsService applications() {
if (null == this.applications) {
checkCredentials();
this.applications =
new com.sinch.sdk.domains.voice.adapters.ApplicationsService(
context, httpClient, clientAuthManagers);
new com.sinch.sdk.domains.voice.adapters.ApplicationsService(v1.applications());
}
return this.applications;
}

public WebHooksService webhooks() {
checkCredentials();
if (null == this.webhooks) {
this.webhooks =
new com.sinch.sdk.domains.voice.adapters.WebHooksService(webhooksAuthManagers);
this.webhooks = new com.sinch.sdk.domains.voice.adapters.WebHooksService(v1.webhooks());
}
return this.webhooks;
}

public com.sinch.sdk.domains.voice.api.v1.VoiceService v1() {
return this.v1;
}

private void checkCredentials() throws ApiAuthException {
if (null == clientAuthManagers || clientAuthManagers.isEmpty()) {
throw new ApiAuthException(
Expand Down
Loading
Loading