From f358d475ed6f0cab80081f0940f1c2f9d5a6ce01 Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Thu, 27 Jun 2024 16:10:23 +0100 Subject: [PATCH] feat: Voice.sendDtmf --- src/main/kotlin/com/vonage/client/kt/Voice.kt | 2 ++ .../kotlin/com/vonage/client/kt/VoiceTest.kt | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/vonage/client/kt/Voice.kt b/src/main/kotlin/com/vonage/client/kt/Voice.kt index 4dcb970..eaa86b1 100644 --- a/src/main/kotlin/com/vonage/client/kt/Voice.kt +++ b/src/main/kotlin/com/vonage/client/kt/Voice.kt @@ -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 = diff --git a/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt b/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt index 8481332..c7dc60c 100644 --- a/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt +++ b/src/test/kotlin/com/vonage/client/kt/VoiceTest.kt @@ -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 @@ -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( @@ -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( @@ -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"