diff --git a/client/src/main/com/sinch/sdk/domains/common/adapters/converters/OffsetDateTimeDtoConverter.java b/client/src/main/com/sinch/sdk/domains/common/adapters/converters/OffsetDateTimeDtoConverter.java new file mode 100644 index 000000000..e9151b54b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/common/adapters/converters/OffsetDateTimeDtoConverter.java @@ -0,0 +1,11 @@ +package com.sinch.sdk.domains.common.adapters.converters; + +import java.time.Instant; +import java.time.OffsetDateTime; + +public class OffsetDateTimeDtoConverter { + + public static Instant convert(OffsetDateTime dto) { + return null != dto ? dto.toInstant() : null; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java index a9d98db13..70e29d483 100644 --- a/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java +++ b/client/src/main/com/sinch/sdk/domains/verification/WebHooksService.java @@ -51,7 +51,7 @@ boolean validateAuthenticatedRequest( VerificationEvent unserializeVerificationEvent(String jsonPayload) throws ApiMappingException; /** - * This function can be called to serialize a verification response to be send as JSON + * This function can be called to serialize a verification response to be sent as JSON * * @param response The response to be serialized * @return The JSON string to be sent diff --git a/client/src/main/com/sinch/sdk/domains/voice/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/CallsService.java index 8c3260076..d8357c3fe 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/CallsService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/CallsService.java @@ -1,8 +1,8 @@ package com.sinch.sdk.domains.voice; import com.sinch.sdk.domains.voice.models.CallLegType; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParameters; import com.sinch.sdk.domains.voice.models.response.CallInformation; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; /** * Using the Calls service, you can manage on-going calls or retrieve information about a call. @@ -37,7 +37,7 @@ public interface CallsService { * @param callId The unique identifier of the call. This value is generated by the system * @param parameters Tasks to be used related to this call */ - void update(String callId, CallsUpdateRequestParameters parameters); + void update(String callId, SVAMLControl parameters); /** * This method is used to manage ongoing, connected calls. This method is only used when using the @@ -51,6 +51,5 @@ public interface CallsService { * @param callId The unique identifier of the call. This value is generated by the system * @param parameters Tasks to be used related to this call */ - void manageWithCallLeg( - String callId, CallLegType callLeg, CallsUpdateRequestParameters parameters); + void manageWithCallLeg(String callId, CallLegType callLeg, SVAMLControl parameters); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java index 47684f9eb..fd69b3109 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/VoiceService.java @@ -40,4 +40,12 @@ public interface VoiceService { * @since 1.0 */ ApplicationsService applications(); + + /** + * Webhooks helpers instance + * + * @return instance service related to webhooks helpers + * @since 1.0 + */ + WebHooksService webhooks(); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java new file mode 100644 index 000000000..8ca79fa06 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/WebHooksService.java @@ -0,0 +1,59 @@ +package com.sinch.sdk.domains.voice; + +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; +import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; +import java.util.Map; + +/** + * Webhooks service + * + * @see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 1.0 + */ +public interface WebHooksService { + + /** + * The Sinch Platform can initiate callback requests to a URL you define (Callback URL) on request + * and result events. All callback requests are signed using your Application key and secret pair + * found on your dashboard. The signature is included in the Authorization header of the request + * + *

By using following function, you can ensure authentication according to received payload + * from your backend + * + * @param method The HTTP method used ot handle the callback + * @param path The path to you backend endpoint used for callback + * @param headers Received headers + * @param jsonPayload Received payload + * @return Is authentication is validated (true) or not (false) + *

see https://developers.sinch.com/docs/voice/api-reference/authentication/callback-signed-request/ + * @since 1.0 + */ + boolean validateAuthenticatedRequest( + String method, String path, Map headers, String jsonPayload); + + /** + * This function can be called to deserialize received payload onto callback onto proper java + * Voice event class + * + * @param jsonPayload Received payload to be deserialized + * @return The Voice event instance class + *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 1.0 + */ + WebhooksEvent unserializeWebhooksEvent(String jsonPayload) throws ApiMappingException; + + /** + * This function can be called to serialize a Voice response to be sent as JSON + * + * @param response The response to be serialized + * @return The JSON string to be sent + *

see https://developers.sinch.com/docs/voice/api-reference/voice/tag/Callbacks/ + * @since 1.0 + */ + String serializeWebhooksResponse(SVAMLControl response) throws ApiMappingException; +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java index 4cc4eb2b4..7c5a94f0b 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/CallsService.java @@ -6,8 +6,8 @@ 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.models.CallLegType; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParameters; import com.sinch.sdk.domains.voice.models.response.CallInformation; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; import com.sinch.sdk.models.Configuration; import java.util.Map; @@ -30,12 +30,11 @@ public CallInformation get(String callId) { return CallsDtoConverter.convert(getApi().callingGetCallResult(callId)); } - public void update(String callId, CallsUpdateRequestParameters parameters) { + public void update(String callId, SVAMLControl parameters) { getApi().callingUpdateCall(callId, CallsDtoConverter.convert(parameters)); } - public void manageWithCallLeg( - String callId, CallLegType callLeg, CallsUpdateRequestParameters parameters) { + public void manageWithCallLeg(String callId, CallLegType callLeg, SVAMLControl parameters) { getApi() .callingManageCallWithCallLeg( callId, callLeg.value(), CallsDtoConverter.convert(parameters)); diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java index 44dc334a6..51e98d717 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/VoiceService.java @@ -7,6 +7,7 @@ import com.sinch.sdk.core.http.HttpClient; import com.sinch.sdk.domains.voice.ApplicationsService; import com.sinch.sdk.domains.voice.CalloutsService; +import com.sinch.sdk.domains.voice.WebHooksService; import com.sinch.sdk.models.Configuration; import java.util.Map; import java.util.Objects; @@ -26,6 +27,7 @@ public class VoiceService implements com.sinch.sdk.domains.voice.VoiceService { private ConferencesService conferences; private CallsService calls; private ApplicationsService applications; + private WebHooksService webhooks; private Map clientAuthManagers; private Map webhooksAuthManagers; @@ -99,6 +101,15 @@ public ApplicationsService applications() { return this.applications; } + public WebHooksService webhooks() { + checkCredentials(); + if (null == this.webhooks) { + this.webhooks = + new com.sinch.sdk.domains.voice.adapters.WebHooksService(webhooksAuthManagers); + } + return this.webhooks; + } + private void checkCredentials() throws ApiAuthException { if (null == clientAuthManagers || clientAuthManagers.isEmpty()) { throw new ApiAuthException( diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java new file mode 100644 index 000000000..ac89e8322 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/WebHooksService.java @@ -0,0 +1,72 @@ +package com.sinch.sdk.domains.voice.adapters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.http.AuthManager; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.voice.adapters.converters.CallsDtoConverter; +import com.sinch.sdk.domains.voice.adapters.converters.WebhooksEventDtoConverter; +import com.sinch.sdk.domains.voice.models.dto.v1.SVAMLRequestBodyDto; +import com.sinch.sdk.domains.voice.models.dto.v1.WebhooksEventDto; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; +import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; +import java.util.Map; +import java.util.TreeMap; +import java.util.logging.Logger; + +public class WebHooksService implements com.sinch.sdk.domains.voice.WebHooksService { + private static final Logger LOGGER = Logger.getLogger(WebHooksService.class.getName()); + + private final Map authManagers; + + public WebHooksService(Map authManagers) { + this.authManagers = authManagers; + } + + public boolean validateAuthenticatedRequest( + String method, String path, Map headers, String jsonPayload) { + + // convert header keys to use case-insensitive map keys + Map caseInsensitiveHeaders = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + caseInsensitiveHeaders.putAll(headers); + + String authorizationHeader = caseInsensitiveHeaders.get("Authorization"); + + // no authorization required + if (null == authorizationHeader) { + return true; + } + + String[] split = authorizationHeader.split(" "); + String authorizationKeyword = split.length > 0 ? split[0] : ""; + + AuthManager authManager = authManagers.get(authorizationKeyword); + if (null == authManager) { + // unknown auth manager + LOGGER.severe( + String.format("Auth manager for authorization '%s' not found", authorizationKeyword)); + return false; + } + return authManager.validateAuthenticatedRequest(method, path, headers, jsonPayload); + } + + @Override + public WebhooksEvent unserializeWebhooksEvent(String jsonPayload) throws ApiMappingException { + try { + WebhooksEventDto o = Mapper.getInstance().readValue(jsonPayload, WebhooksEventDto.class); + return WebhooksEventDtoConverter.convert(o); + } catch (JsonProcessingException e) { + throw new ApiMappingException(jsonPayload, e); + } + } + + @Override + public String serializeWebhooksResponse(SVAMLControl response) throws ApiMappingException { + SVAMLRequestBodyDto dto = CallsDtoConverter.convert(response); + try { + return Mapper.getInstance().writeValueAsString(dto); + } catch (JsonProcessingException e) { + throw new ApiMappingException(response.toString(), e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java index fcf9a91d3..d5d8582c8 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CalloutsDtoConverter.java @@ -7,6 +7,7 @@ import com.sinch.sdk.domains.voice.models.dto.v1.ConferenceCalloutRequestConferenceDtmfOptionsDto; import com.sinch.sdk.domains.voice.models.dto.v1.ConferenceCalloutRequestDto; import com.sinch.sdk.domains.voice.models.dto.v1.CustomCalloutRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.DomainDto; import com.sinch.sdk.domains.voice.models.dto.v1.GetCalloutResponseObjDto; import com.sinch.sdk.domains.voice.models.dto.v1.TtsCalloutRequestDto; import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParameters; @@ -56,7 +57,7 @@ private static CalloutRequestDto convert(CalloutRequestParametersConference clie client.getEnablePie().ifPresent(dto::setEnablePie); client.getLocale().ifPresent(dto::setLocale); client.getGreeting().ifPresent(dto::setGreeting); - client.getMohClass().ifPresent(f -> dto.setMohClass(EnumDynamicConverter.convert(f))); + client.getMusicOnHold().ifPresent(f -> dto.setMohClass(EnumDynamicConverter.convert(f))); client.getDomain().ifPresent(f -> dto.setDomain(EnumDynamicConverter.convert(f))); return new CalloutRequestDto() @@ -76,7 +77,9 @@ private static CalloutRequestDto convert(CalloutRequestParametersTTS client) { client.getEnableDice().ifPresent(dto::setEnableDice); client.getEnablePie().ifPresent(dto::setEnablePie); client.getLocale().ifPresent(dto::setLocale); - client.getDomain().ifPresent(f -> dto.setDomain(EnumDynamicConverter.convert(f))); + client + .getDomain() + .ifPresent(f -> dto.setDomain(DomainDto.fromValue(EnumDynamicConverter.convert(f)))); client.getText().ifPresent(dto::setText); client.getPrompts().ifPresent(dto::setPrompts); @@ -93,9 +96,9 @@ private static CalloutRequestDto convert(CalloutRequestParametersCustom client) client.getCustom().ifPresent(dto::setCustom); client.getMaxDuration().ifPresent(dto::setMaxDuration); - client.getIce().ifPresent(dto::setIce); - client.getAce().ifPresent(dto::setAce); - client.getPie().ifPresent(dto::setPie); + client.getIce().ifPresent(f -> dto.setIce(ControlDtoConverter.convert(f))); + client.getAce().ifPresent(f -> dto.setAce(ControlDtoConverter.convert(f))); + client.getPie().ifPresent(f -> dto.setPie(ControlDtoConverter.convert(f))); return new CalloutRequestDto().method(MethodEnum.CUSTOMCALLOUT.getValue()).customCallout(dto); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java index 26ad71b6c..bd7643431 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverter.java @@ -1,13 +1,13 @@ package com.sinch.sdk.domains.voice.adapters.converters; +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; import com.sinch.sdk.domains.voice.models.DomainType; import com.sinch.sdk.domains.voice.models.dto.v1.GetCallResponseObjDto; import com.sinch.sdk.domains.voice.models.dto.v1.SVAMLRequestBodyDto; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParameters; import com.sinch.sdk.domains.voice.models.response.CallInformation; -import com.sinch.sdk.domains.voice.models.response.CallReasonType; -import com.sinch.sdk.domains.voice.models.response.CallResultType; import com.sinch.sdk.domains.voice.models.response.CallStatusType; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; public class CallsDtoConverter { @@ -22,7 +22,7 @@ public static CallInformation convert(GetCallResponseObjDto dto) { .setCallId(dto.getCallId()) .setDuration(dto.getDuration()) .setStatus(null != dto.getStatus() ? CallStatusType.from(dto.getStatus()) : null) - .setResult(null != dto.getResult() ? CallResultType.from(dto.getResult()) : null) + .setResult(null != dto.getResult() ? CallResultType.from(dto.getResult().getValue()) : null) .setReason(null != dto.getReason() ? CallReasonType.from(dto.getReason()) : null) .setTimeStamp(null != dto.getTimestamp() ? dto.getTimestamp().toInstant() : null) .setCustom(null != dto.getCustom() ? dto.getCustom() : null) @@ -31,15 +31,16 @@ public static CallInformation convert(GetCallResponseObjDto dto) { .build(); } - public static SVAMLRequestBodyDto convert(CallsUpdateRequestParameters client) { + public static SVAMLRequestBodyDto convert(SVAMLControl client) { if (null == client) { return null; } SVAMLRequestBodyDto dto = new SVAMLRequestBodyDto(); - dto.instructions(SAVMLInstructionDtoConverter.convert(client.getInstructions())); - dto.action(SAVMLActionDtoConverter.convert(client.getAction())); - + client + .getInstructions() + .ifPresent(f -> dto.instructions(SVAMLInstructionDtoConverter.convert(f))); + client.getAction().ifPresent(f -> dto.action(SVAMLActionDtoConverter.convert(f))); return dto; } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java index 8eaeb1765..65680ba52 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ConferencesDtoConverter.java @@ -37,7 +37,7 @@ public static ManageConferenceParticipantRequestDto convert( ManageConferenceParticipantRequestDto dto = new ManageConferenceParticipantRequestDto(); client.getCommand().ifPresent(f -> dto.command(EnumDynamicConverter.convert(f))); - client.getMoh().ifPresent(f -> dto.moh(EnumDynamicConverter.convert(f))); + client.getMusicOnHold().ifPresent(f -> dto.moh(EnumDynamicConverter.convert(f))); return dto; } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java new file mode 100644 index 000000000..6fe7dd93b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/ControlDtoConverter.java @@ -0,0 +1,40 @@ +package com.sinch.sdk.domains.voice.adapters.converters; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.core.exceptions.ApiMappingException; +import com.sinch.sdk.core.utils.databind.Mapper; +import com.sinch.sdk.domains.voice.models.requests.Control; +import com.sinch.sdk.domains.voice.models.requests.ControlUrl; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; +import java.util.logging.Logger; + +public class ControlDtoConverter { + + private static final Logger LOGGER = Logger.getLogger(SVAMLActionDtoConverter.class.getName()); + + public static String convert(Control client) { + if (null == client) { + return null; + } + String dto; + if (client instanceof SVAMLControl) { + SVAMLControl value = (SVAMLControl) client; + dto = convertControlToEscapedJSON(value); + } else if (client instanceof ControlUrl) { + ControlUrl value = (ControlUrl) client; + dto = value.getURL(); + } else { + LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); + dto = client.toString(); + } + return dto; + } + + private static String convertControlToEscapedJSON(SVAMLControl client) { + try { + return Mapper.getInstance().writeValueAsString(CallsDtoConverter.convert(client)); + } catch (JsonProcessingException e) { + throw new ApiMappingException(client.toString(), e); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java index 4f4ea9d88..e339412aa 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DestinationDtoConverter.java @@ -2,6 +2,7 @@ import com.sinch.sdk.domains.voice.models.Destination; import com.sinch.sdk.domains.voice.models.DestinationNumber; +import com.sinch.sdk.domains.voice.models.DestinationNumberType; import com.sinch.sdk.domains.voice.models.DestinationSip; import com.sinch.sdk.domains.voice.models.DestinationUser; import com.sinch.sdk.domains.voice.models.dto.v1.DestinationDto; @@ -11,6 +12,7 @@ import java.util.logging.Logger; public class DestinationDtoConverter { + private static final Logger LOGGER = Logger.getLogger(DestinationDtoConverter.class.getName()); public static DestinationDto convert(Destination client) { @@ -18,18 +20,34 @@ public static DestinationDto convert(Destination client) { if (null == client) { return null; } + DestinationTypeDto type = null; + String endpoint = null; if (client instanceof DestinationNumber) { DestinationNumber destination = (DestinationNumber) client; - dto.type(DestinationTypeDto.NUMBER).endpoint(destination.getPhoneNumber().stringValue()); + DestinationNumberType clientType = destination.getType(); + if (clientType == DestinationNumberType.DID) { + type = DestinationTypeDto.DID; + } else if (clientType == DestinationNumberType.PSTN) { + type = DestinationTypeDto.NUMBER; + } else { + LOGGER.severe(String.format("Unexpected type '%s'", destination.getType())); + return dto; + } + endpoint = destination.getPhoneNumber().stringValue(); } else if (client instanceof DestinationUser) { DestinationUser destination = (DestinationUser) client; - dto.type(DestinationTypeDto.USERNAME).endpoint(destination.getUserName()); + type = DestinationTypeDto.USERNAME; + endpoint = destination.getUserName(); } else if (client instanceof DestinationSip) { DestinationSip destination = (DestinationSip) client; - dto.type(DestinationTypeDto.SIP).endpoint(destination.getSIPAddress()); + type = DestinationTypeDto.SIP; + endpoint = destination.getSIPAddress(); } else { LOGGER.severe(String.format("Unexpected class '%s'", client.getClass())); } + if (null != type && endpoint != null) { + dto.type(type).endpoint(endpoint); + } return dto; } @@ -38,10 +56,20 @@ public static Destination convert(DestinationDto dto) { return null; } Destination destination = null; - if (Objects.equals(dto.getType(), DestinationTypeDto.NUMBER2)) { - destination = new DestinationNumber(E164PhoneNumber.valueOf(dto.getEndpoint())); - } else if (Objects.equals(dto.getType(), DestinationTypeDto.USERNAME2)) { + if (Objects.equals(dto.getType(), DestinationTypeDto.NUMBER) + || Objects.equals(dto.getType(), DestinationTypeDto.NUMBER2)) { + destination = + new DestinationNumber( + E164PhoneNumber.valueOf(dto.getEndpoint()), DestinationNumberType.PSTN); + } else if (Objects.equals(dto.getType(), DestinationTypeDto.USERNAME) + || Objects.equals(dto.getType(), DestinationTypeDto.USERNAME2)) { destination = new DestinationUser(dto.getEndpoint()); + } else if (Objects.equals(dto.getType(), DestinationTypeDto.SIP)) { + destination = new DestinationSip(dto.getEndpoint()); + } else if (Objects.equals(dto.getType(), DestinationTypeDto.DID)) { + destination = + new DestinationNumber( + E164PhoneNumber.valueOf(dto.getEndpoint()), DestinationNumberType.DID); } else { LOGGER.severe(String.format("Unexpected type value '%s'", dto.getType())); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java new file mode 100644 index 000000000..36df521e0 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/DomainTypeDtoConverter.java @@ -0,0 +1,21 @@ +package com.sinch.sdk.domains.voice.adapters.converters; + +import com.sinch.sdk.domains.voice.models.DomainType; +import com.sinch.sdk.domains.voice.models.dto.v1.DomainDto; + +public class DomainTypeDtoConverter { + + public static DomainType convert(String dto) { + if (null == dto) { + return null; + } + return DomainType.from(dto.toLowerCase()); + } + + public static DomainType convert(DomainDto dto) { + if (null == dto) { + return null; + } + return DomainType.from(dto.getValue().toLowerCase()); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverter.java similarity index 69% rename from client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverter.java rename to client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverter.java index c70f57447..e1a35983c 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverter.java @@ -29,13 +29,14 @@ import com.sinch.sdk.domains.voice.models.svaml.AnsweringMachineDetection; import com.sinch.sdk.domains.voice.models.svaml.Menu; import com.sinch.sdk.domains.voice.models.svaml.MenuOption; +import com.sinch.sdk.domains.voice.models.svaml.MenuOptionAction; import java.util.Collection; import java.util.List; import java.util.logging.Logger; import java.util.stream.Collectors; -public class SAVMLActionDtoConverter { - private static final Logger LOGGER = Logger.getLogger(SAVMLActionDtoConverter.class.getName()); +public class SVAMLActionDtoConverter { + private static final Logger LOGGER = Logger.getLogger(SVAMLActionDtoConverter.class.getName()); public static SvamlActionDto convert(Action client) { if (null == client) { @@ -82,9 +83,9 @@ private static SvamlActionConnectConfDto convertAction(ActionConnectConference c } SvamlActionConnectConfDto dto = new SvamlActionConnectConfDto(); dto.setName(SvamlActionConnectConfDto.NameEnum.CONNECTCONF.getValue()); - dto.setConferenceId(client.getConferenceId()); - dto.setMoh(EnumDynamicConverter.convert(client.getMoh())); - dto.setConferenceDtmfOptions(convert(client.getDtfmOptions())); + client.getConferenceId().ifPresent(dto::setConferenceId); + client.getMusicOnHold().ifPresent(f -> dto.setMoh(EnumDynamicConverter.convert(f))); + client.getDtfmOptions().ifPresent(f -> dto.setConferenceDtmfOptions(convert(f))); return dto; } @@ -94,8 +95,8 @@ private static SvamlActionConnectMxpDto convertAction(ActionConnectMxp client) { } SvamlActionConnectMxpDto dto = new SvamlActionConnectMxpDto(); dto.setName(SvamlActionConnectMxpDto.NameEnum.CONNECTMXP.getValue()); - dto.setDestination(DestinationDtoConverter.convert(client.getDestination())); - dto.setCallheaders(convertHeaderCollection(client.getCallheaders())); + client.getDestination().ifPresent(f -> dto.setDestination(DestinationDtoConverter.convert(f))); + client.getCallheaders().ifPresent(f -> dto.setCallheaders(convertHeaderCollection(f))); return dto; } @@ -105,15 +106,17 @@ private static SvamlActionConnectPstnDto convertAction(ActionConnectPstn client) } SvamlActionConnectPstnDto dto = new SvamlActionConnectPstnDto(); dto.setName(SvamlActionConnectPstnDto.NameEnum.CONNECTPSTN.getValue()); - dto.setNumber(E164PhoneNumberDtoConverter.convert(client.getNumber())); - dto.setLocale(client.getLocale()); - dto.setMaxDuration(client.getMaxDuration()); - dto.setDialTimeout(client.getDialTimeout()); - dto.setCli(client.getCli()); - dto.setSuppressCallbacks(client.getSuppressCallbacks()); - dto.setDtmf(DualToneMultiFrequencyDtoConverter.convert(client.getDtmf())); - dto.setIndications(EnumDynamicConverter.convert(client.getIndications())); - dto.setAmd(convert(client.getAnsweringMachineDetectionEnabled())); + client.getNumber().ifPresent(f -> dto.setNumber(E164PhoneNumberDtoConverter.convert(f))); + client.getLocale().ifPresent(dto::setLocale); + client.getMaxDuration().ifPresent(dto::setMaxDuration); + client.getDialTimeout().ifPresent(dto::setDialTimeout); + client.getCli().ifPresent(dto::setCli); + client.getSuppressCallbacks().ifPresent(dto::setSuppressCallbacks); + client + .getDualToneMultiFrequency() + .ifPresent(f -> dto.setDtmf(DualToneMultiFrequencyDtoConverter.convert(f))); + client.getIndications().ifPresent(f -> dto.setIndications(EnumDynamicConverter.convert(f))); + client.getAnsweringMachineDetection().ifPresent(f -> dto.setAmd(convert(f))); return dto; } @@ -123,13 +126,13 @@ private static SvamlActionConnectSipDto convertAction(ActionConnectSip client) { } SvamlActionConnectSipDto dto = new SvamlActionConnectSipDto(); dto.setName(SvamlActionConnectSipDto.NameEnum.CONNECTSIP.getValue()); - dto.setDestination(DestinationDtoConverter.convert(client.getDestination())); - dto.setMaxDuration(client.getMaxDuration()); - dto.setCli(client.getCli()); - dto.setTransport(EnumDynamicConverter.convert(client.getTransport())); - dto.setSuppressCallbacks(client.getSuppressCallbacks()); - dto.setCallHeaders(convertHeaderCollection(client.getCallheaders())); - dto.setMoh(EnumDynamicConverter.convert(client.getMoh())); + client.getDestination().ifPresent(f -> dto.setDestination(DestinationDtoConverter.convert(f))); + client.getMaxDuration().ifPresent(dto::setMaxDuration); + client.getCli().ifPresent(dto::setCli); + client.getTransport().ifPresent(f -> dto.setTransport(EnumDynamicConverter.convert(f))); + client.getSuppressCallbacks().ifPresent(dto::setSuppressCallbacks); + client.getCallHeaders().ifPresent(f -> dto.setCallHeaders(convertHeaderCollection(f))); + client.getMusicOnHold().ifPresent(f -> dto.setMoh(EnumDynamicConverter.convert(f))); return dto; } @@ -157,10 +160,11 @@ private static SvamlActionParkDto convertAction(ActionPark client) { } SvamlActionParkDto dto = new SvamlActionParkDto(); dto.setName(SvamlActionParkDto.NameEnum.PARK.getValue()); - dto.setLocale(client.getLocale()); - dto.setIntroPrompt(client.getIntroPrompt()); - dto.setHoldPrompt(client.getHoldPrompt()); - dto.setMaxDuration(client.getMaxDuration()); + client.getLocale().ifPresent(dto::setLocale); + client.getIntroPrompt().ifPresent(dto::setIntroPrompt); + client.getHoldPrompt().ifPresent(dto::setHoldPrompt); + client.getMaxDuration().ifPresent(dto::setMaxDuration); + return dto; } @@ -170,11 +174,11 @@ private static SvamlActionRunMenuDto convertAction(ActionRunMenu client) { } SvamlActionRunMenuDto dto = new SvamlActionRunMenuDto(); dto.setName(SvamlActionRunMenuDto.NameEnum.RUNMENU.getValue()); - dto.setBarge(client.getBarge()); - dto.setLocale(client.getLocale()); - dto.setMainMenu(client.getMainMenu()); - dto.setEnableVoice(client.getEnableVoice()); - dto.setMenus(convertMenuCollection(client.getMenus())); + client.getBarge().ifPresent(dto::setBarge); + client.getLocale().ifPresent(dto::setLocale); + client.getMainMenu().ifPresent(dto::setMainMenu); + client.getEnableVoice().ifPresent(dto::setEnableVoice); + client.getMenus().ifPresent(f -> dto.setMenus(convertMenuCollection(f))); return dto; } @@ -207,7 +211,8 @@ private static SvamlActionConnectPstnAmdDto convert(AnsweringMachineDetection cl } SvamlActionConnectPstnAmdDto dto = new SvamlActionConnectPstnAmdDto(); - dto.setEnabled(client.getEnabled()); + + client.getEnabled().ifPresent(dto::setEnabled); return dto; } @@ -215,7 +220,7 @@ private static List convertMenuCollection(Collection

client) { if (null == client) { return null; } - return client.stream().map(SAVMLActionDtoConverter::convert).collect(Collectors.toList()); + return client.stream().map(SVAMLActionDtoConverter::convert).collect(Collectors.toList()); } private static MenuDto convert(Menu client) { @@ -223,14 +228,15 @@ private static MenuDto convert(Menu client) { return null; } MenuDto dto = new MenuDto(); - dto.setId(client.getId()); - dto.setMainPrompt(client.getMainPrompt()); - dto.setRepeatPrompt(client.getRepeatPrompt()); - dto.setRepeats(client.getRepeats()); - dto.setMaxDigits(client.getMaxDigits()); - dto.setTimeoutMills(client.getTimeoutMills()); - dto.setMaxTimeoutMills(client.getMaxTimeoutMills()); - dto.setOptions(convertMenuOptionCollection(client.getOptions())); + + client.getId().ifPresent(dto::setId); + client.getMainPrompt().ifPresent(dto::setMainPrompt); + client.getRepeatPrompt().ifPresent(dto::setRepeatPrompt); + client.getRepeats().ifPresent(dto::setRepeats); + client.getMaxDigits().ifPresent(dto::setMaxDigits); + client.getTimeoutMills().ifPresent(dto::setTimeoutMills); + client.getMaxTimeoutMills().ifPresent(dto::setMaxTimeoutMills); + client.getOptions().ifPresent(f -> dto.setOptions(convertMenuOptionCollection(f))); return dto; } @@ -240,10 +246,19 @@ private static List convertMenuOptionCollection(Collection - new OptionDto() - .action(EnumDynamicConverter.convert(f.getAction())) - .dtmf(DualToneMultiFrequencyDtoConverter.convert(f.getDtfm()))) + f -> { + OptionDto dto = new OptionDto(); + f.getAction().ifPresent(f2 -> dto.action(convert(f2))); + f.getDtfm().ifPresent(f2 -> dto.dtmf(DualToneMultiFrequencyDtoConverter.convert(f2))); + return dto; + }) .collect(Collectors.toList()); } + + private static String convert(MenuOptionAction client) { + if (null == client || null == client.getType()) { + return null; + } + return String.format("%s(%s)", client.getType().value(), client.getId()); + } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java similarity index 87% rename from client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverter.java rename to client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java index 88dda5552..0a90f57ac 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverter.java +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverter.java @@ -27,17 +27,17 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -public class SAVMLInstructionDtoConverter { +public class SVAMLInstructionDtoConverter { private static final Logger LOGGER = - Logger.getLogger(SAVMLInstructionDtoConverter.class.getName()); + Logger.getLogger(SVAMLInstructionDtoConverter.class.getName()); public static List convert(Collection instructions) { if (null == instructions) { return null; } return instructions.stream() - .map(SAVMLInstructionDtoConverter::convertInstruction) + .map(SVAMLInstructionDtoConverter::convertInstruction) .collect(Collectors.toList()); } @@ -92,10 +92,8 @@ private static SvamlInstructionPlayFilesDto convert(InstructionPlayFiles client) } SvamlInstructionPlayFilesDto dto = new SvamlInstructionPlayFilesDto(); dto.setName(NameEnum.PLAYFILES.getValue()); - if (null != client.getIds()) { - dto.ids(new ArrayList<>(client.getIds())); - } - dto.locale(client.getLocale()); + client.getIds().ifPresent(f -> dto.setIds(new ArrayList<>(f))); + client.getLocale().ifPresent(dto::locale); return dto; } @@ -105,8 +103,8 @@ private static SvamlInstructionSayDto convert(InstructionSay client) { } SvamlInstructionSayDto dto = new SvamlInstructionSayDto(); dto.setName(SvamlInstructionSayDto.NameEnum.SAY.getValue()); - dto.setText(client.getText()); - dto.setLocale(client.getLocale()); + client.getText().ifPresent(dto::setText); + client.getLocale().ifPresent(dto::setLocale); return dto; } @@ -116,9 +114,7 @@ private static SvamlInstructionSendDtmfDto convert(InstructionSendDtfm client) { } SvamlInstructionSendDtmfDto dto = new SvamlInstructionSendDtmfDto(); dto.setName(SvamlInstructionSendDtmfDto.NameEnum.SENDDTMF.getValue()); - if (null != client.getTDtfm()) { - dto.setValue(client.getTDtfm().stringValue()); - } + client.getTDtfm().ifPresent(f -> dto.setValue(f.stringValue())); return dto; } @@ -128,6 +124,7 @@ private static SvamlInstructionSetCookieDto convert(InstructionSetCookie client) } SvamlInstructionSetCookieDto dto = new SvamlInstructionSetCookieDto(); dto.setName(SvamlInstructionSetCookieDto.NameEnum.SETCOOKIE.getValue()); + dto.setKey(client.getKey()); dto.setValue(client.getValue()); return dto; @@ -139,7 +136,7 @@ private static SvamlInstructionStartRecordingDto convert(InstructionStartRecordi } SvamlInstructionStartRecordingDto dto = new SvamlInstructionStartRecordingDto(); dto.setName(SvamlInstructionStartRecordingDto.NameEnum.STARTRECORDING.getValue()); - dto.setOptions(convert(client.getOptions())); + client.getOptions().ifPresent(f -> dto.setOptions(convert(f))); return dto; } @@ -157,11 +154,12 @@ private static SvamlInstructionStartRecordingOptionsDto convert(StartRecordingOp return null; } SvamlInstructionStartRecordingOptionsDto dto = new SvamlInstructionStartRecordingOptionsDto(); - dto.setDestinationUrl(client.getDestinationUrl()); - dto.setCredentials(client.getCredentials()); - dto.setFormat(client.getFormat()); - dto.setNotificationEvents(client.getNotificationEvents()); - dto.setTranscriptionOptions(convert(client.getTranscriptionOptions())); + + client.getDestinationUrl().ifPresent(dto::setDestinationUrl); + client.getCredentials().ifPresent(dto::setCredentials); + client.getFormat().ifPresent(dto::setFormat); + client.getNotificationEvents().ifPresent(dto::setNotificationEvents); + client.getTranscriptionOptions().ifPresent(f -> dto.setTranscriptionOptions(convert(f))); return dto; } @@ -172,8 +170,8 @@ private static SvamlInstructionStartRecordingOptionsTranscriptionOptionsDto conv } SvamlInstructionStartRecordingOptionsTranscriptionOptionsDto dto = new SvamlInstructionStartRecordingOptionsTranscriptionOptionsDto(); - dto.setEnabled(client.getEnabled()); - dto.locale(client.getLocale()); + client.getEnabled().ifPresent(dto::setEnabled); + client.getLocale().ifPresent(dto::locale); return dto; } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java new file mode 100644 index 000000000..07e389c98 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverter.java @@ -0,0 +1,184 @@ +package com.sinch.sdk.domains.voice.adapters.converters; + +import com.sinch.sdk.core.exceptions.ApiException; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.common.adapters.converters.OffsetDateTimeDtoConverter; +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; +import com.sinch.sdk.domains.voice.models.dto.v1.AceRequestAllOfAmdDto; +import com.sinch.sdk.domains.voice.models.dto.v1.AceRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.CallHeaderDto; +import com.sinch.sdk.domains.voice.models.dto.v1.DiceRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.IceRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.NotifyRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.PieRequestAllOfMenuResultDto; +import com.sinch.sdk.domains.voice.models.dto.v1.PieRequestDto; +import com.sinch.sdk.domains.voice.models.dto.v1.WebhooksEventDto; +import com.sinch.sdk.domains.voice.models.dto.v1.WebhooksEventRequestDto; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswer; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerReasonType; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerStatusType; +import com.sinch.sdk.domains.voice.models.webhooks.AnsweredCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.DisconnectCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.IncomingCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.MenuInputType; +import com.sinch.sdk.domains.voice.models.webhooks.MenuResult; +import com.sinch.sdk.domains.voice.models.webhooks.MenuResultInputMethodType; +import com.sinch.sdk.domains.voice.models.webhooks.NotifyEvent; +import com.sinch.sdk.domains.voice.models.webhooks.PromptInputEvent; +import com.sinch.sdk.domains.voice.models.webhooks.WebhooksEvent; +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +public class WebhooksEventDtoConverter { + + public static WebhooksEvent convert(WebhooksEventDto dto) { + + if (null == dto) { + return null; + } + + WebhooksEvent.Builder builder; + + WebhooksEventRequestDto instance = (WebhooksEventRequestDto) dto.getActualInstance(); + if (instance instanceof IceRequestDto) { + builder = convert((IceRequestDto) instance); + } else if (instance instanceof DiceRequestDto) { + builder = convert((DiceRequestDto) instance); + } else if (instance instanceof AceRequestDto) { + builder = convert((AceRequestDto) instance); + } else if (instance instanceof PieRequestDto) { + builder = convert((PieRequestDto) instance); + } else if (instance instanceof NotifyRequestDto) { + builder = convert((NotifyRequestDto) instance); + } else { + throw new ApiException("Unexpected event:" + dto); + } + + return builder.setCallId(instance.getCallid()).setVersion(instance.getVersion()).build(); + } + + private static IncomingCallEvent.Builder convert(IceRequestDto dto) { + + IncomingCallEvent.Builder builder = IncomingCallEvent.builder(); + if (null == dto) { + return builder; + } + + return builder + .setTimestamp(OffsetDateTimeDtoConverter.convert(dto.getTimestamp())) + .setCustom(dto.getCustom()) + .setCallResourceUrl(dto.getCallResourceUrl()) + .setUserRate(PriceDtoConverter.convert(dto.getUserRate())) + .setCli(dto.getCli()) + .setTo(DestinationDtoConverter.convert(dto.getTo())) + .setDomain(DomainTypeDtoConverter.convert(dto.getDomain())) + .setApplicationKey(dto.getApplicationKey()) + .setOriginationType(DomainTypeDtoConverter.convert(dto.getOriginationType())) + .setDuration(dto.getDuration()) + .setRdnis(dto.getRdnis()) + .setCallHeaders(convertHeaderCollection(dto.getCallHeaders())); + } + + private static DisconnectCallEvent.Builder convert(DiceRequestDto dto) { + + DisconnectCallEvent.Builder builder = DisconnectCallEvent.builder(); + if (null == dto) { + return builder; + } + return builder + .setTimestamp(OffsetDateTimeDtoConverter.convert(dto.getTimestamp())) + .setCustom(dto.getCustom()) + .setReason(null != dto.getReason() ? CallReasonType.from(dto.getReason()) : null) + .setResult(null != dto.getResult() ? CallResultType.from(dto.getResult().getValue()) : null) + .setDebit(PriceDtoConverter.convert(dto.getDebit())) + .setUserRate(PriceDtoConverter.convert(dto.getUserRate())) + .setTo(DestinationDtoConverter.convert(dto.getTo())) + .setApplicationKey(dto.getApplicationKey()) + .setDuration(dto.getDuration()) + .setFrom(dto.getFrom()); + } + + private static AnsweredCallEvent.Builder convert(AceRequestDto dto) { + + AnsweredCallEvent.Builder builder = AnsweredCallEvent.builder(); + if (null == dto) { + return builder; + } + return builder + .setTimestamp(OffsetDateTimeDtoConverter.convert(dto.getTimestamp())) + .setCustom(dto.getCustom()) + .setAmd(convert(dto.getAmd())); + } + + private static PromptInputEvent.Builder convert(PieRequestDto dto) { + + PromptInputEvent.Builder builder = PromptInputEvent.builder(); + if (null == dto) { + return builder; + } + return builder + .setTimestamp(OffsetDateTimeDtoConverter.convert(dto.getTimestamp())) + .setCustom(dto.getCustom()) + .setApplicationKey(dto.getApplicationKey()) + .setCallId(dto.getCallid()) + .setVersion(dto.getVersion()) + .setMenuResult(convert(dto.getMenuResult())); + } + + private static NotifyEvent.Builder convert(NotifyRequestDto dto) { + + NotifyEvent.Builder builder = NotifyEvent.builder(); + if (null == dto) { + return builder; + } + return builder + .setCustom(dto.getCustom()) + .setCallId(dto.getCallid()) + .setVersion(dto.getVersion()) + .setType(dto.getType()); + } + + private static AmdAnswer convert(AceRequestAllOfAmdDto dto) { + + if (null == dto) { + return null; + } + return AmdAnswer.builder() + .setReason(convertReason(dto.getReason())) + .setStatus(convertStatus(dto.getStatus())) + .setDuration(dto.getDuration()) + .build(); + } + + private static AmdAnswerReasonType convertReason(String dto) { + if (null == dto) { + return null; + } + return AmdAnswerReasonType.from(dto); + } + + private static AmdAnswerStatusType convertStatus(String dto) { + if (null == dto) { + return null; + } + return AmdAnswerStatusType.from(dto); + } + + private static Collection> convertHeaderCollection(List dto) { + if (null == dto) { + return null; + } + return dto.stream().map(f -> new Pair<>(f.getKey(), f.getValue())).collect(Collectors.toList()); + } + + private static MenuResult convert(PieRequestAllOfMenuResultDto dto) { + return MenuResult.builder() + .setMenuId(dto.getMenuId()) + .setType(MenuInputType.from(dto.getType())) + .setValue(dto.getValue()) + .setInputMethod(MenuResultInputMethodType.from(dto.getInputMethod())) + .build(); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java b/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java index ab392da23..b45908dc9 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/ApplicationAssignedNumber.java @@ -2,6 +2,7 @@ import com.sinch.sdk.models.E164PhoneNumber; +/** Information about your number. */ public class ApplicationAssignedNumber { private final E164PhoneNumber number; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallReasonType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java similarity index 60% rename from client/src/main/com/sinch/sdk/domains/voice/models/response/CallReasonType.java rename to client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java index 4d1e4262b..faed1c979 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallReasonType.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/CallReasonType.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.voice.models.response; +package com.sinch.sdk.domains.voice.models; import com.sinch.sdk.core.utils.EnumDynamic; import com.sinch.sdk.core.utils.EnumSupportDynamic; @@ -10,13 +10,14 @@ public class CallReasonType extends EnumDynamic { public static final CallReasonType NA = new CallReasonType("N/A"); public static final CallReasonType TIMEOUT = new CallReasonType("TIMEOUT"); - public static final CallReasonType CALLERHANGUP = new CallReasonType("CALLERHANGUP"); - public static final CallReasonType CALLEEHANGUP = new CallReasonType("CALLEEHANGUP"); + public static final CallReasonType CALLER_HANGUP = new CallReasonType("CALLERHANGUP"); + public static final CallReasonType CALLEE_HANGUP = new CallReasonType("CALLEEHANGUP"); public static final CallReasonType BLOCKED = new CallReasonType("BLOCKED"); - public static final CallReasonType NOCREDITPARTNER = new CallReasonType("NOCREDITPARTNER"); - public static final CallReasonType MANAGERHANGUP = new CallReasonType("MANAGERHANGUP"); + public static final CallReasonType NO_CREDIT_PARTNER = new CallReasonType("NOCREDITPARTNER"); + public static final CallReasonType MANAGER_HANGUP = new CallReasonType("MANAGERHANGUP"); public static final CallReasonType CANCEL = new CallReasonType("CANCEL"); - public static final CallReasonType GENERALERROR = new CallReasonType("GENERALERROR"); + public static final CallReasonType GENERAL_ERROR = new CallReasonType("GENERALERROR"); + public static final CallReasonType INVALID_SVAMLACTION = new CallReasonType("INVALIDSVAMLACTION"); private static final EnumSupportDynamic ENUM_SUPPORT = new EnumSupportDynamic<>( @@ -25,13 +26,14 @@ public class CallReasonType extends EnumDynamic { Arrays.asList( NA, TIMEOUT, - CALLERHANGUP, - CALLEEHANGUP, + CALLER_HANGUP, + CALLEE_HANGUP, BLOCKED, - NOCREDITPARTNER, - MANAGERHANGUP, + NO_CREDIT_PARTNER, + MANAGER_HANGUP, CANCEL, - GENERALERROR)); + GENERAL_ERROR, + INVALID_SVAMLACTION)); private CallReasonType(String value) { super(value); diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallResultType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java similarity index 95% rename from client/src/main/com/sinch/sdk/domains/voice/models/response/CallResultType.java rename to client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java index 486f1eeda..6f311ec91 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallResultType.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/CallResultType.java @@ -1,4 +1,4 @@ -package com.sinch.sdk.domains.voice.models.response; +package com.sinch.sdk.domains.voice.models; import com.sinch.sdk.core.utils.EnumDynamic; import com.sinch.sdk.core.utils.EnumSupportDynamic; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/CalloutMethodType.java b/client/src/main/com/sinch/sdk/domains/voice/models/CalloutMethodType.java deleted file mode 100644 index ac12c790e..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/CalloutMethodType.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -public class CalloutMethodType extends EnumDynamic { - - public static final CalloutMethodType CONFERENCE_CALLOUT = - new CalloutMethodType("conferenceCallout"); - public static final CalloutMethodType TTS_CALLOUT = new CalloutMethodType("ttsCallout"); - public static final CalloutMethodType CUSTOM_CALLOUT = new CalloutMethodType("customCallout"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - CalloutMethodType.class, - CalloutMethodType::new, - Arrays.asList(CONFERENCE_CALLOUT, TTS_CALLOUT, CUSTOM_CALLOUT)); - - private CalloutMethodType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static CalloutMethodType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(CalloutMethodType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java index 8b5a00e6a..f435c1191 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumber.java @@ -3,22 +3,50 @@ import com.sinch.sdk.models.E164PhoneNumber; import java.util.Objects; -/** Destination of type number for PSTN endpoints */ +/** Destination of numbers type */ public class DestinationNumber extends Destination { + private final E164PhoneNumber phoneNumber; + private final DestinationNumberType type; + /** + * Create a destination instance of type PSTN + * + * @param phoneNumber Valid E164 phone number + */ public DestinationNumber(E164PhoneNumber phoneNumber) { + this(phoneNumber, DestinationNumberType.PSTN); + } + + /** + * Create a destination instance of specified type + * + * @param phoneNumber Valid E164 phone number + * @param type Phone number type + */ + public DestinationNumber(E164PhoneNumber phoneNumber, DestinationNumberType type) { Objects.requireNonNull(phoneNumber); this.phoneNumber = phoneNumber; + this.type = type; } public E164PhoneNumber getPhoneNumber() { return phoneNumber; } + public DestinationNumberType getType() { + return type; + } + @Override public String toString() { - return "DestinationNumber{" + "phoneNumber=" + phoneNumber + "} " + super.toString(); + return "DestinationNumber{" + + "phoneNumber=" + + phoneNumber + + ", type=" + + type + + "} " + + super.toString(); } public static DestinationNumber valueOf(String e164PhoneNumber) { @@ -34,11 +62,11 @@ public boolean equals(Object o) { return false; } DestinationNumber that = (DestinationNumber) o; - return Objects.equals(phoneNumber, that.phoneNumber); + return Objects.equals(phoneNumber, that.phoneNumber) && type == that.type; } @Override public int hashCode() { - return Objects.hash(phoneNumber); + return Objects.hash(phoneNumber, type); } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java new file mode 100644 index 000000000..5ffd8c378 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/DestinationNumberType.java @@ -0,0 +1,36 @@ +package com.sinch.sdk.domains.voice.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** Destination types */ +public class DestinationNumberType extends EnumDynamic { + + /** * Public Switched Telephone Network */ + public static final DestinationNumberType PSTN = new DestinationNumberType("PSTN"); + + /** * Direct Inward Dialing */ + public static final DestinationNumberType DID = new DestinationNumberType("DID"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + DestinationNumberType.class, DestinationNumberType::new, Arrays.asList(PSTN, DID)); + + private DestinationNumberType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static DestinationNumberType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(DestinationNumberType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java b/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java index 1bac26c28..b5f433c48 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/DomainType.java @@ -14,9 +14,13 @@ public class DomainType extends EnumDynamic { /** data (app or web) clients */ public static final DomainType MXP = new DomainType("mxp"); + /** Conference */ + public static final DomainType CONFERENCE = new DomainType("conference"); + /** */ private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>(DomainType.class, DomainType::new, Arrays.asList(PSTN, MXP)); + new EnumSupportDynamic<>( + DomainType.class, DomainType::new, Arrays.asList(PSTN, MXP, CONFERENCE)); private DomainType(String value) { super(value); diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/MohClassType.java b/client/src/main/com/sinch/sdk/domains/voice/models/MohClassType.java deleted file mode 100644 index 09d3c94e0..000000000 --- a/client/src/main/com/sinch/sdk/domains/voice/models/MohClassType.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.sinch.sdk.domains.voice.models; - -import com.sinch.sdk.core.utils.EnumDynamic; -import com.sinch.sdk.core.utils.EnumSupportDynamic; -import java.util.Arrays; -import java.util.stream.Stream; - -/** Means "music-on-hold." */ -public class MohClassType extends EnumDynamic { - - /** progress tone */ - public static final MohClassType RING = new MohClassType("ring"); - - /** Music file */ - public static final MohClassType MUSIC1 = new MohClassType("music1"); - - /** Music file */ - public static final MohClassType MUSIC2 = new MohClassType("music2"); - - /** Music file */ - public static final MohClassType MUSIC3 = new MohClassType("music3"); - - /** */ - private static final EnumSupportDynamic ENUM_SUPPORT = - new EnumSupportDynamic<>( - MohClassType.class, MohClassType::new, Arrays.asList(RING, MUSIC1, MUSIC2, MUSIC3)); - - private MohClassType(String value) { - super(value); - } - - public static Stream values() { - return ENUM_SUPPORT.values(); - } - - public static MohClassType from(String value) { - return ENUM_SUPPORT.from(value); - } - - public static String valueOf(MohClassType e) { - return ENUM_SUPPORT.valueOf(e); - } -} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java b/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java new file mode 100644 index 000000000..e4669681b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/MusicOnHoldType.java @@ -0,0 +1,43 @@ +package com.sinch.sdk.domains.voice.models; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** Means "music-on-hold." */ +public class MusicOnHoldType extends EnumDynamic { + + /** progress tone */ + public static final MusicOnHoldType RING = new MusicOnHoldType("ring"); + + /** Music file */ + public static final MusicOnHoldType MUSIC1 = new MusicOnHoldType("music1"); + + /** Music file */ + public static final MusicOnHoldType MUSIC2 = new MusicOnHoldType("music2"); + + /** Music file */ + public static final MusicOnHoldType MUSIC3 = new MusicOnHoldType("music3"); + + /** */ + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + MusicOnHoldType.class, MusicOnHoldType::new, Arrays.asList(RING, MUSIC1, MUSIC2, MUSIC3)); + + private MusicOnHoldType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static MusicOnHoldType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(MusicOnHoldType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java index 71b90c61d..f17289a96 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParameters.java @@ -1,55 +1,76 @@ package com.sinch.sdk.domains.voice.models.requests; import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.Destination; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; public class CalloutRequestParameters { - private final OptionalValue method; private final OptionalValue destination; private final OptionalValue cli; private final OptionalValue dtfm; private final OptionalValue custom; protected CalloutRequestParameters( - OptionalValue method, OptionalValue destination, OptionalValue cli, OptionalValue dtfm, OptionalValue custom) { - this.method = method; this.destination = destination; this.cli = cli; this.dtfm = dtfm; this.custom = custom; } - public OptionalValue getMethod() { - return method; - } - + /** + * Destination getter + * + * @see Builder#setDestination(Destination) + */ public OptionalValue getDestination() { return destination; } + /** + * Cli getter + * + * @see Builder#setCli(E164PhoneNumber) + */ public OptionalValue getCli() { return cli; } + /** + * Dual Tone Multi Frequency getter + * + * @see Builder#setDtfm(DualToneMultiFrequency) + */ public OptionalValue getDtfm() { return dtfm; } + /** + * Custom value getter + * + * @see Builder#setCustom(String) + */ public OptionalValue getCustom() { return custom; } @Override public String toString() { - return "CalloutRequestParameters{" + "method=" + method + '}'; + return "CalloutRequestParameters{" + + "destination=" + + destination + + ", cli=" + + cli + + ", dtfm=" + + dtfm + + ", custom=" + + custom + + '}'; } public static Builder builder() { @@ -86,11 +107,6 @@ public B setCli(E164PhoneNumber cli) { /** * @param dtfm When the destination picks up, this DTMF tones will be played to the callee. - * Valid characters in the string are "0"-"9", "#" and "w". A "w" will render a 500 ms - * pause. Example: "ww1234#w#" will render a 1s pause, the DTMF tones "1", "2", "3", "4" and - * "#" followed by a 0.5s pause and finally the DTMF tone for "#". This can be used if the - * callout destination for instance require a conference PIN code or an extension to be - * entered. * @return current builder */ public B setDtfm(DualToneMultiFrequency dtfm) { diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java index 9da95b560..c90c1445d 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConference.java @@ -1,11 +1,10 @@ package com.sinch.sdk.domains.voice.models.requests; import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; import com.sinch.sdk.domains.voice.models.Destination; import com.sinch.sdk.domains.voice.models.DomainType; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; @@ -23,7 +22,7 @@ public class CalloutRequestParametersConference extends CalloutRequestParameters private final OptionalValue enablePie; private final OptionalValue locale; private final OptionalValue greeting; - private final OptionalValue mohClass; + private final OptionalValue musicOnHold; private final OptionalValue domain; private CalloutRequestParametersConference( @@ -39,9 +38,9 @@ private CalloutRequestParametersConference( OptionalValue enablePie, OptionalValue locale, OptionalValue greeting, - OptionalValue mohClass, + OptionalValue musicOnHold, OptionalValue domain) { - super(OptionalValue.of(CalloutMethodType.CONFERENCE_CALLOUT), destination, cli, dtfm, custom); + super(destination, cli, dtfm, custom); this.conferenceId = conferenceId; this.dtfmOptions = dtfmOptions; @@ -51,46 +50,76 @@ private CalloutRequestParametersConference( this.enablePie = enablePie; this.locale = locale; this.greeting = greeting; - this.mohClass = mohClass; + this.musicOnHold = musicOnHold; this.domain = domain; } + /** + * @see Builder#setConferenceId(String) + */ public OptionalValue getConferenceId() { return conferenceId; } + /** + * @see Builder#setDtfm(DualToneMultiFrequency) + */ public OptionalValue getDtfmOptions() { return dtfmOptions; } + /** + * @see Builder#setMaxDuration(Integer) + */ public OptionalValue getMaxDuration() { return maxDuration; } + /** + * @see Builder#setEnableAce(Boolean) + */ public OptionalValue getEnableAce() { return enableAce; } + /** + * @see Builder#setEnableDice(Boolean) + */ public OptionalValue getEnableDice() { return enableDice; } + /** + * @see Builder#setEnablePie(Boolean) + */ public OptionalValue getEnablePie() { return enablePie; } + /** + * @see Builder#setLocale(String) + */ public OptionalValue getLocale() { return locale; } + /** + * @see Builder#setGreeting(String) + */ public OptionalValue getGreeting() { return greeting; } - public OptionalValue getMohClass() { - return mohClass; + /** + * @see Builder#setMusicOnHold(MusicOnHoldType) (MusicOnHoldType) + */ + public OptionalValue getMusicOnHold() { + return musicOnHold; } + /** + * @see Builder#setDomain(DomainType) + */ public OptionalValue getDomain() { return domain; } @@ -117,8 +146,8 @@ public String toString() { + ", greeting='" + greeting + '\'' - + ", mohClass=" - + mohClass + + ", musicOnHold=" + + musicOnHold + ", domain=" + domain + "} " @@ -139,7 +168,7 @@ public static class Builder extends CalloutRequestParameters.Builder { OptionalValue enablePie = OptionalValue.empty(); OptionalValue locale = OptionalValue.empty(); OptionalValue greeting = OptionalValue.empty(); - OptionalValue mohClass = OptionalValue.empty(); + OptionalValue musicOnHold = OptionalValue.empty(); OptionalValue domain = OptionalValue.empty(); public Builder() { @@ -147,8 +176,10 @@ public Builder() { } /** - * @param conferenceId The conferenceId of the conference to which you want the callee to join. - * If the * conferenceId doesn't exist a conference room will be created. + * The conferenceId of the conference to which you want the callee to join. * If the * + * conferenceId doesn't exist a conference room will be created. + * + * @param conferenceId The conference value * @return current builder */ public Builder setConferenceId(String conferenceId) { @@ -157,8 +188,10 @@ public Builder setConferenceId(String conferenceId) { } /** - * @param dtfmOptions Options to control how DTMF signals are used by the participant in the - * conference + * Define Dual Tone Multi Frequency options to control how DTMF signals are used by the + * participant in the conference + * + * @param dtfmOptions DTFM definition * @return current builder */ public Builder setDtfmOptions(ConferenceDtfmOptions dtfmOptions) { @@ -252,15 +285,17 @@ public Builder setGreeting(String greeting) { * should listen to while they're alone in the conference, waiting for other participants to * join. * - * @param mohClass The music-on-hold to be used + * @param musicOnHold The music-on-hold to be used * @return current builder */ - public Builder setMohClass(MohClassType mohClass) { - this.mohClass = OptionalValue.of(mohClass); + public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { + this.musicOnHold = OptionalValue.of(musicOnHold); return self(); } /** + * Domain related call + * * @param domain Domain to be used * @return current builder */ @@ -283,7 +318,7 @@ public CalloutRequestParametersConference build() { enablePie, locale, greeting, - mohClass, + musicOnHold, domain); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java index da17fb1e3..30d1ef180 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustom.java @@ -1,8 +1,8 @@ package com.sinch.sdk.domains.voice.models.requests; import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.Destination; +import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference.Builder; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; @@ -13,9 +13,9 @@ public class CalloutRequestParametersCustom extends CalloutRequestParameters { private final OptionalValue maxDuration; - private final OptionalValue ice; - private final OptionalValue ace; - private final OptionalValue pie; + private final OptionalValue ice; + private final OptionalValue ace; + private final OptionalValue pie; private CalloutRequestParametersCustom( OptionalValue destination, @@ -23,10 +23,10 @@ private CalloutRequestParametersCustom( OptionalValue dtfm, OptionalValue custom, OptionalValue maxDuration, - OptionalValue ice, - OptionalValue ace, - OptionalValue pie) { - super(OptionalValue.of(CalloutMethodType.CUSTOM_CALLOUT), destination, cli, dtfm, custom); + OptionalValue ice, + OptionalValue ace, + OptionalValue pie) { + super(destination, cli, dtfm, custom); this.maxDuration = maxDuration; this.ice = ice; @@ -34,19 +34,39 @@ private CalloutRequestParametersCustom( this.pie = pie; } + /** + * See builder + * + * @see Builder#setMaxDuration(Integer) + */ public OptionalValue getMaxDuration() { return maxDuration; } - public OptionalValue getIce() { + /** + * See builder + * + * @see Builder#setIce(Control) + */ + public OptionalValue getIce() { return ice; } - public OptionalValue getAce() { + /** + * See builder + * + * @see Builder#setAce(Control) + */ + public OptionalValue getAce() { return ace; } - public OptionalValue getPie() { + /** + * See builder + * + * @see Builder#setPie(Control) + */ + public OptionalValue getPie() { return pie; } @@ -75,9 +95,9 @@ public static Builder builder() { public static class Builder extends CalloutRequestParameters.Builder { OptionalValue maxDuration = OptionalValue.empty(); - OptionalValue ice = OptionalValue.empty(); - OptionalValue ace = OptionalValue.empty(); - OptionalValue pie = OptionalValue.empty(); + OptionalValue ice = OptionalValue.empty(); + OptionalValue ace = OptionalValue.empty(); + OptionalValue pie = OptionalValue.empty(); public Builder() { super(); @@ -109,7 +129,7 @@ public Builder setMaxDuration(Integer maxDuration) { * @param ice The Incoming Call Event value * @return current builder */ - public Builder setIce(String ice) { + public Builder setIce(Control ice) { this.ice = OptionalValue.of(ice); return self(); } @@ -126,7 +146,7 @@ public Builder setIce(String ice) { * @param ace The Answered Call Event value * @return current builder */ - public Builder setAce(String ace) { + public Builder setAce(Control ace) { this.ace = OptionalValue.of(ace); return self(); } @@ -146,7 +166,7 @@ public Builder setAce(String ace) { * @param pie Prompt Input Event value * @return current builder */ - public Builder setPie(String pie) { + public Builder setPie(Control pie) { this.pie = OptionalValue.of(pie); return self(); } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java index b9303031f..fe6dee04a 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTS.java @@ -1,9 +1,9 @@ package com.sinch.sdk.domains.voice.models.requests; import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.Destination; import com.sinch.sdk.domains.voice.models.DomainType; +import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersCustom.Builder; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; @@ -33,7 +33,7 @@ private CalloutRequestParametersTTS( OptionalValue domain, OptionalValue text, OptionalValue prompts) { - super(OptionalValue.of(CalloutMethodType.TTS_CALLOUT), destination, cli, dtfm, custom); + super(destination, cli, dtfm, custom); this.enableAce = enableAce; this.enableDice = enableDice; @@ -44,30 +44,51 @@ private CalloutRequestParametersTTS( this.domain = domain; } + /** + * @see Builder#setEnableAce(Boolean) + */ public OptionalValue getEnableAce() { return enableAce; } + /** + * @see Builder#setEnableDice(Boolean) + */ public OptionalValue getEnableDice() { return enableDice; } + /** + * @see Builder#setEnablePie(Boolean) + */ public OptionalValue getEnablePie() { return enablePie; } + /** + * @see Builder#setLocale(String) + */ public OptionalValue getLocale() { return locale; } + /** + * @see Builder#setDomain(DomainType) + */ public OptionalValue getDomain() { return domain; } + /** + * @see Builder#setText(String) + */ public OptionalValue getText() { return text; } + /** + * @see Builder#setPrompts(String) + */ public OptionalValue getPrompts() { return prompts; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java index db6bdbf4e..af8d27d8f 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParameters.java @@ -1,27 +1,33 @@ package com.sinch.sdk.domains.voice.models.requests; import com.sinch.sdk.core.models.OptionalValue; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; /** Use to configure conference participant settings */ public class ConferenceManageParticipantRequestParameters { private final OptionalValue command; - private final OptionalValue moh; + private final OptionalValue musicOnHold; private ConferenceManageParticipantRequestParameters( OptionalValue command, - OptionalValue moh) { + OptionalValue musicOnHold) { this.command = command; - this.moh = moh; + this.musicOnHold = musicOnHold; } + /** + * @see Builder#setCommand(ConferenceManageParticipantCommandType) + */ public OptionalValue getCommand() { return command; } - public OptionalValue getMoh() { - return moh; + /** + * @see Builder#setMusicOnHold(MusicOnHoldType) (MusicOnHoldType) + */ + public OptionalValue getMusicOnHold() { + return musicOnHold; } @Override @@ -29,8 +35,8 @@ public String toString() { return "ConferenceManageParticipantRequestParameters{" + "command=" + command - + ", moh=" - + moh + + ", musicOnHold=" + + musicOnHold + '}'; } @@ -41,7 +47,7 @@ public static Builder builder() { public static class Builder { OptionalValue command = OptionalValue.empty(); - OptionalValue moh = OptionalValue.empty(); + OptionalValue musicOnHold = OptionalValue.empty(); /** * @param command Action to apply on conference participant. @@ -53,19 +59,19 @@ public Builder setCommand(ConferenceManageParticipantCommandType command) { } /** - * @param moh Means "music on hold". If this optional parameter is included, plays music to the - * first participant in a conference while they're alone and waiting for other participants - * to join. If moh isn't specified, the user will only hear silence while alone in the + * @param musicOnHold If this optional parameter is included, plays music to the first + * participant in a conference while they're alone and waiting for other participants to + * join. If musicOnHold isn't specified, the user will only hear silence while alone in the * conference. This property is only available to use with the onhold command. * @return current builder */ - public Builder setMoh(MohClassType moh) { - this.moh = OptionalValue.of(moh); + public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { + this.musicOnHold = OptionalValue.of(musicOnHold); return this; } public ConferenceManageParticipantRequestParameters build() { - return new ConferenceManageParticipantRequestParameters(command, moh); + return new ConferenceManageParticipantRequestParameters(command, musicOnHold); } } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java new file mode 100644 index 000000000..c3ed0483f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/Control.java @@ -0,0 +1,8 @@ +package com.sinch.sdk.domains.voice.models.requests; + +/** + * Base class related to a control + * + *

Could be a URL or a SVAML control object + */ +public abstract class Control {} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java new file mode 100644 index 000000000..8f38600f8 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/requests/ControlUrl.java @@ -0,0 +1,39 @@ +package com.sinch.sdk.domains.voice.models.requests; + +/** + * Control URL used during a custom callout + * + * @see Custom + * Callout Description + */ +public class ControlUrl extends Control { + + private final String URL; + + private ControlUrl(String URL) { + this.URL = URL; + } + + /** + * @see #from(String) + */ + public String getURL() { + return URL; + } + + @Override + public String toString() { + return "ControlUrl{" + "URL='" + URL + '\'' + "} " + super.toString(); + } + + /** + * Create a Custom URL instance from String + * + * @param URL URL representation + * @return A newly created instance + */ + public static ControlUrl from(String URL) { + return new ControlUrl(URL); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java b/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java index 383d75084..7bb1d9f27 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/response/CallInformation.java @@ -1,5 +1,7 @@ package com.sinch.sdk.domains.voice.models.response; +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; import com.sinch.sdk.domains.voice.models.Destination; import com.sinch.sdk.domains.voice.models.DomainType; import com.sinch.sdk.domains.voice.models.Price; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java index 9d3e39c7e..f1aa461d6 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Action.java @@ -1,6 +1,6 @@ package com.sinch.sdk.domains.voice.models.svaml; -/** Base class for SAVML Action */ +/** Base class for SVAML Action */ public abstract class Action { @Override diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java index 249db07ca..849befc34 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectConference.java @@ -1,31 +1,34 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; public class ActionConnectConference extends Action { - private final String conferenceId; - private final ConferenceDtfmOptions dtfmOptions; - private final MohClassType moh; + private final OptionalValue conferenceId; + private final OptionalValue dtfmOptions; + private final OptionalValue musicOnHold; private ActionConnectConference( - String conferenceId, ConferenceDtfmOptions dtfmOptions, MohClassType moh) { + OptionalValue conferenceId, + OptionalValue dtfmOptions, + OptionalValue musicOnHold) { this.conferenceId = conferenceId; this.dtfmOptions = dtfmOptions; - this.moh = moh; + this.musicOnHold = musicOnHold; } - public String getConferenceId() { + public OptionalValue getConferenceId() { return conferenceId; } - public ConferenceDtfmOptions getDtfmOptions() { + public OptionalValue getDtfmOptions() { return dtfmOptions; } - public MohClassType getMoh() { - return moh; + public OptionalValue getMusicOnHold() { + return musicOnHold; } @Override @@ -36,8 +39,8 @@ public String toString() { + '\'' + ", dtfmOptions=" + dtfmOptions - + ", moh=" - + moh + + ", musicOnHold=" + + musicOnHold + "} " + super.toString(); } @@ -48,27 +51,27 @@ public static Builder builder() { public static class Builder> { - String conferenceId; - ConferenceDtfmOptions dtfmOptions; - MohClassType moh; + OptionalValue conferenceId = OptionalValue.empty(); + OptionalValue dtfmOptions = OptionalValue.empty(); + OptionalValue musicOnHold = OptionalValue.empty(); public Builder setConferenceId(String conferenceId) { - this.conferenceId = conferenceId; + this.conferenceId = OptionalValue.of(conferenceId); return this; } public Builder setDtfmOptions(ConferenceDtfmOptions dtfmOptions) { - this.dtfmOptions = dtfmOptions; + this.dtfmOptions = OptionalValue.of(dtfmOptions); return this; } - public Builder setMoh(MohClassType moh) { - this.moh = moh; + public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { + this.musicOnHold = OptionalValue.of(musicOnHold); return this; } public ActionConnectConference build() { - return new ActionConnectConference(conferenceId, dtfmOptions, moh); + return new ActionConnectConference(conferenceId, dtfmOptions, musicOnHold); } @SuppressWarnings("unchecked") diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java index aa9ec85ef..c7c9308d0 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectMxp.java @@ -1,24 +1,27 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.core.utils.Pair; import com.sinch.sdk.domains.voice.models.Destination; import java.util.Collection; public class ActionConnectMxp extends Action { - private final Destination destination; - private final Collection> callheaders; + private final OptionalValue destination; + private final OptionalValue>> callheaders; - private ActionConnectMxp(Destination destination, Collection> callheaders) { + private ActionConnectMxp( + OptionalValue destination, + OptionalValue>> callheaders) { this.destination = destination; this.callheaders = callheaders; } - public Destination getDestination() { + public OptionalValue getDestination() { return destination; } - public Collection> getCallheaders() { + public OptionalValue>> getCallheaders() { return callheaders; } @@ -39,16 +42,16 @@ public static Builder builder() { public static class Builder> { - Destination destination; - Collection> callheaders; + OptionalValue destination = OptionalValue.empty(); + OptionalValue>> callheaders = OptionalValue.empty(); public Builder setDestination(Destination destination) { - this.destination = destination; + this.destination = OptionalValue.of(destination); return this; } public Builder setCallheaders(Collection> callheaders) { - this.callheaders = callheaders; + this.callheaders = OptionalValue.of(callheaders); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java index 2c4e4b966..c896f3ad7 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectPstn.java @@ -1,75 +1,76 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; public class ActionConnectPstn extends Action { - private final E164PhoneNumber number; - private final String locale; - private final Integer maxDuration; - private final Integer dialTimeout; - private final String cli; - private final Boolean suppressCallbacks; - private final DualToneMultiFrequency dtmf; - private final IndicationType indications; - private final AnsweringMachineDetection answeringMachineDetectionEnabled; + private final OptionalValue number; + private final OptionalValue locale; + private final OptionalValue maxDuration; + private final OptionalValue dialTimeout; + private final OptionalValue cli; + private final OptionalValue suppressCallbacks; + private final OptionalValue dualToneMultiFrequency; + private final OptionalValue indications; + private final OptionalValue answeringMachineDetection; private ActionConnectPstn( - E164PhoneNumber number, - String locale, - Integer maxDuration, - Integer dialTimeout, - String cli, - Boolean suppressCallbacks, - DualToneMultiFrequency dtmf, - IndicationType indications, - AnsweringMachineDetection answeringMachineDetectionEnabled) { + OptionalValue number, + OptionalValue locale, + OptionalValue maxDuration, + OptionalValue dialTimeout, + OptionalValue cli, + OptionalValue suppressCallbacks, + OptionalValue dualToneMultiFrequency, + OptionalValue indications, + OptionalValue answeringMachineDetection) { this.number = number; this.locale = locale; this.maxDuration = maxDuration; this.dialTimeout = dialTimeout; this.cli = cli; this.suppressCallbacks = suppressCallbacks; - this.dtmf = dtmf; + this.dualToneMultiFrequency = dualToneMultiFrequency; this.indications = indications; - this.answeringMachineDetectionEnabled = answeringMachineDetectionEnabled; + this.answeringMachineDetection = answeringMachineDetection; } - public E164PhoneNumber getNumber() { + public OptionalValue getNumber() { return number; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } - public Integer getMaxDuration() { + public OptionalValue getMaxDuration() { return maxDuration; } - public Integer getDialTimeout() { + public OptionalValue getDialTimeout() { return dialTimeout; } - public String getCli() { + public OptionalValue getCli() { return cli; } - public Boolean getSuppressCallbacks() { + public OptionalValue getSuppressCallbacks() { return suppressCallbacks; } - public DualToneMultiFrequency getDtmf() { - return dtmf; + public OptionalValue getDualToneMultiFrequency() { + return dualToneMultiFrequency; } - public IndicationType getIndications() { + public OptionalValue getIndications() { return indications; } - public AnsweringMachineDetection getAnsweringMachineDetectionEnabled() { - return answeringMachineDetectionEnabled; + public OptionalValue getAnsweringMachineDetection() { + return answeringMachineDetection; } @Override @@ -89,12 +90,12 @@ public String toString() { + '\'' + ", suppressCallbacks=" + suppressCallbacks - + ", dtmf=" - + dtmf + + ", dualToneMultiFrequency=" + + dualToneMultiFrequency + ", indications=" + indications - + ", answeringMachineDetectionEnabled=" - + answeringMachineDetectionEnabled + + ", answeringMachineDetection=" + + answeringMachineDetection + "} " + super.toString(); } @@ -105,59 +106,59 @@ public static Builder builder() { public static class Builder> { - E164PhoneNumber number; - String locale; - Integer maxDuration; - Integer dialTimeout; - String cli; - Boolean suppressCallbacks; - DualToneMultiFrequency dtmf; - IndicationType indications; - AnsweringMachineDetection answeringMachineDetectionEnabled; + OptionalValue number = OptionalValue.empty(); + OptionalValue locale = OptionalValue.empty(); + OptionalValue maxDuration = OptionalValue.empty(); + OptionalValue dialTimeout = OptionalValue.empty(); + OptionalValue cli = OptionalValue.empty(); + OptionalValue suppressCallbacks = OptionalValue.empty(); + OptionalValue dualToneMultiFrequency = OptionalValue.empty(); + OptionalValue indications = OptionalValue.empty(); + OptionalValue answeringMachineDetection = OptionalValue.empty(); public Builder setNumber(E164PhoneNumber number) { - this.number = number; + this.number = OptionalValue.of(number); return this; } public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } public Builder setMaxDuration(Integer duration) { - this.maxDuration = duration; + this.maxDuration = OptionalValue.of(duration); return this; } public Builder setDialTimeout(Integer dialTimeout) { - this.dialTimeout = dialTimeout; + this.dialTimeout = OptionalValue.of(dialTimeout); return this; } public Builder setCli(String cli) { - this.cli = cli; + this.cli = OptionalValue.of(cli); return this; } public Builder setSuppressCallbacks(Boolean suppressCallbacks) { - this.suppressCallbacks = suppressCallbacks; + this.suppressCallbacks = OptionalValue.of(suppressCallbacks); return this; } - public Builder setDtmf(DualToneMultiFrequency dtmf) { - this.dtmf = dtmf; + public Builder setDualToneMultiFrequency(DualToneMultiFrequency dualToneMultiFrequency) { + this.dualToneMultiFrequency = OptionalValue.of(dualToneMultiFrequency); return this; } public Builder setIndications(IndicationType indications) { - this.indications = indications; + this.indications = OptionalValue.of(indications); return this; } - public Builder setAnsweringMachineDetectionEnabled( - AnsweringMachineDetection answeringMachineDetectionEnabled) { - this.answeringMachineDetectionEnabled = answeringMachineDetectionEnabled; + public Builder setAnsweringMachineDetection( + AnsweringMachineDetection answeringMachineDetection) { + this.answeringMachineDetection = OptionalValue.of(answeringMachineDetection); return this; } @@ -169,9 +170,9 @@ public ActionConnectPstn build() { dialTimeout, cli, suppressCallbacks, - dtmf, + dualToneMultiFrequency, indications, - answeringMachineDetectionEnabled); + answeringMachineDetection); } @SuppressWarnings("unchecked") diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java index 2216038cb..c731f34fa 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionConnectSip.java @@ -1,64 +1,65 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.core.utils.Pair; import com.sinch.sdk.domains.voice.models.DestinationSip; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.domains.voice.models.TransportType; import java.util.Collection; public class ActionConnectSip extends Action { - private final DestinationSip destination; - private final Integer maxDuration; - private final String cli; - private final TransportType transport; - private final Boolean suppressCallbacks; - private final Collection> callheaders; - private final MohClassType moh; + private final OptionalValue destination; + private final OptionalValue maxDuration; + private final OptionalValue cli; + private final OptionalValue transport; + private final OptionalValue suppressCallbacks; + private final OptionalValue>> callHeaders; + private final OptionalValue musicOnHold; private ActionConnectSip( - DestinationSip destination, - Integer maxDuration, - String cli, - TransportType transport, - Boolean suppressCallbacks, - Collection> callheaders, - MohClassType moh) { + OptionalValue destination, + OptionalValue maxDuration, + OptionalValue cli, + OptionalValue transport, + OptionalValue suppressCallbacks, + OptionalValue>> callHeaders, + OptionalValue musicOnHold) { this.destination = destination; this.maxDuration = maxDuration; this.cli = cli; this.transport = transport; this.suppressCallbacks = suppressCallbacks; - this.callheaders = callheaders; - this.moh = moh; + this.callHeaders = callHeaders; + this.musicOnHold = musicOnHold; } - public DestinationSip getDestination() { + public OptionalValue getDestination() { return destination; } - public Integer getMaxDuration() { + public OptionalValue getMaxDuration() { return maxDuration; } - public String getCli() { + public OptionalValue getCli() { return cli; } - public TransportType getTransport() { + public OptionalValue getTransport() { return transport; } - public Boolean getSuppressCallbacks() { + public OptionalValue getSuppressCallbacks() { return suppressCallbacks; } - public Collection> getCallheaders() { - return callheaders; + public OptionalValue>> getCallHeaders() { + return callHeaders; } - public MohClassType getMoh() { - return moh; + public OptionalValue getMusicOnHold() { + return musicOnHold; } @Override @@ -75,10 +76,10 @@ public String toString() { + transport + ", suppressCallbacks=" + suppressCallbacks - + ", callheaders=" - + callheaders - + ", moh=" - + moh + + ", callHeaders=" + + callHeaders + + ", musicOnHold=" + + musicOnHold + "} " + super.toString(); } @@ -89,52 +90,52 @@ public static Builder builder() { public static class Builder> { - DestinationSip destination; - Integer maxDuration; - String cli; - TransportType transport; - Boolean suppressCallbacks; - Collection> callheaders; - MohClassType moh; + OptionalValue destination = OptionalValue.empty(); + OptionalValue maxDuration = OptionalValue.empty(); + OptionalValue cli = OptionalValue.empty(); + OptionalValue transport = OptionalValue.empty(); + OptionalValue suppressCallbacks = OptionalValue.empty(); + OptionalValue>> callHeaders = OptionalValue.empty(); + OptionalValue musicOnHold = OptionalValue.empty(); public Builder setDestination(DestinationSip destination) { - this.destination = destination; + this.destination = OptionalValue.of(destination); return this; } public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = maxDuration; + this.maxDuration = OptionalValue.of(maxDuration); return this; } public Builder setCli(String cli) { - this.cli = cli; + this.cli = OptionalValue.of(cli); return this; } public Builder setTransport(TransportType transport) { - this.transport = transport; + this.transport = OptionalValue.of(transport); return this; } public Builder setSuppressCallbacks(Boolean suppressCallbacks) { - this.suppressCallbacks = suppressCallbacks; + this.suppressCallbacks = OptionalValue.of(suppressCallbacks); return this; } - public Builder setCallheaders(Collection> callheaders) { - this.callheaders = callheaders; + public Builder setCallHeaders(Collection> callHeaders) { + this.callHeaders = OptionalValue.of(callHeaders); return this; } - public Builder setMoh(MohClassType moh) { - this.moh = moh; + public Builder setMusicOnHold(MusicOnHoldType musicOnHold) { + this.musicOnHold = OptionalValue.of(musicOnHold); return this; } public ActionConnectSip build() { return new ActionConnectSip( - destination, maxDuration, cli, transport, suppressCallbacks, callheaders, moh); + destination, maxDuration, cli, transport, suppressCallbacks, callHeaders, musicOnHold); } @SuppressWarnings("unchecked") diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java index f107f3d58..d67e792ae 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionPark.java @@ -1,32 +1,38 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; + public class ActionPark extends Action { - private final String locale; - private final String introPrompt; - private final String holdPrompt; - private final Integer maxDuration; + private final OptionalValue locale; + private final OptionalValue introPrompt; + private final OptionalValue holdPrompt; + private final OptionalValue maxDuration; - private ActionPark(String locale, String introPrompt, String holdPrompt, Integer maxDuration) { + private ActionPark( + OptionalValue locale, + OptionalValue introPrompt, + OptionalValue holdPrompt, + OptionalValue maxDuration) { this.locale = locale; this.introPrompt = introPrompt; this.holdPrompt = holdPrompt; this.maxDuration = maxDuration; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } - public String getIntroPrompt() { + public OptionalValue getIntroPrompt() { return introPrompt; } - public String getHoldPrompt() { + public OptionalValue getHoldPrompt() { return holdPrompt; } - public Integer getMaxDuration() { + public OptionalValue getMaxDuration() { return maxDuration; } @@ -54,28 +60,28 @@ public static Builder builder() { public static class Builder> { - String locale; - String introPrompt; - String holdPrompt; - Integer maxDuration; + OptionalValue locale = OptionalValue.empty(); + OptionalValue introPrompt = OptionalValue.empty(); + OptionalValue holdPrompt = OptionalValue.empty(); + OptionalValue maxDuration = OptionalValue.empty(); public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } public Builder setIntroPrompt(String introPrompt) { - this.introPrompt = introPrompt; + this.introPrompt = OptionalValue.of(introPrompt); return this; } public Builder setHoldPrompt(String holdPrompt) { - this.holdPrompt = holdPrompt; + this.holdPrompt = OptionalValue.of(holdPrompt); return this; } public Builder setMaxDuration(Integer maxDuration) { - this.maxDuration = maxDuration; + this.maxDuration = OptionalValue.of(maxDuration); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java index 83965ab55..bdf252e6d 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/ActionRunMenu.java @@ -1,17 +1,22 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import java.util.Collection; public class ActionRunMenu extends Action { - private final Boolean barge; - private final String locale; - private final String mainMenu; - private final Boolean enableVoice; - private final Collection

menus; + private final OptionalValue barge; + private final OptionalValue locale; + private final OptionalValue mainMenu; + private final OptionalValue enableVoice; + private final OptionalValue> menus; private ActionRunMenu( - Boolean barge, String locale, String mainMenu, Boolean enableVoice, Collection menus) { + OptionalValue barge, + OptionalValue locale, + OptionalValue mainMenu, + OptionalValue enableVoice, + OptionalValue> menus) { this.barge = barge; this.locale = locale; this.mainMenu = mainMenu; @@ -19,23 +24,23 @@ private ActionRunMenu( this.menus = menus; } - public Boolean getBarge() { + public OptionalValue getBarge() { return barge; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } - public String getMainMenu() { + public OptionalValue getMainMenu() { return mainMenu; } - public Boolean getEnableVoice() { + public OptionalValue getEnableVoice() { return enableVoice; } - public Collection getMenus() { + public OptionalValue> getMenus() { return menus; } @@ -64,34 +69,34 @@ public static Builder builder() { public static class Builder> { - Boolean barge; - String locale; - String mainMenu; - Boolean enableVoice; - Collection menus; + OptionalValue barge = OptionalValue.empty(); + OptionalValue locale = OptionalValue.empty(); + OptionalValue mainMenu = OptionalValue.empty(); + OptionalValue enableVoice = OptionalValue.empty(); + OptionalValue> menus = OptionalValue.empty(); public Builder setBarge(Boolean barge) { - this.barge = barge; + this.barge = OptionalValue.of(barge); return this; } public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } public Builder setMainMenu(String mainMenu) { - this.mainMenu = mainMenu; + this.mainMenu = OptionalValue.of(mainMenu); return this; } public Builder setEnableVoice(Boolean enableVoice) { - this.enableVoice = enableVoice; + this.enableVoice = OptionalValue.of(enableVoice); return this; } public Builder setMenus(Collection menus) { - this.menus = menus; + this.menus = OptionalValue.of(menus); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java index 53291b62c..753c3c67e 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/AnsweringMachineDetection.java @@ -1,16 +1,16 @@ package com.sinch.sdk.domains.voice.models.svaml; -import com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn.Builder; +import com.sinch.sdk.core.models.OptionalValue; public class AnsweringMachineDetection { - private final Boolean enabled; + private final OptionalValue enabled; - private AnsweringMachineDetection(Boolean enabled) { + private AnsweringMachineDetection(OptionalValue enabled) { this.enabled = enabled; } - public Boolean getEnabled() { + public OptionalValue getEnabled() { return enabled; } @@ -20,10 +20,10 @@ public static Builder builder() { public static class Builder { - Boolean enabled; + OptionalValue enabled = OptionalValue.empty(); public Builder setEnabled(Boolean enabled) { - this.enabled = enabled; + this.enabled = OptionalValue.of(enabled); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java index 2b92a0312..d463bd33b 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionPlayFiles.java @@ -1,22 +1,24 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import java.util.Collection; public class InstructionPlayFiles extends Instruction { - private final Collection ids; - private final String locale; + private final OptionalValue> ids; + private final OptionalValue locale; - private InstructionPlayFiles(Collection ids, String locale) { + private InstructionPlayFiles( + OptionalValue> ids, OptionalValue locale) { this.ids = ids; this.locale = locale; } - public Collection getIds() { + public OptionalValue> getIds() { return ids; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } @@ -38,16 +40,16 @@ public static Builder builder() { public static class Builder> { - Collection ids; - String locale; + OptionalValue> ids = OptionalValue.empty(); + OptionalValue locale = OptionalValue.empty(); public Builder setIds(Collection ids) { - this.ids = ids; + this.ids = OptionalValue.of(ids); return this; } public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java index 87f807808..49f7f2818 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSay.java @@ -1,20 +1,22 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; + public class InstructionSay extends Instruction { - private final String text; - private final String locale; + private final OptionalValue text; + private final OptionalValue locale; - private InstructionSay(String text, String locale) { + private InstructionSay(OptionalValue text, OptionalValue locale) { this.text = text; this.locale = locale; } - public String getText() { + public OptionalValue getText() { return text; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } @@ -36,16 +38,16 @@ public static Builder builder() { public static class Builder> { - String text; - String locale; + OptionalValue text = OptionalValue.empty(); + OptionalValue locale = OptionalValue.empty(); public Builder setText(String text) { - this.text = text; + this.text = OptionalValue.of(text); return this; } public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java index 53dd9814e..47cb0ebd9 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionSendDtfm.java @@ -1,16 +1,17 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.models.DualToneMultiFrequency; public class InstructionSendDtfm extends Instruction { - private final DualToneMultiFrequency dtfm; + private final OptionalValue dtfm; - private InstructionSendDtfm(DualToneMultiFrequency dtfm) { + private InstructionSendDtfm(OptionalValue dtfm) { this.dtfm = dtfm; } - public DualToneMultiFrequency getTDtfm() { + public OptionalValue getTDtfm() { return dtfm; } @@ -25,10 +26,10 @@ public static Builder builder() { public static class Builder> { - DualToneMultiFrequency dtfm; + OptionalValue dtfm = OptionalValue.empty(); public Builder setDtfm(DualToneMultiFrequency dtfm) { - this.dtfm = dtfm; + this.dtfm = OptionalValue.of(dtfm); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java index 10b189a44..ed41960f2 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStartRecording.java @@ -1,14 +1,16 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; + public class InstructionStartRecording extends Instruction { - private final StartRecordingOptions options; + private final OptionalValue options; - private InstructionStartRecording(StartRecordingOptions options) { + private InstructionStartRecording(OptionalValue options) { this.options = options; } - public StartRecordingOptions getOptions() { + public OptionalValue getOptions() { return options; } @@ -23,10 +25,10 @@ public static Builder builder() { public static class Builder> { - StartRecordingOptions options; + OptionalValue options = OptionalValue.empty(); public Builder setOptions(StartRecordingOptions options) { - this.options = options; + this.options = OptionalValue.of(options); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java index a269159ae..fc41a5c0a 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/InstructionStopRecording.java @@ -2,9 +2,7 @@ public class InstructionStopRecording extends Instruction { - private InstructionStopRecording() { - ; - } + private InstructionStopRecording() {} @Override public String toString() { diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java index 9d47b6554..ad07347b5 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/Menu.java @@ -1,27 +1,28 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import java.util.Collection; public class Menu { - private final String id; - private final String mainPrompt; - private final String repeatPrompt; - private final Integer repeats; - private final Integer maxDigits; - private final Integer timeoutMills; - private final Integer maxTimeoutMills; - private final Collection options; + private final OptionalValue id; + private final OptionalValue mainPrompt; + private final OptionalValue repeatPrompt; + private final OptionalValue repeats; + private final OptionalValue maxDigits; + private final OptionalValue timeoutMills; + private final OptionalValue maxTimeoutMills; + private final OptionalValue> options; private Menu( - String id, - String mainPrompt, - String repeatPrompt, - Integer repeats, - Integer maxDigits, - Integer timeoutMills, - Integer maxTimeoutMills, - Collection options) { + OptionalValue id, + OptionalValue mainPrompt, + OptionalValue repeatPrompt, + OptionalValue repeats, + OptionalValue maxDigits, + OptionalValue timeoutMills, + OptionalValue maxTimeoutMills, + OptionalValue> options) { this.id = id; this.mainPrompt = mainPrompt; this.repeatPrompt = repeatPrompt; @@ -32,35 +33,35 @@ private Menu( this.options = options; } - public String getId() { + public OptionalValue getId() { return id; } - public String getMainPrompt() { + public OptionalValue getMainPrompt() { return mainPrompt; } - public String getRepeatPrompt() { + public OptionalValue getRepeatPrompt() { return repeatPrompt; } - public Integer getRepeats() { + public OptionalValue getRepeats() { return repeats; } - public Integer getMaxDigits() { + public OptionalValue getMaxDigits() { return maxDigits; } - public Integer getTimeoutMills() { + public OptionalValue getTimeoutMills() { return timeoutMills; } - public Integer getMaxTimeoutMills() { + public OptionalValue getMaxTimeoutMills() { return maxTimeoutMills; } - public Collection getOptions() { + public OptionalValue> getOptions() { return options; } @@ -95,52 +96,52 @@ public static Builder builder() { public static class Builder { - String id; - String mainPrompt; - String repeatPrompt; - Integer repeats; - Integer maxDigits; - Integer timeoutMills; - Integer maxTimeoutMills; - Collection options; + OptionalValue id = OptionalValue.empty(); + OptionalValue mainPrompt = OptionalValue.empty(); + OptionalValue repeatPrompt = OptionalValue.empty(); + OptionalValue repeats = OptionalValue.empty(); + OptionalValue maxDigits = OptionalValue.empty(); + OptionalValue timeoutMills = OptionalValue.empty(); + OptionalValue maxTimeoutMills = OptionalValue.empty(); + OptionalValue> options = OptionalValue.empty(); public Builder setId(String id) { - this.id = id; + this.id = OptionalValue.of(id); return this; } public Builder setMainPrompt(String mainPrompt) { - this.mainPrompt = mainPrompt; + this.mainPrompt = OptionalValue.of(mainPrompt); return this; } public Builder setRepeatPrompt(String repeatPrompt) { - this.repeatPrompt = repeatPrompt; + this.repeatPrompt = OptionalValue.of(repeatPrompt); return this; } public Builder setRepeats(Integer repeats) { - this.repeats = repeats; + this.repeats = OptionalValue.of(repeats); return this; } public Builder setMaxDigits(Integer maxDigits) { - this.maxDigits = maxDigits; + this.maxDigits = OptionalValue.of(maxDigits); return this; } public Builder setTimeoutMills(Integer timeoutMills) { - this.timeoutMills = timeoutMills; + this.timeoutMills = OptionalValue.of(timeoutMills); return this; } public Builder setMaxTimeoutMills(Integer maxTimeoutMills) { - this.maxTimeoutMills = maxTimeoutMills; + this.maxTimeoutMills = OptionalValue.of(maxTimeoutMills); return this; } public Builder setOptions(Collection options) { - this.options = options; + this.options = OptionalValue.of(options); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java index f85cd2a86..54e4f5e78 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOption.java @@ -1,22 +1,24 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; import com.sinch.sdk.models.DualToneMultiFrequency; public class MenuOption { - private final DualToneMultiFrequency dtfm; - private final MenuOptionActionType action; + private final OptionalValue dtfm; + private final OptionalValue action; - private MenuOption(DualToneMultiFrequency dtfm, MenuOptionActionType action) { + private MenuOption( + OptionalValue dtfm, OptionalValue action) { this.dtfm = dtfm; this.action = action; } - public DualToneMultiFrequency getDtfm() { + public OptionalValue getDtfm() { return dtfm; } - public MenuOptionActionType getAction() { + public OptionalValue getAction() { return action; } @@ -31,16 +33,16 @@ public static Builder builder() { public static class Builder { - DualToneMultiFrequency dtfm; - MenuOptionActionType action; + OptionalValue dtfm = OptionalValue.empty(); + OptionalValue action = OptionalValue.empty(); public Builder setDtfm(DualToneMultiFrequency dtfm) { - this.dtfm = dtfm; + this.dtfm = OptionalValue.of(dtfm); return this; } - public Builder setAction(MenuOptionActionType action) { - this.action = action; + public Builder setAction(MenuOptionAction action) { + this.action = OptionalValue.of(action); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java new file mode 100644 index 000000000..44b3a111d --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/MenuOptionAction.java @@ -0,0 +1,33 @@ +package com.sinch.sdk.domains.voice.models.svaml; + +import java.util.Objects; + +/** Navigates to the named menu */ +public class MenuOptionAction { + + private final MenuOptionActionType type; + private final String id; + + private MenuOptionAction(MenuOptionActionType type, String id) { + Objects.requireNonNull(type, "Action type cannot be null"); + this.type = type; + this.id = id; + } + + public String getId() { + return id; + } + + public MenuOptionActionType getType() { + return type; + } + + public static MenuOptionAction from(MenuOptionActionType type, String id) { + return new MenuOptionAction(type, id); + } + + @Override + public String toString() { + return "MenuOptionAction{" + "type=" + type + ", id='" + id + '\'' + '}'; + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParameters.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java similarity index 55% rename from client/src/main/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParameters.java rename to client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java index 9a26ec1bc..4dc0c1ace 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParameters.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/SVAMLControl.java @@ -1,20 +1,21 @@ -package com.sinch.sdk.domains.voice.models.requests; +package com.sinch.sdk.domains.voice.models.svaml; -import com.sinch.sdk.domains.voice.models.svaml.Action; -import com.sinch.sdk.domains.voice.models.svaml.Instruction; +import com.sinch.sdk.core.models.OptionalValue; +import com.sinch.sdk.domains.voice.models.requests.Control; import java.util.Collection; /** - * Class enabling to define SAVML actions and instructions + * Class enabling to define SVAML actions and instructions * - * @see SAVML + * @see SVAML * Dcoumentation */ -public class CallsUpdateRequestParameters { - private final Collection instructions; - private final Action action; +public class SVAMLControl extends Control { + private final OptionalValue> instructions; + private final OptionalValue action; - private CallsUpdateRequestParameters(Collection instructions, Action action) { + private SVAMLControl( + OptionalValue> instructions, OptionalValue action) { this.instructions = instructions; this.action = action; } @@ -24,7 +25,7 @@ private CallsUpdateRequestParameters(Collection instructions, Actio * * @return See builder {@link Builder#setInstructions setter} */ - public Collection getInstructions() { + public OptionalValue> getInstructions() { return instructions; } @@ -33,18 +34,13 @@ public Collection getInstructions() { * * @return See builder {@link Builder#setAction setter} */ - public Action getAction() { + public OptionalValue getAction() { return action; } @Override public String toString() { - return "CallsUpdateRequestParameters{" - + "instructions=" - + instructions - + ", action=" - + action - + '}'; + return "SVAMLControl{" + "instructions=" + instructions + ", action=" + action + '}'; } /** @@ -58,8 +54,8 @@ public static Builder builder() { public static class Builder { - Collection instructions; - Action action; + OptionalValue> instructions = OptionalValue.empty(); + OptionalValue action = OptionalValue.empty(); public Builder() {} @@ -70,7 +66,7 @@ public Builder() {} * @return Current builder */ public Builder setInstructions(Collection instructions) { - this.instructions = instructions; + this.instructions = OptionalValue.of(instructions); return this; } @@ -81,7 +77,7 @@ public Builder setInstructions(Collection instructions) { * @return Current builder */ public Builder setAction(Action action) { - this.action = action; + this.action = OptionalValue.of(action); return this; } @@ -90,8 +86,8 @@ public Builder setAction(Action action) { * * @return Built instance */ - public CallsUpdateRequestParameters build() { - return new CallsUpdateRequestParameters(instructions, action); + public SVAMLControl build() { + return new SVAMLControl(instructions, action); } } } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java index 2eb73ea9b..71fd8abb5 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/StartRecordingOptions.java @@ -1,19 +1,21 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; + public class StartRecordingOptions { - private final String destinationUrl; - private final String credentials; - private final String format; - private final Boolean notificationEvents; - private final TranscriptionOptions transcriptionOptions; + private final OptionalValue destinationUrl; + private final OptionalValue credentials; + private final OptionalValue format; + private final OptionalValue notificationEvents; + private final OptionalValue transcriptionOptions; private StartRecordingOptions( - String destinationUrl, - String credentials, - String format, - Boolean notificationEvents, - TranscriptionOptions transcriptionOptions) { + OptionalValue destinationUrl, + OptionalValue credentials, + OptionalValue format, + OptionalValue notificationEvents, + OptionalValue transcriptionOptions) { this.destinationUrl = destinationUrl; this.credentials = credentials; this.format = format; @@ -21,23 +23,23 @@ private StartRecordingOptions( this.transcriptionOptions = transcriptionOptions; } - public String getDestinationUrl() { + public OptionalValue getDestinationUrl() { return destinationUrl; } - public String getCredentials() { + public OptionalValue getCredentials() { return credentials; } - public String getFormat() { + public OptionalValue getFormat() { return format; } - public Boolean getNotificationEvents() { + public OptionalValue getNotificationEvents() { return notificationEvents; } - public TranscriptionOptions getTranscriptionOptions() { + public OptionalValue getTranscriptionOptions() { return transcriptionOptions; } @@ -66,34 +68,34 @@ public static Builder builder() { public static class Builder { - String destinationUrl; - String credentials; - String format; - Boolean notificationEvents; - TranscriptionOptions transcriptionOptions; + OptionalValue destinationUrl = OptionalValue.empty(); + OptionalValue credentials = OptionalValue.empty(); + OptionalValue format = OptionalValue.empty(); + OptionalValue notificationEvents = OptionalValue.empty(); + OptionalValue transcriptionOptions = OptionalValue.empty(); public Builder setDestinationUrl(String destinationUrl) { - this.destinationUrl = destinationUrl; + this.destinationUrl = OptionalValue.of(destinationUrl); return this; } public Builder setCredentials(String credentials) { - this.credentials = credentials; + this.credentials = OptionalValue.of(credentials); return this; } public Builder setFormat(String format) { - this.format = format; + this.format = OptionalValue.of(format); return this; } public Builder setNotificationEvents(Boolean notificationEvents) { - this.notificationEvents = notificationEvents; + this.notificationEvents = OptionalValue.of(notificationEvents); return this; } public Builder setTranscriptionOptions(TranscriptionOptions transcriptionOptions) { - this.transcriptionOptions = transcriptionOptions; + this.transcriptionOptions = OptionalValue.of(transcriptionOptions); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java index a41115018..5589b73d5 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/TranscriptionOptions.java @@ -1,20 +1,22 @@ package com.sinch.sdk.domains.voice.models.svaml; +import com.sinch.sdk.core.models.OptionalValue; + public class TranscriptionOptions { - private final Boolean enabled; - private final String locale; + private final OptionalValue enabled; + private final OptionalValue locale; - private TranscriptionOptions(Boolean enabled, String locale) { + private TranscriptionOptions(OptionalValue enabled, OptionalValue locale) { this.enabled = enabled; this.locale = locale; } - public Boolean getEnabled() { + public OptionalValue getEnabled() { return enabled; } - public String getLocale() { + public OptionalValue getLocale() { return locale; } @@ -29,16 +31,16 @@ public static Builder builder() { public static class Builder { - Boolean enabled; - String locale; + OptionalValue enabled = OptionalValue.empty(); + OptionalValue locale = OptionalValue.empty(); public Builder setEnabled(Boolean enabled) { - this.enabled = enabled; + this.enabled = OptionalValue.of(enabled); return this; } public Builder setLocale(String locale) { - this.locale = locale; + this.locale = OptionalValue.of(locale); return this; } diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java index 05a65ab15..f6b66e8e9 100644 --- a/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java +++ b/client/src/main/com/sinch/sdk/domains/voice/models/svaml/package-info.java @@ -1,8 +1,8 @@ /** * Sinch Voice Application Markup Language (SVAML) related models * - * @see SAVML - * documentaiotn + * @see SVAML + * documentation * @since 1.0 */ package com.sinch.sdk.domains.voice.models.svaml; diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java new file mode 100644 index 000000000..ab7de2661 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswer.java @@ -0,0 +1,88 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +/** + * If Answering Machine Detection (see AMD) is enabled, this + * object contains information about whether the call was answered by a machine. + */ +public class AmdAnswer { + + private final AmdAnswerStatusType status; + private final AmdAnswerReasonType reason; + private final Integer duration; + + private AmdAnswer(AmdAnswerStatusType status, AmdAnswerReasonType reason, Integer duration) { + this.status = status; + this.reason = reason; + this.duration = duration; + } + + /** + * Get the status + * + * @return Status value + */ + public AmdAnswerStatusType getStatus() { + return status; + } + + /** + * Get the reason + * + * @return Reason value + */ + public AmdAnswerReasonType getReason() { + return reason; + } + + /** + * Get the length of the call + * + * @return Call length + */ + public Integer getDuration() { + return duration; + } + + @Override + public String toString() { + return "AmdAnswer{" + + "status=" + + status + + ", reason=" + + reason + + ", duration=" + + duration + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + AmdAnswerStatusType status; + AmdAnswerReasonType reason; + Integer duration; + + public Builder setStatus(AmdAnswerStatusType status) { + this.status = status; + return this; + } + + public Builder setReason(AmdAnswerReasonType reason) { + this.reason = reason; + return this; + } + + public Builder setDuration(Integer duration) { + this.duration = duration; + return this; + } + + public AmdAnswer build() { + return new AmdAnswer(status, reason, duration); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java new file mode 100644 index 000000000..b73d8fb99 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerReasonType.java @@ -0,0 +1,42 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** The reason that the system used to determine who answered the call. */ +public class AmdAnswerReasonType extends EnumDynamic { + + /** If the greeting is too long, this could be indicative of an answering machine. */ + public static final AmdAnswerReasonType LONG_GREETING = new AmdAnswerReasonType("longgreeting"); + + /** + * If there is an initial silence after the call is answered before the greeting starts, this + * could be indicative of an answering machine. + */ + public static final AmdAnswerReasonType INITIAL_SILENCE = + new AmdAnswerReasonType("initialsilence"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + AmdAnswerReasonType.class, + AmdAnswerReasonType::new, + Arrays.asList(LONG_GREETING, INITIAL_SILENCE)); + + private AmdAnswerReasonType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static AmdAnswerReasonType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(AmdAnswerReasonType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java new file mode 100644 index 000000000..711d4c653 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AmdAnswerStatusType.java @@ -0,0 +1,44 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** The status of a call */ +public class AmdAnswerStatusType extends EnumDynamic { + + /** An answering machine was detected as answering the call. */ + public static final AmdAnswerStatusType MACHINE = new AmdAnswerStatusType("machine"); + + /** A human was detected as answering the call. */ + public static final AmdAnswerStatusType HUMAN = new AmdAnswerStatusType("human"); + + /** The system was unable to determine who answered the call. */ + public static final AmdAnswerStatusType NOTSURE = new AmdAnswerStatusType("notsure"); + + /** The call was hung up. */ + public static final AmdAnswerStatusType HANGUP = new AmdAnswerStatusType("hangup"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + AmdAnswerStatusType.class, + AmdAnswerStatusType::new, + Arrays.asList(MACHINE, HUMAN, NOTSURE, HANGUP)); + + private AmdAnswerStatusType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static AmdAnswerStatusType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(AmdAnswerStatusType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java new file mode 100644 index 000000000..6ebdec096 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/AnsweredCallEvent.java @@ -0,0 +1,72 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import java.time.Instant; + +/** + * This callback is made when the call is picked up by the callee (person receiving the call). + * + *

It's a POST request to the specified calling callback URL. Look here for allowed {@link + * com.sinch.sdk.domains.voice.models.svaml.Action instructions} and {@link + * com.sinch.sdk.domains.voice.models.svaml.Instruction actions}. + * + *

If there is no response to the callback within the timeout period, the call is connected. + * + *

If you have Answering Machine Detection (AMD) enabled, the amd + * object will also be present on ACE callbacks. + * + *

Note: ACE Callbacks are not issued for InApp Calls (destination: username), only PSTN and SIP + * calls. + * + * @see ACE + */ +public class AnsweredCallEvent extends CallEvent { + + private final AmdAnswer amd; + + private AnsweredCallEvent( + String callId, Instant timestamp, Integer version, String custom, AmdAnswer amd) { + super(callId, timestamp, version, custom); + this.amd = amd; + } + + /** + * If Answering Machine Detection is enabled, this object contains information about whether the + * call was answered by a machine. + * + * @return AMD Answer value + */ + public AmdAnswer getAmd() { + return amd; + } + + @Override + public String toString() { + return "AnsweredCallEvent{" + "amd=" + amd + "} " + super.toString(); + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends CallEvent.Builder> { + + AmdAnswer amd; + + public Builder setAmd(AmdAnswer amd) { + this.amd = amd; + return this; + } + + public AnsweredCallEvent build() { + return new AnsweredCallEvent(callId, timestamp, version, custom, amd); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java new file mode 100644 index 000000000..9f741bb7b --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/CallEvent.java @@ -0,0 +1,70 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.domains.sms.models.DeliveryReportBatch.Builder; +import java.time.Instant; + +/** Base class for webhooks call event */ +public class CallEvent extends WebhooksEvent { + + private final Instant timestamp; + private final String custom; + + protected CallEvent(String callId, Instant timestamp, Integer version, String custom) { + super(callId, version); + this.timestamp = timestamp; + this.custom = custom; + } + + /** + * Event timestamp + * + * @return Timestamp value + */ + public Instant getTimestamp() { + return timestamp; + } + + /** + * A string that can be used to pass custom information related to the call. + * + * @return The custom value used for call + */ + public String getCustom() { + return custom; + } + + @Override + public String toString() { + return "CallEvent{" + "timestamp=" + timestamp + ", custom='" + custom + '\'' + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends WebhooksEvent.Builder { + + Instant timestamp; + String custom; + + public B setTimestamp(Instant timestamp) { + this.timestamp = timestamp; + return self(); + } + + public B setCustom(String custom) { + this.custom = custom; + return self(); + } + + public CallEvent build() { + return new CallEvent(callId, timestamp, version, custom); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java new file mode 100644 index 000000000..7429a2d1f --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/DisconnectCallEvent.java @@ -0,0 +1,229 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; +import com.sinch.sdk.domains.voice.models.Destination; +import com.sinch.sdk.domains.voice.models.Price; +import java.time.Instant; + +/** + * This callback is made when the call is disconnected. + * + *

It's a POST request to the specified calling callback URL. This event doesn't support + * instructions and only supports the hangup action. + * + * @see DICE + */ +public class DisconnectCallEvent extends CallEvent { + + private final CallReasonType reason; + private final CallResultType result; + private final Price debit; + private final Price userRate; + private final Destination to; + private final String applicationKey; + private final Integer duration; + private final String from; + + private DisconnectCallEvent( + String callId, + Instant timestamp, + Integer version, + String custom, + CallReasonType reason, + CallResultType result, + Price debit, + Price userRate, + Destination to, + String applicationKey, + Integer duration, + String from) { + super(callId, timestamp, version, custom); + this.reason = reason; + this.result = result; + this.debit = debit; + this.userRate = userRate; + this.to = to; + this.applicationKey = applicationKey; + this.duration = duration; + this.from = from; + } + + /** + * The reason the call was disconnected + * + * @return Reason value + */ + public CallReasonType getReason() { + return reason; + } + + /** + * The result of the call + * + * @return Result value + */ + public CallResultType getResult() { + return result; + } + + /** + * Amount charged for the call + * + * @return charge value + */ + public Price getDebit() { + return debit; + } + + /** + * Rate per minute for the call + * + * @return rate value + */ + public Price getUserRate() { + return userRate; + } + + /** + * Information about the recipient of the call + * + * @return Recipient information + */ + public Destination getTo() { + return to; + } + + /** + * The unique application key + * + * @return Application key value + */ + public String getApplicationKey() { + return applicationKey; + } + + /** + * The duration of the call in seconds + * + * @return Call duration + */ + public Integer getDuration() { + return duration; + } + + /** + * Information about the initiator of the call. + * + * @return Initiator information + */ + public String getFrom() { + return from; + } + + @Override + public String toString() { + return "DisconnectCallEvent{" + + "reason='" + + reason + + '\'' + + ", result='" + + result + + '\'' + + ", debit=" + + debit + + ", userRate=" + + userRate + + ", to=" + + to + + ", applicationKey='" + + applicationKey + + '\'' + + ", duration=" + + duration + + ", from='" + + from + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends CallEvent.Builder> { + + CallReasonType reason; + CallResultType result; + Price debit; + Price userRate; + Destination to; + String applicationKey; + Integer duration; + String from; + + public B setReason(CallReasonType reason) { + this.reason = reason; + return self(); + } + + public B setResult(CallResultType result) { + this.result = result; + return self(); + } + + public B setDebit(Price debit) { + this.debit = debit; + return self(); + } + + public B setUserRate(Price userRate) { + this.userRate = userRate; + return self(); + } + + public B setTo(Destination to) { + this.to = to; + return self(); + } + + public B setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + return self(); + } + + public B setDuration(Integer duration) { + this.duration = duration; + return self(); + } + + public B setFrom(String from) { + this.from = from; + return self(); + } + + public DisconnectCallEvent build() { + return new DisconnectCallEvent( + callId, + timestamp, + version, + custom, + reason, + result, + debit, + userRate, + to, + applicationKey, + duration, + from); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java new file mode 100644 index 000000000..f250db15c --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/IncomingCallEvent.java @@ -0,0 +1,285 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.voice.models.Destination; +import com.sinch.sdk.domains.voice.models.DomainType; +import com.sinch.sdk.domains.voice.models.Price; +import com.sinch.sdk.domains.voice.models.webhooks.CallEvent.Builder; +import java.time.Instant; +import java.util.Collection; + +/** + * This event, called the ICE event, can be triggered by either an incoming data call or an incoming + * PSTN call. + * + *

It's a POST request to the specified calling callback URL. Look here for allowed {@link + * com.sinch.sdk.domains.voice.models.svaml.Action instructions} and {@link + * com.sinch.sdk.domains.voice.models.svaml.Instruction actions}. + * + *

If there is no response to the callback within the timeout period, an error message is played, + * and the call is disconnected. + * + * @see ICE + */ +public class IncomingCallEvent extends CallEvent { + + private final String callResourceUrl; + private final Price userRate; + private final String cli; + private final Destination to; + private final DomainType domain; + private final String applicationKey; + private final DomainType originationType; + private final Integer duration; + private final String rdnis; + private final Collection> callHeaders; + + private IncomingCallEvent( + String callId, + Instant timestamp, + Integer version, + String custom, + String callResourceUrl, + Price userRate, + String cli, + Destination to, + DomainType domain, + String applicationKey, + DomainType originationType, + Integer duration, + String rdnis, + Collection> callHeaders) { + super(callId, timestamp, version, custom); + this.callResourceUrl = callResourceUrl; + this.userRate = userRate; + this.cli = cli; + this.to = to; + this.domain = domain; + this.applicationKey = applicationKey; + this.originationType = originationType; + this.duration = duration; + this.rdnis = rdnis; + this.callHeaders = callHeaders; + } + + /** + * The path of the API resource + * + * @return path value + */ + public String getCallResourceUrl() { + return callResourceUrl; + } + + /** + * Charged for the call established to the original destination. If the SVAML response specifies + * another destination, the same rate may not apply. + * + * @return charged value + */ + public Price getUserRate() { + return userRate; + } + + /** + * The number that will be displayed to the recipient of the call. + * + *

To set your own CLI, you may use your verified number or your Dashboard virtual number and + * add it to the {@link com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn + * ActionConnectPstn} SVAML response to the Incoming Call Event request. + * + * @return + */ + public String getCli() { + return cli; + } + + /** + * Information about the recipient of the call + * + * @return information value + */ + public Destination getTo() { + return to; + } + + /** + * The domain destination of the incoming call + * + * @return Domain value + */ + public DomainType getDomain() { + return domain; + } + + /** + * The unique application key + * + * @return Application key value + */ + public String getApplicationKey() { + return applicationKey; + } + + /** + * The origination domain of the incoming call + * + * @return Origin type + */ + public DomainType getOriginationType() { + return originationType; + } + + /** + * The duration of the call in seconds + * + * @return Duration value + */ + public Integer getDuration() { + return duration; + } + + /** + * The redirected dialled number identification service + * + * @return RDNIS value + */ + public String getRdnis() { + return rdnis; + } + + /** + * If the call is initiated by a Sinch SDK client, call headers are the headers specified by the + * caller client. Read more about call headers here + * + * @return Headers + */ + public Collection> getCallHeaders() { + return callHeaders; + } + + @Override + public String toString() { + return "IncomingCallEvent{" + + "callResourceUrl='" + + callResourceUrl + + '\'' + + ", userRate=" + + userRate + + ", cli='" + + cli + + '\'' + + ", to=" + + to + + ", domain=" + + domain + + ", applicationKey='" + + applicationKey + + '\'' + + ", originationType=" + + originationType + + ", duration=" + + duration + + ", rdnis='" + + rdnis + + '\'' + + ", callHeaders=" + + callHeaders + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends CallEvent.Builder> { + + String callResourceUrl; + Price userRate; + String cli; + Destination to; + DomainType domain; + String applicationKey; + DomainType originationType; + Integer duration; + String rdnis; + Collection> callHeaders; + + public B setCallResourceUrl(String callResourceUrl) { + this.callResourceUrl = callResourceUrl; + return self(); + } + + public B setUserRate(Price userRate) { + this.userRate = userRate; + return self(); + } + + public B setCli(String cli) { + this.cli = cli; + return self(); + } + + public B setTo(Destination to) { + this.to = to; + return self(); + } + + public B setDomain(DomainType domain) { + this.domain = domain; + return self(); + } + + public B setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + return self(); + } + + public B setOriginationType(DomainType originationType) { + this.originationType = originationType; + return self(); + } + + public B setDuration(Integer duration) { + this.duration = duration; + return self(); + } + + public B setRdnis(String rdnis) { + this.rdnis = rdnis; + return self(); + } + + public B setCallHeaders(Collection> callHeaders) { + this.callHeaders = callHeaders; + return self(); + } + + public IncomingCallEvent build() { + return new IncomingCallEvent( + callId, + timestamp, + version, + custom, + callResourceUrl, + userRate, + cli, + to, + domain, + applicationKey, + originationType, + duration, + rdnis, + callHeaders); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java new file mode 100644 index 000000000..9308885d3 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuInputType.java @@ -0,0 +1,50 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** The type of information that's returned */ +public class MenuInputType extends EnumDynamic { + + /** Returned if there's an error with the input. */ + public static final MenuInputType ERROR = new MenuInputType("error"); + + /** Returned when the event has been triggered from a return command */ + public static final MenuInputType RETURN = new MenuInputType("return"); + + /** Returned when the event has been triggered from collecting DTMF digits */ + public static final MenuInputType SEQUENCE = new MenuInputType("sequence"); + + /** Returned when the timeout period has elapsed */ + public static final MenuInputType TIMEOUT = new MenuInputType("timeout"); + + /** Returned when the call is hung up */ + public static final MenuInputType HANGUP = new MenuInputType("hangup"); + + /** InvalidInput */ + public static final MenuInputType INVALID_INPUT = new MenuInputType("invalidinput"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + MenuInputType.class, + MenuInputType::new, + Arrays.asList(ERROR, RETURN, SEQUENCE, TIMEOUT, HANGUP, INVALID_INPUT)); + + private MenuInputType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static MenuInputType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(MenuInputType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java new file mode 100644 index 000000000..2a3c0a9ed --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResult.java @@ -0,0 +1,85 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +public class MenuResult { + + private final String menuId; + private final MenuInputType type; + private final String value; + private final MenuResultInputMethodType inputMethod; + + private MenuResult( + String menuId, MenuInputType type, String value, MenuResultInputMethodType inputMethod) { + this.menuId = menuId; + this.type = type; + this.value = value; + this.inputMethod = inputMethod; + } + + public String getMenuId() { + return menuId; + } + + public MenuInputType getType() { + return type; + } + + public String getValue() { + return value; + } + + public MenuResultInputMethodType getInputMethod() { + return inputMethod; + } + + @Override + public String toString() { + return "MenuResult{" + + "menuId='" + + menuId + + '\'' + + ", type=" + + type + + ", value='" + + value + + '\'' + + ", inputMethod=" + + inputMethod + + '}'; + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + + String menuId; + MenuInputType type; + String value; + MenuResultInputMethodType inputMethod; + + public Builder setMenuId(String menuId) { + this.menuId = menuId; + return this; + } + + public Builder setType(MenuInputType type) { + this.type = type; + return this; + } + + public Builder setValue(String value) { + this.value = value; + return this; + } + + public Builder setInputMethod(MenuResultInputMethodType inputMethod) { + this.inputMethod = inputMethod; + return this; + } + + public MenuResult build() { + return new MenuResult(menuId, type, value, inputMethod); + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java new file mode 100644 index 000000000..0c4965eef --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/MenuResultInputMethodType.java @@ -0,0 +1,38 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import com.sinch.sdk.core.utils.EnumDynamic; +import com.sinch.sdk.core.utils.EnumSupportDynamic; +import java.util.Arrays; +import java.util.stream.Stream; + +/** The type of input received. */ +public class MenuResultInputMethodType extends EnumDynamic { + + /** The input is key presses of specified digits */ + public static final MenuResultInputMethodType DTMF = new MenuResultInputMethodType("dtmf"); + + /** The input is voice answers */ + public static final MenuResultInputMethodType VOICE = new MenuResultInputMethodType("voice"); + + private static final EnumSupportDynamic ENUM_SUPPORT = + new EnumSupportDynamic<>( + MenuResultInputMethodType.class, + MenuResultInputMethodType::new, + Arrays.asList(VOICE, DTMF)); + + private MenuResultInputMethodType(String value) { + super(value); + } + + public static Stream values() { + return ENUM_SUPPORT.values(); + } + + public static MenuResultInputMethodType from(String value) { + return ENUM_SUPPORT.from(value); + } + + public static String valueOf(MenuResultInputMethodType e) { + return ENUM_SUPPORT.valueOf(e); + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java new file mode 100644 index 000000000..a48be7115 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/NotifyEvent.java @@ -0,0 +1,81 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +/** + * This is the general callback used to send notifications. It's a POST request to the specified + * calling callback URL. + * + *

If there is no response to the callback within the timeout period, the notification is + * discarded. + */ +public class NotifyEvent extends WebhooksEvent { + + private final String custom; + private final String type; + + private NotifyEvent(String callId, Integer version, String custom, String type) { + super(callId, version); + this.custom = custom; + this.type = type; + } + + /** + * An optional parameter containing notification-specific information + * + * @return custom value + */ + public String getCustom() { + return custom; + } + + /** + * The type of information communicated in the notification + * + * @return type value + */ + public String getType() { + return type; + } + + @Override + public String toString() { + return "NotifyEvent{" + + "custom='" + + custom + + '\'' + + ", type='" + + type + + '\'' + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends WebhooksEvent.Builder> { + + String custom; + String type; + + public B setCustom(String custom) { + this.custom = custom; + return self(); + } + + public B setType(String type) { + this.type = type; + return self(); + } + + public NotifyEvent build() { + return new NotifyEvent(callId, version, custom, type); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java new file mode 100644 index 000000000..d22141437 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/PromptInputEvent.java @@ -0,0 +1,95 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +import java.time.Instant; + +/** + * This callback is triggered as a result of a {@link + * com.sinch.sdk.domains.voice.models.svaml.ActionRunMenu runMenu} action. It can be triggered from + * either a user pressing a number of DTMF digits, or by the {@link + * com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType#RETURN return} command. + * + *

It's a POST request to the specified calling callback URL. Your application can respond with + * {@link com.sinch.sdk.domains.voice.models.svaml SVAML} logic. + * + *

Note: PIE callbacks are not issued for DATA Calls, only PSTN and SIP calls. + * + * @see PIE + */ +public class PromptInputEvent extends CallEvent { + + private final String applicationKey; + private final MenuResult menuResult; + + private PromptInputEvent( + String callId, + Instant timestamp, + Integer version, + String custom, + String applicationKey, + MenuResult menuResult) { + super(callId, timestamp, version, custom); + this.applicationKey = applicationKey; + this.menuResult = menuResult; + } + + /** + * The unique application key + * + * @return Application key value + */ + public String getApplicationKey() { + return applicationKey; + } + + /** + * Information about the returned menu result + * + * @return Menu + */ + public MenuResult getMenuResult() { + return menuResult; + } + + @Override + public String toString() { + return "PromptInputEvent{" + + "applicationKey='" + + applicationKey + + '\'' + + ", menuResult=" + + menuResult + + "} " + + super.toString(); + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> extends CallEvent.Builder> { + + String applicationKey; + MenuResult menuResult; + + public Builder setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + return this; + } + + public Builder setMenuResult(MenuResult menuResult) { + this.menuResult = menuResult; + return this; + } + + public PromptInputEvent build() { + return new PromptInputEvent(callId, timestamp, version, custom, applicationKey, menuResult); + } + + @Override + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java new file mode 100644 index 000000000..a8160e755 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/WebhooksEvent.java @@ -0,0 +1,64 @@ +package com.sinch.sdk.domains.voice.models.webhooks; + +public class WebhooksEvent { + + private final String callId; + private final Integer version; + + protected WebhooksEvent(String callId, Integer version) { + this.callId = callId; + this.version = version; + } + + /** + * The unique ID assigned to call related to this event + * + * @return Call ID value + */ + public String getCallId() { + return callId; + } + + /** + * The current API version + * + * @return API version sending the event + */ + public Integer getVersion() { + return version; + } + + @Override + public String toString() { + return "CallEvent{" + "callId='" + callId + '\'' + ", version=" + version + '}'; + } + + public static Builder builder() { + return new Builder<>(); + } + + public static class Builder> { + + String callId; + Integer version; + + public B setCallId(String callId) { + this.callId = callId; + return self(); + } + + public B setVersion(Integer version) { + this.version = version; + return self(); + } + + public WebhooksEvent build() { + return new WebhooksEvent(callId, version); + } + + @SuppressWarnings("unchecked") + protected B self() { + return (B) this; + } + } +} diff --git a/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java new file mode 100644 index 000000000..d21f6bf50 --- /dev/null +++ b/client/src/main/com/sinch/sdk/domains/voice/models/webhooks/package-info.java @@ -0,0 +1,6 @@ +/** + * Voice API webhooks related models + * + * @since 1.0 + */ +package com.sinch.sdk.domains.voice.models.webhooks; diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/CallsServiceTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/CallsServiceTest.java index 432103663..7913e6d81 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/CallsServiceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/CallsServiceTest.java @@ -16,8 +16,8 @@ import com.sinch.sdk.domains.voice.models.CallLegType; import com.sinch.sdk.domains.voice.models.dto.v1.CallsResponseDtoTest; import com.sinch.sdk.domains.voice.models.dto.v1.SVAMLRequestBodyDto; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParametersTest; import com.sinch.sdk.domains.voice.models.response.CallInformation; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControlTest; import com.sinch.sdk.models.Configuration; import java.util.Map; import org.assertj.core.api.Assertions; @@ -64,7 +64,7 @@ void get() throws ApiException { @Test void update() throws ApiException { - service.update("call id", CallsUpdateRequestParametersTest.parameters); + service.update("call id", SVAMLControlTest.parameters); verify(api).callingUpdateCall(callIdCaptor.capture(), updateParametersCaptor.capture()); @@ -78,8 +78,7 @@ void update() throws ApiException { @Test void manageWithCallLeg() throws ApiException { - service.manageWithCallLeg( - "call id", CallLegType.BOTH, CallsUpdateRequestParametersTest.parameters); + service.manageWithCallLeg("call id", CallLegType.BOTH, SVAMLControlTest.parameters); verify(api) .callingManageCallWithCallLeg( diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverterTest.java index 2f4b4d46c..b9aaa2317 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/CallsDtoConverterTest.java @@ -2,6 +2,8 @@ import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.sinch.sdk.BaseTest; +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; import com.sinch.sdk.domains.voice.models.DestinationNumber; import com.sinch.sdk.domains.voice.models.DestinationUser; import com.sinch.sdk.domains.voice.models.DomainType; @@ -12,11 +14,9 @@ import com.sinch.sdk.domains.voice.models.dto.v1.SVAMLRequestBodyDto; import com.sinch.sdk.domains.voice.models.dto.v1.SvamlActionDto; import com.sinch.sdk.domains.voice.models.dto.v1.SvamlInstructionDto; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParametersTest; import com.sinch.sdk.domains.voice.models.response.CallInformation; -import com.sinch.sdk.domains.voice.models.response.CallReasonType; -import com.sinch.sdk.domains.voice.models.response.CallResultType; import com.sinch.sdk.domains.voice.models.response.CallStatusType; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControlTest; import java.time.Instant; import java.util.Collections; import org.assertj.core.api.Assertions; @@ -34,7 +34,7 @@ public class CallsDtoConverterTest extends BaseTest { .setDuration(138) .setStatus(CallStatusType.FINAL) .setResult(CallResultType.ANSWERED) - .setReason(CallReasonType.CALLEEHANGUP) + .setReason(CallReasonType.CALLEE_HANGUP) .setTimeStamp(Instant.parse("2024-01-08T09:48:12Z")) .setCustom("{}") .setUserRate(Price.builder().setCurrencyId("EUR").setAmount(0.1758F).build()) @@ -61,6 +61,6 @@ void convertCallsUpdateRequestParameters() { Assertions.assertThat(svamlRequestBodyDto) .usingRecursiveComparison() - .isEqualTo(CallsDtoConverter.convert(CallsUpdateRequestParametersTest.parameters)); + .isEqualTo(CallsDtoConverter.convert(SVAMLControlTest.parameters)); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverterTest.java similarity index 84% rename from client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverterTest.java rename to client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverterTest.java index a044b69ef..054003e2a 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLActionDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLActionDtoConverterTest.java @@ -5,7 +5,7 @@ import com.sinch.sdk.domains.voice.models.DestinationSip; import com.sinch.sdk.domains.voice.models.DestinationUser; import com.sinch.sdk.domains.voice.models.DtfmModeType; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.domains.voice.models.TransportType; import com.sinch.sdk.domains.voice.models.dto.svaml.ActionConnectConfDtoTest; import com.sinch.sdk.domains.voice.models.dto.svaml.ActionConnectMxpDtoTest; @@ -28,6 +28,7 @@ import com.sinch.sdk.domains.voice.models.svaml.IndicationType; import com.sinch.sdk.domains.voice.models.svaml.Menu; import com.sinch.sdk.domains.voice.models.svaml.MenuOption; +import com.sinch.sdk.domains.voice.models.svaml.MenuOptionAction; import com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; @@ -35,7 +36,7 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -public class SAVMLActionDtoConverterTest { +public class SVAMLActionDtoConverterTest { public static final ActionConnectConference actionConnectConference = ActionConnectConference.builder() @@ -46,7 +47,7 @@ public class SAVMLActionDtoConverterTest { .setMaxDigits(45) .setTimeoutMills(456) .build()) - .setMoh(MohClassType.MUSIC3) + .setMusicOnHold(MusicOnHoldType.MUSIC3) .build(); ActionConnectMxp actionConnectMxp = @@ -63,9 +64,9 @@ public class SAVMLActionDtoConverterTest { .setDialTimeout(456) .setCli("cli value") .setSuppressCallbacks(true) - .setDtmf(DualToneMultiFrequency.valueOf("#w123")) + .setDualToneMultiFrequency(DualToneMultiFrequency.valueOf("#w123")) .setIndications(IndicationType.from("unknown value")) - .setAnsweringMachineDetectionEnabled( + .setAnsweringMachineDetection( AnsweringMachineDetection.builder().setEnabled(true).build()) .build(); @@ -76,8 +77,8 @@ public class SAVMLActionDtoConverterTest { .setCli("a cli value") .setTransport(TransportType.TLS) .setSuppressCallbacks(true) - .setCallheaders(Collections.singletonList(new Pair<>("left string", "right string"))) - .setMoh(MohClassType.MUSIC2) + .setCallHeaders(Collections.singletonList(new Pair<>("left string", "right string"))) + .setMusicOnHold(MusicOnHoldType.MUSIC2) .build(); ActionContinue actionContinue = ActionContinue.builder().build(); @@ -111,7 +112,8 @@ public class SAVMLActionDtoConverterTest { .setOptions( Collections.singletonList( MenuOption.builder() - .setAction(MenuOptionActionType.MENU) + .setAction( + MenuOptionAction.from(MenuOptionActionType.MENU, "foo")) .setDtfm(DualToneMultiFrequency.valueOf("#w")) .build())) .build())) @@ -119,56 +121,56 @@ public class SAVMLActionDtoConverterTest { @Test void convertActionConnectConf() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionConnectConference)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionConnectConference)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionConnectConfDtoTest.dto)); } @Test void convertActionConnectMxp() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionConnectMxp)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionConnectMxp)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionConnectMxpDtoTest.dto)); } @Test void convertActionConnectPstn() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionConnectPstn)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionConnectPstn)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionConnectPstnDtoTest.dto)); } @Test void convertActionConnectSip() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionConnectSip)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionConnectSip)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionConnectSipDtoTest.dto)); } @Test void convertActionContinue() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionContinue)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionContinue)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionContinueDtoTest.dto)); } @Test void convertActionHangup() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionHanghup)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionHanghup)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionHangUpDtoTest.dto)); } @Test void convertActionPark() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionPark)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionPark)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionParkDtoTest.dto)); } @Test void convertActionRunMenu() { - Assertions.assertThat(SAVMLActionDtoConverter.convert(actionRunMenu)) + Assertions.assertThat(SVAMLActionDtoConverter.convert(actionRunMenu)) .usingRecursiveComparison() .isEqualTo(new SvamlActionDto(ActionRunMenuDtoTest.dto)); } diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverterTest.java similarity index 91% rename from client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverterTest.java rename to client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverterTest.java index 994b4ab49..3dfe12578 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SAVMLInstructionDtoConverterTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/SVAMLInstructionDtoConverterTest.java @@ -22,7 +22,7 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -public class SAVMLInstructionDtoConverterTest { +public class SVAMLInstructionDtoConverterTest { public static final InstructionAnswer instructionAnswer = InstructionAnswer.builder().build(); @@ -59,7 +59,7 @@ public class SAVMLInstructionDtoConverterTest { @Test void convertInstructionAnswer() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert(Collections.singletonList(instructionAnswer))) + SVAMLInstructionDtoConverter.convert(Collections.singletonList(instructionAnswer))) .usingRecursiveComparison() .isEqualTo( Collections.singletonList(new SvamlInstructionDto(InstructionAnswerDtoTest.dto))); @@ -68,7 +68,7 @@ void convertInstructionAnswer() { @Test void convertInstructionPlayFiles() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert(Collections.singletonList(instructionPlayFiles))) + SVAMLInstructionDtoConverter.convert(Collections.singletonList(instructionPlayFiles))) .usingRecursiveComparison() .isEqualTo( Collections.singletonList(new SvamlInstructionDto(InstructionPlayFilesDtoTest.dto))); @@ -77,7 +77,7 @@ void convertInstructionPlayFiles() { @Test void convertInstructionSay() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert(Collections.singletonList(instructionSay))) + SVAMLInstructionDtoConverter.convert(Collections.singletonList(instructionSay))) .usingRecursiveComparison() .isEqualTo(Collections.singletonList(new SvamlInstructionDto(InstructionSayDtoTest.dto))); } @@ -85,7 +85,7 @@ void convertInstructionSay() { @Test void convertInstructionSendDtfm() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert(Collections.singletonList(instructionDtfm))) + SVAMLInstructionDtoConverter.convert(Collections.singletonList(instructionDtfm))) .usingRecursiveComparison() .isEqualTo( Collections.singletonList(new SvamlInstructionDto(InstructionSendDtfmDtoTest.dto))); @@ -94,7 +94,7 @@ void convertInstructionSendDtfm() { @Test void convertInstructionSetCookie() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert(Collections.singletonList(instructionSetCookie))) + SVAMLInstructionDtoConverter.convert(Collections.singletonList(instructionSetCookie))) .usingRecursiveComparison() .isEqualTo( Collections.singletonList(new SvamlInstructionDto(InstructionSetCookieDtoTest.dto))); @@ -103,7 +103,7 @@ void convertInstructionSetCookie() { @Test void convertInstructionStartRecording() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert( + SVAMLInstructionDtoConverter.convert( Collections.singletonList(instructionStartRecording))) .usingRecursiveComparison() .isEqualTo( @@ -114,7 +114,7 @@ void convertInstructionStartRecording() { @Test void convertInstructionStopRecording() { Assertions.assertThat( - SAVMLInstructionDtoConverter.convert( + SVAMLInstructionDtoConverter.convert( Collections.singletonList(instructionStopRecording))) .usingRecursiveComparison() .isEqualTo( diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverterTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverterTest.java new file mode 100644 index 000000000..e9bbac2d4 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/voice/adapters/converters/WebhooksEventDtoConverterTest.java @@ -0,0 +1,146 @@ +package com.sinch.sdk.domains.voice.adapters.converters; + +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.core.utils.Pair; +import com.sinch.sdk.domains.voice.models.CallReasonType; +import com.sinch.sdk.domains.voice.models.CallResultType; +import com.sinch.sdk.domains.voice.models.DestinationNumber; +import com.sinch.sdk.domains.voice.models.DomainType; +import com.sinch.sdk.domains.voice.models.Price; +import com.sinch.sdk.domains.voice.models.dto.v1.WebhooksEventDtoTest; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswer; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerReasonType; +import com.sinch.sdk.domains.voice.models.webhooks.AmdAnswerStatusType; +import com.sinch.sdk.domains.voice.models.webhooks.AnsweredCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.DisconnectCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.IncomingCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.MenuInputType; +import com.sinch.sdk.domains.voice.models.webhooks.MenuResult; +import com.sinch.sdk.domains.voice.models.webhooks.MenuResultInputMethodType; +import com.sinch.sdk.domains.voice.models.webhooks.NotifyEvent; +import com.sinch.sdk.domains.voice.models.webhooks.PromptInputEvent; +import java.time.Instant; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +@TestWithResources +public class WebhooksEventDtoConverterTest extends BaseTest { + + public static IncomingCallEvent expectedIncomingCallEvent = + IncomingCallEvent.builder() + .setCallId("a call id") + .setCallResourceUrl("https://calling-euc1.api.sinch.com/calling/v1/calls/id/a call id") + .setTimestamp(Instant.parse("2024-01-16T16:46:36Z")) + .setVersion(1) + .setCli("cli number") + .setUserRate(Price.builder().setCurrencyId("USD").setAmount(0.0F).build()) + .setCustom("my custom") + .setTo(DestinationNumber.valueOf("+123456879")) + .setDomain(DomainType.MXP) + .setApplicationKey("an app key") + .setOriginationType(DomainType.MXP) + .setRdnis("rdnis value") + .setCallHeaders(Collections.singletonList(new Pair<>("the key", "the value"))) + .build(); + + public static DisconnectCallEvent expectedDisconnectCallEvent = + DisconnectCallEvent.builder() + .setCallId("a call id") + .setTimestamp(Instant.parse("2024-01-19T12:49:53Z")) + .setReason(CallReasonType.MANAGER_HANGUP) + .setResult(CallResultType.ANSWERED) + .setVersion(1) + .setCustom("my custom value") + .setDebit(Price.builder().setCurrencyId("EUR").setAmount(0.1758F).build()) + .setUserRate(Price.builder().setCurrencyId("USD").setAmount(0.345F).build()) + .setTo(DestinationNumber.valueOf("123456789")) + .setApplicationKey("an app key") + .setDuration(1) + .setFrom("private") + .build(); + + public static AnsweredCallEvent expectedAnsweredCallEvent = + AnsweredCallEvent.builder() + .setCallId("a call id") + .setTimestamp(Instant.parse("2024-01-19T12:49:53Z")) + .setVersion(1) + .setCustom("my custom value") + .setAmd( + AmdAnswer.builder() + .setStatus(AmdAnswerStatusType.HUMAN) + .setReason(AmdAnswerReasonType.LONG_GREETING) + .setDuration(15) + .build()) + .build(); + + public static PromptInputEvent expectedPromptInputEvent = + PromptInputEvent.builder() + .setCallId("a call id") + .setCustom("my custom value") + .setTimestamp(Instant.parse(("2024-01-23T15:04:28Z"))) + .setVersion(1) + .setApplicationKey("my application key") + .setMenuResult( + MenuResult.builder() + .setMenuId("confirm") + .setType(MenuInputType.SEQUENCE) + .setValue("1452") + .setInputMethod(MenuResultInputMethodType.DTMF) + .build()) + .build(); + + public static NotifyEvent expectedNotifyEvent = + NotifyEvent.builder() + .setCallId("a call id") + .setCustom("my custom value") + .setVersion(1) + .setType("recording_finished") + .build(); + + @Test + void convertIncomingCallRequest() { + + Assertions.assertThat( + WebhooksEventDtoConverter.convert(WebhooksEventDtoTest.expectedIceRequestDto)) + .usingRecursiveComparison() + .isEqualTo(expectedIncomingCallEvent); + } + + @Test + void convertDisconnectCallRequest() { + + Assertions.assertThat( + WebhooksEventDtoConverter.convert(WebhooksEventDtoTest.expectedDiceRequestDto)) + .usingRecursiveComparison() + .isEqualTo(expectedDisconnectCallEvent); + } + + @Test + void convertAnsweredCallEvent() { + + Assertions.assertThat( + WebhooksEventDtoConverter.convert(WebhooksEventDtoTest.expectedAceRequestDto)) + .usingRecursiveComparison() + .isEqualTo(expectedAnsweredCallEvent); + } + + @Test + void convertPieEvent() { + + Assertions.assertThat( + WebhooksEventDtoConverter.convert(WebhooksEventDtoTest.expectedPieRequestDto)) + .usingRecursiveComparison() + .isEqualTo(expectedPromptInputEvent); + } + + @Test + void convertNotifyEvent() { + + Assertions.assertThat( + WebhooksEventDtoConverter.convert(WebhooksEventDtoTest.expectedNotifyRequestDto)) + .usingRecursiveComparison() + .isEqualTo(expectedNotifyEvent); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConferenceTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConferenceTest.java index 70ed863a5..bd305a3fb 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConferenceTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersConferenceTest.java @@ -2,12 +2,11 @@ import static org.junit.jupiter.api.Assertions.*; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.ConferenceDtfmOptions; import com.sinch.sdk.domains.voice.models.DestinationNumber; import com.sinch.sdk.domains.voice.models.DomainType; import com.sinch.sdk.domains.voice.models.DtfmModeType; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; import org.junit.jupiter.api.Test; @@ -33,17 +32,11 @@ public class CalloutRequestParametersConferenceTest { .setEnablePie(Boolean.TRUE) .setLocale("en-US") .setGreeting("Welcome to my conference") - .setMohClass(MohClassType.MUSIC2) + .setMusicOnHold(MusicOnHoldType.MUSIC2) .setCustom("my custom value") .setDomain(DomainType.PSTN) .build(); - @Test - void getMethod() { - assertEquals( - CalloutMethodType.CONFERENCE_CALLOUT, conferenceRequestParameters.getMethod().get()); - } - @Test void getDestination() { assertEquals( @@ -109,7 +102,7 @@ void getGreeting() { @Test void getMohClass() { - assertEquals(MohClassType.MUSIC2, conferenceRequestParameters.getMohClass().get()); + assertEquals(MusicOnHoldType.MUSIC2, conferenceRequestParameters.getMusicOnHold().get()); } @Test diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustomTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustomTest.java index 8719443f4..e5876e556 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustomTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersCustomTest.java @@ -2,10 +2,16 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.DestinationNumber; +import com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn; +import com.sinch.sdk.domains.voice.models.svaml.ActionHangUp; +import com.sinch.sdk.domains.voice.models.svaml.AnsweringMachineDetection; +import com.sinch.sdk.domains.voice.models.svaml.InstructionSay; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; import com.sinch.sdk.models.DualToneMultiFrequency; import com.sinch.sdk.models.E164PhoneNumber; +import java.util.Arrays; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; public class CalloutRequestParametersCustomTest { @@ -18,19 +24,27 @@ public class CalloutRequestParametersCustomTest { .setDtfm(DualToneMultiFrequency.valueOf("w123#")) .setMaxDuration(32) .setIce( - "{\"action\": {\"name\": \"connectPstn\", \"number\": \"+12233445566\", \"cli\":" - + " \"+12234325234\", \"amd\": {\"enabled\": \"true\"}}}") + SVAMLControl.builder() + .setAction( + ActionConnectPstn.builder() + .setCli("+12234325234") + .setNumber(E164PhoneNumber.valueOf("+12233445566")) + .setAnsweringMachineDetection( + AnsweringMachineDetection.builder().setEnabled(true).build()) + .build()) + .build()) .setAce( - "{\"instructions\": [{\"name\": \"say\", \"text\": \"Hello, this is a call from" - + " Sinch!\"}], \"action\": {\"name\": \"hangup\"}}") - .setPie("https://your-application-server-host/application") + SVAMLControl.builder() + .setAction(ActionHangUp.builder().build()) + .setInstructions( + Arrays.asList( + InstructionSay.builder() + .setText("Hello, this is a call from Sinch!") + .build())) + .build()) + .setPie(ControlUrl.from("https://your-application-server-host/application")) .build(); - @Test - void getMethod() { - assertEquals(CalloutMethodType.CUSTOM_CALLOUT, customRequestParameters.getMethod().get()); - } - @Test void getDestination() { assertEquals( @@ -54,23 +68,41 @@ void getCustom() { @Test void getIce() { - assertEquals( - "{\"action\": {\"name\": \"connectPstn\", \"number\": \"+12233445566\", \"cli\":" - + " \"+12234325234\", \"amd\": {\"enabled\": \"true\"}}}", - customRequestParameters.getIce().get()); + Assertions.assertThat( + SVAMLControl.builder() + .setAction( + ActionConnectPstn.builder() + .setCli("+12234325234") + .setNumber(E164PhoneNumber.valueOf("+12233445566")) + .setAnsweringMachineDetection( + AnsweringMachineDetection.builder().setEnabled(true).build()) + .build()) + .build()) + .usingRecursiveComparison() + .isEqualTo(customRequestParameters.getIce().get()); } @Test void getAce() { - assertEquals( - "{\"instructions\": [{\"name\": \"say\", \"text\": \"Hello, this is a call from Sinch!\"}]," - + " \"action\": {\"name\": \"hangup\"}}", - customRequestParameters.getAce().get()); + + Assertions.assertThat( + SVAMLControl.builder() + .setAction(ActionHangUp.builder().build()) + .setInstructions( + Arrays.asList( + InstructionSay.builder() + .setText("Hello, this is a call from Sinch!") + .build())) + .build()) + .usingRecursiveComparison() + .isEqualTo(customRequestParameters.getAce().get()); } @Test void getPie() { - assertEquals( - "https://your-application-server-host/application", customRequestParameters.getPie().get()); + + Assertions.assertThat(ControlUrl.from("https://your-application-server-host/application")) + .usingRecursiveComparison() + .isEqualTo(customRequestParameters.getPie().get()); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTSTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTSTest.java index b29a9d8d3..e83c993ba 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTSTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CalloutRequestParametersTTSTest.java @@ -2,7 +2,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import com.sinch.sdk.domains.voice.models.CalloutMethodType; import com.sinch.sdk.domains.voice.models.DestinationUser; import com.sinch.sdk.domains.voice.models.DomainType; import com.sinch.sdk.models.DualToneMultiFrequency; @@ -28,11 +27,6 @@ public class CalloutRequestParametersTTSTest { + " interpret-as=\"digits\">1234

Please enter it now

]") .build(); - @Test - void getMethod() { - assertEquals(CalloutMethodType.TTS_CALLOUT, ttsRequestParameters.getMethod().get()); - } - @Test void getDestination() { assertEquals( diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParametersTest.java deleted file mode 100644 index c5758282d..000000000 --- a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/CallsUpdateRequestParametersTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sinch.sdk.domains.voice.models.requests; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import com.sinch.sdk.domains.voice.adapters.converters.SAVMLActionDtoConverterTest; -import com.sinch.sdk.domains.voice.adapters.converters.SAVMLInstructionDtoConverterTest; -import java.util.Collections; -import org.junit.jupiter.api.Test; - -public class CallsUpdateRequestParametersTest { - - public static final CallsUpdateRequestParameters parameters = - CallsUpdateRequestParameters.builder() - .setAction(SAVMLActionDtoConverterTest.actionConnectConference) - .setInstructions( - Collections.singletonList(SAVMLInstructionDtoConverterTest.instructionAnswer)) - .build(); - - @Test - void action() { - assertEquals(SAVMLActionDtoConverterTest.actionConnectConference, parameters.getAction()); - } - - @Test - void instructions() { - assertEquals( - Collections.singletonList(SAVMLInstructionDtoConverterTest.instructionAnswer), - parameters.getInstructions()); - } -} diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParametersTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParametersTest.java index 7f73ebe33..3e299f086 100644 --- a/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParametersTest.java +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/requests/ConferenceManageParticipantRequestParametersTest.java @@ -2,7 +2,7 @@ import static org.junit.jupiter.api.Assertions.*; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import org.junit.jupiter.api.Test; public class ConferenceManageParticipantRequestParametersTest { @@ -11,7 +11,7 @@ public class ConferenceManageParticipantRequestParametersTest { conferenceManageParticipantRequestParameters = ConferenceManageParticipantRequestParameters.builder() .setCommand(ConferenceManageParticipantCommandType.UNMUTE) - .setMoh(MohClassType.RING) + .setMusicOnHold(MusicOnHoldType.RING) .build(); @Test @@ -23,6 +23,7 @@ void command() { @Test void moh() { - assertEquals(MohClassType.RING, conferenceManageParticipantRequestParameters.getMoh().get()); + assertEquals( + MusicOnHoldType.RING, conferenceManageParticipantRequestParameters.getMusicOnHold().get()); } } diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionTest.java new file mode 100644 index 000000000..4bcc20dbc --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/MenuOptionActionTest.java @@ -0,0 +1,29 @@ +package com.sinch.sdk.domains.voice.models.svaml; + +import static org.junit.jupiter.api.Assertions.*; + +import org.junit.jupiter.api.Test; + +class MenuOptionActionTest { + + @Test + void getId() { + + assertEquals("an id", MenuOptionAction.from(MenuOptionActionType.MENU, "an id").getId()); + } + + @Test + void getType() { + assertEquals( + MenuOptionActionType.MENU, + MenuOptionAction.from(MenuOptionActionType.MENU, "an id").getType()); + } + + @Test + void throwExceptionOntoNullAction() { + String value = "Action type cannot be null"; + Exception exception = + assertThrows(NullPointerException.class, () -> MenuOptionAction.from(null, "an id")); + assertEquals(exception.getMessage(), value); + } +} diff --git a/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/SVAMLControlTest.java b/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/SVAMLControlTest.java new file mode 100644 index 000000000..84023dfa3 --- /dev/null +++ b/client/src/test/java/com/sinch/sdk/domains/voice/models/svaml/SVAMLControlTest.java @@ -0,0 +1,30 @@ +package com.sinch.sdk.domains.voice.models.svaml; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import com.sinch.sdk.domains.voice.adapters.converters.SVAMLActionDtoConverterTest; +import com.sinch.sdk.domains.voice.adapters.converters.SVAMLInstructionDtoConverterTest; +import java.util.Collections; +import org.junit.jupiter.api.Test; + +public class SVAMLControlTest { + + public static final SVAMLControl parameters = + SVAMLControl.builder() + .setAction(SVAMLActionDtoConverterTest.actionConnectConference) + .setInstructions( + Collections.singletonList(SVAMLInstructionDtoConverterTest.instructionAnswer)) + .build(); + + @Test + void action() { + assertEquals(SVAMLActionDtoConverterTest.actionConnectConference, parameters.getAction().get()); + } + + @Test + void instructions() { + assertEquals( + Collections.singletonList(SVAMLInstructionDtoConverterTest.instructionAnswer), + parameters.getInstructions().get()); + } +} diff --git a/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java b/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java index 5416f6e07..b8d25d464 100644 --- a/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java +++ b/core/src/main/com/sinch/sdk/core/utils/EnumSupportDynamic.java @@ -5,6 +5,7 @@ import java.util.*; import java.util.function.Function; +import java.util.logging.Logger; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -20,6 +21,7 @@ * @param Value instance */ public final class EnumSupportDynamic> { + private static final Logger LOGGER = Logger.getLogger(EnumSupportDynamic.class.getName()); private final Class aClass; private final Map valueMap; @@ -79,6 +81,8 @@ public E from(T value) { if (present == null) { E newValue = surplusFactory.apply(value); + LOGGER.warning(String.format("Dynamically create '%s' from '%s'", newValue, value)); + valueMap.put(value, newValue); values = createImmutableList(values, newValue); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAmdDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAllOfAmdDto.java similarity index 63% rename from openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAmdDto.java rename to openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAllOfAmdDto.java index 182695ed4..0116938e2 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAmdDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestAllOfAmdDto.java @@ -12,11 +12,13 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** @@ -24,17 +26,91 @@ * contains information about whether the call was answered by a machine. */ @JsonPropertyOrder({ - AceRequestAmdDto.JSON_PROPERTY_STATUS, - AceRequestAmdDto.JSON_PROPERTY_REASON, - AceRequestAmdDto.JSON_PROPERTY_DURATION + AceRequestAllOfAmdDto.JSON_PROPERTY_STATUS, + AceRequestAllOfAmdDto.JSON_PROPERTY_REASON, + AceRequestAllOfAmdDto.JSON_PROPERTY_DURATION }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class AceRequestAmdDto { +public class AceRequestAllOfAmdDto { + /** The determination by the system of who answered the call. */ + public enum StatusEnum { + MACHINE("machine"), + + HUMAN("human"), + + NOTSURE("notsure"), + + HANGUP("hangup"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_STATUS = "status"; private String status; private boolean statusDefined = false; + /** The reason that the system used to determine who answered the call. */ + public enum ReasonEnum { + LONGGREETING("longgreeting"), + + INITIALSILENCE("initialsilence"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ReasonEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ReasonEnum fromValue(String value) { + for (ReasonEnum b : ReasonEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_REASON = "reason"; private String reason; private boolean reasonDefined = false; @@ -43,9 +119,9 @@ public class AceRequestAmdDto { private Integer duration; private boolean durationDefined = false; - public AceRequestAmdDto() {} + public AceRequestAllOfAmdDto() {} - public AceRequestAmdDto status(String status) { + public AceRequestAllOfAmdDto status(String status) { this.status = status; this.statusDefined = true; return this; @@ -74,7 +150,7 @@ public void setStatus(String status) { this.statusDefined = true; } - public AceRequestAmdDto reason(String reason) { + public AceRequestAllOfAmdDto reason(String reason) { this.reason = reason; this.reasonDefined = true; return this; @@ -103,7 +179,7 @@ public void setReason(String reason) { this.reasonDefined = true; } - public AceRequestAmdDto duration(Integer duration) { + public AceRequestAllOfAmdDto duration(Integer duration) { this.duration = duration; this.durationDefined = true; return this; @@ -132,7 +208,7 @@ public void setDuration(Integer duration) { this.durationDefined = true; } - /** Return true if this aceRequest_amd object is equal to o. */ + /** Return true if this aceRequest_allOf_amd object is equal to o. */ @Override public boolean equals(Object o) { if (this == o) { @@ -141,10 +217,10 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - AceRequestAmdDto aceRequestAmd = (AceRequestAmdDto) o; - return Objects.equals(this.status, aceRequestAmd.status) - && Objects.equals(this.reason, aceRequestAmd.reason) - && Objects.equals(this.duration, aceRequestAmd.duration); + AceRequestAllOfAmdDto aceRequestAllOfAmd = (AceRequestAllOfAmdDto) o; + return Objects.equals(this.status, aceRequestAllOfAmd.status) + && Objects.equals(this.reason, aceRequestAllOfAmd.reason) + && Objects.equals(this.duration, aceRequestAllOfAmd.duration); } @Override @@ -155,7 +231,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class AceRequestAmdDto {\n"); + sb.append("class AceRequestAllOfAmdDto {\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestDto.java index 200e9af8b..92d374c7a 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/AceRequestDto.java @@ -12,47 +12,92 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; /** The request body of an Answered Call Event. */ @JsonPropertyOrder({ AceRequestDto.JSON_PROPERTY_EVENT, - AceRequestDto.JSON_PROPERTY_CALL_ID, AceRequestDto.JSON_PROPERTY_TIMESTAMP, - AceRequestDto.JSON_PROPERTY_VERSION, AceRequestDto.JSON_PROPERTY_CUSTOM, + AceRequestDto.JSON_PROPERTY_APPLICATION_KEY, AceRequestDto.JSON_PROPERTY_AMD }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class AceRequestDto { + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +public class AceRequestDto extends WebhooksEventRequestDto { + /** Must have the value `ace`. */ + public enum EventEnum { + ACE("ace"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_EVENT = "event"; private String event; private boolean eventDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; - public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; - private String timestamp; + private OffsetDateTime timestamp; private boolean timestampDefined = false; - public static final String JSON_PROPERTY_VERSION = "version"; - private Integer version; - private boolean versionDefined = false; - public static final String JSON_PROPERTY_CUSTOM = "custom"; private String custom; private boolean customDefined = false; + public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; + private String applicationKey; + private boolean applicationKeyDefined = false; + public static final String JSON_PROPERTY_AMD = "amd"; - private AceRequestAmdDto amd; + private AceRequestAllOfAmdDto amd; private boolean amdDefined = false; public AceRequestDto() {} @@ -69,7 +114,7 @@ public AceRequestDto event(String event) { * @return event */ @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getEvent() { return event; } @@ -80,42 +125,13 @@ public boolean getEventDefined() { } @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEvent(String event) { this.event = event; this.eventDefined = true; } - public AceRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; - return this; - } - - /** - * The unique ID assigned to this call. - * - * @return callId - */ - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; - } - - @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; - } - - public AceRequestDto timestamp(String timestamp) { + public AceRequestDto timestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; return this; @@ -128,7 +144,7 @@ public AceRequestDto timestamp(String timestamp) { */ @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getTimestamp() { + public OffsetDateTime getTimestamp() { return timestamp; } @@ -139,70 +155,71 @@ public boolean getTimestampDefined() { @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTimestamp(String timestamp) { + public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; } - public AceRequestDto version(Integer version) { - this.version = version; - this.versionDefined = true; + public AceRequestDto custom(String custom) { + this.custom = custom; + this.customDefined = true; return this; } /** - * The current API version. + * A string that can be used to pass custom information related to the call. * - * @return version + * @return custom */ - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Integer getVersion() { - return version; + public String getCustom() { + return custom; } @JsonIgnore - public boolean getVersionDefined() { - return versionDefined; + public boolean getCustomDefined() { + return customDefined; } - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setVersion(Integer version) { - this.version = version; - this.versionDefined = true; - } - - public AceRequestDto custom(String custom) { + public void setCustom(String custom) { this.custom = custom; this.customDefined = true; + } + + public AceRequestDto applicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; return this; } /** - * A string that can be used to pass custom information related to the call. + * The unique application key. You can find it in the Sinch + * [dashboard](https://dashboard.sinch.com/voice/apps). * - * @return custom + * @return applicationKey */ - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCustom() { - return custom; + public String getApplicationKey() { + return applicationKey; } @JsonIgnore - public boolean getCustomDefined() { - return customDefined; + public boolean getApplicationKeyDefined() { + return applicationKeyDefined; } - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCustom(String custom) { - this.custom = custom; - this.customDefined = true; + public void setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; } - public AceRequestDto amd(AceRequestAmdDto amd) { + public AceRequestDto amd(AceRequestAllOfAmdDto amd) { this.amd = amd; this.amdDefined = true; return this; @@ -215,7 +232,7 @@ public AceRequestDto amd(AceRequestAmdDto amd) { */ @JsonProperty(JSON_PROPERTY_AMD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public AceRequestAmdDto getAmd() { + public AceRequestAllOfAmdDto getAmd() { return amd; } @@ -226,11 +243,23 @@ public boolean getAmdDefined() { @JsonProperty(JSON_PROPERTY_AMD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAmd(AceRequestAmdDto amd) { + public void setAmd(AceRequestAllOfAmdDto amd) { this.amd = amd; this.amdDefined = true; } + @Override + public AceRequestDto callid(String callid) { + this.setCallid(callid); + return this; + } + + @Override + public AceRequestDto version(Integer version) { + this.setVersion(version); + return this; + } + /** Return true if this aceRequest object is equal to o. */ @Override public boolean equals(Object o) { @@ -242,27 +271,27 @@ public boolean equals(Object o) { } AceRequestDto aceRequest = (AceRequestDto) o; return Objects.equals(this.event, aceRequest.event) - && Objects.equals(this.callId, aceRequest.callId) && Objects.equals(this.timestamp, aceRequest.timestamp) - && Objects.equals(this.version, aceRequest.version) && Objects.equals(this.custom, aceRequest.custom) - && Objects.equals(this.amd, aceRequest.amd); + && Objects.equals(this.applicationKey, aceRequest.applicationKey) + && Objects.equals(this.amd, aceRequest.amd) + && super.equals(o); } @Override public int hashCode() { - return Objects.hash(event, callId, timestamp, version, custom, amd); + return Objects.hash(event, timestamp, custom, applicationKey, amd, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AceRequestDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" event: ").append(toIndentedString(event)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); sb.append(" amd: ").append(toIndentedString(amd)).append("\n"); sb.append("}"); return sb.toString(); @@ -277,4 +306,11 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("aceRequest", AceRequestDto.class); + JSONNavigator.registerDiscriminator(AceRequestDto.class, "event", mappings); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/CallResultDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/CallResultDto.java new file mode 100644 index 000000000..39068c706 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/CallResultDto.java @@ -0,0 +1,57 @@ +/* + * Voice API | Sinch + * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. + * + * The version of the OpenAPI document: 1.0.1 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** Contains the result of a call. */ +public enum CallResultDto { + N_A("N/A"), + + ANSWERED("ANSWERED"), + + BUSY("BUSY"), + + NOANSWER("NOANSWER"), + + FAILED("FAILED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + CallResultDto(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static CallResultDto fromValue(String value) { + for (CallResultDto b : CallResultDto.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DestinationTypeDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DestinationTypeDto.java index 692f15506..1978317cd 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DestinationTypeDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DestinationTypeDto.java @@ -30,6 +30,8 @@ public enum DestinationTypeDto { SIP("sip"), + DID("did"), + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDebitDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDebitDto.java deleted file mode 100644 index 7c9897339..000000000 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDebitDto.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Voice API | Sinch - * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. - * - * The version of the OpenAPI document: 1.0.1 - * Contact: support@sinch.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sinch.sdk.domains.voice.models.dto.v1; - -import com.fasterxml.jackson.annotation.JsonFilter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.math.BigDecimal; -import java.util.Objects; - -/** An object containg currency and total amount charged for the call. */ -@JsonPropertyOrder({ - DiceRequestDebitDto.JSON_PROPERTY_CURRENCY_ID, - DiceRequestDebitDto.JSON_PROPERTY_AMOUNT -}) -@JsonFilter("uninitializedFilter") -@JsonInclude(value = JsonInclude.Include.CUSTOM) -public class DiceRequestDebitDto { - public static final String JSON_PROPERTY_CURRENCY_ID = "currencyId"; - private String currencyId; - private boolean currencyIdDefined = false; - - public static final String JSON_PROPERTY_AMOUNT = "amount"; - private BigDecimal amount; - private boolean amountDefined = false; - - public DiceRequestDebitDto() {} - - public DiceRequestDebitDto currencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - return this; - } - - /** - * The currency ID of the rate, for example, `USD`. - * - * @return currencyId - */ - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCurrencyId() { - return currencyId; - } - - @JsonIgnore - public boolean getCurrencyIdDefined() { - return currencyIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCurrencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - } - - public DiceRequestDebitDto amount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - return this; - } - - /** - * The total amount debited for the call. - * - * @return amount - */ - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public BigDecimal getAmount() { - return amount; - } - - @JsonIgnore - public boolean getAmountDefined() { - return amountDefined; - } - - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAmount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - } - - /** Return true if this diceRequest_debit object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DiceRequestDebitDto diceRequestDebit = (DiceRequestDebitDto) o; - return Objects.equals(this.currencyId, diceRequestDebit.currencyId) - && Objects.equals(this.amount, diceRequestDebit.amount); - } - - @Override - public int hashCode() { - return Objects.hash(currencyId, amount); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DiceRequestDebitDto {\n"); - sb.append(" currencyId: ").append(toIndentedString(currencyId)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDto.java index e4112a91b..d5b93b606 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestDto.java @@ -12,73 +12,170 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; /** The request body of a Disconnected Call Event. */ @JsonPropertyOrder({ DiceRequestDto.JSON_PROPERTY_EVENT, - DiceRequestDto.JSON_PROPERTY_CALL_ID, DiceRequestDto.JSON_PROPERTY_TIMESTAMP, + DiceRequestDto.JSON_PROPERTY_CUSTOM, + DiceRequestDto.JSON_PROPERTY_APPLICATION_KEY, DiceRequestDto.JSON_PROPERTY_REASON, DiceRequestDto.JSON_PROPERTY_RESULT, - DiceRequestDto.JSON_PROPERTY_VERSION, - DiceRequestDto.JSON_PROPERTY_CUSTOM, DiceRequestDto.JSON_PROPERTY_DEBIT, DiceRequestDto.JSON_PROPERTY_USER_RATE, DiceRequestDto.JSON_PROPERTY_TO, DiceRequestDto.JSON_PROPERTY_DURATION, DiceRequestDto.JSON_PROPERTY_FROM, - DiceRequestDto.JSON_PROPERTY_CALL_HEADERS, - DiceRequestDto.JSON_PROPERTY_APPLICATION_KEY + DiceRequestDto.JSON_PROPERTY_CALL_HEADERS }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class DiceRequestDto { + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +public class DiceRequestDto extends WebhooksEventRequestDto { + /** Must have the value `dice`. */ + public enum EventEnum { + DICE("dice"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_EVENT = "event"; private String event; private boolean eventDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; - public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; - private String timestamp; + private OffsetDateTime timestamp; private boolean timestampDefined = false; + public static final String JSON_PROPERTY_CUSTOM = "custom"; + private String custom; + private boolean customDefined = false; + + public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; + private String applicationKey; + private boolean applicationKeyDefined = false; + + /** The reason the call was disconnected. */ + public enum ReasonEnum { + N_A("N/A"), + + TIMEOUT("TIMEOUT"), + + CALLERHANGUP("CALLERHANGUP"), + + CALLEEHANGUP("CALLEEHANGUP"), + + BLOCKED("BLOCKED"), + + MANAGERHANGUP("MANAGERHANGUP"), + + NOCREDITPARTNER("NOCREDITPARTNER"), + + GENERALERROR("GENERALERROR"), + + CANCEL("CANCEL"), + + USERNOTFOUND("USERNOTFOUND"), + + CALLBACKERROR("CALLBACKERROR"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ReasonEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static ReasonEnum fromValue(String value) { + for (ReasonEnum b : ReasonEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_REASON = "reason"; private String reason; private boolean reasonDefined = false; public static final String JSON_PROPERTY_RESULT = "result"; - private String result; + private CallResultDto result; private boolean resultDefined = false; - public static final String JSON_PROPERTY_VERSION = "version"; - private Integer version; - private boolean versionDefined = false; - - public static final String JSON_PROPERTY_CUSTOM = "custom"; - private String custom; - private boolean customDefined = false; - public static final String JSON_PROPERTY_DEBIT = "debit"; - private DiceRequestDebitDto debit; + private PriceDto debit; private boolean debitDefined = false; public static final String JSON_PROPERTY_USER_RATE = "userRate"; - private DiceRequestUserRateDto userRate; + private PriceDto userRate; private boolean userRateDefined = false; public static final String JSON_PROPERTY_TO = "to"; - private IceRequestToDto to; + private DestinationDto to; private boolean toDefined = false; public static final String JSON_PROPERTY_DURATION = "duration"; @@ -93,10 +190,6 @@ public class DiceRequestDto { private List callHeaders; private boolean callHeadersDefined = false; - public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; - private String applicationKey; - private boolean applicationKeyDefined = false; - public DiceRequestDto() {} public DiceRequestDto event(String event) { @@ -111,7 +204,7 @@ public DiceRequestDto event(String event) { * @return event */ @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getEvent() { return event; } @@ -122,42 +215,13 @@ public boolean getEventDefined() { } @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEvent(String event) { this.event = event; this.eventDefined = true; } - public DiceRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; - return this; - } - - /** - * The unique ID assigned to this call. - * - * @return callId - */ - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; - } - - @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; - } - - public DiceRequestDto timestamp(String timestamp) { + public DiceRequestDto timestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; return this; @@ -170,7 +234,7 @@ public DiceRequestDto timestamp(String timestamp) { */ @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getTimestamp() { + public OffsetDateTime getTimestamp() { return timestamp; } @@ -181,128 +245,129 @@ public boolean getTimestampDefined() { @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTimestamp(String timestamp) { + public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; } - public DiceRequestDto reason(String reason) { - this.reason = reason; - this.reasonDefined = true; + public DiceRequestDto custom(String custom) { + this.custom = custom; + this.customDefined = true; return this; } /** - * The reason the call was disconnected. + * A string that can be used to pass custom information related to the call. * - * @return reason + * @return custom */ - @JsonProperty(JSON_PROPERTY_REASON) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getReason() { - return reason; + public String getCustom() { + return custom; } @JsonIgnore - public boolean getReasonDefined() { - return reasonDefined; + public boolean getCustomDefined() { + return customDefined; } - @JsonProperty(JSON_PROPERTY_REASON) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setReason(String reason) { - this.reason = reason; - this.reasonDefined = true; + public void setCustom(String custom) { + this.custom = custom; + this.customDefined = true; } - public DiceRequestDto result(String result) { - this.result = result; - this.resultDefined = true; + public DiceRequestDto applicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; return this; } /** - * The result of the call. + * The unique application key. You can find it in the Sinch + * [dashboard](https://dashboard.sinch.com/voice/apps). * - * @return result + * @return applicationKey */ - @JsonProperty(JSON_PROPERTY_RESULT) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getResult() { - return result; + public String getApplicationKey() { + return applicationKey; } @JsonIgnore - public boolean getResultDefined() { - return resultDefined; + public boolean getApplicationKeyDefined() { + return applicationKeyDefined; } - @JsonProperty(JSON_PROPERTY_RESULT) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setResult(String result) { - this.result = result; - this.resultDefined = true; + public void setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; } - public DiceRequestDto version(Integer version) { - this.version = version; - this.versionDefined = true; + public DiceRequestDto reason(String reason) { + this.reason = reason; + this.reasonDefined = true; return this; } /** - * The current API version. + * The reason the call was disconnected. * - * @return version + * @return reason */ - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_REASON) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Integer getVersion() { - return version; + public String getReason() { + return reason; } @JsonIgnore - public boolean getVersionDefined() { - return versionDefined; + public boolean getReasonDefined() { + return reasonDefined; } - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_REASON) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setVersion(Integer version) { - this.version = version; - this.versionDefined = true; + public void setReason(String reason) { + this.reason = reason; + this.reasonDefined = true; } - public DiceRequestDto custom(String custom) { - this.custom = custom; - this.customDefined = true; + public DiceRequestDto result(CallResultDto result) { + this.result = result; + this.resultDefined = true; return this; } /** - * A string that can be used to pass custom information related to the call. + * Get result * - * @return custom + * @return result */ - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCustom() { - return custom; + public CallResultDto getResult() { + return result; } @JsonIgnore - public boolean getCustomDefined() { - return customDefined; + public boolean getResultDefined() { + return resultDefined; } - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCustom(String custom) { - this.custom = custom; - this.customDefined = true; + public void setResult(CallResultDto result) { + this.result = result; + this.resultDefined = true; } - public DiceRequestDto debit(DiceRequestDebitDto debit) { + public DiceRequestDto debit(PriceDto debit) { this.debit = debit; this.debitDefined = true; return this; @@ -315,7 +380,7 @@ public DiceRequestDto debit(DiceRequestDebitDto debit) { */ @JsonProperty(JSON_PROPERTY_DEBIT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public DiceRequestDebitDto getDebit() { + public PriceDto getDebit() { return debit; } @@ -326,12 +391,12 @@ public boolean getDebitDefined() { @JsonProperty(JSON_PROPERTY_DEBIT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setDebit(DiceRequestDebitDto debit) { + public void setDebit(PriceDto debit) { this.debit = debit; this.debitDefined = true; } - public DiceRequestDto userRate(DiceRequestUserRateDto userRate) { + public DiceRequestDto userRate(PriceDto userRate) { this.userRate = userRate; this.userRateDefined = true; return this; @@ -344,7 +409,7 @@ public DiceRequestDto userRate(DiceRequestUserRateDto userRate) { */ @JsonProperty(JSON_PROPERTY_USER_RATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public DiceRequestUserRateDto getUserRate() { + public PriceDto getUserRate() { return userRate; } @@ -355,12 +420,12 @@ public boolean getUserRateDefined() { @JsonProperty(JSON_PROPERTY_USER_RATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setUserRate(DiceRequestUserRateDto userRate) { + public void setUserRate(PriceDto userRate) { this.userRate = userRate; this.userRateDefined = true; } - public DiceRequestDto to(IceRequestToDto to) { + public DiceRequestDto to(DestinationDto to) { this.to = to; this.toDefined = true; return this; @@ -373,7 +438,7 @@ public DiceRequestDto to(IceRequestToDto to) { */ @JsonProperty(JSON_PROPERTY_TO) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public IceRequestToDto getTo() { + public DestinationDto getTo() { return to; } @@ -384,7 +449,7 @@ public boolean getToDefined() { @JsonProperty(JSON_PROPERTY_TO) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTo(IceRequestToDto to) { + public void setTo(DestinationDto to) { this.to = to; this.toDefined = true; } @@ -486,34 +551,16 @@ public void setCallHeaders(List callHeaders) { this.callHeadersDefined = true; } - public DiceRequestDto applicationKey(String applicationKey) { - this.applicationKey = applicationKey; - this.applicationKeyDefined = true; + @Override + public DiceRequestDto callid(String callid) { + this.setCallid(callid); return this; } - /** - * The unique application key. You can find it in the Sinch - * [dashboard](https://dashboard.sinch.com/voice/apps). - * - * @return applicationKey - */ - @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApplicationKey() { - return applicationKey; - } - - @JsonIgnore - public boolean getApplicationKeyDefined() { - return applicationKeyDefined; - } - - @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - this.applicationKeyDefined = true; + @Override + public DiceRequestDto version(Integer version) { + this.setVersion(version); + return this; } /** Return true if this diceRequest object is equal to o. */ @@ -527,58 +574,55 @@ public boolean equals(Object o) { } DiceRequestDto diceRequest = (DiceRequestDto) o; return Objects.equals(this.event, diceRequest.event) - && Objects.equals(this.callId, diceRequest.callId) && Objects.equals(this.timestamp, diceRequest.timestamp) + && Objects.equals(this.custom, diceRequest.custom) + && Objects.equals(this.applicationKey, diceRequest.applicationKey) && Objects.equals(this.reason, diceRequest.reason) && Objects.equals(this.result, diceRequest.result) - && Objects.equals(this.version, diceRequest.version) - && Objects.equals(this.custom, diceRequest.custom) && Objects.equals(this.debit, diceRequest.debit) && Objects.equals(this.userRate, diceRequest.userRate) && Objects.equals(this.to, diceRequest.to) && Objects.equals(this.duration, diceRequest.duration) && Objects.equals(this.from, diceRequest.from) && Objects.equals(this.callHeaders, diceRequest.callHeaders) - && Objects.equals(this.applicationKey, diceRequest.applicationKey); + && super.equals(o); } @Override public int hashCode() { return Objects.hash( event, - callId, timestamp, + custom, + applicationKey, reason, result, - version, - custom, debit, userRate, to, duration, from, callHeaders, - applicationKey); + super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class DiceRequestDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" event: ").append(toIndentedString(event)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); sb.append(" reason: ").append(toIndentedString(reason)).append("\n"); sb.append(" result: ").append(toIndentedString(result)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); - sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); sb.append(" debit: ").append(toIndentedString(debit)).append("\n"); sb.append(" userRate: ").append(toIndentedString(userRate)).append("\n"); sb.append(" to: ").append(toIndentedString(to)).append("\n"); sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); sb.append(" from: ").append(toIndentedString(from)).append("\n"); sb.append(" callHeaders: ").append(toIndentedString(callHeaders)).append("\n"); - sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); sb.append("}"); return sb.toString(); } @@ -592,4 +636,11 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("diceRequest", DiceRequestDto.class); + JSONNavigator.registerDiscriminator(DiceRequestDto.class, "event", mappings); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestUserRateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestUserRateDto.java deleted file mode 100644 index 7bf00c45e..000000000 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DiceRequestUserRateDto.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Voice API | Sinch - * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. - * - * The version of the OpenAPI document: 1.0.1 - * Contact: support@sinch.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sinch.sdk.domains.voice.models.dto.v1; - -import com.fasterxml.jackson.annotation.JsonFilter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.math.BigDecimal; -import java.util.Objects; - -/** An object containg currency and rate per minute for the call. */ -@JsonPropertyOrder({ - DiceRequestUserRateDto.JSON_PROPERTY_CURRENCY_ID, - DiceRequestUserRateDto.JSON_PROPERTY_AMOUNT -}) -@JsonFilter("uninitializedFilter") -@JsonInclude(value = JsonInclude.Include.CUSTOM) -public class DiceRequestUserRateDto { - public static final String JSON_PROPERTY_CURRENCY_ID = "currencyId"; - private String currencyId; - private boolean currencyIdDefined = false; - - public static final String JSON_PROPERTY_AMOUNT = "amount"; - private BigDecimal amount; - private boolean amountDefined = false; - - public DiceRequestUserRateDto() {} - - public DiceRequestUserRateDto currencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - return this; - } - - /** - * The currency in which the call is charged. - * - * @return currencyId - */ - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCurrencyId() { - return currencyId; - } - - @JsonIgnore - public boolean getCurrencyIdDefined() { - return currencyIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCurrencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - } - - public DiceRequestUserRateDto amount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - return this; - } - - /** - * The rate per minute that was charged for the call. - * - * @return amount - */ - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public BigDecimal getAmount() { - return amount; - } - - @JsonIgnore - public boolean getAmountDefined() { - return amountDefined; - } - - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAmount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - } - - /** Return true if this diceRequest_userRate object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - DiceRequestUserRateDto diceRequestUserRate = (DiceRequestUserRateDto) o; - return Objects.equals(this.currencyId, diceRequestUserRate.currencyId) - && Objects.equals(this.amount, diceRequestUserRate.amount); - } - - @Override - public int hashCode() { - return Objects.hash(currencyId, amount); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class DiceRequestUserRateDto {\n"); - sb.append(" currencyId: ").append(toIndentedString(currencyId)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DomainDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DomainDto.java new file mode 100644 index 000000000..6c0453efb --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/DomainDto.java @@ -0,0 +1,58 @@ +/* + * Voice API | Sinch + * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. + * + * The version of the OpenAPI document: 1.0.1 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * Can be either `pstn` for PSTN endpoint or `mxp` for data (app or web) + * clients. + */ +public enum DomainDto { + PSTN("pstn"), + + MXP("mxp"), + + PSTN2("PSTN"), + + MXP2("MXP"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + DomainDto(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static DomainDto fromValue(String value) { + for (DomainDto b : DomainDto.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/GetCallResponseObjDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/GetCallResponseObjDto.java index d36534dbc..a12803460 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/GetCallResponseObjDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/GetCallResponseObjDto.java @@ -132,49 +132,8 @@ public static StatusEnum fromValue(String value) { private String status; private boolean statusDefined = false; - /** Contains the result of a call. */ - public enum ResultEnum { - N_A("N/A"), - - ANSWERED("ANSWERED"), - - BUSY("BUSY"), - - NOANSWER("NOANSWER"), - - FAILED("FAILED"), - - UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); - - private String value; - - ResultEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static ResultEnum fromValue(String value) { - for (ResultEnum b : ResultEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - return UNKNOWN_DEFAULT_OPEN_API; - } - } - public static final String JSON_PROPERTY_RESULT = "result"; - private String result; + private CallResultDto result; private boolean resultDefined = false; /** Contains the reason why a call ended. */ @@ -197,6 +156,8 @@ public enum ReasonEnum { GENERALERROR("GENERALERROR"), + INVALIDSVAMLACTION("INVALIDSVAMLACTION"), + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); private String value; @@ -422,20 +383,20 @@ public void setStatus(String status) { this.statusDefined = true; } - public GetCallResponseObjDto result(String result) { + public GetCallResponseObjDto result(CallResultDto result) { this.result = result; this.resultDefined = true; return this; } /** - * Contains the result of a call. + * Get result * * @return result */ @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getResult() { + public CallResultDto getResult() { return result; } @@ -446,7 +407,7 @@ public boolean getResultDefined() { @JsonProperty(JSON_PROPERTY_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setResult(String result) { + public void setResult(CallResultDto result) { this.result = result; this.resultDefined = true; } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestDto.java index b87bf4794..fe744f07a 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestDto.java @@ -12,28 +12,33 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Objects; /** The request body of an Incoming Call Event. */ @JsonPropertyOrder({ IceRequestDto.JSON_PROPERTY_EVENT, - IceRequestDto.JSON_PROPERTY_CALL_ID, - IceRequestDto.JSON_PROPERTY_CALL_RESOURCE_URL, IceRequestDto.JSON_PROPERTY_TIMESTAMP, - IceRequestDto.JSON_PROPERTY_VERSION, IceRequestDto.JSON_PROPERTY_CUSTOM, + IceRequestDto.JSON_PROPERTY_APPLICATION_KEY, + IceRequestDto.JSON_PROPERTY_CALL_RESOURCE_URL, IceRequestDto.JSON_PROPERTY_USER_RATE, IceRequestDto.JSON_PROPERTY_CLI, IceRequestDto.JSON_PROPERTY_TO, IceRequestDto.JSON_PROPERTY_DOMAIN, - IceRequestDto.JSON_PROPERTY_APPLICATION_KEY, IceRequestDto.JSON_PROPERTY_ORIGINATION_TYPE, IceRequestDto.JSON_PROPERTY_DURATION, IceRequestDto.JSON_PROPERTY_RDNIS, @@ -41,33 +46,72 @@ }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class IceRequestDto { + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +public class IceRequestDto extends WebhooksEventRequestDto { + /** Must have the value `ice`. */ + public enum EventEnum { + ICE("ice"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_EVENT = "event"; private String event; private boolean eventDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; - - public static final String JSON_PROPERTY_CALL_RESOURCE_URL = "callResourceUrl"; - private String callResourceUrl; - private boolean callResourceUrlDefined = false; - public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; - private String timestamp; + private OffsetDateTime timestamp; private boolean timestampDefined = false; - public static final String JSON_PROPERTY_VERSION = "version"; - private Integer version; - private boolean versionDefined = false; - public static final String JSON_PROPERTY_CUSTOM = "custom"; private String custom; private boolean customDefined = false; + public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; + private String applicationKey; + private boolean applicationKeyDefined = false; + + public static final String JSON_PROPERTY_CALL_RESOURCE_URL = "callResourceUrl"; + private String callResourceUrl; + private boolean callResourceUrlDefined = false; + public static final String JSON_PROPERTY_USER_RATE = "userRate"; - private IceRequestUserRateDto userRate; + private PriceDto userRate; private boolean userRateDefined = false; public static final String JSON_PROPERTY_CLI = "cli"; @@ -75,19 +119,15 @@ public class IceRequestDto { private boolean cliDefined = false; public static final String JSON_PROPERTY_TO = "to"; - private IceRequestToDto to; + private DestinationDto to; private boolean toDefined = false; public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private DomainDto domain; private boolean domainDefined = false; - public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; - private String applicationKey; - private boolean applicationKeyDefined = false; - public static final String JSON_PROPERTY_ORIGINATION_TYPE = "originationType"; - private String originationType; + private DomainDto originationType; private boolean originationTypeDefined = false; public static final String JSON_PROPERTY_DURATION = "duration"; @@ -116,7 +156,7 @@ public IceRequestDto event(String event) { * @return event */ @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getEvent() { return event; } @@ -127,158 +167,130 @@ public boolean getEventDefined() { } @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEvent(String event) { this.event = event; this.eventDefined = true; } - public IceRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; - return this; - } - - /** - * The unique ID assigned to this call. - * - * @return callId - */ - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; - } - - @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; - } - - public IceRequestDto callResourceUrl(String callResourceUrl) { - this.callResourceUrl = callResourceUrl; - this.callResourceUrlDefined = true; + public IceRequestDto timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + this.timestampDefined = true; return this; } /** - * The path of the API resource. + * The timestamp in UTC format. * - * @return callResourceUrl + * @return timestamp */ - @JsonProperty(JSON_PROPERTY_CALL_RESOURCE_URL) + @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallResourceUrl() { - return callResourceUrl; + public OffsetDateTime getTimestamp() { + return timestamp; } @JsonIgnore - public boolean getCallResourceUrlDefined() { - return callResourceUrlDefined; + public boolean getTimestampDefined() { + return timestampDefined; } - @JsonProperty(JSON_PROPERTY_CALL_RESOURCE_URL) + @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallResourceUrl(String callResourceUrl) { - this.callResourceUrl = callResourceUrl; - this.callResourceUrlDefined = true; - } - - public IceRequestDto timestamp(String timestamp) { + public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; + } + + public IceRequestDto custom(String custom) { + this.custom = custom; + this.customDefined = true; return this; } /** - * The timestamp in UTC format. + * A string that can be used to pass custom information related to the call. * - * @return timestamp + * @return custom */ - @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getTimestamp() { - return timestamp; + public String getCustom() { + return custom; } @JsonIgnore - public boolean getTimestampDefined() { - return timestampDefined; + public boolean getCustomDefined() { + return customDefined; } - @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTimestamp(String timestamp) { - this.timestamp = timestamp; - this.timestampDefined = true; + public void setCustom(String custom) { + this.custom = custom; + this.customDefined = true; } - public IceRequestDto version(Integer version) { - this.version = version; - this.versionDefined = true; + public IceRequestDto applicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; return this; } /** - * The current API version. + * The unique application key. You can find it in the Sinch + * [dashboard](https://dashboard.sinch.com/voice/apps). * - * @return version + * @return applicationKey */ - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Integer getVersion() { - return version; + public String getApplicationKey() { + return applicationKey; } @JsonIgnore - public boolean getVersionDefined() { - return versionDefined; + public boolean getApplicationKeyDefined() { + return applicationKeyDefined; } - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setVersion(Integer version) { - this.version = version; - this.versionDefined = true; + public void setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; } - public IceRequestDto custom(String custom) { - this.custom = custom; - this.customDefined = true; + public IceRequestDto callResourceUrl(String callResourceUrl) { + this.callResourceUrl = callResourceUrl; + this.callResourceUrlDefined = true; return this; } /** - * A string that can be used to pass custom information related to the call. + * The path of the API resource. * - * @return custom + * @return callResourceUrl */ - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_CALL_RESOURCE_URL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCustom() { - return custom; + public String getCallResourceUrl() { + return callResourceUrl; } @JsonIgnore - public boolean getCustomDefined() { - return customDefined; + public boolean getCallResourceUrlDefined() { + return callResourceUrlDefined; } - @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonProperty(JSON_PROPERTY_CALL_RESOURCE_URL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCustom(String custom) { - this.custom = custom; - this.customDefined = true; + public void setCallResourceUrl(String callResourceUrl) { + this.callResourceUrl = callResourceUrl; + this.callResourceUrlDefined = true; } - public IceRequestDto userRate(IceRequestUserRateDto userRate) { + public IceRequestDto userRate(PriceDto userRate) { this.userRate = userRate; this.userRateDefined = true; return this; @@ -291,7 +303,7 @@ public IceRequestDto userRate(IceRequestUserRateDto userRate) { */ @JsonProperty(JSON_PROPERTY_USER_RATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public IceRequestUserRateDto getUserRate() { + public PriceDto getUserRate() { return userRate; } @@ -302,7 +314,7 @@ public boolean getUserRateDefined() { @JsonProperty(JSON_PROPERTY_USER_RATE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setUserRate(IceRequestUserRateDto userRate) { + public void setUserRate(PriceDto userRate) { this.userRate = userRate; this.userRateDefined = true; } @@ -339,7 +351,7 @@ public void setCli(String cli) { this.cliDefined = true; } - public IceRequestDto to(IceRequestToDto to) { + public IceRequestDto to(DestinationDto to) { this.to = to; this.toDefined = true; return this; @@ -352,7 +364,7 @@ public IceRequestDto to(IceRequestToDto to) { */ @JsonProperty(JSON_PROPERTY_TO) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public IceRequestToDto getTo() { + public DestinationDto getTo() { return to; } @@ -363,25 +375,25 @@ public boolean getToDefined() { @JsonProperty(JSON_PROPERTY_TO) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTo(IceRequestToDto to) { + public void setTo(DestinationDto to) { this.to = to; this.toDefined = true; } - public IceRequestDto domain(String domain) { + public IceRequestDto domain(DomainDto domain) { this.domain = domain; this.domainDefined = true; return this; } /** - * The domain destination of the incoming call. + * Get domain * * @return domain */ @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getDomain() { + public DomainDto getDomain() { return domain; } @@ -392,55 +404,25 @@ public boolean getDomainDefined() { @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setDomain(String domain) { + public void setDomain(DomainDto domain) { this.domain = domain; this.domainDefined = true; } - public IceRequestDto applicationKey(String applicationKey) { - this.applicationKey = applicationKey; - this.applicationKeyDefined = true; - return this; - } - - /** - * The unique application key. You can find it in the Sinch - * [dashboard](https://dashboard.sinch.com/voice/apps). - * - * @return applicationKey - */ - @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApplicationKey() { - return applicationKey; - } - - @JsonIgnore - public boolean getApplicationKeyDefined() { - return applicationKeyDefined; - } - - @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setApplicationKey(String applicationKey) { - this.applicationKey = applicationKey; - this.applicationKeyDefined = true; - } - - public IceRequestDto originationType(String originationType) { + public IceRequestDto originationType(DomainDto originationType) { this.originationType = originationType; this.originationTypeDefined = true; return this; } /** - * The origination domain of the incoming call. + * Get originationType * * @return originationType */ @JsonProperty(JSON_PROPERTY_ORIGINATION_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getOriginationType() { + public DomainDto getOriginationType() { return originationType; } @@ -451,7 +433,7 @@ public boolean getOriginationTypeDefined() { @JsonProperty(JSON_PROPERTY_ORIGINATION_TYPE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setOriginationType(String originationType) { + public void setOriginationType(DomainDto originationType) { this.originationType = originationType; this.originationTypeDefined = true; } @@ -553,6 +535,18 @@ public void setCallHeaders(List callHeaders) { this.callHeadersDefined = true; } + @Override + public IceRequestDto callid(String callid) { + this.setCallid(callid); + return this; + } + + @Override + public IceRequestDto version(Integer version) { + this.setVersion(version); + return this; + } + /** Return true if this iceRequest object is equal to o. */ @Override public boolean equals(Object o) { @@ -564,57 +558,54 @@ public boolean equals(Object o) { } IceRequestDto iceRequest = (IceRequestDto) o; return Objects.equals(this.event, iceRequest.event) - && Objects.equals(this.callId, iceRequest.callId) - && Objects.equals(this.callResourceUrl, iceRequest.callResourceUrl) && Objects.equals(this.timestamp, iceRequest.timestamp) - && Objects.equals(this.version, iceRequest.version) && Objects.equals(this.custom, iceRequest.custom) + && Objects.equals(this.applicationKey, iceRequest.applicationKey) + && Objects.equals(this.callResourceUrl, iceRequest.callResourceUrl) && Objects.equals(this.userRate, iceRequest.userRate) && Objects.equals(this.cli, iceRequest.cli) && Objects.equals(this.to, iceRequest.to) && Objects.equals(this.domain, iceRequest.domain) - && Objects.equals(this.applicationKey, iceRequest.applicationKey) && Objects.equals(this.originationType, iceRequest.originationType) && Objects.equals(this.duration, iceRequest.duration) && Objects.equals(this.rdnis, iceRequest.rdnis) - && Objects.equals(this.callHeaders, iceRequest.callHeaders); + && Objects.equals(this.callHeaders, iceRequest.callHeaders) + && super.equals(o); } @Override public int hashCode() { return Objects.hash( event, - callId, - callResourceUrl, timestamp, - version, custom, + applicationKey, + callResourceUrl, userRate, cli, to, domain, - applicationKey, originationType, duration, rdnis, - callHeaders); + callHeaders, + super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class IceRequestDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" event: ").append(toIndentedString(event)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); - sb.append(" callResourceUrl: ").append(toIndentedString(callResourceUrl)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); + sb.append(" callResourceUrl: ").append(toIndentedString(callResourceUrl)).append("\n"); sb.append(" userRate: ").append(toIndentedString(userRate)).append("\n"); sb.append(" cli: ").append(toIndentedString(cli)).append("\n"); sb.append(" to: ").append(toIndentedString(to)).append("\n"); sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); - sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); sb.append(" originationType: ").append(toIndentedString(originationType)).append("\n"); sb.append(" duration: ").append(toIndentedString(duration)).append("\n"); sb.append(" rdnis: ").append(toIndentedString(rdnis)).append("\n"); @@ -632,4 +623,11 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("iceRequest", IceRequestDto.class); + JSONNavigator.registerDiscriminator(IceRequestDto.class, "event", mappings); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestToDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestToDto.java deleted file mode 100644 index 3ac9f758d..000000000 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestToDto.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Voice API | Sinch - * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. - * - * The version of the OpenAPI document: 1.0.1 - * Contact: support@sinch.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sinch.sdk.domains.voice.models.dto.v1; - -import com.fasterxml.jackson.annotation.JsonFilter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.util.Objects; - -/** An object containing information about the recipient of the call. */ -@JsonPropertyOrder({IceRequestToDto.JSON_PROPERTY_TYPE, IceRequestToDto.JSON_PROPERTY_ENDPOINT}) -@JsonFilter("uninitializedFilter") -@JsonInclude(value = JsonInclude.Include.CUSTOM) -public class IceRequestToDto { - public static final String JSON_PROPERTY_TYPE = "type"; - private String type; - private boolean typeDefined = false; - - public static final String JSON_PROPERTY_ENDPOINT = "endpoint"; - private String endpoint; - private boolean endpointDefined = false; - - public IceRequestToDto() {} - - public IceRequestToDto type(String type) { - this.type = type; - this.typeDefined = true; - return this; - } - - /** - * The type of the destination. - * - * @return type - */ - @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getType() { - return type; - } - - @JsonIgnore - public boolean getTypeDefined() { - return typeDefined; - } - - @JsonProperty(JSON_PROPERTY_TYPE) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setType(String type) { - this.type = type; - this.typeDefined = true; - } - - public IceRequestToDto endpoint(String endpoint) { - this.endpoint = endpoint; - this.endpointDefined = true; - return this; - } - - /** - * The phone number, user name, or other identifier of the destination. - * - * @return endpoint - */ - @JsonProperty(JSON_PROPERTY_ENDPOINT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getEndpoint() { - return endpoint; - } - - @JsonIgnore - public boolean getEndpointDefined() { - return endpointDefined; - } - - @JsonProperty(JSON_PROPERTY_ENDPOINT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - this.endpointDefined = true; - } - - /** Return true if this iceRequest_to object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - IceRequestToDto iceRequestTo = (IceRequestToDto) o; - return Objects.equals(this.type, iceRequestTo.type) - && Objects.equals(this.endpoint, iceRequestTo.endpoint); - } - - @Override - public int hashCode() { - return Objects.hash(type, endpoint); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class IceRequestToDto {\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" endpoint: ").append(toIndentedString(endpoint)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestUserRateDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestUserRateDto.java deleted file mode 100644 index 9a9c30274..000000000 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/IceRequestUserRateDto.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Voice API | Sinch - * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. - * - * The version of the OpenAPI document: 1.0.1 - * Contact: support@sinch.com - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package com.sinch.sdk.domains.voice.models.dto.v1; - -import com.fasterxml.jackson.annotation.JsonFilter; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.math.BigDecimal; -import java.util.Objects; - -/** - * The rate that will be charged for the call established to the original destination. If the SVAML - * response specifies another destination, the same rate may not apply. - */ -@JsonPropertyOrder({ - IceRequestUserRateDto.JSON_PROPERTY_CURRENCY_ID, - IceRequestUserRateDto.JSON_PROPERTY_AMOUNT -}) -@JsonFilter("uninitializedFilter") -@JsonInclude(value = JsonInclude.Include.CUSTOM) -public class IceRequestUserRateDto { - public static final String JSON_PROPERTY_CURRENCY_ID = "currencyId"; - private String currencyId; - private boolean currencyIdDefined = false; - - public static final String JSON_PROPERTY_AMOUNT = "amount"; - private BigDecimal amount; - private boolean amountDefined = false; - - public IceRequestUserRateDto() {} - - public IceRequestUserRateDto currencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - return this; - } - - /** - * The currency ID of the rate, for example, `USD`. - * - * @return currencyId - */ - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCurrencyId() { - return currencyId; - } - - @JsonIgnore - public boolean getCurrencyIdDefined() { - return currencyIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CURRENCY_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCurrencyId(String currencyId) { - this.currencyId = currencyId; - this.currencyIdDefined = true; - } - - public IceRequestUserRateDto amount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - return this; - } - - /** - * The amount of the rate. - * - * @return amount - */ - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public BigDecimal getAmount() { - return amount; - } - - @JsonIgnore - public boolean getAmountDefined() { - return amountDefined; - } - - @JsonProperty(JSON_PROPERTY_AMOUNT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAmount(BigDecimal amount) { - this.amount = amount; - this.amountDefined = true; - } - - /** Return true if this iceRequest_userRate object is equal to o. */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - IceRequestUserRateDto iceRequestUserRate = (IceRequestUserRateDto) o; - return Objects.equals(this.currencyId, iceRequestUserRate.currencyId) - && Objects.equals(this.amount, iceRequestUserRate.amount); - } - - @Override - public int hashCode() { - return Objects.hash(currencyId, amount); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class IceRequestUserRateDto {\n"); - sb.append(" currencyId: ").append(toIndentedString(currencyId)).append("\n"); - sb.append(" amount: ").append(toIndentedString(amount)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyErrorRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyErrorRequestDto.java index 429467424..6f6f1b355 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyErrorRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyErrorRequestDto.java @@ -24,7 +24,7 @@ NotifyErrorRequestDto.JSON_PROPERTY_EVENT, NotifyErrorRequestDto.JSON_PROPERTY_VERSION, NotifyErrorRequestDto.JSON_PROPERTY_TYPE, - NotifyErrorRequestDto.JSON_PROPERTY_CALL_ID, + NotifyErrorRequestDto.JSON_PROPERTY_CALLID, NotifyErrorRequestDto.JSON_PROPERTY_ERROR_CODE, NotifyErrorRequestDto.JSON_PROPERTY_ERROR_MSG, NotifyErrorRequestDto.JSON_PROPERTY_USER, @@ -45,9 +45,9 @@ public class NotifyErrorRequestDto { private String type; private boolean typeDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; + public static final String JSON_PROPERTY_CALLID = "callid"; + private String callid; + private boolean callidDefined = false; public static final String JSON_PROPERTY_ERROR_CODE = "errorCode"; private Integer errorCode; @@ -155,33 +155,33 @@ public void setType(String type) { this.typeDefined = true; } - public NotifyErrorRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; + public NotifyErrorRequestDto callid(String callid) { + this.callid = callid; + this.callidDefined = true; return this; } /** * The unique ID assigned to this call. * - * @return callId + * @return callid */ - @JsonProperty(JSON_PROPERTY_CALL_ID) + @JsonProperty(JSON_PROPERTY_CALLID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; + public String getCallid() { + return callid; } @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; + public boolean getCallidDefined() { + return callidDefined; } - @JsonProperty(JSON_PROPERTY_CALL_ID) + @JsonProperty(JSON_PROPERTY_CALLID) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; + public void setCallid(String callid) { + this.callid = callid; + this.callidDefined = true; } public NotifyErrorRequestDto errorCode(Integer errorCode) { @@ -313,7 +313,7 @@ public boolean equals(Object o) { return Objects.equals(this.event, notifyErrorRequest.event) && Objects.equals(this.version, notifyErrorRequest.version) && Objects.equals(this.type, notifyErrorRequest.type) - && Objects.equals(this.callId, notifyErrorRequest.callId) + && Objects.equals(this.callid, notifyErrorRequest.callid) && Objects.equals(this.errorCode, notifyErrorRequest.errorCode) && Objects.equals(this.errorMsg, notifyErrorRequest.errorMsg) && Objects.equals(this.user, notifyErrorRequest.user) @@ -322,7 +322,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(event, version, type, callId, errorCode, errorMsg, user, custom); + return Objects.hash(event, version, type, callid, errorCode, errorMsg, user, custom); } @Override @@ -332,7 +332,7 @@ public String toString() { sb.append(" event: ").append(toIndentedString(event)).append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); + sb.append(" callid: ").append(toIndentedString(callid)).append("\n"); sb.append(" errorCode: ").append(toIndentedString(errorCode)).append("\n"); sb.append(" errorMsg: ").append(toIndentedString(errorMsg)).append("\n"); sb.append(" user: ").append(toIndentedString(user)).append("\n"); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyRequestDto.java index 8ec0882fe..0dbb48338 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/NotifyRequestDto.java @@ -12,36 +12,75 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; /** The request body of a Notify Event. */ @JsonPropertyOrder({ NotifyRequestDto.JSON_PROPERTY_EVENT, - NotifyRequestDto.JSON_PROPERTY_CALL_ID, - NotifyRequestDto.JSON_PROPERTY_VERSION, NotifyRequestDto.JSON_PROPERTY_TYPE, NotifyRequestDto.JSON_PROPERTY_CUSTOM }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class NotifyRequestDto { + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +public class NotifyRequestDto extends WebhooksEventRequestDto { + /** Must have the value `notify`. */ + public enum EventEnum { + NOTIFY("notify"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_EVENT = "event"; private String event; private boolean eventDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; - - public static final String JSON_PROPERTY_VERSION = "version"; - private Integer version; - private boolean versionDefined = false; - public static final String JSON_PROPERTY_TYPE = "type"; private String type; private boolean typeDefined = false; @@ -81,64 +120,6 @@ public void setEvent(String event) { this.eventDefined = true; } - public NotifyRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; - return this; - } - - /** - * The unique ID assigned to this call. - * - * @return callId - */ - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; - } - - @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; - } - - public NotifyRequestDto version(Integer version) { - this.version = version; - this.versionDefined = true; - return this; - } - - /** - * The current API version. - * - * @return version - */ - @JsonProperty(JSON_PROPERTY_VERSION) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Integer getVersion() { - return version; - } - - @JsonIgnore - public boolean getVersionDefined() { - return versionDefined; - } - - @JsonProperty(JSON_PROPERTY_VERSION) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setVersion(Integer version) { - this.version = version; - this.versionDefined = true; - } - public NotifyRequestDto type(String type) { this.type = type; this.typeDefined = true; @@ -197,6 +178,18 @@ public void setCustom(String custom) { this.customDefined = true; } + @Override + public NotifyRequestDto callid(String callid) { + this.setCallid(callid); + return this; + } + + @Override + public NotifyRequestDto version(Integer version) { + this.setVersion(version); + return this; + } + /** Return true if this notifyRequest object is equal to o. */ @Override public boolean equals(Object o) { @@ -208,24 +201,22 @@ public boolean equals(Object o) { } NotifyRequestDto notifyRequest = (NotifyRequestDto) o; return Objects.equals(this.event, notifyRequest.event) - && Objects.equals(this.callId, notifyRequest.callId) - && Objects.equals(this.version, notifyRequest.version) && Objects.equals(this.type, notifyRequest.type) - && Objects.equals(this.custom, notifyRequest.custom); + && Objects.equals(this.custom, notifyRequest.custom) + && super.equals(o); } @Override public int hashCode() { - return Objects.hash(event, callId, version, type, custom); + return Objects.hash(event, type, custom, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class NotifyRequestDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" event: ").append(toIndentedString(event)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); sb.append("}"); @@ -241,4 +232,11 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("notifyRequest", NotifyRequestDto.class); + JSONNavigator.registerDiscriminator(NotifyRequestDto.class, "event", mappings); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestMenuResultDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestAllOfMenuResultDto.java similarity index 71% rename from openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestMenuResultDto.java rename to openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestAllOfMenuResultDto.java index 1706a1b03..8cd2ba6a5 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestMenuResultDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestAllOfMenuResultDto.java @@ -12,27 +12,72 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** An object containing information about the returned menu result. */ @JsonPropertyOrder({ - PieRequestMenuResultDto.JSON_PROPERTY_MENU_ID, - PieRequestMenuResultDto.JSON_PROPERTY_TYPE, - PieRequestMenuResultDto.JSON_PROPERTY_VALUE, - PieRequestMenuResultDto.JSON_PROPERTY_INPUT_METHOD + PieRequestAllOfMenuResultDto.JSON_PROPERTY_MENU_ID, + PieRequestAllOfMenuResultDto.JSON_PROPERTY_TYPE, + PieRequestAllOfMenuResultDto.JSON_PROPERTY_VALUE, + PieRequestAllOfMenuResultDto.JSON_PROPERTY_INPUT_METHOD }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class PieRequestMenuResultDto { +public class PieRequestAllOfMenuResultDto { public static final String JSON_PROPERTY_MENU_ID = "menuId"; private String menuId; private boolean menuIdDefined = false; + /** The type of information that's returned. */ + public enum TypeEnum { + ERROR("error"), + + RETURN("return"), + + SEQUENCE("sequence"), + + TIMEOUT("timeout"), + + HANGUP("hangup"), + + INVALIDINPUT("invalidinput"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_TYPE = "type"; private String type; private boolean typeDefined = false; @@ -45,9 +90,9 @@ public class PieRequestMenuResultDto { private String inputMethod; private boolean inputMethodDefined = false; - public PieRequestMenuResultDto() {} + public PieRequestAllOfMenuResultDto() {} - public PieRequestMenuResultDto menuId(String menuId) { + public PieRequestAllOfMenuResultDto menuId(String menuId) { this.menuId = menuId; this.menuIdDefined = true; return this; @@ -76,7 +121,7 @@ public void setMenuId(String menuId) { this.menuIdDefined = true; } - public PieRequestMenuResultDto type(String type) { + public PieRequestAllOfMenuResultDto type(String type) { this.type = type; this.typeDefined = true; return this; @@ -105,7 +150,7 @@ public void setType(String type) { this.typeDefined = true; } - public PieRequestMenuResultDto value(String value) { + public PieRequestAllOfMenuResultDto value(String value) { this.value = value; this.valueDefined = true; return this; @@ -134,7 +179,7 @@ public void setValue(String value) { this.valueDefined = true; } - public PieRequestMenuResultDto inputMethod(String inputMethod) { + public PieRequestAllOfMenuResultDto inputMethod(String inputMethod) { this.inputMethod = inputMethod; this.inputMethodDefined = true; return this; @@ -163,7 +208,7 @@ public void setInputMethod(String inputMethod) { this.inputMethodDefined = true; } - /** Return true if this pieRequest_menuResult object is equal to o. */ + /** Return true if this pieRequest_allOf_menuResult object is equal to o. */ @Override public boolean equals(Object o) { if (this == o) { @@ -172,11 +217,11 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) { return false; } - PieRequestMenuResultDto pieRequestMenuResult = (PieRequestMenuResultDto) o; - return Objects.equals(this.menuId, pieRequestMenuResult.menuId) - && Objects.equals(this.type, pieRequestMenuResult.type) - && Objects.equals(this.value, pieRequestMenuResult.value) - && Objects.equals(this.inputMethod, pieRequestMenuResult.inputMethod); + PieRequestAllOfMenuResultDto pieRequestAllOfMenuResult = (PieRequestAllOfMenuResultDto) o; + return Objects.equals(this.menuId, pieRequestAllOfMenuResult.menuId) + && Objects.equals(this.type, pieRequestAllOfMenuResult.type) + && Objects.equals(this.value, pieRequestAllOfMenuResult.value) + && Objects.equals(this.inputMethod, pieRequestAllOfMenuResult.inputMethod); } @Override @@ -187,7 +232,7 @@ public int hashCode() { @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("class PieRequestMenuResultDto {\n"); + sb.append("class PieRequestAllOfMenuResultDto {\n"); sb.append(" menuId: ").append(toIndentedString(menuId)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" value: ").append(toIndentedString(value)).append("\n"); diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestDto.java index b5ea29c62..62a066f2c 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/PieRequestDto.java @@ -12,44 +12,89 @@ package com.sinch.sdk.domains.voice.models.dto.v1; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonValue; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.time.OffsetDateTime; +import java.util.HashMap; +import java.util.Map; import java.util.Objects; /** The request body of a Prompt Input Event. */ @JsonPropertyOrder({ PieRequestDto.JSON_PROPERTY_EVENT, - PieRequestDto.JSON_PROPERTY_CALL_ID, PieRequestDto.JSON_PROPERTY_TIMESTAMP, PieRequestDto.JSON_PROPERTY_MENU_RESULT, - PieRequestDto.JSON_PROPERTY_VERSION, + PieRequestDto.JSON_PROPERTY_CUSTOM, PieRequestDto.JSON_PROPERTY_APPLICATION_KEY }) @JsonFilter("uninitializedFilter") @JsonInclude(value = JsonInclude.Include.CUSTOM) -public class PieRequestDto { + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +public class PieRequestDto extends WebhooksEventRequestDto { + /** Must have the value `pie`. */ + public enum EventEnum { + PIE("pie"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + EventEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static EventEnum fromValue(String value) { + for (EventEnum b : EventEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + } + public static final String JSON_PROPERTY_EVENT = "event"; private String event; private boolean eventDefined = false; - public static final String JSON_PROPERTY_CALL_ID = "callId"; - private String callId; - private boolean callIdDefined = false; - public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; - private String timestamp; + private OffsetDateTime timestamp; private boolean timestampDefined = false; public static final String JSON_PROPERTY_MENU_RESULT = "menuResult"; - private PieRequestMenuResultDto menuResult; + private PieRequestAllOfMenuResultDto menuResult; private boolean menuResultDefined = false; - public static final String JSON_PROPERTY_VERSION = "version"; - private Integer version; - private boolean versionDefined = false; + public static final String JSON_PROPERTY_CUSTOM = "custom"; + private String custom; + private boolean customDefined = false; public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; private String applicationKey; @@ -69,7 +114,7 @@ public PieRequestDto event(String event) { * @return event */ @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public String getEvent() { return event; } @@ -80,42 +125,13 @@ public boolean getEventDefined() { } @JsonProperty(JSON_PROPERTY_EVENT) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) public void setEvent(String event) { this.event = event; this.eventDefined = true; } - public PieRequestDto callId(String callId) { - this.callId = callId; - this.callIdDefined = true; - return this; - } - - /** - * The unique ID assigned to this call. - * - * @return callId - */ - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getCallId() { - return callId; - } - - @JsonIgnore - public boolean getCallIdDefined() { - return callIdDefined; - } - - @JsonProperty(JSON_PROPERTY_CALL_ID) - @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setCallId(String callId) { - this.callId = callId; - this.callIdDefined = true; - } - - public PieRequestDto timestamp(String timestamp) { + public PieRequestDto timestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; return this; @@ -128,7 +144,7 @@ public PieRequestDto timestamp(String timestamp) { */ @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getTimestamp() { + public OffsetDateTime getTimestamp() { return timestamp; } @@ -139,12 +155,12 @@ public boolean getTimestampDefined() { @JsonProperty(JSON_PROPERTY_TIMESTAMP) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setTimestamp(String timestamp) { + public void setTimestamp(OffsetDateTime timestamp) { this.timestamp = timestamp; this.timestampDefined = true; } - public PieRequestDto menuResult(PieRequestMenuResultDto menuResult) { + public PieRequestDto menuResult(PieRequestAllOfMenuResultDto menuResult) { this.menuResult = menuResult; this.menuResultDefined = true; return this; @@ -157,7 +173,7 @@ public PieRequestDto menuResult(PieRequestMenuResultDto menuResult) { */ @JsonProperty(JSON_PROPERTY_MENU_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public PieRequestMenuResultDto getMenuResult() { + public PieRequestAllOfMenuResultDto getMenuResult() { return menuResult; } @@ -168,38 +184,38 @@ public boolean getMenuResultDefined() { @JsonProperty(JSON_PROPERTY_MENU_RESULT) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setMenuResult(PieRequestMenuResultDto menuResult) { + public void setMenuResult(PieRequestAllOfMenuResultDto menuResult) { this.menuResult = menuResult; this.menuResultDefined = true; } - public PieRequestDto version(Integer version) { - this.version = version; - this.versionDefined = true; + public PieRequestDto custom(String custom) { + this.custom = custom; + this.customDefined = true; return this; } /** - * The current API version. + * A string that can be used to pass custom information related to the call. * - * @return version + * @return custom */ - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public Integer getVersion() { - return version; + public String getCustom() { + return custom; } @JsonIgnore - public boolean getVersionDefined() { - return versionDefined; + public boolean getCustomDefined() { + return customDefined; } - @JsonProperty(JSON_PROPERTY_VERSION) + @JsonProperty(JSON_PROPERTY_CUSTOM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setVersion(Integer version) { - this.version = version; - this.versionDefined = true; + public void setCustom(String custom) { + this.custom = custom; + this.customDefined = true; } public PieRequestDto applicationKey(String applicationKey) { @@ -232,6 +248,18 @@ public void setApplicationKey(String applicationKey) { this.applicationKeyDefined = true; } + @Override + public PieRequestDto callid(String callid) { + this.setCallid(callid); + return this; + } + + @Override + public PieRequestDto version(Integer version) { + this.setVersion(version); + return this; + } + /** Return true if this pieRequest object is equal to o. */ @Override public boolean equals(Object o) { @@ -243,27 +271,27 @@ public boolean equals(Object o) { } PieRequestDto pieRequest = (PieRequestDto) o; return Objects.equals(this.event, pieRequest.event) - && Objects.equals(this.callId, pieRequest.callId) && Objects.equals(this.timestamp, pieRequest.timestamp) && Objects.equals(this.menuResult, pieRequest.menuResult) - && Objects.equals(this.version, pieRequest.version) - && Objects.equals(this.applicationKey, pieRequest.applicationKey); + && Objects.equals(this.custom, pieRequest.custom) + && Objects.equals(this.applicationKey, pieRequest.applicationKey) + && super.equals(o); } @Override public int hashCode() { - return Objects.hash(event, callId, timestamp, menuResult, version, applicationKey); + return Objects.hash(event, timestamp, menuResult, custom, applicationKey, super.hashCode()); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PieRequestDto {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); sb.append(" event: ").append(toIndentedString(event)).append("\n"); - sb.append(" callId: ").append(toIndentedString(callId)).append("\n"); sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); sb.append(" menuResult: ").append(toIndentedString(menuResult)).append("\n"); - sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); sb.append("}"); return sb.toString(); @@ -278,4 +306,11 @@ private String toIndentedString(Object o) { } return o.toString().replace("\n", "\n "); } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("pieRequest", PieRequestDto.class); + JSONNavigator.registerDiscriminator(PieRequestDto.class, "event", mappings); + } } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/TtsCalloutRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/TtsCalloutRequestDto.java index 01ede53ba..cefcf0b8b 100644 --- a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/TtsCalloutRequestDto.java +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/TtsCalloutRequestDto.java @@ -12,13 +12,11 @@ package com.sinch.sdk.domains.voice.models.dto.v1; -import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import com.fasterxml.jackson.annotation.JsonValue; import java.util.Objects; /** @@ -53,46 +51,8 @@ public class TtsCalloutRequestDto { private String dtmf; private boolean dtmfDefined = false; - /** - * Can be either `pstn` for PSTN endpoint or `mxp` for data (app or web) - * clients. - */ - public enum DomainEnum { - PSTN("pstn"), - - MXP("mxp"), - - UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); - - private String value; - - DomainEnum(String value) { - this.value = value; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - - @JsonCreator - public static DomainEnum fromValue(String value) { - for (DomainEnum b : DomainEnum.values()) { - if (b.value.equals(value)) { - return b; - } - } - return UNKNOWN_DEFAULT_OPEN_API; - } - } - public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private DomainDto domain; private boolean domainDefined = false; public static final String JSON_PROPERTY_CUSTOM = "custom"; @@ -220,21 +180,20 @@ public void setDtmf(String dtmf) { this.dtmfDefined = true; } - public TtsCalloutRequestDto domain(String domain) { + public TtsCalloutRequestDto domain(DomainDto domain) { this.domain = domain; this.domainDefined = true; return this; } /** - * Can be either `pstn` for PSTN endpoint or `mxp` for data (app or web) - * clients. + * Get domain * * @return domain */ @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getDomain() { + public DomainDto getDomain() { return domain; } @@ -245,7 +204,7 @@ public boolean getDomainDefined() { @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setDomain(String domain) { + public void setDomain(DomainDto domain) { this.domain = domain; this.domainDefined = true; } diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksCallEventRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksCallEventRequestDto.java new file mode 100644 index 000000000..96132adb2 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksCallEventRequestDto.java @@ -0,0 +1,174 @@ +/* + * Voice API | Sinch + * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. + * + * The version of the OpenAPI document: 1.0.1 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** WebhooksCallEventRequestDto */ +@JsonPropertyOrder({ + WebhooksCallEventRequestDto.JSON_PROPERTY_TIMESTAMP, + WebhooksCallEventRequestDto.JSON_PROPERTY_CUSTOM, + WebhooksCallEventRequestDto.JSON_PROPERTY_APPLICATION_KEY +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) +public class WebhooksCallEventRequestDto { + public static final String JSON_PROPERTY_TIMESTAMP = "timestamp"; + private OffsetDateTime timestamp; + private boolean timestampDefined = false; + + public static final String JSON_PROPERTY_CUSTOM = "custom"; + private String custom; + private boolean customDefined = false; + + public static final String JSON_PROPERTY_APPLICATION_KEY = "applicationKey"; + private String applicationKey; + private boolean applicationKeyDefined = false; + + public WebhooksCallEventRequestDto() {} + + public WebhooksCallEventRequestDto timestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + this.timestampDefined = true; + return this; + } + + /** + * The timestamp in UTC format. + * + * @return timestamp + */ + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getTimestamp() { + return timestamp; + } + + @JsonIgnore + public boolean getTimestampDefined() { + return timestampDefined; + } + + @JsonProperty(JSON_PROPERTY_TIMESTAMP) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setTimestamp(OffsetDateTime timestamp) { + this.timestamp = timestamp; + this.timestampDefined = true; + } + + public WebhooksCallEventRequestDto custom(String custom) { + this.custom = custom; + this.customDefined = true; + return this; + } + + /** + * A string that can be used to pass custom information related to the call. + * + * @return custom + */ + @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCustom() { + return custom; + } + + @JsonIgnore + public boolean getCustomDefined() { + return customDefined; + } + + @JsonProperty(JSON_PROPERTY_CUSTOM) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCustom(String custom) { + this.custom = custom; + this.customDefined = true; + } + + public WebhooksCallEventRequestDto applicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; + return this; + } + + /** + * The unique application key. You can find it in the Sinch + * [dashboard](https://dashboard.sinch.com/voice/apps). + * + * @return applicationKey + */ + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getApplicationKey() { + return applicationKey; + } + + @JsonIgnore + public boolean getApplicationKeyDefined() { + return applicationKeyDefined; + } + + @JsonProperty(JSON_PROPERTY_APPLICATION_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setApplicationKey(String applicationKey) { + this.applicationKey = applicationKey; + this.applicationKeyDefined = true; + } + + /** Return true if this webhooksCallEventRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhooksCallEventRequestDto webhooksCallEventRequest = (WebhooksCallEventRequestDto) o; + return Objects.equals(this.timestamp, webhooksCallEventRequest.timestamp) + && Objects.equals(this.custom, webhooksCallEventRequest.custom) + && Objects.equals(this.applicationKey, webhooksCallEventRequest.applicationKey); + } + + @Override + public int hashCode() { + return Objects.hash(timestamp, custom, applicationKey); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebhooksCallEventRequestDto {\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).append("\n"); + sb.append(" custom: ").append(toIndentedString(custom)).append("\n"); + sb.append(" applicationKey: ").append(toIndentedString(applicationKey)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDto.java new file mode 100644 index 000000000..c7c9fc748 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDto.java @@ -0,0 +1,516 @@ +/* + * Voice API | Sinch + * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. + * + * The version of the OpenAPI document: 1.0.1 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import com.sinch.sdk.core.models.AbstractOpenApiSchema; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@JsonDeserialize(using = WebhooksEventDto.WebhooksEventDtoDeserializer.class) +@JsonSerialize(using = WebhooksEventDto.WebhooksEventDtoSerializer.class) +public class WebhooksEventDto extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(WebhooksEventDto.class.getName()); + + public static class WebhooksEventDtoSerializer extends StdSerializer { + public WebhooksEventDtoSerializer(Class t) { + super(t); + } + + public WebhooksEventDtoSerializer() { + this(null); + } + + @Override + public void serialize(WebhooksEventDto value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class WebhooksEventDtoDeserializer extends StdDeserializer { + public WebhooksEventDtoDeserializer() { + this(WebhooksEventDto.class); + } + + public WebhooksEventDtoDeserializer(Class vc) { + super(vc); + } + + @Override + public WebhooksEventDto deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + WebhooksEventDto newWebhooksEventDto = new WebhooksEventDto(); + Map result2 = + tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {}); + String discriminatorValue = (String) result2.get("event"); + switch (discriminatorValue) { + case "ace": + deserialized = tree.traverse(jp.getCodec()).readValueAs(AceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "aceRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(AceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "dice": + deserialized = tree.traverse(jp.getCodec()).readValueAs(DiceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "diceRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(DiceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "ice": + deserialized = tree.traverse(jp.getCodec()).readValueAs(IceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "iceRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(IceRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "notify": + deserialized = tree.traverse(jp.getCodec()).readValueAs(NotifyRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "notifyRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(NotifyRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "pie": + deserialized = tree.traverse(jp.getCodec()).readValueAs(PieRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + case "pieRequest": + deserialized = tree.traverse(jp.getCodec()).readValueAs(PieRequestDto.class); + newWebhooksEventDto.setActualInstance(deserialized); + return newWebhooksEventDto; + default: + log.log( + Level.WARNING, + String.format( + "Failed to lookup discriminator value `%s` for WebhooksEventDto. Possible values:" + + " ace aceRequest dice diceRequest ice iceRequest notify notifyRequest pie" + + " pieRequest", + discriminatorValue)); + } + + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize AceRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (AceRequestDto.class.equals(Integer.class) + || AceRequestDto.class.equals(Long.class) + || AceRequestDto.class.equals(Float.class) + || AceRequestDto.class.equals(Double.class) + || AceRequestDto.class.equals(Boolean.class) + || AceRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((AceRequestDto.class.equals(Integer.class) + || AceRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((AceRequestDto.class.equals(Float.class) + || AceRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (AceRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (AceRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(AceRequestDto.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'AceRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'AceRequestDto'", e); + } + + // deserialize DiceRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (DiceRequestDto.class.equals(Integer.class) + || DiceRequestDto.class.equals(Long.class) + || DiceRequestDto.class.equals(Float.class) + || DiceRequestDto.class.equals(Double.class) + || DiceRequestDto.class.equals(Boolean.class) + || DiceRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((DiceRequestDto.class.equals(Integer.class) + || DiceRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((DiceRequestDto.class.equals(Float.class) + || DiceRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (DiceRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (DiceRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(DiceRequestDto.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'DiceRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'DiceRequestDto'", e); + } + + // deserialize IceRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (IceRequestDto.class.equals(Integer.class) + || IceRequestDto.class.equals(Long.class) + || IceRequestDto.class.equals(Float.class) + || IceRequestDto.class.equals(Double.class) + || IceRequestDto.class.equals(Boolean.class) + || IceRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((IceRequestDto.class.equals(Integer.class) + || IceRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((IceRequestDto.class.equals(Float.class) + || IceRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (IceRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (IceRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(IceRequestDto.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'IceRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'IceRequestDto'", e); + } + + // deserialize NotifyRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (NotifyRequestDto.class.equals(Integer.class) + || NotifyRequestDto.class.equals(Long.class) + || NotifyRequestDto.class.equals(Float.class) + || NotifyRequestDto.class.equals(Double.class) + || NotifyRequestDto.class.equals(Boolean.class) + || NotifyRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((NotifyRequestDto.class.equals(Integer.class) + || NotifyRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((NotifyRequestDto.class.equals(Float.class) + || NotifyRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (NotifyRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (NotifyRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(NotifyRequestDto.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'NotifyRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'NotifyRequestDto'", e); + } + + // deserialize PieRequestDto + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (PieRequestDto.class.equals(Integer.class) + || PieRequestDto.class.equals(Long.class) + || PieRequestDto.class.equals(Float.class) + || PieRequestDto.class.equals(Double.class) + || PieRequestDto.class.equals(Boolean.class) + || PieRequestDto.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((PieRequestDto.class.equals(Integer.class) + || PieRequestDto.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((PieRequestDto.class.equals(Float.class) + || PieRequestDto.class.equals(Double.class)) + && token == JsonToken.VALUE_NUMBER_FLOAT); + attemptParsing |= + (PieRequestDto.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (PieRequestDto.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + deserialized = tree.traverse(jp.getCodec()).readValueAs(PieRequestDto.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + match++; + log.log(Level.FINER, "Input data matches schema 'PieRequestDto'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'PieRequestDto'", e); + } + + if (match == 1) { + WebhooksEventDto ret = new WebhooksEventDto(); + ret.setActualInstance(deserialized); + return ret; + } + throw new IOException( + String.format( + "Failed deserialization for WebhooksEventDto: %d classes match result, expected 1", + match)); + } + + /** Handle deserialization of the 'null' value. */ + @Override + public WebhooksEventDto getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "WebhooksEventDto cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap<>(); + + public WebhooksEventDto() { + super("oneOf", Boolean.FALSE); + } + + public WebhooksEventDto(AceRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public WebhooksEventDto(DiceRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public WebhooksEventDto(IceRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public WebhooksEventDto(NotifyRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public WebhooksEventDto(PieRequestDto o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("AceRequestDto", AceRequestDto.class); + schemas.put("DiceRequestDto", DiceRequestDto.class); + schemas.put("IceRequestDto", IceRequestDto.class); + schemas.put("NotifyRequestDto", NotifyRequestDto.class); + schemas.put("PieRequestDto", PieRequestDto.class); + JSONNavigator.registerDescendants(WebhooksEventDto.class, Collections.unmodifiableMap(schemas)); + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("ace", AceRequestDto.class); + mappings.put("aceRequest", AceRequestDto.class); + mappings.put("dice", DiceRequestDto.class); + mappings.put("diceRequest", DiceRequestDto.class); + mappings.put("ice", IceRequestDto.class); + mappings.put("iceRequest", IceRequestDto.class); + mappings.put("notify", NotifyRequestDto.class); + mappings.put("notifyRequest", NotifyRequestDto.class); + mappings.put("pie", PieRequestDto.class); + mappings.put("pieRequest", PieRequestDto.class); + mappings.put("webhooksEvent", WebhooksEventDto.class); + JSONNavigator.registerDiscriminator(WebhooksEventDto.class, "event", mappings); + } + + @Override + public Map> getSchemas() { + return WebhooksEventDto.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: AceRequestDto, DiceRequestDto, IceRequestDto, + * NotifyRequestDto, PieRequestDto + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSONNavigator.isInstanceOf(AceRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(DiceRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(IceRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(NotifyRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSONNavigator.isInstanceOf(PieRequestDto.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be AceRequestDto, DiceRequestDto, IceRequestDto," + + " NotifyRequestDto, PieRequestDto"); + } + + /** + * Get the actual instance, which can be the following: AceRequestDto, DiceRequestDto, + * IceRequestDto, NotifyRequestDto, PieRequestDto + * + * @return The actual instance (AceRequestDto, DiceRequestDto, IceRequestDto, NotifyRequestDto, + * PieRequestDto) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `AceRequestDto`. If the actual instance is not `AceRequestDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `AceRequestDto` + * @throws ClassCastException if the instance is not `AceRequestDto` + */ + public AceRequestDto getAceRequestDto() throws ClassCastException { + return (AceRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `DiceRequestDto`. If the actual instance is not `DiceRequestDto`, + * the ClassCastException will be thrown. + * + * @return The actual instance of `DiceRequestDto` + * @throws ClassCastException if the instance is not `DiceRequestDto` + */ + public DiceRequestDto getDiceRequestDto() throws ClassCastException { + return (DiceRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `IceRequestDto`. If the actual instance is not `IceRequestDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `IceRequestDto` + * @throws ClassCastException if the instance is not `IceRequestDto` + */ + public IceRequestDto getIceRequestDto() throws ClassCastException { + return (IceRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `NotifyRequestDto`. If the actual instance is not + * `NotifyRequestDto`, the ClassCastException will be thrown. + * + * @return The actual instance of `NotifyRequestDto` + * @throws ClassCastException if the instance is not `NotifyRequestDto` + */ + public NotifyRequestDto getNotifyRequestDto() throws ClassCastException { + return (NotifyRequestDto) super.getActualInstance(); + } + + /** + * Get the actual instance of `PieRequestDto`. If the actual instance is not `PieRequestDto`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `PieRequestDto` + * @throws ClassCastException if the instance is not `PieRequestDto` + */ + public PieRequestDto getPieRequestDto() throws ClassCastException { + return (PieRequestDto) super.getActualInstance(); + } +} diff --git a/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventRequestDto.java b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventRequestDto.java new file mode 100644 index 000000000..f3bae9c66 --- /dev/null +++ b/openapi-contracts/src/main/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventRequestDto.java @@ -0,0 +1,206 @@ +/* + * Voice API | Sinch + * The Voice API exposes calling- and conference-related functionality in the Sinch Voice Platform. + * + * The version of the OpenAPI document: 1.0.1 + * Contact: support@sinch.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.fasterxml.jackson.annotation.JsonFilter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.sinch.sdk.core.utils.databind.JSONNavigator; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** WebhooksEventRequestDto */ +@JsonPropertyOrder({ + WebhooksEventRequestDto.JSON_PROPERTY_EVENT, + WebhooksEventRequestDto.JSON_PROPERTY_CALLID, + WebhooksEventRequestDto.JSON_PROPERTY_VERSION +}) +@JsonFilter("uninitializedFilter") +@JsonInclude(value = JsonInclude.Include.CUSTOM) + +/*@JsonIgnoreProperties( + value = "event", // ignore manually set event, it will be automatically generated by Jackson during serialization + allowSetters = true // allows the event to be set during deserialization +)*/ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NONE, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "event", + visible = true) +@JsonSubTypes({ + @JsonSubTypes.Type(value = AceRequestDto.class, name = "aceRequest"), + @JsonSubTypes.Type(value = DiceRequestDto.class, name = "diceRequest"), + @JsonSubTypes.Type(value = IceRequestDto.class, name = "iceRequest"), + @JsonSubTypes.Type(value = NotifyRequestDto.class, name = "notifyRequest"), + @JsonSubTypes.Type(value = PieRequestDto.class, name = "pieRequest"), +}) +public class WebhooksEventRequestDto { + public static final String JSON_PROPERTY_EVENT = "event"; + private String event; + private boolean eventDefined = false; + + public static final String JSON_PROPERTY_CALLID = "callid"; + private String callid; + private boolean callidDefined = false; + + public static final String JSON_PROPERTY_VERSION = "version"; + private Integer version; + private boolean versionDefined = false; + + public WebhooksEventRequestDto() {} + + public WebhooksEventRequestDto event(String event) { + this.event = event; + this.eventDefined = true; + return this; + } + + /** + * Get event + * + * @return event + */ + @JsonProperty(JSON_PROPERTY_EVENT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getEvent() { + return event; + } + + @JsonIgnore + public boolean getEventDefined() { + return eventDefined; + } + + @JsonProperty(JSON_PROPERTY_EVENT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public void setEvent(String event) { + this.event = event; + this.eventDefined = true; + } + + public WebhooksEventRequestDto callid(String callid) { + this.callid = callid; + this.callidDefined = true; + return this; + } + + /** + * The unique ID assigned to this call. + * + * @return callid + */ + @JsonProperty(JSON_PROPERTY_CALLID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCallid() { + return callid; + } + + @JsonIgnore + public boolean getCallidDefined() { + return callidDefined; + } + + @JsonProperty(JSON_PROPERTY_CALLID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setCallid(String callid) { + this.callid = callid; + this.callidDefined = true; + } + + public WebhooksEventRequestDto version(Integer version) { + this.version = version; + this.versionDefined = true; + return this; + } + + /** + * The current API version. + * + * @return version + */ + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Integer getVersion() { + return version; + } + + @JsonIgnore + public boolean getVersionDefined() { + return versionDefined; + } + + @JsonProperty(JSON_PROPERTY_VERSION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public void setVersion(Integer version) { + this.version = version; + this.versionDefined = true; + } + + /** Return true if this webhooksEventRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + WebhooksEventRequestDto webhooksEventRequest = (WebhooksEventRequestDto) o; + return Objects.equals(this.event, webhooksEventRequest.event) + && Objects.equals(this.callid, webhooksEventRequest.callid) + && Objects.equals(this.version, webhooksEventRequest.version); + } + + @Override + public int hashCode() { + return Objects.hash(event, callid, version); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WebhooksEventRequestDto {\n"); + sb.append(" event: ").append(toIndentedString(event)).append("\n"); + sb.append(" callid: ").append(toIndentedString(callid)).append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + static { + // Initialize and register the discriminator mappings. + Map> mappings = new HashMap>(); + mappings.put("aceRequest", AceRequestDto.class); + mappings.put("diceRequest", DiceRequestDto.class); + mappings.put("iceRequest", IceRequestDto.class); + mappings.put("notifyRequest", NotifyRequestDto.class); + mappings.put("pieRequest", PieRequestDto.class); + mappings.put("webhooksEventRequest", WebhooksEventRequestDto.class); + JSONNavigator.registerDiscriminator(WebhooksEventRequestDto.class, "event", mappings); + } +} diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/svaml/ActionRunMenuDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/svaml/ActionRunMenuDtoTest.java index e5c9edfa0..d67d340b9 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/svaml/ActionRunMenuDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/svaml/ActionRunMenuDtoTest.java @@ -34,7 +34,8 @@ public class ActionRunMenuDtoTest extends BaseTest { .timeoutMills(500) .maxTimeoutMills(123456) .options( - Collections.singletonList(new OptionDto().dtmf("#w").action("menu"))))); + Collections.singletonList( + new OptionDto().dtmf("#w").action("menu(foo)"))))); @GivenTextResource("/domains/voice/svaml/ActionRunMenuDto.json") String json; diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CalloutRequestDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CalloutRequestDtoTest.java index fa8fd9f8e..921dd1d0c 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CalloutRequestDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CalloutRequestDtoTest.java @@ -58,7 +58,7 @@ public class CalloutRequestDtoTest extends BaseTest { .cli("+14045001000") .dtmf("w123#") .custom("my custom value") - .domain("pstn") + .domain(DomainDto.PSTN) .locale("en-US") .text("text value") .prompts( @@ -81,11 +81,13 @@ public class CalloutRequestDtoTest extends BaseTest { .custom("my custom value") .maxDuration(32) .ice( - "{\"action\": {\"name\": \"connectPstn\", \"number\": \"+12233445566\"," - + " \"cli\": \"+12234325234\", \"amd\": {\"enabled\": \"true\"}}}") + "{\"action\":{\"name\":\"connectPstn\",\"number\":" + + "\"+12233445566\",\"cli\":\"+12234325234\",\"amd\":" + + "{\"enabled\":true}}}") .ace( - "{\"instructions\": [{\"name\": \"say\", \"text\": \"Hello, this is a call" - + " from Sinch!\"}], \"action\": {\"name\": \"hangup\"}}") + "{\"instructions\":[{\"name\":\"say\",\"text\":\"Hello," + + " this is a call from Sinch!\"}],\"action\":{\"name\":" + + "\"hangup\"}}") .pie("https://your-application-server-host/application")); @Test diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CallsResponseDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CallsResponseDtoTest.java index 56a79e515..d857f057b 100644 --- a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CallsResponseDtoTest.java +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/CallsResponseDtoTest.java @@ -4,7 +4,6 @@ import com.adelean.inject.resources.junit.jupiter.TestWithResources; import com.sinch.sdk.BaseTest; import com.sinch.sdk.domains.voice.models.dto.v1.GetCallResponseObjDto.ReasonEnum; -import com.sinch.sdk.domains.voice.models.dto.v1.GetCallResponseObjDto.ResultEnum; import com.sinch.sdk.domains.voice.models.dto.v1.GetCallResponseObjDto.StatusEnum; import java.time.OffsetDateTime; import org.assertj.core.api.Assertions; @@ -27,7 +26,7 @@ public class CallsResponseDtoTest extends BaseTest { .callId("a call UUID") .duration(138) .status(StatusEnum.FINAL.getValue()) - .result(ResultEnum.ANSWERED.getValue()) + .result(CallResultDto.ANSWERED) .reason(ReasonEnum.CALLEEHANGUP.getValue()) .timestamp(OffsetDateTime.parse("2024-01-08T09:48:12Z")) .custom("{}") diff --git a/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDtoTest.java b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDtoTest.java new file mode 100644 index 000000000..8e0a4be66 --- /dev/null +++ b/openapi-contracts/src/test/java/com/sinch/sdk/domains/voice/models/dto/v1/WebhooksEventDtoTest.java @@ -0,0 +1,182 @@ +package com.sinch.sdk.domains.voice.models.dto.v1; + +import com.adelean.inject.resources.junit.jupiter.GivenJsonResource; +import com.adelean.inject.resources.junit.jupiter.GivenTextResource; +import com.adelean.inject.resources.junit.jupiter.TestWithResources; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.sinch.sdk.BaseTest; +import com.sinch.sdk.domains.voice.models.dto.v1.NotifyRequestDto.EventEnum; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.Collections; +import org.assertj.core.api.Assertions; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; + +@TestWithResources +public class WebhooksEventDtoTest extends BaseTest { + + @GivenJsonResource("/domains/voice/webhooks/IceRequestDto.json") + WebhooksEventDto loadedIceRequestDto; + + @GivenJsonResource("/domains/voice/webhooks/DiceRequestDto.json") + WebhooksEventDto loadedDiceRequestDto; + + @GivenJsonResource("/domains/voice/webhooks/AceRequestDto.json") + WebhooksEventDto loadedAceRequestDto; + + @GivenJsonResource("/domains/voice/webhooks/PieRequestDto.json") + WebhooksEventDto loadedPieRequestDto; + + @GivenJsonResource("/domains/voice/webhooks/NotifyRequestDto.json") + WebhooksEventDto loadedNotifyRequestDto; + + @GivenTextResource("/domains/voice/webhooks/SVAMLResponseDto.json") + String jsonSVAMLResponseDto; + + public static WebhooksEventDto expectedIceRequestDto = + new WebhooksEventDto( + new IceRequestDto() + .event(IceRequestDto.EventEnum.ICE.getValue()) + .callid("a call id") + .callResourceUrl("https://calling-euc1.api.sinch.com/calling/v1/calls/id/a call id") + .timestamp(OffsetDateTime.parse("2024-01-16T16:46:36Z")) + .version(1) + .custom("my custom") + .userRate(new PriceDto().currencyId("USD").amount(0.0F)) + .cli("cli number") + .to(new DestinationDto().type(DestinationTypeDto.NUMBER).endpoint("+123456879")) + .domain(DomainDto.MXP) + .applicationKey("an app key") + .originationType(DomainDto.MXP2) + .rdnis("rdnis value") + .callHeaders( + Collections.singletonList( + new CallHeaderDto().key("the key").value("the value")))); + + public static WebhooksEventDto expectedDiceRequestDto = + new WebhooksEventDto( + new DiceRequestDto() + .event(DiceRequestDto.EventEnum.DICE.getValue()) + .callid("a call id") + .timestamp(OffsetDateTime.parse("2024-01-19T12:49:53Z")) + .version(1) + .custom("my custom value") + .userRate(new PriceDto().currencyId("EUR").amount(0.1758F)) + .to(new DestinationDto().type(DestinationTypeDto.NUMBER).endpoint("123456789")) + .applicationKey("an app key") + .result(CallResultDto.ANSWERED) + .reason(DiceRequestDto.ReasonEnum.MANAGERHANGUP.getValue()) + .from("private") + .duration(1) + .debit(new PriceDto().currencyId("EUR").amount(0.1758F)) + .userRate(new PriceDto().currencyId("USD").amount(0.345F))); + + public static WebhooksEventDto expectedAceRequestDto = + new WebhooksEventDto( + new AceRequestDto() + .event(AceRequestDto.EventEnum.ACE.getValue()) + .callid("a call id") + .timestamp(OffsetDateTime.parse("2024-01-19T12:49:53Z")) + .version(1) + .custom("my custom value") + .applicationKey("my application key") + .amd( + new AceRequestAllOfAmdDto().status("human").reason("longgreeting").duration(15))); + + public static WebhooksEventDto expectedPieRequestDto = + new WebhooksEventDto( + new PieRequestDto() + .event(PieRequestDto.EventEnum.PIE.getValue()) + .callid("a call id") + .timestamp(OffsetDateTime.parse("2024-01-23T15:04:28Z")) + .version(1) + .custom("my custom value") + .applicationKey("my application key") + .menuResult( + new PieRequestAllOfMenuResultDto() + .menuId("confirm") + .type("sequence") + .value("1452") + .inputMethod("dtmf"))); + + public static WebhooksEventDto expectedNotifyRequestDto = + new WebhooksEventDto( + new NotifyRequestDto() + .event(EventEnum.NOTIFY.getValue()) + .callid("a call id") + .version(1) + .custom("my custom value") + .type("recording_finished")); + + public static SVAMLRequestBodyDto expectedSVAMLResponseDto = + new SVAMLRequestBodyDto() + .action( + new SvamlActionDto( + new SvamlActionConnectConfDto() + .name(SvamlActionConnectConfDto.NameEnum.CONNECTCONF.getValue()) + .conferenceId("My Conference Id"))) + .instructions( + Arrays.asList( + new SvamlInstructionDto( + new SvamlInstructionSayDto() + .name(SvamlInstructionSayDto.NameEnum.SAY.getValue()) + .text("Hello from instruction")), + new SvamlInstructionDto( + new SvamlInstructionStartRecordingDto() + .name( + SvamlInstructionStartRecordingDto.NameEnum.STARTRECORDING.getValue()) + .options( + new SvamlInstructionStartRecordingOptionsDto() + .destinationUrl("s3://my-bucket/") + .credentials( + "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY:eu-central-1") + .notificationEvents(true) + .transcriptionOptions( + new SvamlInstructionStartRecordingOptionsTranscriptionOptionsDto() + .enabled(true)))))); + + @Test + void deserializeIceRequest() { + Assertions.assertThat(loadedIceRequestDto) + .usingRecursiveComparison() + .isEqualTo(expectedIceRequestDto); + } + + @Test + void deserializeDiceRequest() { + Assertions.assertThat(loadedDiceRequestDto) + .usingRecursiveComparison() + .isEqualTo(expectedDiceRequestDto); + } + + @Test + void deserializeAceRequest() { + Assertions.assertThat(loadedAceRequestDto) + .usingRecursiveComparison() + .isEqualTo(expectedAceRequestDto); + } + + @Test + void deserializePieRequest() { + Assertions.assertThat(loadedPieRequestDto) + .usingRecursiveComparison() + .isEqualTo(expectedPieRequestDto); + } + + @Test + void deserializeNotifyRequest() { + Assertions.assertThat(loadedNotifyRequestDto) + .usingRecursiveComparison() + .isEqualTo(expectedNotifyRequestDto); + } + + @Test + void serializeSVAMLResponse() throws JsonProcessingException, JSONException { + + String serializedString = objectMapper.writeValueAsString(expectedSVAMLResponseDto); + + JSONAssert.assertEquals(jsonSVAMLResponseDto, serializedString, true); + } +} diff --git a/openapi-contracts/src/test/resources/domains/voice/svaml/ActionRunMenuDto.json b/openapi-contracts/src/test/resources/domains/voice/svaml/ActionRunMenuDto.json index 5da34d4f5..002a30da4 100644 --- a/openapi-contracts/src/test/resources/domains/voice/svaml/ActionRunMenuDto.json +++ b/openapi-contracts/src/test/resources/domains/voice/svaml/ActionRunMenuDto.json @@ -16,7 +16,7 @@ "options": [ { "dtmf": "#w", - "action": "menu" + "action": "menu(foo)" } ] } diff --git a/openapi-contracts/src/test/resources/domains/voice/v1/CalloutRequestCustomDto.json b/openapi-contracts/src/test/resources/domains/voice/v1/CalloutRequestCustomDto.json index 31cf9de1a..72b6bf771 100644 --- a/openapi-contracts/src/test/resources/domains/voice/v1/CalloutRequestCustomDto.json +++ b/openapi-contracts/src/test/resources/domains/voice/v1/CalloutRequestCustomDto.json @@ -9,8 +9,8 @@ "dtmf": "w123#", "custom": "my custom value", "maxDuration": 32, - "ice": "{\"action\": {\"name\": \"connectPstn\", \"number\": \"+12233445566\", \"cli\": \"+12234325234\", \"amd\": {\"enabled\": \"true\"}}}", - "ace": "{\"instructions\": [{\"name\": \"say\", \"text\": \"Hello, this is a call from Sinch!\"}], \"action\": {\"name\": \"hangup\"}}", + "ice": "{\"action\":{\"name\":\"connectPstn\",\"number\":\"+12233445566\",\"cli\":\"+12234325234\",\"amd\":{\"enabled\":true}}}", + "ace": "{\"instructions\":[{\"name\":\"say\",\"text\":\"Hello, this is a call from Sinch!\"}],\"action\":{\"name\":\"hangup\"}}", "pie": "https://your-application-server-host/application" } } diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/AceRequestDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/AceRequestDto.json new file mode 100644 index 000000000..4cb9b6b5d --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/AceRequestDto.json @@ -0,0 +1,13 @@ +{ + "event": "ace", + "callid": "a call id", + "timestamp": "2024-01-19T12:49:53Z", + "version": 1, + "custom": "my custom value", + "applicationKey": "my application key", + "amd": { + "status": "human", + "reason": "longgreeting", + "duration": 15 + } +} diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/DiceRequestDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/DiceRequestDto.json new file mode 100644 index 000000000..137a691ce --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/DiceRequestDto.json @@ -0,0 +1,24 @@ +{ + "event": "dice", + "callid": "a call id", + "timestamp": "2024-01-19T12:49:53Z", + "reason": "MANAGERHANGUP", + "result": "ANSWERED", + "version": 1, + "custom": "my custom value", + "debit": { + "currencyId": "EUR", + "amount": 0.1758 + }, + "userRate": { + "currencyId": "USD", + "amount": 0.345 + }, + "to": { + "type": "number", + "endpoint": "123456789" + }, + "applicationKey": "an app key", + "duration": 1, + "from": "private" +} diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/IceRequestDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/IceRequestDto.json new file mode 100644 index 000000000..3b9b6723e --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/IceRequestDto.json @@ -0,0 +1,27 @@ +{ + "event": "ice", + "callid": "a call id", + "callResourceUrl": "https://calling-euc1.api.sinch.com/calling/v1/calls/id/a call id", + "timestamp": "2024-01-16T16:46:36Z", + "version": 1, + "custom": "my custom", + "userRate": { + "currencyId": "USD", + "amount": 0.0 + }, + "cli": "cli number", + "to": { + "type": "number", + "endpoint": "+123456879" + }, + "domain": "mxp", + "applicationKey": "an app key", + "originationType": "MXP", + "rdnis": "rdnis value", + "callHeaders": [ + { + "key": "the key", + "value": "the value" + } + ] +} diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/NotifyRequestDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/NotifyRequestDto.json new file mode 100644 index 000000000..d20872d69 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/NotifyRequestDto.json @@ -0,0 +1,7 @@ +{ + "event": "notify", + "callid": "a call id", + "custom": "my custom value", + "version": 1, + "type": "recording_finished" +} \ No newline at end of file diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/PieRequestDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/PieRequestDto.json new file mode 100644 index 000000000..30254d790 --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/PieRequestDto.json @@ -0,0 +1,14 @@ +{ + "event": "pie", + "callid": "a call id", + "custom": "my custom value", + "timestamp": "2024-01-23T15:04:28Z", + "menuResult": { + "type": "sequence", + "value": "1452", + "menuId": "confirm", + "inputMethod": "dtmf" + }, + "version": 1, + "applicationKey": "my application key" +} \ No newline at end of file diff --git a/openapi-contracts/src/test/resources/domains/voice/webhooks/SVAMLResponseDto.json b/openapi-contracts/src/test/resources/domains/voice/webhooks/SVAMLResponseDto.json new file mode 100644 index 000000000..8800801aa --- /dev/null +++ b/openapi-contracts/src/test/resources/domains/voice/webhooks/SVAMLResponseDto.json @@ -0,0 +1,23 @@ +{ + "instructions": [ + { + "name": "say", + "text": "Hello from instruction" + }, + { + "name": "startRecording", + "options": { + "destinationUrl": "s3://my-bucket/", + "credentials": "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY:eu-central-1", + "notificationEvents": true, + "transcriptionOptions": { + "enabled": true + } + } + } + ], + "action": { + "name": "connectConf", + "conferenceId": "My Conference Id" + } +} diff --git a/pom.xml b/pom.xml index ee457e84c..97ab7db97 100644 --- a/pom.xml +++ b/pom.xml @@ -292,6 +292,7 @@ sample-app/src/main/java/com/sinch/sample/webhooks/verification/VerificationController.java + sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceController.java 1.18.1 diff --git a/sample-app/README.md b/sample-app/README.md index 723087464..46b0abe5b 100644 --- a/sample-app/README.md +++ b/sample-app/README.md @@ -49,10 +49,14 @@ Like for credentials, use the following command to define a parameter required b ``` Variable to be used: -- `PHONE_NUMBER`: Some test are requiring a phone number parameter. -- `BATCH_ID`: Some test are requiring a phone number parameter (SMS). -- `CONFERENCE_ID`: Some test are requiring a conference ID parameter (Voice Conference). -- `CALL_ID`: Some test are requiring a call ID parameter related to a conference participant (Voice). +- `PHONE_NUMBER`: Phone number parameter to be used for destination calls +- `BATCH_ID`: Batch identifier parameter (SMS). +- `CONFERENCE_ID`: Conference ID parameter to be used with Voice Conference. +- `CALL_ID`: Call identifier parameter related to a Voice call (conference, ...). +- `VERIFICATION_ID`: Verification identifier parameter related to a ... verification action + +- `WEBHOOKS_URL`: URL to be used as base path for webhooks +- `WEBHOOKS_VOICE_PATH`: Voice path value (will be concatenated to `WEBHOOKS_URL` on runtime) to define the Voice webhooks URL See https://developers.sinch.com for details about these parameters @@ -122,7 +126,7 @@ See https://developers.sinch.com for details about these parameters | Service | Sample | Class | Note | |--------------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------| -| Callouts | Call | [com.sinch.sample.voice.callouts.Call](src/main/java/com/sinch/sample/voice/callouts/Call.java) | | +| Callouts | Call | [com.sinch.sample.voice.callouts.Call](src/main/java/com/sinch/sample/voice/callouts/Call.java) | Require `PHONE_NUMBER` and `WEBHOOKS_URL` parameters | | Conferences | Call | [com.sinch.sample.voice.conferences.Call](src/main/java/com/sinch/sample/voice/conferences/Call.java) | Require `CONFERENCE_ID` parameter | | | Get | [com.sinch.sample.voice.conferences.Get](src/main/java/com/sinch/sample/voice/conferences/Get.java) | Require `CONFERENCE_ID` parameter | | | KickParticipant | [com.sinch.sample.voice.conferences.KickParticipant](src/main/java/com/sinch/sample/voice/conferences/KickParticipant.java) | Require `CONFERENCE_ID` & `CALL_ID` parameters | @@ -161,4 +165,5 @@ Check your dashboard to retrieve Application credentials values |--------------|------------------------------------------------------------------------------------------------|-------| | Numbers | [com.sinch.sample.webhooks.numbers](src/main/java/com/sinch/sample/webhooks/numbers) | | | Verification | [com.sinch.sample.webhooks.verification](src/main/java/com/sinch/sample/webhooks/verification) | | +| Voice | [com.sinch.sample.webhooks.voice](src/main/java/com/sinch/sample/webhooks/voice) | | diff --git a/sample-app/src/main/java/com/sinch/sample/BaseApplication.java b/sample-app/src/main/java/com/sinch/sample/BaseApplication.java index 47329fb10..86201b99d 100644 --- a/sample-app/src/main/java/com/sinch/sample/BaseApplication.java +++ b/sample-app/src/main/java/com/sinch/sample/BaseApplication.java @@ -9,18 +9,29 @@ public abstract class BaseApplication { private static final String BATCH_ID_KEY = "BATCH_ID"; public static final String PHONE_NUMBER_KEY = "PHONE_NUMBER"; - public static final String CONFERENCE_ID = "CONFERENCE_ID"; - public static final String CALL_ID = "CALL_ID"; + private static final String VIRTUAL_PHONE_NUMBER_KEY = "VIRTUAL_PHONE_NUMBER"; + public static final String CONFERENCE_ID_KEY = "CONFERENCE_ID"; + private static final String CALL_ID_KEY = "CALL_ID"; + private static final String VERIFICATION_ID_KEY = "VERIFICATION_ID"; + + public static final String WEBHOOKS_URL_KEY = "WEBHOOKS_URL"; + public static final String WEBHOOKS_VOICE_PATH_KEY = "WEBHOOKS_VOICE_PATH"; protected static final Logger LOGGER = Utils.initializeLogger(BaseApplication.class.getName()); protected SinchClient client; protected String phoneNumber; + protected String virtualPhoneNumber; protected String batchId; protected String conferenceId; protected String callId; + protected String verificationId; + protected String applicationKey; + protected String webhooksVoicePath; + + Properties properties; protected BaseApplication() throws IOException { @@ -28,25 +39,25 @@ protected BaseApplication() throws IOException { Configuration configuration = Utils.loadConfiguration(LOGGER); - Properties properties = Utils.loadProperties(LOGGER); - phoneNumber = - null != System.getenv(PHONE_NUMBER_KEY) - ? System.getenv(PHONE_NUMBER_KEY) - : properties.getProperty(PHONE_NUMBER_KEY); - batchId = - null != System.getenv(BATCH_ID_KEY) - ? System.getenv(BATCH_ID_KEY) - : properties.getProperty(BATCH_ID_KEY); - conferenceId = - null != System.getenv(CONFERENCE_ID) - ? System.getenv(CONFERENCE_ID) - : properties.getProperty(CONFERENCE_ID); - callId = - null != System.getenv(CALL_ID) ? System.getenv(CALL_ID) : properties.getProperty(CALL_ID); + properties = Utils.loadProperties(LOGGER); + + phoneNumber = getConfigValue(PHONE_NUMBER_KEY); + batchId = getConfigValue(BATCH_ID_KEY); + conferenceId = getConfigValue(CONFERENCE_ID_KEY); + callId = getConfigValue(CALL_ID_KEY); + verificationId = getConfigValue(VERIFICATION_ID_KEY); + virtualPhoneNumber = getConfigValue(VIRTUAL_PHONE_NUMBER_KEY); + + String webhooksUrl = getConfigValue(WEBHOOKS_URL_KEY); + webhooksVoicePath = String.format("%s%s", webhooksUrl, getConfigValue(WEBHOOKS_VOICE_PATH_KEY)); applicationKey = configuration.getApplicationKey(); client = new SinchClient(configuration); } + private String getConfigValue(String key) { + return null != System.getenv(key) ? System.getenv(key) : properties.getProperty(key); + } + public abstract void run() throws InterruptedException; } diff --git a/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java b/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java index edece1bc9..f5067c767 100644 --- a/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java +++ b/sample-app/src/main/java/com/sinch/sample/verification/status/GetById.java @@ -23,7 +23,7 @@ public static void main(String[] args) { public void run() { - VerificationId id = VerificationId.valueOf("018c01d2-a726-0b2b-5c0f-0dab29e5a2f9"); + VerificationId id = VerificationId.valueOf(callId); LOGGER.info("Get status by id for : " + id); diff --git a/sample-app/src/main/java/com/sinch/sample/verification/verifications/ReportById.java b/sample-app/src/main/java/com/sinch/sample/verification/verifications/ReportById.java index 12f23ec45..f8e13c700 100644 --- a/sample-app/src/main/java/com/sinch/sample/verification/verifications/ReportById.java +++ b/sample-app/src/main/java/com/sinch/sample/verification/verifications/ReportById.java @@ -28,7 +28,7 @@ public static void main(String[] args) { public void run() { - VerificationId id = VerificationId.valueOf("018c017e-111d-cf38-6015-2003e49baaa1"); + VerificationId id = VerificationId.valueOf(verificationId); LOGGER.info("Get report by id for : " + id); diff --git a/sample-app/src/main/java/com/sinch/sample/voice/ConferencesSampleFlow.java b/sample-app/src/main/java/com/sinch/sample/voice/ConferencesSampleFlow.java index 98cb9f377..c1bffbcc9 100644 --- a/sample-app/src/main/java/com/sinch/sample/voice/ConferencesSampleFlow.java +++ b/sample-app/src/main/java/com/sinch/sample/voice/ConferencesSampleFlow.java @@ -1,6 +1,6 @@ package com.sinch.sample.voice; -import static com.sinch.sample.BaseApplication.CONFERENCE_ID; +import static com.sinch.sample.BaseApplication.CONFERENCE_ID_KEY; import static com.sinch.sample.BaseApplication.PHONE_NUMBER_KEY; import static com.sinch.sample.Utils.echo; import static com.sinch.sample.Utils.echoStep; @@ -9,7 +9,7 @@ import com.sinch.sdk.SinchClient; import com.sinch.sdk.core.exceptions.ApiException; import com.sinch.sdk.domains.voice.models.DestinationNumber; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.domains.voice.models.requests.CalloutRequestParametersConference; import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantCommandType; import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantRequestParameters; @@ -32,9 +32,9 @@ public static void main(String[] args) { var properties = Utils.loadProperties(LOGGER); var configuration = Utils.loadConfiguration(LOGGER); var conferenceId = - null != System.getenv(CONFERENCE_ID) - ? System.getenv(CONFERENCE_ID) - : properties.getProperty(CONFERENCE_ID); + null != System.getenv(CONFERENCE_ID_KEY) + ? System.getenv(CONFERENCE_ID_KEY) + : properties.getProperty(CONFERENCE_ID_KEY); var phoneNumber = null != System.getenv(PHONE_NUMBER_KEY) ? System.getenv(PHONE_NUMBER_KEY) @@ -97,7 +97,7 @@ String joinConference( .setConferenceId(conferenceId) .setDestination(DestinationNumber.valueOf(phoneNumber)) .setGreeting("Hello from Sinch Conference sample with Jav SDK") - .setMohClass(MohClassType.MUSIC1) + .setMusicOnHold(MusicOnHoldType.MUSIC1) .setCli(E164PhoneNumber.valueOf("+1123456789")) .build(); diff --git a/sample-app/src/main/java/com/sinch/sample/voice/callouts/Call.java b/sample-app/src/main/java/com/sinch/sample/voice/callouts/Call.java index 1e7023829..61cb975d8 100644 --- a/sample-app/src/main/java/com/sinch/sample/voice/callouts/Call.java +++ b/sample-app/src/main/java/com/sinch/sample/voice/callouts/Call.java @@ -2,8 +2,24 @@ import com.sinch.sample.BaseApplication; import com.sinch.sdk.domains.voice.models.DestinationNumber; +import com.sinch.sdk.domains.voice.models.DomainType; +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.domains.voice.models.requests.ControlUrl; +import com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn; +import com.sinch.sdk.domains.voice.models.svaml.ActionRunMenu; +import com.sinch.sdk.domains.voice.models.svaml.InstructionSay; +import com.sinch.sdk.domains.voice.models.svaml.Menu; +import com.sinch.sdk.domains.voice.models.svaml.MenuOption; +import com.sinch.sdk.domains.voice.models.svaml.MenuOptionAction; +import com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; +import com.sinch.sdk.models.DualToneMultiFrequency; +import com.sinch.sdk.models.E164PhoneNumber; import java.io.IOException; +import java.util.Arrays; import java.util.logging.Logger; public class Call extends BaseApplication { @@ -25,14 +41,92 @@ public void run() { LOGGER.info("Start call for: " + phoneNumber); - var parameters = - CalloutRequestParametersConference.builder() - .setDestination(DestinationNumber.valueOf(phoneNumber)) - .setConferenceId("My conference Id") - .setCustom("my custom value") - .build(); + CalloutRequestParameters parameters = + // getTextToSpeechRequest(); + // getCalloutRequest(); + getConferenceRequest(); + var response = client.voice().callouts().call(parameters); LOGGER.info("Response: " + response); } + + private CalloutRequestParametersTTS getTextToSpeechRequest() { + return CalloutRequestParametersTTS.builder() + .setDestination(DestinationNumber.valueOf(phoneNumber)) + .setEnableAce(true) + .setEnableDice(true) + .setEnablePie(true) + .setText("Hello") + .setDtfm(DualToneMultiFrequency.valueOf("w#1")) + .build(); + } + + private CalloutRequestParametersCustom getCalloutRequest() { + return CalloutRequestParametersCustom.builder() + .setCustom("my custom value") + .setIce( + SVAMLControl.builder() + .setAction( + ActionConnectPstn.builder() + .setNumber(E164PhoneNumber.valueOf(phoneNumber)) + .setCli("+123456789") + .build()) + .setInstructions( + Arrays.asList(InstructionSay.builder().setText("Hello from Sinch").build())) + .build()) + .setAce( + SVAMLControl.builder() + .setAction( + ActionRunMenu.builder() + .setLocale("Kimberly") + .setEnableVoice(true) + .setMenus( + Arrays.asList( + Menu.builder() + .setId("main") + .setMainPrompt( + "#tts[Welcome to the main menu. Press 1 to confirm" + + " order or 4 to cancel]") + .setRepeatPrompt("#tts[Incorrect value, please try again]") + .setTimeoutMills(5000) + .setOptions( + Arrays.asList( + MenuOption.builder() + .setDtfm(DualToneMultiFrequency.valueOf("1")) + .setAction( + MenuOptionAction.from( + MenuOptionActionType.MENU, "confirm")) + .build(), + MenuOption.builder() + .setDtfm(DualToneMultiFrequency.valueOf("4")) + .setAction( + MenuOptionAction.from( + MenuOptionActionType.RETURN, "cancel")) + .build())) + .build(), + Menu.builder() + .setId("confirm") + .setMainPrompt( + "#tts[Thank you for confirming your order. Enter your" + + " 4-digit PIN.]") + .setMaxDigits(4) + .build())) + .build()) + .build()) + .setPie(ControlUrl.from(webhooksVoicePath)) + .build(); + } + + private CalloutRequestParametersConference getConferenceRequest() { + return CalloutRequestParametersConference.builder() + .setDestination(DestinationNumber.valueOf(phoneNumber)) + .setConferenceId(conferenceId) + .setDomain(DomainType.PSTN) + .setCustom("my custom value") + .setEnableAce(true) + .setEnableDice(true) + .setEnablePie(true) + .build(); + } } diff --git a/sample-app/src/main/java/com/sinch/sample/voice/calls/ManageWithCallLeg.java b/sample-app/src/main/java/com/sinch/sample/voice/calls/ManageWithCallLeg.java index 26015618c..265c7225c 100644 --- a/sample-app/src/main/java/com/sinch/sample/voice/calls/ManageWithCallLeg.java +++ b/sample-app/src/main/java/com/sinch/sample/voice/calls/ManageWithCallLeg.java @@ -2,10 +2,10 @@ import com.sinch.sample.BaseApplication; import com.sinch.sdk.domains.voice.models.CallLegType; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParameters; import com.sinch.sdk.domains.voice.models.svaml.ActionContinue; import com.sinch.sdk.domains.voice.models.svaml.Instruction; import com.sinch.sdk.domains.voice.models.svaml.InstructionSay; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; import java.io.IOException; import java.util.Collection; import java.util.Collections; @@ -37,11 +37,7 @@ public void run() { Collections.singletonList( InstructionSay.builder().setText("Hello from sample app").setLocale("en").build()); - var parameters = - CallsUpdateRequestParameters.builder() - .setInstructions(instructions) - .setAction(action) - .build(); + var parameters = SVAMLControl.builder().setInstructions(instructions).setAction(action).build(); client.voice().calls().manageWithCallLeg(callId, CallLegType.BOTH, parameters); } } diff --git a/sample-app/src/main/java/com/sinch/sample/voice/calls/Update.java b/sample-app/src/main/java/com/sinch/sample/voice/calls/Update.java index 192bb91ab..e7b94799e 100644 --- a/sample-app/src/main/java/com/sinch/sample/voice/calls/Update.java +++ b/sample-app/src/main/java/com/sinch/sample/voice/calls/Update.java @@ -6,9 +6,8 @@ import com.sinch.sdk.domains.voice.models.DestinationSip; import com.sinch.sdk.domains.voice.models.DestinationUser; import com.sinch.sdk.domains.voice.models.DtfmModeType; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.domains.voice.models.TransportType; -import com.sinch.sdk.domains.voice.models.requests.CallsUpdateRequestParameters; import com.sinch.sdk.domains.voice.models.svaml.Action; import com.sinch.sdk.domains.voice.models.svaml.ActionConnectConference; import com.sinch.sdk.domains.voice.models.svaml.ActionConnectMxp; @@ -30,7 +29,9 @@ import com.sinch.sdk.domains.voice.models.svaml.InstructionStopRecording; import com.sinch.sdk.domains.voice.models.svaml.Menu; import com.sinch.sdk.domains.voice.models.svaml.MenuOption; +import com.sinch.sdk.domains.voice.models.svaml.MenuOptionAction; import com.sinch.sdk.domains.voice.models.svaml.MenuOptionActionType; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; import com.sinch.sdk.domains.voice.models.svaml.StartRecordingOptions; import com.sinch.sdk.domains.voice.models.svaml.TranscriptionOptions; import com.sinch.sdk.models.DualToneMultiFrequency; @@ -70,7 +71,7 @@ public void run() { .setMaxDigits(45) .setTimeoutMills(456) .build()) - .setMoh(MohClassType.MUSIC3) + .setMusicOnHold(MusicOnHoldType.MUSIC3) .build(); var actionRunMenu = @@ -91,7 +92,10 @@ public void run() { .setMaxTimeoutMills(123456) .setOptions( Collections.singletonList( - MenuOption.builder().setAction(MenuOptionActionType.MENU).build())) + MenuOption.builder() + .setAction( + MenuOptionAction.from(MenuOptionActionType.MENU, "foo")) + .build())) .build())) .build(); @@ -109,9 +113,9 @@ public void run() { .setDialTimeout(456) .setCli("cli value") .setSuppressCallbacks(true) - .setDtmf(DualToneMultiFrequency.valueOf("#w123")) + .setDualToneMultiFrequency(DualToneMultiFrequency.valueOf("#w123")) .setIndications(IndicationType.from("unknown value")) - .setAnsweringMachineDetectionEnabled( + .setAnsweringMachineDetection( AnsweringMachineDetection.builder().setEnabled(true).build()) .build(); @@ -122,8 +126,8 @@ public void run() { .setCli("a cli value") .setTransport(TransportType.TLS) .setSuppressCallbacks(true) - .setCallheaders(List.of(new Pair<>("left string", "right string"))) - .setMoh(MohClassType.MUSIC2) + .setCallHeaders(List.of(new Pair<>("left string", "right string"))) + .setMusicOnHold(MusicOnHoldType.MUSIC2) .build(); var actionContinue = ActionContinue.builder().build(); @@ -171,11 +175,7 @@ public void run() { Collection instructions = Collections.singletonList(instruction); - var parameters = - CallsUpdateRequestParameters.builder() - .setInstructions(instructions) - .setAction(action) - .build(); + var parameters = SVAMLControl.builder().setInstructions(instructions).setAction(action).build(); client.voice().calls().update(callId, parameters); } } diff --git a/sample-app/src/main/java/com/sinch/sample/voice/conferences/ManageParticipant.java b/sample-app/src/main/java/com/sinch/sample/voice/conferences/ManageParticipant.java index b235a1885..7be45cb3f 100644 --- a/sample-app/src/main/java/com/sinch/sample/voice/conferences/ManageParticipant.java +++ b/sample-app/src/main/java/com/sinch/sample/voice/conferences/ManageParticipant.java @@ -1,7 +1,7 @@ package com.sinch.sample.voice.conferences; import com.sinch.sample.BaseApplication; -import com.sinch.sdk.domains.voice.models.MohClassType; +import com.sinch.sdk.domains.voice.models.MusicOnHoldType; import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantCommandType; import com.sinch.sdk.domains.voice.models.requests.ConferenceManageParticipantRequestParameters; import java.io.IOException; @@ -25,7 +25,7 @@ public static void main(String[] args) { public void run() { var command = ConferenceManageParticipantCommandType.MUTE; - var moh = MohClassType.MUSIC1; + var moh = MusicOnHoldType.MUSIC1; LOGGER.info( "Manage participant '%s' for conference '%s'. Setting command to '%s' and moh to '%s'" @@ -39,7 +39,7 @@ public void run() { callId, ConferenceManageParticipantRequestParameters.builder() .setCommand(command) - .setMoh(moh) + .setMusicOnHold(moh) .build()); } } diff --git a/sample-app/src/main/java/com/sinch/sample/webhooks/numbers/NumbersService.java b/sample-app/src/main/java/com/sinch/sample/webhooks/numbers/NumbersService.java index c85c91cd6..f797edc7e 100644 --- a/sample-app/src/main/java/com/sinch/sample/webhooks/numbers/NumbersService.java +++ b/sample-app/src/main/java/com/sinch/sample/webhooks/numbers/NumbersService.java @@ -9,11 +9,6 @@ public class NumbersService { private static final Logger LOGGER = Logger.getLogger(NumbersService.class.getName()); - /* @Autowired - public NumbersService(SinchClient sinchClient) { - - }*/ - public void numbersEvent(EventNotification event) { LOGGER.info("Handle event :" + event); diff --git a/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceController.java b/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceController.java new file mode 100644 index 000000000..590306cb6 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceController.java @@ -0,0 +1,96 @@ +package com.sinch.sample.webhooks.voice; + +import com.sinch.sdk.SinchClient; +import com.sinch.sdk.domains.voice.models.webhooks.AnsweredCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.DisconnectCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.IncomingCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.NotifyEvent; +import com.sinch.sdk.domains.voice.models.webhooks.PromptInputEvent; +import java.util.Map; +import java.util.logging.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.server.ResponseStatusException; + +@RestController +public class VoiceController { + + private final SinchClient sinchClient; + private final VoiceService service; + private static final Logger LOGGER = Logger.getLogger(VoiceController.class.getName()); + + @Autowired + public VoiceController(SinchClient sinchClient, VoiceService service) { + this.sinchClient = sinchClient; + this.service = service; + } + + @PostMapping( + value = "/VoiceEvent", + consumes = MediaType.APPLICATION_JSON_VALUE, + produces = MediaType.APPLICATION_JSON_VALUE) + public String VerificationEvent( + @RequestHeader Map headers, @RequestBody String body) { + + LOGGER.finest("Received body:" + body); + LOGGER.finest("Received headers: " + headers); + + // ensure valid authentication to handle request + var validAuth = + sinchClient + .verification() + .webhooks() + .validateAuthenticatedRequest( + // The HTTP verb this controller is managing + "POST", + // The URI this controller is managing + "/VoiceEvent", + // request headers + headers, + // request payload body + body); + + // token validation failed + if (!validAuth) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED); + } + + // decode the payload request + var event = sinchClient.voice().webhooks().unserializeWebhooksEvent(body); + + // let business layer process the request + var response = + switch (event) { + case IncomingCallEvent e -> service.incoming(e); + case AnsweredCallEvent e -> service.answered(e); + case DisconnectCallEvent e -> { + service.disconnect(e); + yield null; + } + case PromptInputEvent e -> { + service.prompt(e); + yield null; + } + case NotifyEvent e -> { + service.notify(e); + yield null; + } + default -> throw new IllegalStateException("Unexpected value: " + event); + }; + + if (null == response) { + return ""; + } + + LOGGER.finest("response: " + response); + String responseBody = sinchClient.voice().webhooks().serializeWebhooksResponse(response); + LOGGER.finest("payload: " + responseBody); + + return responseBody; + } +} diff --git a/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceService.java b/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceService.java new file mode 100644 index 000000000..1c77c8a35 --- /dev/null +++ b/sample-app/src/main/java/com/sinch/sample/webhooks/voice/VoiceService.java @@ -0,0 +1,78 @@ +package com.sinch.sample.webhooks.voice; + +import com.sinch.sdk.SinchClient; +import com.sinch.sdk.domains.voice.models.svaml.ActionConnectConference; +import com.sinch.sdk.domains.voice.models.svaml.ActionConnectPstn; +import com.sinch.sdk.domains.voice.models.svaml.InstructionSay; +import com.sinch.sdk.domains.voice.models.svaml.InstructionStartRecording; +import com.sinch.sdk.domains.voice.models.svaml.SVAMLControl; +import com.sinch.sdk.domains.voice.models.svaml.StartRecordingOptions; +import com.sinch.sdk.domains.voice.models.svaml.TranscriptionOptions; +import com.sinch.sdk.domains.voice.models.webhooks.AnsweredCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.DisconnectCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.IncomingCallEvent; +import com.sinch.sdk.domains.voice.models.webhooks.NotifyEvent; +import com.sinch.sdk.domains.voice.models.webhooks.PromptInputEvent; +import java.util.Arrays; +import java.util.logging.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class VoiceService { + + private final SinchClient sinchClient; + + private static final Logger LOGGER = Logger.getLogger(VoiceService.class.getName()); + + @Autowired + public VoiceService(SinchClient sinchClient) { + this.sinchClient = sinchClient; + } + + public SVAMLControl incoming(IncomingCallEvent event) { + + LOGGER.info("decoded event :" + event); + var action = ActionConnectPstn.builder().build(); + + return SVAMLControl.builder().setAction(action).build(); + } + + public SVAMLControl answered(AnsweredCallEvent event) { + + LOGGER.info("decoded event :" + event); + var action = ActionConnectConference.builder().setConferenceId("My Conference Id").build(); + + var say = InstructionSay.builder().setText("Hello from instruction").build(); + var startRecoding = + InstructionStartRecording.builder() + .setOptions( + StartRecordingOptions.builder() + .setDestinationUrl("s3://my-bucket/") + .setCredentials( + "AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY:eu-central-1") + .setTranscriptionOptions( + TranscriptionOptions.builder().setEnabled(true).build()) + .setNotificationEvents(true) + .build()) + .build(); + var instructions = Arrays.asList(say, startRecoding); + + return SVAMLControl.builder().setAction(action).setInstructions(instructions).build(); + } + + public void disconnect(DisconnectCallEvent event) { + + LOGGER.info("decoded event :" + event); + } + + public void prompt(PromptInputEvent event) { + + LOGGER.info("decoded event :" + event); + } + + public void notify(NotifyEvent event) { + + LOGGER.info("decoded event :" + event); + } +} diff --git a/sample-app/src/main/resources/config.properties b/sample-app/src/main/resources/config.properties index 820c9eb91..768f1d8d1 100644 --- a/sample-app/src/main/resources/config.properties +++ b/sample-app/src/main/resources/config.properties @@ -1,2 +1,18 @@ -# supersede default values from Sinch SDK -# numbers-server= https://numbers.api.sinch.com +CONFERENCE_ID=My Conference Id +WEBHOOKS_VOICE_PATH=/VoiceEvent + +SINCH_PROJECT_ID= +SINCH_KEY_ID= +SINCH_KEY_SECRET= + +APPLICATION_API_KEY= +APPLICATION_API_SECRET= + +WEBHOOKS_URL= + +VIRTUAL_PHONE_NUMBER= + +BATCH_ID= +CALL_ID= +VERIFICATION_ID= +