Skip to content

Commit 3d154f1

Browse files
Merge pull request #95 from Bandwidth/SWI-2566
SWI-2566 Added detectLanguage
2 parents 4d2fc58 + d98ea95 commit 3d154f1

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

lib/bandwidth/voice_lib/bxml/verbs/record.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def to_bxml(xml)
1919
'maxDuration' => max_duration,
2020
'fileFormat' => file_format,
2121
'transcribe' => transcribe,
22+
'detectLanguage' => detect_language,
2223
'transcriptionAvailableUrl' => transcription_available_url,
2324
'transcriptionAvailableMethod' => transcription_available_method,
2425
'silenceTimeout' => silence_timeout,

lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def to_bxml(xml)
1616
'fileFormat' => file_format,
1717
'multiChannel' => multi_channel,
1818
'transcribe' => transcribe,
19+
'detectLanguage' => detect_language,
1920
'transcriptionAvailableUrl' => transcription_available_url,
2021
'transcriptionAvailableMethod' => transcription_available_method
2122
}))

lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class TranscribeRecordingRequest < BaseModel
3333
# @return [Float]
3434
attr_accessor :callback_timeout
3535

36+
# TODO: Write general description for this method
37+
# @return [Boolean]
38+
attr_accessor :detect_language
39+
3640
# A mapping from model property names to API property names.
3741
def self.names
3842
@_hash = {} if @_hash.nil?
@@ -42,6 +46,7 @@ def self.names
4246
@_hash['password'] = 'password'
4347
@_hash['tag'] = 'tag'
4448
@_hash['callback_timeout'] = 'callbackTimeout'
49+
@_hash['detect_language'] = 'detectLanguage'
4550
@_hash
4651
end
4752

@@ -54,6 +59,7 @@ def optionals
5459
password
5560
tag
5661
callback_timeout
62+
detect_language
5763
]
5864
end
5965

@@ -65,6 +71,7 @@ def nullables
6571
password
6672
tag
6773
callback_timeout
74+
detect_language
6875
]
6976
end
7077

@@ -73,13 +80,15 @@ def initialize(callback_url = nil,
7380
username = nil,
7481
password = nil,
7582
tag = nil,
83+
detect_language = nil,
7684
callback_timeout = nil)
7785
@callback_url = callback_url unless callback_url == SKIP
7886
@callback_method = callback_method unless callback_method == SKIP
7987
@username = username unless username == SKIP
8088
@password = password unless password == SKIP
8189
@tag = tag unless tag == SKIP
8290
@callback_timeout = callback_timeout unless callback_timeout == SKIP
91+
@detect_language = detect_language unless detect_language == SKIP
8392
end
8493

8594
# Creates an instance of the object from a hash.
@@ -95,13 +104,16 @@ def self.from_hash(hash)
95104
tag = hash.key?('tag') ? hash['tag'] : SKIP
96105
callback_timeout =
97106
hash.key?('callbackTimeout') ? hash['callbackTimeout'] : SKIP
107+
detect_language =
108+
hash.key?('detectLanguage') ? hash['detectLanguage'] : SKIP
98109

99110
# Create object from extracted values.
100111
TranscribeRecordingRequest.new(callback_url,
101112
callback_method,
102113
username,
103114
password,
104115
tag,
116+
detect_language,
105117
callback_timeout)
106118
end
107119
end

test/integration/test_integration.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def test_create_call_and_get_call_state
122122
assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
123123

124124
#Get phone call information
125-
sleep 1
125+
sleep(5)
126126
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
127127
assert(response.data.state.length > 0, "state value not set")
128128
assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
@@ -151,6 +151,7 @@ def test_create_call_with_amd_and_get_call_state
151151
assert(response.data.call_id.length > 0, "call_id value not set")
152152

153153
#Get phone call information
154+
sleep(5)
154155
response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
155156
assert(response.data.state.length > 0, "state value not set")
156157
end
@@ -354,6 +355,7 @@ def test_record
354355
:recording_available_url => "https://available.com",
355356
:recording_available_method => "GET",
356357
:transcribe => false,
358+
:detect_language=> true,
357359
:transcription_available_url => "https://transcribe.com",
358360
:transcription_available_method => "POST",
359361
:username => "user",
@@ -371,7 +373,7 @@ def test_record
371373

372374
response = Bandwidth::Voice::Response.new()
373375
response.push(record)
374-
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Record tag="tag" username="user" password="pass" recordCompleteUrl="https://complete.com" recordCompleteMethod="POST" recordingAvailableUrl="https://available.com" recordingAvailableMethod="GET" terminatingDigits="#" maxDuration="3" fileFormat="wav" transcribe="false" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="POST" silenceTimeout="5" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
376+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Record tag="tag" username="user" password="pass" recordCompleteUrl="https://complete.com" recordCompleteMethod="POST" recordingAvailableUrl="https://available.com" recordingAvailableMethod="GET" terminatingDigits="#" maxDuration="3" fileFormat="wav" transcribe="false" detectLanguage="true" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="POST" silenceTimeout="5" recordCompleteFallbackUrl="https://test.com" recordCompleteFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
375377
actual = response.to_bxml()
376378
assert_equal(expected, actual)
377379
end

0 commit comments

Comments
 (0)