bandwidth-sdk 9.2.0 → 9.4.1

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: 063a9c96b344ab96b6b6717599921eed06e2e2cb8fffb2081b6e88da34d0883e
4
- data.tar.gz: 5fbba072d5895a00208b1ae54451f05f01fc7b34c5eff381b34cd286bba65363
3
+ metadata.gz: 7b7e5b0e9890b1d9a0d92bca32e5e8197efa6110c70cfb2648a13219f5e51f38
4
+ data.tar.gz: 6955fba0a7d0c5245b10211e1cf49c99a612d6cfb80021e41248b3de8a83896b
5
5
  SHA512:
6
- metadata.gz: '08f682f87864b61e67fed4badf7469d2e18ce260a0c592131ae5964e133d48418f10806baddaad4d636fa9d5b8d0436d7d4b9b9dc1a1f8ed12b56991932ac71d'
7
- data.tar.gz: f047132f1527a0f4e4e794d6cfd4e1dee6b6adc732ca8bce596c35f394de77636719a154eb45f2a4144a23db596b4263e330a228d5d81d7f942ae584c759edbc
6
+ metadata.gz: bbd9d8709867f56cffcc8335a16b157908536dbd5512ffb7dd01fc9f623b21b1cd398f12ec2679872e0d3d490fc69d95c93d979a4c754c2d434ef0a6f87a9e7b
7
+ data.tar.gz: 36b3209ec8b26ddb55759bcddd5de4abe8413ec062c5ed14637dbd14c22133f894e1cc5fe08c4c5b31e7f17cff58b40fddf60cbd321785543d9158d5cacf3c8d
data/README.md CHANGED
@@ -156,7 +156,10 @@ create_participant_response = web_rtc_client.create_participant(account_id, :bod
156
156
  participant_id = create_participant_response.data.participant.id
157
157
  puts participant_id
158
158
 
159
- web_rtc_client.add_participant_to_session(account_id, session_id, participant_id)
159
+ body = Subscriptions.new
160
+ body.session_id = "1234-abcd"
161
+
162
+ web_rtc_client.add_participant_to_session(account_id, session_id, participant_id, body: body)
160
163
  ```
161
164
 
162
165
  ## Supported Ruby Versions
@@ -3,8 +3,11 @@
3
3
  # This file was automatically generated by APIMATIC v2.0
4
4
  # ( https://apimatic.io ).
5
5
 
6
+ require 'faraday/follow_redirects'
7
+ require 'faraday/gzip'
6
8
  require 'faraday/http_cache'
7
- require 'faraday_middleware'
9
+ require 'faraday/multipart'
10
+ require 'faraday/retry'
8
11
 
9
12
  module Bandwidth
10
13
  # An implementation of HttpClient.
@@ -15,8 +18,8 @@ module Bandwidth
15
18
  cache: false, verify: true)
16
19
  @connection = Faraday.new do |faraday|
17
20
  faraday.use Faraday::HttpCache, serializer: Marshal if cache
18
- faraday.use FaradayMiddleware::FollowRedirects
19
- faraday.use :gzip
21
+ faraday.use Faraday::FollowRedirects::Middleware
22
+ faraday.request :gzip
20
23
  faraday.request :multipart
21
24
  faraday.request :url_encoded
22
25
  faraday.ssl[:ca_file] = Certifi.where
@@ -3,14 +3,11 @@ Dir[File.dirname(__FILE__) + '/verbs/*'].each {|file|
3
3
  require_relative file
4
4
  }
5
5
 
6
- SSML_REGEX = /<([a-zA-Z\/\/].*?)>/
7
- SPEAK_SENTENCE_REGEX = /<SpeakSentence.*?>.*?<\/SpeakSentence>/
8
-
9
6
  module Bandwidth
10
7
  module Voice
11
- class Response
8
+ class Bxml
12
9
  # Initializer
13
- # @param verbs [Array] optional list of verbs to include into response
10
+ # @param verbs [Array] optional list of verbs to include in the bxml tag
14
11
  def initialize(verbs = nil)
15
12
  @verbs = verbs || []
16
13
  end
@@ -19,7 +16,7 @@ module Bandwidth
19
16
  def to_bxml()
20
17
  xml = Builder::XmlMarkup.new()
21
18
  xml.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8')
22
- xml.Response do
19
+ xml.Bxml do
23
20
  @verbs.each {|verb| verb.to_bxml(xml)}
24
21
  end
25
22
  xml.target!().gsub(SPEAK_SENTENCE_REGEX){|s|s.gsub(SSML_REGEX, '<\1>')}
@@ -0,0 +1,39 @@
1
+ require 'builder'
2
+ Dir[File.dirname(__FILE__) + '/verbs/*'].each {|file|
3
+ require_relative file
4
+ }
5
+
6
+ SSML_REGEX = /&lt;([a-zA-Z\/\/].*?)&gt;/
7
+ SPEAK_SENTENCE_REGEX = /<SpeakSentence.*?>.*?<\/SpeakSentence>/
8
+
9
+ module Bandwidth
10
+ module Voice
11
+ class Response
12
+ # Initializer
13
+ # @param verbs [Array] optional list of verbs to include into response
14
+ def initialize(verbs = nil)
15
+ @verbs = verbs || []
16
+ end
17
+
18
+ # Return BXML representaion of this response
19
+ def to_bxml()
20
+ xml = Builder::XmlMarkup.new()
21
+ xml.instruct!(:xml, :version=>'1.0', :encoding=>'UTF-8')
22
+ xml.Response do
23
+ @verbs.each {|verb| verb.to_bxml(xml)}
24
+ end
25
+ xml.target!().gsub(SPEAK_SENTENCE_REGEX){|s|s.gsub(SSML_REGEX, '<\1>')}
26
+ end
27
+
28
+ # Add one or more verbs to this response
29
+ def push(*verbs)
30
+ @verbs.push(*verbs)
31
+ end
32
+
33
+ # Add a verb to this response
34
+ def <<(verb)
35
+ @verbs << verb
36
+ end
37
+ end
38
+ end
39
+ end
@@ -252,6 +252,87 @@ module Voice
252
252
  ApiResponse.new(_response)
253
253
  end
254
254
 
255
+ # Makes a PUT request to /api/v2/accounts/{accountId}/calls/{callId}/bxml
256
+ # @param [String] account_id Required parameter: Example:
257
+ # @param [String] call_id Required parameter: Example:
258
+ # @param [String] body Required parameter: Example:
259
+ # @return [void] response from the API call
260
+ def modify_call_bxml(account_id,
261
+ call_id,
262
+ body
263
+ )
264
+ # Prepare query url.
265
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
266
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/bxml'
267
+ _query_builder = APIHelper.append_url_with_template_parameters(
268
+ _query_builder,
269
+ 'accountId' => { 'value' => account_id, 'encode' => false },
270
+ 'callId' => { 'value' => call_id, 'encode' => false }
271
+ )
272
+ _query_url = APIHelper.clean_url _query_builder
273
+
274
+ # Prepare headers.
275
+ _headers = {
276
+ 'content-type' => 'application/xml; charset=utf-8'
277
+ }
278
+
279
+ # Prepare and execute HttpRequest.
280
+ _request = config.http_client.put(
281
+ _query_url,
282
+ headers: _headers,
283
+ parameters: body.to_json
284
+ )
285
+ VoiceBasicAuth.apply(config, _request)
286
+ _response = execute_request(_request)
287
+
288
+ # Validate response against endpoint and global error codes.
289
+ case _response.status_code
290
+ when 400
291
+ raise ApiErrorException.new(
292
+ 'Something\'s not quite right... Your request is invalid. Please' \
293
+ ' fix it before trying again.',
294
+ _response
295
+ )
296
+ when 401
297
+ raise APIException.new(
298
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
299
+ ' credentials to authenticate to the API.',
300
+ _response
301
+ )
302
+ when 403
303
+ raise ApiErrorException.new(
304
+ 'User unauthorized to perform this action.',
305
+ _response
306
+ )
307
+ when 404
308
+ raise ApiErrorException.new(
309
+ 'The resource specified cannot be found or does not belong to you.',
310
+ _response
311
+ )
312
+ when 415
313
+ raise ApiErrorException.new(
314
+ 'We don\'t support that media type. If a request body is required,' \
315
+ ' please send it to us as `application/xml`.',
316
+ _response
317
+ )
318
+ when 429
319
+ raise ApiErrorException.new(
320
+ 'You\'re sending requests to this endpoint too frequently. Please' \
321
+ ' slow your request rate down and try again.',
322
+ _response
323
+ )
324
+ when 500
325
+ raise ApiErrorException.new(
326
+ 'Something unexpected happened. Please try again.',
327
+ _response
328
+ )
329
+ end
330
+ validate_response(_response)
331
+
332
+ # Return appropriate response type.
333
+ ApiResponse.new(_response)
334
+ end
335
+
255
336
  # Pauses or resumes a recording.
256
337
  # @param [String] account_id Required parameter: Example:
257
338
  # @param [String] call_id Required parameter: Example:
@@ -86,6 +86,11 @@ module Bandwidth
86
86
  # @return [String]
87
87
  attr_accessor :fallback_password
88
88
 
89
+ # When an answering machine is detected, the amount of silence (in seconds)
90
+ # before assuming the message has finished playing.
91
+ # return [Float]
92
+ attr_accessor :machine_speech_end_threshold
93
+
89
94
  # A mapping from model property names to API property names.
90
95
  def self.names
91
96
  @_hash = {} if @_hash.nil?
@@ -103,6 +108,7 @@ module Bandwidth
103
108
  @_hash['password'] = 'password'
104
109
  @_hash['fallback_username'] = 'fallbackUsername'
105
110
  @_hash['fallback_password'] = 'fallbackPassword'
111
+ @_hash['machine_speech_end_threshold'] = 'machineSpeechEndThreshold'
106
112
  @_hash
107
113
  end
108
114
 
@@ -123,6 +129,7 @@ module Bandwidth
123
129
  password
124
130
  fallback_username
125
131
  fallback_password
132
+ machine_speech_end_threshold
126
133
  ]
127
134
  end
128
135
 
@@ -137,6 +144,7 @@ module Bandwidth
137
144
  password
138
145
  fallback_username
139
146
  fallback_password
147
+ machine_speech_end_threshold
140
148
  ]
141
149
  end
142
150
 
@@ -153,7 +161,8 @@ module Bandwidth
153
161
  username = nil,
154
162
  password = nil,
155
163
  fallback_username = nil,
156
- fallback_password = nil)
164
+ fallback_password = nil,
165
+ machine_speech_end_threshold = nil)
157
166
  @mode = mode unless mode == SKIP
158
167
  @detection_timeout = detection_timeout unless detection_timeout == SKIP
159
168
  @silence_timeout = silence_timeout unless silence_timeout == SKIP
@@ -168,6 +177,7 @@ module Bandwidth
168
177
  @password = password unless password == SKIP
169
178
  @fallback_username = fallback_username unless fallback_username == SKIP
170
179
  @fallback_password = fallback_password unless fallback_password == SKIP
180
+ @machine_speech_end_threshold = machine_speech_end_threshold unless machine_speech_end_threshold == SKIP
171
181
  end
172
182
 
173
183
  # Creates an instance of the object from a hash.
@@ -197,6 +207,8 @@ module Bandwidth
197
207
  hash.key?('fallbackUsername') ? hash['fallbackUsername'] : SKIP
198
208
  fallback_password =
199
209
  hash.key?('fallbackPassword') ? hash['fallbackPassword'] : SKIP
210
+ machine_speech_end_threshold =
211
+ hash.key?('machineSpeechEndThreshold') ? hash['machineSpeechEndThreshold'] : SKIP
200
212
 
201
213
  # Create object from extracted values.
202
214
  MachineDetectionConfiguration.new(mode,
@@ -212,7 +224,8 @@ module Bandwidth
212
224
  username,
213
225
  password,
214
226
  fallback_username,
215
- fallback_password)
227
+ fallback_password,
228
+ machine_speech_end_threshold)
216
229
  end
217
230
  end
218
231
  end
data/lib/bandwidth.rb CHANGED
@@ -47,6 +47,7 @@ require_relative 'bandwidth/http/auth/web_rtc_basic_auth'
47
47
  require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
48
48
 
49
49
  # External Files
50
+ require_relative 'bandwidth/voice_lib/bxml/response.rb'
50
51
  require_relative 'bandwidth/voice_lib/bxml/bxml.rb'
51
52
  require_relative 'bandwidth/voice_lib/bxml/verbs/bridge.rb'
52
53
  require_relative 'bandwidth/voice_lib/bxml/verbs/conference.rb'
@@ -128,6 +128,7 @@ class IntegrationTest < Test::Unit::TestCase
128
128
  machine_detection.delay_result = true
129
129
  machine_detection.callback_url = BASE_CALLBACK_URL + '/machineDetection'
130
130
  machine_detection.callback_method = 'POST'
131
+ machine_detection.machine_speech_end_threshold = 3.2
131
132
 
132
133
  body = CreateCallRequest.new
133
134
  body.from = BW_NUMBER
@@ -261,6 +262,34 @@ class IntegrationTest < Test::Unit::TestCase
261
262
  assert_equal(expected, actual)
262
263
  end
263
264
 
265
+ def test_empty_bxml_verb
266
+ bxml = Bandwidth::Voice::Bxml.new()
267
+
268
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml></Bxml>'
269
+ actual = bxml.to_bxml()
270
+ assert_equal(expected, actual)
271
+ end
272
+
273
+ def test_bxml_speak_sentence_pause
274
+ bxml = Bandwidth::Voice::Bxml.new()
275
+
276
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
277
+ :sentence => "new modify call bxml is pog",
278
+ :voice => "Julie"
279
+ })
280
+
281
+ pause = Bandwidth::Voice::Pause.new({
282
+ :duration => 6
283
+ })
284
+
285
+ bxml.push(speak_sentence)
286
+ bxml.push(pause)
287
+
288
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence voice="Julie">new modify call bxml is pog</SpeakSentence><Pause duration="6"/></Bxml>'
289
+ actual = bxml.to_bxml()
290
+ assert_equal(expected, actual)
291
+ end
292
+
264
293
  def test_hangup
265
294
  hangup = Bandwidth::Voice::Hangup.new()
266
295
 
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: 9.2.0
4
+ version: 9.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bandwidth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-29 00:00:00.000000000 Z
11
+ date: 2022-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -28,24 +28,66 @@ dependencies:
28
28
  name: faraday
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '3.0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
32
42
  - !ruby/object:Gem::Version
33
43
  version: '1.0'
34
- - - "<="
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: faraday-follow_redirects
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.3'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: faraday-gzip
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
35
66
  - !ruby/object:Gem::Version
36
- version: 1.9.3
67
+ version: 0.1.0
37
68
  type: :runtime
38
69
  prerelease: false
39
70
  version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.1.0
75
+ - !ruby/object:Gem::Dependency
76
+ name: faraday-multipart
77
+ requirement: !ruby/object:Gem::Requirement
40
78
  requirements:
41
79
  - - "~>"
42
80
  - !ruby/object:Gem::Version
43
81
  version: '1.0'
44
- - - "<="
82
+ type: :runtime
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
45
87
  - !ruby/object:Gem::Version
46
- version: 1.9.3
88
+ version: '1.0'
47
89
  - !ruby/object:Gem::Dependency
48
- name: faraday_middleware
90
+ name: faraday-retry
49
91
  requirement: !ruby/object:Gem::Requirement
50
92
  requirements:
51
93
  - - "~>"
@@ -140,6 +182,20 @@ dependencies:
140
182
  - - "~>"
141
183
  - !ruby/object:Gem::Version
142
184
  version: '1.0'
185
+ - !ruby/object:Gem::Dependency
186
+ name: test-unit
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ type: :development
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
143
199
  description: The official client SDK for Bandwidht's Voice, Messaging, MFA, and WebRTC
144
200
  APIs
145
201
  email: dx@bandwidth.com
@@ -206,6 +262,7 @@ files:
206
262
  - lib/bandwidth/utilities/date_time_helper.rb
207
263
  - lib/bandwidth/utilities/file_wrapper.rb
208
264
  - lib/bandwidth/voice_lib/bxml/bxml.rb
265
+ - lib/bandwidth/voice_lib/bxml/response.rb
209
266
  - lib/bandwidth/voice_lib/bxml/verbs/bridge.rb
210
267
  - lib/bandwidth/voice_lib/bxml/verbs/conference.rb
211
268
  - lib/bandwidth/voice_lib/bxml/verbs/forward.rb