bandwidth-sdk 2.1.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +85 -70
- data/lib/bandwidth.rb +31 -2
- data/lib/bandwidth/api_helper.rb +14 -9
- data/lib/bandwidth/client.rb +22 -2
- data/lib/bandwidth/configuration.rb +67 -12
- data/lib/bandwidth/http/api_response.rb +2 -0
- data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
- data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
- data/lib/bandwidth/http/faraday_client.rb +5 -2
- data/lib/bandwidth/messaging_lib/messaging.rb +5 -3
- data/lib/bandwidth/messaging_lib/messaging/client.rb +13 -2
- data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +191 -113
- data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message.rb +23 -13
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_message_item.rb +125 -0
- data/lib/bandwidth/messaging_lib/messaging/models/bandwidth_messages_list.rb +60 -0
- data/lib/bandwidth/messaging_lib/messaging/models/media.rb +4 -4
- data/lib/bandwidth/messaging_lib/messaging/models/message_request.rb +21 -8
- data/lib/bandwidth/messaging_lib/messaging/models/page_info.rb +62 -0
- data/lib/bandwidth/messaging_lib/messaging/models/priority_enum.rb +19 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +22 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +51 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/mfa_controller.rb +209 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/error_with_request_exception.rb +34 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/forbidden_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/unauthorized_request_exception.rb +29 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +75 -0
- data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
- data/lib/bandwidth/utilities/file_wrapper.rb +17 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +28 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +32 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +13 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +7 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +9 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/redirect.rb +5 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/ring.rb +15 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/sip_uri.rb +25 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/start_gather.rb +20 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
- data/lib/bandwidth/voice_lib/bxml/verbs/stop_gather.rb +14 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/tag.rb +13 -0
- data/lib/bandwidth/voice_lib/bxml/verbs/transfer.rb +14 -3
- data/lib/bandwidth/voice_lib/voice.rb +19 -4
- data/lib/bandwidth/voice_lib/voice/client.rb +13 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +1219 -133
- data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
- data/lib/bandwidth/voice_lib/voice/models/answer_fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +56 -2
- data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
- data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +135 -12
- data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +37 -1
- data/lib/bandwidth/voice_lib/voice/models/api_modify_conference_request.rb +107 -0
- data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_detail.rb +108 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_event_method_enum.rb +35 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_member_detail.rb +80 -0
- data/lib/bandwidth/voice_lib/voice/models/conference_recording_metadata_response.rb +126 -0
- data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
- data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
- data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +66 -28
- data/lib/bandwidth/voice_lib/voice/models/redirect_fallback_method_enum.rb +17 -0
- data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
- data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
- data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
- data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +29 -0
- data/lib/bandwidth/voice_lib/voice/models/status3_enum.rb +32 -0
- data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
- data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
- data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
- data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
- data/lib/bandwidth/web_rtc_lib/utils/web_rtc_transfer.rb +13 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc.rb +22 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +51 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +692 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
- data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/device_api_version_enum.rb +17 -0
- data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +92 -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
- data/test/integration/test_integration.rb +570 -0
- metadata +132 -19
- data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
- data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
- data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
@@ -0,0 +1,17 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# RedirectFallbackMethod.
|
8
|
+
class RedirectFallbackMethodEnum
|
9
|
+
REDIRECT_FALLBACK_METHOD_ENUM = [
|
10
|
+
# TODO: Write general description for POST
|
11
|
+
POST = 'POST'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for GET
|
14
|
+
GET = 'GET'.freeze
|
15
|
+
].freeze
|
16
|
+
end
|
17
|
+
end
|
@@ -7,14 +7,11 @@ module Bandwidth
|
|
7
7
|
# State1.
|
8
8
|
class State1Enum
|
9
9
|
STATE1_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 RECORDING
|
17
|
-
RECORDING = 'RECORDING'.freeze
|
13
|
+
# TODO: Write general description for COMPLETED
|
14
|
+
COMPLETED = 'completed'.freeze
|
18
15
|
].freeze
|
19
16
|
end
|
20
17
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# State2.
|
8
|
+
class State2Enum
|
9
|
+
STATE2_ENUM = [
|
10
|
+
# TODO: Write general description for NOT_RECORDING
|
11
|
+
NOT_RECORDING = 'NOT_RECORDING'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for PAUSED
|
14
|
+
PAUSED = 'PAUSED'.freeze,
|
15
|
+
|
16
|
+
# TODO: Write general description for RECORDING
|
17
|
+
RECORDING = 'RECORDING'.freeze
|
18
|
+
].freeze
|
19
|
+
end
|
20
|
+
end
|
@@ -7,11 +7,14 @@ module Bandwidth
|
|
7
7
|
# State.
|
8
8
|
class StateEnum
|
9
9
|
STATE_ENUM = [
|
10
|
-
# TODO: Write general description for
|
11
|
-
|
10
|
+
# TODO: Write general description for DISCONNECTED
|
11
|
+
DISCONNECTED = 'DISCONNECTED'.freeze,
|
12
12
|
|
13
|
-
# TODO: Write general description for
|
14
|
-
|
13
|
+
# TODO: Write general description for ANSWERED
|
14
|
+
ANSWERED = 'ANSWERED'.freeze,
|
15
|
+
|
16
|
+
# TODO: Write general description for INITIATED
|
17
|
+
INITIATED = 'INITIATED'.freeze
|
15
18
|
].freeze
|
16
19
|
end
|
17
20
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Status1.
|
8
|
+
class Status1Enum
|
9
|
+
STATUS1_ENUM = [
|
10
|
+
# TODO: Write general description for PROCESSING
|
11
|
+
PROCESSING = 'processing'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for PARTIAL
|
14
|
+
PARTIAL = 'partial'.freeze,
|
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,
|
24
|
+
|
25
|
+
# TODO: Write general description for ALREADYINPROGRESS
|
26
|
+
ALREADYINPROGRESS = 'already-in-progress'.freeze
|
27
|
+
].freeze
|
28
|
+
end
|
29
|
+
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
|
+
# Status3.
|
8
|
+
class Status3Enum
|
9
|
+
STATUS3_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
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Status.
|
8
|
+
class StatusEnum
|
9
|
+
STATUS_ENUM = [
|
10
|
+
# TODO: Write general description for ACTIVE
|
11
|
+
ACTIVE = 'active'.freeze,
|
12
|
+
|
13
|
+
# TODO: Write general description for COMPLETED
|
14
|
+
COMPLETED = 'completed'.freeze
|
15
|
+
].freeze
|
16
|
+
end
|
17
|
+
end
|
@@ -4,28 +4,28 @@
|
|
4
4
|
# ( https://apimatic.io ).
|
5
5
|
|
6
6
|
module Bandwidth
|
7
|
-
#
|
8
|
-
class
|
7
|
+
# Transcript Model.
|
8
|
+
class Transcript < BaseModel
|
9
9
|
# TODO: Write general description for this method
|
10
10
|
# @return [String]
|
11
|
-
attr_accessor :
|
11
|
+
attr_accessor :text
|
12
12
|
|
13
13
|
# TODO: Write general description for this method
|
14
|
-
# @return [
|
15
|
-
attr_accessor :
|
14
|
+
# @return [Float]
|
15
|
+
attr_accessor :confidence
|
16
16
|
|
17
17
|
# A mapping from model property names to API property names.
|
18
18
|
def self.names
|
19
19
|
@_hash = {} if @_hash.nil?
|
20
|
-
@_hash['
|
21
|
-
@_hash['
|
20
|
+
@_hash['text'] = 'text'
|
21
|
+
@_hash['confidence'] = 'confidence'
|
22
22
|
@_hash
|
23
23
|
end
|
24
24
|
|
25
|
-
def initialize(
|
26
|
-
|
27
|
-
@
|
28
|
-
@
|
25
|
+
def initialize(text = nil,
|
26
|
+
confidence = nil)
|
27
|
+
@text = text
|
28
|
+
@confidence = confidence
|
29
29
|
end
|
30
30
|
|
31
31
|
# Creates an instance of the object from a hash.
|
@@ -33,12 +33,12 @@ module Bandwidth
|
|
33
33
|
return nil unless hash
|
34
34
|
|
35
35
|
# Extract variables from the hash.
|
36
|
-
|
37
|
-
|
36
|
+
text = hash['text']
|
37
|
+
confidence = hash['confidence']
|
38
38
|
|
39
39
|
# Create object from extracted values.
|
40
|
-
|
41
|
-
|
40
|
+
Transcript.new(text,
|
41
|
+
confidence)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# Transcription Model.
|
8
|
+
class Transcription < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :id
|
12
|
+
|
13
|
+
# TODO: Write general description for this method
|
14
|
+
# @return [Status3Enum]
|
15
|
+
attr_accessor :status
|
16
|
+
|
17
|
+
# TODO: Write general description for this method
|
18
|
+
# @return [String]
|
19
|
+
attr_accessor :completed_time
|
20
|
+
|
21
|
+
# TODO: Write general description for this method
|
22
|
+
# @return [String]
|
23
|
+
attr_accessor :url
|
24
|
+
|
25
|
+
# A mapping from model property names to API property names.
|
26
|
+
def self.names
|
27
|
+
@_hash = {} if @_hash.nil?
|
28
|
+
@_hash['id'] = 'id'
|
29
|
+
@_hash['status'] = 'status'
|
30
|
+
@_hash['completed_time'] = 'completedTime'
|
31
|
+
@_hash['url'] = 'url'
|
32
|
+
@_hash
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize(id = nil,
|
36
|
+
status = nil,
|
37
|
+
completed_time = nil,
|
38
|
+
url = nil)
|
39
|
+
@id = id
|
40
|
+
@status = status
|
41
|
+
@completed_time = completed_time
|
42
|
+
@url = url
|
43
|
+
end
|
44
|
+
|
45
|
+
# Creates an instance of the object from a hash.
|
46
|
+
def self.from_hash(hash)
|
47
|
+
return nil unless hash
|
48
|
+
|
49
|
+
# Extract variables from the hash.
|
50
|
+
id = hash['id']
|
51
|
+
status = hash['status']
|
52
|
+
completed_time = hash['completedTime']
|
53
|
+
url = hash['url']
|
54
|
+
|
55
|
+
# Create object from extracted values.
|
56
|
+
Transcription.new(id,
|
57
|
+
status,
|
58
|
+
completed_time,
|
59
|
+
url)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# bandwidth
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Bandwidth
|
7
|
+
# TranscriptionResponse Model.
|
8
|
+
class TranscriptionResponse < BaseModel
|
9
|
+
# TODO: Write general description for this method
|
10
|
+
# @return [List of Transcript]
|
11
|
+
attr_accessor :transcripts
|
12
|
+
|
13
|
+
# A mapping from model property names to API property names.
|
14
|
+
def self.names
|
15
|
+
@_hash = {} if @_hash.nil?
|
16
|
+
@_hash['transcripts'] = 'transcripts'
|
17
|
+
@_hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(transcripts = nil)
|
21
|
+
@transcripts = transcripts
|
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
|
+
# Parameter is an array, so we need to iterate through it
|
30
|
+
transcripts = nil
|
31
|
+
unless hash['transcripts'].nil?
|
32
|
+
transcripts = []
|
33
|
+
hash['transcripts'].each do |structure|
|
34
|
+
transcripts << (Transcript.from_hash(structure) if structure)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# Create object from extracted values.
|
39
|
+
TranscriptionResponse.new(transcripts)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# web_rtc_transfer.rb
|
2
|
+
#
|
3
|
+
# Custom transfer BXML for WebRtc
|
4
|
+
#
|
5
|
+
# @copyright Bandwidth INC
|
6
|
+
|
7
|
+
module Bandwidth
|
8
|
+
module WebRtc
|
9
|
+
def generate_bxml(device_token, sip_uri="sip:sipx.webrtc.bandwidth.com:5060")
|
10
|
+
return '<?xml version="1.0" encoding="UTF-8"?><Response><Transfer><SipUri uui="%s;encoding=jwt">%s</SipUri></Transfer></Response>' % [device_token, sip_uri]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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/device_api_version_enum.rb'
|
16
|
+
require_relative 'web_rtc/models/publish_permission_enum.rb'
|
17
|
+
|
18
|
+
# Exceptions
|
19
|
+
require_relative 'web_rtc/exceptions/error_exception.rb'
|
20
|
+
# Controllers
|
21
|
+
require_relative 'web_rtc/controllers/base_controller.rb'
|
22
|
+
require_relative 'web_rtc/controllers/api_controller.rb'
|
@@ -0,0 +1,51 @@
|
|
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
|
+
base_url: 'https://www.example.com',
|
21
|
+
messaging_basic_auth_user_name: 'TODO: Replace',
|
22
|
+
messaging_basic_auth_password: 'TODO: Replace',
|
23
|
+
two_factor_auth_basic_auth_user_name: 'TODO: Replace',
|
24
|
+
two_factor_auth_basic_auth_password: 'TODO: Replace',
|
25
|
+
voice_basic_auth_user_name: 'TODO: Replace',
|
26
|
+
voice_basic_auth_password: 'TODO: Replace',
|
27
|
+
web_rtc_basic_auth_user_name: 'TODO: Replace',
|
28
|
+
web_rtc_basic_auth_password: 'TODO: Replace',
|
29
|
+
config: nil)
|
30
|
+
@config = if config.nil?
|
31
|
+
Configuration.new(timeout: timeout,
|
32
|
+
max_retries: max_retries,
|
33
|
+
retry_interval: retry_interval,
|
34
|
+
backoff_factor: backoff_factor,
|
35
|
+
environment: environment,
|
36
|
+
base_url: base_url,
|
37
|
+
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
38
|
+
messaging_basic_auth_password: messaging_basic_auth_password,
|
39
|
+
two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
|
40
|
+
two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
|
41
|
+
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
42
|
+
voice_basic_auth_password: voice_basic_auth_password,
|
43
|
+
web_rtc_basic_auth_user_name: web_rtc_basic_auth_user_name,
|
44
|
+
web_rtc_basic_auth_password: web_rtc_basic_auth_password)
|
45
|
+
else
|
46
|
+
config
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
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' => false }
|
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' => false },
|
91
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
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' => false },
|
152
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
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' => false }
|
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' => false },
|
268
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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' => false },
|
329
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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' => false },
|
381
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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' => false },
|
449
|
+
'sessionId' => { 'value' => session_id, 'encode' => false },
|
450
|
+
'participantId' => { 'value' => participant_id, 'encode' => false }
|
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' => false },
|
513
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
514
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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' => false },
|
568
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
569
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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' => false },
|
638
|
+
'participantId' => { 'value' => participant_id, 'encode' => false },
|
639
|
+
'sessionId' => { 'value' => session_id, 'encode' => false }
|
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
|