bandwidth-sdk 3.4.0 → 3.9.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -20,7 +20,10 @@ module Bandwidth
20
20
  DELETED = 'deleted'.freeze,
21
21
 
22
22
  # TODO: Write general description for ERROR
23
- ERROR = 'error'.freeze
23
+ ERROR = 'error'.freeze,
24
+
25
+ # TODO: Write general description for ALREADYINPROGRESS
26
+ ALREADYINPROGRESS = 'already-in-progress'.freeze
24
27
  ].freeze
25
28
  end
26
29
  end
@@ -4,9 +4,9 @@
4
4
  # ( https://apimatic.io ).
5
5
 
6
6
  module Bandwidth
7
- # Status2.
8
- class Status2Enum
9
- STATUS2_ENUM = [
7
+ # Status3.
8
+ class Status3Enum
9
+ STATUS3_ENUM = [
10
10
  # TODO: Write general description for NONE
11
11
  NONE = 'none'.freeze,
12
12
 
@@ -11,7 +11,7 @@ module Bandwidth
11
11
  attr_accessor :id
12
12
 
13
13
  # TODO: Write general description for this method
14
- # @return [Status2Enum]
14
+ # @return [Status3Enum]
15
15
  attr_accessor :status
16
16
 
17
17
  # TODO: Write general description for this method
@@ -0,0 +1,21 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+
7
+ require_relative 'web_rtc/client.rb'
8
+
9
+ # Models
10
+ require_relative 'web_rtc/models/session.rb'
11
+ require_relative 'web_rtc/models/participant.rb'
12
+ require_relative 'web_rtc/models/subscriptions.rb'
13
+ require_relative 'web_rtc/models/participant_subscription.rb'
14
+ require_relative 'web_rtc/models/accounts_participants_response.rb'
15
+ require_relative 'web_rtc/models/publish_permission_enum.rb'
16
+
17
+ # Exceptions
18
+ require_relative 'web_rtc/exceptions/error_exception.rb'
19
+ # Controllers
20
+ require_relative 'web_rtc/controllers/base_controller.rb'
21
+ require_relative 'web_rtc/controllers/api_controller.rb'
@@ -0,0 +1,49 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ module WebRtc
8
+ # bandwidth client class.
9
+ class Client
10
+ attr_reader :config
11
+
12
+ # Access to client controller.
13
+ # @return [APIController] Returns the controller instance.
14
+ def client
15
+ @client ||= APIController.new config
16
+ end
17
+
18
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
19
+ backoff_factor: 1, environment: Environment::PRODUCTION,
20
+ messaging_basic_auth_user_name: 'TODO: Replace',
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',
24
+ voice_basic_auth_user_name: '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)
29
+ @config = if config.nil?
30
+ Configuration.new(timeout: timeout,
31
+ max_retries: max_retries,
32
+ retry_interval: retry_interval,
33
+ backoff_factor: backoff_factor,
34
+ environment: environment,
35
+ messaging_basic_auth_user_name: messaging_basic_auth_user_name,
36
+ messaging_basic_auth_password: messaging_basic_auth_password,
37
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
38
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
39
+ voice_basic_auth_user_name: voice_basic_auth_user_name,
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)
43
+ else
44
+ config
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,692 @@
1
+ # bandwidth
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Bandwidth
7
+ module WebRtc
8
+ # APIController
9
+ class APIController < BaseController
10
+ def initialize(config, http_call_back: nil)
11
+ super(config, http_call_back: http_call_back)
12
+ end
13
+
14
+ # Create a new participant under this account
15
+ # Participants are idempotent, so relevant parameters must be set in this
16
+ # function if desired
17
+ # @param [String] account_id Required parameter: Account ID
18
+ # @param [Participant] body Optional parameter: Participant parameters
19
+ # @return [AccountsParticipantsResponse] response from the API call
20
+ def create_participant(account_id,
21
+ body: nil)
22
+ # Prepare query url.
23
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
24
+ _query_builder << '/accounts/{accountId}/participants'
25
+ _query_builder = APIHelper.append_url_with_template_parameters(
26
+ _query_builder,
27
+ 'accountId' => { 'value' => account_id, 'encode' => true }
28
+ )
29
+ _query_url = APIHelper.clean_url _query_builder
30
+
31
+ # Prepare headers.
32
+ _headers = {
33
+ 'accept' => 'application/json',
34
+ 'content-type' => 'application/json; charset=utf-8'
35
+ }
36
+
37
+ # Prepare and execute HttpRequest.
38
+ _request = config.http_client.post(
39
+ _query_url,
40
+ headers: _headers,
41
+ parameters: body.to_json
42
+ )
43
+ WebRtcBasicAuth.apply(config, _request)
44
+ _response = execute_request(_request)
45
+
46
+ # Validate response against endpoint and global error codes.
47
+ if _response.status_code == 400
48
+ raise APIException.new(
49
+ 'Bad Request',
50
+ _response
51
+ )
52
+ elsif _response.status_code == 401
53
+ raise APIException.new(
54
+ 'Unauthorized',
55
+ _response
56
+ )
57
+ elsif _response.status_code == 403
58
+ raise APIException.new(
59
+ 'Access Denied',
60
+ _response
61
+ )
62
+ end
63
+ unless _response.status_code.between?(200, 208)
64
+ raise ErrorException.new(
65
+ 'Unexpected Error',
66
+ _response
67
+ )
68
+ end
69
+ validate_response(_response)
70
+
71
+ # Return appropriate response type.
72
+ decoded = APIHelper.json_deserialize(_response.raw_body)
73
+ ApiResponse.new(
74
+ _response,
75
+ data: AccountsParticipantsResponse.from_hash(decoded)
76
+ )
77
+ end
78
+
79
+ # Get participant by ID
80
+ # @param [String] account_id Required parameter: Account ID
81
+ # @param [String] participant_id Required parameter: Participant ID
82
+ # @return [Participant] response from the API call
83
+ def get_participant(account_id,
84
+ participant_id)
85
+ # Prepare query url.
86
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
87
+ _query_builder << '/accounts/{accountId}/participants/{participantId}'
88
+ _query_builder = APIHelper.append_url_with_template_parameters(
89
+ _query_builder,
90
+ 'accountId' => { 'value' => account_id, 'encode' => true },
91
+ 'participantId' => { 'value' => participant_id, 'encode' => true }
92
+ )
93
+ _query_url = APIHelper.clean_url _query_builder
94
+
95
+ # Prepare headers.
96
+ _headers = {
97
+ 'accept' => 'application/json'
98
+ }
99
+
100
+ # Prepare and execute HttpRequest.
101
+ _request = config.http_client.get(
102
+ _query_url,
103
+ headers: _headers
104
+ )
105
+ WebRtcBasicAuth.apply(config, _request)
106
+ _response = execute_request(_request)
107
+
108
+ # Validate response against endpoint and global error codes.
109
+ if _response.status_code == 401
110
+ raise APIException.new(
111
+ 'Unauthorized',
112
+ _response
113
+ )
114
+ elsif _response.status_code == 403
115
+ raise APIException.new(
116
+ 'Access Denied',
117
+ _response
118
+ )
119
+ elsif _response.status_code == 404
120
+ raise APIException.new(
121
+ 'Not Found',
122
+ _response
123
+ )
124
+ end
125
+ unless _response.status_code.between?(200, 208)
126
+ raise ErrorException.new(
127
+ 'Unexpected Error',
128
+ _response
129
+ )
130
+ end
131
+ validate_response(_response)
132
+
133
+ # Return appropriate response type.
134
+ decoded = APIHelper.json_deserialize(_response.raw_body)
135
+ ApiResponse.new(
136
+ _response, data: Participant.from_hash(decoded)
137
+ )
138
+ end
139
+
140
+ # Delete participant by ID
141
+ # @param [String] account_id Required parameter: Account ID
142
+ # @param [String] participant_id Required parameter: Example:
143
+ # @return [void] response from the API call
144
+ def delete_participant(account_id,
145
+ participant_id)
146
+ # Prepare query url.
147
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
148
+ _query_builder << '/accounts/{accountId}/participants/{participantId}'
149
+ _query_builder = APIHelper.append_url_with_template_parameters(
150
+ _query_builder,
151
+ 'accountId' => { 'value' => account_id, 'encode' => true },
152
+ 'participantId' => { 'value' => participant_id, 'encode' => true }
153
+ )
154
+ _query_url = APIHelper.clean_url _query_builder
155
+
156
+ # Prepare and execute HttpRequest.
157
+ _request = config.http_client.delete(
158
+ _query_url
159
+ )
160
+ WebRtcBasicAuth.apply(config, _request)
161
+ _response = execute_request(_request)
162
+
163
+ # Validate response against endpoint and global error codes.
164
+ if _response.status_code == 401
165
+ raise APIException.new(
166
+ 'Unauthorized',
167
+ _response
168
+ )
169
+ elsif _response.status_code == 403
170
+ raise APIException.new(
171
+ 'Access Denied',
172
+ _response
173
+ )
174
+ elsif _response.status_code == 404
175
+ raise APIException.new(
176
+ 'Not Found',
177
+ _response
178
+ )
179
+ end
180
+ unless _response.status_code.between?(200, 208)
181
+ raise ErrorException.new(
182
+ 'Unexpected Error',
183
+ _response
184
+ )
185
+ end
186
+ validate_response(_response)
187
+
188
+ # Return appropriate response type.
189
+ ApiResponse.new(_response)
190
+ end
191
+
192
+ # Create a new session
193
+ # Sessions are idempotent, so relevant parameters must be set in this
194
+ # function if desired
195
+ # @param [String] account_id Required parameter: Account ID
196
+ # @param [Session] body Optional parameter: Session parameters
197
+ # @return [Session] response from the API call
198
+ def create_session(account_id,
199
+ body: nil)
200
+ # Prepare query url.
201
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
202
+ _query_builder << '/accounts/{accountId}/sessions'
203
+ _query_builder = APIHelper.append_url_with_template_parameters(
204
+ _query_builder,
205
+ 'accountId' => { 'value' => account_id, 'encode' => true }
206
+ )
207
+ _query_url = APIHelper.clean_url _query_builder
208
+
209
+ # Prepare headers.
210
+ _headers = {
211
+ 'accept' => 'application/json',
212
+ 'content-type' => 'application/json; charset=utf-8'
213
+ }
214
+
215
+ # Prepare and execute HttpRequest.
216
+ _request = config.http_client.post(
217
+ _query_url,
218
+ headers: _headers,
219
+ parameters: body.to_json
220
+ )
221
+ WebRtcBasicAuth.apply(config, _request)
222
+ _response = execute_request(_request)
223
+
224
+ # Validate response against endpoint and global error codes.
225
+ if _response.status_code == 400
226
+ raise APIException.new(
227
+ 'Bad Request',
228
+ _response
229
+ )
230
+ elsif _response.status_code == 401
231
+ raise APIException.new(
232
+ 'Unauthorized',
233
+ _response
234
+ )
235
+ elsif _response.status_code == 403
236
+ raise APIException.new(
237
+ 'Access Denied',
238
+ _response
239
+ )
240
+ end
241
+ unless _response.status_code.between?(200, 208)
242
+ raise ErrorException.new(
243
+ 'Unexpected Error',
244
+ _response
245
+ )
246
+ end
247
+ validate_response(_response)
248
+
249
+ # Return appropriate response type.
250
+ decoded = APIHelper.json_deserialize(_response.raw_body)
251
+ ApiResponse.new(
252
+ _response, data: Session.from_hash(decoded)
253
+ )
254
+ end
255
+
256
+ # Get session by ID
257
+ # @param [String] account_id Required parameter: Account ID
258
+ # @param [String] session_id Required parameter: Session ID
259
+ # @return [Session] response from the API call
260
+ def get_session(account_id,
261
+ session_id)
262
+ # Prepare query url.
263
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
264
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}'
265
+ _query_builder = APIHelper.append_url_with_template_parameters(
266
+ _query_builder,
267
+ 'accountId' => { 'value' => account_id, 'encode' => true },
268
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
269
+ )
270
+ _query_url = APIHelper.clean_url _query_builder
271
+
272
+ # Prepare headers.
273
+ _headers = {
274
+ 'accept' => 'application/json'
275
+ }
276
+
277
+ # Prepare and execute HttpRequest.
278
+ _request = config.http_client.get(
279
+ _query_url,
280
+ headers: _headers
281
+ )
282
+ WebRtcBasicAuth.apply(config, _request)
283
+ _response = execute_request(_request)
284
+
285
+ # Validate response against endpoint and global error codes.
286
+ if _response.status_code == 401
287
+ raise APIException.new(
288
+ 'Unauthorized',
289
+ _response
290
+ )
291
+ elsif _response.status_code == 403
292
+ raise APIException.new(
293
+ 'Access Denied',
294
+ _response
295
+ )
296
+ elsif _response.status_code == 404
297
+ raise APIException.new(
298
+ 'Not Found',
299
+ _response
300
+ )
301
+ end
302
+ unless _response.status_code.between?(200, 208)
303
+ raise ErrorException.new(
304
+ 'Unexpected Error',
305
+ _response
306
+ )
307
+ end
308
+ validate_response(_response)
309
+
310
+ # Return appropriate response type.
311
+ decoded = APIHelper.json_deserialize(_response.raw_body)
312
+ ApiResponse.new(
313
+ _response, data: Session.from_hash(decoded)
314
+ )
315
+ end
316
+
317
+ # Delete session by ID
318
+ # @param [String] account_id Required parameter: Account ID
319
+ # @param [String] session_id Required parameter: Session ID
320
+ # @return [void] response from the API call
321
+ def delete_session(account_id,
322
+ session_id)
323
+ # Prepare query url.
324
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
325
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}'
326
+ _query_builder = APIHelper.append_url_with_template_parameters(
327
+ _query_builder,
328
+ 'accountId' => { 'value' => account_id, 'encode' => true },
329
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
330
+ )
331
+ _query_url = APIHelper.clean_url _query_builder
332
+
333
+ # Prepare and execute HttpRequest.
334
+ _request = config.http_client.delete(
335
+ _query_url
336
+ )
337
+ WebRtcBasicAuth.apply(config, _request)
338
+ _response = execute_request(_request)
339
+
340
+ # Validate response against endpoint and global error codes.
341
+ if _response.status_code == 401
342
+ raise APIException.new(
343
+ 'Unauthorized',
344
+ _response
345
+ )
346
+ elsif _response.status_code == 403
347
+ raise APIException.new(
348
+ 'Access Denied',
349
+ _response
350
+ )
351
+ elsif _response.status_code == 404
352
+ raise APIException.new(
353
+ 'Not Found',
354
+ _response
355
+ )
356
+ end
357
+ unless _response.status_code.between?(200, 208)
358
+ raise ErrorException.new(
359
+ 'Unexpected Error',
360
+ _response
361
+ )
362
+ end
363
+ validate_response(_response)
364
+
365
+ # Return appropriate response type.
366
+ ApiResponse.new(_response)
367
+ end
368
+
369
+ # List participants in a session
370
+ # @param [String] account_id Required parameter: Account ID
371
+ # @param [String] session_id Required parameter: Session ID
372
+ # @return [List of Participant] response from the API call
373
+ def list_session_participants(account_id,
374
+ session_id)
375
+ # Prepare query url.
376
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
377
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants'
378
+ _query_builder = APIHelper.append_url_with_template_parameters(
379
+ _query_builder,
380
+ 'accountId' => { 'value' => account_id, 'encode' => true },
381
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
382
+ )
383
+ _query_url = APIHelper.clean_url _query_builder
384
+
385
+ # Prepare headers.
386
+ _headers = {
387
+ 'accept' => 'application/json'
388
+ }
389
+
390
+ # Prepare and execute HttpRequest.
391
+ _request = config.http_client.get(
392
+ _query_url,
393
+ headers: _headers
394
+ )
395
+ WebRtcBasicAuth.apply(config, _request)
396
+ _response = execute_request(_request)
397
+
398
+ # Validate response against endpoint and global error codes.
399
+ if _response.status_code == 401
400
+ raise APIException.new(
401
+ 'Unauthorized',
402
+ _response
403
+ )
404
+ elsif _response.status_code == 403
405
+ raise APIException.new(
406
+ 'Access Denied',
407
+ _response
408
+ )
409
+ elsif _response.status_code == 404
410
+ raise APIException.new(
411
+ 'Not Found',
412
+ _response
413
+ )
414
+ end
415
+ unless _response.status_code.between?(200, 208)
416
+ raise ErrorException.new(
417
+ 'Unexpected Error',
418
+ _response
419
+ )
420
+ end
421
+ validate_response(_response)
422
+
423
+ # Return appropriate response type.
424
+ decoded = APIHelper.json_deserialize(_response.raw_body)
425
+ ApiResponse.new(
426
+ _response,
427
+ data: decoded.map { |element| Participant.from_hash(element) }
428
+ )
429
+ end
430
+
431
+ # Add a participant to a session
432
+ # Subscriptions can optionally be provided as part of this call
433
+ # @param [String] account_id Required parameter: Account ID
434
+ # @param [String] session_id Required parameter: Session ID
435
+ # @param [String] participant_id Required parameter: Participant ID
436
+ # @param [Subscriptions] body Optional parameter: Subscriptions the
437
+ # participant should be created with
438
+ # @return [void] response from the API call
439
+ def add_participant_to_session(account_id,
440
+ session_id,
441
+ participant_id,
442
+ body: nil)
443
+ # Prepare query url.
444
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
445
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
446
+ _query_builder = APIHelper.append_url_with_template_parameters(
447
+ _query_builder,
448
+ 'accountId' => { 'value' => account_id, 'encode' => true },
449
+ 'sessionId' => { 'value' => session_id, 'encode' => true },
450
+ 'participantId' => { 'value' => participant_id, 'encode' => true }
451
+ )
452
+ _query_url = APIHelper.clean_url _query_builder
453
+
454
+ # Prepare headers.
455
+ _headers = {
456
+ 'content-type' => 'application/json; charset=utf-8'
457
+ }
458
+
459
+ # Prepare and execute HttpRequest.
460
+ _request = config.http_client.put(
461
+ _query_url,
462
+ headers: _headers,
463
+ parameters: body.to_json
464
+ )
465
+ WebRtcBasicAuth.apply(config, _request)
466
+ _response = execute_request(_request)
467
+
468
+ # Validate response against endpoint and global error codes.
469
+ if _response.status_code == 401
470
+ raise APIException.new(
471
+ 'Unauthorized',
472
+ _response
473
+ )
474
+ elsif _response.status_code == 403
475
+ raise APIException.new(
476
+ 'Access Denied',
477
+ _response
478
+ )
479
+ elsif _response.status_code == 404
480
+ raise APIException.new(
481
+ 'Not Found',
482
+ _response
483
+ )
484
+ end
485
+ unless _response.status_code.between?(200, 208)
486
+ raise ErrorException.new(
487
+ 'Unexpected Error',
488
+ _response
489
+ )
490
+ end
491
+ validate_response(_response)
492
+
493
+ # Return appropriate response type.
494
+ ApiResponse.new(_response)
495
+ end
496
+
497
+ # Remove a participant from a session
498
+ # This will automatically remove any subscriptions the participant has
499
+ # associated with this session
500
+ # @param [String] account_id Required parameter: Account ID
501
+ # @param [String] participant_id Required parameter: Participant ID
502
+ # @param [String] session_id Required parameter: Session ID
503
+ # @return [void] response from the API call
504
+ def remove_participant_from_session(account_id,
505
+ participant_id,
506
+ session_id)
507
+ # Prepare query url.
508
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
509
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}'
510
+ _query_builder = APIHelper.append_url_with_template_parameters(
511
+ _query_builder,
512
+ 'accountId' => { 'value' => account_id, 'encode' => true },
513
+ 'participantId' => { 'value' => participant_id, 'encode' => true },
514
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
515
+ )
516
+ _query_url = APIHelper.clean_url _query_builder
517
+
518
+ # Prepare and execute HttpRequest.
519
+ _request = config.http_client.delete(
520
+ _query_url
521
+ )
522
+ WebRtcBasicAuth.apply(config, _request)
523
+ _response = execute_request(_request)
524
+
525
+ # Validate response against endpoint and global error codes.
526
+ if _response.status_code == 401
527
+ raise APIException.new(
528
+ 'Unauthorized',
529
+ _response
530
+ )
531
+ elsif _response.status_code == 403
532
+ raise APIException.new(
533
+ 'Access Denied',
534
+ _response
535
+ )
536
+ elsif _response.status_code == 404
537
+ raise APIException.new(
538
+ 'Not Found',
539
+ _response
540
+ )
541
+ end
542
+ unless _response.status_code.between?(200, 208)
543
+ raise ErrorException.new(
544
+ 'Unexpected Error',
545
+ _response
546
+ )
547
+ end
548
+ validate_response(_response)
549
+
550
+ # Return appropriate response type.
551
+ ApiResponse.new(_response)
552
+ end
553
+
554
+ # Get a participant's subscriptions
555
+ # @param [String] account_id Required parameter: Account ID
556
+ # @param [String] participant_id Required parameter: Participant ID
557
+ # @param [String] session_id Required parameter: Session ID
558
+ # @return [Subscriptions] response from the API call
559
+ def get_participant_subscriptions(account_id,
560
+ participant_id,
561
+ session_id)
562
+ # Prepare query url.
563
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
564
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
565
+ _query_builder = APIHelper.append_url_with_template_parameters(
566
+ _query_builder,
567
+ 'accountId' => { 'value' => account_id, 'encode' => true },
568
+ 'participantId' => { 'value' => participant_id, 'encode' => true },
569
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
570
+ )
571
+ _query_url = APIHelper.clean_url _query_builder
572
+
573
+ # Prepare headers.
574
+ _headers = {
575
+ 'accept' => 'application/json'
576
+ }
577
+
578
+ # Prepare and execute HttpRequest.
579
+ _request = config.http_client.get(
580
+ _query_url,
581
+ headers: _headers
582
+ )
583
+ WebRtcBasicAuth.apply(config, _request)
584
+ _response = execute_request(_request)
585
+
586
+ # Validate response against endpoint and global error codes.
587
+ if _response.status_code == 401
588
+ raise APIException.new(
589
+ 'Unauthorized',
590
+ _response
591
+ )
592
+ elsif _response.status_code == 403
593
+ raise APIException.new(
594
+ 'Access Denied',
595
+ _response
596
+ )
597
+ elsif _response.status_code == 404
598
+ raise APIException.new(
599
+ 'Not Found',
600
+ _response
601
+ )
602
+ end
603
+ unless _response.status_code.between?(200, 208)
604
+ raise ErrorException.new(
605
+ 'Unexpected Error',
606
+ _response
607
+ )
608
+ end
609
+ validate_response(_response)
610
+
611
+ # Return appropriate response type.
612
+ decoded = APIHelper.json_deserialize(_response.raw_body)
613
+ ApiResponse.new(
614
+ _response, data: Subscriptions.from_hash(decoded)
615
+ )
616
+ end
617
+
618
+ # Update a participant's subscriptions
619
+ # This is a full update that will replace the participant's subscriptions.
620
+ # First call `getParticipantSubscriptions` if you need the current
621
+ # subscriptions. Call this function with no `Subscriptions` object to remove
622
+ # all subscriptions
623
+ # @param [String] account_id Required parameter: Account ID
624
+ # @param [String] participant_id Required parameter: Participant ID
625
+ # @param [String] session_id Required parameter: Session ID
626
+ # @param [Subscriptions] body Optional parameter: Initial state
627
+ # @return [void] response from the API call
628
+ def update_participant_subscriptions(account_id,
629
+ participant_id,
630
+ session_id,
631
+ body: nil)
632
+ # Prepare query url.
633
+ _query_builder = config.get_base_uri(Server::WEBRTCDEFAULT)
634
+ _query_builder << '/accounts/{accountId}/sessions/{sessionId}/participants/{participantId}/subscriptions'
635
+ _query_builder = APIHelper.append_url_with_template_parameters(
636
+ _query_builder,
637
+ 'accountId' => { 'value' => account_id, 'encode' => true },
638
+ 'participantId' => { 'value' => participant_id, 'encode' => true },
639
+ 'sessionId' => { 'value' => session_id, 'encode' => true }
640
+ )
641
+ _query_url = APIHelper.clean_url _query_builder
642
+
643
+ # Prepare headers.
644
+ _headers = {
645
+ 'content-type' => 'application/json; charset=utf-8'
646
+ }
647
+
648
+ # Prepare and execute HttpRequest.
649
+ _request = config.http_client.put(
650
+ _query_url,
651
+ headers: _headers,
652
+ parameters: body.to_json
653
+ )
654
+ WebRtcBasicAuth.apply(config, _request)
655
+ _response = execute_request(_request)
656
+
657
+ # Validate response against endpoint and global error codes.
658
+ if _response.status_code == 400
659
+ raise APIException.new(
660
+ 'Bad Request',
661
+ _response
662
+ )
663
+ elsif _response.status_code == 401
664
+ raise APIException.new(
665
+ 'Unauthorized',
666
+ _response
667
+ )
668
+ elsif _response.status_code == 403
669
+ raise APIException.new(
670
+ 'Access Denied',
671
+ _response
672
+ )
673
+ elsif _response.status_code == 404
674
+ raise APIException.new(
675
+ 'Not Found',
676
+ _response
677
+ )
678
+ end
679
+ unless _response.status_code.between?(200, 208)
680
+ raise ErrorException.new(
681
+ 'Unexpected Error',
682
+ _response
683
+ )
684
+ end
685
+ validate_response(_response)
686
+
687
+ # Return appropriate response type.
688
+ ApiResponse.new(_response)
689
+ end
690
+ end
691
+ end
692
+ end