bandwidth-sdk 3.2.0 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bandwidth.rb +2 -0
- data/lib/bandwidth/client.rb +11 -2
- data/lib/bandwidth/configuration.rb +23 -5
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
- data/lib/bandwidth/messaging_lib/messaging/client.rb +7 -2
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +1 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +7 -2
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +24 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +30 -4
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +33 -10
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
- data/lib/bandwidth/voice_lib/voice.rb +2 -0
- data/lib/bandwidth/voice_lib/voice/client.rb +7 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +145 -78
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
- data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +4 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +8 -14
- data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +4 -13
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +1 -1
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +682 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/exceptions/error_exception.rb +34 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
- metadata +19 -2
@@ -50,6 +50,14 @@ module Bandwidth
|
|
50
50
|
# @return [String]
|
51
51
|
attr_accessor :application_id
|
52
52
|
|
53
|
+
# Format is E164
|
54
|
+
# @return [String]
|
55
|
+
attr_accessor :obfuscated_to
|
56
|
+
|
57
|
+
# Format is E164
|
58
|
+
# @return [String]
|
59
|
+
attr_accessor :obfuscated_from
|
60
|
+
|
53
61
|
# A mapping from model property names to API property names.
|
54
62
|
def self.names
|
55
63
|
@_hash = {} if @_hash.nil?
|
@@ -64,6 +72,8 @@ module Bandwidth
|
|
64
72
|
@_hash['disconnect_method'] = 'disconnectMethod'
|
65
73
|
@_hash['tag'] = 'tag'
|
66
74
|
@_hash['application_id'] = 'applicationId'
|
75
|
+
@_hash['obfuscated_to'] = 'obfuscatedTo'
|
76
|
+
@_hash['obfuscated_from'] = 'obfuscatedFrom'
|
67
77
|
@_hash
|
68
78
|
end
|
69
79
|
|
@@ -77,7 +87,9 @@ module Bandwidth
|
|
77
87
|
answer_method = nil,
|
78
88
|
disconnect_url = nil,
|
79
89
|
disconnect_method = nil,
|
80
|
-
tag = nil
|
90
|
+
tag = nil,
|
91
|
+
obfuscated_to = nil,
|
92
|
+
obfuscated_from = nil)
|
81
93
|
@from = from
|
82
94
|
@to = to
|
83
95
|
@call_timeout = call_timeout
|
@@ -89,6 +101,8 @@ module Bandwidth
|
|
89
101
|
@disconnect_method = disconnect_method
|
90
102
|
@tag = tag
|
91
103
|
@application_id = application_id
|
104
|
+
@obfuscated_to = obfuscated_to
|
105
|
+
@obfuscated_from = obfuscated_from
|
92
106
|
end
|
93
107
|
|
94
108
|
# Creates an instance of the object from a hash.
|
@@ -107,6 +121,8 @@ module Bandwidth
|
|
107
121
|
disconnect_url = hash['disconnectUrl']
|
108
122
|
disconnect_method = hash['disconnectMethod']
|
109
123
|
tag = hash['tag']
|
124
|
+
obfuscated_to = hash['obfuscatedTo']
|
125
|
+
obfuscated_from = hash['obfuscatedFrom']
|
110
126
|
|
111
127
|
# Create object from extracted values.
|
112
128
|
ApiCreateCallRequest.new(from,
|
@@ -119,7 +135,9 @@ module Bandwidth
|
|
119
135
|
answer_method,
|
120
136
|
disconnect_url,
|
121
137
|
disconnect_method,
|
122
|
-
tag
|
138
|
+
tag,
|
139
|
+
obfuscated_to,
|
140
|
+
obfuscated_from)
|
123
141
|
end
|
124
142
|
end
|
125
143
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# CallEngineModifyConferenceRequest Model.
|
8
|
+
class CallEngineModifyConferenceRequest < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [StatusEnum]
|
11
|
+
attr_accessor :status
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['status'] = 'status'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(status = nil)
|
21
|
+
@status = status
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates an instance of the object from a hash.
|
25
|
+
def self.from_hash(hash)
|
26
|
+
return nil unless hash
|
27
|
+
|
28
|
+
# Extract variables from the hash.
|
29
|
+
status = hash['status']
|
30
|
+
|
31
|
+
# Create object from extracted values.
|
32
|
+
CallEngineModifyConferenceRequest.new(status)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -38,7 +38,10 @@ module Bandwidth
|
|
38
38
|
NODECAPACITYEXCEEDED = 'node-capacity-exceeded'.freeze,
|
39
39
|
|
40
40
|
# TODO: Write general description for UNKNOWN
|
41
|
-
UNKNOWN = 'unknown'.freeze
|
41
|
+
UNKNOWN = 'unknown'.freeze,
|
42
|
+
|
43
|
+
# TODO: Write general description for APPLICATIONERROR
|
44
|
+
APPLICATIONERROR = 'application-error'.freeze
|
42
45
|
].freeze
|
43
46
|
end
|
44
47
|
end
|
@@ -7,26 +7,20 @@ module Bandwidth
|
|
7
7
|
# Status1.
|
8
8
|
class Status1Enum
|
9
9
|
STATUS1_ENUM = [
|
10
|
-
# TODO: Write general description for REQUESTED
|
11
|
-
REQUESTED = 'requested'.freeze,
|
12
|
-
|
13
|
-
# TODO: Write general description for NONE
|
14
|
-
NONE = 'none'.freeze,
|
15
|
-
|
16
10
|
# TODO: Write general description for PROCESSING
|
17
11
|
PROCESSING = 'processing'.freeze,
|
18
12
|
|
19
|
-
# TODO: Write general description for
|
20
|
-
|
13
|
+
# TODO: Write general description for PARTIAL
|
14
|
+
PARTIAL = 'partial'.freeze,
|
21
15
|
|
22
|
-
# TODO: Write general description for
|
23
|
-
|
16
|
+
# TODO: Write general description for COMPLETE
|
17
|
+
COMPLETE = 'complete'.freeze,
|
24
18
|
|
25
|
-
# TODO: Write general description for
|
26
|
-
|
19
|
+
# TODO: Write general description for DELETED
|
20
|
+
DELETED = 'deleted'.freeze,
|
27
21
|
|
28
|
-
# TODO: Write general description for
|
29
|
-
|
22
|
+
# TODO: Write general description for ERROR
|
23
|
+
ERROR = 'error'.freeze
|
30
24
|
].freeze
|
31
25
|
end
|
32
26
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Status2.
|
8
|
+
class Status2Enum
|
9
|
+
STATUS2_ENUM = [
|
10
|
+
# TODO: Write general description for NONE
|
11
|
+
NONE = 'none'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for PROCESSING
|
14
|
+
PROCESSING = 'processing'.freeze,
|
15
|
+
|
16
|
+
# TODO: Write general description for AVAILABLE
|
17
|
+
AVAILABLE = 'available'.freeze,
|
18
|
+
|
19
|
+
# TODO: Write general description for ERROR
|
20
|
+
ERROR = 'error'.freeze,
|
21
|
+
|
22
|
+
# TODO: Write general description for TIMEOUT
|
23
|
+
TIMEOUT = 'timeout'.freeze,
|
24
|
+
|
25
|
+
# TODO: Write general description for FILESIZETOOBIG
|
26
|
+
FILESIZETOOBIG = 'file-size-too-big'.freeze,
|
27
|
+
|
28
|
+
# TODO: Write general description for FILESIZETOOSMALL
|
29
|
+
FILESIZETOOSMALL = 'file-size-too-small'.freeze
|
30
|
+
].freeze
|
31
|
+
end
|
32
|
+
end
|
@@ -7,20 +7,11 @@ module Bandwidth
|
|
7
7
|
# Status.
|
8
8
|
class StatusEnum
|
9
9
|
STATUS_ENUM = [
|
10
|
-
# TODO: Write general description for
|
11
|
-
|
10
|
+
# TODO: Write general description for ACTIVE
|
11
|
+
ACTIVE = 'active'.freeze,
|
12
12
|
|
13
|
-
# TODO: Write general description for
|
14
|
-
|
15
|
-
|
16
|
-
# TODO: Write general description for COMPLETE
|
17
|
-
COMPLETE = 'complete'.freeze,
|
18
|
-
|
19
|
-
# TODO: Write general description for DELETED
|
20
|
-
DELETED = 'deleted'.freeze,
|
21
|
-
|
22
|
-
# TODO: Write general description for ERROR
|
23
|
-
ERROR = 'error'.freeze
|
13
|
+
# TODO: Write general description for COMPLETED
|
14
|
+
COMPLETED = 'completed'.freeze
|
24
15
|
].freeze
|
25
16
|
end
|
26
17
|
end
|
@@ -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
|