Skip to content

Commit

Permalink
Merge pull request #166 from sinch/release-1.4.0
Browse files Browse the repository at this point in the history
Merge release 'release-1.4.0' branch into main
  • Loading branch information
JPPortier authored Nov 7, 2024
2 parents 06bafd3 + 9c69548 commit e04c078
Show file tree
Hide file tree
Showing 413 changed files with 26,044 additions and 17,059 deletions.
2 changes: 1 addition & 1 deletion client/src/main/com/sinch/sdk/SDK.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public class SDK {

public static final String NAME = "Sinch Java SDK";
public static final String VERSION = "1.4.0-dev";
public static final String VERSION = "1.4.1-dev";
public static final String AUXILIARY_FLAG = "";
}
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 @@ -3,6 +3,7 @@
import com.sinch.sdk.core.exceptions.ApiAuthException;
import com.sinch.sdk.core.exceptions.ApiException;
import com.sinch.sdk.core.http.AuthManager;
import com.sinch.sdk.core.utils.MapUtils;
import com.sinch.sdk.core.utils.Pair;
import com.sinch.sdk.core.utils.StringUtil;
import java.net.URI;
Expand All @@ -15,7 +16,6 @@
import java.util.Base64;
import java.util.Collection;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Logger;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
Expand Down Expand Up @@ -107,9 +107,7 @@ public boolean validateAuthenticatedRequest(
String method, String path, Map<String, String> headers, String jsonPayload) {

// convert header keys to use case-insensitive map keys
Map<String, String> caseInsensitiveHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
caseInsensitiveHeaders.putAll(headers);

Map<String, String> caseInsensitiveHeaders = MapUtils.getCaseInsensitiveMap(headers);
String authorizationHeader = caseInsensitiveHeaders.get("Authorization");

// missing authorization header
Expand Down
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));
}
}
Loading

0 comments on commit e04c078

Please sign in to comment.