bandwidth-sdk 7.0.0 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -0
  3. data/lib/bandwidth/api_helper.rb +19 -17
  4. data/lib/bandwidth/configuration.rb +7 -19
  5. data/lib/bandwidth/http/faraday_client.rb +1 -1
  6. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +53 -42
  7. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
  8. data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
  9. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
  10. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
  11. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +65 -32
  12. data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
  13. data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
  14. data/lib/bandwidth/messaging_lib/messaging/models/media.rb +23 -6
  15. data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
  16. data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
  17. data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
  18. data/lib/bandwidth/models/base_model.rb +11 -0
  19. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/base_controller.rb +3 -5
  20. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/controllers/mfa_controller.rb +21 -16
  21. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/error_with_request_exception.rb +5 -2
  22. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/forbidden_request_exception.rb +4 -1
  23. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/exceptions/unauthorized_request_exception.rb +4 -1
  24. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_code_request_schema.rb +27 -12
  25. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_messaging_response.rb +17 -2
  26. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_code_response.rb +17 -2
  27. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_verify_request_schema.rb +29 -10
  28. data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth/models/two_factor_voice_response.rb +17 -2
  29. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
  30. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
  31. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
  32. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
  33. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
  34. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
  35. data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
  36. data/lib/bandwidth/utilities/date_time_helper.rb +2 -2
  37. data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
  38. data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +2 -1
  39. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +171 -150
  40. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
  41. data/lib/bandwidth/voice_lib/voice/exceptions/api_error_exception.rb +6 -3
  42. data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
  43. data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +78 -37
  44. data/lib/bandwidth/voice_lib/voice/models/call_state.rb +94 -42
  45. data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
  46. data/lib/bandwidth/voice_lib/voice/models/conference_member_state.rb +35 -12
  47. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +55 -24
  48. data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +54 -17
  49. data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +173 -96
  50. data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +85 -41
  51. data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
  52. data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
  53. data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
  54. data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
  55. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_request.rb +15 -2
  56. data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +59 -19
  57. data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +55 -18
  58. data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +40 -12
  59. data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
  60. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +80 -0
  61. data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +26 -8
  62. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
  63. data/lib/bandwidth/voice_lib/voice.rb +7 -1
  64. data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +61 -50
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
  67. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
  68. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
  69. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
  70. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
  71. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
  72. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
  73. data/lib/bandwidth.rb +19 -18
  74. data/test/integration/test_integration.rb +95 -58
  75. metadata +10 -3
@@ -11,7 +11,8 @@ module MultiFactorAuth
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # Allows a user to send a MFA code through a phone call
14
+ # Multi-Factor authentication with Bandwidth Voice services. Allows for a
15
+ # user to send an MFA code via a phone call.
15
16
  # @param [String] account_id Required parameter: Bandwidth Account ID with
16
17
  # Voice service enabled
17
18
  # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
@@ -43,22 +44,23 @@ module MultiFactorAuth
43
44
  _response = execute_request(_request)
44
45
 
45
46
  # Validate response against endpoint and global error codes.
46
- if _response.status_code == 400
47
+ case _response.status_code
48
+ when 400
47
49
  raise ErrorWithRequestException.new(
48
50
  'If there is any issue with values passed in by the user',
49
51
  _response
50
52
  )
51
- elsif _response.status_code == 401
53
+ when 401
52
54
  raise UnauthorizedRequestException.new(
53
55
  'Authentication is either incorrect or not present',
54
56
  _response
55
57
  )
56
- elsif _response.status_code == 403
58
+ when 403
57
59
  raise ForbiddenRequestException.new(
58
60
  'The user is not authorized to access this resource',
59
61
  _response
60
62
  )
61
- elsif _response.status_code == 500
63
+ when 500
62
64
  raise ErrorWithRequestException.new(
63
65
  'An internal server error occurred',
64
66
  _response
@@ -73,7 +75,8 @@ module MultiFactorAuth
73
75
  )
74
76
  end
75
77
 
76
- # Allows a user to send a MFA code through a text message (SMS)
78
+ # Multi-Factor authentication with Bandwidth Messaging services. Allows a
79
+ # user to send an MFA code via a text message (SMS).
77
80
  # @param [String] account_id Required parameter: Bandwidth Account ID with
78
81
  # Messaging service enabled
79
82
  # @param [TwoFactorCodeRequestSchema] body Required parameter: Example:
@@ -105,22 +108,23 @@ module MultiFactorAuth
105
108
  _response = execute_request(_request)
106
109
 
107
110
  # Validate response against endpoint and global error codes.
108
- if _response.status_code == 400
111
+ case _response.status_code
112
+ when 400
109
113
  raise ErrorWithRequestException.new(
110
114
  'If there is any issue with values passed in by the user',
111
115
  _response
112
116
  )
113
- elsif _response.status_code == 401
117
+ when 401
114
118
  raise UnauthorizedRequestException.new(
115
119
  'Authentication is either incorrect or not present',
116
120
  _response
117
121
  )
118
- elsif _response.status_code == 403
122
+ when 403
119
123
  raise ForbiddenRequestException.new(
120
124
  'The user is not authorized to access this resource',
121
125
  _response
122
126
  )
123
- elsif _response.status_code == 500
127
+ when 500
124
128
  raise ErrorWithRequestException.new(
125
129
  'An internal server error occurred',
126
130
  _response
@@ -136,7 +140,7 @@ module MultiFactorAuth
136
140
  )
137
141
  end
138
142
 
139
- # Allows a user to verify an MFA code
143
+ # Allows a user to verify an MFA code.
140
144
  # @param [String] account_id Required parameter: Bandwidth Account ID with
141
145
  # Two-Factor enabled
142
146
  # @param [TwoFactorVerifyRequestSchema] body Required parameter: Example:
@@ -168,28 +172,29 @@ module MultiFactorAuth
168
172
  _response = execute_request(_request)
169
173
 
170
174
  # Validate response against endpoint and global error codes.
171
- if _response.status_code == 400
175
+ case _response.status_code
176
+ when 400
172
177
  raise ErrorWithRequestException.new(
173
178
  'If there is any issue with values passed in by the user',
174
179
  _response
175
180
  )
176
- elsif _response.status_code == 401
181
+ when 401
177
182
  raise UnauthorizedRequestException.new(
178
183
  'Authentication is either incorrect or not present',
179
184
  _response
180
185
  )
181
- elsif _response.status_code == 403
186
+ when 403
182
187
  raise ForbiddenRequestException.new(
183
188
  'The user is not authorized to access this resource',
184
189
  _response
185
190
  )
186
- elsif _response.status_code == 429
191
+ when 429
187
192
  raise ErrorWithRequestException.new(
188
193
  'The user has made too many bad requests and is temporarily locked' \
189
194
  ' out',
190
195
  _response
191
196
  )
192
- elsif _response.status_code == 500
197
+ when 500
193
198
  raise ErrorWithRequestException.new(
194
199
  'An internal server error occurred',
195
200
  _response
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # ErrorWithRequest class.
8
8
  class ErrorWithRequestException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # An error message pertaining to what the issue could be
10
13
  # @return [String]
11
14
  attr_accessor :error
@@ -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
- @error = hash['error']
31
- @request_id = hash['requestId']
33
+ @error = hash.key?('error') ? hash['error'] : SKIP
34
+ @request_id = hash.key?('requestId') ? hash['requestId'] : SKIP
32
35
  end
33
36
  end
34
37
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # ForbiddenRequest class.
8
8
  class ForbiddenRequestException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # The message containing the reason behind the request being forbidden
10
13
  # @return [String]
11
14
  attr_accessor :message
@@ -23,7 +26,7 @@ module Bandwidth
23
26
  # @param [Hash] The deserialized response sent by the server in the
24
27
  # response body.
25
28
  def unbox(hash)
26
- @message = hash['Message']
29
+ @message = hash.key?('Message') ? hash['Message'] : SKIP
27
30
  end
28
31
  end
29
32
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # UnauthorizedRequest class.
8
8
  class UnauthorizedRequestException < APIException
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # The message containing the reason behind the request being unauthorized
10
13
  # @return [String]
11
14
  attr_accessor :message
@@ -23,7 +26,7 @@ module Bandwidth
23
26
  # @param [Hash] The deserialized response sent by the server in the
24
27
  # response body.
25
28
  def unbox(hash)
26
- @message = hash['message']
29
+ @message = hash.key?('message') ? hash['message'] : SKIP
27
30
  end
28
31
  end
29
32
  end
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TwoFactorCodeRequestSchema Model.
8
8
  class TwoFactorCodeRequestSchema < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # The phone number to send the 2fa code to.
10
13
  # @return [String]
11
14
  attr_accessor :to
@@ -50,18 +53,30 @@ module Bandwidth
50
53
  @_hash
51
54
  end
52
55
 
56
+ # An array for optional fields
57
+ def optionals
58
+ %w[
59
+ scope
60
+ ]
61
+ end
62
+
63
+ # An array for nullable fields
64
+ def nullables
65
+ []
66
+ end
67
+
53
68
  def initialize(to = nil,
54
69
  from = nil,
55
70
  application_id = nil,
56
71
  message = nil,
57
72
  digits = nil,
58
73
  scope = nil)
59
- @to = to
60
- @from = from
61
- @application_id = application_id
62
- @scope = scope
63
- @message = message
64
- @digits = digits
74
+ @to = to unless to == SKIP
75
+ @from = from unless from == SKIP
76
+ @application_id = application_id unless application_id == SKIP
77
+ @scope = scope unless scope == SKIP
78
+ @message = message unless message == SKIP
79
+ @digits = digits unless digits == SKIP
65
80
  end
66
81
 
67
82
  # Creates an instance of the object from a hash.
@@ -69,12 +84,12 @@ module Bandwidth
69
84
  return nil unless hash
70
85
 
71
86
  # Extract variables from the hash.
72
- to = hash['to']
73
- from = hash['from']
74
- application_id = hash['applicationId']
75
- message = hash['message']
76
- digits = hash['digits']
77
- scope = hash['scope']
87
+ to = hash.key?('to') ? hash['to'] : SKIP
88
+ from = hash.key?('from') ? hash['from'] : SKIP
89
+ application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP
90
+ message = hash.key?('message') ? hash['message'] : SKIP
91
+ digits = hash.key?('digits') ? hash['digits'] : SKIP
92
+ scope = hash.key?('scope') ? hash['scope'] : SKIP
78
93
 
79
94
  # Create object from extracted values.
80
95
  TwoFactorCodeRequestSchema.new(to,
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TwoFactorMessagingResponse Model.
8
8
  class TwoFactorMessagingResponse < 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 :message_id
@@ -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
+ message_id
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def nullables
32
+ []
33
+ end
34
+
20
35
  def initialize(message_id = nil)
21
- @message_id = message_id
36
+ @message_id = message_id unless message_id == SKIP
22
37
  end
23
38
 
24
39
  # Creates an instance of the object from a hash.
@@ -26,7 +41,7 @@ module Bandwidth
26
41
  return nil unless hash
27
42
 
28
43
  # Extract variables from the hash.
29
- message_id = hash['messageId']
44
+ message_id = hash.key?('messageId') ? hash['messageId'] : SKIP
30
45
 
31
46
  # Create object from extracted values.
32
47
  TwoFactorMessagingResponse.new(message_id)
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TwoFactorVerifyCodeResponse Model.
8
8
  class TwoFactorVerifyCodeResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # TODO: Write general description for this method
10
13
  # @return [Boolean]
11
14
  attr_accessor :valid
@@ -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
+ valid
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def nullables
32
+ []
33
+ end
34
+
20
35
  def initialize(valid = nil)
21
- @valid = valid
36
+ @valid = valid unless valid == SKIP
22
37
  end
23
38
 
24
39
  # Creates an instance of the object from a hash.
@@ -26,7 +41,7 @@ module Bandwidth
26
41
  return nil unless hash
27
42
 
28
43
  # Extract variables from the hash.
29
- valid = hash['valid']
44
+ valid = hash.key?('valid') ? hash['valid'] : SKIP
30
45
 
31
46
  # Create object from extracted values.
32
47
  TwoFactorVerifyCodeResponse.new(valid)
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TwoFactorVerifyRequestSchema Model.
8
8
  class TwoFactorVerifyRequestSchema < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
9
12
  # The phone number to send the 2fa code to.
10
13
  # @return [String]
11
14
  attr_accessor :to
@@ -41,16 +44,31 @@ module Bandwidth
41
44
  @_hash
42
45
  end
43
46
 
47
+ # An array for optional fields
48
+ def optionals
49
+ %w[
50
+ scope
51
+ ]
52
+ end
53
+
54
+ # An array for nullable fields
55
+ def nullables
56
+ []
57
+ end
58
+
44
59
  def initialize(to = nil,
45
60
  application_id = nil,
46
61
  expiration_time_in_minutes = nil,
47
62
  code = nil,
48
63
  scope = nil)
49
- @to = to
50
- @application_id = application_id
51
- @scope = scope
52
- @expiration_time_in_minutes = expiration_time_in_minutes
53
- @code = code
64
+ @to = to unless to == SKIP
65
+ @application_id = application_id unless application_id == SKIP
66
+ @scope = scope unless scope == SKIP
67
+ unless expiration_time_in_minutes == SKIP
68
+ @expiration_time_in_minutes =
69
+ expiration_time_in_minutes
70
+ end
71
+ @code = code unless code == SKIP
54
72
  end
55
73
 
56
74
  # Creates an instance of the object from a hash.
@@ -58,11 +76,12 @@ module Bandwidth
58
76
  return nil unless hash
59
77
 
60
78
  # Extract variables from the hash.
61
- to = hash['to']
62
- application_id = hash['applicationId']
63
- expiration_time_in_minutes = hash['expirationTimeInMinutes']
64
- code = hash['code']
65
- scope = hash['scope']
79
+ to = hash.key?('to') ? hash['to'] : SKIP
80
+ application_id = hash.key?('applicationId') ? hash['applicationId'] : SKIP
81
+ expiration_time_in_minutes =
82
+ hash.key?('expirationTimeInMinutes') ? hash['expirationTimeInMinutes'] : SKIP
83
+ code = hash.key?('code') ? hash['code'] : SKIP
84
+ scope = hash.key?('scope') ? hash['scope'] : SKIP
66
85
 
67
86
  # Create object from extracted values.
68
87
  TwoFactorVerifyRequestSchema.new(to,
@@ -6,6 +6,9 @@
6
6
  module Bandwidth
7
7
  # TwoFactorVoiceResponse Model.
8
8
  class TwoFactorVoiceResponse < 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 :call_id
@@ -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
+ call_id
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def nullables
32
+ []
33
+ end
34
+
20
35
  def initialize(call_id = nil)
21
- @call_id = call_id
36
+ @call_id = call_id unless call_id == SKIP
22
37
  end
23
38
 
24
39
  # Creates an instance of the object from a hash.
@@ -26,7 +41,7 @@ module Bandwidth
26
41
  return nil unless hash
27
42
 
28
43
  # Extract variables from the hash.
29
- call_id = hash['callId']
44
+ call_id = hash.key?('callId') ? hash['callId'] : SKIP
30
45
 
31
46
  # Create object from extracted values.
32
47
  TwoFactorVoiceResponse.new(call_id)