bandwidth-sdk 3.3.0 → 3.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bandwidth.rb +2 -0
- data/lib/bandwidth/api_helper.rb +14 -9
- data/lib/bandwidth/client.rb +11 -2
- data/lib/bandwidth/configuration.rb +23 -5
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +7 -2
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +18 -12
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +1 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +7 -2
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +38 -9
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +30 -4
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +33 -10
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
- data/lib/bandwidth/voice_lib/voice.rb +5 -0
- data/lib/bandwidth/voice_lib/voice/client.rb +7 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +352 -115
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
- data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +105 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
- data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +692 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +34 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
- metadata +22 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22e17841f86e7515af23eb80a22bdbebf088530844046ffe0015a967ec095335
|
4
|
+
data.tar.gz: 76973db63618901c5675517b4a9ba7e5adef6f0579132d493d50ce43d6814516
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60dd4c3f1ea55f0f92cd25fc3d62d695d96c286c87b1b54d54eec5a965e5d8a73cf6e45bbcf6c6099d631a7062f3aab6906ec5425af2c4490910fd95bcc2fd0
|
7
|
+
data.tar.gz: 5d93c7a448c86a2028f807cfe7e6a025f706563965a523582600e474ca92abc84fbbdf86b897fa0f574ea2fbcb08551f9a036da82ee6ccd6c81afda9fe87aa5b
|
data/lib/bandwidth.rb
CHANGED
@@ -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
|
data/lib/bandwidth/api_helper.rb
CHANGED
@@ -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
|
-
|
45
|
-
|
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
|
-
|
52
|
-
|
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 =
|
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.
|
data/lib/bandwidth/client.rb
CHANGED
@@ -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',
|
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',
|
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(
|
80
|
-
|
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(
|
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(
|
363
|
+
ApiResponse.new(
|
364
|
+
_response, data: BandwidthMessage.from_hash(decoded)
|
365
|
+
)
|
360
366
|
end
|
361
367
|
end
|
362
368
|
end
|
@@ -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',
|
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(
|
49
|
-
|
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(
|
87
|
-
|
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(
|
125
|
-
|
151
|
+
ApiResponse.new(
|
152
|
+
_response,
|
153
|
+
data: TwoFactorVerifyCodeResponse.from_hash(decoded)
|
154
|
+
)
|
126
155
|
end
|
127
156
|
end
|
128
157
|
end
|