bandwidth-sdk 2.2.2 → 3.4.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 (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth.rb +2 -1
  3. data/lib/bandwidth/client.rb +9 -0
  4. data/lib/bandwidth/configuration.rb +22 -4
  5. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  6. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +4 -0
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +30 -83
  9. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  10. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  11. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +19 -0
  12. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +44 -0
  13. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +129 -0
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +62 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +71 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  20. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  21. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  22. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +2 -1
  23. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  24. data/lib/bandwidth/voice_lib/voice.rb +2 -0
  25. data/lib/bandwidth/voice_lib/voice/client.rb +4 -0
  26. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +145 -78
  27. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  28. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  29. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  30. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
  31. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
  32. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
  33. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  34. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
  35. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
  36. metadata +18 -7
  37. data/lib/bandwidth/messaging_lib/messaging/exceptions/path_client_exception.rb +0 -49
  38. data/lib/bandwidth/messaging_lib/messaging/models/field_error.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a0d3a06b7e019a1602f4a796f096c7ac408e66395b10ff9088f26393c028acf
4
- data.tar.gz: 67d9cfdf43befba134e4dabc3abddc1317821db91d0ac18c9d2a92456da270d8
3
+ metadata.gz: 7589bdf9914178c33cc9928e5ef7aa125787264250cc0dbe94de6ebd9cc4c728
4
+ data.tar.gz: 19fe33d12e403fe6d0528591d8a5e9ad4a631b4bb4707f8f9f75de110e21ce04
5
5
  SHA512:
6
- metadata.gz: 94fef92c336e12b4c6bcfc29b51048fbd5f00493ce1868c4baaf539f58f89b5024bc65bc8426aac36eae1c0c04930234e4ed57878bd7d049a719a6b8c96f05e9
7
- data.tar.gz: 5d058ccd30dc7b4efa01397d346247a75d81101da1e981d011f00ec437c1e7d12e97651462111861880135e7c56e776a369a11fd7c6b90712038645dbf19f5b3
6
+ metadata.gz: 4729d4bfc676472e949007c92b09b07dae9d14c6c1376e70980eb9455d666620984eb089a02d17105f8dde864579a633136fa47a77beb3a43f8a3a42ee0844e9
7
+ data.tar.gz: dd15b63a5fb1cb3b6b23d1a912d5f7878c37fd9375f08eee00d190ca6ce9f95e05c67b7aa30adabb9aa77883bfeb652174aa6b1d6eedbba4d7c9cdc44d22d7ee
@@ -35,8 +35,9 @@ require_relative 'bandwidth/configuration.rb'
35
35
  # Namespaces
36
36
  require_relative 'bandwidth/messaging_lib/messaging'
37
37
  require_relative 'bandwidth/http/auth/messaging_basic_auth.rb'
38
+ require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
39
+ require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
38
40
  require_relative 'bandwidth/voice_lib/voice'
39
41
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
40
42
 
41
-
42
43
  # Controllers
@@ -12,6 +12,11 @@ module Bandwidth
12
12
  def messaging_client
13
13
  @messaging_client ||= Messaging::Client.new(config: config)
14
14
  end
15
+ # Access to two_factor_auth_client controller.
16
+ # @return [TwoFactorAuth::Client] Returns the client instance.
17
+ def two_factor_auth_client
18
+ @two_factor_auth_client ||= TwoFactorAuth::Client.new(config: config)
19
+ end
15
20
  # Access to voice_client controller.
16
21
  # @return [Voice::Client] Returns the client instance.
17
22
  def voice_client
@@ -22,6 +27,8 @@ module Bandwidth
22
27
  backoff_factor: 1, environment: Environment::PRODUCTION,
23
28
  messaging_basic_auth_user_name: 'TODO: Replace',
24
29
  messaging_basic_auth_password: 'TODO: Replace',
30
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
31
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
25
32
  voice_basic_auth_user_name: 'TODO: Replace',
26
33
  voice_basic_auth_password: 'TODO: Replace', config: nil)
27
34
  @config = if config.nil?
@@ -31,6 +38,8 @@ module Bandwidth
31
38
  environment: environment,
32
39
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
33
40
  messaging_basic_auth_password: messaging_basic_auth_password,
41
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
42
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
34
43
  voice_basic_auth_user_name: voice_basic_auth_user_name,
35
44
  voice_basic_auth_password: voice_basic_auth_password)
36
45
  else
@@ -16,6 +16,7 @@ module Bandwidth
16
16
  SERVER = [
17
17
  DEFAULT = 'default'.freeze,
18
18
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
19
+ TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
19
20
  VOICEDEFAULT = 'VoiceDefault'.freeze
20
21
  ].freeze
21
22
  end
@@ -32,6 +33,8 @@ module Bandwidth
32
33
  attr_reader :environment
33
34
  attr_reader :messaging_basic_auth_user_name
34
35
  attr_reader :messaging_basic_auth_password
36
+ attr_reader :two_factor_auth_basic_auth_user_name
37
+ attr_reader :two_factor_auth_basic_auth_password
35
38
  attr_reader :voice_basic_auth_user_name
36
39
  attr_reader :voice_basic_auth_password
37
40
 
@@ -43,6 +46,8 @@ module Bandwidth
43
46
  backoff_factor: 1, environment: Environment::PRODUCTION,
44
47
  messaging_basic_auth_user_name: 'TODO: Replace',
45
48
  messaging_basic_auth_password: 'TODO: Replace',
49
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
50
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
46
51
  voice_basic_auth_user_name: 'TODO: Replace',
47
52
  voice_basic_auth_password: 'TODO: Replace')
48
53
  # The value to use for connection timeout
@@ -59,7 +64,7 @@ module Bandwidth
59
64
  @backoff_factor = backoff_factor
60
65
 
61
66
  # Current API environment
62
- @environment = environment
67
+ @environment = String(environment)
63
68
 
64
69
  # The username to use with basic authentication
65
70
  @messaging_basic_auth_user_name = messaging_basic_auth_user_name
@@ -67,6 +72,12 @@ module Bandwidth
67
72
  # The password to use with basic authentication
68
73
  @messaging_basic_auth_password = messaging_basic_auth_password
69
74
 
75
+ # The username to use with basic authentication
76
+ @two_factor_auth_basic_auth_user_name = two_factor_auth_basic_auth_user_name
77
+
78
+ # The password to use with basic authentication
79
+ @two_factor_auth_basic_auth_password = two_factor_auth_basic_auth_password
80
+
70
81
  # The username to use with basic authentication
71
82
  @voice_basic_auth_user_name = voice_basic_auth_user_name
72
83
 
@@ -81,6 +92,8 @@ module Bandwidth
81
92
  backoff_factor: nil, environment: nil,
82
93
  messaging_basic_auth_user_name: nil,
83
94
  messaging_basic_auth_password: nil,
95
+ two_factor_auth_basic_auth_user_name: nil,
96
+ two_factor_auth_basic_auth_password: nil,
84
97
  voice_basic_auth_user_name: nil,
85
98
  voice_basic_auth_password: nil)
86
99
  timeout ||= self.timeout
@@ -90,6 +103,8 @@ module Bandwidth
90
103
  environment ||= self.environment
91
104
  messaging_basic_auth_user_name ||= self.messaging_basic_auth_user_name
92
105
  messaging_basic_auth_password ||= self.messaging_basic_auth_password
106
+ two_factor_auth_basic_auth_user_name ||= self.two_factor_auth_basic_auth_user_name
107
+ two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
93
108
  voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
94
109
  voice_basic_auth_password ||= self.voice_basic_auth_password
95
110
 
@@ -99,6 +114,8 @@ module Bandwidth
99
114
  environment: environment,
100
115
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
101
116
  messaging_basic_auth_password: messaging_basic_auth_password,
117
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
118
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
102
119
  voice_basic_auth_user_name: voice_basic_auth_user_name,
103
120
  voice_basic_auth_password: voice_basic_auth_password
104
121
  )
@@ -111,20 +128,21 @@ module Bandwidth
111
128
  end
112
129
 
113
130
  # All the environments the SDK can run in.
114
- @environments = {
131
+ ENVIRONMENTS = {
115
132
  Environment::PRODUCTION => {
116
133
  Server::DEFAULT => 'api.bandwidth.com',
117
134
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
135
+ Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
118
136
  Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
119
137
  }
120
- }
138
+ }.freeze
121
139
 
122
140
  # Generates the appropriate base URI for the environment and the server.
123
141
  # @param [Configuration::Server] The server enum for which the base URI is
124
142
  # required.
125
143
  # @return [String] The base URI.
126
144
  def get_base_uri(server = Server::DEFAULT)
127
- self.class.environments[environment][server].clone
145
+ ENVIRONMENTS[environment][server].clone
128
146
  end
129
147
  end
130
148
  end
@@ -0,0 +1,22 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'base64'
7
+
8
+ module Bandwidth
9
+ # Utility class for basic authorization.
10
+ class TwoFactorAuthBasicAuth
11
+ # Add basic authentication to the request.
12
+ # @param [HttpRequest] The HttpRequest object to which authentication will
13
+ # be added.
14
+ def self.apply(config, http_request)
15
+ username = config.two_factor_auth_basic_auth_user_name
16
+ password = config.two_factor_auth_basic_auth_password
17
+ value = Base64.strict_encode64("#{username}:#{password}")
18
+ header_value = "Basic #{value}"
19
+ http_request.headers['Authorization'] = header_value
20
+ end
21
+ end
22
+ end
@@ -7,7 +7,6 @@
7
7
  require_relative 'messaging/client.rb'
8
8
 
9
9
  # Models
10
- require_relative 'messaging/models/field_error.rb'
11
10
  require_relative 'messaging/models/media.rb'
12
11
  require_relative 'messaging/models/tag.rb'
13
12
  require_relative 'messaging/models/deferred_result.rb'
@@ -16,8 +15,7 @@ require_relative 'messaging/models/bandwidth_message.rb'
16
15
  require_relative 'messaging/models/message_request.rb'
17
16
 
18
17
  # Exceptions
19
- require_relative 'messaging/exceptions/generic_client_exception.rb'
20
- require_relative 'messaging/exceptions/path_client_exception.rb'
18
+ require_relative 'messaging/exceptions/messaging_exception.rb'
21
19
  # Controllers
22
20
  require_relative 'messaging/controllers/base_controller.rb'
23
21
  require_relative 'messaging/controllers/api_controller.rb'
@@ -19,6 +19,8 @@ module Bandwidth
19
19
  backoff_factor: 1, environment: Environment::PRODUCTION,
20
20
  messaging_basic_auth_user_name: 'TODO: Replace',
21
21
  messaging_basic_auth_password: 'TODO: Replace',
22
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
22
24
  voice_basic_auth_user_name: 'TODO: Replace',
23
25
  voice_basic_auth_password: 'TODO: Replace', config: nil)
24
26
  @config = if config.nil?
@@ -29,6 +31,8 @@ module Bandwidth
29
31
  environment: environment,
30
32
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
31
33
  messaging_basic_auth_password: messaging_basic_auth_password,
34
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
35
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
32
36
  voice_basic_auth_user_name: voice_basic_auth_user_name,
33
37
  voice_basic_auth_password: voice_basic_auth_password)
34
38
  else
@@ -11,59 +11,6 @@ module Messaging
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # getMessage
15
- # @return [void] response from the API call
16
- def get_message
17
- # Prepare query url.
18
- _query_builder = config.get_base_uri(Server::MESSAGINGDEFAULT)
19
- _query_builder << '/ping'
20
- _query_url = APIHelper.clean_url _query_builder
21
-
22
- # Prepare and execute HttpRequest.
23
- _request = config.http_client.get(
24
- _query_url
25
- )
26
- MessagingBasicAuth.apply(config, _request)
27
- _response = execute_request(_request)
28
-
29
- # Validate response against endpoint and global error codes.
30
- if _response.status_code == 400
31
- raise GenericClientException.new(
32
- '400 Request is malformed or invalid',
33
- _response
34
- )
35
- elsif _response.status_code == 401
36
- raise PathClientException.new(
37
- '401 The specified user does not have access to the account',
38
- _response
39
- )
40
- elsif _response.status_code == 403
41
- raise PathClientException.new(
42
- '403 The user does not have access to this API',
43
- _response
44
- )
45
- elsif _response.status_code == 404
46
- raise PathClientException.new(
47
- '404 Path not found',
48
- _response
49
- )
50
- elsif _response.status_code == 415
51
- raise GenericClientException.new(
52
- '415 The content-type of the request is incorrect',
53
- _response
54
- )
55
- elsif _response.status_code == 429
56
- raise GenericClientException.new(
57
- '429 The rate limit has been reached',
58
- _response
59
- )
60
- end
61
- validate_response(_response)
62
-
63
- # Return appropriate response type.
64
- ApiResponse.new(_response)
65
- end
66
-
67
14
  # listMedia
68
15
  # @param [String] user_id Required parameter: Example:
69
16
  # @param [String] continuation_token Optional parameter: Example:
@@ -95,32 +42,32 @@ module Messaging
95
42
 
96
43
  # Validate response against endpoint and global error codes.
97
44
  if _response.status_code == 400
98
- raise GenericClientException.new(
45
+ raise MessagingException.new(
99
46
  '400 Request is malformed or invalid',
100
47
  _response
101
48
  )
102
49
  elsif _response.status_code == 401
103
- raise PathClientException.new(
50
+ raise MessagingException.new(
104
51
  '401 The specified user does not have access to the account',
105
52
  _response
106
53
  )
107
54
  elsif _response.status_code == 403
108
- raise PathClientException.new(
55
+ raise MessagingException.new(
109
56
  '403 The user does not have access to this API',
110
57
  _response
111
58
  )
112
59
  elsif _response.status_code == 404
113
- raise PathClientException.new(
60
+ raise MessagingException.new(
114
61
  '404 Path not found',
115
62
  _response
116
63
  )
117
64
  elsif _response.status_code == 415
118
- raise GenericClientException.new(
65
+ raise MessagingException.new(
119
66
  '415 The content-type of the request is incorrect',
120
67
  _response
121
68
  )
122
69
  elsif _response.status_code == 429
123
- raise GenericClientException.new(
70
+ raise MessagingException.new(
124
71
  '429 The rate limit has been reached',
125
72
  _response
126
73
  )
@@ -158,32 +105,32 @@ module Messaging
158
105
 
159
106
  # Validate response against endpoint and global error codes.
160
107
  if _response.status_code == 400
161
- raise GenericClientException.new(
108
+ raise MessagingException.new(
162
109
  '400 Request is malformed or invalid',
163
110
  _response
164
111
  )
165
112
  elsif _response.status_code == 401
166
- raise PathClientException.new(
113
+ raise MessagingException.new(
167
114
  '401 The specified user does not have access to the account',
168
115
  _response
169
116
  )
170
117
  elsif _response.status_code == 403
171
- raise PathClientException.new(
118
+ raise MessagingException.new(
172
119
  '403 The user does not have access to this API',
173
120
  _response
174
121
  )
175
122
  elsif _response.status_code == 404
176
- raise PathClientException.new(
123
+ raise MessagingException.new(
177
124
  '404 Path not found',
178
125
  _response
179
126
  )
180
127
  elsif _response.status_code == 415
181
- raise GenericClientException.new(
128
+ raise MessagingException.new(
182
129
  '415 The content-type of the request is incorrect',
183
130
  _response
184
131
  )
185
132
  elsif _response.status_code == 429
186
- raise GenericClientException.new(
133
+ raise MessagingException.new(
187
134
  '429 The rate limit has been reached',
188
135
  _response
189
136
  )
@@ -246,32 +193,32 @@ module Messaging
246
193
 
247
194
  # Validate response against endpoint and global error codes.
248
195
  if _response.status_code == 400
249
- raise GenericClientException.new(
196
+ raise MessagingException.new(
250
197
  '400 Request is malformed or invalid',
251
198
  _response
252
199
  )
253
200
  elsif _response.status_code == 401
254
- raise PathClientException.new(
201
+ raise MessagingException.new(
255
202
  '401 The specified user does not have access to the account',
256
203
  _response
257
204
  )
258
205
  elsif _response.status_code == 403
259
- raise PathClientException.new(
206
+ raise MessagingException.new(
260
207
  '403 The user does not have access to this API',
261
208
  _response
262
209
  )
263
210
  elsif _response.status_code == 404
264
- raise PathClientException.new(
211
+ raise MessagingException.new(
265
212
  '404 Path not found',
266
213
  _response
267
214
  )
268
215
  elsif _response.status_code == 415
269
- raise GenericClientException.new(
216
+ raise MessagingException.new(
270
217
  '415 The content-type of the request is incorrect',
271
218
  _response
272
219
  )
273
220
  elsif _response.status_code == 429
274
- raise GenericClientException.new(
221
+ raise MessagingException.new(
275
222
  '429 The rate limit has been reached',
276
223
  _response
277
224
  )
@@ -307,32 +254,32 @@ module Messaging
307
254
 
308
255
  # Validate response against endpoint and global error codes.
309
256
  if _response.status_code == 400
310
- raise GenericClientException.new(
257
+ raise MessagingException.new(
311
258
  '400 Request is malformed or invalid',
312
259
  _response
313
260
  )
314
261
  elsif _response.status_code == 401
315
- raise PathClientException.new(
262
+ raise MessagingException.new(
316
263
  '401 The specified user does not have access to the account',
317
264
  _response
318
265
  )
319
266
  elsif _response.status_code == 403
320
- raise PathClientException.new(
267
+ raise MessagingException.new(
321
268
  '403 The user does not have access to this API',
322
269
  _response
323
270
  )
324
271
  elsif _response.status_code == 404
325
- raise PathClientException.new(
272
+ raise MessagingException.new(
326
273
  '404 Path not found',
327
274
  _response
328
275
  )
329
276
  elsif _response.status_code == 415
330
- raise GenericClientException.new(
277
+ raise MessagingException.new(
331
278
  '415 The content-type of the request is incorrect',
332
279
  _response
333
280
  )
334
281
  elsif _response.status_code == 429
335
- raise GenericClientException.new(
282
+ raise MessagingException.new(
336
283
  '429 The rate limit has been reached',
337
284
  _response
338
285
  )
@@ -375,32 +322,32 @@ module Messaging
375
322
 
376
323
  # Validate response against endpoint and global error codes.
377
324
  if _response.status_code == 400
378
- raise GenericClientException.new(
325
+ raise MessagingException.new(
379
326
  '400 Request is malformed or invalid',
380
327
  _response
381
328
  )
382
329
  elsif _response.status_code == 401
383
- raise PathClientException.new(
330
+ raise MessagingException.new(
384
331
  '401 The specified user does not have access to the account',
385
332
  _response
386
333
  )
387
334
  elsif _response.status_code == 403
388
- raise PathClientException.new(
335
+ raise MessagingException.new(
389
336
  '403 The user does not have access to this API',
390
337
  _response
391
338
  )
392
339
  elsif _response.status_code == 404
393
- raise PathClientException.new(
340
+ raise MessagingException.new(
394
341
  '404 Path not found',
395
342
  _response
396
343
  )
397
344
  elsif _response.status_code == 415
398
- raise GenericClientException.new(
345
+ raise MessagingException.new(
399
346
  '415 The content-type of the request is incorrect',
400
347
  _response
401
348
  )
402
349
  elsif _response.status_code == 429
403
- raise GenericClientException.new(
350
+ raise MessagingException.new(
404
351
  '429 The rate limit has been reached',
405
352
  _response
406
353
  )