bandwidth-sdk 8.0.0 → 9.0.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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth/api_helper.rb +19 -17
  3. data/lib/bandwidth/configuration.rb +7 -19
  4. data/lib/bandwidth/http/faraday_client.rb +1 -1
  5. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
  6. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
  7. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
  8. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
  9. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
  10. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
  12. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
  13. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
  14. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
  15. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
  16. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
  17. data/lib/bandwidth/models/base_model.rb +11 -0
  18. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
  19. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
  20. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
  21. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
  22. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
  23. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
  24. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
  25. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
  26. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
  27. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
  28. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
  30. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
  32. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
  35. data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
  36. data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
  37. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +171 -150
  38. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
  39. data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
  40. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
  41. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
  42. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
  43. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
  44. data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
  45. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
  46. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
  47. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
  48. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
  49. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
  50. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
  51. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
  52. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
  53. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
  54. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
  55. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
  56. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
  57. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
  58. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
  59. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
  60. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
  61. data/lib/bandwidth/voice_lib/voice.rb +7 -1
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
  67. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
  68. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
  69. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
  70. data/lib/bandwidth.rb +19 -18
  71. data/test/integration/test_integration.rb +75 -53
  72. metadata +9 -2
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TranscriptionMetadata Model.
8
8
  class TranscriptionMetadata < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # TODO: Write general description for this method
10
13
  # @return [String]
11
14
  attr_accessor :id
@@ -41,14 +44,29 @@ module Bandwidth
41
44
  @_hash
42
45
  end
43
46
 
47
+ # An array for optional fields
48
+ def optionals
49
+ %w[
50
+ id
51
+ status
52
+ completed_time
53
+ url
54
+ ]
55
+ end
56
+
57
+ # An array for nullable fields
58
+ def nullables
59
+ []
60
+ end
61
+
44
62
  def initialize(id = nil,
45
63
  status = nil,
46
64
  completed_time = nil,
47
65
  url = nil)
48
- @id = id
49
- @status = status
50
- @completed_time = completed_time
51
- @url = url
66
+ @id = id unless id == SKIP
67
+ @status = status unless status == SKIP
68
+ @completed_time = completed_time unless completed_time == SKIP
69
+ @url = url unless url == SKIP
52
70
  end
53
71
 
54
72
  # Creates an instance of the object from a hash.
@@ -56,10 +74,10 @@ module Bandwidth
56
74
  return nil unless hash
57
75
 
58
76
  # Extract variables from the hash.
59
- id = hash['id']
60
- status = hash['status']
61
- completed_time = hash['completedTime']
62
- url = hash['url']
77
+ id = hash.key?('id') ? hash['id'] : SKIP
78
+ status = hash.key?('status') ? hash['status'] : SKIP
79
+ completed_time = hash.key?('completedTime') ? hash['completedTime'] : SKIP
80
+ url = hash.key?('url') ? hash['url'] : SKIP
63
81
 
64
82
  # Create object from extracted values.
65
83
  TranscriptionMetadata.new(id,
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TranscriptionResponse Model.
8
8
  class TranscriptionResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # TODO: Write general description for this method
10
13
  # @return [List of Transcript]
11
14
  attr_accessor :transcripts
@@ -17,8 +20,20 @@ module Bandwidth
17
20
  @_hash
18
21
  end
19
22
 
23
+ # An array for optional fields
24
+ def optionals
25
+ %w[
26
+ transcripts
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def nullables
32
+ []
33
+ end
34
+
20
35
  def initialize(transcripts = nil)
21
- @transcripts = transcripts
36
+ @transcripts = transcripts unless transcripts == SKIP
22
37
  end
23
38
 
24
39
  # Creates an instance of the object from a hash.
@@ -35,6 +50,8 @@ module Bandwidth
35
50
  end
36
51
  end
37
52
 
53
+ transcripts = SKIP unless hash.key?('transcripts')
54
+
38
55
  # Create object from extracted values.
39
56
  TranscriptionResponse.new(transcripts)
40
57
  end
@@ -17,17 +17,24 @@ require_relative 'voice/models/modify_conference_request.rb'
17
17
  require_relative 'voice/models/conference_state.rb'
18
18
  require_relative 'voice/models/conference_member_state.rb'
19
19
  require_relative 'voice/models/conference_recording_metadata.rb'
20
+ require_relative 'voice/models/machine_detection_configuration.rb'
20
21
  require_relative 'voice/models/transcribe_recording_request.rb'
21
22
  require_relative 'voice/models/transcription_response.rb'
22
23
  require_relative 'voice/models/transcription_metadata.rb'
23
24
  require_relative 'voice/models/transcript.rb'
25
+ require_relative 'voice/models/call_callback.rb'
26
+ require_relative 'voice/models/transcription.rb'
27
+ require_relative 'voice/models/diversion.rb'
28
+ require_relative 'voice/models/conference_callback.rb'
24
29
  require_relative 'voice/models/answer_fallback_method_enum.rb'
25
30
  require_relative 'voice/models/answer_method_enum.rb'
26
31
  require_relative 'voice/models/callback_method_enum.rb'
27
32
  require_relative 'voice/models/conference_event_method_enum.rb'
28
33
  require_relative 'voice/models/direction_enum.rb'
29
34
  require_relative 'voice/models/disconnect_method_enum.rb'
35
+ require_relative 'voice/models/fallback_method_enum.rb'
30
36
  require_relative 'voice/models/file_format_enum.rb'
37
+ require_relative 'voice/models/mode_enum.rb'
31
38
  require_relative 'voice/models/redirect_fallback_method_enum.rb'
32
39
  require_relative 'voice/models/redirect_method_enum.rb'
33
40
  require_relative 'voice/models/state_enum.rb'
@@ -39,4 +46,3 @@ require_relative 'voice/exceptions/api_error_exception.rb'
39
46
  # Controllers
40
47
  require_relative 'voice/controllers/base_controller.rb'
41
48
  require_relative 'voice/controllers/api_controller.rb'
42
- require_relative 'bxml/bxml.rb'
@@ -11,9 +11,9 @@ module WebRtc
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # Create a new participant under this account
14
+ # Create a new participant under this account.
15
15
  # Participants are idempotent, so relevant parameters must be set in this
16
- # function if desired
16
+ # function if desired.
17
17
  # @param [String] account_id Required parameter: Account ID
18
18
  # @param [Participant] body Optional parameter: Participant parameters
19
19
  # @return [AccountsParticipantsResponse] response from the API call
@@ -44,17 +44,18 @@ module WebRtc
44
44
  _response = execute_request(_request)
45
45
 
46
46
  # Validate response against endpoint and global error codes.
47
- if _response.status_code == 400
47
+ case _response.status_code
48
+ when 400
48
49
  raise APIException.new(
49
50
  'Bad Request',
50
51
  _response
51
52
  )
52
- elsif _response.status_code == 401
53
+ when 401
53
54
  raise APIException.new(
54
55
  'Unauthorized',
55
56
  _response
56
57
  )
57
- elsif _response.status_code == 403
58
+ when 403
58
59
  raise APIException.new(
59
60
  'Access Denied',
60
61
  _response
@@ -76,7 +77,7 @@ module WebRtc
76
77
  )
77
78
  end
78
79
 
79
- # Get participant by ID
80
+ # Get participant by ID.
80
81
  # @param [String] account_id Required parameter: Account ID
81
82
  # @param [String] participant_id Required parameter: Participant ID
82
83
  # @return [Participant] response from the API call
@@ -106,17 +107,18 @@ module WebRtc
106
107
  _response = execute_request(_request)
107
108
 
108
109
  # Validate response against endpoint and global error codes.
109
- if _response.status_code == 401
110
+ case _response.status_code
111
+ when 401
110
112
  raise APIException.new(
111
113
  'Unauthorized',
112
114
  _response
113
115
  )
114
- elsif _response.status_code == 403
116
+ when 403
115
117
  raise APIException.new(
116
118
  'Access Denied',
117
119
  _response
118
120
  )
119
- elsif _response.status_code == 404
121
+ when 404
120
122
  raise APIException.new(
121
123
  'Not Found',
122
124
  _response
@@ -137,7 +139,7 @@ module WebRtc
137
139
  )
138
140
  end
139
141
 
140
- # Delete participant by ID
142
+ # Delete participant by ID.
141
143
  # @param [String] account_id Required parameter: Account ID
142
144
  # @param [String] participant_id Required parameter: Example:
143
145
  # @return [void] response from the API call
@@ -161,17 +163,18 @@ module WebRtc
161
163
  _response = execute_request(_request)
162
164
 
163
165
  # Validate response against endpoint and global error codes.
164
- if _response.status_code == 401
166
+ case _response.status_code
167
+ when 401
165
168
  raise APIException.new(
166
169
  'Unauthorized',
167
170
  _response
168
171
  )
169
- elsif _response.status_code == 403
172
+ when 403
170
173
  raise APIException.new(
171
174
  'Access Denied',
172
175
  _response
173
176
  )
174
- elsif _response.status_code == 404
177
+ when 404
175
178
  raise APIException.new(
176
179
  'Not Found',
177
180
  _response
@@ -189,9 +192,9 @@ module WebRtc
189
192
  ApiResponse.new(_response)
190
193
  end
191
194
 
192
- # Create a new session
195
+ # Create a new session.
193
196
  # Sessions are idempotent, so relevant parameters must be set in this
194
- # function if desired
197
+ # function if desired.
195
198
  # @param [String] account_id Required parameter: Account ID
196
199
  # @param [Session] body Optional parameter: Session parameters
197
200
  # @return [Session] response from the API call
@@ -222,17 +225,18 @@ module WebRtc
222
225
  _response = execute_request(_request)
223
226
 
224
227
  # Validate response against endpoint and global error codes.
225
- if _response.status_code == 400
228
+ case _response.status_code
229
+ when 400
226
230
  raise APIException.new(
227
231
  'Bad Request',
228
232
  _response
229
233
  )
230
- elsif _response.status_code == 401
234
+ when 401
231
235
  raise APIException.new(
232
236
  'Unauthorized',
233
237
  _response
234
238
  )
235
- elsif _response.status_code == 403
239
+ when 403
236
240
  raise APIException.new(
237
241
  'Access Denied',
238
242
  _response
@@ -253,7 +257,7 @@ module WebRtc
253
257
  )
254
258
  end
255
259
 
256
- # Get session by ID
260
+ # Get session by ID.
257
261
  # @param [String] account_id Required parameter: Account ID
258
262
  # @param [String] session_id Required parameter: Session ID
259
263
  # @return [Session] response from the API call
@@ -283,17 +287,18 @@ module WebRtc
283
287
  _response = execute_request(_request)
284
288
 
285
289
  # Validate response against endpoint and global error codes.
286
- if _response.status_code == 401
290
+ case _response.status_code
291
+ when 401
287
292
  raise APIException.new(
288
293
  'Unauthorized',
289
294
  _response
290
295
  )
291
- elsif _response.status_code == 403
296
+ when 403
292
297
  raise APIException.new(
293
298
  'Access Denied',
294
299
  _response
295
300
  )
296
- elsif _response.status_code == 404
301
+ when 404
297
302
  raise APIException.new(
298
303
  'Not Found',
299
304
  _response
@@ -314,7 +319,7 @@ module WebRtc
314
319
  )
315
320
  end
316
321
 
317
- # Delete session by ID
322
+ # Delete session by ID.
318
323
  # @param [String] account_id Required parameter: Account ID
319
324
  # @param [String] session_id Required parameter: Session ID
320
325
  # @return [void] response from the API call
@@ -338,17 +343,18 @@ module WebRtc
338
343
  _response = execute_request(_request)
339
344
 
340
345
  # Validate response against endpoint and global error codes.
341
- if _response.status_code == 401
346
+ case _response.status_code
347
+ when 401
342
348
  raise APIException.new(
343
349
  'Unauthorized',
344
350
  _response
345
351
  )
346
- elsif _response.status_code == 403
352
+ when 403
347
353
  raise APIException.new(
348
354
  'Access Denied',
349
355
  _response
350
356
  )
351
- elsif _response.status_code == 404
357
+ when 404
352
358
  raise APIException.new(
353
359
  'Not Found',
354
360
  _response
@@ -366,7 +372,7 @@ module WebRtc
366
372
  ApiResponse.new(_response)
367
373
  end
368
374
 
369
- # List participants in a session
375
+ # List participants in a session.
370
376
  # @param [String] account_id Required parameter: Account ID
371
377
  # @param [String] session_id Required parameter: Session ID
372
378
  # @return [List of Participant] response from the API call
@@ -396,17 +402,18 @@ module WebRtc
396
402
  _response = execute_request(_request)
397
403
 
398
404
  # Validate response against endpoint and global error codes.
399
- if _response.status_code == 401
405
+ case _response.status_code
406
+ when 401
400
407
  raise APIException.new(
401
408
  'Unauthorized',
402
409
  _response
403
410
  )
404
- elsif _response.status_code == 403
411
+ when 403
405
412
  raise APIException.new(
406
413
  'Access Denied',
407
414
  _response
408
415
  )
409
- elsif _response.status_code == 404
416
+ when 404
410
417
  raise APIException.new(
411
418
  'Not Found',
412
419
  _response
@@ -428,8 +435,8 @@ module WebRtc
428
435
  )
429
436
  end
430
437
 
431
- # Add a participant to a session
432
- # Subscriptions can optionally be provided as part of this call
438
+ # Add a participant to a session.
439
+ # Subscriptions can optionally be provided as part of this call.
433
440
  # @param [String] account_id Required parameter: Account ID
434
441
  # @param [String] session_id Required parameter: Session ID
435
442
  # @param [String] participant_id Required parameter: Participant ID
@@ -466,17 +473,18 @@ module WebRtc
466
473
  _response = execute_request(_request)
467
474
 
468
475
  # Validate response against endpoint and global error codes.
469
- if _response.status_code == 401
476
+ case _response.status_code
477
+ when 401
470
478
  raise APIException.new(
471
479
  'Unauthorized',
472
480
  _response
473
481
  )
474
- elsif _response.status_code == 403
482
+ when 403
475
483
  raise APIException.new(
476
484
  'Access Denied',
477
485
  _response
478
486
  )
479
- elsif _response.status_code == 404
487
+ when 404
480
488
  raise APIException.new(
481
489
  'Not Found',
482
490
  _response
@@ -494,9 +502,9 @@ module WebRtc
494
502
  ApiResponse.new(_response)
495
503
  end
496
504
 
497
- # Remove a participant from a session
505
+ # Remove a participant from a session.
498
506
  # This will automatically remove any subscriptions the participant has
499
- # associated with this session
507
+ # associated with this session.
500
508
  # @param [String] account_id Required parameter: Account ID
501
509
  # @param [String] session_id Required parameter: Session ID
502
510
  # @param [String] participant_id Required parameter: Participant ID
@@ -523,17 +531,18 @@ module WebRtc
523
531
  _response = execute_request(_request)
524
532
 
525
533
  # Validate response against endpoint and global error codes.
526
- if _response.status_code == 401
534
+ case _response.status_code
535
+ when 401
527
536
  raise APIException.new(
528
537
  'Unauthorized',
529
538
  _response
530
539
  )
531
- elsif _response.status_code == 403
540
+ when 403
532
541
  raise APIException.new(
533
542
  'Access Denied',
534
543
  _response
535
544
  )
536
- elsif _response.status_code == 404
545
+ when 404
537
546
  raise APIException.new(
538
547
  'Not Found',
539
548
  _response
@@ -551,7 +560,7 @@ module WebRtc
551
560
  ApiResponse.new(_response)
552
561
  end
553
562
 
554
- # Get a participant's subscriptions
563
+ # Get a participant's subscriptions.
555
564
  # @param [String] account_id Required parameter: Account ID
556
565
  # @param [String] session_id Required parameter: Session ID
557
566
  # @param [String] participant_id Required parameter: Participant ID
@@ -584,17 +593,18 @@ module WebRtc
584
593
  _response = execute_request(_request)
585
594
 
586
595
  # Validate response against endpoint and global error codes.
587
- if _response.status_code == 401
596
+ case _response.status_code
597
+ when 401
588
598
  raise APIException.new(
589
599
  'Unauthorized',
590
600
  _response
591
601
  )
592
- elsif _response.status_code == 403
602
+ when 403
593
603
  raise APIException.new(
594
604
  'Access Denied',
595
605
  _response
596
606
  )
597
- elsif _response.status_code == 404
607
+ when 404
598
608
  raise APIException.new(
599
609
  'Not Found',
600
610
  _response
@@ -615,11 +625,11 @@ module WebRtc
615
625
  )
616
626
  end
617
627
 
618
- # Update a participant's subscriptions
628
+ # Update a participant's subscriptions.
619
629
  # This is a full update that will replace the participant's subscriptions.
620
630
  # First call `getParticipantSubscriptions` if you need the current
621
631
  # subscriptions. Call this function with no `Subscriptions` object to remove
622
- # all subscriptions
632
+ # all subscriptions.
623
633
  # @param [String] account_id Required parameter: Account ID
624
634
  # @param [String] session_id Required parameter: Session ID
625
635
  # @param [String] participant_id Required parameter: Participant ID
@@ -655,22 +665,23 @@ module WebRtc
655
665
  _response = execute_request(_request)
656
666
 
657
667
  # Validate response against endpoint and global error codes.
658
- if _response.status_code == 400
668
+ case _response.status_code
669
+ when 400
659
670
  raise APIException.new(
660
671
  'Bad Request',
661
672
  _response
662
673
  )
663
- elsif _response.status_code == 401
674
+ when 401
664
675
  raise APIException.new(
665
676
  'Unauthorized',
666
677
  _response
667
678
  )
668
- elsif _response.status_code == 403
679
+ when 403
669
680
  raise APIException.new(
670
681
  'Access Denied',
671
682
  _response
672
683
  )
673
- elsif _response.status_code == 404
684
+ when 404
674
685
  raise APIException.new(
675
686
  'Not Found',
676
687
  _response
@@ -19,14 +19,12 @@ module Bandwidth
19
19
 
20
20
  def validate_parameters(args)
21
21
  args.each do |_name, value|
22
- if value.nil?
23
- raise ArgumentError, "Required parameter #{_name} cannot be nil."
24
- end
22
+ raise ArgumentError, "Required parameter #{_name} cannot be nil." if value.nil?
25
23
  end
26
24
  end
27
25
 
28
26
  def execute_request(request, binary: false)
29
- @http_call_back.on_before_request(request) if @http_call_back
27
+ @http_call_back&.on_before_request(request)
30
28
 
31
29
  APIHelper.clean_hash(request.headers)
32
30
  request.headers.merge!(@global_headers)
@@ -36,7 +34,7 @@ module Bandwidth
36
34
  else
37
35
  config.http_client.execute_as_string(request)
38
36
  end
39
- @http_call_back.on_after_response(response) if @http_call_back
37
+ @http_call_back&.on_after_response(response)
40
38
 
41
39
  response
42
40
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # Error class.
8
8
  class ErrorException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # TODO: Write general description for this method
10
13
  # @return [Integer]
11
14
  attr_accessor :code
@@ -27,8 +30,8 @@ module Bandwidth
27
30
  # @param [Hash] The deserialized response sent by the server in the
28
31
  # response body.
29
32
  def unbox(hash)
30
- @code = hash['code']
31
- @message = hash['message']
33
+ @code = hash.key?('code') ? hash['code'] : SKIP
34
+ @message = hash.key?('message') ? hash['message'] : SKIP
32
35
  end
33
36
  end
34
37
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # AccountsParticipantsResponse Model.
8
8
  class AccountsParticipantsResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # A participant object
10
13
  # @return [Participant]
11
14
  attr_accessor :participant
@@ -24,10 +27,23 @@ module Bandwidth
24
27
  @_hash
25
28
  end
26
29
 
30
+ # An array for optional fields
31
+ def optionals
32
+ %w[
33
+ participant
34
+ token
35
+ ]
36
+ end
37
+
38
+ # An array for nullable fields
39
+ def nullables
40
+ []
41
+ end
42
+
27
43
  def initialize(participant = nil,
28
44
  token = nil)
29
- @participant = participant
30
- @token = token
45
+ @participant = participant unless participant == SKIP
46
+ @token = token unless token == SKIP
31
47
  end
32
48
 
33
49
  # Creates an instance of the object from a hash.
@@ -35,9 +51,8 @@ module Bandwidth
35
51
  return nil unless hash
36
52
 
37
53
  # Extract variables from the hash.
38
- participant = Participant.from_hash(hash['participant']) if
39
- hash['participant']
40
- token = hash['token']
54
+ participant = Participant.from_hash(hash['participant']) if hash['participant']
55
+ token = hash.key?('token') ? hash['token'] : SKIP
41
56
 
42
57
  # Create object from extracted values.
43
58
  AccountsParticipantsResponse.new(participant,
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # A participant object
8
8
  class Participant < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # Unique id of the participant
10
13
  # @return [String]
11
14
  attr_accessor :id
@@ -49,6 +52,26 @@ module Bandwidth
49
52
  @_hash
50
53
  end
51
54
 
55
+ # An array for optional fields
56
+ def optionals
57
+ %w[
58
+ id
59
+ callback_url
60
+ publish_permissions
61
+ sessions
62
+ subscriptions
63
+ tag
64
+ device_api_version
65
+ ]
66
+ end
67
+
68
+ # An array for nullable fields
69
+ def nullables
70
+ %w[
71
+ callback_url
72
+ ]
73
+ end
74
+
52
75
  def initialize(id = nil,
53
76
  callback_url = nil,
54
77
  publish_permissions = nil,
@@ -56,13 +79,13 @@ module Bandwidth
56
79
  subscriptions = nil,
57
80
  tag = nil,
58
81
  device_api_version = DeviceApiVersionEnum::V2)
59
- @id = id
60
- @callback_url = callback_url
61
- @publish_permissions = publish_permissions
62
- @sessions = sessions
63
- @subscriptions = subscriptions
64
- @tag = tag
65
- @device_api_version = device_api_version
82
+ @id = id unless id == SKIP
83
+ @callback_url = callback_url unless callback_url == SKIP
84
+ @publish_permissions = publish_permissions unless publish_permissions == SKIP
85
+ @sessions = sessions unless sessions == SKIP
86
+ @subscriptions = subscriptions unless subscriptions == SKIP
87
+ @tag = tag unless tag == SKIP
88
+ @device_api_version = device_api_version unless device_api_version == SKIP
66
89
  end
67
90
 
68
91
  # Creates an instance of the object from a hash.
@@ -70,13 +93,13 @@ module Bandwidth
70
93
  return nil unless hash
71
94
 
72
95
  # Extract variables from the hash.
73
- id = hash['id']
74
- callback_url = hash['callbackUrl']
75
- publish_permissions = hash['publishPermissions']
76
- sessions = hash['sessions']
77
- subscriptions = Subscriptions.from_hash(hash['subscriptions']) if
78
- hash['subscriptions']
79
- tag = hash['tag']
96
+ id = hash.key?('id') ? hash['id'] : SKIP
97
+ callback_url = hash.key?('callbackUrl') ? hash['callbackUrl'] : SKIP
98
+ publish_permissions =
99
+ hash.key?('publishPermissions') ? hash['publishPermissions'] : SKIP
100
+ sessions = hash.key?('sessions') ? hash['sessions'] : SKIP
101
+ subscriptions = Subscriptions.from_hash(hash['subscriptions']) if hash['subscriptions']
102
+ tag = hash.key?('tag') ? hash['tag'] : SKIP
80
103
  device_api_version = hash['deviceApiVersion'] ||= DeviceApiVersionEnum::V2
81
104
 
82
105
  # Create object from extracted values.