bandwidth-sdk 3.3.0 → 3.8.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/api_helper.rb +14 -9
- 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/api_controller.rb +18 -12
- 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 +38 -9
- 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/voice.rb +5 -0
- data/lib/bandwidth/voice_lib/voice/client.rb +7 -2
- data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +352 -115
- 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/conference_detail.rb +105 -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/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 +692 -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 +22 -2
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb
ADDED
@@ -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
|
+
# InvalidRequest class.
|
8
|
+
class InvalidRequestException < APIException
|
9
|
+
# An error message pertaining to what the issue could be
|
10
|
+
# @return [String]
|
11
|
+
attr_accessor :result
|
12
|
+
|
13
|
+
# The constructor.
|
14
|
+
# @param [String] The reason for raising an exception.
|
15
|
+
# @param [HttpResponse] The HttpReponse of the API call.
|
16
|
+
def initialize(reason, response)
|
17
|
+
super(reason, response)
|
18
|
+
hash = APIHelper.json_deserialize(@response.raw_body)
|
19
|
+
unbox(hash)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Populates this object by extracting properties from a hash.
|
23
|
+
# @param [Hash] The deserialized response sent by the server in the
|
24
|
+
# response body.
|
25
|
+
def unbox(hash)
|
26
|
+
@result = hash['result']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb
CHANGED
@@ -6,22 +6,38 @@
|
|
6
6
|
module Bandwidth
|
7
7
|
# TwoFactorCodeRequestSchema Model.
|
8
8
|
class TwoFactorCodeRequestSchema < BaseModel
|
9
|
-
#
|
9
|
+
# The phone number to send the 2fa code to.
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :to
|
12
12
|
|
13
|
-
#
|
13
|
+
# The application phone number, the sender of the 2fa code.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :from
|
16
16
|
|
17
|
-
#
|
17
|
+
# The application unique ID, obtained from Bandwidth.
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :application_id
|
20
20
|
|
21
|
-
#
|
21
|
+
# An optional field to denote what scope or action the 2fa code is
|
22
|
+
# addressing. If not supplied, defaults to "2FA".
|
22
23
|
# @return [String]
|
23
24
|
attr_accessor :scope
|
24
25
|
|
26
|
+
# The message format of the 2fa code. There are three values that the
|
27
|
+
# system will replace "{CODE}", "{NAME}", "{SCOPE}". The "{SCOPE}" and
|
28
|
+
# "{NAME} value template are optional, while "{CODE}" must be supplied. As
|
29
|
+
# the name would suggest, code will be replace with the actual 2fa code.
|
30
|
+
# Name is replaced with the application name, configured during provisioning
|
31
|
+
# of 2fa. The scope value is the same value sent during the call and
|
32
|
+
# partitioned by the server.
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :message
|
35
|
+
|
36
|
+
# The number of digits for your 2fa code. The valid number ranges from 2 to
|
37
|
+
# 8, inclusively.
|
38
|
+
# @return [Float]
|
39
|
+
attr_accessor :digits
|
40
|
+
|
25
41
|
# A mapping from model property names to API property names.
|
26
42
|
def self.names
|
27
43
|
@_hash = {} if @_hash.nil?
|
@@ -29,17 +45,23 @@ module Bandwidth
|
|
29
45
|
@_hash['from'] = 'from'
|
30
46
|
@_hash['application_id'] = 'applicationId'
|
31
47
|
@_hash['scope'] = 'scope'
|
48
|
+
@_hash['message'] = 'message'
|
49
|
+
@_hash['digits'] = 'digits'
|
32
50
|
@_hash
|
33
51
|
end
|
34
52
|
|
35
53
|
def initialize(to = nil,
|
36
54
|
from = nil,
|
37
55
|
application_id = nil,
|
56
|
+
message = nil,
|
57
|
+
digits = nil,
|
38
58
|
scope = nil)
|
39
59
|
@to = to
|
40
60
|
@from = from
|
41
61
|
@application_id = application_id
|
42
62
|
@scope = scope
|
63
|
+
@message = message
|
64
|
+
@digits = digits
|
43
65
|
end
|
44
66
|
|
45
67
|
# Creates an instance of the object from a hash.
|
@@ -50,12 +72,16 @@ module Bandwidth
|
|
50
72
|
to = hash['to']
|
51
73
|
from = hash['from']
|
52
74
|
application_id = hash['applicationId']
|
75
|
+
message = hash['message']
|
76
|
+
digits = hash['digits']
|
53
77
|
scope = hash['scope']
|
54
78
|
|
55
79
|
# Create object from extracted values.
|
56
80
|
TwoFactorCodeRequestSchema.new(to,
|
57
81
|
from,
|
58
82
|
application_id,
|
83
|
+
message,
|
84
|
+
digits,
|
59
85
|
scope)
|
60
86
|
end
|
61
87
|
end
|
data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb
CHANGED
@@ -6,23 +6,36 @@
|
|
6
6
|
module Bandwidth
|
7
7
|
# TwoFactorVerifyRequestSchema Model.
|
8
8
|
class TwoFactorVerifyRequestSchema < BaseModel
|
9
|
-
#
|
9
|
+
# The phone number to send the 2fa code to.
|
10
10
|
# @return [String]
|
11
11
|
attr_accessor :to
|
12
12
|
|
13
|
-
#
|
13
|
+
# The application phone number, the sender of the 2fa code.
|
14
14
|
# @return [String]
|
15
15
|
attr_accessor :from
|
16
16
|
|
17
|
-
#
|
17
|
+
# The application unique ID, obtained from Bandwidth.
|
18
18
|
# @return [String]
|
19
19
|
attr_accessor :application_id
|
20
20
|
|
21
|
-
#
|
21
|
+
# An optional field to denote what scope or action the 2fa code is
|
22
|
+
# addressing. If not supplied, defaults to "2FA".
|
22
23
|
# @return [String]
|
23
24
|
attr_accessor :scope
|
24
25
|
|
25
|
-
#
|
26
|
+
# The number of digits for your 2fa code. The valid number ranges from 2 to
|
27
|
+
# 8, inclusively.
|
28
|
+
# @return [Float]
|
29
|
+
attr_accessor :digits
|
30
|
+
|
31
|
+
# The time period, in minutes, to validate the 2fa code. By setting this to
|
32
|
+
# 3 minutes, it will mean any code generated within the last 3 minutes are
|
33
|
+
# still valid. The valid range for expiration time is between 0 and 15
|
34
|
+
# minutes, exclusively and inclusively, respectively.
|
35
|
+
# @return [Float]
|
36
|
+
attr_accessor :expiration_time_in_minutes
|
37
|
+
|
38
|
+
# The generated 2fa code to check if valid
|
26
39
|
# @return [String]
|
27
40
|
attr_accessor :code
|
28
41
|
|
@@ -33,6 +46,8 @@ module Bandwidth
|
|
33
46
|
@_hash['from'] = 'from'
|
34
47
|
@_hash['application_id'] = 'applicationId'
|
35
48
|
@_hash['scope'] = 'scope'
|
49
|
+
@_hash['digits'] = 'digits'
|
50
|
+
@_hash['expiration_time_in_minutes'] = 'expirationTimeInMinutes'
|
36
51
|
@_hash['code'] = 'code'
|
37
52
|
@_hash
|
38
53
|
end
|
@@ -40,12 +55,16 @@ module Bandwidth
|
|
40
55
|
def initialize(to = nil,
|
41
56
|
from = nil,
|
42
57
|
application_id = nil,
|
43
|
-
|
44
|
-
|
58
|
+
digits = nil,
|
59
|
+
expiration_time_in_minutes = nil,
|
60
|
+
code = nil,
|
61
|
+
scope = nil)
|
45
62
|
@to = to
|
46
63
|
@from = from
|
47
64
|
@application_id = application_id
|
48
65
|
@scope = scope
|
66
|
+
@digits = digits
|
67
|
+
@expiration_time_in_minutes = expiration_time_in_minutes
|
49
68
|
@code = code
|
50
69
|
end
|
51
70
|
|
@@ -57,15 +76,19 @@ module Bandwidth
|
|
57
76
|
to = hash['to']
|
58
77
|
from = hash['from']
|
59
78
|
application_id = hash['applicationId']
|
60
|
-
|
79
|
+
digits = hash['digits']
|
80
|
+
expiration_time_in_minutes = hash['expirationTimeInMinutes']
|
61
81
|
code = hash['code']
|
82
|
+
scope = hash['scope']
|
62
83
|
|
63
84
|
# Create object from extracted values.
|
64
85
|
TwoFactorVerifyRequestSchema.new(to,
|
65
86
|
from,
|
66
87
|
application_id,
|
67
|
-
|
68
|
-
|
88
|
+
digits,
|
89
|
+
expiration_time_in_minutes,
|
90
|
+
code,
|
91
|
+
scope)
|
69
92
|
end
|
70
93
|
end
|
71
94
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'xml_verb'
|
2
|
+
|
3
|
+
module Bandwidth
|
4
|
+
module Voice
|
5
|
+
# The Bridge verb allows you to connect 2 calls
|
6
|
+
class Bridge
|
7
|
+
include XmlVerb
|
8
|
+
|
9
|
+
def to_bxml(xml)
|
10
|
+
xml.Bridge(call_id, compact_hash({
|
11
|
+
'bridgeCompleteUrl' => bridge_complete_url,
|
12
|
+
'bridgeCompleteMethod' => bridge_complete_method,
|
13
|
+
'bridgeTargetCompleteUrl' => bridge_target_complete_url,
|
14
|
+
'bridgeTargetCompleteMethod' => bridge_target_complete_method,
|
15
|
+
'username' => username,
|
16
|
+
'password' => password,
|
17
|
+
'tag' => tag
|
18
|
+
}))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require_relative 'xml_verb'
|
2
|
+
|
3
|
+
module Bandwidth
|
4
|
+
module Voice
|
5
|
+
# The Conference verb is used to add callees to conferences
|
6
|
+
class Conference
|
7
|
+
include XmlVerb
|
8
|
+
|
9
|
+
def to_bxml(xml)
|
10
|
+
if not call_ids_to_coach.nil?
|
11
|
+
coach_ids = call_ids_to_coach.instance_of?(String) ? call_ids_to_coach : call_ids_to_coach.join(",")
|
12
|
+
else
|
13
|
+
coach_ids = nil
|
14
|
+
end
|
15
|
+
xml.Conference(conference_name, compact_hash({
|
16
|
+
'mute' => mute,
|
17
|
+
'hold' => hold,
|
18
|
+
'callIdsToCoach' => coach_ids,
|
19
|
+
'conferenceEventUrl' => conference_event_url,
|
20
|
+
'conferenceEventMethod' => conference_event_method,
|
21
|
+
'username' => username,
|
22
|
+
'password' => password,
|
23
|
+
'tag' => tag
|
24
|
+
}))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -12,6 +12,9 @@ require_relative 'voice/models/api_call_state_response.rb'
|
|
12
12
|
require_relative 'voice/models/api_create_call_request.rb'
|
13
13
|
require_relative 'voice/models/api_modify_call_request.rb'
|
14
14
|
require_relative 'voice/models/api_transcribe_recording_request.rb'
|
15
|
+
require_relative 'voice/models/call_engine_modify_conference_request.rb'
|
16
|
+
require_relative 'voice/models/conference_detail.rb'
|
17
|
+
require_relative 'voice/models/conference_member_detail.rb'
|
15
18
|
require_relative 'voice/models/modify_call_recording_state.rb'
|
16
19
|
require_relative 'voice/models/recording_metadata_response.rb'
|
17
20
|
require_relative 'voice/models/transcript.rb'
|
@@ -19,6 +22,7 @@ require_relative 'voice/models/transcription.rb'
|
|
19
22
|
require_relative 'voice/models/transcription_response.rb'
|
20
23
|
require_relative 'voice/models/answer_method_enum.rb'
|
21
24
|
require_relative 'voice/models/callback_method_enum.rb'
|
25
|
+
require_relative 'voice/models/conference_event_method_enum.rb'
|
22
26
|
require_relative 'voice/models/direction_enum.rb'
|
23
27
|
require_relative 'voice/models/disconnect_cause_enum.rb'
|
24
28
|
require_relative 'voice/models/disconnect_method_enum.rb'
|
@@ -29,6 +33,7 @@ require_relative 'voice/models/state1_enum.rb'
|
|
29
33
|
require_relative 'voice/models/state2_enum.rb'
|
30
34
|
require_relative 'voice/models/status_enum.rb'
|
31
35
|
require_relative 'voice/models/status1_enum.rb'
|
36
|
+
require_relative 'voice/models/status2_enum.rb'
|
32
37
|
|
33
38
|
# Exceptions
|
34
39
|
require_relative 'voice/exceptions/api_error_response_exception.rb'
|
@@ -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',
|
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
|
@@ -22,7 +22,7 @@ module Voice
|
|
22
22
|
_query_builder << '/api/v2/accounts/{accountId}/calls'
|
23
23
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
24
24
|
_query_builder,
|
25
|
-
'accountId' => account_id
|
25
|
+
'accountId' => { 'value' => account_id, 'encode' => true }
|
26
26
|
)
|
27
27
|
_query_url = APIHelper.clean_url _query_builder
|
28
28
|
|
@@ -44,20 +44,19 @@ module Voice
|
|
44
44
|
# Validate response against endpoint and global error codes.
|
45
45
|
if _response.status_code == 400
|
46
46
|
raise ApiErrorResponseException.new(
|
47
|
-
'Something\'s not quite right...
|
48
|
-
'
|
49
|
-
' before trying again.',
|
47
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
48
|
+
' fix it before trying again.',
|
50
49
|
_response
|
51
50
|
)
|
52
51
|
elsif _response.status_code == 401
|
53
52
|
raise APIException.new(
|
54
|
-
'Please
|
53
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
54
|
+
' credentials to authenticate to the API.',
|
55
55
|
_response
|
56
56
|
)
|
57
57
|
elsif _response.status_code == 403
|
58
58
|
raise ApiErrorResponseException.new(
|
59
|
-
'
|
60
|
-
' the Bandwidth Dashboard.',
|
59
|
+
'User unauthorized to perform this action.',
|
61
60
|
_response
|
62
61
|
)
|
63
62
|
elsif _response.status_code == 404
|
@@ -87,7 +86,9 @@ module Voice
|
|
87
86
|
|
88
87
|
# Return appropriate response type.
|
89
88
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
90
|
-
ApiResponse.new(
|
89
|
+
ApiResponse.new(
|
90
|
+
_response, data: ApiCallResponse.from_hash(decoded)
|
91
|
+
)
|
91
92
|
end
|
92
93
|
|
93
94
|
# Returns near-realtime metadata about the specified call
|
@@ -101,8 +102,8 @@ module Voice
|
|
101
102
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
|
102
103
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
103
104
|
_query_builder,
|
104
|
-
'accountId' => account_id,
|
105
|
-
'callId' => call_id
|
105
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
106
|
+
'callId' => { 'value' => call_id, 'encode' => true }
|
106
107
|
)
|
107
108
|
_query_url = APIHelper.clean_url _query_builder
|
108
109
|
|
@@ -122,20 +123,19 @@ module Voice
|
|
122
123
|
# Validate response against endpoint and global error codes.
|
123
124
|
if _response.status_code == 400
|
124
125
|
raise ApiErrorResponseException.new(
|
125
|
-
'Something\'s not quite right...
|
126
|
-
'
|
127
|
-
' before trying again.',
|
126
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
127
|
+
' fix it before trying again.',
|
128
128
|
_response
|
129
129
|
)
|
130
130
|
elsif _response.status_code == 401
|
131
131
|
raise APIException.new(
|
132
|
-
'Please
|
132
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
133
|
+
' credentials to authenticate to the API.',
|
133
134
|
_response
|
134
135
|
)
|
135
136
|
elsif _response.status_code == 403
|
136
137
|
raise ApiErrorResponseException.new(
|
137
|
-
'
|
138
|
-
' the Bandwidth Dashboard.',
|
138
|
+
'User unauthorized to perform this action.',
|
139
139
|
_response
|
140
140
|
)
|
141
141
|
elsif _response.status_code == 404
|
@@ -165,7 +165,9 @@ module Voice
|
|
165
165
|
|
166
166
|
# Return appropriate response type.
|
167
167
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
168
|
-
ApiResponse.new(
|
168
|
+
ApiResponse.new(
|
169
|
+
_response, data: ApiCallStateResponse.from_hash(decoded)
|
170
|
+
)
|
169
171
|
end
|
170
172
|
|
171
173
|
# Interrupts and replaces an active call's BXML document
|
@@ -181,8 +183,8 @@ module Voice
|
|
181
183
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
|
182
184
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
183
185
|
_query_builder,
|
184
|
-
'accountId' => account_id,
|
185
|
-
'callId' => call_id
|
186
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
187
|
+
'callId' => { 'value' => call_id, 'encode' => true }
|
186
188
|
)
|
187
189
|
_query_url = APIHelper.clean_url _query_builder
|
188
190
|
|
@@ -203,20 +205,19 @@ module Voice
|
|
203
205
|
# Validate response against endpoint and global error codes.
|
204
206
|
if _response.status_code == 400
|
205
207
|
raise ApiErrorResponseException.new(
|
206
|
-
'Something\'s not quite right...
|
207
|
-
'
|
208
|
-
' before trying again.',
|
208
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
209
|
+
' fix it before trying again.',
|
209
210
|
_response
|
210
211
|
)
|
211
212
|
elsif _response.status_code == 401
|
212
213
|
raise APIException.new(
|
213
|
-
'Please
|
214
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
215
|
+
' credentials to authenticate to the API.',
|
214
216
|
_response
|
215
217
|
)
|
216
218
|
elsif _response.status_code == 403
|
217
219
|
raise ApiErrorResponseException.new(
|
218
|
-
'
|
219
|
-
' the Bandwidth Dashboard.',
|
220
|
+
'User unauthorized to perform this action.',
|
220
221
|
_response
|
221
222
|
)
|
222
223
|
elsif _response.status_code == 404
|
@@ -261,8 +262,8 @@ module Voice
|
|
261
262
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recording'
|
262
263
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
263
264
|
_query_builder,
|
264
|
-
'accountId' => account_id,
|
265
|
-
'callId' => call_id
|
265
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
266
|
+
'callId' => { 'value' => call_id, 'encode' => true }
|
266
267
|
)
|
267
268
|
_query_url = APIHelper.clean_url _query_builder
|
268
269
|
|
@@ -283,20 +284,19 @@ module Voice
|
|
283
284
|
# Validate response against endpoint and global error codes.
|
284
285
|
if _response.status_code == 400
|
285
286
|
raise ApiErrorResponseException.new(
|
286
|
-
'Something\'s not quite right...
|
287
|
-
'
|
288
|
-
' before trying again.',
|
287
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
288
|
+
' fix it before trying again.',
|
289
289
|
_response
|
290
290
|
)
|
291
291
|
elsif _response.status_code == 401
|
292
292
|
raise APIException.new(
|
293
|
-
'Please
|
293
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
294
|
+
' credentials to authenticate to the API.',
|
294
295
|
_response
|
295
296
|
)
|
296
297
|
elsif _response.status_code == 403
|
297
298
|
raise ApiErrorResponseException.new(
|
298
|
-
'
|
299
|
-
' the Bandwidth Dashboard.',
|
299
|
+
'User unauthorized to perform this action.',
|
300
300
|
_response
|
301
301
|
)
|
302
302
|
elsif _response.status_code == 404
|
@@ -348,8 +348,8 @@ module Voice
|
|
348
348
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings'
|
349
349
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
350
350
|
_query_builder,
|
351
|
-
'accountId' => account_id,
|
352
|
-
'callId' => call_id
|
351
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
352
|
+
'callId' => { 'value' => call_id, 'encode' => true }
|
353
353
|
)
|
354
354
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
355
355
|
_query_builder,
|
@@ -376,20 +376,19 @@ module Voice
|
|
376
376
|
# Validate response against endpoint and global error codes.
|
377
377
|
if _response.status_code == 400
|
378
378
|
raise ApiErrorResponseException.new(
|
379
|
-
'Something\'s not quite right...
|
380
|
-
'
|
381
|
-
' before trying again.',
|
379
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
380
|
+
' fix it before trying again.',
|
382
381
|
_response
|
383
382
|
)
|
384
383
|
elsif _response.status_code == 401
|
385
384
|
raise APIException.new(
|
386
|
-
'Please
|
385
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
386
|
+
' credentials to authenticate to the API.',
|
387
387
|
_response
|
388
388
|
)
|
389
389
|
elsif _response.status_code == 403
|
390
390
|
raise ApiErrorResponseException.new(
|
391
|
-
'
|
392
|
-
' the Bandwidth Dashboard.',
|
391
|
+
'User unauthorized to perform this action.',
|
393
392
|
_response
|
394
393
|
)
|
395
394
|
elsif _response.status_code == 404
|
@@ -438,9 +437,9 @@ module Voice
|
|
438
437
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
|
439
438
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
440
439
|
_query_builder,
|
441
|
-
'accountId' => account_id,
|
442
|
-
'callId' => call_id,
|
443
|
-
'recordingId' => recording_id
|
440
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
441
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
442
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
444
443
|
)
|
445
444
|
_query_url = APIHelper.clean_url _query_builder
|
446
445
|
|
@@ -460,20 +459,19 @@ module Voice
|
|
460
459
|
# Validate response against endpoint and global error codes.
|
461
460
|
if _response.status_code == 400
|
462
461
|
raise ApiErrorResponseException.new(
|
463
|
-
'Something\'s not quite right...
|
464
|
-
'
|
465
|
-
' before trying again.',
|
462
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
463
|
+
' fix it before trying again.',
|
466
464
|
_response
|
467
465
|
)
|
468
466
|
elsif _response.status_code == 401
|
469
467
|
raise APIException.new(
|
470
|
-
'Please
|
468
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
469
|
+
' credentials to authenticate to the API.',
|
471
470
|
_response
|
472
471
|
)
|
473
472
|
elsif _response.status_code == 403
|
474
473
|
raise ApiErrorResponseException.new(
|
475
|
-
'
|
476
|
-
' the Bandwidth Dashboard.',
|
474
|
+
'User unauthorized to perform this action.',
|
477
475
|
_response
|
478
476
|
)
|
479
477
|
elsif _response.status_code == 404
|
@@ -503,8 +501,9 @@ module Voice
|
|
503
501
|
|
504
502
|
# Return appropriate response type.
|
505
503
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
506
|
-
ApiResponse.new(
|
507
|
-
|
504
|
+
ApiResponse.new(
|
505
|
+
_response, data: RecordingMetadataResponse.from_hash(decoded)
|
506
|
+
)
|
508
507
|
end
|
509
508
|
|
510
509
|
# Deletes the specified recording
|
@@ -520,9 +519,9 @@ module Voice
|
|
520
519
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
|
521
520
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
522
521
|
_query_builder,
|
523
|
-
'accountId' => account_id,
|
524
|
-
'callId' => call_id,
|
525
|
-
'recordingId' => recording_id
|
522
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
523
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
524
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
526
525
|
)
|
527
526
|
_query_url = APIHelper.clean_url _query_builder
|
528
527
|
|
@@ -536,20 +535,19 @@ module Voice
|
|
536
535
|
# Validate response against endpoint and global error codes.
|
537
536
|
if _response.status_code == 400
|
538
537
|
raise ApiErrorResponseException.new(
|
539
|
-
'Something\'s not quite right...
|
540
|
-
'
|
541
|
-
' before trying again.',
|
538
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
539
|
+
' fix it before trying again.',
|
542
540
|
_response
|
543
541
|
)
|
544
542
|
elsif _response.status_code == 401
|
545
543
|
raise APIException.new(
|
546
|
-
'Please
|
544
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
545
|
+
' credentials to authenticate to the API.',
|
547
546
|
_response
|
548
547
|
)
|
549
548
|
elsif _response.status_code == 403
|
550
549
|
raise ApiErrorResponseException.new(
|
551
|
-
'
|
552
|
-
' the Bandwidth Dashboard.',
|
550
|
+
'User unauthorized to perform this action.',
|
553
551
|
_response
|
554
552
|
)
|
555
553
|
elsif _response.status_code == 404
|
@@ -594,9 +592,9 @@ module Voice
|
|
594
592
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
|
595
593
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
596
594
|
_query_builder,
|
597
|
-
'accountId' => account_id,
|
598
|
-
'callId' => call_id,
|
599
|
-
'recordingId' => recording_id
|
595
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
596
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
597
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
600
598
|
)
|
601
599
|
_query_url = APIHelper.clean_url _query_builder
|
602
600
|
|
@@ -610,20 +608,19 @@ module Voice
|
|
610
608
|
# Validate response against endpoint and global error codes.
|
611
609
|
if _response.status_code == 400
|
612
610
|
raise ApiErrorResponseException.new(
|
613
|
-
'Something\'s not quite right...
|
614
|
-
'
|
615
|
-
' before trying again.',
|
611
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
612
|
+
' fix it before trying again.',
|
616
613
|
_response
|
617
614
|
)
|
618
615
|
elsif _response.status_code == 401
|
619
616
|
raise APIException.new(
|
620
|
-
'Please
|
617
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
618
|
+
' credentials to authenticate to the API.',
|
621
619
|
_response
|
622
620
|
)
|
623
621
|
elsif _response.status_code == 403
|
624
622
|
raise ApiErrorResponseException.new(
|
625
|
-
'
|
626
|
-
' the Bandwidth Dashboard.',
|
623
|
+
'User unauthorized to perform this action.',
|
627
624
|
_response
|
628
625
|
)
|
629
626
|
elsif _response.status_code == 404
|
@@ -652,7 +649,9 @@ module Voice
|
|
652
649
|
validate_response(_response)
|
653
650
|
|
654
651
|
# Return appropriate response type.
|
655
|
-
ApiResponse.new(
|
652
|
+
ApiResponse.new(
|
653
|
+
_response, data: _response.raw_body
|
654
|
+
)
|
656
655
|
end
|
657
656
|
|
658
657
|
# Deletes the specified recording's media
|
@@ -668,9 +667,9 @@ module Voice
|
|
668
667
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
|
669
668
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
670
669
|
_query_builder,
|
671
|
-
'accountId' => account_id,
|
672
|
-
'callId' => call_id,
|
673
|
-
'recordingId' => recording_id
|
670
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
671
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
672
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
674
673
|
)
|
675
674
|
_query_url = APIHelper.clean_url _query_builder
|
676
675
|
|
@@ -684,20 +683,19 @@ module Voice
|
|
684
683
|
# Validate response against endpoint and global error codes.
|
685
684
|
if _response.status_code == 400
|
686
685
|
raise ApiErrorResponseException.new(
|
687
|
-
'Something\'s not quite right...
|
688
|
-
'
|
689
|
-
' before trying again.',
|
686
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
687
|
+
' fix it before trying again.',
|
690
688
|
_response
|
691
689
|
)
|
692
690
|
elsif _response.status_code == 401
|
693
691
|
raise APIException.new(
|
694
|
-
'Please
|
692
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
693
|
+
' credentials to authenticate to the API.',
|
695
694
|
_response
|
696
695
|
)
|
697
696
|
elsif _response.status_code == 403
|
698
697
|
raise ApiErrorResponseException.new(
|
699
|
-
'
|
700
|
-
' the Bandwidth Dashboard.',
|
698
|
+
'User unauthorized to perform this action.',
|
701
699
|
_response
|
702
700
|
)
|
703
701
|
elsif _response.status_code == 404
|
@@ -742,9 +740,9 @@ module Voice
|
|
742
740
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
743
741
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
744
742
|
_query_builder,
|
745
|
-
'accountId' => account_id,
|
746
|
-
'callId' => call_id,
|
747
|
-
'recordingId' => recording_id
|
743
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
744
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
745
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
748
746
|
)
|
749
747
|
_query_url = APIHelper.clean_url _query_builder
|
750
748
|
|
@@ -764,20 +762,19 @@ module Voice
|
|
764
762
|
# Validate response against endpoint and global error codes.
|
765
763
|
if _response.status_code == 400
|
766
764
|
raise ApiErrorResponseException.new(
|
767
|
-
'Something\'s not quite right...
|
768
|
-
'
|
769
|
-
' before trying again.',
|
765
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
766
|
+
' fix it before trying again.',
|
770
767
|
_response
|
771
768
|
)
|
772
769
|
elsif _response.status_code == 401
|
773
770
|
raise APIException.new(
|
774
|
-
'Please
|
771
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
772
|
+
' credentials to authenticate to the API.',
|
775
773
|
_response
|
776
774
|
)
|
777
775
|
elsif _response.status_code == 403
|
778
776
|
raise ApiErrorResponseException.new(
|
779
|
-
'
|
780
|
-
' the Bandwidth Dashboard.',
|
777
|
+
'User unauthorized to perform this action.',
|
781
778
|
_response
|
782
779
|
)
|
783
780
|
elsif _response.status_code == 404
|
@@ -807,7 +804,9 @@ module Voice
|
|
807
804
|
|
808
805
|
# Return appropriate response type.
|
809
806
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
810
|
-
ApiResponse.new(
|
807
|
+
ApiResponse.new(
|
808
|
+
_response, data: TranscriptionResponse.from_hash(decoded)
|
809
|
+
)
|
811
810
|
end
|
812
811
|
|
813
812
|
# Requests that the specified recording be transcribed
|
@@ -825,9 +824,9 @@ module Voice
|
|
825
824
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
826
825
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
827
826
|
_query_builder,
|
828
|
-
'accountId' => account_id,
|
829
|
-
'callId' => call_id,
|
830
|
-
'recordingId' => recording_id
|
827
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
828
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
829
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
831
830
|
)
|
832
831
|
_query_url = APIHelper.clean_url _query_builder
|
833
832
|
|
@@ -848,20 +847,19 @@ module Voice
|
|
848
847
|
# Validate response against endpoint and global error codes.
|
849
848
|
if _response.status_code == 400
|
850
849
|
raise ApiErrorResponseException.new(
|
851
|
-
'Something\'s not quite right...
|
852
|
-
'
|
853
|
-
' before trying again.',
|
850
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
851
|
+
' fix it before trying again.',
|
854
852
|
_response
|
855
853
|
)
|
856
854
|
elsif _response.status_code == 401
|
857
855
|
raise APIException.new(
|
858
|
-
'Please
|
856
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
857
|
+
' credentials to authenticate to the API.',
|
859
858
|
_response
|
860
859
|
)
|
861
860
|
elsif _response.status_code == 403
|
862
861
|
raise ApiErrorResponseException.new(
|
863
|
-
'
|
864
|
-
' the Bandwidth Dashboard.',
|
862
|
+
'User unauthorized to perform this action.',
|
865
863
|
_response
|
866
864
|
)
|
867
865
|
elsif _response.status_code == 404
|
@@ -912,9 +910,9 @@ module Voice
|
|
912
910
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
913
911
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
914
912
|
_query_builder,
|
915
|
-
'accountId' => account_id,
|
916
|
-
'callId' => call_id,
|
917
|
-
'recordingId' => recording_id
|
913
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
914
|
+
'callId' => { 'value' => call_id, 'encode' => true },
|
915
|
+
'recordingId' => { 'value' => recording_id, 'encode' => true }
|
918
916
|
)
|
919
917
|
_query_url = APIHelper.clean_url _query_builder
|
920
918
|
|
@@ -928,20 +926,19 @@ module Voice
|
|
928
926
|
# Validate response against endpoint and global error codes.
|
929
927
|
if _response.status_code == 400
|
930
928
|
raise ApiErrorResponseException.new(
|
931
|
-
'Something\'s not quite right...
|
932
|
-
'
|
933
|
-
' before trying again.',
|
929
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
930
|
+
' fix it before trying again.',
|
934
931
|
_response
|
935
932
|
)
|
936
933
|
elsif _response.status_code == 401
|
937
934
|
raise APIException.new(
|
938
|
-
'Please
|
935
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
936
|
+
' credentials to authenticate to the API.',
|
939
937
|
_response
|
940
938
|
)
|
941
939
|
elsif _response.status_code == 403
|
942
940
|
raise ApiErrorResponseException.new(
|
943
|
-
'
|
944
|
-
' the Bandwidth Dashboard.',
|
941
|
+
'User unauthorized to perform this action.',
|
945
942
|
_response
|
946
943
|
)
|
947
944
|
elsif _response.status_code == 404
|
@@ -973,6 +970,247 @@ module Voice
|
|
973
970
|
ApiResponse.new(_response)
|
974
971
|
end
|
975
972
|
|
973
|
+
# Returns information about the specified conference
|
974
|
+
# @param [String] account_id Required parameter: Example:
|
975
|
+
# @param [String] conference_id Required parameter: Example:
|
976
|
+
# @return [ConferenceDetail] response from the API call
|
977
|
+
def get_conference_by_id(account_id,
|
978
|
+
conference_id)
|
979
|
+
# Prepare query url.
|
980
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
981
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
|
982
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
983
|
+
_query_builder,
|
984
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
985
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => true }
|
986
|
+
)
|
987
|
+
_query_url = APIHelper.clean_url _query_builder
|
988
|
+
|
989
|
+
# Prepare headers.
|
990
|
+
_headers = {
|
991
|
+
'accept' => 'application/json'
|
992
|
+
}
|
993
|
+
|
994
|
+
# Prepare and execute HttpRequest.
|
995
|
+
_request = config.http_client.get(
|
996
|
+
_query_url,
|
997
|
+
headers: _headers
|
998
|
+
)
|
999
|
+
VoiceBasicAuth.apply(config, _request)
|
1000
|
+
_response = execute_request(_request)
|
1001
|
+
|
1002
|
+
# Validate response against endpoint and global error codes.
|
1003
|
+
if _response.status_code == 400
|
1004
|
+
raise ApiErrorResponseException.new(
|
1005
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
1006
|
+
' fix it before trying again.',
|
1007
|
+
_response
|
1008
|
+
)
|
1009
|
+
elsif _response.status_code == 401
|
1010
|
+
raise APIException.new(
|
1011
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1012
|
+
' credentials to authenticate to the API.',
|
1013
|
+
_response
|
1014
|
+
)
|
1015
|
+
elsif _response.status_code == 403
|
1016
|
+
raise ApiErrorResponseException.new(
|
1017
|
+
'User unauthorized to perform this action.',
|
1018
|
+
_response
|
1019
|
+
)
|
1020
|
+
elsif _response.status_code == 404
|
1021
|
+
raise ApiErrorResponseException.new(
|
1022
|
+
'The resource specified cannot be found or does not belong to you.',
|
1023
|
+
_response
|
1024
|
+
)
|
1025
|
+
elsif _response.status_code == 415
|
1026
|
+
raise ApiErrorResponseException.new(
|
1027
|
+
'We don\'t support that media type. If a request body is required,' \
|
1028
|
+
' please send it to us as `application/json`.',
|
1029
|
+
_response
|
1030
|
+
)
|
1031
|
+
elsif _response.status_code == 429
|
1032
|
+
raise ApiErrorResponseException.new(
|
1033
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
1034
|
+
' slow your request rate down and try again.',
|
1035
|
+
_response
|
1036
|
+
)
|
1037
|
+
elsif _response.status_code == 500
|
1038
|
+
raise ApiErrorResponseException.new(
|
1039
|
+
'Something unexpected happened. Please try again.',
|
1040
|
+
_response
|
1041
|
+
)
|
1042
|
+
end
|
1043
|
+
validate_response(_response)
|
1044
|
+
|
1045
|
+
# Return appropriate response type.
|
1046
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
1047
|
+
ApiResponse.new(
|
1048
|
+
_response, data: ConferenceDetail.from_hash(decoded)
|
1049
|
+
)
|
1050
|
+
end
|
1051
|
+
|
1052
|
+
# Modify the conference state
|
1053
|
+
# @param [String] account_id Required parameter: Example:
|
1054
|
+
# @param [String] conference_id Required parameter: Example:
|
1055
|
+
# @param [CallEngineModifyConferenceRequest] body Optional parameter:
|
1056
|
+
# Example:
|
1057
|
+
# @return [void] response from the API call
|
1058
|
+
def modify_conference(account_id,
|
1059
|
+
conference_id,
|
1060
|
+
body: nil)
|
1061
|
+
# Prepare query url.
|
1062
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
1063
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
|
1064
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
1065
|
+
_query_builder,
|
1066
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
1067
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => true }
|
1068
|
+
)
|
1069
|
+
_query_url = APIHelper.clean_url _query_builder
|
1070
|
+
|
1071
|
+
# Prepare headers.
|
1072
|
+
_headers = {
|
1073
|
+
'content-type' => 'application/json; charset=utf-8'
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
# Prepare and execute HttpRequest.
|
1077
|
+
_request = config.http_client.post(
|
1078
|
+
_query_url,
|
1079
|
+
headers: _headers,
|
1080
|
+
parameters: body.to_json
|
1081
|
+
)
|
1082
|
+
VoiceBasicAuth.apply(config, _request)
|
1083
|
+
_response = execute_request(_request)
|
1084
|
+
|
1085
|
+
# Validate response against endpoint and global error codes.
|
1086
|
+
if _response.status_code == 400
|
1087
|
+
raise ApiErrorResponseException.new(
|
1088
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
1089
|
+
' fix it before trying again.',
|
1090
|
+
_response
|
1091
|
+
)
|
1092
|
+
elsif _response.status_code == 401
|
1093
|
+
raise APIException.new(
|
1094
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1095
|
+
' credentials to authenticate to the API.',
|
1096
|
+
_response
|
1097
|
+
)
|
1098
|
+
elsif _response.status_code == 403
|
1099
|
+
raise ApiErrorResponseException.new(
|
1100
|
+
'User unauthorized to perform this action.',
|
1101
|
+
_response
|
1102
|
+
)
|
1103
|
+
elsif _response.status_code == 404
|
1104
|
+
raise ApiErrorResponseException.new(
|
1105
|
+
'The resource specified cannot be found or does not belong to you.',
|
1106
|
+
_response
|
1107
|
+
)
|
1108
|
+
elsif _response.status_code == 415
|
1109
|
+
raise ApiErrorResponseException.new(
|
1110
|
+
'We don\'t support that media type. If a request body is required,' \
|
1111
|
+
' please send it to us as `application/json`.',
|
1112
|
+
_response
|
1113
|
+
)
|
1114
|
+
elsif _response.status_code == 429
|
1115
|
+
raise ApiErrorResponseException.new(
|
1116
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
1117
|
+
' slow your request rate down and try again.',
|
1118
|
+
_response
|
1119
|
+
)
|
1120
|
+
elsif _response.status_code == 500
|
1121
|
+
raise ApiErrorResponseException.new(
|
1122
|
+
'Something unexpected happened. Please try again.',
|
1123
|
+
_response
|
1124
|
+
)
|
1125
|
+
end
|
1126
|
+
validate_response(_response)
|
1127
|
+
|
1128
|
+
# Return appropriate response type.
|
1129
|
+
ApiResponse.new(_response)
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
# Returns information about the specified conference member
|
1133
|
+
# @param [String] account_id Required parameter: Example:
|
1134
|
+
# @param [String] conference_id Required parameter: Example:
|
1135
|
+
# @param [String] member_id Required parameter: Example:
|
1136
|
+
# @return [ConferenceMemberDetail] response from the API call
|
1137
|
+
def get_conference_member(account_id,
|
1138
|
+
conference_id,
|
1139
|
+
member_id)
|
1140
|
+
# Prepare query url.
|
1141
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
1142
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'
|
1143
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
1144
|
+
_query_builder,
|
1145
|
+
'accountId' => { 'value' => account_id, 'encode' => true },
|
1146
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => true },
|
1147
|
+
'memberId' => { 'value' => member_id, 'encode' => true }
|
1148
|
+
)
|
1149
|
+
_query_url = APIHelper.clean_url _query_builder
|
1150
|
+
|
1151
|
+
# Prepare headers.
|
1152
|
+
_headers = {
|
1153
|
+
'accept' => 'application/json'
|
1154
|
+
}
|
1155
|
+
|
1156
|
+
# Prepare and execute HttpRequest.
|
1157
|
+
_request = config.http_client.get(
|
1158
|
+
_query_url,
|
1159
|
+
headers: _headers
|
1160
|
+
)
|
1161
|
+
VoiceBasicAuth.apply(config, _request)
|
1162
|
+
_response = execute_request(_request)
|
1163
|
+
|
1164
|
+
# Validate response against endpoint and global error codes.
|
1165
|
+
if _response.status_code == 400
|
1166
|
+
raise ApiErrorResponseException.new(
|
1167
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
1168
|
+
' fix it before trying again.',
|
1169
|
+
_response
|
1170
|
+
)
|
1171
|
+
elsif _response.status_code == 401
|
1172
|
+
raise APIException.new(
|
1173
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1174
|
+
' credentials to authenticate to the API.',
|
1175
|
+
_response
|
1176
|
+
)
|
1177
|
+
elsif _response.status_code == 403
|
1178
|
+
raise ApiErrorResponseException.new(
|
1179
|
+
'User unauthorized to perform this action.',
|
1180
|
+
_response
|
1181
|
+
)
|
1182
|
+
elsif _response.status_code == 404
|
1183
|
+
raise ApiErrorResponseException.new(
|
1184
|
+
'The resource specified cannot be found or does not belong to you.',
|
1185
|
+
_response
|
1186
|
+
)
|
1187
|
+
elsif _response.status_code == 415
|
1188
|
+
raise ApiErrorResponseException.new(
|
1189
|
+
'We don\'t support that media type. If a request body is required,' \
|
1190
|
+
' please send it to us as `application/json`.',
|
1191
|
+
_response
|
1192
|
+
)
|
1193
|
+
elsif _response.status_code == 429
|
1194
|
+
raise ApiErrorResponseException.new(
|
1195
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
1196
|
+
' slow your request rate down and try again.',
|
1197
|
+
_response
|
1198
|
+
)
|
1199
|
+
elsif _response.status_code == 500
|
1200
|
+
raise ApiErrorResponseException.new(
|
1201
|
+
'Something unexpected happened. Please try again.',
|
1202
|
+
_response
|
1203
|
+
)
|
1204
|
+
end
|
1205
|
+
validate_response(_response)
|
1206
|
+
|
1207
|
+
# Return appropriate response type.
|
1208
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
1209
|
+
ApiResponse.new(
|
1210
|
+
_response, data: ConferenceMemberDetail.from_hash(decoded)
|
1211
|
+
)
|
1212
|
+
end
|
1213
|
+
|
976
1214
|
# Returns a list of metadata for the recordings associated with the
|
977
1215
|
# specified account. The list can be filtered by the optional from, to,
|
978
1216
|
# minStartTime, and maxStartTime arguments. The list is capped at 1000
|
@@ -993,7 +1231,7 @@ module Voice
|
|
993
1231
|
_query_builder << '/api/v2/accounts/{accountId}/recordings'
|
994
1232
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
995
1233
|
_query_builder,
|
996
|
-
'accountId' => account_id
|
1234
|
+
'accountId' => { 'value' => account_id, 'encode' => true }
|
997
1235
|
)
|
998
1236
|
_query_builder = APIHelper.append_url_with_query_parameters(
|
999
1237
|
_query_builder,
|
@@ -1020,20 +1258,19 @@ module Voice
|
|
1020
1258
|
# Validate response against endpoint and global error codes.
|
1021
1259
|
if _response.status_code == 400
|
1022
1260
|
raise ApiErrorResponseException.new(
|
1023
|
-
'Something\'s not quite right...
|
1024
|
-
'
|
1025
|
-
' before trying again.',
|
1261
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
1262
|
+
' fix it before trying again.',
|
1026
1263
|
_response
|
1027
1264
|
)
|
1028
1265
|
elsif _response.status_code == 401
|
1029
1266
|
raise APIException.new(
|
1030
|
-
'Please
|
1267
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
1268
|
+
' credentials to authenticate to the API.',
|
1031
1269
|
_response
|
1032
1270
|
)
|
1033
1271
|
elsif _response.status_code == 403
|
1034
1272
|
raise ApiErrorResponseException.new(
|
1035
|
-
'
|
1036
|
-
' the Bandwidth Dashboard.',
|
1273
|
+
'User unauthorized to perform this action.',
|
1037
1274
|
_response
|
1038
1275
|
)
|
1039
1276
|
elsif _response.status_code == 404
|