Skip to content

Commit

Permalink
feat: Voice.sendDtmf
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jun 27, 2024
1 parent ba86ac1 commit f358d47
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/com/vonage/client/kt/Voice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class Voice(private val voiceClient: VoiceClient) {
fun transfer(nccoUrl: String) = voiceClient.transferCall(callId, nccoUrl)

fun transfer(nccoUrl: URI) = transfer(nccoUrl.toString())

fun sendDtmf(digits: String): DtmfResponse = voiceClient.sendDtmf(callId, digits)
}

fun listCalls(filter: (CallsFilter.Builder.() -> Unit)? = null): CallInfoPage =
Expand Down
16 changes: 14 additions & 2 deletions src/test/kotlin/com/vonage/client/kt/VoiceTest.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.vonage.client.kt

import com.vonage.client.common.HttpMethod
import com.vonage.client.video.Websocket.AudioRate
import com.vonage.client.voice.*
import com.vonage.client.voice.ncco.Ncco
import com.vonage.client.voice.ncco.TalkAction
Expand All @@ -25,6 +24,7 @@ class VoiceTest : AbstractTest() {
private val count = 89
private val pageSize = 25
private val recordIndex = 14
private val dtmf = "p*123#"
private val callResponseMap = mapOf(
"_links" to mapOf(
"self" to mapOf(
Expand Down Expand Up @@ -160,6 +160,19 @@ class VoiceTest : AbstractTest() {
})
}

@Test
fun `send dtmf`() {
val message = "DTMF sent"
mockPut(expectedUrl = "$callUrl/dtmf", status = 200,
expectedRequestParams = mapOf("digits" to dtmf),
expectedResponseParams = mapOf("message" to message, "uuid" to callIdStr)
)
val response = callObj.sendDtmf(dtmf)
assertNotNull(response)
assertEquals(message, response.message)
assertEquals(callIdStr, response.uuid)
}

@Test
fun `list calls all filter parameters`() {
mockGet(callsBaseUrl, expectedQueryParams = mapOf(
Expand Down Expand Up @@ -213,7 +226,6 @@ class VoiceTest : AbstractTest() {
val callStatus = CallStatus.RINGING
val callDirection = CallDirection.OUTBOUND
val wsContentType = "audio/l16;rate=8000"
val dtmf = "p*123#"
val vbcExt = "4321"
val userToUserHeader = "56a390f3d2b7310023a"

Expand Down

0 comments on commit f358d47

Please sign in to comment.