Skip to content

Commit

Permalink
feat: Voice NCCOs (pending Connect tests)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 2, 2024
1 parent 1b4e30f commit 3c4f200
Show file tree
Hide file tree
Showing 3 changed files with 281 additions and 38 deletions.
47 changes: 45 additions & 2 deletions src/main/kotlin/com/vonage/client/kt/Voice.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.vonage.client.kt

import com.vonage.client.voice.*
import com.vonage.client.voice.ncco.Action
import com.vonage.client.voice.ncco.Ncco
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 @@ -63,3 +64,45 @@ fun CallsFilter.Builder.dateEnd(dateEnd: String): CallsFilter.Builder =
fun Call.Builder.advancedMachineDetection(amd: AdvancedMachineDetection.Builder.() -> Unit): Call.Builder =
advancedMachineDetection(AdvancedMachineDetection.builder().apply(amd).build())

fun InputAction.Builder.speech(settings: SpeechSettings.Builder.() -> Unit): InputAction.Builder =
speech(SpeechSettings.builder().apply(settings).build())

fun InputAction.Builder.dtmf(timeout: Int? = null, maxDigits: Int? = null, submitOnHash: Boolean? = null): InputAction.Builder {
val dtmfSettings = DtmfSettings()
dtmfSettings.timeOut = timeout
dtmfSettings.maxDigits = maxDigits
dtmfSettings.isSubmitOnHash = submitOnHash
return dtmf(dtmfSettings)
}

fun ConversationAction.Builder.transcription(settings: TranscriptionSettings.Builder.() -> Unit): ConversationAction.Builder =
transcription(TranscriptionSettings.builder().apply(settings).build())

fun RecordAction.Builder.transcription(settings: TranscriptionSettings.Builder.() -> Unit): RecordAction.Builder =
transcription(TranscriptionSettings.builder().apply(settings).build())

fun ConnectAction.Builder.advancedMachineDetection(amd: AdvancedMachineDetection.Builder.() -> Unit): ConnectAction.Builder =
advancedMachineDetection(AdvancedMachineDetection.builder().apply(amd).build())

fun recordAction(properties: RecordAction.Builder.() -> Unit): RecordAction =
RecordAction.builder().apply(properties).build()

fun talkAction(text: String, properties: TalkAction.Builder.() -> Unit): TalkAction =
TalkAction.builder(text).apply(properties).build()

fun streamAction(streamUrl: String, properties: StreamAction.Builder.() -> Unit): StreamAction =
StreamAction.builder(streamUrl).apply(properties).build()

fun notifyAction(eventUrl: String, payload: Map<String, Any>? = null, eventMethod: EventMethod? = null): NotifyAction =
NotifyAction.builder(payload, eventUrl).eventMethod(eventMethod).build()

fun inputAction(properties: InputAction.Builder.() -> Unit): InputAction =
InputAction.builder().apply(properties).build()

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()


3 changes: 2 additions & 1 deletion src/test/kotlin/com/vonage/client/kt/AbstractTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ abstract class AbstractTest {
private val signatureSecret = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQR"
private val apiKeySecretEncoded = "YTFiMmMzZDQ6MTIzNDU2Nzg5MGFiY2RlZg=="
private val privateKeyPath = "src/test/resources/com/vonage/client/kt/application_key"
protected val testUuid = UUID.fromString("aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab")
protected val testUuidStr = "aaaaaaaa-bbbb-4ccc-8ddd-0123456789ab"
protected val testUuid = UUID.fromString(testUuidStr)
protected val toNumber = "447712345689"
protected val altNumber = "447700900001"
protected val text = "Hello, World!"
Expand Down
Loading

0 comments on commit 3c4f200

Please sign in to comment.