bandwidth-sdk 2.1.1 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +85 -70
  3. data/lib/bandwidth.rb +7 -1
  4. data/lib/bandwidth/client.rb +20 -2
  5. data/lib/bandwidth/configuration.rb +45 -9
  6. data/lib/bandwidth/http/auth/two_factor_auth_basic_auth.rb +22 -0
  7. data/lib/bandwidth/http/auth/web_rtc_basic_auth.rb +22 -0
  8. data/lib/bandwidth/http/faraday_client.rb +2 -6
  9. data/lib/bandwidth/messaging_lib/messaging.rb +1 -3
  10. data/lib/bandwidth/messaging_lib/messaging/client.rb +11 -2
  11. data/lib/bandwidth/messaging_lib/messaging/controllers/api_controller.rb +45 -88
  12. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  13. data/lib/bandwidth/messaging_lib/messaging/exceptions/{generic_client_exception.rb → messaging_exception.rb} +2 -14
  14. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth.rb +20 -0
  15. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/client.rb +49 -0
  16. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/api_controller.rb +153 -0
  17. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/controllers/base_controller.rb +49 -0
  18. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/exceptions/invalid_request_exception.rb +29 -0
  19. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_code_request_schema.rb +88 -0
  20. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_messaging_response.rb +35 -0
  21. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_code_response.rb +35 -0
  22. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_verify_request_schema.rb +94 -0
  23. data/lib/bandwidth/two_factor_auth_lib/two_factor_auth/models/two_factor_voice_response.rb +35 -0
  24. data/lib/bandwidth/utilities/file_wrapper.rb +17 -0
  25. data/lib/bandwidth/voice_lib/bxml/verbs/bridge.rb +22 -0
  26. data/lib/bandwidth/voice_lib/bxml/verbs/conference.rb +28 -0
  27. data/lib/bandwidth/voice_lib/bxml/verbs/gather.rb +8 -0
  28. data/lib/bandwidth/voice_lib/bxml/verbs/phone_number.rb +2 -0
  29. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +5 -1
  30. data/lib/bandwidth/voice_lib/bxml/verbs/send_dtmf.rb +4 -1
  31. data/lib/bandwidth/voice_lib/bxml/verbs/start_recording.rb +4 -1
  32. data/lib/bandwidth/voice_lib/voice.rb +13 -4
  33. data/lib/bandwidth/voice_lib/voice/client.rb +11 -2
  34. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +629 -112
  35. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  36. data/lib/bandwidth/voice_lib/voice/exceptions/{error_response_exception.rb → api_error_response_exception.rb} +3 -3
  37. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +11 -2
  38. data/lib/bandwidth/voice_lib/voice/models/api_call_state_response.rb +164 -0
  39. data/lib/bandwidth/voice_lib/voice/models/api_create_call_request.rb +20 -2
  40. data/lib/bandwidth/voice_lib/voice/models/api_modify_call_request.rb +1 -1
  41. data/lib/bandwidth/voice_lib/voice/models/api_transcribe_recording_request.rb +71 -0
  42. data/lib/bandwidth/voice_lib/voice/models/call_engine_modify_conference_request.rb +35 -0
  43. data/lib/bandwidth/voice_lib/voice/models/callback_method_enum.rb +35 -0
  44. data/lib/bandwidth/voice_lib/voice/models/disconnect_cause_enum.rb +47 -0
  45. data/lib/bandwidth/voice_lib/voice/models/modify_call_recording_state.rb +1 -1
  46. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +35 -25
  47. data/lib/bandwidth/voice_lib/voice/models/state1_enum.rb +4 -7
  48. data/lib/bandwidth/voice_lib/voice/models/state2_enum.rb +20 -0
  49. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +7 -4
  50. data/lib/bandwidth/voice_lib/voice/models/status1_enum.rb +26 -0
  51. data/lib/bandwidth/voice_lib/voice/models/status2_enum.rb +32 -0
  52. data/lib/bandwidth/voice_lib/voice/models/status_enum.rb +17 -0
  53. data/lib/bandwidth/{messaging_lib/messaging/models/field_error.rb → voice_lib/voice/models/transcript.rb} +15 -15
  54. data/lib/bandwidth/voice_lib/voice/models/transcription.rb +62 -0
  55. data/lib/bandwidth/voice_lib/voice/models/transcription_response.rb +42 -0
  56. data/lib/bandwidth/web_rtc_lib/web_rtc.rb +21 -0
  57. data/lib/bandwidth/web_rtc_lib/web_rtc/client.rb +49 -0
  58. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/api_controller.rb +682 -0
  59. data/lib/bandwidth/web_rtc_lib/web_rtc/controllers/base_controller.rb +49 -0
  60. data/lib/bandwidth/{messaging_lib/messaging/exceptions/path_client_exception.rb → web_rtc_lib/web_rtc/exceptions/error_exception.rb} +4 -19
  61. data/lib/bandwidth/web_rtc_lib/web_rtc/models/accounts_participants_response.rb +47 -0
  62. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant.rb +83 -0
  63. data/lib/bandwidth/web_rtc_lib/web_rtc/models/participant_subscription.rb +35 -0
  64. data/lib/bandwidth/web_rtc_lib/web_rtc/models/publish_permission_enum.rb +17 -0
  65. data/lib/bandwidth/web_rtc_lib/web_rtc/models/session.rb +44 -0
  66. data/lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb +54 -0
  67. metadata +58 -11
  68. data/lib/bandwidth/voice_lib/voice/models/api_get_account_recordings_metadata_request.rb +0 -65
  69. data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +0 -20
  70. data/lib/bandwidth/voice_lib/voice/models/type_enum.rb +0 -32
@@ -28,8 +28,16 @@ module Bandwidth
28
28
  s.to_bxml(xml)
29
29
  end
30
30
  end
31
+ def nest_verbs_list(xml, property)
32
+ if property
33
+ property.each do |verb|
34
+ verb.to_bxml(xml)
35
+ end
36
+ end
37
+ end
31
38
  embedded_xml(xml, speak_sentence, SpeakSentence)
32
39
  embedded_xml(xml, play_audio, PlayAudio)
40
+ nest_verbs_list(xml, nested_verbs)
33
41
  end
34
42
  end
35
43
  end
@@ -8,6 +8,8 @@ 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
15
  'tag' => tag
@@ -17,7 +17,11 @@ 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
21
25
  }))
22
26
  end
23
27
  end
@@ -6,7 +6,10 @@ module Bandwidth
6
6
  include XmlVerb
7
7
 
8
8
  def to_bxml(xml)
9
- xml.SendDtmf(dtmf)
9
+ xml.SendDtmf(dtmf, compact_hash({
10
+ 'toneDuration' => tone_duration,
11
+ 'toneInterval' => tone_interval
12
+ }))
10
13
  end
11
14
  end
12
15
  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
@@ -8,23 +8,32 @@ 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_transcribe_recording_request.rb'
15
+ require_relative 'voice/models/call_engine_modify_conference_request.rb'
14
16
  require_relative 'voice/models/modify_call_recording_state.rb'
15
17
  require_relative 'voice/models/recording_metadata_response.rb'
18
+ require_relative 'voice/models/transcript.rb'
19
+ require_relative 'voice/models/transcription.rb'
20
+ require_relative 'voice/models/transcription_response.rb'
16
21
  require_relative 'voice/models/answer_method_enum.rb'
22
+ require_relative 'voice/models/callback_method_enum.rb'
17
23
  require_relative 'voice/models/direction_enum.rb'
24
+ require_relative 'voice/models/disconnect_cause_enum.rb'
18
25
  require_relative 'voice/models/disconnect_method_enum.rb'
19
26
  require_relative 'voice/models/file_format_enum.rb'
20
27
  require_relative 'voice/models/redirect_method_enum.rb'
21
28
  require_relative 'voice/models/state_enum.rb'
22
29
  require_relative 'voice/models/state1_enum.rb'
23
- require_relative 'voice/models/transcription_status_enum.rb'
24
- require_relative 'voice/models/type_enum.rb'
30
+ require_relative 'voice/models/state2_enum.rb'
31
+ require_relative 'voice/models/status_enum.rb'
32
+ require_relative 'voice/models/status1_enum.rb'
33
+ require_relative 'voice/models/status2_enum.rb'
25
34
 
26
35
  # Exceptions
27
- require_relative 'voice/exceptions/error_response_exception.rb'
36
+ require_relative 'voice/exceptions/api_error_response_exception.rb'
28
37
  # Controllers
29
38
  require_relative 'voice/controllers/base_controller.rb'
30
39
  require_relative 'voice/controllers/api_controller.rb'
@@ -19,8 +19,13 @@ module Bandwidth
19
19
  backoff_factor: 1, environment: Environment::PRODUCTION,
20
20
  messaging_basic_auth_user_name: 'TODO: Replace',
21
21
  messaging_basic_auth_password: 'TODO: Replace',
22
+ two_factor_auth_basic_auth_user_name: 'TODO: Replace',
23
+ two_factor_auth_basic_auth_password: 'TODO: Replace',
22
24
  voice_basic_auth_user_name: 'TODO: Replace',
23
- voice_basic_auth_password: 'TODO: Replace', config: nil)
25
+ voice_basic_auth_password: 'TODO: Replace',
26
+ web_rtc_basic_auth_user_name: 'TODO: Replace',
27
+ web_rtc_basic_auth_password: 'TODO: Replace',
28
+ config: nil)
24
29
  @config = if config.nil?
25
30
  Configuration.new(timeout: timeout,
26
31
  max_retries: max_retries,
@@ -29,8 +34,12 @@ module Bandwidth
29
34
  environment: environment,
30
35
  messaging_basic_auth_user_name: messaging_basic_auth_user_name,
31
36
  messaging_basic_auth_password: messaging_basic_auth_password,
37
+ two_factor_auth_basic_auth_user_name: two_factor_auth_basic_auth_user_name,
38
+ two_factor_auth_basic_auth_password: two_factor_auth_basic_auth_password,
32
39
  voice_basic_auth_user_name: voice_basic_auth_user_name,
33
- 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)
34
43
  else
35
44
  config
36
45
  end
@@ -11,7 +11,7 @@ module Voice
11
11
  super(config, http_call_back: http_call_back)
12
12
  end
13
13
 
14
- # Creates a call request
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
@@ -43,36 +43,41 @@ module Voice
43
43
 
44
44
  # Validate response against endpoint and global error codes.
45
45
  if _response.status_code == 400
46
- raise ErrorResponseException.new(
47
- 'Something didn\'t look right about that request. Please fix it' \
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 authenticate yourself',
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 ErrorResponseException.new(
58
- 'Your credentials are invalid. Please use your API credentials for' \
59
- ' the Bandwidth Dashboard.',
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.',
60
65
  _response
61
66
  )
62
67
  elsif _response.status_code == 415
63
- raise ErrorResponseException.new(
64
- 'We don\'t support that media type. Please send us' \
65
- ' `application/json`.',
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`.',
66
71
  _response
67
72
  )
68
73
  elsif _response.status_code == 429
69
- raise ErrorResponseException.new(
74
+ raise ApiErrorResponseException.new(
70
75
  'You\'re sending requests to this endpoint too frequently. Please' \
71
76
  ' slow your request rate down and try again.',
72
77
  _response
73
78
  )
74
79
  elsif _response.status_code == 500
75
- raise ErrorResponseException.new(
80
+ raise ApiErrorResponseException.new(
76
81
  'Something unexpected happened. Please try again.',
77
82
  _response
78
83
  )
@@ -84,6 +89,83 @@ module Voice
84
89
  ApiResponse.new(_response, data: ApiCallResponse.from_hash(decoded))
85
90
  end
86
91
 
92
+ # Returns near-realtime metadata about the specified call
93
+ # @param [String] account_id Required parameter: Example:
94
+ # @param [String] call_id Required parameter: Example:
95
+ # @return [ApiCallStateResponse] response from the API call
96
+ def get_call_state(account_id,
97
+ call_id)
98
+ # Prepare query url.
99
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
100
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
101
+ _query_builder = APIHelper.append_url_with_template_parameters(
102
+ _query_builder,
103
+ 'accountId' => account_id,
104
+ 'callId' => call_id
105
+ )
106
+ _query_url = APIHelper.clean_url _query_builder
107
+
108
+ # Prepare headers.
109
+ _headers = {
110
+ 'accept' => 'application/json'
111
+ }
112
+
113
+ # Prepare and execute HttpRequest.
114
+ _request = config.http_client.get(
115
+ _query_url,
116
+ headers: _headers
117
+ )
118
+ VoiceBasicAuth.apply(config, _request)
119
+ _response = execute_request(_request)
120
+
121
+ # Validate response against endpoint and global error codes.
122
+ if _response.status_code == 400
123
+ raise ApiErrorResponseException.new(
124
+ 'Something\'s not quite right... Your request is invalid. Please' \
125
+ ' fix it before trying again.',
126
+ _response
127
+ )
128
+ elsif _response.status_code == 401
129
+ raise APIException.new(
130
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
131
+ ' credentials to authenticate to the API.',
132
+ _response
133
+ )
134
+ elsif _response.status_code == 403
135
+ raise ApiErrorResponseException.new(
136
+ 'User unauthorized to perform this action.',
137
+ _response
138
+ )
139
+ elsif _response.status_code == 404
140
+ raise ApiErrorResponseException.new(
141
+ 'The resource specified cannot be found or does not belong to you.',
142
+ _response
143
+ )
144
+ elsif _response.status_code == 415
145
+ raise ApiErrorResponseException.new(
146
+ 'We don\'t support that media type. If a request body is required,' \
147
+ ' please send it to us as `application/json`.',
148
+ _response
149
+ )
150
+ elsif _response.status_code == 429
151
+ raise ApiErrorResponseException.new(
152
+ 'You\'re sending requests to this endpoint too frequently. Please' \
153
+ ' slow your request rate down and try again.',
154
+ _response
155
+ )
156
+ elsif _response.status_code == 500
157
+ raise ApiErrorResponseException.new(
158
+ 'Something unexpected happened. Please try again.',
159
+ _response
160
+ )
161
+ end
162
+ validate_response(_response)
163
+
164
+ # Return appropriate response type.
165
+ decoded = APIHelper.json_deserialize(_response.raw_body)
166
+ ApiResponse.new(_response, data: ApiCallStateResponse.from_hash(decoded))
167
+ end
168
+
87
169
  # Interrupts and replaces an active call's BXML document
88
170
  # @param [String] account_id Required parameter: Example:
89
171
  # @param [String] call_id Required parameter: Example:
@@ -118,40 +200,41 @@ module Voice
118
200
 
119
201
  # Validate response against endpoint and global error codes.
120
202
  if _response.status_code == 400
121
- raise APIException.new(
122
- 'The call can\'t be modified in its current state',
203
+ raise ApiErrorResponseException.new(
204
+ 'Something\'s not quite right... Your request is invalid. Please' \
205
+ ' fix it before trying again.',
123
206
  _response
124
207
  )
125
208
  elsif _response.status_code == 401
126
209
  raise APIException.new(
127
- 'Please authenticate yourself',
210
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
211
+ ' credentials to authenticate to the API.',
128
212
  _response
129
213
  )
130
214
  elsif _response.status_code == 403
131
- raise ErrorResponseException.new(
132
- 'Your credentials are invalid. Please use your API credentials for' \
133
- ' the Bandwidth Dashboard.',
215
+ raise ApiErrorResponseException.new(
216
+ 'User unauthorized to perform this action.',
134
217
  _response
135
218
  )
136
219
  elsif _response.status_code == 404
137
- raise APIException.new(
138
- 'The call never existed, no longer exists, or is inaccessible to you',
220
+ raise ApiErrorResponseException.new(
221
+ 'The resource specified cannot be found or does not belong to you.',
139
222
  _response
140
223
  )
141
224
  elsif _response.status_code == 415
142
- raise ErrorResponseException.new(
143
- 'We don\'t support that media type. Please send us' \
144
- ' `application/json`.',
225
+ raise ApiErrorResponseException.new(
226
+ 'We don\'t support that media type. If a request body is required,' \
227
+ ' please send it to us as `application/json`.',
145
228
  _response
146
229
  )
147
230
  elsif _response.status_code == 429
148
- raise ErrorResponseException.new(
231
+ raise ApiErrorResponseException.new(
149
232
  'You\'re sending requests to this endpoint too frequently. Please' \
150
233
  ' slow your request rate down and try again.',
151
234
  _response
152
235
  )
153
236
  elsif _response.status_code == 500
154
- raise ErrorResponseException.new(
237
+ raise ApiErrorResponseException.new(
155
238
  'Something unexpected happened. Please try again.',
156
239
  _response
157
240
  )
@@ -196,40 +279,41 @@ module Voice
196
279
 
197
280
  # Validate response against endpoint and global error codes.
198
281
  if _response.status_code == 400
199
- raise APIException.new(
200
- 'The call can\'t be modified in its current state',
282
+ raise ApiErrorResponseException.new(
283
+ 'Something\'s not quite right... Your request is invalid. Please' \
284
+ ' fix it before trying again.',
201
285
  _response
202
286
  )
203
287
  elsif _response.status_code == 401
204
288
  raise APIException.new(
205
- 'Please authenticate yourself',
289
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
290
+ ' credentials to authenticate to the API.',
206
291
  _response
207
292
  )
208
293
  elsif _response.status_code == 403
209
- raise ErrorResponseException.new(
210
- 'Your credentials are invalid. Please use your API credentials for' \
211
- ' the Bandwidth Dashboard.',
294
+ raise ApiErrorResponseException.new(
295
+ 'User unauthorized to perform this action.',
212
296
  _response
213
297
  )
214
298
  elsif _response.status_code == 404
215
- raise APIException.new(
216
- 'The call never existed, no longer exists, or is inaccessible to you',
299
+ raise ApiErrorResponseException.new(
300
+ 'The resource specified cannot be found or does not belong to you.',
217
301
  _response
218
302
  )
219
303
  elsif _response.status_code == 415
220
- raise ErrorResponseException.new(
221
- 'We don\'t support that media type. Please send us' \
222
- ' `application/json`.',
304
+ raise ApiErrorResponseException.new(
305
+ 'We don\'t support that media type. If a request body is required,' \
306
+ ' please send it to us as `application/json`.',
223
307
  _response
224
308
  )
225
309
  elsif _response.status_code == 429
226
- raise ErrorResponseException.new(
310
+ raise ApiErrorResponseException.new(
227
311
  'You\'re sending requests to this endpoint too frequently. Please' \
228
312
  ' slow your request rate down and try again.',
229
313
  _response
230
314
  )
231
315
  elsif _response.status_code == 500
232
- raise ErrorResponseException.new(
316
+ raise ApiErrorResponseException.new(
233
317
  'Something unexpected happened. Please try again.',
234
318
  _response
235
319
  )
@@ -244,9 +328,17 @@ module Voice
244
328
  # took place during the specified call
245
329
  # @param [String] account_id Required parameter: Example:
246
330
  # @param [String] call_id Required parameter: Example:
331
+ # @param [String] from Optional parameter: Example:
332
+ # @param [String] to Optional parameter: Example:
333
+ # @param [String] min_start_time Optional parameter: Example:
334
+ # @param [String] max_start_time Optional parameter: Example:
247
335
  # @return [List of RecordingMetadataResponse] response from the API call
248
336
  def get_query_metadata_for_account_and_call(account_id,
249
- call_id)
337
+ call_id,
338
+ from: nil,
339
+ to: nil,
340
+ min_start_time: nil,
341
+ max_start_time: nil)
250
342
  # Prepare query url.
251
343
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
252
344
  _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings'
@@ -255,6 +347,13 @@ module Voice
255
347
  'accountId' => account_id,
256
348
  'callId' => call_id
257
349
  )
350
+ _query_builder = APIHelper.append_url_with_query_parameters(
351
+ _query_builder,
352
+ 'from' => from,
353
+ 'to' => to,
354
+ 'minStartTime' => min_start_time,
355
+ 'maxStartTime' => max_start_time
356
+ )
258
357
  _query_url = APIHelper.clean_url _query_builder
259
358
 
260
359
  # Prepare headers.
@@ -272,36 +371,41 @@ module Voice
272
371
 
273
372
  # Validate response against endpoint and global error codes.
274
373
  if _response.status_code == 400
275
- raise ErrorResponseException.new(
276
- 'Something didn\'t look right about that request. Please fix it' \
277
- ' before trying again.',
374
+ raise ApiErrorResponseException.new(
375
+ 'Something\'s not quite right... Your request is invalid. Please' \
376
+ ' fix it before trying again.',
278
377
  _response
279
378
  )
280
379
  elsif _response.status_code == 401
281
380
  raise APIException.new(
282
- 'Please authenticate yourself',
381
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
382
+ ' credentials to authenticate to the API.',
283
383
  _response
284
384
  )
285
385
  elsif _response.status_code == 403
286
- raise ErrorResponseException.new(
287
- 'Your credentials are invalid. Please use your API credentials for' \
288
- ' the Bandwidth Dashboard.',
386
+ raise ApiErrorResponseException.new(
387
+ 'User unauthorized to perform this action.',
388
+ _response
389
+ )
390
+ elsif _response.status_code == 404
391
+ raise ApiErrorResponseException.new(
392
+ 'The resource specified cannot be found or does not belong to you.',
289
393
  _response
290
394
  )
291
395
  elsif _response.status_code == 415
292
- raise ErrorResponseException.new(
293
- 'We don\'t support that media type. Please send us' \
294
- ' `application/json`.',
396
+ raise ApiErrorResponseException.new(
397
+ 'We don\'t support that media type. If a request body is required,' \
398
+ ' please send it to us as `application/json`.',
295
399
  _response
296
400
  )
297
401
  elsif _response.status_code == 429
298
- raise ErrorResponseException.new(
402
+ raise ApiErrorResponseException.new(
299
403
  'You\'re sending requests to this endpoint too frequently. Please' \
300
404
  ' slow your request rate down and try again.',
301
405
  _response
302
406
  )
303
407
  elsif _response.status_code == 500
304
- raise ErrorResponseException.new(
408
+ raise ApiErrorResponseException.new(
305
409
  'Something unexpected happened. Please try again.',
306
410
  _response
307
411
  )
@@ -350,42 +454,41 @@ module Voice
350
454
 
351
455
  # Validate response against endpoint and global error codes.
352
456
  if _response.status_code == 400
353
- raise ErrorResponseException.new(
354
- 'Something didn\'t look right about that request. Please fix it' \
355
- ' before trying again.',
457
+ raise ApiErrorResponseException.new(
458
+ 'Something\'s not quite right... Your request is invalid. Please' \
459
+ ' fix it before trying again.',
356
460
  _response
357
461
  )
358
462
  elsif _response.status_code == 401
359
463
  raise APIException.new(
360
- 'Please authenticate yourself',
464
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
465
+ ' credentials to authenticate to the API.',
361
466
  _response
362
467
  )
363
468
  elsif _response.status_code == 403
364
- raise ErrorResponseException.new(
365
- 'Your credentials are invalid. Please use your API credentials for' \
366
- ' the Bandwidth Dashboard.',
469
+ raise ApiErrorResponseException.new(
470
+ 'User unauthorized to perform this action.',
367
471
  _response
368
472
  )
369
473
  elsif _response.status_code == 404
370
- raise APIException.new(
371
- 'The recording never existed, no longer exists, or is inaccessible' \
372
- ' to you',
474
+ raise ApiErrorResponseException.new(
475
+ 'The resource specified cannot be found or does not belong to you.',
373
476
  _response
374
477
  )
375
478
  elsif _response.status_code == 415
376
- raise ErrorResponseException.new(
377
- 'We don\'t support that media type. Please send us' \
378
- ' `application/json`.',
479
+ raise ApiErrorResponseException.new(
480
+ 'We don\'t support that media type. If a request body is required,' \
481
+ ' please send it to us as `application/json`.',
379
482
  _response
380
483
  )
381
484
  elsif _response.status_code == 429
382
- raise ErrorResponseException.new(
485
+ raise ApiErrorResponseException.new(
383
486
  'You\'re sending requests to this endpoint too frequently. Please' \
384
487
  ' slow your request rate down and try again.',
385
488
  _response
386
489
  )
387
490
  elsif _response.status_code == 500
388
- raise ErrorResponseException.new(
491
+ raise ApiErrorResponseException.new(
389
492
  'Something unexpected happened. Please try again.',
390
493
  _response
391
494
  )
@@ -426,42 +529,41 @@ module Voice
426
529
 
427
530
  # Validate response against endpoint and global error codes.
428
531
  if _response.status_code == 400
429
- raise ErrorResponseException.new(
430
- 'Something didn\'t look right about that request. Please fix it' \
431
- ' before trying again.',
532
+ raise ApiErrorResponseException.new(
533
+ 'Something\'s not quite right... Your request is invalid. Please' \
534
+ ' fix it before trying again.',
432
535
  _response
433
536
  )
434
537
  elsif _response.status_code == 401
435
538
  raise APIException.new(
436
- 'Please authenticate yourself',
539
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
540
+ ' credentials to authenticate to the API.',
437
541
  _response
438
542
  )
439
543
  elsif _response.status_code == 403
440
- raise ErrorResponseException.new(
441
- 'Your credentials are invalid. Please use your API credentials for' \
442
- ' the Bandwidth Dashboard.',
544
+ raise ApiErrorResponseException.new(
545
+ 'User unauthorized to perform this action.',
443
546
  _response
444
547
  )
445
548
  elsif _response.status_code == 404
446
- raise APIException.new(
447
- 'The recording never existed, no longer exists, or is inaccessible' \
448
- ' to you',
549
+ raise ApiErrorResponseException.new(
550
+ 'The resource specified cannot be found or does not belong to you.',
449
551
  _response
450
552
  )
451
553
  elsif _response.status_code == 415
452
- raise ErrorResponseException.new(
453
- 'We don\'t support that media type. Please send us' \
454
- ' `application/json`.',
554
+ raise ApiErrorResponseException.new(
555
+ 'We don\'t support that media type. If a request body is required,' \
556
+ ' please send it to us as `application/json`.',
455
557
  _response
456
558
  )
457
559
  elsif _response.status_code == 429
458
- raise ErrorResponseException.new(
560
+ raise ApiErrorResponseException.new(
459
561
  'You\'re sending requests to this endpoint too frequently. Please' \
460
562
  ' slow your request rate down and try again.',
461
563
  _response
462
564
  )
463
565
  elsif _response.status_code == 500
464
- raise ErrorResponseException.new(
566
+ raise ApiErrorResponseException.new(
465
567
  'Something unexpected happened. Please try again.',
466
568
  _response
467
569
  )
@@ -500,42 +602,41 @@ module Voice
500
602
 
501
603
  # Validate response against endpoint and global error codes.
502
604
  if _response.status_code == 400
503
- raise ErrorResponseException.new(
504
- 'Something didn\'t look right about that request. Please fix it' \
505
- ' before trying again.',
605
+ raise ApiErrorResponseException.new(
606
+ 'Something\'s not quite right... Your request is invalid. Please' \
607
+ ' fix it before trying again.',
506
608
  _response
507
609
  )
508
610
  elsif _response.status_code == 401
509
611
  raise APIException.new(
510
- 'Please authenticate yourself',
612
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
613
+ ' credentials to authenticate to the API.',
511
614
  _response
512
615
  )
513
616
  elsif _response.status_code == 403
514
- raise ErrorResponseException.new(
515
- 'Your credentials are invalid. Please use your API credentials for' \
516
- ' the Bandwidth Dashboard.',
617
+ raise ApiErrorResponseException.new(
618
+ 'User unauthorized to perform this action.',
517
619
  _response
518
620
  )
519
621
  elsif _response.status_code == 404
520
- raise APIException.new(
521
- 'The recording never existed, no longer exists, or is inaccessible' \
522
- ' to you',
622
+ raise ApiErrorResponseException.new(
623
+ 'The resource specified cannot be found or does not belong to you.',
523
624
  _response
524
625
  )
525
626
  elsif _response.status_code == 415
526
- raise ErrorResponseException.new(
527
- 'We don\'t support that media type. Please send us' \
528
- ' `application/json`.',
627
+ raise ApiErrorResponseException.new(
628
+ 'We don\'t support that media type. If a request body is required,' \
629
+ ' please send it to us as `application/json`.',
529
630
  _response
530
631
  )
531
632
  elsif _response.status_code == 429
532
- raise ErrorResponseException.new(
633
+ raise ApiErrorResponseException.new(
533
634
  'You\'re sending requests to this endpoint too frequently. Please' \
534
635
  ' slow your request rate down and try again.',
535
636
  _response
536
637
  )
537
638
  elsif _response.status_code == 500
538
- raise ErrorResponseException.new(
639
+ raise ApiErrorResponseException.new(
539
640
  'Something unexpected happened. Please try again.',
540
641
  _response
541
642
  )
@@ -546,11 +647,415 @@ module Voice
546
647
  ApiResponse.new(_response, data: _response.raw_body)
547
648
  end
548
649
 
549
- # Returns a (potentially empty; capped at 1000) list of metadata for the
550
- # recordings associated with the specified account
650
+ # Deletes the specified recording's media
551
651
  # @param [String] account_id Required parameter: Example:
652
+ # @param [String] call_id Required parameter: Example:
653
+ # @param [String] recording_id Required parameter: Example:
654
+ # @return [void] response from the API call
655
+ def delete_recording_media(account_id,
656
+ call_id,
657
+ recording_id)
658
+ # Prepare query url.
659
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
660
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
661
+ _query_builder = APIHelper.append_url_with_template_parameters(
662
+ _query_builder,
663
+ 'accountId' => account_id,
664
+ 'callId' => call_id,
665
+ 'recordingId' => recording_id
666
+ )
667
+ _query_url = APIHelper.clean_url _query_builder
668
+
669
+ # Prepare and execute HttpRequest.
670
+ _request = config.http_client.delete(
671
+ _query_url
672
+ )
673
+ VoiceBasicAuth.apply(config, _request)
674
+ _response = execute_request(_request)
675
+
676
+ # Validate response against endpoint and global error codes.
677
+ if _response.status_code == 400
678
+ raise ApiErrorResponseException.new(
679
+ 'Something\'s not quite right... Your request is invalid. Please' \
680
+ ' fix it before trying again.',
681
+ _response
682
+ )
683
+ elsif _response.status_code == 401
684
+ raise APIException.new(
685
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
686
+ ' credentials to authenticate to the API.',
687
+ _response
688
+ )
689
+ elsif _response.status_code == 403
690
+ raise ApiErrorResponseException.new(
691
+ 'User unauthorized to perform this action.',
692
+ _response
693
+ )
694
+ elsif _response.status_code == 404
695
+ raise ApiErrorResponseException.new(
696
+ 'The resource specified cannot be found or does not belong to you.',
697
+ _response
698
+ )
699
+ elsif _response.status_code == 415
700
+ raise ApiErrorResponseException.new(
701
+ 'We don\'t support that media type. If a request body is required,' \
702
+ ' please send it to us as `application/json`.',
703
+ _response
704
+ )
705
+ elsif _response.status_code == 429
706
+ raise ApiErrorResponseException.new(
707
+ 'You\'re sending requests to this endpoint too frequently. Please' \
708
+ ' slow your request rate down and try again.',
709
+ _response
710
+ )
711
+ elsif _response.status_code == 500
712
+ raise ApiErrorResponseException.new(
713
+ 'Something unexpected happened. Please try again.',
714
+ _response
715
+ )
716
+ end
717
+ validate_response(_response)
718
+
719
+ # Return appropriate response type.
720
+ ApiResponse.new(_response)
721
+ end
722
+
723
+ # Downloads the specified transcription
724
+ # @param [String] account_id Required parameter: Example:
725
+ # @param [String] call_id Required parameter: Example:
726
+ # @param [String] recording_id Required parameter: Example:
727
+ # @return [TranscriptionResponse] response from the API call
728
+ def get_recording_transcription(account_id,
729
+ call_id,
730
+ recording_id)
731
+ # Prepare query url.
732
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
733
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
734
+ _query_builder = APIHelper.append_url_with_template_parameters(
735
+ _query_builder,
736
+ 'accountId' => account_id,
737
+ 'callId' => call_id,
738
+ 'recordingId' => recording_id
739
+ )
740
+ _query_url = APIHelper.clean_url _query_builder
741
+
742
+ # Prepare headers.
743
+ _headers = {
744
+ 'accept' => 'application/json'
745
+ }
746
+
747
+ # Prepare and execute HttpRequest.
748
+ _request = config.http_client.get(
749
+ _query_url,
750
+ headers: _headers
751
+ )
752
+ VoiceBasicAuth.apply(config, _request)
753
+ _response = execute_request(_request)
754
+
755
+ # Validate response against endpoint and global error codes.
756
+ if _response.status_code == 400
757
+ raise ApiErrorResponseException.new(
758
+ 'Something\'s not quite right... Your request is invalid. Please' \
759
+ ' fix it before trying again.',
760
+ _response
761
+ )
762
+ elsif _response.status_code == 401
763
+ raise APIException.new(
764
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
765
+ ' credentials to authenticate to the API.',
766
+ _response
767
+ )
768
+ elsif _response.status_code == 403
769
+ raise ApiErrorResponseException.new(
770
+ 'User unauthorized to perform this action.',
771
+ _response
772
+ )
773
+ elsif _response.status_code == 404
774
+ raise ApiErrorResponseException.new(
775
+ 'The resource specified cannot be found or does not belong to you.',
776
+ _response
777
+ )
778
+ elsif _response.status_code == 415
779
+ raise ApiErrorResponseException.new(
780
+ 'We don\'t support that media type. If a request body is required,' \
781
+ ' please send it to us as `application/json`.',
782
+ _response
783
+ )
784
+ elsif _response.status_code == 429
785
+ raise ApiErrorResponseException.new(
786
+ 'You\'re sending requests to this endpoint too frequently. Please' \
787
+ ' slow your request rate down and try again.',
788
+ _response
789
+ )
790
+ elsif _response.status_code == 500
791
+ raise ApiErrorResponseException.new(
792
+ 'Something unexpected happened. Please try again.',
793
+ _response
794
+ )
795
+ end
796
+ validate_response(_response)
797
+
798
+ # Return appropriate response type.
799
+ decoded = APIHelper.json_deserialize(_response.raw_body)
800
+ ApiResponse.new(_response, data: TranscriptionResponse.from_hash(decoded))
801
+ end
802
+
803
+ # Requests that the specified recording be transcribed
804
+ # @param [String] account_id Required parameter: Example:
805
+ # @param [String] call_id Required parameter: Example:
806
+ # @param [String] recording_id Required parameter: Example:
807
+ # @param [ApiTranscribeRecordingRequest] body Optional parameter: Example:
808
+ # @return [void] response from the API call
809
+ def create_transcribe_recording(account_id,
810
+ call_id,
811
+ recording_id,
812
+ body: nil)
813
+ # Prepare query url.
814
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
815
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
816
+ _query_builder = APIHelper.append_url_with_template_parameters(
817
+ _query_builder,
818
+ 'accountId' => account_id,
819
+ 'callId' => call_id,
820
+ 'recordingId' => recording_id
821
+ )
822
+ _query_url = APIHelper.clean_url _query_builder
823
+
824
+ # Prepare headers.
825
+ _headers = {
826
+ 'content-type' => 'application/json; charset=utf-8'
827
+ }
828
+
829
+ # Prepare and execute HttpRequest.
830
+ _request = config.http_client.post(
831
+ _query_url,
832
+ headers: _headers,
833
+ parameters: body.to_json
834
+ )
835
+ VoiceBasicAuth.apply(config, _request)
836
+ _response = execute_request(_request)
837
+
838
+ # Validate response against endpoint and global error codes.
839
+ if _response.status_code == 400
840
+ raise ApiErrorResponseException.new(
841
+ 'Something\'s not quite right... Your request is invalid. Please' \
842
+ ' fix it before trying again.',
843
+ _response
844
+ )
845
+ elsif _response.status_code == 401
846
+ raise APIException.new(
847
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
848
+ ' credentials to authenticate to the API.',
849
+ _response
850
+ )
851
+ elsif _response.status_code == 403
852
+ raise ApiErrorResponseException.new(
853
+ 'User unauthorized to perform this action.',
854
+ _response
855
+ )
856
+ elsif _response.status_code == 404
857
+ raise ApiErrorResponseException.new(
858
+ 'The resource specified cannot be found or does not belong to you.',
859
+ _response
860
+ )
861
+ elsif _response.status_code == 410
862
+ raise ApiErrorResponseException.new(
863
+ 'The media for this recording has been deleted, so we can\'t' \
864
+ ' transcribe it',
865
+ _response
866
+ )
867
+ elsif _response.status_code == 415
868
+ raise ApiErrorResponseException.new(
869
+ 'We don\'t support that media type. If a request body is required,' \
870
+ ' please send it to us as `application/json`.',
871
+ _response
872
+ )
873
+ elsif _response.status_code == 429
874
+ raise ApiErrorResponseException.new(
875
+ 'You\'re sending requests to this endpoint too frequently. Please' \
876
+ ' slow your request rate down and try again.',
877
+ _response
878
+ )
879
+ elsif _response.status_code == 500
880
+ raise ApiErrorResponseException.new(
881
+ 'Something unexpected happened. Please try again.',
882
+ _response
883
+ )
884
+ end
885
+ validate_response(_response)
886
+
887
+ # Return appropriate response type.
888
+ ApiResponse.new(_response)
889
+ end
890
+
891
+ # Deletes the specified recording's transcription
892
+ # @param [String] account_id Required parameter: Example:
893
+ # @param [String] call_id Required parameter: Example:
894
+ # @param [String] recording_id Required parameter: Example:
895
+ # @return [void] response from the API call
896
+ def delete_recording_transcription(account_id,
897
+ call_id,
898
+ recording_id)
899
+ # Prepare query url.
900
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
901
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/transcription'
902
+ _query_builder = APIHelper.append_url_with_template_parameters(
903
+ _query_builder,
904
+ 'accountId' => account_id,
905
+ 'callId' => call_id,
906
+ 'recordingId' => recording_id
907
+ )
908
+ _query_url = APIHelper.clean_url _query_builder
909
+
910
+ # Prepare and execute HttpRequest.
911
+ _request = config.http_client.delete(
912
+ _query_url
913
+ )
914
+ VoiceBasicAuth.apply(config, _request)
915
+ _response = execute_request(_request)
916
+
917
+ # Validate response against endpoint and global error codes.
918
+ if _response.status_code == 400
919
+ raise ApiErrorResponseException.new(
920
+ 'Something\'s not quite right... Your request is invalid. Please' \
921
+ ' fix it before trying again.',
922
+ _response
923
+ )
924
+ elsif _response.status_code == 401
925
+ raise APIException.new(
926
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
927
+ ' credentials to authenticate to the API.',
928
+ _response
929
+ )
930
+ elsif _response.status_code == 403
931
+ raise ApiErrorResponseException.new(
932
+ 'User unauthorized to perform this action.',
933
+ _response
934
+ )
935
+ elsif _response.status_code == 404
936
+ raise ApiErrorResponseException.new(
937
+ 'The resource specified cannot be found or does not belong to you.',
938
+ _response
939
+ )
940
+ elsif _response.status_code == 415
941
+ raise ApiErrorResponseException.new(
942
+ 'We don\'t support that media type. If a request body is required,' \
943
+ ' please send it to us as `application/json`.',
944
+ _response
945
+ )
946
+ elsif _response.status_code == 429
947
+ raise ApiErrorResponseException.new(
948
+ 'You\'re sending requests to this endpoint too frequently. Please' \
949
+ ' slow your request rate down and try again.',
950
+ _response
951
+ )
952
+ elsif _response.status_code == 500
953
+ raise ApiErrorResponseException.new(
954
+ 'Something unexpected happened. Please try again.',
955
+ _response
956
+ )
957
+ end
958
+ validate_response(_response)
959
+
960
+ # Return appropriate response type.
961
+ ApiResponse.new(_response)
962
+ end
963
+
964
+ # Modify the conference state
965
+ # @param [String] account_id Required parameter: Example:
966
+ # @param [String] conference_id Required parameter: Example:
967
+ # @param [CallEngineModifyConferenceRequest] body Optional parameter:
968
+ # Example:
969
+ # @return [void] response from the API call
970
+ def modify_conference(account_id,
971
+ conference_id,
972
+ body: nil)
973
+ # Prepare query url.
974
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
975
+ _query_builder << '/api/v2/accounts/{accountId}/conferences/{conferenceId}'
976
+ _query_builder = APIHelper.append_url_with_template_parameters(
977
+ _query_builder,
978
+ 'accountId' => account_id,
979
+ 'conferenceId' => conference_id
980
+ )
981
+ _query_url = APIHelper.clean_url _query_builder
982
+
983
+ # Prepare headers.
984
+ _headers = {
985
+ 'content-type' => 'application/json; charset=utf-8'
986
+ }
987
+
988
+ # Prepare and execute HttpRequest.
989
+ _request = config.http_client.post(
990
+ _query_url,
991
+ headers: _headers,
992
+ parameters: body.to_json
993
+ )
994
+ VoiceBasicAuth.apply(config, _request)
995
+ _response = execute_request(_request)
996
+
997
+ # Validate response against endpoint and global error codes.
998
+ if _response.status_code == 400
999
+ raise ApiErrorResponseException.new(
1000
+ 'Something\'s not quite right... Your request is invalid. Please' \
1001
+ ' fix it before trying again.',
1002
+ _response
1003
+ )
1004
+ elsif _response.status_code == 401
1005
+ raise APIException.new(
1006
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
1007
+ ' credentials to authenticate to the API.',
1008
+ _response
1009
+ )
1010
+ elsif _response.status_code == 403
1011
+ raise ApiErrorResponseException.new(
1012
+ 'User unauthorized to perform this action.',
1013
+ _response
1014
+ )
1015
+ elsif _response.status_code == 404
1016
+ raise ApiErrorResponseException.new(
1017
+ 'The resource specified cannot be found or does not belong to you.',
1018
+ _response
1019
+ )
1020
+ elsif _response.status_code == 415
1021
+ raise ApiErrorResponseException.new(
1022
+ 'We don\'t support that media type. If a request body is required,' \
1023
+ ' please send it to us as `application/json`.',
1024
+ _response
1025
+ )
1026
+ elsif _response.status_code == 429
1027
+ raise ApiErrorResponseException.new(
1028
+ 'You\'re sending requests to this endpoint too frequently. Please' \
1029
+ ' slow your request rate down and try again.',
1030
+ _response
1031
+ )
1032
+ elsif _response.status_code == 500
1033
+ raise ApiErrorResponseException.new(
1034
+ 'Something unexpected happened. Please try again.',
1035
+ _response
1036
+ )
1037
+ end
1038
+ validate_response(_response)
1039
+
1040
+ # Return appropriate response type.
1041
+ ApiResponse.new(_response)
1042
+ end
1043
+
1044
+ # Returns a list of metadata for the recordings associated with the
1045
+ # specified account. The list can be filtered by the optional from, to,
1046
+ # minStartTime, and maxStartTime arguments. The list is capped at 1000
1047
+ # entries and may be empty if no recordings match the specified criteria.
1048
+ # @param [String] account_id Required parameter: Example:
1049
+ # @param [String] from Optional parameter: Example:
1050
+ # @param [String] to Optional parameter: Example:
1051
+ # @param [String] min_start_time Optional parameter: Example:
1052
+ # @param [String] max_start_time Optional parameter: Example:
552
1053
  # @return [List of RecordingMetadataResponse] response from the API call
553
- def get_query_metadata_for_account(account_id)
1054
+ def get_query_metadata_for_account(account_id,
1055
+ from: nil,
1056
+ to: nil,
1057
+ min_start_time: nil,
1058
+ max_start_time: nil)
554
1059
  # Prepare query url.
555
1060
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
556
1061
  _query_builder << '/api/v2/accounts/{accountId}/recordings'
@@ -558,6 +1063,13 @@ module Voice
558
1063
  _query_builder,
559
1064
  'accountId' => account_id
560
1065
  )
1066
+ _query_builder = APIHelper.append_url_with_query_parameters(
1067
+ _query_builder,
1068
+ 'from' => from,
1069
+ 'to' => to,
1070
+ 'minStartTime' => min_start_time,
1071
+ 'maxStartTime' => max_start_time
1072
+ )
561
1073
  _query_url = APIHelper.clean_url _query_builder
562
1074
 
563
1075
  # Prepare headers.
@@ -575,36 +1087,41 @@ module Voice
575
1087
 
576
1088
  # Validate response against endpoint and global error codes.
577
1089
  if _response.status_code == 400
578
- raise ErrorResponseException.new(
579
- 'Something didn\'t look right about that request. Please fix it' \
580
- ' before trying again.',
1090
+ raise ApiErrorResponseException.new(
1091
+ 'Something\'s not quite right... Your request is invalid. Please' \
1092
+ ' fix it before trying again.',
581
1093
  _response
582
1094
  )
583
1095
  elsif _response.status_code == 401
584
1096
  raise APIException.new(
585
- 'Please authenticate yourself',
1097
+ 'Your credentials are invalid. Please use your Bandwidth dashboard' \
1098
+ ' credentials to authenticate to the API.',
586
1099
  _response
587
1100
  )
588
1101
  elsif _response.status_code == 403
589
- raise ErrorResponseException.new(
590
- 'Your credentials are invalid. Please use your API credentials for' \
591
- ' the Bandwidth Dashboard.',
1102
+ raise ApiErrorResponseException.new(
1103
+ 'User unauthorized to perform this action.',
1104
+ _response
1105
+ )
1106
+ elsif _response.status_code == 404
1107
+ raise ApiErrorResponseException.new(
1108
+ 'The resource specified cannot be found or does not belong to you.',
592
1109
  _response
593
1110
  )
594
1111
  elsif _response.status_code == 415
595
- raise ErrorResponseException.new(
596
- 'We don\'t support that media type. Please send us' \
597
- ' `application/json`.',
1112
+ raise ApiErrorResponseException.new(
1113
+ 'We don\'t support that media type. If a request body is required,' \
1114
+ ' please send it to us as `application/json`.',
598
1115
  _response
599
1116
  )
600
1117
  elsif _response.status_code == 429
601
- raise ErrorResponseException.new(
1118
+ raise ApiErrorResponseException.new(
602
1119
  'You\'re sending requests to this endpoint too frequently. Please' \
603
1120
  ' slow your request rate down and try again.',
604
1121
  _response
605
1122
  )
606
1123
  elsif _response.status_code == 500
607
- raise ErrorResponseException.new(
1124
+ raise ApiErrorResponseException.new(
608
1125
  'Something unexpected happened. Please try again.',
609
1126
  _response
610
1127
  )