bandwidth-sdk 3.6.0 → 3.7.0

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