bandwidth-sdk 6.0.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e18aadfe51bc80e15e60e4bc4d67b175f10a6c5675c25eadccd4f8a878253dbb
4
- data.tar.gz: 10f37b0a59cb13126b410b549372a54ab7aac33ae3bd236ecb058692a981bbe4
3
+ metadata.gz: 26c4cadeb77f88938cc4adac87254af331797646e475f2985dbe93078c128058
4
+ data.tar.gz: 26e318c93cff54b0d8d47f36dabd4bfcfa66ec33ecd2eaa8a3d6013216f5a635
5
5
  SHA512:
6
- metadata.gz: 52c78cc210f261df7338ef3fea73c6a1ac7e1b15ed247fc7631db68ea9caaf7b9b09465e9694dfd4de83fd5d4ed53d9a57d421a0dfc66da71109911024d01490
7
- data.tar.gz: 06404ecbc6c77c435ccb96b56369916120d25d7124ef57850231f59f92ee16d8b7520042d838614a126bca4fec1829f21d5d05d57f9fe28066126060a911b71f
6
+ metadata.gz: 05ed430d18e6bdfffa1400a86d2a92d841d3340aa9bf838a9647c534354585992bd273978008a5161b51bd6b2616d06cf4fbb4ae638f5631d2999459817d6cf4
7
+ data.tar.gz: 5595927b80c12008edb1d1527ac407ca97f431a1dff0acc6984ec2dcfcb9b1e11573af76a4ec40b894ff8b17033f0e226f742ea0505a353d370ad0407f36ff8e
data/README.md CHANGED
@@ -72,7 +72,7 @@ body.from = '+18888888888'
72
72
  body.text = 'Hello from Bandwidth'
73
73
 
74
74
  begin
75
- response = messaging_client.create_message(account_id, :body => body)
75
+ response = messaging_client.create_message(account_id, body)
76
76
  puts response.data.id #1570740275373xbn7mbhsfewasdr
77
77
  puts response.status_code #202
78
78
  rescue Bandwidth::GenericClientException => e
@@ -12,6 +12,7 @@ require_relative 'web_rtc/models/participant.rb'
12
12
  require_relative 'web_rtc/models/subscriptions.rb'
13
13
  require_relative 'web_rtc/models/participant_subscription.rb'
14
14
  require_relative 'web_rtc/models/accounts_participants_response.rb'
15
+ require_relative 'web_rtc/models/device_api_version_enum.rb'
15
16
  require_relative 'web_rtc/models/publish_permission_enum.rb'
16
17
 
17
18
  # Exceptions
@@ -0,0 +1,17 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ # Optional field to define the device api version of this participant
8
+ class DeviceApiVersionEnum
9
+ DEVICE_API_VERSION_ENUM = [
10
+ # TODO: Write general description for V3
11
+ V3 = 'v3'.freeze,
12
+
13
+ # TODO: Write general description for V2
14
+ V2 = 'v2'.freeze
15
+ ].freeze
16
+ end
17
+ end
@@ -32,6 +32,10 @@ module Bandwidth
32
32
  # @return [String]
33
33
  attr_accessor :tag
34
34
 
35
+ # Optional field to define the device api version of this participant
36
+ # @return [DeviceApiVersionEnum]
37
+ attr_accessor :device_api_version
38
+
35
39
  # A mapping from model property names to API property names.
36
40
  def self.names
37
41
  @_hash = {} if @_hash.nil?
@@ -41,6 +45,7 @@ module Bandwidth
41
45
  @_hash['sessions'] = 'sessions'
42
46
  @_hash['subscriptions'] = 'subscriptions'
43
47
  @_hash['tag'] = 'tag'
48
+ @_hash['device_api_version'] = 'deviceApiVersion'
44
49
  @_hash
45
50
  end
46
51
 
@@ -49,13 +54,15 @@ module Bandwidth
49
54
  publish_permissions = nil,
50
55
  sessions = nil,
51
56
  subscriptions = nil,
52
- tag = nil)
57
+ tag = nil,
58
+ device_api_version = DeviceApiVersionEnum::V2)
53
59
  @id = id
54
60
  @callback_url = callback_url
55
61
  @publish_permissions = publish_permissions
56
62
  @sessions = sessions
57
63
  @subscriptions = subscriptions
58
64
  @tag = tag
65
+ @device_api_version = device_api_version
59
66
  end
60
67
 
61
68
  # Creates an instance of the object from a hash.
@@ -70,6 +77,7 @@ module Bandwidth
70
77
  subscriptions = Subscriptions.from_hash(hash['subscriptions']) if
71
78
  hash['subscriptions']
72
79
  tag = hash['tag']
80
+ device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2
73
81
 
74
82
  # Create object from extracted values.
75
83
  Participant.new(id,
@@ -77,7 +85,8 @@ module Bandwidth
77
85
  publish_permissions,
78
86
  sessions,
79
87
  subscriptions,
80
- tag)
88
+ tag,
89
+ device_api_version)
81
90
  end
82
91
  end
83
92
  end
@@ -0,0 +1,570 @@
1
+ # test_integration.rb
2
+ #
3
+ # A simple integration test against Bandwidth's APIs
4
+
5
+ require 'test/unit'
6
+ require_relative '../../lib/bandwidth.rb'
7
+
8
+ include Bandwidth
9
+ include Bandwidth::Voice
10
+ include Bandwidth::Messaging
11
+ include Bandwidth::TwoFactorAuth
12
+
13
+ begin
14
+ USERNAME = ENV.fetch("USERNAME")
15
+ PASSWORD = ENV.fetch("PASSWORD")
16
+ ACCOUNT_ID = ENV.fetch("ACCOUNT_ID")
17
+ VOICE_APPLICATION_ID = ENV.fetch("VOICE_APPLICATION_ID")
18
+ MESSAGING_APPLICATION_ID = ENV.fetch("MESSAGING_APPLICATION_ID")
19
+ CALLBACK_URL = ENV.fetch("CALLBACK_URL")
20
+ PHONE_NUMBER_OUTBOUND = ENV.fetch("PHONE_NUMBER_OUTBOUND")
21
+ PHONE_NUMBER_INBOUND = ENV.fetch("PHONE_NUMBER_INBOUND")
22
+ MFA_MESSAGING_APPLICATION_ID = ENV.fetch("MFA_MESSAGING_APPLICATION_ID")
23
+ MFA_VOICE_APPLICATION_ID = ENV.fetch("MFA_VOICE_APPLICATION_ID")
24
+ PHONE_NUMBER_MFA = ENV.fetch("PHONE_NUMBER_MFA")
25
+ rescue
26
+ puts "Environmental variables not found"
27
+ exit(-1)
28
+ end
29
+
30
+ class IntegrationTest < Test::Unit::TestCase
31
+ def setup
32
+ @bandwidth_client = Bandwidth::Client.new(
33
+ voice_basic_auth_user_name: USERNAME,
34
+ voice_basic_auth_password: PASSWORD,
35
+ messaging_basic_auth_user_name: USERNAME,
36
+ messaging_basic_auth_password: PASSWORD,
37
+ two_factor_auth_basic_auth_user_name: USERNAME,
38
+ two_factor_auth_basic_auth_password: PASSWORD
39
+ )
40
+ end
41
+
42
+ def test_create_message
43
+ body = MessageRequest.new
44
+ body.application_id = MESSAGING_APPLICATION_ID
45
+ body.to = [PHONE_NUMBER_INBOUND]
46
+ body.from = PHONE_NUMBER_OUTBOUND
47
+ body.text = "Ruby Integration"
48
+ response = @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, body)
49
+ assert(response.data.id.length > 0, "id value not set") #validate that _some_ id was returned
50
+ end
51
+
52
+ def test_create_message_invalid_phone_number
53
+ body = MessageRequest.new
54
+ body.application_id = MESSAGING_APPLICATION_ID
55
+ body.to = ["+1invalid"]
56
+ body.from = PHONE_NUMBER_OUTBOUND
57
+ body.text = "Ruby Integration"
58
+ begin
59
+ @bandwidth_client.messaging_client.client.create_message(ACCOUNT_ID, :body => body)
60
+ #workaround to make sure that if the above error is not raised, the build will fail
61
+ assert(false, "Expected exception not raised")
62
+ rescue MessagingException => e
63
+ assert(e.description.length > 0, "description value not set")
64
+ end
65
+ end
66
+
67
+ def test_upload_download_media
68
+ #define constants for upload media and download media
69
+ media_file_name = 'ruby_integration' #future update to add special symbols
70
+ media_file = '12345' #todo: check a binary string
71
+
72
+ #media upload
73
+ @bandwidth_client.messaging_client.client.upload_media(ACCOUNT_ID, media_file_name, media_file.length.to_s, media_file, :content_type => "application/octet-stream", :cache_control => "no-cache")
74
+
75
+ #media download
76
+ downloaded_media_file = @bandwidth_client.messaging_client.client.get_media(ACCOUNT_ID, media_file_name).data
77
+
78
+ assert_equal(downloaded_media_file, media_file, "Downloaded media file not equal to upload")
79
+ end
80
+
81
+ def test_create_call_and_get_call_state
82
+ body = ApiCreateCallRequest.new
83
+ body.from = PHONE_NUMBER_OUTBOUND
84
+ body.to = PHONE_NUMBER_INBOUND
85
+ body.application_id = VOICE_APPLICATION_ID
86
+ body.answer_url = CALLBACK_URL
87
+ response = @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
88
+ assert(response.data.call_id.length > 0, "call_id value not set")
89
+
90
+ #Get phone call information
91
+ response = @bandwidth_client.voice_client.client.get_call_state(ACCOUNT_ID, response.data.call_id)
92
+ assert(response.data.state.length > 0, "state value not set")
93
+ end
94
+
95
+ def test_create_call_invalid_phone_number
96
+ body = ApiCreateCallRequest.new
97
+ body.from = PHONE_NUMBER_OUTBOUND
98
+ body.to = "+1invalid"
99
+ body.application_id = VOICE_APPLICATION_ID
100
+ body.answer_url = CALLBACK_URL
101
+
102
+ begin
103
+ @bandwidth_client.voice_client.client.create_call(ACCOUNT_ID, :body => body)
104
+ #workaround to make sure that if the above error is not raised, the build will fail
105
+ assert(false, "Expected exception not raised")
106
+ rescue ApiErrorResponseException => e
107
+ assert(e.description.length > 0, "description value not set")
108
+ end
109
+ end
110
+
111
+ def test_forward
112
+ forward = Bandwidth::Voice::Forward.new({
113
+ :to => "+15554443333",
114
+ :from => "+13334445555",
115
+ :call_timeout => 25,
116
+ :diversion_treatment => "none",
117
+ :diversion_reason => "away"
118
+ })
119
+
120
+ response = Bandwidth::Voice::Response.new()
121
+ response.push(forward)
122
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Forward to="+15554443333" from="+13334445555" callTimeout="25" diversionTreatment="none" diversionReason="away"/></Response>'
123
+ actual = response.to_bxml()
124
+ assert_equal(expected, actual)
125
+ end
126
+
127
+ def test_gather
128
+ gather = Bandwidth::Voice::Gather.new({
129
+ :gather_url => "https://test.com",
130
+ :gather_method => "POST",
131
+ :username => "user",
132
+ :password => "pass",
133
+ :tag => "tag",
134
+ :terminating_digits => "#",
135
+ :max_digits => 3,
136
+ :inter_digit_timeout => 5,
137
+ :first_digit_timeout => "10",
138
+ :repeat_count => 1,
139
+ :gather_fallback_url => "https://test.com",
140
+ :gather_fallback_method => "GET",
141
+ :fallback_username => "fuser",
142
+ :fallback_password => "fpass"
143
+ })
144
+
145
+ response = Bandwidth::Voice::Response.new()
146
+ response.push(gather)
147
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather gatherUrl="https://test.com" gatherMethod="POST" terminatingDigits="#" tag="tag" maxDigits="3" interDigitTimeout="5" username="user" password="pass" firstDigitTimeout="10" repeatCount="1" gatherFallbackUrl="https://test.com" gatherFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"></Gather></Response>'
148
+ actual = response.to_bxml()
149
+ assert_equal(expected, actual)
150
+ end
151
+
152
+ def test_gather_nested_speak_sentence
153
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
154
+ :sentence => "test"
155
+ })
156
+ gather = Bandwidth::Voice::Gather.new({
157
+ :speak_sentence => speak_sentence
158
+ })
159
+
160
+ response = Bandwidth::Voice::Response.new()
161
+ response.push(gather)
162
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><SpeakSentence>test</SpeakSentence></Gather></Response>'
163
+ actual = response.to_bxml()
164
+ assert_equal(expected, actual)
165
+ end
166
+
167
+ def test_gather_nested_play_audio
168
+ play_audio = Bandwidth::Voice::PlayAudio.new({
169
+ :url => "https://test.com"
170
+ })
171
+ gather = Bandwidth::Voice::Gather.new({
172
+ :play_audio => play_audio
173
+ })
174
+
175
+ response = Bandwidth::Voice::Response.new()
176
+ response.push(gather)
177
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio></Gather></Response>'
178
+ actual = response.to_bxml()
179
+ assert_equal(expected, actual)
180
+ end
181
+
182
+ def test_gather_multiple_nested_verbs
183
+ play_audio = Bandwidth::Voice::PlayAudio.new({
184
+ :url => "https://test.com"
185
+ })
186
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
187
+ :sentence => "test"
188
+ })
189
+ gather = Bandwidth::Voice::Gather.new({
190
+ :nested_verbs => [play_audio, speak_sentence]
191
+ })
192
+
193
+ response = Bandwidth::Voice::Response.new()
194
+ response.push(gather)
195
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Gather><PlayAudio>https://test.com</PlayAudio><SpeakSentence>test</SpeakSentence></Gather></Response>'
196
+ actual = response.to_bxml()
197
+ assert_equal(expected, actual)
198
+ end
199
+
200
+ def test_hangup
201
+ hangup = Bandwidth::Voice::Hangup.new()
202
+
203
+ response = Bandwidth::Voice::Response.new()
204
+ response.push(hangup)
205
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Hangup/></Response>'
206
+ actual = response.to_bxml()
207
+ assert_equal(expected, actual)
208
+ end
209
+
210
+ def test_pause
211
+ pause = Bandwidth::Voice::Pause.new({
212
+ :duration => 2
213
+ })
214
+
215
+ response = Bandwidth::Voice::Response.new()
216
+ response.push(pause)
217
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Pause duration="2"/></Response>'
218
+ actual = response.to_bxml()
219
+ assert_equal(expected, actual)
220
+ end
221
+
222
+ def test_pause_recording
223
+ pause_recording = Bandwidth::Voice::PauseRecording.new()
224
+
225
+ response = Bandwidth::Voice::Response.new()
226
+ response.push(pause_recording)
227
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PauseRecording/></Response>'
228
+ actual = response.to_bxml()
229
+ assert_equal(expected, actual)
230
+ end
231
+
232
+ def test_play_audio
233
+ play_audio = Bandwidth::Voice::PlayAudio.new({
234
+ :url => "https://test.com",
235
+ :username => "user",
236
+ :password => "pass"
237
+ })
238
+
239
+ response = Bandwidth::Voice::Response.new()
240
+ response.push(play_audio)
241
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><PlayAudio username="user" password="pass">https://test.com</PlayAudio></Response>'
242
+ actual = response.to_bxml()
243
+ assert_equal(expected, actual)
244
+ end
245
+
246
+ def test_record
247
+ record = Bandwidth::Voice::Record.new({
248
+ :record_complete_url => "https://complete.com",
249
+ :record_complete_method => "POST",
250
+ :recording_available_url => "https://available.com",
251
+ :recording_available_method => "GET",
252
+ :transcribe => false,
253
+ :transcription_available_url => "https://transcribe.com",
254
+ :transcription_available_method => "POST",
255
+ :username => "user",
256
+ :password => "pass",
257
+ :tag => "tag",
258
+ :terminating_digits => "#",
259
+ :max_duration => 3,
260
+ :silence_timeout => 5,
261
+ :file_format => "wav",
262
+ :record_complete_fallback_url => "https://test.com",
263
+ :record_complete_fallback_method => "GET",
264
+ :fallback_username => "fuser",
265
+ :fallback_password => "fpass"
266
+ })
267
+
268
+ response = Bandwidth::Voice::Response.new()
269
+ response.push(record)
270
+ 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>'
271
+ actual = response.to_bxml()
272
+ assert_equal(expected, actual)
273
+ end
274
+
275
+ def test_redirect
276
+ redirect = Bandwidth::Voice::Redirect.new({
277
+ :redirect_url => "https://redirect.com",
278
+ :redirect_method => "GET",
279
+ :username => "user",
280
+ :password => "pass",
281
+ :tag => "tag",
282
+ :redirect_fallback_url => "https://test.com",
283
+ :redirect_fallback_method => "GET",
284
+ :fallback_username => "fuser",
285
+ :fallback_password => "fpass"
286
+ })
287
+
288
+ response = Bandwidth::Voice::Response.new()
289
+ response.push(redirect)
290
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Redirect redirectUrl="https://redirect.com" redirectMethod="GET" tag="tag" username="user" password="pass" redirectFallbackUrl="https://test.com" redirectFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass"/></Response>'
291
+ actual = response.to_bxml()
292
+ assert_equal(expected, actual)
293
+ end
294
+
295
+ def test_resume_recording
296
+ resume_recording = Bandwidth::Voice::ResumeRecording.new()
297
+
298
+ response = Bandwidth::Voice::Response.new()
299
+ response.push(resume_recording)
300
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><ResumeRecording/></Response>'
301
+ actual = response.to_bxml()
302
+ assert_equal(expected, actual)
303
+ end
304
+
305
+ def test_send_dtmf
306
+ send_dtmf = Bandwidth::Voice::SendDtmf.new({
307
+ :dtmf => "12w34",
308
+ :tone_duration => 75,
309
+ :tone_interval => 65
310
+ })
311
+
312
+ response = Bandwidth::Voice::Response.new()
313
+ response.push(send_dtmf)
314
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SendDtmf toneDuration="75" toneInterval="65">12w34</SendDtmf></Response>'
315
+ actual = response.to_bxml()
316
+ assert_equal(expected, actual)
317
+ end
318
+
319
+ def test_speak_sentence
320
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
321
+ :sentence => "test",
322
+ :voice => "julie",
323
+ :gender => "female",
324
+ :locale => "en_US"
325
+ })
326
+
327
+ response = Bandwidth::Voice::Response.new()
328
+ response.push(speak_sentence)
329
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence voice="julie" locale="en_US" gender="female">test</SpeakSentence></Response>'
330
+ actual = response.to_bxml()
331
+ assert_equal(expected, actual)
332
+ end
333
+
334
+ def test_speak_sentence_ssml
335
+ speak_sentence = Bandwidth::Voice::SpeakSentence.new({
336
+ :sentence => 'Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.',
337
+ })
338
+
339
+ response = Bandwidth::Voice::Response.new()
340
+ response.push(speak_sentence)
341
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><SpeakSentence>Hello, you have reached the home of <lang xml:lang="es-MX">Antonio Mendoza</lang>.Please leave a message.</SpeakSentence></Response>'
342
+ actual = response.to_bxml()
343
+ assert_equal(expected, actual)
344
+ end
345
+
346
+ def test_start_recording
347
+ start_recording = Bandwidth::Voice::StartRecording.new({
348
+ :recording_available_url => "https://available.com",
349
+ :recording_available_method => "POST",
350
+ :transcribe => false,
351
+ :transcription_available_url => "https://transcribe.com",
352
+ :transcription_available_method => "GET",
353
+ :username => "user",
354
+ :password => "pass",
355
+ :tag => "tag",
356
+ :file_format => "mp3",
357
+ :multi_channel => true
358
+ })
359
+
360
+ response = Bandwidth::Voice::Response.new()
361
+ response.push(start_recording)
362
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartRecording tag="tag" username="user" password="pass" recordingAvailableUrl="https://available.com" recordingAvailableMethod="POST" fileFormat="mp3" multiChannel="true" transcribe="false" transcriptionAvailableUrl="https://transcribe.com" transcriptionAvailableMethod="GET"/></Response>'
363
+ actual = response.to_bxml()
364
+ assert_equal(expected, actual)
365
+ end
366
+
367
+ def test_stop_recording
368
+ stop_recording = Bandwidth::Voice::StopRecording.new()
369
+
370
+ response = Bandwidth::Voice::Response.new()
371
+ response.push(stop_recording)
372
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopRecording/></Response>'
373
+ actual = response.to_bxml()
374
+ assert_equal(expected, actual)
375
+ end
376
+
377
+ def test_transfer
378
+ phone_number = Bandwidth::Voice::PhoneNumber.new({
379
+ :number => "+15554443333",
380
+ :transfer_answer_url => "https://phoneanswer.com",
381
+ :transfer_answer_method => "GET",
382
+ :transfer_disconnect_url => "https://phonedisconnect.com",
383
+ :transfer_disconnect_method => "POST",
384
+ :username => "phoneuser",
385
+ :password => "phonepassword",
386
+ :tag => "phonetag",
387
+ :transfer_answer_fallback_url => "https://test.com",
388
+ :transfer_answer_fallback_method => "GET",
389
+ :fallback_username => "fuser",
390
+ :fallback_password => "fpass"
391
+ })
392
+ transfer = Bandwidth::Voice::Transfer.new({
393
+ :transfer_caller_id => "+13334445555",
394
+ :call_timeout => 3,
395
+ :transfer_complete_url => "https://transfercomplete.com",
396
+ :transfer_complete_method => "POST",
397
+ :username => "transferuser",
398
+ :password => "transferpass",
399
+ :tag => "transfertag",
400
+ :diversion_treatment => "none",
401
+ :diversion_reason => "away",
402
+ :phone_numbers => [phone_number],
403
+ :transfer_complete_fallback_url => "https://test.com",
404
+ :transfer_complete_fallback_method => "GET",
405
+ :fallback_username => "fusern",
406
+ :fallback_password => "fpassw"
407
+ })
408
+
409
+ response = Bandwidth::Voice::Response.new()
410
+ response.push(transfer)
411
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer transferCallerId="+13334445555" callTimeout="3" tag="transfertag" transferCompleteUrl="https://transfercomplete.com" transferCompleteMethod="POST" username="transferuser" password="transferpass" diversionTreatment="none" diversionReason="away" transferCompleteFallbackUrl="https://test.com" transferCompleteFallbackMethod="GET" fallbackUsername="fusern" fallbackPassword="fpassw"><PhoneNumber transferAnswerUrl="https://phoneanswer.com" transferAnswerMethod="GET" transferDisconnectUrl="https://phonedisconnect.com" transferDisconnectMethod="POST" username="phoneuser" password="phonepassword" tag="phonetag" transferAnswerFallbackUrl="https://test.com" transferAnswerFallbackMethod="GET" fallbackUsername="fuser" fallbackPassword="fpass">+15554443333</PhoneNumber></Transfer></Response>'
412
+ actual = response.to_bxml()
413
+ assert_equal(expected, actual)
414
+ end
415
+
416
+ def test_conference
417
+ conference = Bandwidth::Voice::Conference.new({
418
+ :conference_name => 'my-conference',
419
+ :mute => false,
420
+ :hold => true,
421
+ :call_ids_to_coach => "c-123,c-234",
422
+ :conference_event_url => "https://test.com",
423
+ :conference_event_method => "POST",
424
+ :username => "user",
425
+ :password => "pass",
426
+ :tag => "tag",
427
+ :conference_event_fallback_url => "https://test2.com",
428
+ :conference_event_fallback_method => "POST",
429
+ :fallback_username => "fuser",
430
+ :fallback_password => "fpass"
431
+ })
432
+ response = Bandwidth::Voice::Response.new()
433
+ response.push(conference)
434
+
435
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference mute="false" hold="true" callIdsToCoach="c-123,c-234" conferenceEventUrl="https://test.com" conferenceEventMethod="POST" username="user" password="pass" tag="tag" conferenceEventFallbackUrl="https://test2.com" conferenceEventFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">my-conference</Conference></Response>'
436
+ actual = response.to_bxml()
437
+ assert_equal(expected, actual)
438
+ end
439
+
440
+ def test_conference_coach_ids_array
441
+ conference = Bandwidth::Voice::Conference.new({
442
+ :conference_name => 'my-conference',
443
+ :call_ids_to_coach => ["c-123", "c-234"],
444
+ })
445
+ response = Bandwidth::Voice::Response.new()
446
+ response.push(conference)
447
+
448
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference callIdsToCoach="c-123,c-234">my-conference</Conference></Response>'
449
+ actual = response.to_bxml()
450
+ assert_equal(expected, actual)
451
+ end
452
+
453
+ def test_conference_no_coach
454
+ conference = Bandwidth::Voice::Conference.new({
455
+ :conference_name => 'my-conference'
456
+ })
457
+ response = Bandwidth::Voice::Response.new()
458
+ response.push(conference)
459
+
460
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Conference>my-conference</Conference></Response>'
461
+ actual = response.to_bxml()
462
+ assert_equal(expected, actual)
463
+ end
464
+
465
+ def test_mfa_messaging
466
+ body = TwoFactorCodeRequestSchema.new
467
+ body.from = PHONE_NUMBER_MFA
468
+ body.to = PHONE_NUMBER_INBOUND
469
+ body.application_id = MFA_MESSAGING_APPLICATION_ID
470
+ body.scope = "scope"
471
+ body.digits = 6
472
+ body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
473
+
474
+ response = @bandwidth_client.two_factor_auth_client.mfa.create_messaging_two_factor(ACCOUNT_ID, body)
475
+ assert(response.data.message_id.length > 0, "message id value not set")
476
+ end
477
+
478
+ def test_mfa_voice
479
+ body = TwoFactorCodeRequestSchema.new
480
+ body.from = PHONE_NUMBER_MFA
481
+ body.to = PHONE_NUMBER_INBOUND
482
+ body.application_id = MFA_VOICE_APPLICATION_ID
483
+ body.scope = "scope"
484
+ body.digits = 6
485
+ body.message = "Your temporary {NAME} {SCOPE} code is {CODE}"
486
+
487
+ response = @bandwidth_client.two_factor_auth_client.mfa.create_voice_two_factor(ACCOUNT_ID, body)
488
+ assert(response.data.call_id.length > 0, "call id value not set")
489
+ end
490
+
491
+ def test_mfa_verify
492
+ body = TwoFactorVerifyRequestSchema.new
493
+ body.to = PHONE_NUMBER_INBOUND
494
+ body.application_id = MFA_VOICE_APPLICATION_ID
495
+ body.scope = "scope"
496
+ body.code = "123456"
497
+ body.expiration_time_in_minutes = 3
498
+ response = @bandwidth_client.two_factor_auth_client.mfa.create_verify_two_factor(ACCOUNT_ID, body)
499
+ #Ruby has no check to see if variables are of type boolean
500
+ #An explicit true/false check is required
501
+ assert(response.data.valid == true || response.data.valid == false, "'valid' variable is not a boolean")
502
+ end
503
+
504
+ def test_bridge
505
+ bridge = Bandwidth::Voice::Bridge.new({
506
+ :call_id => "c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
507
+ :bridge_complete_url => "https://test.com",
508
+ :bridge_complete_method => "POST",
509
+ :bridge_target_complete_url => "https://test2.com",
510
+ :bridge_target_complete_method => "GET",
511
+ :username => "user",
512
+ :password => "pass",
513
+ :tag => "custom tag",
514
+ :bridge_complete_fallback_url => "https://test3.com",
515
+ :bridge_complete_fallback_method => "GET",
516
+ :bridge_target_complete_fallback_url => "https://test4.com",
517
+ :bridge_target_complete_fallback_method => "POST",
518
+ :fallback_username => "fuser",
519
+ :fallback_password => "fpass"
520
+ })
521
+
522
+ response = Bandwidth::Voice::Response.new()
523
+ response.push(bridge)
524
+
525
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Bridge bridgeCompleteUrl="https://test.com" bridgeCompleteMethod="POST" bridgeTargetCompleteUrl="https://test2.com" bridgeTargetCompleteMethod="GET" username="user" password="pass" tag="custom tag" bridgeCompleteFallbackUrl="https://test3.com" bridgeCompleteFallbackMethod="GET" bridgeTargetCompleteFallbackUrl="https://test4.com" bridgeTargetCompleteFallbackMethod="POST" fallbackUsername="fuser" fallbackPassword="fpass">c-c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d</Bridge></Response>'
526
+ actual = response.to_bxml()
527
+ assert_equal(expected, actual)
528
+ end
529
+
530
+ def test_ring
531
+ ring = Bandwidth::Voice::Ring.new({
532
+ :duration => 5
533
+ })
534
+
535
+ response = Bandwidth::Voice::Response.new()
536
+ response.push(ring)
537
+
538
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><Ring duration="5"/></Response>'
539
+ actual = response.to_bxml()
540
+ assert_equal(expected, actual)
541
+ end
542
+
543
+ def test_start_gather
544
+ start_gather = Bandwidth::Voice::StartGather.new({
545
+ :username => "user",
546
+ :password => "pass",
547
+ :tag => "custom tag",
548
+ :dtmf_url => "https://test.com",
549
+ :dtmf_method => "GET"
550
+ })
551
+
552
+ response = Bandwidth::Voice::Response.new()
553
+ response.push(start_gather)
554
+
555
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartGather username="user" password="pass" tag="custom tag" dtmfUrl="https://test.com" dtmfMethod="GET"/></Response>'
556
+ actual = response.to_bxml()
557
+ assert_equal(expected, actual)
558
+ end
559
+
560
+ def test_stop_gather
561
+ stop_gather = Bandwidth::Voice::StopGather.new()
562
+
563
+ response = Bandwidth::Voice::Response.new()
564
+ response.push(stop_gather)
565
+
566
+ expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopGather/></Response>'
567
+ actual = response.to_bxml()
568
+ assert_equal(expected, actual)
569
+ end
570
+ 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: 6.0.0
4
+ version: 6.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - APIMatic SDK Generator
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -259,14 +259,13 @@ files:
259
259
  - lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb
260
260
  - lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb
261
261
  - lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb
262
+ - lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb
262
263
  - lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb
263
264
  - lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb
264
265
  - lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb
265
266
  - lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb
266
267
  - lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb
267
- - test/controllers/controller_test_base.rb
268
- - test/http_response_catcher.rb
269
- - test/test_helper.rb
268
+ - test/integration/test_integration.rb
270
269
  homepage: https://apimatic.io
271
270
  licenses:
272
271
  - MIT
@@ -1,21 +0,0 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- require 'json'
7
- require 'minitest/autorun'
8
- require 'minitest/hell'
9
- require 'minitest/pride'
10
- require 'minitest/proveit'
11
- require 'bandwidth'
12
- require_relative '../test_helper'
13
- require_relative '../http_response_catcher'
14
-
15
- class ControllerTestBase < Minitest::Test
16
- parallelize_me!
17
- include Bandwidth
18
-
19
- # Create configuration and set any test parameters
20
- CONFIG = Configuration.new
21
- end
@@ -1,19 +0,0 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- class HttpResponseCatcher < Bandwidth::HttpCallBack
7
- attr_accessor :response
8
-
9
- def on_before_request(request)
10
- end
11
-
12
- # Catching the response
13
- def on_after_response(response)
14
- @response = response
15
- end
16
- end
17
-
18
-
19
-
data/test/test_helper.rb DELETED
@@ -1,94 +0,0 @@
1
- # bandwidth
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- require 'tempfile'
7
- require 'open-uri'
8
-
9
- class TestHelper
10
-
11
- @cache = Hash.new
12
-
13
- # Class method to compare the received headers with the expected headers.
14
- # @param [Hash] A hash of expected headers (keys in lower case).
15
- # @param [Hash] A hash of received headers.
16
- # @param [Boolean, optional] A flag which determines if we allow extra headers.
17
- def self.match_headers(expected_headers,
18
- received_headers,
19
- allow_extra: true)
20
- return false if ((received_headers.length < expected_headers.length) ||
21
- ((allow_extra == false) && (received_headers.length > expected_headers.length)))
22
-
23
- received_headers = Hash[received_headers.map{|k, v| [k.to_s.downcase, v]}]
24
- expected_headers.each do |e_key, e_value|
25
- return false unless received_headers.key?(e_key)
26
- return false if ((e_value != nil) &&
27
- (e_value != received_headers[e_key]))
28
- end
29
-
30
- return true
31
- end
32
-
33
- # Class method to compare the received body with the expected body.
34
- # @param [Dynamic] The expected body.
35
- # @param [Dynamic] The received body.
36
- # @param [Boolean, optional] A flag which determines if we check values in dictionaries.
37
- # @param [Boolean, optional] A flag which determines if we check the order of array elements.
38
- # @param [Boolean, optional] A flag which determines if we check the count of array elements.
39
- def self.match_body(expected_body,
40
- received_body,
41
- check_values: false,
42
- check_order: false,
43
- check_count: false)
44
- if expected_body.instance_of? Hash
45
- return false unless received_body.instance_of? Hash
46
- for key in expected_body.keys
47
- return false unless received_body.keys.include? key
48
- if check_values or expected_body[key].instance_of? Hash
49
- return false unless TestHelper.match_body(expected_body[key],
50
- received_body[key],
51
- check_values: check_values,
52
- check_order: check_order,
53
- check_count: check_count)
54
- end
55
- end
56
- elsif expected_body.instance_of? Array
57
- return False unless received_body.instance_of? Array
58
- if check_count == true && (expected_body.length != received_body.length)
59
- return false
60
- else
61
- previous_matches = Array.new
62
- expected_body.each.with_index do |expected_element, i|
63
- matches = (received_body.map.with_index do |received_element, j|
64
- j if TestHelper.match_body(expected_element,
65
- received_element,
66
- check_values: check_values,
67
- check_order: check_order,
68
- check_count: check_count)
69
- end).compact
70
- return false if matches.length == 0
71
- if check_order == true
72
- return false if (i != 0 && matches.map{|x| previous_matches.map{|y| y > x}.all?}.all?)
73
- previous_matches = matches
74
- end
75
- end
76
- end
77
- elsif expected_body != received_body
78
- return false
79
- end
80
- return true
81
- end
82
-
83
- # Class method which takes a URL, downloads the file (if not already downloaded
84
- # for this test session) and returns the path of the file.
85
- # @param [String] The URL of the required file.
86
- def self.get_file(url)
87
- unless @cache.keys.include? url
88
- @cache[url] = Tempfile.new('APIMatic')
89
- @cache[url].binmode
90
- @cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
91
- end
92
- return @cache[url].path
93
- end
94
- end