Skip to content

Commit b375833

Browse files
committed
refactor: Remove InputAction.Builder#type
1 parent 5b5fdb9 commit b375833

File tree

3 files changed

+15
-34
lines changed

3 files changed

+15
-34
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ First stable GA release
99

1010
### Added
1111
- `Voice.downloadRecording(String, Path)` method
12-
- `InputAction.Builder.type` Boolean overload method (preferable to the Collection method)
1312
- `Application.Builder#networkApis` DSL method
1413

1514
### Changed

src/main/kotlin/com/vonage/client/kt/Voice.kt

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,35 +207,16 @@ fun InputAction.Builder.speech(settings: SpeechSettings.Builder.() -> Unit = {})
207207
speech(SpeechSettings.builder().apply(settings).build())
208208

209209
/**
210-
* Configure the behavior of Dual-Tone Multi-Frequency (DTMF) input. This setting is mutually exclusive with
211-
* [Call.Builder#speech], so you must provide one or the other for receiving input from the callee.
210+
* Configure the behavior of Dual-Tone Multi-Frequency (DTMF) input.
212211
*
213-
* @param settings (OPTIONAL) A lambda function for configuring the DTMF settings.
212+
* @param settings A lambda function for configuring the DTMF settings. If you provide this instead of
213+
* calling the [InputAction.Builder#dtmf()] method, you cannot use asynchronous input mode.
214214
*
215215
* @return The updated [InputAction.Builder].
216216
*/
217-
fun InputAction.Builder.dtmf(settings: DtmfSettings.Builder.() -> Unit = {}): InputAction.Builder =
217+
fun InputAction.Builder.dtmf(settings: DtmfSettings.Builder.() -> Unit): InputAction.Builder =
218218
dtmf(DtmfSettings.builder().apply(settings).build())
219219

220-
/**
221-
* Sets the input type(s). At least one must be specified (i.e. set to `true`).
222-
*
223-
* @param dtmf Whether to accept DTMF input.
224-
* @param speech Whether to accept speech input.
225-
*
226-
* @return The updated [InputAction.Builder].
227-
* @see InputAction.Builder.type(Collection)
228-
*/
229-
fun InputAction.Builder.type(dtmf: Boolean = false, speech: Boolean = false): InputAction.Builder {
230-
var type = mutableListOf<String>()
231-
if (dtmf) type.add("dtmf")
232-
if (speech) type.add("speech")
233-
if (type.isEmpty()) {
234-
throw IllegalArgumentException("At least one input type must be specified.")
235-
}
236-
return type(type)
237-
}
238-
239220
/**
240221
* Configure the behaviour of call recording transcription. If present (even if all settings are default),
241222
* transcription is activated. The [ConversationAction.Builder.record] parameter must also be set to `true`.

src/test/kotlin/com/vonage/client/kt/VoiceTest.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -597,24 +597,25 @@ class VoiceTest : AbstractTest() {
597597

598598
@Test
599599
fun `create call with input action required parameters only`() {
600+
val emptySpeech = mapOf("speech" to emptyMap<String, Any>())
600601
testSingleNcco(
601-
additionalParams = mapOf("type" to listOf("dtmf", "speech")),
602-
ncco = inputAction { type(speech = true, dtmf = true) }
602+
additionalParams = mapOf("type" to listOf("dtmf", "speech")) + emptySpeech,
603+
ncco = inputAction { dtmf(); speech() }
603604
)
604605
testSingleNcco(
605606
additionalParams = mapOf("type" to listOf("dtmf")),
606-
ncco = inputAction { type(dtmf = true) }
607+
ncco = inputAction { dtmf() }
607608
)
608609
testSingleNcco(
609-
additionalParams = mapOf("type" to listOf("speech")),
610-
ncco = inputAction { type(speech = true) }
610+
additionalParams = mapOf("type" to listOf("speech")) + emptySpeech,
611+
ncco = inputAction { speech() }
611612
)
612613
}
613614

614615
@Test
615616
fun `at least one type should be specified in inputAction`() {
616-
assertThrows<IllegalArgumentException> {
617-
inputAction { type() }
617+
assertThrows<IllegalStateException> {
618+
inputAction { }
618619
}
619620
}
620621

@@ -742,8 +743,8 @@ class VoiceTest : AbstractTest() {
742743
),
743744
mapOf(
744745
"action" to "input",
745-
"speech" to emptyMap,
746-
"dtmf" to emptyMap
746+
"type" to listOf("speech", "dtmf"),
747+
"speech" to emptyMap
747748
),
748749
mapOf(
749750
"action" to "notify",
@@ -806,7 +807,7 @@ class VoiceTest : AbstractTest() {
806807
val record = true
807808
val endOnExit = true
808809
val startOnEnter = true
809-
val inputActionTypes = listOf("dtmf", "asr")
810+
val inputActionTypes = listOf("dtmf", "speech")
810811
val dtmfTimeout = 7
811812
val maxDigits = 16
812813
val submitOnHash = true

0 commit comments

Comments
 (0)