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