bandwidth-sdk 10.3.0 → 10.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6da05ba4b6e401983ac08107e419d06a018640e84f980eb39aea9f9a8c8458fd
4
- data.tar.gz: daab0265c2590c6c289b9582d3325f159f3501b66240873c821f269d613e4033
3
+ metadata.gz: ffaae51706420e65f3e5d390fb9215c6dbcfab4fafd63afdcb23db02b9f35c2f
4
+ data.tar.gz: bbf5a6df61b719af55f8207cae476e6e9dfa558e39b144ce6f612616081e8b5f
5
5
  SHA512:
6
- metadata.gz: 9cc3ffa14b5c4c6574f26524a8caf74e4efdba60e5ab02f7aa74e8ef6ef70d62ffa5d9c6be66ee715d64a3db9e16e0e94a0bcf829aeccc5f4c240af68e4efc9f
7
- data.tar.gz: 14d7c3993dd30956d75043799b50db9ac075c505cf3255bd0dd9040ccf3695cc67f51a9ed341acfbbc010dd3326a62eb4cf7244b1e4a52cd49e0c5e635b0852e
6
+ metadata.gz: 40337ac287221ab0177321f3118373023052bc5f322c44e30768b1b678d51917ada3a261e5620fa0d9ad9cb9fb626d03163e4fcf8bf63b7c4ec7c04480e84a4a
7
+ data.tar.gz: dfade60302bddd061ff00afe378cc64f006c93c7b95c36a290aeb80f38ded9eb10d8c156b994b6cebe4fa414bde4f103c48925f844e9802cae47505fb9bc5b80
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bandwidth Ruby SDK
2
2
 
3
- [![Test](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test.yml)
3
+ [![Nightly Tests](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml/badge.svg)](https://github.com/Bandwidth/ruby-sdk/actions/workflows/test-nightly.yml)
4
4
 
5
5
 
6
6
  | **OS** | **Ruby** |
@@ -0,0 +1,17 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # These elements define optional user specified parameters that will be sent to the destination URL when the real-time transcription is first started
6
+ class CustomParam
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ xml.CustomParam(compact_hash({
11
+ 'name' => name,
12
+ 'value' => value
13
+ }))
14
+ end
15
+ end
16
+ end
17
+ end
@@ -19,6 +19,7 @@ module Bandwidth
19
19
  'maxDuration' => max_duration,
20
20
  'fileFormat' => file_format,
21
21
  'transcribe' => transcribe,
22
+ 'detectLanguage' => detect_language,
22
23
  'transcriptionAvailableUrl' => transcription_available_url,
23
24
  'transcriptionAvailableMethod' => transcription_available_method,
24
25
  'silenceTimeout' => silence_timeout,
@@ -16,6 +16,7 @@ module Bandwidth
16
16
  'fileFormat' => file_format,
17
17
  'multiChannel' => multi_channel,
18
18
  'transcribe' => transcribe,
19
+ 'detectLanguage' => detect_language,
19
20
  'transcriptionAvailableUrl' => transcription_available_url,
20
21
  'transcriptionAvailableMethod' => transcription_available_method
21
22
  }))
@@ -0,0 +1,42 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # The StartTranscription verb allows a segment of a call to be transcribed and optionally for the live transcription to be sent off to another destination for additional processing
6
+ class StartTranscription
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ xml.StartTranscription(compact_hash({
11
+ 'name' => name,
12
+ 'tracks' => tracks,
13
+ 'transcriptionEventUrl' => transcriptionEventUrl,
14
+ 'transcriptionEventMethod' => transcriptionEventMethod,
15
+ 'username' => username,
16
+ 'password' => password,
17
+ 'destination' => destination,
18
+ 'stabilized' => stabilized
19
+ })) do
20
+ def embedded_xml(xml, property, type)
21
+ if property
22
+ s = if property.is_a?(type)
23
+ then property
24
+ else type.new(property)
25
+ end
26
+ s.to_bxml(xml)
27
+ end
28
+ end
29
+ def nest_verbs_list(xml, property)
30
+ if property
31
+ property.each do |verb|
32
+ verb.to_bxml(xml)
33
+ end
34
+ end
35
+ end
36
+ embedded_xml(xml, custom_params, CustomParam)
37
+ nest_verbs_list(xml, nested_verbs)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'xml_verb'
2
+
3
+ module Bandwidth
4
+ module Voice
5
+ # The StopTranscription verb is used to stop a real-time transcription that was started with a previous `<StartTranscription>` verb
6
+ class StopTranscription
7
+ include XmlVerb
8
+
9
+ def to_bxml(xml)
10
+ xml.StopTranscription(compact_hash({
11
+ 'name' => name
12
+ }))
13
+ end
14
+ end
15
+ end
16
+ end
@@ -2,7 +2,7 @@ require_relative 'xml_verb'
2
2
 
3
3
  module Bandwidth
4
4
  module Voice
5
- # The StartStream verb allows a segment of a call to be sent off to another destination for additional processing
5
+ # These elements define optional user specified parameters that will be sent to the destination URL when the stream is first started
6
6
  class StreamParam
7
7
  include XmlVerb
8
8
 
@@ -33,6 +33,10 @@ module Bandwidth
33
33
  # @return [Float]
34
34
  attr_accessor :callback_timeout
35
35
 
36
+ # TODO: Write general description for this method
37
+ # @return [Boolean]
38
+ attr_accessor :detect_language
39
+
36
40
  # A mapping from model property names to API property names.
37
41
  def self.names
38
42
  @_hash = {} if @_hash.nil?
@@ -42,6 +46,7 @@ module Bandwidth
42
46
  @_hash['password'] = 'password'
43
47
  @_hash['tag'] = 'tag'
44
48
  @_hash['callback_timeout'] = 'callbackTimeout'
49
+ @_hash['detect_language'] = 'detectLanguage'
45
50
  @_hash
46
51
  end
47
52
 
@@ -54,6 +59,7 @@ module Bandwidth
54
59
  password
55
60
  tag
56
61
  callback_timeout
62
+ detect_language
57
63
  ]
58
64
  end
59
65
 
@@ -65,6 +71,7 @@ module Bandwidth
65
71
  password
66
72
  tag
67
73
  callback_timeout
74
+ detect_language
68
75
  ]
69
76
  end
70
77
 
@@ -73,6 +80,7 @@ module Bandwidth
73
80
  username = nil,
74
81
  password = nil,
75
82
  tag = nil,
83
+ detect_language = nil,
76
84
  callback_timeout = nil)
77
85
  @callback_url = callback_url unless callback_url == SKIP
78
86
  @callback_method = callback_method unless callback_method == SKIP
@@ -80,6 +88,7 @@ module Bandwidth
80
88
  @password = password unless password == SKIP
81
89
  @tag = tag unless tag == SKIP
82
90
  @callback_timeout = callback_timeout unless callback_timeout == SKIP
91
+ @detect_language = detect_language unless detect_language == SKIP
83
92
  end
84
93
 
85
94
  # Creates an instance of the object from a hash.
@@ -95,6 +104,8 @@ module Bandwidth
95
104
  tag = hash.key?('tag') ? hash['tag'] : SKIP
96
105
  callback_timeout =
97
106
  hash.key?('callbackTimeout') ? hash['callbackTimeout'] : SKIP
107
+ detect_language =
108
+ hash.key?('detectLanguage') ? hash['detectLanguage'] : SKIP
98
109
 
99
110
  # Create object from extracted values.
100
111
  TranscribeRecordingRequest.new(callback_url,
@@ -102,6 +113,7 @@ module Bandwidth
102
113
  username,
103
114
  password,
104
115
  tag,
116
+ detect_language,
105
117
  callback_timeout)
106
118
  end
107
119
  end
@@ -122,11 +122,18 @@ class IntegrationTest < Test::Unit::TestCase
122
122
  assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
123
123
 
124
124
  #Get phone call information
125
- sleep 1
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
+
130
137
  end
131
138
 
132
139
  def test_create_call_with_amd_and_get_call_state
@@ -151,8 +158,15 @@ class IntegrationTest < Test::Unit::TestCase
151
158
  assert(response.data.call_id.length > 0, "call_id value not set")
152
159
 
153
160
  #Get phone call information
154
- response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
155
- 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
156
170
  end
157
171
 
158
172
  def test_create_call_with_priority
@@ -354,6 +368,7 @@ class IntegrationTest < Test::Unit::TestCase
354
368
  :recording_available_url => "https://available.com",
355
369
  :recording_available_method => "GET",
356
370
  :transcribe => false,
371
+ :detect_language=> true,
357
372
  :transcription_available_url => "https://transcribe.com",
358
373
  :transcription_available_method => "POST",
359
374
  :username => "user",
@@ -371,7 +386,7 @@ class IntegrationTest < Test::Unit::TestCase
371
386
 
372
387
  response = Bandwidth::Voice::Response.new()
373
388
  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>'
389
+ 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>'
375
390
  actual = response.to_bxml()
376
391
  assert_equal(expected, actual)
377
392
  end
@@ -764,4 +779,73 @@ class IntegrationTest < Test::Unit::TestCase
764
779
 
765
780
  assert_equal(expected, actual)
766
781
  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
767
851
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bandwidth-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.3.0
4
+ version: 10.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bandwidth
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-14 00:00:00.000000000 Z
11
+ date: 2023-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -231,6 +231,7 @@ files:
231
231
  - lib/bandwidth/voice_lib/bxml/response.rb
232
232
  - lib/bandwidth/voice_lib/bxml/verbs/bridge.rb
233
233
  - lib/bandwidth/voice_lib/bxml/verbs/conference.rb
234
+ - lib/bandwidth/voice_lib/bxml/verbs/custom_param.rb
234
235
  - lib/bandwidth/voice_lib/bxml/verbs/forward.rb
235
236
  - lib/bandwidth/voice_lib/bxml/verbs/gather.rb
236
237
  - lib/bandwidth/voice_lib/bxml/verbs/hangup.rb
@@ -248,9 +249,11 @@ files:
248
249
  - lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb
249
250
  - lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb
250
251
  - lib/bandwidth/voice_lib/bxml/verbs/start_stream.rb
252
+ - lib/bandwidth/voice_lib/bxml/verbs/start_transcription.rb
251
253
  - lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb
252
254
  - lib/bandwidth/voice_lib/bxml/verbs/stop_recording.rb
253
255
  - lib/bandwidth/voice_lib/bxml/verbs/stop_stream.rb
256
+ - lib/bandwidth/voice_lib/bxml/verbs/stop_transcription.rb
254
257
  - lib/bandwidth/voice_lib/bxml/verbs/stream_param.rb
255
258
  - lib/bandwidth/voice_lib/bxml/verbs/tag.rb
256
259
  - lib/bandwidth/voice_lib/bxml/verbs/transfer.rb
@@ -314,7 +317,7 @@ homepage: https://github.com/Bandwidth/ruby-sdk
314
317
  licenses:
315
318
  - MIT
316
319
  metadata: {}
317
- post_install_message:
320
+ post_install_message:
318
321
  rdoc_options: []
319
322
  require_paths:
320
323
  - lib
@@ -329,8 +332,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
332
  - !ruby/object:Gem::Version
330
333
  version: '0'
331
334
  requirements: []
332
- rubygems_version: 3.4.6
333
- signing_key:
335
+ rubygems_version: 3.4.10
336
+ signing_key:
334
337
  specification_version: 4
335
338
  summary: Bandwidth
336
339
  test_files: []