bandwidth-sdk 3.4.0 → 3.9.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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bandwidth.rb +2 -0
  3. data/lib/bandwidth/api_helper.rb +14 -9
  4. data/lib/bandwidth/client.rb +11 -2
  5. data/lib/bandwidth/configuration.rb +23 -5
  6. data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +7 -2
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +18 -12
  9. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  10. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +1 -0
  11. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +7 -2
  12. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +38 -9
  13. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +30 -4
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +33 -10
  17. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
  18. data/lib/bandwidth/voice_lib/voice.rb +6 -2
  19. data/lib/bandwidth/voice_lib/voice/client.rb +7 -2
  20. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +625 -55
  21. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  22. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +38 -2
  23. data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +105 -0
  24. data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +35 -0
  25. data/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +80 -0
  26. data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +125 -0
  27. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +27 -0
  28. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +4 -1
  29. data/lib/bandwidth/voice_lib/voice/models/{status2_enum.rb → status3_enum.rb} +3 -3
  30. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
  31. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
  32. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
  33. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +692 -0
  34. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
  35. data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +34 -0
  36. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
  37. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
  38. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
  39. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
  40. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
  41. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
  42. metadata +41 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7589bdf9914178c33cc9928e5ef7aa125787264250cc0dbe94de6ebd9cc4c728
4
- data.tar.gz: 19fe33d12e403fe6d0528591d8a5e9ad4a631b4bb4707f8f9f75de110e21ce04
3
+ metadata.gz: f60ebb7f84d08c70a63b5e3e0f66dbbba6ed9454e00eff7cd33b8b09ba0253b4
4
+ data.tar.gz: 3473820c95bb5b50f4b416f26aed89a3131e0641532499e75cf89879ef2f8e30
5
5
  SHA512:
6
- metadata.gz: 4729d4bfc676472e949007c92b09b07dae9d14c6c1376e70980eb9455d666620984eb089a02d17105f8dde864579a633136fa47a77beb3a43f8a3a42ee0844e9
7
- data.tar.gz: dd15b63a5fb1cb3b6b23d1a912d5f7878c37fd9375f08eee00d190ca6ce9f95e05c67b7aa30adabb9aa77883bfeb652174aa6b1d6eedbba4d7c9cdc44d22d7ee
6
+ metadata.gz: eb17e8c233e85ddf3a0f83e84e58117cb8cdcb16b5e18b6a13de2cecd7ec6bfe1e586dc0ff7187a6db861173a80f9bfcf3c41a9c239bb29c7abffb0e3d2670ba
7
+ data.tar.gz: 68d4877a6985d95bb3744fa7d321a3f9784c9237795a5a0e78a4899dc3afa73e3c09f568d235068e32c0d4bdc08231b873aa3a80b55ebbb4ffadfe09ef95afed
@@ -39,5 +39,7 @@ require_relative 'bandwidth/two_factor_auth_lib/two_factor_auth'
39
39
  require_relative 'bandwidth/http/auth/two_factor_auth_basic_auth.rb'
40
40
  require_relative 'bandwidth/voice_lib/voice'
41
41
  require_relative 'bandwidth/http/auth/voice_basic_auth.rb'
42
+ require_relative 'bandwidth/web_rtc_lib/web_rtc'
43
+ require_relative 'bandwidth/http/auth/web_rtc_basic_auth.rb'
42
44
 
43
45
  # Controllers
@@ -41,17 +41,22 @@ module Bandwidth
41
41
  # Return if there are no parameters to replace.
42
42
  return query_builder if parameters.nil?
43
43
 
44
- # Iterate and append parameters.
45
- parameters.each do |key, value|
46
- replace_value = ''
47
-
48
- if value.nil?
44
+ parameters.each do |key, val|
45
+ if val.nil?
49
46
  replace_value = ''
50
- elsif value.instance_of? Array
51
- value.map! { |element| CGI.escape(element.to_s) }
52
- replace_value = value.join('/')
47
+ elsif val['value'].instance_of? Array
48
+ if val['encode'] == true
49
+ val['value'].map! { |element| CGI.escape(element.to_s) }
50
+ else
51
+ val['value'].map!(&:to_s)
52
+ end
53
+ replace_value = val['value'].join('/')
53
54
  else
54
- replace_value = CGI.escape(value.to_s)
55
+ replace_value = if val['encode'] == true
56
+ CGI.escape(val['value'].to_s)
57
+ else
58
+ val['value'].to_s
59
+ end
55
60
  end
56
61
 
57
62
  # Find the template parameter and replace it with its value.
@@ -22,6 +22,11 @@ module Bandwidth
22
22
  def voice_client
23
23
  @voice_client ||= Voice::Client.new(config: config)
24
24
  end
25
+ # Access to web_rtc_client controller.
26
+ # @return [WebRtc::Client] Returns the client instance.
27
+ def web_rtc_client
28
+ @web_rtc_client ||= WebRtc::Client.new(config: config)
29
+ end
25
30
 
26
31
  def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
27
32
  backoff_factor: 1, environment: Environment::PRODUCTION,
@@ -30,7 +35,9 @@ module Bandwidth
30
35
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
31
36
  two_factor_auth_basic_auth_password: 'TODO: Replace',
32
37
  voice_basic_auth_user_name: 'TODO: Replace',
33
- voice_basic_auth_password: 'TODO: Replace', config: nil)
38
+ voice_basic_auth_password: 'TODO: Replace',
39
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
40
+ web_rtc_basic_auth_password: 'TODO: Replace', config: nil)
34
41
  @config = if config.nil?
35
42
  Configuration.new(timeout: timeout, max_retries: max_retries,
36
43
  retry_interval: retry_interval,
@@ -41,7 +48,9 @@ module Bandwidth
41
48
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
42
49
  two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
43
50
  voice_basic_auth_user_name: voice_basic_auth_user_name,
44
- voice_basic_auth_password: voice_basic_auth_password)
51
+ voice_basic_auth_password: voice_basic_auth_password,
52
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
53
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
45
54
  else
46
55
  config
47
56
  end
@@ -17,7 +17,8 @@ module Bandwidth
17
17
  DEFAULT = 'default'.freeze,
18
18
  MESSAGINGDEFAULT = 'MessagingDefault'.freeze,
19
19
  TWOFACTORAUTHDEFAULT = 'TwoFactorAuthDefault'.freeze,
20
- VOICEDEFAULT = 'VoiceDefault'.freeze
20
+ VOICEDEFAULT = 'VoiceDefault'.freeze,
21
+ WEBRTCDEFAULT = 'WebRtcDefault'.freeze
21
22
  ].freeze
22
23
  end
23
24
 
@@ -37,6 +38,8 @@ module Bandwidth
37
38
  attr_reader :two_factor_auth_basic_auth_password
38
39
  attr_reader :voice_basic_auth_user_name
39
40
  attr_reader :voice_basic_auth_password
41
+ attr_reader :web_rtc_basic_auth_user_name
42
+ attr_reader :web_rtc_basic_auth_password
40
43
 
41
44
  class << self
42
45
  attr_reader :environments
@@ -49,7 +52,9 @@ module Bandwidth
49
52
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
50
53
  two_factor_auth_basic_auth_password: 'TODO: Replace',
51
54
  voice_basic_auth_user_name: 'TODO: Replace',
52
- voice_basic_auth_password: 'TODO: Replace')
55
+ voice_basic_auth_password: 'TODO: Replace',
56
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
57
+ web_rtc_basic_auth_password: 'TODO: Replace')
53
58
  # The value to use for connection timeout
54
59
  @timeout = timeout
55
60
 
@@ -84,6 +89,12 @@ module Bandwidth
84
89
  # The password to use with basic authentication
85
90
  @voice_basic_auth_password = voice_basic_auth_password
86
91
 
92
+ # The username to use with basic authentication
93
+ @web_rtc_basic_auth_user_name = web_rtc_basic_auth_user_name
94
+
95
+ # The password to use with basic authentication
96
+ @web_rtc_basic_auth_password = web_rtc_basic_auth_password
97
+
87
98
  # The Http Client to use for making requests.
88
99
  @http_client = create_http_client
89
100
  end
@@ -95,7 +106,9 @@ module Bandwidth
95
106
  two_factor_auth_basic_auth_user_name: nil,
96
107
  two_factor_auth_basic_auth_password: nil,
97
108
  voice_basic_auth_user_name: nil,
98
- voice_basic_auth_password: nil)
109
+ voice_basic_auth_password: nil,
110
+ web_rtc_basic_auth_user_name: nil,
111
+ web_rtc_basic_auth_password: nil)
99
112
  timeout ||= self.timeout
100
113
  max_retries ||= self.max_retries
101
114
  retry_interval ||= self.retry_interval
@@ -107,6 +120,8 @@ module Bandwidth
107
120
  two_factor_auth_basic_auth_password ||= self.two_factor_auth_basic_auth_password
108
121
  voice_basic_auth_user_name ||= self.voice_basic_auth_user_name
109
122
  voice_basic_auth_password ||= self.voice_basic_auth_password
123
+ web_rtc_basic_auth_user_name ||= self.web_rtc_basic_auth_user_name
124
+ web_rtc_basic_auth_password ||= self.web_rtc_basic_auth_password
110
125
 
111
126
  Configuration.new(
112
127
  timeout: timeout, max_retries: max_retries,
@@ -117,7 +132,9 @@ module Bandwidth
117
132
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
118
133
  two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
119
134
  voice_basic_auth_user_name: voice_basic_auth_user_name,
120
- voice_basic_auth_password: voice_basic_auth_password
135
+ voice_basic_auth_password: voice_basic_auth_password,
136
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
137
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password
121
138
  )
122
139
  end
123
140
 
@@ -133,7 +150,8 @@ module Bandwidth
133
150
  Server::DEFAULT => 'api.bandwidth.com',
134
151
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
135
152
  Server::TWOFACTORAUTHDEFAULT => 'https://mfa.bandwidth.com/api/v1/',
136
- Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
153
+ Server::VOICEDEFAULT => 'https://voice.bandwidth.com',
154
+ Server::WEBRTCDEFAULT => 'https://api.webrtc.bandwidth.com/v1'
137
155
  }
138
156
  }.freeze
139
157
 
@@ -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 WebRtcBasicAuth
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.web_rtc_basic_auth_user_name
16
+ password = config.web_rtc_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
@@ -22,7 +22,10 @@ module Bandwidth
22
22
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
23
  two_factor_auth_basic_auth_password: 'TODO: Replace',
24
24
  voice_basic_auth_user_name: 'TODO: Replace',
25
- voice_basic_auth_password: 'TODO: Replace', config: nil)
25
+ voice_basic_auth_password: 'TODO: Replace',
26
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
27
+ web_rtc_basic_auth_password: 'TODO: Replace',
28
+ config: nil)
26
29
  @config = if config.nil?
27
30
  Configuration.new(timeout: timeout,
28
31
  max_retries: max_retries,
@@ -34,7 +37,9 @@ module Bandwidth
34
37
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
35
38
  two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
36
39
  voice_basic_auth_user_name: voice_basic_auth_user_name,
37
- voice_basic_auth_password: voice_basic_auth_password)
40
+ voice_basic_auth_password: voice_basic_auth_password,
41
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
42
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
38
43
  else
39
44
  config
40
45
  end
@@ -22,7 +22,7 @@ module Messaging
22
22
  _query_builder << '/users/{userId}/media'
23
23
  _query_builder = APIHelper.append_url_with_template_parameters(
24
24
  _query_builder,
25
- 'userId' => user_id
25
+ 'userId' => { 'value' => user_id, 'encode' => true }
26
26
  )
27
27
  _query_url = APIHelper.clean_url _query_builder
28
28
 
@@ -76,8 +76,10 @@ module Messaging
76
76
 
77
77
  # Return appropriate response type.
78
78
  decoded = APIHelper.json_deserialize(_response.raw_body)
79
- ApiResponse.new(_response,
80
- data: decoded.map { |element| Media.from_hash(element) })
79
+ ApiResponse.new(
80
+ _response,
81
+ data: decoded.map { |element| Media.from_hash(element) }
82
+ )
81
83
  end
82
84
 
83
85
  # getMedia
@@ -91,8 +93,8 @@ module Messaging
91
93
  _query_builder << '/users/{userId}/media/{mediaId}'
92
94
  _query_builder = APIHelper.append_url_with_template_parameters(
93
95
  _query_builder,
94
- 'userId' => user_id,
95
- 'mediaId' => media_id
96
+ 'userId' => { 'value' => user_id, 'encode' => true },
97
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
96
98
  )
97
99
  _query_url = APIHelper.clean_url _query_builder
98
100
 
@@ -138,7 +140,9 @@ module Messaging
138
140
  validate_response(_response)
139
141
 
140
142
  # Return appropriate response type.
141
- ApiResponse.new(_response, data: _response.raw_body)
143
+ ApiResponse.new(
144
+ _response, data: _response.raw_body
145
+ )
142
146
  end
143
147
 
144
148
  # uploadMedia
@@ -161,8 +165,8 @@ module Messaging
161
165
  _query_builder << '/users/{userId}/media/{mediaId}'
162
166
  _query_builder = APIHelper.append_url_with_template_parameters(
163
167
  _query_builder,
164
- 'userId' => user_id,
165
- 'mediaId' => media_id
168
+ 'userId' => { 'value' => user_id, 'encode' => true },
169
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
166
170
  )
167
171
  _query_url = APIHelper.clean_url _query_builder
168
172
 
@@ -240,8 +244,8 @@ module Messaging
240
244
  _query_builder << '/users/{userId}/media/{mediaId}'
241
245
  _query_builder = APIHelper.append_url_with_template_parameters(
242
246
  _query_builder,
243
- 'userId' => user_id,
244
- 'mediaId' => media_id
247
+ 'userId' => { 'value' => user_id, 'encode' => true },
248
+ 'mediaId' => { 'value' => media_id, 'encode' => true }
245
249
  )
246
250
  _query_url = APIHelper.clean_url _query_builder
247
251
 
@@ -301,7 +305,7 @@ module Messaging
301
305
  _query_builder << '/users/{userId}/messages'
302
306
  _query_builder = APIHelper.append_url_with_template_parameters(
303
307
  _query_builder,
304
- 'userId' => user_id
308
+ 'userId' => { 'value' => user_id, 'encode' => true }
305
309
  )
306
310
  _query_url = APIHelper.clean_url _query_builder
307
311
 
@@ -356,7 +360,9 @@ module Messaging
356
360
 
357
361
  # Return appropriate response type.
358
362
  decoded = APIHelper.json_deserialize(_response.raw_body)
359
- ApiResponse.new(_response, data: BandwidthMessage.from_hash(decoded))
363
+ ApiResponse.new(
364
+ _response, data: BandwidthMessage.from_hash(decoded)
365
+ )
360
366
  end
361
367
  end
362
368
  end
@@ -13,7 +13,7 @@ module Bandwidth
13
13
  @http_call_back = http_call_back
14
14
 
15
15
  @global_headers = {
16
- 'user-agent' => 'ruby-sdk-refs/tags/ruby3.4.0'
16
+ 'user-agent' => 'ruby-sdk-refs/tags/ruby3.9.0'
17
17
  }
18
18
  end
19
19
 
@@ -14,6 +14,7 @@ require_relative 'two_factor_auth/models/two_factor_verify_request_schema.rb'
14
14
  require_relative 'two_factor_auth/models/two_factor_verify_code_response.rb'
15
15
 
16
16
  # Exceptions
17
+ require_relative 'two_factor_auth/exceptions/invalid_request_exception.rb'
17
18
  # Controllers
18
19
  require_relative 'two_factor_auth/controllers/base_controller.rb'
19
20
  require_relative 'two_factor_auth/controllers/api_controller.rb'
@@ -22,7 +22,10 @@ module Bandwidth
22
22
  two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
23
  two_factor_auth_basic_auth_password: 'TODO: Replace',
24
24
  voice_basic_auth_user_name: 'TODO: Replace',
25
- voice_basic_auth_password: 'TODO: Replace', config: nil)
25
+ voice_basic_auth_password: 'TODO: Replace',
26
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
27
+ web_rtc_basic_auth_password: 'TODO: Replace',
28
+ config: nil)
26
29
  @config = if config.nil?
27
30
  Configuration.new(timeout: timeout,
28
31
  max_retries: max_retries,
@@ -34,7 +37,9 @@ module Bandwidth
34
37
  two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
35
38
  two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
36
39
  voice_basic_auth_user_name: voice_basic_auth_user_name,
37
- voice_basic_auth_password: voice_basic_auth_password)
40
+ voice_basic_auth_password: voice_basic_auth_password,
41
+ web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
42
+ web_rtc_basic_auth_password: web_rtc_basic_auth_password)
38
43
  else
39
44
  config
40
45
  end
@@ -23,7 +23,7 @@ module TwoFactorAuth
23
23
  _query_builder << '/accounts/{accountId}/code/voice'
24
24
  _query_builder = APIHelper.append_url_with_template_parameters(
25
25
  _query_builder,
26
- 'accountId' => account_id
26
+ 'accountId' => { 'value' => account_id, 'encode' => true }
27
27
  )
28
28
  _query_url = APIHelper.clean_url _query_builder
29
29
 
@@ -41,12 +41,21 @@ module TwoFactorAuth
41
41
  )
42
42
  TwoFactorAuthBasicAuth.apply(config, _request)
43
43
  _response = execute_request(_request)
44
+
45
+ # Validate response against endpoint and global error codes.
46
+ if _response.status_code == 400
47
+ raise InvalidRequestException.new(
48
+ 'client request error',
49
+ _response
50
+ )
51
+ end
44
52
  validate_response(_response)
45
53
 
46
54
  # Return appropriate response type.
47
55
  decoded = APIHelper.json_deserialize(_response.raw_body)
48
- ApiResponse.new(_response,
49
- data: TwoFactorVoiceResponse.from_hash(decoded))
56
+ ApiResponse.new(
57
+ _response, data: TwoFactorVoiceResponse.from_hash(decoded)
58
+ )
50
59
  end
51
60
 
52
61
  # Two-Factor authentication with Bandwidth messaging services
@@ -61,7 +70,7 @@ module TwoFactorAuth
61
70
  _query_builder << '/accounts/{accountId}/code/messaging'
62
71
  _query_builder = APIHelper.append_url_with_template_parameters(
63
72
  _query_builder,
64
- 'accountId' => account_id
73
+ 'accountId' => { 'value' => account_id, 'encode' => true }
65
74
  )
66
75
  _query_url = APIHelper.clean_url _query_builder
67
76
 
@@ -79,12 +88,22 @@ module TwoFactorAuth
79
88
  )
80
89
  TwoFactorAuthBasicAuth.apply(config, _request)
81
90
  _response = execute_request(_request)
91
+
92
+ # Validate response against endpoint and global error codes.
93
+ if _response.status_code == 400
94
+ raise InvalidRequestException.new(
95
+ 'client request error',
96
+ _response
97
+ )
98
+ end
82
99
  validate_response(_response)
83
100
 
84
101
  # Return appropriate response type.
85
102
  decoded = APIHelper.json_deserialize(_response.raw_body)
86
- ApiResponse.new(_response,
87
- data: TwoFactorMessagingResponse.from_hash(decoded))
103
+ ApiResponse.new(
104
+ _response,
105
+ data: TwoFactorMessagingResponse.from_hash(decoded)
106
+ )
88
107
  end
89
108
 
90
109
  # Verify a previously sent two-factor authentication code
@@ -99,7 +118,7 @@ module TwoFactorAuth
99
118
  _query_builder << '/accounts/{accountId}/code/verify'
100
119
  _query_builder = APIHelper.append_url_with_template_parameters(
101
120
  _query_builder,
102
- 'accountId' => account_id
121
+ 'accountId' => { 'value' => account_id, 'encode' => true }
103
122
  )
104
123
  _query_url = APIHelper.clean_url _query_builder
105
124
 
@@ -117,12 +136,22 @@ module TwoFactorAuth
117
136
  )
118
137
  TwoFactorAuthBasicAuth.apply(config, _request)
119
138
  _response = execute_request(_request)
139
+
140
+ # Validate response against endpoint and global error codes.
141
+ if _response.status_code == 400
142
+ raise InvalidRequestException.new(
143
+ 'client request error',
144
+ _response
145
+ )
146
+ end
120
147
  validate_response(_response)
121
148
 
122
149
  # Return appropriate response type.
123
150
  decoded = APIHelper.json_deserialize(_response.raw_body)
124
- ApiResponse.new(_response,
125
- data: TwoFactorVerifyCodeResponse.from_hash(decoded))
151
+ ApiResponse.new(
152
+ _response,
153
+ data: TwoFactorVerifyCodeResponse.from_hash(decoded)
154
+ )
126
155
  end
127
156
  end
128
157
  end
@@ -13,7 +13,7 @@ module Bandwidth
13
13
  @http_call_back = http_call_back
14
14
 
15
15
  @global_headers = {
16
- 'user-agent' => 'ruby-sdk-refs/tags/ruby3.4.0'
16
+ 'user-agent' => 'ruby-sdk-refs/tags/ruby3.9.0'
17
17
  }
18
18
  end
19
19