Skip to content

Commit

Permalink
refactor: Simplify transferCall NCCO
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jul 1, 2024
1 parent 930267e commit 1b4e30f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/kotlin/com/vonage/client/kt/Voice.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 java.net.URI
import java.time.Instant
Expand All @@ -26,7 +27,7 @@ class Voice(private val voiceClient: VoiceClient) {

fun unearmuff() = voiceClient.unearmuffCall(callId)

fun transfer(ncco: Ncco) = voiceClient.transferCall(callId, ncco)
fun transfer(vararg actions: Action) = voiceClient.transferCall(callId, Ncco(actions.asList()))

fun transfer(nccoUrl: String) = voiceClient.transferCall(callId, nccoUrl)

Expand Down Expand Up @@ -60,4 +61,5 @@ fun CallsFilter.Builder.dateEnd(dateEnd: String): CallsFilter.Builder =
dateEnd(Date.from(Instant.parse(dateEnd)))

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

2 changes: 1 addition & 1 deletion src/test/kotlin/com/vonage/client/kt/VoiceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class VoiceTest : AbstractTest() {
@Test
fun `transfer call with ncco`() {
testModifyCall(nccoAction = mapOf("action" to "talk", "text" to text), invocation = {
callObj.transfer(Ncco(TalkAction.builder(text).build()))
callObj.transfer(TalkAction.builder(text).build())
})
}

Expand Down

0 comments on commit 1b4e30f

Please sign in to comment.