@@ -122,11 +122,18 @@ 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 ( 15 )
126- response = @bandwidth_client . voice_client . client . get_call ( BW_ACCOUNT_ID , response . data . call_id )
127- assert ( response . data . state . length > 0 , "state value not set" )
128- assert_not_nil ( response . data . enqueued_time , "enqueued time is nil" )
129- assert ( response . data . enqueued_time . is_a? ( DateTime ) , "enqueued time is not a DateTime object" )
125+ sleep ( 2 )
126+ begin
127+ response = @bandwidth_client . voice_client . client . get_call ( BW_ACCOUNT_ID , response . data . call_id )
128+ assert ( response . data . state . length > 0 , "state value not set" )
129+ assert_not_nil ( response . data . enqueued_time , "enqueued time is nil" )
130+ assert ( response . data . enqueued_time . is_a? ( DateTime ) , "enqueued time is not a DateTime object" )
131+ rescue ApiErrorException => e
132+ if e . response_code != 404
133+ raise StandardError , "Unexpected HTTP Response: " + e . message
134+ end
135+ end
136+
130137 end
131138
132139 def test_create_call_with_amd_and_get_call_state
@@ -151,9 +158,15 @@ def test_create_call_with_amd_and_get_call_state
151158 assert ( response . data . call_id . length > 0 , "call_id value not set" )
152159
153160 #Get phone call information
154- sleep ( 15 )
155- response = @bandwidth_client . voice_client . client . get_call ( BW_ACCOUNT_ID , response . data . call_id )
156- assert ( response . data . state . length > 0 , "state value not set" )
161+ sleep ( 2 )
162+ begin
163+ response = @bandwidth_client . voice_client . client . get_call ( BW_ACCOUNT_ID , response . data . call_id )
164+ assert ( response . data . state . length > 0 , "state value not set" )
165+ rescue ApiErrorException => e
166+ if e . response_code != 404
167+ raise StandardError , "Unexpected HTTP Response: " + e . message
168+ end
169+ end
157170 end
158171
159172 def test_create_call_with_priority
@@ -766,4 +779,73 @@ def test_stop_stream_bxml_verb
766779
767780 assert_equal ( expected , actual )
768781 end
782+
783+ def test_start_transcription_bxml_verb
784+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartTranscription name="test_transcription" tracks="inbound" transcriptionEventUrl="https://www.test.com/event" transcriptionEventMethod="POST" username="username" password="password" destination="https://www.test.com/transcription"><CustomParam name="name1" value="value1"/></StartTranscription></Response>'
785+ response = Bandwidth ::Voice ::Response . new ( )
786+
787+ custom_param1 = Bandwidth ::Voice ::CustomParam . new ( {
788+ :name => "name1" ,
789+ :value => "value1"
790+ } )
791+
792+ start_transcription = Bandwidth ::Voice ::StartTranscription . new ( {
793+ :name => "test_transcription" ,
794+ :tracks => "inbound" ,
795+ :transcriptionEventUrl => "https://www.test.com/event" ,
796+ :transcriptionEventMethod => "POST" ,
797+ :username => "username" ,
798+ :password => "password" ,
799+ :destination => "https://www.test.com/transcription" ,
800+ :custom_params => custom_param1
801+ } )
802+
803+ response . push ( start_transcription )
804+ actual = response . to_bxml ( )
805+
806+ assert_equal ( expected , actual )
807+ end
808+
809+ def test_start_transcription_multiple_nested_custom_params
810+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartTranscription name="test_transcription" tracks="inbound" transcriptionEventUrl="https://www.test.com/event" transcriptionEventMethod="POST" username="username" password="password" destination="https://www.test.com/transcription"><CustomParam name="name1" value="value1"/><CustomParam name="name2" value="value2"/></StartTranscription></Response>'
811+ response = Bandwidth ::Voice ::Response . new ( )
812+
813+ custom_param1 = Bandwidth ::Voice ::CustomParam . new ( {
814+ :name => "name1" ,
815+ :value => "value1"
816+ } )
817+
818+ custom_param2 = Bandwidth ::Voice ::CustomParam . new ( {
819+ :name => "name2" ,
820+ :value => "value2"
821+ } )
822+
823+ start_transcription = Bandwidth ::Voice ::StartTranscription . new ( {
824+ :destination => "https://www.test.com/transcription" ,
825+ :name => "test_transcription" ,
826+ :tracks => "inbound" ,
827+ :transcriptionEventUrl => "https://www.test.com/event" ,
828+ :transcriptionEventMethod => "POST" ,
829+ :username => "username" ,
830+ :password => "password" ,
831+ :nested_verbs => [ custom_param1 , custom_param2 ]
832+ } )
833+
834+ response . push ( start_transcription )
835+ actual = response . to_bxml ( )
836+
837+ assert_equal ( expected , actual )
838+ end
839+
840+ def test_stop_transcription_bxml_verb
841+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopTranscription name="test_transcription"/></Response>'
842+ response = Bandwidth ::Voice ::Response . new ( )
843+ stop_transcription = Bandwidth ::Voice ::StopTranscription . new ( {
844+ :name => "test_transcription"
845+ } )
846+ response . push ( stop_transcription )
847+ actual = response . to_bxml ( )
848+
849+ assert_equal ( expected , actual )
850+ end
769851end
0 commit comments