diff --git a/src/main/kotlin/com/vonage/client/kt/Voice.kt b/src/main/kotlin/com/vonage/client/kt/Voice.kt index 78cad87..9f6c8b0 100644 --- a/src/main/kotlin/com/vonage/client/kt/Voice.kt +++ b/src/main/kotlin/com/vonage/client/kt/Voice.kt @@ -2,8 +2,6 @@ package com.vonage.client.kt import com.vonage.client.voice.* import com.vonage.client.voice.ncco.* -import com.vonage.client.voice.ncco.AppEndpoint -import com.vonage.client.voice.ncco.Endpoint import java.net.URI import java.time.Instant import java.util.* @@ -102,7 +100,6 @@ fun inputAction(properties: InputAction.Builder.() -> Unit): InputAction = fun conversationAction(name: String, properties: ConversationAction.Builder.() -> Unit): ConversationAction = ConversationAction.builder(name).apply(properties).build() -fun connectAction(vararg endpoints: Endpoint, properties: ConnectAction.Builder.() -> Unit): ConnectAction = - ConnectAction.builder(endpoints.asList()).apply(properties).build() - - +fun connectAction(endpoint: com.vonage.client.voice.ncco.Endpoint, + properties: ConnectAction.Builder.() -> Unit): ConnectAction = + ConnectAction.builder(endpoint).apply(properties).build() diff --git a/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt b/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt index fd8c18a..21fc7ee 100644 --- a/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt +++ b/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt @@ -435,13 +435,14 @@ class VoiceTest : AbstractTest() { val transcriptionEventMethod = EventMethod.GET val notifyEventMethod = conversationEventMethod val recordEventMethod = transcriptionEventMethod + val inputEventMethod = transcriptionEventMethod + val connectEventMethod = conversationEventMethod val musicOnHoldUrl = "https://nexmo-community.github.io/ncco-examples/assets/voice_api_audio_streaming.mp3" val transcriptionEventUrl = "https://example.com/transcription" val mute = true val record = true val endOnExit = true val startOnEnter = true - val inputEventMethod = transcriptionEventMethod val inputActionTypes = listOf("dtmf", "asr") val dtmfTimeout = 7 val maxDigits = 16 @@ -455,12 +456,17 @@ class VoiceTest : AbstractTest() { val speechContext = listOf("sales", "support", "customer", "Developer") val recordingTimeout = 1260 val recordingChannels = 18 + val limit = 5710 val endOnKey = 'x' val endOnSilenceRecording = 7 val splitRecording = SplitRecording.CONVERSATION val recordEventUrl = "https://example.com/recordings" val beepStart = true val machineDetection = MachineDetection.CONTINUE + val eventType = EventType.SYNCHRONOUS + val connectTimeout = 38 + val ringbackTone = "http://example.com/ringbackTone.wav" + val beepTimeout = 90 testCreateCall(mapOf( "from" to mapOf( @@ -554,6 +560,26 @@ class VoiceTest : AbstractTest() { "eventMethod" to transcriptionEventMethod.name, "sentimentAnalysis" to false ) + ), + mapOf( + "action" to "connect", + "eventUrl" to listOf(eventUrl), + "eventMethod" to connectEventMethod.name, + "eventType" to eventType.name.lowercase(), + "limit" to limit, + "randomFromNumber" to true, + "ringbackTone" to ringbackTone, + "timeout" to connectTimeout, + "advancedMachineDetection" to mapOf( + "beep_timeout" to beepTimeout + ), + "endpoint" to listOf( + mapOf( + "type" to phoneType, + "number" to altNumber, + "dtmfAnswer" to dtmf + ) + ) ) ) @@ -602,8 +628,14 @@ class VoiceTest : AbstractTest() { eventUrl(eventUrl); eventMethod(transcriptionEventMethod) sentimentAnalysis(false) } + }, + connectAction(com.vonage.client.voice.ncco.PhoneEndpoint.builder(altNumber).dtmfAnswer(dtmf).build()) { + eventUrl(eventUrl); eventMethod(connectEventMethod); limit(limit) + eventType(eventType); timeOut(connectTimeout); ringbackTone(ringbackTone); + randomFromNumber(true); advancedMachineDetection { + beepTimeout(beepTimeout) + } } - // TODO connect action ) } }