bandwidth-sdk 1.0.1 → 1.0.2

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +27 -27
  3. data/README.md +18 -59
  4. data/lib/bandwidth/api_helper.rb +4 -0
  5. data/lib/bandwidth/client.rb +1 -1
  6. data/lib/bandwidth/configuration.rb +2 -2
  7. data/lib/bandwidth/messaging_lib/messaging/client.rb +1 -1
  8. data/lib/bandwidth/messaging_lib/messaging/controllers/base_controller.rb +1 -1
  9. data/lib/bandwidth/voice_lib/bxml/verbs/record.rb +26 -0
  10. data/lib/bandwidth/voice_lib/voice.rb +6 -5
  11. data/lib/bandwidth/voice_lib/voice/client.rb +1 -1
  12. data/lib/bandwidth/voice_lib/voice/controllers/api_controller.rb +178 -98
  13. data/lib/bandwidth/voice_lib/voice/controllers/base_controller.rb +1 -1
  14. data/lib/bandwidth/voice_lib/voice/models/api_call_response.rb +67 -40
  15. data/lib/bandwidth/voice_lib/voice/models/direction_enum.rb +17 -0
  16. data/lib/bandwidth/voice_lib/voice/models/duration.rb +78 -0
  17. data/lib/bandwidth/voice_lib/voice/models/file_format_enum.rb +17 -0
  18. data/lib/bandwidth/voice_lib/voice/models/recording_metadata_response.rb +152 -0
  19. data/lib/bandwidth/voice_lib/voice/models/state_enum.rb +2 -2
  20. data/lib/bandwidth/voice_lib/voice/models/temporal_unit.rb +62 -0
  21. data/lib/bandwidth/voice_lib/voice/models/transcription_status_enum.rb +20 -0
  22. metadata +15 -13
  23. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_exception.rb +0 -51
  24. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_not_found_exception.rb +0 -49
  25. data/lib/bandwidth/voice_lib/voice/exceptions/bandwidth_rate_limit_error_exception.rb +0 -56
  26. data/lib/bandwidth/voice_lib/voice/models/bandwidth_callback_message_voice.rb +0 -98
  27. data/lib/bandwidth/voice_lib/voice/models/field_error.rb +0 -44
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a08fba9df25add3682d001d09a80cc04b5c0565488a4526f06e4bc528dab5492
4
- data.tar.gz: 97299422f725aaf94f9d82c63dd042602f310c065f0b21742f5264bf2862fb4c
3
+ metadata.gz: 18591a5d5044520f1468b2739bf7f7d3f2e55c90256808ee87c88035b2547955
4
+ data.tar.gz: 94718076a51266243ac4da676d6719ae4c3c8143f1ee41a2d4f74845160f5a7c
5
5
  SHA512:
6
- metadata.gz: f54a8299f7ccfe91e5085898e5bc857778fccb2700bd8b62f5b18f8a1abad277683a708d18b77e39c4960a80664b4908ebf0b33d70699188b17d47f1c0b955f3
7
- data.tar.gz: c5cf922c1d5df2617d98d0efa00084104c27c2edc6a75b0db9d35097aa2ba658e5a78e8645e53900ccd8c264391a98b78118a11d66f475f199d0d07f6a54a9d3
6
+ metadata.gz: f4a3945a2bdc1dc56df26eaf365a6be187c25949accedcc1b711079273e42b29fcbffcb1a336a0a92f2e563638a01bfdfc0d6c2c2314fa7bb5be11b42f8c4cbe
7
+ data.tar.gz: 79820119110f3e897e7da7115a957db73ebaa3ad27255c96de2ab7d740415bd85e221aafc72561fdff7ad9666fe845755dd436d8aac071eb9b975ab80b61f566
data/LICENSE CHANGED
@@ -1,28 +1,28 @@
1
- License:
2
- ========
3
- The MIT License (MIT)
4
- http://opensource.org/licenses/MIT
5
-
6
- Copyright (c) 2014 - 2016 APIMATIC Limited
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy
9
- of this software and associated documentation files (the "Software"), to deal
10
- in the Software without restriction, including without limitation the rights
11
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- copies of the Software, and to permit persons to whom the Software is
13
- furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in
16
- all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- THE SOFTWARE.
25
-
26
- Trade Mark:
27
- ==========
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2016 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
28
  APIMATIC is a trade mark for APIMATIC Limited
data/README.md CHANGED
@@ -2,69 +2,28 @@
2
2
 
3
3
  Bandwidth's set of APIs
4
4
 
5
+ ## Install the Package
5
6
 
6
- ## Building
7
+ Install the gem from the command line:
7
8
 
8
- The generated code depends on a few Ruby gems. The references to these gems are added in the gemspec file. The easiest way to resolve the dependencies, build the gem and install it is through Rake:
9
-
10
- 1. Install Rake if not already installed: `gem install rake`
11
- 2. Install Bundler if not already installed: `gem install bundler`
12
- 3. From terminal/cmd navigate to the root directory of the SDK.
13
- 4. Invoke: `rake install`
14
-
15
- Alternatively, you can build and install the gem manually:
16
-
17
- 1. From terminal/cmd navigate to the root directory of the SDK.
18
- 2. Run the build command: `gem build bandwidth.gemspec`
19
- 3. Run the install command: `gem install bandwidth-1.0.1.gem`
20
-
21
- ![Installing Gem](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&gemVer=1.0.1&gemName=bandwidth&step=buildSDK)
22
-
23
- ## Installation
24
-
25
- The following section explains how to use the bandwidth ruby gem in a new Rails project using RubyMine™. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
26
-
27
- ### 1. Starting a new project
28
-
29
- Close any existing projects in RubyMine™ by selecting `File -> Close Project`. Next, click on `Create New Project` to create a new project from scratch.
30
-
31
- ![Create a new project in RubyMine - Step 1](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&step=createNewProject0)
32
-
33
- Next, provide `TestApp` as the project name, choose `Rails Application` as the project type, and click `OK`.
34
-
35
- ![Create a new Rails Application in RubyMine - Step 2](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&step=createNewProject1)
36
-
37
- In the next dialog make sure that the correct Ruby SDK is being used (minimum 2.0.0) and click `OK`.
38
-
39
- ![Create a new Rails Application in RubyMine - Step 3](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&step=createNewProject2)
40
-
41
- ### 2. Add reference of the gem
42
-
43
- In order to use the Tester gem in the new project we must add a gem reference. Locate the `Gemfile` in the Project Explorer window under the `TestApp` project node. The file contains references to all gems being used in the project. Here, add the reference to the library gem by adding the following line: `gem 'bandwidth', '~> 1.0.1'`
44
-
45
- ![Add new reference to the Gemfile](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&gemVer=1.0.1&gemName=bandwidth&step=addReference)
46
-
47
- ### 3. Adding a new Rails Controller
48
-
49
- Once the `TestApp` project is created, a folder named `controllers` will be visible in the *Project Explorer* under the following path: `TestApp > app > controllers`. Right click on this folder and select `New -> Run Rails Generator...`.
50
-
51
- ![Run Rails Generator on Controllers Folder](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&gemVer=1.0.1&gemName=bandwidth&step=addCode0)
9
+ ```ruby
10
+ gem install bandwidth-sdk -v 1.0.2
11
+ ```
52
12
 
53
- Selecting the said option will popup a small window where the generator names are displayed. Here, select the `controller` template.
13
+ Or add the gem to your Gemfile and run `bundle`:
54
14
 
55
- ![Create a new Controller](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&step=addCode1)
15
+ ```ruby
16
+ gem 'bandwidth-sdk', '1.0.2'
17
+ ```
56
18
 
57
- Next, a popup window will ask you for a Controller name and included Actions. For controller name provide `Hello` and include an action named `Index` and click `OK`.
19
+ For additional gem details, see the [RubyGems page for the bandwidth-sdk gem](https://rubygems.org/gems/bandwidth-sdk/versions/1.0.2).
58
20
 
59
- ![Add a new Controller](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&gemVer=1.0.1&gemName=bandwidth&step=addCode2)
60
21
 
61
- A new controller class named `HelloController` will be created in a file named `hello_controller.rb` containing a method named `Index`. In this method, add code for initialization and a sample for its usage.
62
22
 
63
- ![Initialize the library](https://apidocs.io/illustration/ruby?workspaceFolder=Bandwidth&gemName=bandwidth&step=addCode3)
64
23
 
65
- ## Usage
24
+ ## Initialize the API Client
66
25
 
67
- To initialize the API client, the following parameters need to be passed.
26
+ The following parameters are configurable for the API Client.
68
27
 
69
28
  | Parameter | Type | Description |
70
29
  | --- | --- | --- |
@@ -72,12 +31,13 @@ To initialize the API client, the following parameters need to be passed.
72
31
  | `messaging_basic_auth_password` | `String` | The password to use with basic authentication |
73
32
  | `voice_basic_auth_user_name` | `String` | The username to use with basic authentication |
74
33
  | `voice_basic_auth_password` | `String` | The password to use with basic authentication |
75
- | `timeout` | `Float` | The value to use for connection timeout |
76
- | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails |
77
- | `retry_interval` | `Float` | Pause in seconds between retries |
78
- | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff |
34
+ | `environment` | Environment | The API environment. <br> **Default: `Environment.PRODUCTION`** |
35
+ | `timeout` | `Float` | The value to use for connection timeout. <br> **Default: 60** |
36
+ | `max_retries` | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
37
+ | `retry_interval` | `Float` | Pause in seconds between retries. <br> **Default: 1** |
38
+ | `backoff_factor` | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 1** |
79
39
 
80
- The API client can be initialized using a Configuration object as following.
40
+ The API client can be initialized as following.
81
41
 
82
42
  ```ruby
83
43
  client = Bandwidth::Client.new(
@@ -101,7 +61,6 @@ API calls return an `ApiResponse` object that includes the following fields:
101
61
  | `errors` | Errors, if they exist |
102
62
  | `data` | The deserialized body of the HTTP response |
103
63
 
104
-
105
64
  ## Authorization
106
65
 
107
66
  This API does not require authentication.
@@ -235,6 +235,10 @@ module Bandwidth
235
235
  retval.merge!(APIHelper.form_encode(value, instance_name + '[' +
236
236
  key.to_s + ']', formatting: formatting))
237
237
  end
238
+ elsif obj.instance_of? File
239
+ retval[instance_name] = UploadIO.new(
240
+ obj, 'application/octet-stream', File.basename(obj.path)
241
+ )
238
242
  else
239
243
  retval[instance_name] = obj
240
244
  end
@@ -18,7 +18,7 @@ module Bandwidth
18
18
  @voice_client ||= Voice::Client.new(config: config)
19
19
  end
20
20
 
21
- def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
21
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
22
22
  backoff_factor: 1, environment: Environment::PRODUCTION,
23
23
  messaging_basic_auth_user_name: 'TODO: Replace',
24
24
  messaging_basic_auth_password: 'TODO: Replace',
@@ -39,7 +39,7 @@ module Bandwidth
39
39
  attr_reader :environments
40
40
  end
41
41
 
42
- def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
42
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
43
43
  backoff_factor: 1, environment: Environment::PRODUCTION,
44
44
  messaging_basic_auth_user_name: 'TODO: Replace',
45
45
  messaging_basic_auth_password: 'TODO: Replace',
@@ -115,7 +115,7 @@ module Bandwidth
115
115
  Environment::PRODUCTION => {
116
116
  Server::DEFAULT => 'api.bandwidth.com',
117
117
  Server::MESSAGINGDEFAULT => 'https://messaging.bandwidth.com/api/v2',
118
- Server::VOICEDEFAULT => 'https://voice.bandwidth.com/api/v2/'
118
+ Server::VOICEDEFAULT => 'https://voice.bandwidth.com'
119
119
  }
120
120
  }
121
121
 
@@ -15,7 +15,7 @@ module Bandwidth
15
15
  @client ||= APIController.new config
16
16
  end
17
17
 
18
- def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
18
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
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',
@@ -29,7 +29,7 @@ module Bandwidth
29
29
  @http_call_back.on_before_request(request) if @http_call_back
30
30
 
31
31
  APIHelper.clean_hash(request.headers)
32
- request.headers = @global_headers.clone.merge(request.headers)
32
+ request.headers.merge!(@global_headers)
33
33
 
34
34
  response = if binary
35
35
  config.http_client.execute_as_binary(request)
@@ -0,0 +1,26 @@
1
+
2
+ require_relative 'xml_verb'
3
+
4
+ module Bandwidth
5
+ module Voice
6
+ # The Record verb is used to trigger call recording
7
+ class Record
8
+ include XmlVerb
9
+
10
+ def to_bxml(xml)
11
+ xml.Record(compact_hash({
12
+ 'tag' => tag,
13
+ 'username' => username,
14
+ 'password' => password,
15
+ 'recordCompleteUrl' => record_complete_url,
16
+ 'recordCompleteMethod' => record_complete_method,
17
+ 'recordingAvailableUrl' => recording_available_url,
18
+ 'recordingAvailableMethod' => recording_available_method,
19
+ 'terminatingDigits' => terminating_digits,
20
+ 'maxDuration' => max_duration,
21
+ 'fileFormat' => file_format
22
+ }))
23
+ end
24
+ end
25
+ end
26
+ end
@@ -7,20 +7,21 @@
7
7
  require_relative 'voice/client.rb'
8
8
 
9
9
  # Models
10
- require_relative 'voice/models/field_error.rb'
11
10
  require_relative 'voice/models/api_call_response.rb'
12
11
  require_relative 'voice/models/api_create_call_request.rb'
13
12
  require_relative 'voice/models/api_modify_call_request.rb'
14
- require_relative 'voice/models/bandwidth_callback_message_voice.rb'
13
+ require_relative 'voice/models/duration.rb'
14
+ require_relative 'voice/models/recording_metadata_response.rb'
15
+ require_relative 'voice/models/temporal_unit.rb'
15
16
  require_relative 'voice/models/answer_method_enum.rb'
17
+ require_relative 'voice/models/direction_enum.rb'
16
18
  require_relative 'voice/models/disconnect_method_enum.rb'
19
+ require_relative 'voice/models/file_format_enum.rb'
17
20
  require_relative 'voice/models/redirect_method_enum.rb'
18
21
  require_relative 'voice/models/state_enum.rb'
22
+ require_relative 'voice/models/transcription_status_enum.rb'
19
23
 
20
24
  # Exceptions
21
- require_relative 'voice/exceptions/bandwidth_exception.rb'
22
- require_relative 'voice/exceptions/bandwidth_not_found_exception.rb'
23
- require_relative 'voice/exceptions/bandwidth_rate_limit_error_exception.rb'
24
25
  # Controllers
25
26
  require_relative 'voice/controllers/base_controller.rb'
26
27
  require_relative 'voice/controllers/api_controller.rb'
@@ -15,7 +15,7 @@ module Bandwidth
15
15
  @client ||= APIController.new config
16
16
  end
17
17
 
18
- def initialize(timeout: 0, max_retries: 0, retry_interval: 1,
18
+ def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
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',
@@ -19,7 +19,7 @@ module Voice
19
19
  body: nil)
20
20
  # Prepare query url.
21
21
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
22
- _query_builder << '/accounts/{accountId}/calls'
22
+ _query_builder << '/api/v2/accounts/{accountId}/calls'
23
23
  _query_builder = APIHelper.append_url_with_template_parameters(
24
24
  _query_builder,
25
25
  'accountId' => account_id
@@ -40,54 +40,6 @@ module Voice
40
40
  )
41
41
  VoiceBasicAuth.apply(config, _request)
42
42
  _response = execute_request(_request)
43
-
44
- # Validate response against endpoint and global error codes.
45
- if _response.status_code == 400
46
- raise BandwidthException.new(
47
- '400 request is malformed or invalid',
48
- _response
49
- )
50
- elsif _response.status_code == 401
51
- raise BandwidthException.new(
52
- '401 The specified user does not have access to the account',
53
- _response
54
- )
55
- elsif _response.status_code == 403
56
- raise BandwidthException.new(
57
- '403 The user does not have access to the API',
58
- _response
59
- )
60
- elsif _response.status_code == 404
61
- raise BandwidthNotFoundException.new(
62
- '404 he call-id is no longer active, or the path is not found',
63
- _response
64
- )
65
- elsif _response.status_code == 409
66
- raise BandwidthException.new(
67
- '409 Error when modifying a call that is unable to be modified',
68
- _response
69
- )
70
- elsif _response.status_code == 415
71
- raise BandwidthException.new(
72
- '415 The content-type of the request is incorrect',
73
- _response
74
- )
75
- elsif _response.status_code == 429
76
- raise BandwidthRateLimitErrorException.new(
77
- '429 The rate limit has been reached',
78
- _response
79
- )
80
- elsif _response.status_code == 500
81
- raise BandwidthException.new(
82
- '500 Unknown server error',
83
- _response
84
- )
85
- elsif _response.status_code == 503
86
- raise BandwidthException.new(
87
- '503 The service is unavailable for some reason',
88
- _response
89
- )
90
- end
91
43
  validate_response(_response)
92
44
 
93
45
  # Return appropriate response type.
@@ -95,7 +47,7 @@ module Voice
95
47
  ApiResponse.new(_response, data: ApiCallResponse.from_hash(decoded))
96
48
  end
97
49
 
98
- # Creates a call request
50
+ # Interrupts and replaces an active call's BXML document
99
51
  # @param [String] account_id Required parameter: Example:
100
52
  # @param [String] call_id Required parameter: Example:
101
53
  # @param [ApiModifyCallRequest] body Optional parameter: Example:
@@ -105,7 +57,7 @@ module Voice
105
57
  body: nil)
106
58
  # Prepare query url.
107
59
  _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
108
- _query_builder << '/accounts/{accountId}/calls/{callId}'
60
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}'
109
61
  _query_builder = APIHelper.append_url_with_template_parameters(
110
62
  _query_builder,
111
63
  'accountId' => account_id,
@@ -126,59 +78,187 @@ module Voice
126
78
  )
127
79
  VoiceBasicAuth.apply(config, _request)
128
80
  _response = execute_request(_request)
81
+ validate_response(_response)
82
+
83
+ # Return appropriate response type.
84
+ ApiResponse.new(_response)
85
+ end
86
+
87
+ # Returns a (potentially empty) list of metadata for the recordings that
88
+ # took place during the specified call
89
+ # @param [String] account_id Required parameter: Example:
90
+ # @param [String] call_id Required parameter: Example:
91
+ # @return [List of RecordingMetadataResponse] response from the API call
92
+ def get_query_metadata_for_account_and_call(account_id,
93
+ call_id)
94
+ # Prepare query url.
95
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
96
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings'
97
+ _query_builder = APIHelper.append_url_with_template_parameters(
98
+ _query_builder,
99
+ 'accountId' => account_id,
100
+ 'callId' => call_id
101
+ )
102
+ _query_url = APIHelper.clean_url _query_builder
103
+
104
+ # Prepare headers.
105
+ _headers = {
106
+ 'accept' => 'application/json'
107
+ }
108
+
109
+ # Prepare and execute HttpRequest.
110
+ _request = config.http_client.get(
111
+ _query_url,
112
+ headers: _headers
113
+ )
114
+ VoiceBasicAuth.apply(config, _request)
115
+ _response = execute_request(_request)
116
+ validate_response(_response)
117
+
118
+ # Return appropriate response type.
119
+ decoded = APIHelper.json_deserialize(_response.raw_body)
120
+ ApiResponse.new(
121
+ _response,
122
+ data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) }
123
+ )
124
+ end
125
+
126
+ # Returns metadata for the specified recording
127
+ # @param [String] recording_id Required parameter: Example:
128
+ # @param [String] account_id Required parameter: Example:
129
+ # @param [String] call_id Required parameter: Example:
130
+ # @return [RecordingMetadataResponse] response from the API call
131
+ def get_metadata_for_recording(recording_id,
132
+ account_id,
133
+ call_id)
134
+ # Prepare query url.
135
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
136
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
137
+ _query_builder = APIHelper.append_url_with_template_parameters(
138
+ _query_builder,
139
+ 'recordingId' => recording_id,
140
+ 'accountId' => account_id,
141
+ 'callId' => call_id
142
+ )
143
+ _query_url = APIHelper.clean_url _query_builder
144
+
145
+ # Prepare headers.
146
+ _headers = {
147
+ 'accept' => 'application/json'
148
+ }
149
+
150
+ # Prepare and execute HttpRequest.
151
+ _request = config.http_client.get(
152
+ _query_url,
153
+ headers: _headers
154
+ )
155
+ VoiceBasicAuth.apply(config, _request)
156
+ _response = execute_request(_request)
157
+ validate_response(_response)
158
+
159
+ # Return appropriate response type.
160
+ decoded = APIHelper.json_deserialize(_response.raw_body)
161
+ ApiResponse.new(_response,
162
+ data: RecordingMetadataResponse.from_hash(decoded))
163
+ end
129
164
 
130
- # Validate response against endpoint and global error codes.
131
- if _response.status_code == 400
132
- raise BandwidthException.new(
133
- '400 request is malformed or invalid',
134
- _response
135
- )
136
- elsif _response.status_code == 401
137
- raise BandwidthException.new(
138
- '401 The specified user does not have access to the account',
139
- _response
140
- )
141
- elsif _response.status_code == 403
142
- raise BandwidthException.new(
143
- '403 The user does not have access to the API',
144
- _response
145
- )
146
- elsif _response.status_code == 404
147
- raise BandwidthNotFoundException.new(
148
- '404 he call-id is no longer active, or the path is not found',
149
- _response
150
- )
151
- elsif _response.status_code == 409
152
- raise BandwidthException.new(
153
- '409 Error when modifying a call that is unable to be modified',
154
- _response
155
- )
156
- elsif _response.status_code == 415
157
- raise BandwidthException.new(
158
- '415 The content-type of the request is incorrect',
159
- _response
160
- )
161
- elsif _response.status_code == 429
162
- raise BandwidthRateLimitErrorException.new(
163
- '429 The rate limit has been reached',
164
- _response
165
- )
166
- elsif _response.status_code == 500
167
- raise BandwidthException.new(
168
- '500 Unknown server error',
169
- _response
170
- )
171
- elsif _response.status_code == 503
172
- raise BandwidthException.new(
173
- '503 The service is unavailable for some reason',
174
- _response
175
- )
176
- end
165
+ # Deletes the specified recording
166
+ # @param [String] recording_id Required parameter: Example:
167
+ # @param [String] account_id Required parameter: Example:
168
+ # @param [String] call_id Required parameter: Example:
169
+ # @return [void] response from the API call
170
+ def delete_recording(recording_id,
171
+ account_id,
172
+ call_id)
173
+ # Prepare query url.
174
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
175
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}'
176
+ _query_builder = APIHelper.append_url_with_template_parameters(
177
+ _query_builder,
178
+ 'recordingId' => recording_id,
179
+ 'accountId' => account_id,
180
+ 'callId' => call_id
181
+ )
182
+ _query_url = APIHelper.clean_url _query_builder
183
+
184
+ # Prepare and execute HttpRequest.
185
+ _request = config.http_client.delete(
186
+ _query_url
187
+ )
188
+ VoiceBasicAuth.apply(config, _request)
189
+ _response = execute_request(_request)
177
190
  validate_response(_response)
178
191
 
179
192
  # Return appropriate response type.
180
193
  ApiResponse.new(_response)
181
194
  end
195
+
196
+ # Downloads the specified recording
197
+ # @param [String] account_id Required parameter: Example:
198
+ # @param [String] call_id Required parameter: Example:
199
+ # @param [String] recording_id Required parameter: Example:
200
+ # @return [String] response from the API call
201
+ def get_stream_recording_media(account_id,
202
+ call_id,
203
+ recording_id)
204
+ # Prepare query url.
205
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
206
+ _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}/recordings/{recordingId}/media'
207
+ _query_builder = APIHelper.append_url_with_template_parameters(
208
+ _query_builder,
209
+ 'accountId' => account_id,
210
+ 'callId' => call_id,
211
+ 'recordingId' => recording_id
212
+ )
213
+ _query_url = APIHelper.clean_url _query_builder
214
+
215
+ # Prepare and execute HttpRequest.
216
+ _request = config.http_client.get(
217
+ _query_url
218
+ )
219
+ VoiceBasicAuth.apply(config, _request)
220
+ _response = execute_request(_request)
221
+ validate_response(_response)
222
+
223
+ # Return appropriate response type.
224
+ ApiResponse.new(_response, data: _response.raw_body)
225
+ end
226
+
227
+ # Returns a (potentially empty; capped at 1000) list of metadata for the
228
+ # recordings associated with the specified account
229
+ # @param [String] account_id Required parameter: Example:
230
+ # @return [List of RecordingMetadataResponse] response from the API call
231
+ def get_query_metadata_for_account(account_id)
232
+ # Prepare query url.
233
+ _query_builder = config.get_base_uri(Server::VOICEDEFAULT)
234
+ _query_builder << '/api/v2/accounts/{accountId}/recordings'
235
+ _query_builder = APIHelper.append_url_with_template_parameters(
236
+ _query_builder,
237
+ 'accountId' => account_id
238
+ )
239
+ _query_url = APIHelper.clean_url _query_builder
240
+
241
+ # Prepare headers.
242
+ _headers = {
243
+ 'accept' => 'application/json'
244
+ }
245
+
246
+ # Prepare and execute HttpRequest.
247
+ _request = config.http_client.get(
248
+ _query_url,
249
+ headers: _headers
250
+ )
251
+ VoiceBasicAuth.apply(config, _request)
252
+ _response = execute_request(_request)
253
+ validate_response(_response)
254
+
255
+ # Return appropriate response type.
256
+ decoded = APIHelper.json_deserialize(_response.raw_body)
257
+ ApiResponse.new(
258
+ _response,
259
+ data: decoded.map { |element| RecordingMetadataResponse.from_hash(element) }
260
+ )
261
+ end
182
262
  end
183
263
  end
184
264
  end