Skip to content

Commit

Permalink
test: ConnectAction NCCO
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 2, 2024
1 parent 3c4f200 commit d5f8c3e
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
9 changes: 3 additions & 6 deletions src/main/kotlin/com/vonage/client/kt/Voice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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()
36 changes: 34 additions & 2 deletions src/test/kotlin/com/vonage/client/kt/VoiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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
)
)
)
)

Expand Down Expand Up @@ -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
)
}
}
Expand Down

0 comments on commit d5f8c3e

Please sign in to comment.