bandwidth-sdk 6.2.0 → 9.0.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/api_helper.rb +19 -29
- data/lib/bandwidth/client.rb +8 -8
- data/lib/bandwidth/configuration.rb +20 -32
- data/lib/bandwidth/http/auth/{two_factor_auth_basic_auth.rb → multi_factor_auth_basic_auth.rb} +3 -3
- data/lib/bandwidth/http/faraday_client.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/client.rb +14 -5
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +78 -71
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/messaging_lib/messaging/exceptions/messaging_exception.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_callback_message.rb +31 -11
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +54 -25
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +102 -24
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +23 -4
- data/lib/bandwidth/messaging_lib/messaging/models/deferred_result.rb +20 -4
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +27 -80
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +32 -14
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +28 -8
- data/lib/bandwidth/messaging_lib/messaging/models/tag.rb +20 -4
- data/lib/bandwidth/models/base_model.rb +30 -8
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/client.rb +15 -6
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/controllers/mfa_controller.rb +28 -23
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/error_with_request_exception.rb +5 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/forbidden_request_exception.rb +4 -1
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/exceptions/unauthorized_request_exception.rb +4 -1
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_code_request_schema.rb +27 -12
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_messaging_response.rb +17 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_code_response.rb +17 -2
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_verify_request_schema.rb +29 -10
- data/lib/bandwidth/{two_factor_auth_lib/two_factor_auth → multi_factor_auth_lib/multi_factor_auth}/models/two_factor_voice_response.rb +17 -2
- data/lib/bandwidth/multi_factor_auth_lib/multi_factor_auth.rb +23 -0
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/api_controller.rb +212 -210
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/exceptions/accounts_tnlookup400_error_exception.rb +4 -1
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_request.rb +17 -2
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_response.rb +20 -4
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/order_status.rb +28 -7
- data/lib/bandwidth/phone_number_lookup_lib/phone_number_lookup/models/result.rb +43 -18
- data/lib/bandwidth/utilities/date_time_helper.rb +156 -0
- data/lib/bandwidth/utilities/file_wrapper.rb +1 -2
- data/lib/bandwidth/voice_lib/voice/client.rb +14 -5
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +418 -379
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/voice_lib/voice/exceptions/{api_error_response_exception.rb → api_error_exception.rb} +8 -5
- data/lib/bandwidth/voice_lib/voice/models/call_callback.rb +343 -0
- data/lib/bandwidth/voice_lib/voice/models/call_recording_metadata.rb +250 -0
- data/lib/bandwidth/voice_lib/voice/models/call_state.rb +284 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_callback.rb +211 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +2 -20
- data/lib/bandwidth/voice_lib/voice/models/{conference_member_detail.rb → conference_member_state.rb} +43 -20
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata.rb +173 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_state.rb +153 -0
- data/lib/bandwidth/voice_lib/voice/models/create_call_request.rb +301 -0
- data/lib/bandwidth/voice_lib/voice/models/create_call_response.rb +256 -0
- data/lib/bandwidth/voice_lib/voice/models/diversion.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/machine_detection_configuration.rb +218 -0
- data/lib/bandwidth/voice_lib/voice/models/mode_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/{modify_call_recording_state.rb → modify_call_recording_request.rb} +19 -6
- data/lib/bandwidth/voice_lib/voice/models/modify_call_request.rb +156 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_conference_request.rb +144 -0
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/transcribe_recording_request.rb +108 -0
- data/lib/bandwidth/voice_lib/voice/models/transcript.rb +20 -4
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +35 -17
- data/lib/bandwidth/voice_lib/voice/models/transcription_metadata.rb +89 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +18 -1
- data/lib/bandwidth/voice_lib/voice.rb +20 -18
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +7 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +4 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +75 -64
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +3 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +5 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +20 -5
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +37 -14
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +15 -2
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +20 -4
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +20 -3
- data/lib/bandwidth.rb +20 -18
- data/test/integration/test_integration.rb +92 -57
- metadata +35 -31
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +0 -22
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +0 -207
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +0 -164
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +0 -248
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +0 -116
- data/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +0 -107
- data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +0 -80
- data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +0 -108
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +0 -126
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +0 -47
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +0 -190
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +0 -29
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +0 -32
@@ -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
|
@@ -7,40 +7,42 @@
|
|
7
7
|
require_relative 'voice/client.rb'
|
8
8
|
|
9
9
|
# Models
|
10
|
-
require_relative 'voice/models/
|
11
|
-
require_relative 'voice/models/
|
12
|
-
require_relative 'voice/models/
|
13
|
-
require_relative 'voice/models/
|
14
|
-
require_relative 'voice/models/
|
15
|
-
require_relative 'voice/models/
|
16
|
-
require_relative 'voice/models/
|
17
|
-
require_relative 'voice/models/
|
18
|
-
require_relative 'voice/models/
|
19
|
-
require_relative 'voice/models/
|
20
|
-
require_relative 'voice/models/
|
10
|
+
require_relative 'voice/models/create_call_request.rb'
|
11
|
+
require_relative 'voice/models/create_call_response.rb'
|
12
|
+
require_relative 'voice/models/call_state.rb'
|
13
|
+
require_relative 'voice/models/modify_call_request.rb'
|
14
|
+
require_relative 'voice/models/modify_call_recording_request.rb'
|
15
|
+
require_relative 'voice/models/call_recording_metadata.rb'
|
16
|
+
require_relative 'voice/models/modify_conference_request.rb'
|
17
|
+
require_relative 'voice/models/conference_state.rb'
|
18
|
+
require_relative 'voice/models/conference_member_state.rb'
|
19
|
+
require_relative 'voice/models/conference_recording_metadata.rb'
|
20
|
+
require_relative 'voice/models/machine_detection_configuration.rb'
|
21
|
+
require_relative 'voice/models/transcribe_recording_request.rb'
|
22
|
+
require_relative 'voice/models/transcription_response.rb'
|
23
|
+
require_relative 'voice/models/transcription_metadata.rb'
|
21
24
|
require_relative 'voice/models/transcript.rb'
|
25
|
+
require_relative 'voice/models/call_callback.rb'
|
22
26
|
require_relative 'voice/models/transcription.rb'
|
23
|
-
require_relative 'voice/models/
|
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
|
-
require_relative 'voice/models/disconnect_cause_enum.rb'
|
30
34
|
require_relative 'voice/models/disconnect_method_enum.rb'
|
35
|
+
require_relative 'voice/models/fallback_method_enum.rb'
|
31
36
|
require_relative 'voice/models/file_format_enum.rb'
|
37
|
+
require_relative 'voice/models/mode_enum.rb'
|
32
38
|
require_relative 'voice/models/redirect_fallback_method_enum.rb'
|
33
39
|
require_relative 'voice/models/redirect_method_enum.rb'
|
34
40
|
require_relative 'voice/models/state_enum.rb'
|
35
41
|
require_relative 'voice/models/state1_enum.rb'
|
36
|
-
require_relative 'voice/models/state2_enum.rb'
|
37
42
|
require_relative 'voice/models/status_enum.rb'
|
38
|
-
require_relative 'voice/models/status1_enum.rb'
|
39
|
-
require_relative 'voice/models/status3_enum.rb'
|
40
43
|
|
41
44
|
# Exceptions
|
42
|
-
require_relative 'voice/exceptions/
|
45
|
+
require_relative 'voice/exceptions/api_error_exception.rb'
|
43
46
|
# Controllers
|
44
47
|
require_relative 'voice/controllers/base_controller.rb'
|
45
48
|
require_relative 'voice/controllers/api_controller.rb'
|
46
|
-
require_relative 'bxml/bxml.rb'
|
@@ -6,8 +6,13 @@
|
|
6
6
|
|
7
7
|
module Bandwidth
|
8
8
|
module WebRtc
|
9
|
-
def generate_bxml(device_token, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
|
10
|
-
return '<?xml version="1.0" encoding="UTF-8"?><Response
|
9
|
+
def generate_bxml(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
|
10
|
+
return '<?xml version="1.0" encoding="UTF-8"?><Response>' + generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri) + '</Response>'
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate_transfer_bxml_verb(device_token, voice_call_id, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
|
14
|
+
voice_call_id = voice_call_id.split("-", 2).last.split("-").join()
|
15
|
+
return '<Transfer><SipUri uui="%s;encoding=base64,%s;encoding=jwt">%s</SipUri></Transfer>' % [voice_call_id, device_token, sip_uri]
|
11
16
|
end
|
12
17
|
end
|
13
18
|
end
|
@@ -23,8 +23,8 @@ module Bandwidth
|
|
23
23
|
base_url: 'https://www.example.com',
|
24
24
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
25
25
|
messaging_basic_auth_password: 'TODO: Replace',
|
26
|
-
|
27
|
-
|
26
|
+
multi_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
27
|
+
multi_factor_auth_basic_auth_password: 'TODO: Replace',
|
28
28
|
phone_number_lookup_basic_auth_user_name: 'TODO: Replace',
|
29
29
|
phone_number_lookup_basic_auth_password: 'TODO: Replace',
|
30
30
|
voice_basic_auth_user_name: 'TODO: Replace',
|
@@ -43,8 +43,8 @@ module Bandwidth
|
|
43
43
|
base_url: base_url,
|
44
44
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
45
45
|
messaging_basic_auth_password: messaging_basic_auth_password,
|
46
|
-
|
47
|
-
|
46
|
+
multi_factor_auth_basic_auth_user_name: multi_factor_auth_basic_auth_user_name,
|
47
|
+
multi_factor_auth_basic_auth_password: multi_factor_auth_basic_auth_password,
|
48
48
|
phone_number_lookup_basic_auth_user_name: phone_number_lookup_basic_auth_user_name,
|
49
49
|
phone_number_lookup_basic_auth_password: phone_number_lookup_basic_auth_password,
|
50
50
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
@@ -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
|
-
|
47
|
+
case _response.status_code
|
48
|
+
when 400
|
48
49
|
raise APIException.new(
|
49
50
|
'Bad Request',
|
50
51
|
_response
|
51
52
|
)
|
52
|
-
|
53
|
+
when 401
|
53
54
|
raise APIException.new(
|
54
55
|
'Unauthorized',
|
55
56
|
_response
|
56
57
|
)
|
57
|
-
|
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
|
-
|
110
|
+
case _response.status_code
|
111
|
+
when 401
|
110
112
|
raise APIException.new(
|
111
113
|
'Unauthorized',
|
112
114
|
_response
|
113
115
|
)
|
114
|
-
|
116
|
+
when 403
|
115
117
|
raise APIException.new(
|
116
118
|
'Access Denied',
|
117
119
|
_response
|
118
120
|
)
|
119
|
-
|
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
|
-
|
166
|
+
case _response.status_code
|
167
|
+
when 401
|
165
168
|
raise APIException.new(
|
166
169
|
'Unauthorized',
|
167
170
|
_response
|
168
171
|
)
|
169
|
-
|
172
|
+
when 403
|
170
173
|
raise APIException.new(
|
171
174
|
'Access Denied',
|
172
175
|
_response
|
173
176
|
)
|
174
|
-
|
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
|
-
|
228
|
+
case _response.status_code
|
229
|
+
when 400
|
226
230
|
raise APIException.new(
|
227
231
|
'Bad Request',
|
228
232
|
_response
|
229
233
|
)
|
230
|
-
|
234
|
+
when 401
|
231
235
|
raise APIException.new(
|
232
236
|
'Unauthorized',
|
233
237
|
_response
|
234
238
|
)
|
235
|
-
|
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
|
-
|
290
|
+
case _response.status_code
|
291
|
+
when 401
|
287
292
|
raise APIException.new(
|
288
293
|
'Unauthorized',
|
289
294
|
_response
|
290
295
|
)
|
291
|
-
|
296
|
+
when 403
|
292
297
|
raise APIException.new(
|
293
298
|
'Access Denied',
|
294
299
|
_response
|
295
300
|
)
|
296
|
-
|
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
|
-
|
346
|
+
case _response.status_code
|
347
|
+
when 401
|
342
348
|
raise APIException.new(
|
343
349
|
'Unauthorized',
|
344
350
|
_response
|
345
351
|
)
|
346
|
-
|
352
|
+
when 403
|
347
353
|
raise APIException.new(
|
348
354
|
'Access Denied',
|
349
355
|
_response
|
350
356
|
)
|
351
|
-
|
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
|
-
|
405
|
+
case _response.status_code
|
406
|
+
when 401
|
400
407
|
raise APIException.new(
|
401
408
|
'Unauthorized',
|
402
409
|
_response
|
403
410
|
)
|
404
|
-
|
411
|
+
when 403
|
405
412
|
raise APIException.new(
|
406
413
|
'Access Denied',
|
407
414
|
_response
|
408
415
|
)
|
409
|
-
|
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
|
-
|
476
|
+
case _response.status_code
|
477
|
+
when 401
|
470
478
|
raise APIException.new(
|
471
479
|
'Unauthorized',
|
472
480
|
_response
|
473
481
|
)
|
474
|
-
|
482
|
+
when 403
|
475
483
|
raise APIException.new(
|
476
484
|
'Access Denied',
|
477
485
|
_response
|
478
486
|
)
|
479
|
-
|
487
|
+
when 404
|
480
488
|
raise APIException.new(
|
481
489
|
'Not Found',
|
482
490
|
_response
|
@@ -494,24 +502,24 @@ 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
|
-
# @param [String] participant_id Required parameter: Participant ID
|
502
509
|
# @param [String] session_id Required parameter: Session ID
|
510
|
+
# @param [String] participant_id Required parameter: Participant ID
|
503
511
|
# @return [void] response from the API call
|
504
512
|
def remove_participant_from_session(account_id,
|
505
|
-
|
506
|
-
|
513
|
+
session_id,
|
514
|
+
participant_id)
|
507
515
|
# Prepare query url.
|
508
516
|
_query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
|
509
517
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
|
510
518
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
511
519
|
_query_builder,
|
512
520
|
'accountId' => { 'value' => account_id, 'encode' => false },
|
513
|
-
'
|
514
|
-
'
|
521
|
+
'sessionId' => { 'value' => session_id, 'encode' => false },
|
522
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
515
523
|
)
|
516
524
|
_query_url = APIHelper.clean_url _query_builder
|
517
525
|
|
@@ -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
|
-
|
534
|
+
case _response.status_code
|
535
|
+
when 401
|
527
536
|
raise APIException.new(
|
528
537
|
'Unauthorized',
|
529
538
|
_response
|
530
539
|
)
|
531
|
-
|
540
|
+
when 403
|
532
541
|
raise APIException.new(
|
533
542
|
'Access Denied',
|
534
543
|
_response
|
535
544
|
)
|
536
|
-
|
545
|
+
when 404
|
537
546
|
raise APIException.new(
|
538
547
|
'Not Found',
|
539
548
|
_response
|
@@ -551,22 +560,22 @@ 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
|
-
# @param [String] participant_id Required parameter: Participant ID
|
557
565
|
# @param [String] session_id Required parameter: Session ID
|
566
|
+
# @param [String] participant_id Required parameter: Participant ID
|
558
567
|
# @return [Subscriptions] response from the API call
|
559
568
|
def get_participant_subscriptions(account_id,
|
560
|
-
|
561
|
-
|
569
|
+
session_id,
|
570
|
+
participant_id)
|
562
571
|
# Prepare query url.
|
563
572
|
_query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
|
564
573
|
_query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
|
565
574
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
566
575
|
_query_builder,
|
567
576
|
'accountId' => { 'value' => account_id, 'encode' => false },
|
568
|
-
'
|
569
|
-
'
|
577
|
+
'sessionId' => { 'value' => session_id, 'encode' => false },
|
578
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
570
579
|
)
|
571
580
|
_query_url = APIHelper.clean_url _query_builder
|
572
581
|
|
@@ -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
|
-
|
596
|
+
case _response.status_code
|
597
|
+
when 401
|
588
598
|
raise APIException.new(
|
589
599
|
'Unauthorized',
|
590
600
|
_response
|
591
601
|
)
|
592
|
-
|
602
|
+
when 403
|
593
603
|
raise APIException.new(
|
594
604
|
'Access Denied',
|
595
605
|
_response
|
596
606
|
)
|
597
|
-
|
607
|
+
when 404
|
598
608
|
raise APIException.new(
|
599
609
|
'Not Found',
|
600
610
|
_response
|
@@ -615,19 +625,19 @@ 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
|
-
# @param [String] participant_id Required parameter: Participant ID
|
625
634
|
# @param [String] session_id Required parameter: Session ID
|
635
|
+
# @param [String] participant_id Required parameter: Participant ID
|
626
636
|
# @param [Subscriptions] body Optional parameter: Initial state
|
627
637
|
# @return [void] response from the API call
|
628
638
|
def update_participant_subscriptions(account_id,
|
629
|
-
participant_id,
|
630
639
|
session_id,
|
640
|
+
participant_id,
|
631
641
|
body: nil)
|
632
642
|
# Prepare query url.
|
633
643
|
_query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
|
@@ -635,8 +645,8 @@ module WebRtc
|
|
635
645
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
636
646
|
_query_builder,
|
637
647
|
'accountId' => { 'value' => account_id, 'encode' => false },
|
638
|
-
'
|
639
|
-
'
|
648
|
+
'sessionId' => { 'value' => session_id, 'encode' => false },
|
649
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
640
650
|
)
|
641
651
|
_query_url = APIHelper.clean_url _query_builder
|
642
652
|
|
@@ -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
|
-
|
668
|
+
case _response.status_code
|
669
|
+
when 400
|
659
670
|
raise APIException.new(
|
660
671
|
'Bad Request',
|
661
672
|
_response
|
662
673
|
)
|
663
|
-
|
674
|
+
when 401
|
664
675
|
raise APIException.new(
|
665
676
|
'Unauthorized',
|
666
677
|
_response
|
667
678
|
)
|
668
|
-
|
679
|
+
when 403
|
669
680
|
raise APIException.new(
|
670
681
|
'Access Denied',
|
671
682
|
_response
|
672
683
|
)
|
673
|
-
|
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
|
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
|
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
|
-
|
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,
|