Skip to content

Commit 96a0cec

Browse files
SWI-3663 Update SDK Based on Recent Spec Changes (#110)
* Generate SDK with OpenAPI Generator Version 7.0.0 * Clean SDK using Rubocop * update README template * update get calls tests * remove unnecessary expect --------- Co-authored-by: ckoegel <[email protected]>
1 parent 8c708af commit 96a0cec

File tree

8 files changed

+340
-4
lines changed

8 files changed

+340
-4
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
| Ubuntu 20.04 | 2.7, 3.0, 3.1, 3.2 |
1313
| Ubuntu 22.04 | 2.7, 3.0, 3.1, 3.2 |
1414

15-
Bandwidth - the Ruby gem for the Bandwidth
15+
Bandwidth - the Ruby gem for the Bandwidth SDK
1616

17-
# Generated with the command:
17+
### Generated with the command:
1818
`openapi-generator generate -g ruby -i bandwidth.yml -c openapi-config.yml -o ./`
1919

2020
Bandwidth's Communication APIs
@@ -28,6 +28,12 @@ For more information, please visit [https://dev.bandwidth.com](https://dev.bandw
2828

2929
## Installation
3030

31+
### Install from RubyGems
32+
33+
```shell
34+
gem install bandwidth-sdk
35+
```
36+
3137
### Build a gem
3238

3339
To build the Ruby code into a gem:
@@ -103,6 +109,7 @@ Class | Method | HTTP request | Description
103109
------------ | ------------- | ------------- | -------------
104110
*Bandwidth::CallsApi* | [**create_call**](docs/CallsApi.md#create_call) | **POST** /accounts/{accountId}/calls | Create Call
105111
*Bandwidth::CallsApi* | [**get_call_state**](docs/CallsApi.md#get_call_state) | **GET** /accounts/{accountId}/calls/{callId} | Get Call State Information
112+
*Bandwidth::CallsApi* | [**list_calls**](docs/CallsApi.md#list_calls) | **GET** /accounts/{accountId}/calls | Get Calls
106113
*Bandwidth::CallsApi* | [**update_call**](docs/CallsApi.md#update_call) | **POST** /accounts/{accountId}/calls/{callId} | Update Call
107114
*Bandwidth::CallsApi* | [**update_call_bxml**](docs/CallsApi.md#update_call_bxml) | **PUT** /accounts/{accountId}/calls/{callId}/bxml | Update Call BXML
108115
*Bandwidth::ConferencesApi* | [**download_conference_recording**](docs/ConferencesApi.md#download_conference_recording) | **GET** /accounts/{accountId}/conferences/{conferenceId}/recordings/{recordingId}/media | Download Conference Recording

bandwidth.yml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,52 @@ paths:
275275
$ref: '#/components/responses/voiceTooManyRequestsError'
276276
'500':
277277
$ref: '#/components/responses/voiceInternalServerError'
278+
get:
279+
tags:
280+
- Calls
281+
summary: Get Calls
282+
description: >-
283+
Returns a max of 10000 calls, sorted by `createdTime` from oldest to
284+
newest.
285+
286+
287+
**NOTE:** If the number of calls in the account is bigger than
288+
`pageSize`, a `Link` header (with format `<{url}>; rel="next"`) will be
289+
returned in the response. The url can be used to retrieve the next page
290+
of call records.
291+
292+
Also, call information is kept for 7 days after the calls are hung up.
293+
If you attempt to retrieve information for a call that is older than 7
294+
days, you will get an empty array [] in response.
295+
operationId: listCalls
296+
parameters:
297+
- $ref: '#/components/parameters/accountId'
298+
- $ref: '#/components/parameters/to'
299+
- $ref: '#/components/parameters/from'
300+
- $ref: '#/components/parameters/minStartTimeCalls'
301+
- $ref: '#/components/parameters/maxStartTimeCalls'
302+
- $ref: '#/components/parameters/disconnectCause'
303+
- $ref: '#/components/parameters/pageSizeCalls'
304+
- $ref: '#/components/parameters/pageToken1'
305+
responses:
306+
'200':
307+
$ref: '#/components/responses/listCallsResponse'
308+
'400':
309+
$ref: '#/components/responses/voiceBadRequestError'
310+
'401':
311+
$ref: '#/components/responses/voiceUnauthorizedError'
312+
'403':
313+
$ref: '#/components/responses/voiceForbiddenError'
314+
'404':
315+
$ref: '#/components/responses/voiceNotFoundError'
316+
'405':
317+
$ref: '#/components/responses/voiceNotAllowedError'
318+
'415':
319+
$ref: '#/components/responses/voiceUnsupportedMediaTypeError'
320+
'429':
321+
$ref: '#/components/responses/voiceTooManyRequestsError'
322+
'500':
323+
$ref: '#/components/responses/voiceInternalServerError'
278324
servers: &ref_1
279325
- url: https://voice.bandwidth.com/api/v2
280326
description: Production
@@ -4491,6 +4537,14 @@ components:
44914537
application/json:
44924538
schema:
44934539
$ref: '#/components/schemas/callState'
4540+
listCallsResponse:
4541+
description: Calls retrieved successfully
4542+
content:
4543+
application/json:
4544+
schema:
4545+
type: array
4546+
items:
4547+
$ref: '#/components/schemas/callState'
44944548
getStatisticsResponse:
44954549
description: Statistics Found
44964550
content:
@@ -5106,6 +5160,38 @@ components:
51065160
default: 1000
51075161
description: Specifies the max number of conferences that will be returned.
51085162
example: 500
5163+
minStartTimeCalls:
5164+
name: minStartTime
5165+
in: query
5166+
required: false
5167+
schema:
5168+
type: string
5169+
description: >-
5170+
Filter results to calls which have a `startTime` after or including
5171+
`minStartTime` (in ISO8601 format).
5172+
example: '2022-06-21T19:13:21Z'
5173+
maxStartTimeCalls:
5174+
name: maxStartTime
5175+
in: query
5176+
required: false
5177+
schema:
5178+
type: string
5179+
description: >-
5180+
Filter results to calls which have a `startTime` before or including
5181+
`maxStartTime` (in ISO8601 format).
5182+
example: '2022-06-21T19:13:21Z'
5183+
pageSizeCalls:
5184+
name: pageSize
5185+
in: query
5186+
required: false
5187+
schema:
5188+
type: integer
5189+
format: int32
5190+
minimum: 1
5191+
maximum: 10000
5192+
default: 1000
5193+
description: Specifies the max number of calls that will be returned.
5194+
example: 500
51095195
pageToken1:
51105196
name: pageToken
51115197
in: query
@@ -5116,6 +5202,14 @@ components:
51165202
Not intended for explicit use. To use pagination, follow the links in
51175203
the `Link` header of the response, as indicated in the endpoint
51185204
description.
5205+
disconnectCause:
5206+
name: disconnectCause
5207+
in: query
5208+
required: false
5209+
schema:
5210+
type: string
5211+
description: Filter results to calls with specified call Disconnect Cause.
5212+
example: hangup
51195213
requestId:
51205214
name: requestId
51215215
in: path

custom_templates/README.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
| Ubuntu 20.04 | 2.7, 3.0, 3.1, 3.2 |
1313
| Ubuntu 22.04 | 2.7, 3.0, 3.1, 3.2 |
1414

15-
{{moduleName}} - the Ruby gem for the {{appName}}
15+
{{moduleName}} - the Ruby gem for the {{appName}} SDK
1616

17-
# Generated with the command:
17+
### Generated with the command:
1818
`openapi-generator generate -g ruby -i bandwidth.yml -c openapi-config.yml -o ./`
1919

2020
{{#appDescriptionWithNewLines}}
@@ -35,6 +35,12 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
3535

3636
## Installation
3737

38+
### Install from RubyGems
39+
40+
```shell
41+
gem install {{{gemName}}}
42+
```
43+
3844
### Build a gem
3945

4046
To build the Ruby code into a gem:

docs/CallsApi.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All URIs are relative to *http://localhost*
66
| ------ | ------------ | ----------- |
77
| [**create_call**](CallsApi.md#create_call) | **POST** /accounts/{accountId}/calls | Create Call |
88
| [**get_call_state**](CallsApi.md#get_call_state) | **GET** /accounts/{accountId}/calls/{callId} | Get Call State Information |
9+
| [**list_calls**](CallsApi.md#list_calls) | **GET** /accounts/{accountId}/calls | Get Calls |
910
| [**update_call**](CallsApi.md#update_call) | **POST** /accounts/{accountId}/calls/{callId} | Update Call |
1011
| [**update_call_bxml**](CallsApi.md#update_call_bxml) | **PUT** /accounts/{accountId}/calls/{callId}/bxml | Update Call BXML |
1112

@@ -154,6 +155,92 @@ end
154155
- **Accept**: application/json
155156

156157

158+
## list_calls
159+
160+
> <Array<CallState>> list_calls(account_id, opts)
161+
162+
Get Calls
163+
164+
Returns a max of 10000 calls, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of calls in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of call records. Also, call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an empty array [] in response.
165+
166+
### Examples
167+
168+
```ruby
169+
require 'time'
170+
require 'bandwidth-sdk'
171+
# setup authorization
172+
Bandwidth.configure do |config|
173+
# Configure HTTP basic authorization: Basic
174+
config.username = 'YOUR USERNAME'
175+
config.password = 'YOUR PASSWORD'
176+
end
177+
178+
api_instance = Bandwidth::CallsApi.new
179+
account_id = '9900000' # String | Your Bandwidth Account ID.
180+
opts = {
181+
to: '%2b19195551234', # String | Filter results by the `to` field.
182+
from: '%2b19195554321', # String | Filter results by the `from` field.
183+
min_start_time: '2022-06-21T19:13:21Z', # String | Filter results to calls which have a `startTime` after or including `minStartTime` (in ISO8601 format).
184+
max_start_time: '2022-06-21T19:13:21Z', # String | Filter results to calls which have a `startTime` before or including `maxStartTime` (in ISO8601 format).
185+
disconnect_cause: 'hangup', # String | Filter results to calls with specified call Disconnect Cause.
186+
page_size: 500, # Integer | Specifies the max number of calls that will be returned.
187+
page_token: 'page_token_example' # String | Not intended for explicit use. To use pagination, follow the links in the `Link` header of the response, as indicated in the endpoint description.
188+
}
189+
190+
begin
191+
# Get Calls
192+
result = api_instance.list_calls(account_id, opts)
193+
p result
194+
rescue Bandwidth::ApiError => e
195+
puts "Error when calling CallsApi->list_calls: #{e}"
196+
end
197+
```
198+
199+
#### Using the list_calls_with_http_info variant
200+
201+
This returns an Array which contains the response data, status code and headers.
202+
203+
> <Array(<Array<CallState>>, Integer, Hash)> list_calls_with_http_info(account_id, opts)
204+
205+
```ruby
206+
begin
207+
# Get Calls
208+
data, status_code, headers = api_instance.list_calls_with_http_info(account_id, opts)
209+
p status_code # => 2xx
210+
p headers # => { ... }
211+
p data # => <Array<CallState>>
212+
rescue Bandwidth::ApiError => e
213+
puts "Error when calling CallsApi->list_calls_with_http_info: #{e}"
214+
end
215+
```
216+
217+
### Parameters
218+
219+
| Name | Type | Description | Notes |
220+
| ---- | ---- | ----------- | ----- |
221+
| **account_id** | **String** | Your Bandwidth Account ID. | |
222+
| **to** | **String** | Filter results by the &#x60;to&#x60; field. | [optional] |
223+
| **from** | **String** | Filter results by the &#x60;from&#x60; field. | [optional] |
224+
| **min_start_time** | **String** | Filter results to calls which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format). | [optional] |
225+
| **max_start_time** | **String** | Filter results to calls which have a &#x60;startTime&#x60; before or including &#x60;maxStartTime&#x60; (in ISO8601 format). | [optional] |
226+
| **disconnect_cause** | **String** | Filter results to calls with specified call Disconnect Cause. | [optional] |
227+
| **page_size** | **Integer** | Specifies the max number of calls that will be returned. | [optional][default to 1000] |
228+
| **page_token** | **String** | Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description. | [optional] |
229+
230+
### Return type
231+
232+
[**Array&lt;CallState&gt;**](CallState.md)
233+
234+
### Authorization
235+
236+
[Basic](../README.md#Basic)
237+
238+
### HTTP request headers
239+
240+
- **Content-Type**: Not defined
241+
- **Accept**: application/json
242+
243+
157244
## update_call
158245

159246
> update_call(account_id, call_id, update_call)

lib/bandwidth-sdk/api/calls_api.rb

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,98 @@ def get_call_state_with_http_info(account_id, call_id, opts = {})
162162
return data, status_code, headers
163163
end
164164

165+
# Get Calls
166+
# Returns a max of 10000 calls, sorted by `createdTime` from oldest to newest. **NOTE:** If the number of calls in the account is bigger than `pageSize`, a `Link` header (with format `<{url}>; rel=\"next\"`) will be returned in the response. The url can be used to retrieve the next page of call records. Also, call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an empty array [] in response.
167+
# @param account_id [String] Your Bandwidth Account ID.
168+
# @param [Hash] opts the optional parameters
169+
# @option opts [String] :to Filter results by the &#x60;to&#x60; field.
170+
# @option opts [String] :from Filter results by the &#x60;from&#x60; field.
171+
# @option opts [String] :min_start_time Filter results to calls which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
172+
# @option opts [String] :max_start_time Filter results to calls which have a &#x60;startTime&#x60; before or including &#x60;maxStartTime&#x60; (in ISO8601 format).
173+
# @option opts [String] :disconnect_cause Filter results to calls with specified call Disconnect Cause.
174+
# @option opts [Integer] :page_size Specifies the max number of calls that will be returned. (default to 1000)
175+
# @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
176+
# @return [Array<CallState>]
177+
def list_calls(account_id, opts = {})
178+
data, _status_code, _headers = list_calls_with_http_info(account_id, opts)
179+
data
180+
end
181+
182+
# Get Calls
183+
# Returns a max of 10000 calls, sorted by &#x60;createdTime&#x60; from oldest to newest. **NOTE:** If the number of calls in the account is bigger than &#x60;pageSize&#x60;, a &#x60;Link&#x60; header (with format &#x60;&lt;{url}&gt;; rel&#x3D;\&quot;next\&quot;&#x60;) will be returned in the response. The url can be used to retrieve the next page of call records. Also, call information is kept for 7 days after the calls are hung up. If you attempt to retrieve information for a call that is older than 7 days, you will get an empty array [] in response.
184+
# @param account_id [String] Your Bandwidth Account ID.
185+
# @param [Hash] opts the optional parameters
186+
# @option opts [String] :to Filter results by the &#x60;to&#x60; field.
187+
# @option opts [String] :from Filter results by the &#x60;from&#x60; field.
188+
# @option opts [String] :min_start_time Filter results to calls which have a &#x60;startTime&#x60; after or including &#x60;minStartTime&#x60; (in ISO8601 format).
189+
# @option opts [String] :max_start_time Filter results to calls which have a &#x60;startTime&#x60; before or including &#x60;maxStartTime&#x60; (in ISO8601 format).
190+
# @option opts [String] :disconnect_cause Filter results to calls with specified call Disconnect Cause.
191+
# @option opts [Integer] :page_size Specifies the max number of calls that will be returned. (default to 1000)
192+
# @option opts [String] :page_token Not intended for explicit use. To use pagination, follow the links in the &#x60;Link&#x60; header of the response, as indicated in the endpoint description.
193+
# @return [Array<(Array<CallState>, Integer, Hash)>] Array<CallState> data, response status code and response headers
194+
def list_calls_with_http_info(account_id, opts = {})
195+
if @api_client.config.debugging
196+
@api_client.config.logger.debug 'Calling API: CallsApi.list_calls ...'
197+
end
198+
# verify the required parameter 'account_id' is set
199+
if @api_client.config.client_side_validation && account_id.nil?
200+
fail ArgumentError, "Missing the required parameter 'account_id' when calling CallsApi.list_calls"
201+
end
202+
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 10000
203+
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CallsApi.list_calls, must be smaller than or equal to 10000.'
204+
end
205+
206+
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
207+
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling CallsApi.list_calls, must be greater than or equal to 1.'
208+
end
209+
210+
# resource path
211+
local_var_path = '/accounts/{accountId}/calls'.sub('{' + 'accountId' + '}', CGI.escape(account_id.to_s))
212+
213+
# query parameters
214+
query_params = opts[:query_params] || {}
215+
query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?
216+
query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
217+
query_params[:'minStartTime'] = opts[:'min_start_time'] if !opts[:'min_start_time'].nil?
218+
query_params[:'maxStartTime'] = opts[:'max_start_time'] if !opts[:'max_start_time'].nil?
219+
query_params[:'disconnectCause'] = opts[:'disconnect_cause'] if !opts[:'disconnect_cause'].nil?
220+
query_params[:'pageSize'] = opts[:'page_size'] if !opts[:'page_size'].nil?
221+
query_params[:'pageToken'] = opts[:'page_token'] if !opts[:'page_token'].nil?
222+
223+
# header parameters
224+
header_params = opts[:header_params] || {}
225+
# HTTP header 'Accept' (if needed)
226+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
227+
228+
# form parameters
229+
form_params = opts[:form_params] || {}
230+
231+
# http body (model)
232+
post_body = opts[:debug_body]
233+
234+
# return_type
235+
return_type = opts[:debug_return_type] || 'Array<CallState>'
236+
237+
# auth_names
238+
auth_names = opts[:debug_auth_names] || ['Basic']
239+
240+
new_options = opts.merge(
241+
:operation => :"CallsApi.list_calls",
242+
:header_params => header_params,
243+
:query_params => query_params,
244+
:form_params => form_params,
245+
:body => post_body,
246+
:auth_names => auth_names,
247+
:return_type => return_type
248+
)
249+
250+
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
251+
if @api_client.config.debugging
252+
@api_client.config.logger.debug "API called: CallsApi#list_calls\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
253+
end
254+
return data, status_code, headers
255+
end
256+
165257
# Update Call
166258
# Interrupts and redirects a call to a different URL that should return a BXML document.
167259
# @param account_id [String] Your Bandwidth Account ID.

lib/bandwidth-sdk/configuration.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ def operation_server_settings
272272
description: "Production",
273273
}
274274
],
275+
"CallsApi.list_calls": [
276+
{
277+
url: "https://voice.bandwidth.com/api/v2",
278+
description: "Production",
279+
}
280+
],
275281
"CallsApi.update_call": [
276282
{
277283
url: "https://voice.bandwidth.com/api/v2",

0 commit comments

Comments
 (0)