bandwidth-sdk 9.3.0 → 10.0.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: 714d17e79fcabfbf641b2953be3d87f4661957c4ce6452a9add5fba71f7e06fc
4
- data.tar.gz: 910e102f0b21b52e4ab8cacb474595a95960f8d5db93689c41261d775175bc86
3
+ metadata.gz: 7f647905f7c08b4614b21b7ca9278210ed8ff6f532f4b0cd09f1c705852c5567
4
+ data.tar.gz: '00348580d308e3fccd81a42642daed1a3b6a39562feb953d0789cbf750a79f0f'
5
5
  SHA512:
6
- metadata.gz: 4bd7b9cb0599cbe42a6f414b2ba26b5b3aa3267f8b27be6748e6f50e0f53e0eb382860abcbedf3330e0aaf6c5c4994ee08986c5df2b898a021c84e8d7f7407a6
7
- data.tar.gz: 875c6add47513bdd45c8db63c614f5ea58c030370a1c5265840eb0a8a1c652487ff0d0752d853fbdf2a2f3fb644b6afa87e4ecc98f8b70a168aca8f9321a2799
6
+ metadata.gz: c001719da52d9026ea151cb5f95229b0a1ef8b864c7bede8d48c02856f742c0124be304982d350be46ca399cd074170b957cc7a4b887c964f68a41cdf6385ca5
7
+ data.tar.gz: 3efb5225670bc0b6cc86088afa4ee45b8e9ecc5f023d33ff33ff6072454f0599474a4d575cfe0db2c2d85d70ca304cde445623f8f25b3f26d03d099da92c545f
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:
@@ -62,6 +62,9 @@ module Bandwidth
62
62
  # @return [DateTime]
63
63
  attr_accessor :start_time
64
64
 
65
+ # @return [DateTime]
66
+ attr_accessor :enqueued_time
67
+
65
68
  # The current state of the call. Current possible values are 'initiated',
66
69
  # 'answered' and 'disconnected'. Additional states may be added in the
67
70
  # future, so your application must be tolerant of unknown values.
@@ -124,6 +127,7 @@ module Bandwidth
124
127
  @_hash['identity'] = 'identity'
125
128
  @_hash['stir_shaken'] = 'stirShaken'
126
129
  @_hash['start_time'] = 'startTime'
130
+ @_hash['enqueued_time'] = 'enqueuedTime'
127
131
  @_hash['answer_time'] = 'answerTime'
128
132
  @_hash['end_time'] = 'endTime'
129
133
  @_hash['disconnect_cause'] = 'disconnectCause'
@@ -147,6 +151,7 @@ module Bandwidth
147
151
  identity
148
152
  stir_shaken
149
153
  start_time
154
+ enqueued_time
150
155
  answer_time
151
156
  end_time
152
157
  disconnect_cause
@@ -180,6 +185,7 @@ module Bandwidth
180
185
  identity = nil,
181
186
  stir_shaken = nil,
182
187
  start_time = nil,
188
+ enqueued_time = nil,
183
189
  answer_time = nil,
184
190
  end_time = nil,
185
191
  disconnect_cause = nil,
@@ -197,6 +203,7 @@ module Bandwidth
197
203
  @identity = identity unless identity == SKIP
198
204
  @stir_shaken = stir_shaken unless stir_shaken == SKIP
199
205
  @start_time = start_time unless start_time == SKIP
206
+ @enqueued_time = enqueued_time unless enqueued_time == SKIP
200
207
  @answer_time = answer_time unless answer_time == SKIP
201
208
  @end_time = end_time unless end_time == SKIP
202
209
  @disconnect_cause = disconnect_cause unless disconnect_cause == SKIP
@@ -221,17 +228,22 @@ module Bandwidth
221
228
  identity = hash.key?('identity') ? hash['identity'] : SKIP
222
229
  stir_shaken = hash.key?('stirShaken') ? hash['stirShaken'] : SKIP
223
230
  start_time = if hash.key?('startTime')
224
- (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
231
+ (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
225
232
  else
226
233
  SKIP
227
234
  end
235
+ enqueued_time = if hash.key?('enqueuedTime')
236
+ (DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime'])
237
+ else
238
+ SKIP
239
+ end
228
240
  answer_time = if hash.key?('answerTime')
229
241
  (DateTimeHelper.from_rfc3339(hash['answerTime']) if hash['answerTime'])
230
242
  else
231
243
  SKIP
232
244
  end
233
245
  end_time = if hash.key?('endTime')
234
- (DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime'])
246
+ (DateTimeHelper.from_rfc3339(hash['endTime']) if hash['endTime'])
235
247
  else
236
248
  SKIP
237
249
  end
@@ -257,6 +269,7 @@ module Bandwidth
257
269
  identity,
258
270
  stir_shaken,
259
271
  start_time,
272
+ enqueued_time,
260
273
  answer_time,
261
274
  end_time,
262
275
  disconnect_cause,
@@ -269,6 +282,10 @@ module Bandwidth
269
282
  DateTimeHelper.to_rfc3339(start_time)
270
283
  end
271
284
 
285
+ def to_enqueued_time
286
+ DateTimeHelper.to_rfc3339(enqueued_time)
287
+ end
288
+
272
289
  def to_answer_time
273
290
  DateTimeHelper.to_rfc3339(answer_time)
274
291
  end
@@ -32,7 +32,7 @@ module Bandwidth
32
32
 
33
33
  # TODO: Write general description for this method
34
34
  # @return [DateTime]
35
- attr_accessor :start_time
35
+ attr_accessor :enqueued_time
36
36
 
37
37
  # TODO: Write general description for this method
38
38
  # @return [String]
@@ -101,7 +101,7 @@ module Bandwidth
101
101
  @_hash['application_id'] = 'applicationId'
102
102
  @_hash['to'] = 'to'
103
103
  @_hash['from'] = 'from'
104
- @_hash['start_time'] = 'startTime'
104
+ @_hash['enqueued_time'] = 'enqueuedTime '
105
105
  @_hash['call_url'] = 'callUrl'
106
106
  @_hash['call_timeout'] = 'callTimeout'
107
107
  @_hash['callback_timeout'] = 'callbackTimeout'
@@ -123,7 +123,7 @@ module Bandwidth
123
123
  # An array for optional fields
124
124
  def optionals
125
125
  %w[
126
- start_time
126
+ enqueued_time
127
127
  call_timeout
128
128
  callback_timeout
129
129
  answer_fallback_url
@@ -163,7 +163,7 @@ module Bandwidth
163
163
  answer_url = nil,
164
164
  answer_method = nil,
165
165
  disconnect_method = nil,
166
- start_time = nil,
166
+ enqueued_time = nil,
167
167
  call_timeout = nil,
168
168
  callback_timeout = nil,
169
169
  answer_fallback_url = nil,
@@ -180,7 +180,7 @@ module Bandwidth
180
180
  @application_id = application_id unless application_id == SKIP
181
181
  @to = to unless to == SKIP
182
182
  @from = from unless from == SKIP
183
- @start_time = start_time unless start_time == SKIP
183
+ @enqueued_time = enqueued_time unless enqueued_time == SKIP
184
184
  @call_url = call_url unless call_url == SKIP
185
185
  @call_timeout = call_timeout unless call_timeout == SKIP
186
186
  @callback_timeout = callback_timeout unless callback_timeout == SKIP
@@ -213,8 +213,8 @@ module Bandwidth
213
213
  answer_method = hash.key?('answerMethod') ? hash['answerMethod'] : SKIP
214
214
  disconnect_method =
215
215
  hash.key?('disconnectMethod') ? hash['disconnectMethod'] : SKIP
216
- start_time = if hash.key?('startTime')
217
- (DateTimeHelper.from_rfc3339(hash['startTime']) if hash['startTime'])
216
+ enqueued_time = if hash.key?('enqueuedTime')
217
+ (DateTimeHelper.from_rfc3339(hash['enqueuedTime']) if hash['enqueuedTime'])
218
218
  else
219
219
  SKIP
220
220
  end
@@ -245,7 +245,7 @@ module Bandwidth
245
245
  answer_url,
246
246
  answer_method,
247
247
  disconnect_method,
248
- start_time,
248
+ enqueued_time,
249
249
  call_timeout,
250
250
  callback_timeout,
251
251
  answer_fallback_url,
@@ -259,8 +259,8 @@ module Bandwidth
259
259
  priority)
260
260
  end
261
261
 
262
- def to_start_time
263
- DateTimeHelper.to_rfc3339(start_time)
262
+ def to_enqueued_time
263
+ DateTimeHelper.to_rfc3339(enqueued_time)
264
264
  end
265
265
  end
266
266
  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'
@@ -111,11 +111,15 @@ class IntegrationTest < Test::Unit::TestCase
111
111
  body.answer_url = BASE_CALLBACK_URL
112
112
  response = @bandwidth_client.voice_client.client.create_call(BW_ACCOUNT_ID, body)
113
113
  assert(response.data.call_id.length > 0, "call_id value not set")
114
+ assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
115
+ assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
114
116
 
115
117
  #Get phone call information
116
118
  sleep 1
117
119
  response = @bandwidth_client.voice_client.client.get_call(BW_ACCOUNT_ID, response.data.call_id)
118
120
  assert(response.data.state.length > 0, "state value not set")
121
+ assert_not_nil(response.data.enqueued_time, "enqueued time is nil")
122
+ assert(response.data.enqueued_time.is_a?(DateTime), "enqueued time is not a DateTime object")
119
123
  end
120
124
 
121
125
  def test_create_call_with_amd_and_get_call_state
@@ -262,6 +266,34 @@ class IntegrationTest < Test::Unit::TestCase
262
266
  assert_equal(expected, actual)
263
267
  end
264
268
 
269
+ def test_empty_bxml_verb
270
+ bxml = Bandwidth::Voice::Bxml.new()
271
+
272
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml></Bxml>'
273
+ actual = bxml.to_bxml()
274
+ assert_equal(expected, actual)
275
+ end
276
+
277
+ def test_bxml_speak_sentence_pause
278
+ bxml = Bandwidth::Voice::Bxml.new()
279
+
280
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
281
+ :sentence => "new modify call bxml is pog",
282
+ :voice => "Julie"
283
+ })
284
+
285
+ pause = Bandwidth::Voice::Pause.new({
286
+ :duration => 6
287
+ })
288
+
289
+ bxml.push(speak_sentence)
290
+ bxml.push(pause)
291
+
292
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Bxml><SpeakSentence voice="Julie">new modify call bxml is pog</SpeakSentence><Pause duration="6"/></Bxml>'
293
+ actual = bxml.to_bxml()
294
+ assert_equal(expected, actual)
295
+ end
296
+
265
297
  def test_hangup
266
298
  hangup = Bandwidth::Voice::Hangup.new()
267
299
 
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.3.0
4
+ version: 10.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bandwidth
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-26 00:00:00.000000000 Z
11
+ date: 2022-07-05 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