bandwidth-sdk 2.1.1 → 6.1.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/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
|
@@ -8,9 +8,15 @@ module Bandwidth
|
|
|
8
8
|
xml.PhoneNumber(number, compact_hash({
|
|
9
9
|
'transferAnswerUrl' => transfer_answer_url,
|
|
10
10
|
'transferAnswerMethod' => transfer_answer_method,
|
|
11
|
+
'transferDisconnectUrl' => transfer_disconnect_url,
|
|
12
|
+
'transferDisconnectMethod' => transfer_disconnect_method,
|
|
11
13
|
'username' => username,
|
|
12
14
|
'password' => password,
|
|
13
|
-
'tag' => tag
|
|
15
|
+
'tag' => tag,
|
|
16
|
+
'transferAnswerFallbackUrl' => transfer_answer_fallback_url,
|
|
17
|
+
'transferAnswerFallbackMethod' => transfer_answer_fallback_method,
|
|
18
|
+
'fallbackUsername' => fallback_username,
|
|
19
|
+
'fallbackPassword' => fallback_password
|
|
14
20
|
}))
|
|
15
21
|
end
|
|
16
22
|
end
|
|
@@ -17,7 +17,15 @@ module Bandwidth
|
|
|
17
17
|
'recordingAvailableMethod' => recording_available_method,
|
|
18
18
|
'terminatingDigits' => terminating_digits,
|
|
19
19
|
'maxDuration' => max_duration,
|
|
20
|
-
'fileFormat' => file_format
|
|
20
|
+
'fileFormat' => file_format,
|
|
21
|
+
'transcribe' => transcribe,
|
|
22
|
+
'transcriptionAvailableUrl' => transcription_available_url,
|
|
23
|
+
'transcriptionAvailableMethod' => transcription_available_method,
|
|
24
|
+
'silenceTimeout' => silence_timeout,
|
|
25
|
+
'recordCompleteFallbackUrl' => record_complete_fallback_url,
|
|
26
|
+
'recordCompleteFallbackMethod' => record_complete_fallback_method,
|
|
27
|
+
'fallbackUsername' => fallback_username,
|
|
28
|
+
'fallbackPassword' => fallback_password
|
|
21
29
|
}))
|
|
22
30
|
end
|
|
23
31
|
end
|
|
@@ -12,7 +12,11 @@ module Bandwidth
|
|
|
12
12
|
'redirectMethod' => redirect_method,
|
|
13
13
|
'tag' => tag,
|
|
14
14
|
'username' => username,
|
|
15
|
-
'password' => password
|
|
15
|
+
'password' => password,
|
|
16
|
+
'redirectFallbackUrl' => redirect_fallback_url,
|
|
17
|
+
'redirectFallbackMethod' => redirect_fallback_method,
|
|
18
|
+
'fallbackUsername' => fallback_username,
|
|
19
|
+
'fallbackPassword' => fallback_password
|
|
16
20
|
}))
|
|
17
21
|
end
|
|
18
22
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require_relative 'xml_verb'
|
|
2
|
+
|
|
3
|
+
module Bandwidth
|
|
4
|
+
module Voice
|
|
5
|
+
class SipUri
|
|
6
|
+
include XmlVerb
|
|
7
|
+
def to_bxml(xml)
|
|
8
|
+
xml.SipUri(uri, compact_hash({
|
|
9
|
+
'transferAnswerUrl' => transfer_answer_url,
|
|
10
|
+
'transferAnswerMethod' => transfer_answer_method,
|
|
11
|
+
'transferDisconnectUrl' => transfer_disconnect_url,
|
|
12
|
+
'transferDisconnectMethod' => transfer_disconnect_method,
|
|
13
|
+
'username' => username,
|
|
14
|
+
'password' => password,
|
|
15
|
+
'tag' => tag,
|
|
16
|
+
'uui' => uui,
|
|
17
|
+
'transferAnswerFallbackUrl' => transfer_answer_fallback_url,
|
|
18
|
+
'transferAnswerFallbackMethod' => transfer_answer_fallback_method,
|
|
19
|
+
'fallbackUsername' => fallback_username,
|
|
20
|
+
'fallbackPassword' => fallback_password
|
|
21
|
+
}))
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require_relative 'xml_verb'
|
|
2
|
+
|
|
3
|
+
module Bandwidth
|
|
4
|
+
module Voice
|
|
5
|
+
# The StartGather verb is used to start a gather
|
|
6
|
+
class StartGather
|
|
7
|
+
include XmlVerb
|
|
8
|
+
|
|
9
|
+
def to_bxml(xml)
|
|
10
|
+
xml.StartGather(compact_hash({
|
|
11
|
+
'username' => username,
|
|
12
|
+
'password' => password,
|
|
13
|
+
'tag' => tag,
|
|
14
|
+
'dtmfUrl' => dtmf_url,
|
|
15
|
+
'dtmfMethod' => dtmf_method,
|
|
16
|
+
}))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -14,7 +14,10 @@ module Bandwidth
|
|
|
14
14
|
'recordingAvailableUrl' => recording_available_url,
|
|
15
15
|
'recordingAvailableMethod' => recording_available_method,
|
|
16
16
|
'fileFormat' => file_format,
|
|
17
|
-
'multiChannel' => multi_channel
|
|
17
|
+
'multiChannel' => multi_channel,
|
|
18
|
+
'transcribe' => transcribe,
|
|
19
|
+
'transcriptionAvailableUrl' => transcription_available_url,
|
|
20
|
+
'transcriptionAvailableMethod' => transcription_available_method
|
|
18
21
|
}))
|
|
19
22
|
end
|
|
20
23
|
end
|
|
@@ -16,7 +16,11 @@ module Bandwidth
|
|
|
16
16
|
'username' => username,
|
|
17
17
|
'password' => password,
|
|
18
18
|
'diversionTreatment' => diversion_treatment,
|
|
19
|
-
'diversionReason' => diversion_reason
|
|
19
|
+
'diversionReason' => diversion_reason,
|
|
20
|
+
'transferCompleteFallbackUrl' => transfer_complete_fallback_url,
|
|
21
|
+
'transferCompleteFallbackMethod' => transfer_complete_fallback_method,
|
|
22
|
+
'fallbackUsername' => fallback_username,
|
|
23
|
+
'fallbackPassword' => fallback_password
|
|
20
24
|
})) do
|
|
21
25
|
def embedded_xml(xml, property, type)
|
|
22
26
|
if property
|
|
@@ -27,8 +31,15 @@ module Bandwidth
|
|
|
27
31
|
s.to_bxml(xml)
|
|
28
32
|
end
|
|
29
33
|
end
|
|
30
|
-
phone_numbers.
|
|
31
|
-
|
|
34
|
+
if not phone_numbers.nil?
|
|
35
|
+
phone_numbers.each do |number|
|
|
36
|
+
embedded_xml(xml, number, PhoneNumber)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
if not sip_uris.nil?
|
|
40
|
+
sip_uris.each do |sip_uri|
|
|
41
|
+
embedded_xml(xml, sip_uri, SipUri)
|
|
42
|
+
end
|
|
32
43
|
end
|
|
33
44
|
end
|
|
34
45
|
end
|
|
@@ -8,23 +8,38 @@ require_relative 'voice/client.rb'
|
|
|
8
8
|
|
|
9
9
|
# Models
|
|
10
10
|
require_relative 'voice/models/api_call_response.rb'
|
|
11
|
+
require_relative 'voice/models/api_call_state_response.rb'
|
|
11
12
|
require_relative 'voice/models/api_create_call_request.rb'
|
|
12
|
-
require_relative 'voice/models/api_get_account_recordings_metadata_request.rb'
|
|
13
13
|
require_relative 'voice/models/api_modify_call_request.rb'
|
|
14
|
+
require_relative 'voice/models/api_modify_conference_request.rb'
|
|
15
|
+
require_relative 'voice/models/api_transcribe_recording_request.rb'
|
|
16
|
+
require_relative 'voice/models/conference_detail.rb'
|
|
17
|
+
require_relative 'voice/models/conference_member_detail.rb'
|
|
18
|
+
require_relative 'voice/models/conference_recording_metadata_response.rb'
|
|
14
19
|
require_relative 'voice/models/modify_call_recording_state.rb'
|
|
15
20
|
require_relative 'voice/models/recording_metadata_response.rb'
|
|
21
|
+
require_relative 'voice/models/transcript.rb'
|
|
22
|
+
require_relative 'voice/models/transcription.rb'
|
|
23
|
+
require_relative 'voice/models/transcription_response.rb'
|
|
24
|
+
require_relative 'voice/models/answer_fallback_method_enum.rb'
|
|
16
25
|
require_relative 'voice/models/answer_method_enum.rb'
|
|
26
|
+
require_relative 'voice/models/callback_method_enum.rb'
|
|
27
|
+
require_relative 'voice/models/conference_event_method_enum.rb'
|
|
17
28
|
require_relative 'voice/models/direction_enum.rb'
|
|
29
|
+
require_relative 'voice/models/disconnect_cause_enum.rb'
|
|
18
30
|
require_relative 'voice/models/disconnect_method_enum.rb'
|
|
19
31
|
require_relative 'voice/models/file_format_enum.rb'
|
|
32
|
+
require_relative 'voice/models/redirect_fallback_method_enum.rb'
|
|
20
33
|
require_relative 'voice/models/redirect_method_enum.rb'
|
|
21
34
|
require_relative 'voice/models/state_enum.rb'
|
|
22
35
|
require_relative 'voice/models/state1_enum.rb'
|
|
23
|
-
require_relative 'voice/models/
|
|
24
|
-
require_relative 'voice/models/
|
|
36
|
+
require_relative 'voice/models/state2_enum.rb'
|
|
37
|
+
require_relative 'voice/models/status_enum.rb'
|
|
38
|
+
require_relative 'voice/models/status1_enum.rb'
|
|
39
|
+
require_relative 'voice/models/status3_enum.rb'
|
|
25
40
|
|
|
26
41
|
# Exceptions
|
|
27
|
-
require_relative 'voice/exceptions/
|
|
42
|
+
require_relative 'voice/exceptions/api_error_response_exception.rb'
|
|
28
43
|
# Controllers
|
|
29
44
|
require_relative 'voice/controllers/base_controller.rb'
|
|
30
45
|
require_relative 'voice/controllers/api_controller.rb'
|
|
@@ -17,20 +17,31 @@ module Bandwidth
|
|
|
17
17
|
|
|
18
18
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
|
19
19
|
backoff_factor: 1, environment: Environment::PRODUCTION,
|
|
20
|
+
base_url: 'https://www.example.com',
|
|
20
21
|
messaging_basic_auth_user_name: 'TODO: Replace',
|
|
21
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',
|
|
22
25
|
voice_basic_auth_user_name: 'TODO: Replace',
|
|
23
|
-
voice_basic_auth_password: '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)
|
|
24
30
|
@config = if config.nil?
|
|
25
31
|
Configuration.new(timeout: timeout,
|
|
26
32
|
max_retries: max_retries,
|
|
27
33
|
retry_interval: retry_interval,
|
|
28
34
|
backoff_factor: backoff_factor,
|
|
29
35
|
environment: environment,
|
|
36
|
+
base_url: base_url,
|
|
30
37
|
messaging_basic_auth_user_name: messaging_basic_auth_user_name,
|
|
31
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,
|
|
32
41
|
voice_basic_auth_user_name: voice_basic_auth_user_name,
|
|
33
|
-
voice_basic_auth_password: voice_basic_auth_password
|
|
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)
|
|
34
45
|
else
|
|
35
46
|
config
|
|
36
47
|
end
|
|
@@ -11,7 +11,7 @@ module Voice
|
|
|
11
11
|
super(config, http_call_back: http_call_back)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# Creates
|
|
14
|
+
# Creates an outbound call
|
|
15
15
|
# @param [String] account_id Required parameter: Example:
|
|
16
16
|
# @param [ApiCreateCallRequest] body Optional parameter: Example:
|
|
17
17
|
# @return [ApiCallResponse] response from the API call
|
|
@@ -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' => false }
|
|
26
26
|
)
|
|
27
27
|
_query_url = APIHelper.clean_url _query_builder
|
|
28
28
|
|
|
@@ -43,36 +43,120 @@ module Voice
|
|
|
43
43
|
|
|
44
44
|
# Validate response against endpoint and global error codes.
|
|
45
45
|
if _response.status_code == 400
|
|
46
|
-
raise
|
|
47
|
-
'Something
|
|
48
|
-
' before trying again.',
|
|
46
|
+
raise ApiErrorResponseException.new(
|
|
47
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
48
|
+
' fix it before trying again.',
|
|
49
49
|
_response
|
|
50
50
|
)
|
|
51
51
|
elsif _response.status_code == 401
|
|
52
52
|
raise APIException.new(
|
|
53
|
-
'Please
|
|
53
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
54
|
+
' credentials to authenticate to the API.',
|
|
54
55
|
_response
|
|
55
56
|
)
|
|
56
57
|
elsif _response.status_code == 403
|
|
57
|
-
raise
|
|
58
|
-
'
|
|
59
|
-
|
|
58
|
+
raise ApiErrorResponseException.new(
|
|
59
|
+
'User unauthorized to perform this action.',
|
|
60
|
+
_response
|
|
61
|
+
)
|
|
62
|
+
elsif _response.status_code == 404
|
|
63
|
+
raise ApiErrorResponseException.new(
|
|
64
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
65
|
+
_response
|
|
66
|
+
)
|
|
67
|
+
elsif _response.status_code == 415
|
|
68
|
+
raise ApiErrorResponseException.new(
|
|
69
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
70
|
+
' please send it to us as `application/json`.',
|
|
71
|
+
_response
|
|
72
|
+
)
|
|
73
|
+
elsif _response.status_code == 429
|
|
74
|
+
raise ApiErrorResponseException.new(
|
|
75
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
76
|
+
' slow your request rate down and try again.',
|
|
77
|
+
_response
|
|
78
|
+
)
|
|
79
|
+
elsif _response.status_code == 500
|
|
80
|
+
raise ApiErrorResponseException.new(
|
|
81
|
+
'Something unexpected happened. Please try again.',
|
|
82
|
+
_response
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
validate_response(_response)
|
|
86
|
+
|
|
87
|
+
# Return appropriate response type.
|
|
88
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
89
|
+
ApiResponse.new(
|
|
90
|
+
_response, data: ApiCallResponse.from_hash(decoded)
|
|
91
|
+
)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Returns near-realtime metadata about the specified call
|
|
95
|
+
# @param [String] account_id Required parameter: Example:
|
|
96
|
+
# @param [String] call_id Required parameter: Example:
|
|
97
|
+
# @return [ApiCallStateResponse] response from the API call
|
|
98
|
+
def get_call_state(account_id,
|
|
99
|
+
call_id)
|
|
100
|
+
# Prepare query url.
|
|
101
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
102
|
+
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
|
|
103
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
104
|
+
_query_builder,
|
|
105
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
106
|
+
'callId' => { 'value' => call_id, 'encode' => false }
|
|
107
|
+
)
|
|
108
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
109
|
+
|
|
110
|
+
# Prepare headers.
|
|
111
|
+
_headers = {
|
|
112
|
+
'accept' => 'application/json'
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Prepare and execute HttpRequest.
|
|
116
|
+
_request = config.http_client.get(
|
|
117
|
+
_query_url,
|
|
118
|
+
headers: _headers
|
|
119
|
+
)
|
|
120
|
+
VoiceBasicAuth.apply(config, _request)
|
|
121
|
+
_response = execute_request(_request)
|
|
122
|
+
|
|
123
|
+
# Validate response against endpoint and global error codes.
|
|
124
|
+
if _response.status_code == 400
|
|
125
|
+
raise ApiErrorResponseException.new(
|
|
126
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
127
|
+
' fix it before trying again.',
|
|
128
|
+
_response
|
|
129
|
+
)
|
|
130
|
+
elsif _response.status_code == 401
|
|
131
|
+
raise APIException.new(
|
|
132
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
133
|
+
' credentials to authenticate to the API.',
|
|
134
|
+
_response
|
|
135
|
+
)
|
|
136
|
+
elsif _response.status_code == 403
|
|
137
|
+
raise ApiErrorResponseException.new(
|
|
138
|
+
'User unauthorized to perform this action.',
|
|
139
|
+
_response
|
|
140
|
+
)
|
|
141
|
+
elsif _response.status_code == 404
|
|
142
|
+
raise ApiErrorResponseException.new(
|
|
143
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
60
144
|
_response
|
|
61
145
|
)
|
|
62
146
|
elsif _response.status_code == 415
|
|
63
|
-
raise
|
|
64
|
-
'We don\'t support that media type.
|
|
65
|
-
' `application/json`.',
|
|
147
|
+
raise ApiErrorResponseException.new(
|
|
148
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
149
|
+
' please send it to us as `application/json`.',
|
|
66
150
|
_response
|
|
67
151
|
)
|
|
68
152
|
elsif _response.status_code == 429
|
|
69
|
-
raise
|
|
153
|
+
raise ApiErrorResponseException.new(
|
|
70
154
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
71
155
|
' slow your request rate down and try again.',
|
|
72
156
|
_response
|
|
73
157
|
)
|
|
74
158
|
elsif _response.status_code == 500
|
|
75
|
-
raise
|
|
159
|
+
raise ApiErrorResponseException.new(
|
|
76
160
|
'Something unexpected happened. Please try again.',
|
|
77
161
|
_response
|
|
78
162
|
)
|
|
@@ -81,7 +165,9 @@ module Voice
|
|
|
81
165
|
|
|
82
166
|
# Return appropriate response type.
|
|
83
167
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
84
|
-
ApiResponse.new(
|
|
168
|
+
ApiResponse.new(
|
|
169
|
+
_response, data: ApiCallStateResponse.from_hash(decoded)
|
|
170
|
+
)
|
|
85
171
|
end
|
|
86
172
|
|
|
87
173
|
# Interrupts and replaces an active call's BXML document
|
|
@@ -97,8 +183,8 @@ module Voice
|
|
|
97
183
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
|
|
98
184
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
99
185
|
_query_builder,
|
|
100
|
-
'accountId' => account_id,
|
|
101
|
-
'callId' => call_id
|
|
186
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
187
|
+
'callId' => { 'value' => call_id, 'encode' => false }
|
|
102
188
|
)
|
|
103
189
|
_query_url = APIHelper.clean_url _query_builder
|
|
104
190
|
|
|
@@ -118,40 +204,41 @@ module Voice
|
|
|
118
204
|
|
|
119
205
|
# Validate response against endpoint and global error codes.
|
|
120
206
|
if _response.status_code == 400
|
|
121
|
-
raise
|
|
122
|
-
'
|
|
207
|
+
raise ApiErrorResponseException.new(
|
|
208
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
209
|
+
' fix it before trying again.',
|
|
123
210
|
_response
|
|
124
211
|
)
|
|
125
212
|
elsif _response.status_code == 401
|
|
126
213
|
raise APIException.new(
|
|
127
|
-
'Please
|
|
214
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
215
|
+
' credentials to authenticate to the API.',
|
|
128
216
|
_response
|
|
129
217
|
)
|
|
130
218
|
elsif _response.status_code == 403
|
|
131
|
-
raise
|
|
132
|
-
'
|
|
133
|
-
' the Bandwidth Dashboard.',
|
|
219
|
+
raise ApiErrorResponseException.new(
|
|
220
|
+
'User unauthorized to perform this action.',
|
|
134
221
|
_response
|
|
135
222
|
)
|
|
136
223
|
elsif _response.status_code == 404
|
|
137
|
-
raise
|
|
138
|
-
'The
|
|
224
|
+
raise ApiErrorResponseException.new(
|
|
225
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
139
226
|
_response
|
|
140
227
|
)
|
|
141
228
|
elsif _response.status_code == 415
|
|
142
|
-
raise
|
|
143
|
-
'We don\'t support that media type.
|
|
144
|
-
' `application/json`.',
|
|
229
|
+
raise ApiErrorResponseException.new(
|
|
230
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
231
|
+
' please send it to us as `application/json`.',
|
|
145
232
|
_response
|
|
146
233
|
)
|
|
147
234
|
elsif _response.status_code == 429
|
|
148
|
-
raise
|
|
235
|
+
raise ApiErrorResponseException.new(
|
|
149
236
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
150
237
|
' slow your request rate down and try again.',
|
|
151
238
|
_response
|
|
152
239
|
)
|
|
153
240
|
elsif _response.status_code == 500
|
|
154
|
-
raise
|
|
241
|
+
raise ApiErrorResponseException.new(
|
|
155
242
|
'Something unexpected happened. Please try again.',
|
|
156
243
|
_response
|
|
157
244
|
)
|
|
@@ -175,8 +262,8 @@ module Voice
|
|
|
175
262
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recording'
|
|
176
263
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
177
264
|
_query_builder,
|
|
178
|
-
'accountId' => account_id,
|
|
179
|
-
'callId' => call_id
|
|
265
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
266
|
+
'callId' => { 'value' => call_id, 'encode' => false }
|
|
180
267
|
)
|
|
181
268
|
_query_url = APIHelper.clean_url _query_builder
|
|
182
269
|
|
|
@@ -196,40 +283,41 @@ module Voice
|
|
|
196
283
|
|
|
197
284
|
# Validate response against endpoint and global error codes.
|
|
198
285
|
if _response.status_code == 400
|
|
199
|
-
raise
|
|
200
|
-
'
|
|
286
|
+
raise ApiErrorResponseException.new(
|
|
287
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
288
|
+
' fix it before trying again.',
|
|
201
289
|
_response
|
|
202
290
|
)
|
|
203
291
|
elsif _response.status_code == 401
|
|
204
292
|
raise APIException.new(
|
|
205
|
-
'Please
|
|
293
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
294
|
+
' credentials to authenticate to the API.',
|
|
206
295
|
_response
|
|
207
296
|
)
|
|
208
297
|
elsif _response.status_code == 403
|
|
209
|
-
raise
|
|
210
|
-
'
|
|
211
|
-
' the Bandwidth Dashboard.',
|
|
298
|
+
raise ApiErrorResponseException.new(
|
|
299
|
+
'User unauthorized to perform this action.',
|
|
212
300
|
_response
|
|
213
301
|
)
|
|
214
302
|
elsif _response.status_code == 404
|
|
215
|
-
raise
|
|
216
|
-
'The
|
|
303
|
+
raise ApiErrorResponseException.new(
|
|
304
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
217
305
|
_response
|
|
218
306
|
)
|
|
219
307
|
elsif _response.status_code == 415
|
|
220
|
-
raise
|
|
221
|
-
'We don\'t support that media type.
|
|
222
|
-
' `application/json`.',
|
|
308
|
+
raise ApiErrorResponseException.new(
|
|
309
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
310
|
+
' please send it to us as `application/json`.',
|
|
223
311
|
_response
|
|
224
312
|
)
|
|
225
313
|
elsif _response.status_code == 429
|
|
226
|
-
raise
|
|
314
|
+
raise ApiErrorResponseException.new(
|
|
227
315
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
228
316
|
' slow your request rate down and try again.',
|
|
229
317
|
_response
|
|
230
318
|
)
|
|
231
319
|
elsif _response.status_code == 500
|
|
232
|
-
raise
|
|
320
|
+
raise ApiErrorResponseException.new(
|
|
233
321
|
'Something unexpected happened. Please try again.',
|
|
234
322
|
_response
|
|
235
323
|
)
|
|
@@ -252,8 +340,8 @@ module Voice
|
|
|
252
340
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings'
|
|
253
341
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
254
342
|
_query_builder,
|
|
255
|
-
'accountId' => account_id,
|
|
256
|
-
'callId' => call_id
|
|
343
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
344
|
+
'callId' => { 'value' => call_id, 'encode' => false }
|
|
257
345
|
)
|
|
258
346
|
_query_url = APIHelper.clean_url _query_builder
|
|
259
347
|
|
|
@@ -272,36 +360,41 @@ module Voice
|
|
|
272
360
|
|
|
273
361
|
# Validate response against endpoint and global error codes.
|
|
274
362
|
if _response.status_code == 400
|
|
275
|
-
raise
|
|
276
|
-
'Something
|
|
277
|
-
' before trying again.',
|
|
363
|
+
raise ApiErrorResponseException.new(
|
|
364
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
365
|
+
' fix it before trying again.',
|
|
278
366
|
_response
|
|
279
367
|
)
|
|
280
368
|
elsif _response.status_code == 401
|
|
281
369
|
raise APIException.new(
|
|
282
|
-
'Please
|
|
370
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
371
|
+
' credentials to authenticate to the API.',
|
|
283
372
|
_response
|
|
284
373
|
)
|
|
285
374
|
elsif _response.status_code == 403
|
|
286
|
-
raise
|
|
287
|
-
'
|
|
288
|
-
|
|
375
|
+
raise ApiErrorResponseException.new(
|
|
376
|
+
'User unauthorized to perform this action.',
|
|
377
|
+
_response
|
|
378
|
+
)
|
|
379
|
+
elsif _response.status_code == 404
|
|
380
|
+
raise ApiErrorResponseException.new(
|
|
381
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
289
382
|
_response
|
|
290
383
|
)
|
|
291
384
|
elsif _response.status_code == 415
|
|
292
|
-
raise
|
|
293
|
-
'We don\'t support that media type.
|
|
294
|
-
' `application/json`.',
|
|
385
|
+
raise ApiErrorResponseException.new(
|
|
386
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
387
|
+
' please send it to us as `application/json`.',
|
|
295
388
|
_response
|
|
296
389
|
)
|
|
297
390
|
elsif _response.status_code == 429
|
|
298
|
-
raise
|
|
391
|
+
raise ApiErrorResponseException.new(
|
|
299
392
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
300
393
|
' slow your request rate down and try again.',
|
|
301
394
|
_response
|
|
302
395
|
)
|
|
303
396
|
elsif _response.status_code == 500
|
|
304
|
-
raise
|
|
397
|
+
raise ApiErrorResponseException.new(
|
|
305
398
|
'Something unexpected happened. Please try again.',
|
|
306
399
|
_response
|
|
307
400
|
)
|
|
@@ -329,9 +422,9 @@ module Voice
|
|
|
329
422
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
|
|
330
423
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
331
424
|
_query_builder,
|
|
332
|
-
'accountId' => account_id,
|
|
333
|
-
'callId' => call_id,
|
|
334
|
-
'recordingId' => recording_id
|
|
425
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
426
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
427
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
335
428
|
)
|
|
336
429
|
_query_url = APIHelper.clean_url _query_builder
|
|
337
430
|
|
|
@@ -350,42 +443,41 @@ module Voice
|
|
|
350
443
|
|
|
351
444
|
# Validate response against endpoint and global error codes.
|
|
352
445
|
if _response.status_code == 400
|
|
353
|
-
raise
|
|
354
|
-
'Something
|
|
355
|
-
' before trying again.',
|
|
446
|
+
raise ApiErrorResponseException.new(
|
|
447
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
448
|
+
' fix it before trying again.',
|
|
356
449
|
_response
|
|
357
450
|
)
|
|
358
451
|
elsif _response.status_code == 401
|
|
359
452
|
raise APIException.new(
|
|
360
|
-
'Please
|
|
453
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
454
|
+
' credentials to authenticate to the API.',
|
|
361
455
|
_response
|
|
362
456
|
)
|
|
363
457
|
elsif _response.status_code == 403
|
|
364
|
-
raise
|
|
365
|
-
'
|
|
366
|
-
' the Bandwidth Dashboard.',
|
|
458
|
+
raise ApiErrorResponseException.new(
|
|
459
|
+
'User unauthorized to perform this action.',
|
|
367
460
|
_response
|
|
368
461
|
)
|
|
369
462
|
elsif _response.status_code == 404
|
|
370
|
-
raise
|
|
371
|
-
'The
|
|
372
|
-
' to you',
|
|
463
|
+
raise ApiErrorResponseException.new(
|
|
464
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
373
465
|
_response
|
|
374
466
|
)
|
|
375
467
|
elsif _response.status_code == 415
|
|
376
|
-
raise
|
|
377
|
-
'We don\'t support that media type.
|
|
378
|
-
' `application/json`.',
|
|
468
|
+
raise ApiErrorResponseException.new(
|
|
469
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
470
|
+
' please send it to us as `application/json`.',
|
|
379
471
|
_response
|
|
380
472
|
)
|
|
381
473
|
elsif _response.status_code == 429
|
|
382
|
-
raise
|
|
474
|
+
raise ApiErrorResponseException.new(
|
|
383
475
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
384
476
|
' slow your request rate down and try again.',
|
|
385
477
|
_response
|
|
386
478
|
)
|
|
387
479
|
elsif _response.status_code == 500
|
|
388
|
-
raise
|
|
480
|
+
raise ApiErrorResponseException.new(
|
|
389
481
|
'Something unexpected happened. Please try again.',
|
|
390
482
|
_response
|
|
391
483
|
)
|
|
@@ -394,8 +486,9 @@ module Voice
|
|
|
394
486
|
|
|
395
487
|
# Return appropriate response type.
|
|
396
488
|
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
397
|
-
ApiResponse.new(
|
|
398
|
-
|
|
489
|
+
ApiResponse.new(
|
|
490
|
+
_response, data: RecordingMetadataResponse.from_hash(decoded)
|
|
491
|
+
)
|
|
399
492
|
end
|
|
400
493
|
|
|
401
494
|
# Deletes the specified recording
|
|
@@ -411,9 +504,9 @@ module Voice
|
|
|
411
504
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
|
|
412
505
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
413
506
|
_query_builder,
|
|
414
|
-
'accountId' => account_id,
|
|
415
|
-
'callId' => call_id,
|
|
416
|
-
'recordingId' => recording_id
|
|
507
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
508
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
509
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
417
510
|
)
|
|
418
511
|
_query_url = APIHelper.clean_url _query_builder
|
|
419
512
|
|
|
@@ -426,42 +519,41 @@ module Voice
|
|
|
426
519
|
|
|
427
520
|
# Validate response against endpoint and global error codes.
|
|
428
521
|
if _response.status_code == 400
|
|
429
|
-
raise
|
|
430
|
-
'Something
|
|
431
|
-
' before trying again.',
|
|
522
|
+
raise ApiErrorResponseException.new(
|
|
523
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
524
|
+
' fix it before trying again.',
|
|
432
525
|
_response
|
|
433
526
|
)
|
|
434
527
|
elsif _response.status_code == 401
|
|
435
528
|
raise APIException.new(
|
|
436
|
-
'Please
|
|
529
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
530
|
+
' credentials to authenticate to the API.',
|
|
437
531
|
_response
|
|
438
532
|
)
|
|
439
533
|
elsif _response.status_code == 403
|
|
440
|
-
raise
|
|
441
|
-
'
|
|
442
|
-
' the Bandwidth Dashboard.',
|
|
534
|
+
raise ApiErrorResponseException.new(
|
|
535
|
+
'User unauthorized to perform this action.',
|
|
443
536
|
_response
|
|
444
537
|
)
|
|
445
538
|
elsif _response.status_code == 404
|
|
446
|
-
raise
|
|
447
|
-
'The
|
|
448
|
-
' to you',
|
|
539
|
+
raise ApiErrorResponseException.new(
|
|
540
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
449
541
|
_response
|
|
450
542
|
)
|
|
451
543
|
elsif _response.status_code == 415
|
|
452
|
-
raise
|
|
453
|
-
'We don\'t support that media type.
|
|
454
|
-
' `application/json`.',
|
|
544
|
+
raise ApiErrorResponseException.new(
|
|
545
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
546
|
+
' please send it to us as `application/json`.',
|
|
455
547
|
_response
|
|
456
548
|
)
|
|
457
549
|
elsif _response.status_code == 429
|
|
458
|
-
raise
|
|
550
|
+
raise ApiErrorResponseException.new(
|
|
459
551
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
460
552
|
' slow your request rate down and try again.',
|
|
461
553
|
_response
|
|
462
554
|
)
|
|
463
555
|
elsif _response.status_code == 500
|
|
464
|
-
raise
|
|
556
|
+
raise ApiErrorResponseException.new(
|
|
465
557
|
'Something unexpected happened. Please try again.',
|
|
466
558
|
_response
|
|
467
559
|
)
|
|
@@ -485,9 +577,9 @@ module Voice
|
|
|
485
577
|
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
|
|
486
578
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
487
579
|
_query_builder,
|
|
488
|
-
'accountId' => account_id,
|
|
489
|
-
'callId' => call_id,
|
|
490
|
-
'recordingId' => recording_id
|
|
580
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
581
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
582
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
491
583
|
)
|
|
492
584
|
_query_url = APIHelper.clean_url _query_builder
|
|
493
585
|
|
|
@@ -500,42 +592,116 @@ module Voice
|
|
|
500
592
|
|
|
501
593
|
# Validate response against endpoint and global error codes.
|
|
502
594
|
if _response.status_code == 400
|
|
503
|
-
raise
|
|
504
|
-
'Something
|
|
505
|
-
' before trying again.',
|
|
595
|
+
raise ApiErrorResponseException.new(
|
|
596
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
597
|
+
' fix it before trying again.',
|
|
506
598
|
_response
|
|
507
599
|
)
|
|
508
600
|
elsif _response.status_code == 401
|
|
509
601
|
raise APIException.new(
|
|
510
|
-
'Please
|
|
602
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
603
|
+
' credentials to authenticate to the API.',
|
|
511
604
|
_response
|
|
512
605
|
)
|
|
513
606
|
elsif _response.status_code == 403
|
|
514
|
-
raise
|
|
515
|
-
'
|
|
516
|
-
' the Bandwidth Dashboard.',
|
|
607
|
+
raise ApiErrorResponseException.new(
|
|
608
|
+
'User unauthorized to perform this action.',
|
|
517
609
|
_response
|
|
518
610
|
)
|
|
519
611
|
elsif _response.status_code == 404
|
|
612
|
+
raise ApiErrorResponseException.new(
|
|
613
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
614
|
+
_response
|
|
615
|
+
)
|
|
616
|
+
elsif _response.status_code == 415
|
|
617
|
+
raise ApiErrorResponseException.new(
|
|
618
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
619
|
+
' please send it to us as `application/json`.',
|
|
620
|
+
_response
|
|
621
|
+
)
|
|
622
|
+
elsif _response.status_code == 429
|
|
623
|
+
raise ApiErrorResponseException.new(
|
|
624
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
625
|
+
' slow your request rate down and try again.',
|
|
626
|
+
_response
|
|
627
|
+
)
|
|
628
|
+
elsif _response.status_code == 500
|
|
629
|
+
raise ApiErrorResponseException.new(
|
|
630
|
+
'Something unexpected happened. Please try again.',
|
|
631
|
+
_response
|
|
632
|
+
)
|
|
633
|
+
end
|
|
634
|
+
validate_response(_response)
|
|
635
|
+
|
|
636
|
+
# Return appropriate response type.
|
|
637
|
+
ApiResponse.new(
|
|
638
|
+
_response, data: _response.raw_body
|
|
639
|
+
)
|
|
640
|
+
end
|
|
641
|
+
|
|
642
|
+
# Deletes the specified recording's media
|
|
643
|
+
# @param [String] account_id Required parameter: Example:
|
|
644
|
+
# @param [String] call_id Required parameter: Example:
|
|
645
|
+
# @param [String] recording_id Required parameter: Example:
|
|
646
|
+
# @return [void] response from the API call
|
|
647
|
+
def delete_recording_media(account_id,
|
|
648
|
+
call_id,
|
|
649
|
+
recording_id)
|
|
650
|
+
# Prepare query url.
|
|
651
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
652
|
+
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
|
|
653
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
654
|
+
_query_builder,
|
|
655
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
656
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
657
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
658
|
+
)
|
|
659
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
660
|
+
|
|
661
|
+
# Prepare and execute HttpRequest.
|
|
662
|
+
_request = config.http_client.delete(
|
|
663
|
+
_query_url
|
|
664
|
+
)
|
|
665
|
+
VoiceBasicAuth.apply(config, _request)
|
|
666
|
+
_response = execute_request(_request)
|
|
667
|
+
|
|
668
|
+
# Validate response against endpoint and global error codes.
|
|
669
|
+
if _response.status_code == 400
|
|
670
|
+
raise ApiErrorResponseException.new(
|
|
671
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
672
|
+
' fix it before trying again.',
|
|
673
|
+
_response
|
|
674
|
+
)
|
|
675
|
+
elsif _response.status_code == 401
|
|
520
676
|
raise APIException.new(
|
|
521
|
-
'
|
|
522
|
-
' to
|
|
677
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
678
|
+
' credentials to authenticate to the API.',
|
|
679
|
+
_response
|
|
680
|
+
)
|
|
681
|
+
elsif _response.status_code == 403
|
|
682
|
+
raise ApiErrorResponseException.new(
|
|
683
|
+
'User unauthorized to perform this action.',
|
|
684
|
+
_response
|
|
685
|
+
)
|
|
686
|
+
elsif _response.status_code == 404
|
|
687
|
+
raise ApiErrorResponseException.new(
|
|
688
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
523
689
|
_response
|
|
524
690
|
)
|
|
525
691
|
elsif _response.status_code == 415
|
|
526
|
-
raise
|
|
527
|
-
'We don\'t support that media type.
|
|
528
|
-
' `application/json`.',
|
|
692
|
+
raise ApiErrorResponseException.new(
|
|
693
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
694
|
+
' please send it to us as `application/json`.',
|
|
529
695
|
_response
|
|
530
696
|
)
|
|
531
697
|
elsif _response.status_code == 429
|
|
532
|
-
raise
|
|
698
|
+
raise ApiErrorResponseException.new(
|
|
533
699
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
534
700
|
' slow your request rate down and try again.',
|
|
535
701
|
_response
|
|
536
702
|
)
|
|
537
703
|
elsif _response.status_code == 500
|
|
538
|
-
raise
|
|
704
|
+
raise ApiErrorResponseException.new(
|
|
539
705
|
'Something unexpected happened. Please try again.',
|
|
540
706
|
_response
|
|
541
707
|
)
|
|
@@ -543,20 +709,25 @@ module Voice
|
|
|
543
709
|
validate_response(_response)
|
|
544
710
|
|
|
545
711
|
# Return appropriate response type.
|
|
546
|
-
ApiResponse.new(_response
|
|
712
|
+
ApiResponse.new(_response)
|
|
547
713
|
end
|
|
548
714
|
|
|
549
|
-
#
|
|
550
|
-
# recordings associated with the specified account
|
|
715
|
+
# Downloads the specified transcription
|
|
551
716
|
# @param [String] account_id Required parameter: Example:
|
|
552
|
-
# @
|
|
553
|
-
|
|
717
|
+
# @param [String] call_id Required parameter: Example:
|
|
718
|
+
# @param [String] recording_id Required parameter: Example:
|
|
719
|
+
# @return [TranscriptionResponse] response from the API call
|
|
720
|
+
def get_recording_transcription(account_id,
|
|
721
|
+
call_id,
|
|
722
|
+
recording_id)
|
|
554
723
|
# Prepare query url.
|
|
555
724
|
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
556
|
-
_query_builder << '/api/v2/accounts/{accountId}/recordings'
|
|
725
|
+
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
|
557
726
|
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
558
727
|
_query_builder,
|
|
559
|
-
'accountId' => account_id
|
|
728
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
729
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
730
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
560
731
|
)
|
|
561
732
|
_query_url = APIHelper.clean_url _query_builder
|
|
562
733
|
|
|
@@ -575,36 +746,951 @@ module Voice
|
|
|
575
746
|
|
|
576
747
|
# Validate response against endpoint and global error codes.
|
|
577
748
|
if _response.status_code == 400
|
|
578
|
-
raise
|
|
579
|
-
'Something
|
|
580
|
-
' before trying again.',
|
|
749
|
+
raise ApiErrorResponseException.new(
|
|
750
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
751
|
+
' fix it before trying again.',
|
|
752
|
+
_response
|
|
753
|
+
)
|
|
754
|
+
elsif _response.status_code == 401
|
|
755
|
+
raise APIException.new(
|
|
756
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
757
|
+
' credentials to authenticate to the API.',
|
|
758
|
+
_response
|
|
759
|
+
)
|
|
760
|
+
elsif _response.status_code == 403
|
|
761
|
+
raise ApiErrorResponseException.new(
|
|
762
|
+
'User unauthorized to perform this action.',
|
|
763
|
+
_response
|
|
764
|
+
)
|
|
765
|
+
elsif _response.status_code == 404
|
|
766
|
+
raise ApiErrorResponseException.new(
|
|
767
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
768
|
+
_response
|
|
769
|
+
)
|
|
770
|
+
elsif _response.status_code == 415
|
|
771
|
+
raise ApiErrorResponseException.new(
|
|
772
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
773
|
+
' please send it to us as `application/json`.',
|
|
774
|
+
_response
|
|
775
|
+
)
|
|
776
|
+
elsif _response.status_code == 429
|
|
777
|
+
raise ApiErrorResponseException.new(
|
|
778
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
779
|
+
' slow your request rate down and try again.',
|
|
780
|
+
_response
|
|
781
|
+
)
|
|
782
|
+
elsif _response.status_code == 500
|
|
783
|
+
raise ApiErrorResponseException.new(
|
|
784
|
+
'Something unexpected happened. Please try again.',
|
|
785
|
+
_response
|
|
786
|
+
)
|
|
787
|
+
end
|
|
788
|
+
validate_response(_response)
|
|
789
|
+
|
|
790
|
+
# Return appropriate response type.
|
|
791
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
792
|
+
ApiResponse.new(
|
|
793
|
+
_response, data: TranscriptionResponse.from_hash(decoded)
|
|
794
|
+
)
|
|
795
|
+
end
|
|
796
|
+
|
|
797
|
+
# Requests that the specified recording be transcribed
|
|
798
|
+
# @param [String] account_id Required parameter: Example:
|
|
799
|
+
# @param [String] call_id Required parameter: Example:
|
|
800
|
+
# @param [String] recording_id Required parameter: Example:
|
|
801
|
+
# @param [ApiTranscribeRecordingRequest] body Optional parameter: Example:
|
|
802
|
+
# @return [void] response from the API call
|
|
803
|
+
def create_transcribe_recording(account_id,
|
|
804
|
+
call_id,
|
|
805
|
+
recording_id,
|
|
806
|
+
body: nil)
|
|
807
|
+
# Prepare query url.
|
|
808
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
809
|
+
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
|
810
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
811
|
+
_query_builder,
|
|
812
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
813
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
814
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
815
|
+
)
|
|
816
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
817
|
+
|
|
818
|
+
# Prepare headers.
|
|
819
|
+
_headers = {
|
|
820
|
+
'content-type' => 'application/json; charset=utf-8'
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
# Prepare and execute HttpRequest.
|
|
824
|
+
_request = config.http_client.post(
|
|
825
|
+
_query_url,
|
|
826
|
+
headers: _headers,
|
|
827
|
+
parameters: body.to_json
|
|
828
|
+
)
|
|
829
|
+
VoiceBasicAuth.apply(config, _request)
|
|
830
|
+
_response = execute_request(_request)
|
|
831
|
+
|
|
832
|
+
# Validate response against endpoint and global error codes.
|
|
833
|
+
if _response.status_code == 400
|
|
834
|
+
raise ApiErrorResponseException.new(
|
|
835
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
836
|
+
' fix it before trying again.',
|
|
837
|
+
_response
|
|
838
|
+
)
|
|
839
|
+
elsif _response.status_code == 401
|
|
840
|
+
raise APIException.new(
|
|
841
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
842
|
+
' credentials to authenticate to the API.',
|
|
843
|
+
_response
|
|
844
|
+
)
|
|
845
|
+
elsif _response.status_code == 403
|
|
846
|
+
raise ApiErrorResponseException.new(
|
|
847
|
+
'User unauthorized to perform this action.',
|
|
848
|
+
_response
|
|
849
|
+
)
|
|
850
|
+
elsif _response.status_code == 404
|
|
851
|
+
raise ApiErrorResponseException.new(
|
|
852
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
853
|
+
_response
|
|
854
|
+
)
|
|
855
|
+
elsif _response.status_code == 410
|
|
856
|
+
raise ApiErrorResponseException.new(
|
|
857
|
+
'The media for this recording has been deleted, so we can\'t' \
|
|
858
|
+
' transcribe it',
|
|
859
|
+
_response
|
|
860
|
+
)
|
|
861
|
+
elsif _response.status_code == 415
|
|
862
|
+
raise ApiErrorResponseException.new(
|
|
863
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
864
|
+
' please send it to us as `application/json`.',
|
|
865
|
+
_response
|
|
866
|
+
)
|
|
867
|
+
elsif _response.status_code == 429
|
|
868
|
+
raise ApiErrorResponseException.new(
|
|
869
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
870
|
+
' slow your request rate down and try again.',
|
|
871
|
+
_response
|
|
872
|
+
)
|
|
873
|
+
elsif _response.status_code == 500
|
|
874
|
+
raise ApiErrorResponseException.new(
|
|
875
|
+
'Something unexpected happened. Please try again.',
|
|
876
|
+
_response
|
|
877
|
+
)
|
|
878
|
+
end
|
|
879
|
+
validate_response(_response)
|
|
880
|
+
|
|
881
|
+
# Return appropriate response type.
|
|
882
|
+
ApiResponse.new(_response)
|
|
883
|
+
end
|
|
884
|
+
|
|
885
|
+
# Deletes the specified recording's transcription
|
|
886
|
+
# @param [String] account_id Required parameter: Example:
|
|
887
|
+
# @param [String] call_id Required parameter: Example:
|
|
888
|
+
# @param [String] recording_id Required parameter: Example:
|
|
889
|
+
# @return [void] response from the API call
|
|
890
|
+
def delete_recording_transcription(account_id,
|
|
891
|
+
call_id,
|
|
892
|
+
recording_id)
|
|
893
|
+
# Prepare query url.
|
|
894
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
895
|
+
_query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
|
|
896
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
897
|
+
_query_builder,
|
|
898
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
899
|
+
'callId' => { 'value' => call_id, 'encode' => false },
|
|
900
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
901
|
+
)
|
|
902
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
903
|
+
|
|
904
|
+
# Prepare and execute HttpRequest.
|
|
905
|
+
_request = config.http_client.delete(
|
|
906
|
+
_query_url
|
|
907
|
+
)
|
|
908
|
+
VoiceBasicAuth.apply(config, _request)
|
|
909
|
+
_response = execute_request(_request)
|
|
910
|
+
|
|
911
|
+
# Validate response against endpoint and global error codes.
|
|
912
|
+
if _response.status_code == 400
|
|
913
|
+
raise ApiErrorResponseException.new(
|
|
914
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
915
|
+
' fix it before trying again.',
|
|
581
916
|
_response
|
|
582
917
|
)
|
|
583
918
|
elsif _response.status_code == 401
|
|
584
919
|
raise APIException.new(
|
|
585
|
-
'Please
|
|
920
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
921
|
+
' credentials to authenticate to the API.',
|
|
586
922
|
_response
|
|
587
923
|
)
|
|
588
924
|
elsif _response.status_code == 403
|
|
589
|
-
raise
|
|
590
|
-
'
|
|
591
|
-
|
|
925
|
+
raise ApiErrorResponseException.new(
|
|
926
|
+
'User unauthorized to perform this action.',
|
|
927
|
+
_response
|
|
928
|
+
)
|
|
929
|
+
elsif _response.status_code == 404
|
|
930
|
+
raise ApiErrorResponseException.new(
|
|
931
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
932
|
+
_response
|
|
933
|
+
)
|
|
934
|
+
elsif _response.status_code == 415
|
|
935
|
+
raise ApiErrorResponseException.new(
|
|
936
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
937
|
+
' please send it to us as `application/json`.',
|
|
938
|
+
_response
|
|
939
|
+
)
|
|
940
|
+
elsif _response.status_code == 429
|
|
941
|
+
raise ApiErrorResponseException.new(
|
|
942
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
943
|
+
' slow your request rate down and try again.',
|
|
944
|
+
_response
|
|
945
|
+
)
|
|
946
|
+
elsif _response.status_code == 500
|
|
947
|
+
raise ApiErrorResponseException.new(
|
|
948
|
+
'Something unexpected happened. Please try again.',
|
|
949
|
+
_response
|
|
950
|
+
)
|
|
951
|
+
end
|
|
952
|
+
validate_response(_response)
|
|
953
|
+
|
|
954
|
+
# Return appropriate response type.
|
|
955
|
+
ApiResponse.new(_response)
|
|
956
|
+
end
|
|
957
|
+
|
|
958
|
+
# Returns information about the conferences in the account
|
|
959
|
+
# @param [String] account_id Required parameter: Example:
|
|
960
|
+
# @param [Integer] page_size Optional parameter: Example:1000
|
|
961
|
+
# @param [String] page_token Optional parameter: Example:
|
|
962
|
+
# @param [String] name Optional parameter: Example:
|
|
963
|
+
# @param [String] min_created_time Optional parameter: Example:
|
|
964
|
+
# @param [String] max_created_time Optional parameter: Example:
|
|
965
|
+
# @return [List of ConferenceDetail] response from the API call
|
|
966
|
+
def get_conferences_by_account(account_id,
|
|
967
|
+
page_size: 1000,
|
|
968
|
+
page_token: nil,
|
|
969
|
+
name: nil,
|
|
970
|
+
min_created_time: nil,
|
|
971
|
+
max_created_time: nil)
|
|
972
|
+
# Prepare query url.
|
|
973
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
974
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences'
|
|
975
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
976
|
+
_query_builder,
|
|
977
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
|
978
|
+
)
|
|
979
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
|
980
|
+
_query_builder,
|
|
981
|
+
'pageSize' => page_size,
|
|
982
|
+
'pageToken' => page_token,
|
|
983
|
+
'name' => name,
|
|
984
|
+
'minCreatedTime' => min_created_time,
|
|
985
|
+
'maxCreatedTime' => max_created_time
|
|
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,
|
|
1049
|
+
data: decoded.map { |element| ConferenceDetail.from_hash(element) }
|
|
1050
|
+
)
|
|
1051
|
+
end
|
|
1052
|
+
|
|
1053
|
+
# Returns information about the specified conference
|
|
1054
|
+
# @param [String] account_id Required parameter: Example:
|
|
1055
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1056
|
+
# @return [ConferenceDetail] response from the API call
|
|
1057
|
+
def get_conference_by_id(account_id,
|
|
1058
|
+
conference_id)
|
|
1059
|
+
# Prepare query url.
|
|
1060
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1061
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
|
|
1062
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1063
|
+
_query_builder,
|
|
1064
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1065
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false }
|
|
1066
|
+
)
|
|
1067
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1068
|
+
|
|
1069
|
+
# Prepare headers.
|
|
1070
|
+
_headers = {
|
|
1071
|
+
'accept' => 'application/json'
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
# Prepare and execute HttpRequest.
|
|
1075
|
+
_request = config.http_client.get(
|
|
1076
|
+
_query_url,
|
|
1077
|
+
headers: _headers
|
|
1078
|
+
)
|
|
1079
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1080
|
+
_response = execute_request(_request)
|
|
1081
|
+
|
|
1082
|
+
# Validate response against endpoint and global error codes.
|
|
1083
|
+
if _response.status_code == 400
|
|
1084
|
+
raise ApiErrorResponseException.new(
|
|
1085
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1086
|
+
' fix it before trying again.',
|
|
1087
|
+
_response
|
|
1088
|
+
)
|
|
1089
|
+
elsif _response.status_code == 401
|
|
1090
|
+
raise APIException.new(
|
|
1091
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1092
|
+
' credentials to authenticate to the API.',
|
|
1093
|
+
_response
|
|
1094
|
+
)
|
|
1095
|
+
elsif _response.status_code == 403
|
|
1096
|
+
raise ApiErrorResponseException.new(
|
|
1097
|
+
'User unauthorized to perform this action.',
|
|
1098
|
+
_response
|
|
1099
|
+
)
|
|
1100
|
+
elsif _response.status_code == 404
|
|
1101
|
+
raise ApiErrorResponseException.new(
|
|
1102
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1103
|
+
_response
|
|
1104
|
+
)
|
|
1105
|
+
elsif _response.status_code == 415
|
|
1106
|
+
raise ApiErrorResponseException.new(
|
|
1107
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1108
|
+
' please send it to us as `application/json`.',
|
|
1109
|
+
_response
|
|
1110
|
+
)
|
|
1111
|
+
elsif _response.status_code == 429
|
|
1112
|
+
raise ApiErrorResponseException.new(
|
|
1113
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1114
|
+
' slow your request rate down and try again.',
|
|
1115
|
+
_response
|
|
1116
|
+
)
|
|
1117
|
+
elsif _response.status_code == 500
|
|
1118
|
+
raise ApiErrorResponseException.new(
|
|
1119
|
+
'Something unexpected happened. Please try again.',
|
|
1120
|
+
_response
|
|
1121
|
+
)
|
|
1122
|
+
end
|
|
1123
|
+
validate_response(_response)
|
|
1124
|
+
|
|
1125
|
+
# Return appropriate response type.
|
|
1126
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
1127
|
+
ApiResponse.new(
|
|
1128
|
+
_response, data: ConferenceDetail.from_hash(decoded)
|
|
1129
|
+
)
|
|
1130
|
+
end
|
|
1131
|
+
|
|
1132
|
+
# Modify the conference state
|
|
1133
|
+
# @param [String] account_id Required parameter: Example:
|
|
1134
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1135
|
+
# @param [ApiModifyConferenceRequest] body Optional parameter: Example:
|
|
1136
|
+
# @return [void] response from the API call
|
|
1137
|
+
def modify_conference(account_id,
|
|
1138
|
+
conference_id,
|
|
1139
|
+
body: nil)
|
|
1140
|
+
# Prepare query url.
|
|
1141
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1142
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
|
|
1143
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1144
|
+
_query_builder,
|
|
1145
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1146
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false }
|
|
1147
|
+
)
|
|
1148
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1149
|
+
|
|
1150
|
+
# Prepare headers.
|
|
1151
|
+
_headers = {
|
|
1152
|
+
'content-type' => 'application/json; charset=utf-8'
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
# Prepare and execute HttpRequest.
|
|
1156
|
+
_request = config.http_client.post(
|
|
1157
|
+
_query_url,
|
|
1158
|
+
headers: _headers,
|
|
1159
|
+
parameters: body.to_json
|
|
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
|
+
ApiResponse.new(_response)
|
|
1209
|
+
end
|
|
1210
|
+
|
|
1211
|
+
# Updates settings for a particular conference member
|
|
1212
|
+
# @param [String] account_id Required parameter: Example:
|
|
1213
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1214
|
+
# @param [String] call_id Required parameter: Example:
|
|
1215
|
+
# @param [ConferenceMemberDetail] body Optional parameter: Example:
|
|
1216
|
+
# @return [void] response from the API call
|
|
1217
|
+
def modify_conference_member(account_id,
|
|
1218
|
+
conference_id,
|
|
1219
|
+
call_id,
|
|
1220
|
+
body: nil)
|
|
1221
|
+
# Prepare query url.
|
|
1222
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1223
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{callId}'
|
|
1224
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1225
|
+
_query_builder,
|
|
1226
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1227
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false },
|
|
1228
|
+
'callId' => { 'value' => call_id, 'encode' => false }
|
|
1229
|
+
)
|
|
1230
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1231
|
+
|
|
1232
|
+
# Prepare headers.
|
|
1233
|
+
_headers = {
|
|
1234
|
+
'content-type' => 'application/json; charset=utf-8'
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
# Prepare and execute HttpRequest.
|
|
1238
|
+
_request = config.http_client.put(
|
|
1239
|
+
_query_url,
|
|
1240
|
+
headers: _headers,
|
|
1241
|
+
parameters: body.to_json
|
|
1242
|
+
)
|
|
1243
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1244
|
+
_response = execute_request(_request)
|
|
1245
|
+
|
|
1246
|
+
# Validate response against endpoint and global error codes.
|
|
1247
|
+
if _response.status_code == 400
|
|
1248
|
+
raise ApiErrorResponseException.new(
|
|
1249
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1250
|
+
' fix it before trying again.',
|
|
1251
|
+
_response
|
|
1252
|
+
)
|
|
1253
|
+
elsif _response.status_code == 401
|
|
1254
|
+
raise APIException.new(
|
|
1255
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1256
|
+
' credentials to authenticate to the API.',
|
|
1257
|
+
_response
|
|
1258
|
+
)
|
|
1259
|
+
elsif _response.status_code == 403
|
|
1260
|
+
raise ApiErrorResponseException.new(
|
|
1261
|
+
'User unauthorized to perform this action.',
|
|
1262
|
+
_response
|
|
1263
|
+
)
|
|
1264
|
+
elsif _response.status_code == 404
|
|
1265
|
+
raise ApiErrorResponseException.new(
|
|
1266
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1267
|
+
_response
|
|
1268
|
+
)
|
|
1269
|
+
elsif _response.status_code == 415
|
|
1270
|
+
raise ApiErrorResponseException.new(
|
|
1271
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1272
|
+
' please send it to us as `application/json`.',
|
|
1273
|
+
_response
|
|
1274
|
+
)
|
|
1275
|
+
elsif _response.status_code == 429
|
|
1276
|
+
raise ApiErrorResponseException.new(
|
|
1277
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1278
|
+
' slow your request rate down and try again.',
|
|
1279
|
+
_response
|
|
1280
|
+
)
|
|
1281
|
+
elsif _response.status_code == 500
|
|
1282
|
+
raise ApiErrorResponseException.new(
|
|
1283
|
+
'Something unexpected happened. Please try again.',
|
|
1284
|
+
_response
|
|
1285
|
+
)
|
|
1286
|
+
end
|
|
1287
|
+
validate_response(_response)
|
|
1288
|
+
|
|
1289
|
+
# Return appropriate response type.
|
|
1290
|
+
ApiResponse.new(_response)
|
|
1291
|
+
end
|
|
1292
|
+
|
|
1293
|
+
# Returns information about the specified conference member
|
|
1294
|
+
# @param [String] account_id Required parameter: Example:
|
|
1295
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1296
|
+
# @param [String] member_id Required parameter: Example:
|
|
1297
|
+
# @return [ConferenceMemberDetail] response from the API call
|
|
1298
|
+
def get_conference_member(account_id,
|
|
1299
|
+
conference_id,
|
|
1300
|
+
member_id)
|
|
1301
|
+
# Prepare query url.
|
|
1302
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1303
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/members/{memberId}'
|
|
1304
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1305
|
+
_query_builder,
|
|
1306
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1307
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false },
|
|
1308
|
+
'memberId' => { 'value' => member_id, 'encode' => false }
|
|
1309
|
+
)
|
|
1310
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1311
|
+
|
|
1312
|
+
# Prepare headers.
|
|
1313
|
+
_headers = {
|
|
1314
|
+
'accept' => 'application/json'
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
# Prepare and execute HttpRequest.
|
|
1318
|
+
_request = config.http_client.get(
|
|
1319
|
+
_query_url,
|
|
1320
|
+
headers: _headers
|
|
1321
|
+
)
|
|
1322
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1323
|
+
_response = execute_request(_request)
|
|
1324
|
+
|
|
1325
|
+
# Validate response against endpoint and global error codes.
|
|
1326
|
+
if _response.status_code == 400
|
|
1327
|
+
raise ApiErrorResponseException.new(
|
|
1328
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1329
|
+
' fix it before trying again.',
|
|
1330
|
+
_response
|
|
1331
|
+
)
|
|
1332
|
+
elsif _response.status_code == 401
|
|
1333
|
+
raise APIException.new(
|
|
1334
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1335
|
+
' credentials to authenticate to the API.',
|
|
1336
|
+
_response
|
|
1337
|
+
)
|
|
1338
|
+
elsif _response.status_code == 403
|
|
1339
|
+
raise ApiErrorResponseException.new(
|
|
1340
|
+
'User unauthorized to perform this action.',
|
|
1341
|
+
_response
|
|
1342
|
+
)
|
|
1343
|
+
elsif _response.status_code == 404
|
|
1344
|
+
raise ApiErrorResponseException.new(
|
|
1345
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1346
|
+
_response
|
|
1347
|
+
)
|
|
1348
|
+
elsif _response.status_code == 415
|
|
1349
|
+
raise ApiErrorResponseException.new(
|
|
1350
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1351
|
+
' please send it to us as `application/json`.',
|
|
1352
|
+
_response
|
|
1353
|
+
)
|
|
1354
|
+
elsif _response.status_code == 429
|
|
1355
|
+
raise ApiErrorResponseException.new(
|
|
1356
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1357
|
+
' slow your request rate down and try again.',
|
|
1358
|
+
_response
|
|
1359
|
+
)
|
|
1360
|
+
elsif _response.status_code == 500
|
|
1361
|
+
raise ApiErrorResponseException.new(
|
|
1362
|
+
'Something unexpected happened. Please try again.',
|
|
1363
|
+
_response
|
|
1364
|
+
)
|
|
1365
|
+
end
|
|
1366
|
+
validate_response(_response)
|
|
1367
|
+
|
|
1368
|
+
# Return appropriate response type.
|
|
1369
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
1370
|
+
ApiResponse.new(
|
|
1371
|
+
_response, data: ConferenceMemberDetail.from_hash(decoded)
|
|
1372
|
+
)
|
|
1373
|
+
end
|
|
1374
|
+
|
|
1375
|
+
# Returns a (potentially empty) list of metadata for the recordings that
|
|
1376
|
+
# took place during the specified conference
|
|
1377
|
+
# @param [String] account_id Required parameter: Example:
|
|
1378
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1379
|
+
# @return [List of ConferenceRecordingMetadataResponse] response from the API call
|
|
1380
|
+
def get_query_metadata_for_account_and_conference(account_id,
|
|
1381
|
+
conference_id)
|
|
1382
|
+
# Prepare query url.
|
|
1383
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1384
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings'
|
|
1385
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1386
|
+
_query_builder,
|
|
1387
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1388
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false }
|
|
1389
|
+
)
|
|
1390
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1391
|
+
|
|
1392
|
+
# Prepare headers.
|
|
1393
|
+
_headers = {
|
|
1394
|
+
'accept' => 'application/json'
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
# Prepare and execute HttpRequest.
|
|
1398
|
+
_request = config.http_client.get(
|
|
1399
|
+
_query_url,
|
|
1400
|
+
headers: _headers
|
|
1401
|
+
)
|
|
1402
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1403
|
+
_response = execute_request(_request)
|
|
1404
|
+
|
|
1405
|
+
# Validate response against endpoint and global error codes.
|
|
1406
|
+
if _response.status_code == 400
|
|
1407
|
+
raise ApiErrorResponseException.new(
|
|
1408
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1409
|
+
' fix it before trying again.',
|
|
1410
|
+
_response
|
|
1411
|
+
)
|
|
1412
|
+
elsif _response.status_code == 401
|
|
1413
|
+
raise APIException.new(
|
|
1414
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1415
|
+
' credentials to authenticate to the API.',
|
|
1416
|
+
_response
|
|
1417
|
+
)
|
|
1418
|
+
elsif _response.status_code == 403
|
|
1419
|
+
raise ApiErrorResponseException.new(
|
|
1420
|
+
'User unauthorized to perform this action.',
|
|
1421
|
+
_response
|
|
1422
|
+
)
|
|
1423
|
+
elsif _response.status_code == 404
|
|
1424
|
+
raise ApiErrorResponseException.new(
|
|
1425
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1426
|
+
_response
|
|
1427
|
+
)
|
|
1428
|
+
elsif _response.status_code == 415
|
|
1429
|
+
raise ApiErrorResponseException.new(
|
|
1430
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1431
|
+
' please send it to us as `application/json`.',
|
|
1432
|
+
_response
|
|
1433
|
+
)
|
|
1434
|
+
elsif _response.status_code == 429
|
|
1435
|
+
raise ApiErrorResponseException.new(
|
|
1436
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1437
|
+
' slow your request rate down and try again.',
|
|
1438
|
+
_response
|
|
1439
|
+
)
|
|
1440
|
+
elsif _response.status_code == 500
|
|
1441
|
+
raise ApiErrorResponseException.new(
|
|
1442
|
+
'Something unexpected happened. Please try again.',
|
|
1443
|
+
_response
|
|
1444
|
+
)
|
|
1445
|
+
end
|
|
1446
|
+
validate_response(_response)
|
|
1447
|
+
|
|
1448
|
+
# Return appropriate response type.
|
|
1449
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
1450
|
+
ApiResponse.new(
|
|
1451
|
+
_response,
|
|
1452
|
+
data: decoded.map { |element| ConferenceRecordingMetadataResponse.from_hash(element) }
|
|
1453
|
+
)
|
|
1454
|
+
end
|
|
1455
|
+
|
|
1456
|
+
# Returns metadata for the specified recording
|
|
1457
|
+
# @param [String] account_id Required parameter: Example:
|
|
1458
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1459
|
+
# @param [String] recording_id Required parameter: Example:
|
|
1460
|
+
# @return [RecordingMetadataResponse] response from the API call
|
|
1461
|
+
def get_metadata_for_conference_recording(account_id,
|
|
1462
|
+
conference_id,
|
|
1463
|
+
recording_id)
|
|
1464
|
+
# Prepare query url.
|
|
1465
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1466
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}'
|
|
1467
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1468
|
+
_query_builder,
|
|
1469
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1470
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false },
|
|
1471
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
1472
|
+
)
|
|
1473
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1474
|
+
|
|
1475
|
+
# Prepare headers.
|
|
1476
|
+
_headers = {
|
|
1477
|
+
'accept' => 'application/json'
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
# Prepare and execute HttpRequest.
|
|
1481
|
+
_request = config.http_client.get(
|
|
1482
|
+
_query_url,
|
|
1483
|
+
headers: _headers
|
|
1484
|
+
)
|
|
1485
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1486
|
+
_response = execute_request(_request)
|
|
1487
|
+
|
|
1488
|
+
# Validate response against endpoint and global error codes.
|
|
1489
|
+
if _response.status_code == 400
|
|
1490
|
+
raise ApiErrorResponseException.new(
|
|
1491
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1492
|
+
' fix it before trying again.',
|
|
1493
|
+
_response
|
|
1494
|
+
)
|
|
1495
|
+
elsif _response.status_code == 401
|
|
1496
|
+
raise APIException.new(
|
|
1497
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1498
|
+
' credentials to authenticate to the API.',
|
|
1499
|
+
_response
|
|
1500
|
+
)
|
|
1501
|
+
elsif _response.status_code == 403
|
|
1502
|
+
raise ApiErrorResponseException.new(
|
|
1503
|
+
'User unauthorized to perform this action.',
|
|
1504
|
+
_response
|
|
1505
|
+
)
|
|
1506
|
+
elsif _response.status_code == 404
|
|
1507
|
+
raise ApiErrorResponseException.new(
|
|
1508
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1509
|
+
_response
|
|
1510
|
+
)
|
|
1511
|
+
elsif _response.status_code == 415
|
|
1512
|
+
raise ApiErrorResponseException.new(
|
|
1513
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1514
|
+
' please send it to us as `application/json`.',
|
|
1515
|
+
_response
|
|
1516
|
+
)
|
|
1517
|
+
elsif _response.status_code == 429
|
|
1518
|
+
raise ApiErrorResponseException.new(
|
|
1519
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1520
|
+
' slow your request rate down and try again.',
|
|
1521
|
+
_response
|
|
1522
|
+
)
|
|
1523
|
+
elsif _response.status_code == 500
|
|
1524
|
+
raise ApiErrorResponseException.new(
|
|
1525
|
+
'Something unexpected happened. Please try again.',
|
|
1526
|
+
_response
|
|
1527
|
+
)
|
|
1528
|
+
end
|
|
1529
|
+
validate_response(_response)
|
|
1530
|
+
|
|
1531
|
+
# Return appropriate response type.
|
|
1532
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
|
1533
|
+
ApiResponse.new(
|
|
1534
|
+
_response, data: RecordingMetadataResponse.from_hash(decoded)
|
|
1535
|
+
)
|
|
1536
|
+
end
|
|
1537
|
+
|
|
1538
|
+
# Downloads the specified recording
|
|
1539
|
+
# @param [String] account_id Required parameter: Example:
|
|
1540
|
+
# @param [String] conference_id Required parameter: Example:
|
|
1541
|
+
# @param [String] recording_id Required parameter: Example:
|
|
1542
|
+
# @return [Binary] response from the API call
|
|
1543
|
+
def get_stream_conference_recording_media(account_id,
|
|
1544
|
+
conference_id,
|
|
1545
|
+
recording_id)
|
|
1546
|
+
# Prepare query url.
|
|
1547
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1548
|
+
_query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media'
|
|
1549
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1550
|
+
_query_builder,
|
|
1551
|
+
'accountId' => { 'value' => account_id, 'encode' => false },
|
|
1552
|
+
'conferenceId' => { 'value' => conference_id, 'encode' => false },
|
|
1553
|
+
'recordingId' => { 'value' => recording_id, 'encode' => false }
|
|
1554
|
+
)
|
|
1555
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1556
|
+
|
|
1557
|
+
# Prepare and execute HttpRequest.
|
|
1558
|
+
_request = config.http_client.get(
|
|
1559
|
+
_query_url
|
|
1560
|
+
)
|
|
1561
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1562
|
+
_response = execute_request(_request, binary: true)
|
|
1563
|
+
|
|
1564
|
+
# Validate response against endpoint and global error codes.
|
|
1565
|
+
if _response.status_code == 400
|
|
1566
|
+
raise ApiErrorResponseException.new(
|
|
1567
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1568
|
+
' fix it before trying again.',
|
|
1569
|
+
_response
|
|
1570
|
+
)
|
|
1571
|
+
elsif _response.status_code == 401
|
|
1572
|
+
raise APIException.new(
|
|
1573
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1574
|
+
' credentials to authenticate to the API.',
|
|
1575
|
+
_response
|
|
1576
|
+
)
|
|
1577
|
+
elsif _response.status_code == 403
|
|
1578
|
+
raise ApiErrorResponseException.new(
|
|
1579
|
+
'User unauthorized to perform this action.',
|
|
1580
|
+
_response
|
|
1581
|
+
)
|
|
1582
|
+
elsif _response.status_code == 404
|
|
1583
|
+
raise ApiErrorResponseException.new(
|
|
1584
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
1585
|
+
_response
|
|
1586
|
+
)
|
|
1587
|
+
elsif _response.status_code == 415
|
|
1588
|
+
raise ApiErrorResponseException.new(
|
|
1589
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1590
|
+
' please send it to us as `application/json`.',
|
|
1591
|
+
_response
|
|
1592
|
+
)
|
|
1593
|
+
elsif _response.status_code == 429
|
|
1594
|
+
raise ApiErrorResponseException.new(
|
|
1595
|
+
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
1596
|
+
' slow your request rate down and try again.',
|
|
1597
|
+
_response
|
|
1598
|
+
)
|
|
1599
|
+
elsif _response.status_code == 500
|
|
1600
|
+
raise ApiErrorResponseException.new(
|
|
1601
|
+
'Something unexpected happened. Please try again.',
|
|
1602
|
+
_response
|
|
1603
|
+
)
|
|
1604
|
+
end
|
|
1605
|
+
validate_response(_response)
|
|
1606
|
+
|
|
1607
|
+
# Return appropriate response type.
|
|
1608
|
+
ApiResponse.new(
|
|
1609
|
+
_response, data: _response.raw_body
|
|
1610
|
+
)
|
|
1611
|
+
end
|
|
1612
|
+
|
|
1613
|
+
# Returns a list of metadata for the recordings associated with the
|
|
1614
|
+
# specified account. The list can be filtered by the optional from, to,
|
|
1615
|
+
# minStartTime, and maxStartTime arguments. The list is capped at 1000
|
|
1616
|
+
# entries and may be empty if no recordings match the specified criteria.
|
|
1617
|
+
# @param [String] account_id Required parameter: Example:
|
|
1618
|
+
# @param [String] from Optional parameter: Example:
|
|
1619
|
+
# @param [String] to Optional parameter: Example:
|
|
1620
|
+
# @param [String] min_start_time Optional parameter: Example:
|
|
1621
|
+
# @param [String] max_start_time Optional parameter: Example:
|
|
1622
|
+
# @return [List of RecordingMetadataResponse] response from the API call
|
|
1623
|
+
def get_query_metadata_for_account(account_id,
|
|
1624
|
+
from: nil,
|
|
1625
|
+
to: nil,
|
|
1626
|
+
min_start_time: nil,
|
|
1627
|
+
max_start_time: nil)
|
|
1628
|
+
# Prepare query url.
|
|
1629
|
+
_query_builder = config.get_base_uri(Server::VOICEDEFAULT)
|
|
1630
|
+
_query_builder << '/api/v2/accounts/{accountId}/recordings'
|
|
1631
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
|
1632
|
+
_query_builder,
|
|
1633
|
+
'accountId' => { 'value' => account_id, 'encode' => false }
|
|
1634
|
+
)
|
|
1635
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
|
1636
|
+
_query_builder,
|
|
1637
|
+
'from' => from,
|
|
1638
|
+
'to' => to,
|
|
1639
|
+
'minStartTime' => min_start_time,
|
|
1640
|
+
'maxStartTime' => max_start_time
|
|
1641
|
+
)
|
|
1642
|
+
_query_url = APIHelper.clean_url _query_builder
|
|
1643
|
+
|
|
1644
|
+
# Prepare headers.
|
|
1645
|
+
_headers = {
|
|
1646
|
+
'accept' => 'application/json'
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1649
|
+
# Prepare and execute HttpRequest.
|
|
1650
|
+
_request = config.http_client.get(
|
|
1651
|
+
_query_url,
|
|
1652
|
+
headers: _headers
|
|
1653
|
+
)
|
|
1654
|
+
VoiceBasicAuth.apply(config, _request)
|
|
1655
|
+
_response = execute_request(_request)
|
|
1656
|
+
|
|
1657
|
+
# Validate response against endpoint and global error codes.
|
|
1658
|
+
if _response.status_code == 400
|
|
1659
|
+
raise ApiErrorResponseException.new(
|
|
1660
|
+
'Something\'s not quite right... Your request is invalid. Please' \
|
|
1661
|
+
' fix it before trying again.',
|
|
1662
|
+
_response
|
|
1663
|
+
)
|
|
1664
|
+
elsif _response.status_code == 401
|
|
1665
|
+
raise APIException.new(
|
|
1666
|
+
'Your credentials are invalid. Please use your Bandwidth dashboard' \
|
|
1667
|
+
' credentials to authenticate to the API.',
|
|
1668
|
+
_response
|
|
1669
|
+
)
|
|
1670
|
+
elsif _response.status_code == 403
|
|
1671
|
+
raise ApiErrorResponseException.new(
|
|
1672
|
+
'User unauthorized to perform this action.',
|
|
1673
|
+
_response
|
|
1674
|
+
)
|
|
1675
|
+
elsif _response.status_code == 404
|
|
1676
|
+
raise ApiErrorResponseException.new(
|
|
1677
|
+
'The resource specified cannot be found or does not belong to you.',
|
|
592
1678
|
_response
|
|
593
1679
|
)
|
|
594
1680
|
elsif _response.status_code == 415
|
|
595
|
-
raise
|
|
596
|
-
'We don\'t support that media type.
|
|
597
|
-
' `application/json`.',
|
|
1681
|
+
raise ApiErrorResponseException.new(
|
|
1682
|
+
'We don\'t support that media type. If a request body is required,' \
|
|
1683
|
+
' please send it to us as `application/json`.',
|
|
598
1684
|
_response
|
|
599
1685
|
)
|
|
600
1686
|
elsif _response.status_code == 429
|
|
601
|
-
raise
|
|
1687
|
+
raise ApiErrorResponseException.new(
|
|
602
1688
|
'You\'re sending requests to this endpoint too frequently. Please' \
|
|
603
1689
|
' slow your request rate down and try again.',
|
|
604
1690
|
_response
|
|
605
1691
|
)
|
|
606
1692
|
elsif _response.status_code == 500
|
|
607
|
-
raise
|
|
1693
|
+
raise ApiErrorResponseException.new(
|
|
608
1694
|
'Something unexpected happened. Please try again.',
|
|
609
1695
|
_response
|
|
610
1696
|
)
|