Skip to content

Commit

Permalink
chore: Ruby generate list class (#405)
Browse files Browse the repository at this point in the history
<!--
We appreciate the effort for this pull request but before that please
make sure you read the contribution guidelines, then fill out the blanks
below.

Please format the PR title appropriately based on the type of change:
  <type>[!]: <description>
Where <type> is one of: docs, chore, feat, fix, test, misc.
Add a '!' after the type for breaking changes (e.g. feat!: new breaking
feature).

**All third-party contributors acknowledge that any contributions they
provide will be made under the same open-source license that the
open-source project is provided under.**

Please enter each Issue number you are resolving in your PR after one of
the following words [Fixes, Closes, Resolves]. This will auto-link these
issues and close them when this PR is merged!
e.g.
Fixes #1
Closes #2
-->

# Fixes #

Template to generate List Class for ruby has been added

### Checklist
- [x] I acknowledge that all my contributions will be made under the
project's license
- [ ] Run `make test-docker`
- [ ] Verify affected language:
- [ ] Generate [twilio-go](https://github.com/twilio/twilio-go) from our
[OpenAPI specification](https://github.com/twilio/twilio-oai) using the
[build_twilio_go.py](./examples/build_twilio_go.py) using `python
examples/build_twilio_go.py path/to/twilio-oai/spec/yaml
path/to/twilio-go` and inspect the diff
    - [ ] Run `make test` in `twilio-go`
    - [ ] Create a pull request in `twilio-go`
    - [ ] Provide a link below to the pull request
- [ ] I have made a material change to the repo (functionality, testing,
spelling, grammar)
- [ ] I have read the [Contribution
Guidelines](https://github.com/twilio/twilio-oai-generator/blob/main/CONTRIBUTING.md)
and my PR follows them
- [ ] I have titled the PR appropriately
- [ ] I have updated my branch with the main branch
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added the necessary documentation about the functionality
in the appropriate .md file
- [ ] I have added inline documentation to the code I modified

If you have questions, please create a GitHub Issue in this repository.
  • Loading branch information
rohith-prakash committed Jan 20, 2023
1 parent c470242 commit a1bdf1c
Show file tree
Hide file tree
Showing 32 changed files with 1,618 additions and 118 deletions.
68 changes: 68 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/api/v2010.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
##
# This code was generated by
# ___ _ _ _ _ _ _ ____ ____ ____ _ ____ ____ _ _ ____ ____ ____ ___ __ __
# | | | | | | | | | __ | | |__| | __ | __ |___ |\ | |___ |__/ |__| | | | |__/
# | |_|_| | |___ | |__| |__| | | | |__] |___ | \| |___ | \ | | | |__| | \
#
# Twilio - Accounts
# This is the public Twilio REST API.
#
# NOTE: This class is auto generated by OpenAPI Generator.
# https://openapi-generator.tech
# Do not edit the class manually.
#

module Twilio
module REST
class Api
class V2010 < Version
##
# Initialize the V2010 version of Api
def initialize(domain)
super
@version = '2010-04-01'
@accounts = nil
@account = nil
end

##
# @param [String] sid
# @return [Twilio::REST::Api::V2010::AccountContext] if sid was passed.
# @return [Twilio::REST::Api::V2010::accountList]
def accounts(sid=:unset)
if sid.nil?
raise ArgumentError, 'sid cannot be nil'
end
if sid == :unset
@accounts ||= AccountList.new self
else
AccountContext.new(self, sid)
end
end
##
# @return [Twilio::REST::Api::V2010::accountContext]
def account
@account ||= AccountList.new self
end


##
# Setter to override the primary account
def account=(value)
@account = value
end
def accounts(sid =:unset)
self.account.accounts(sid)
end
def calls(testInteger =:unset)
self.account.calls(testInteger)
end
##
# Provide a user friendly representation
def to_s
'<Twilio::REST::Api::V2010>';
end
end
end
end
end
170 changes: 170 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,173 @@
#


module Twilio
module REST
class Api < Domain
class V2010 < Version
class AccountList < ListResource
##
# Initialize the AccountList
# @param [Version] version Version that contains the resource
# @return [AccountList] AccountList
def initialize(version)
super(version)
# Path Solution
@solution = { }
@uri = "/Accounts.json"

end

##
# Create the AccountInstance
# @param [String] x_twilio_webhook_enabled
# @param [String] recording_status_callback
# @param [Array&lt;String&gt;] recording_status_callback_event
# @param [String] twiml
# @return [AccountInstance] Created AccountInstance
def create(x_twilio_webhook_enabled: :unset,
recording_status_callback: :unset,
recording_status_callback_event: :unset,
twiml: :unset
)
data = Twilio::Values.of(

'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled,

'RecordingStatusCallback' => recording_status_callback,

'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e },

'Twiml' => twiml,
})

payload = @version.create('POST', @uri, data: data)

AccountInstance.new(@version, payload, )
end


##
# Lists AccountInstance records from the API as a list.
# Unlike stream(), this operation is eager and will load `limit` records into
# memory before returning.
# @param [Time] date_created
# @param [Date] date_test
# @param [Time] date_created_before
# @param [Time] date_created_after
# @param [Integer] limit Upper limit for the number of records to return. stream()
# guarantees to never return more than limit. Default is no limit
# @param [Integer] page_size Number of records to fetch per request, when
# not set will use the default value of 50 records. If no page_size is defined
# but a limit is defined, stream() will attempt to read the limit with the most
# efficient page size, i.e. min(limit, 1000)
# @return [Array] Array of up to limit results
def list(date_created: :unset,date_test: :unset,date_created_before: :unset,date_created_after: :unset, limit: nil, page_size: nil)
self.stream(
date_created: date_created,
date_test: date_test,
date_created_before: date_created_before,
date_created_after: date_created_after,
limit: limit,
page_size: page_size
).entries
end

##
# Streams Instance records from the API as an Enumerable.
# This operation lazily loads records as efficiently as possible until the limit
# is reached.
# @param [Time] date_created
# @param [Date] date_test
# @param [Time] date_created_before
# @param [Time] date_created_after
# @param [Integer] limit Upper limit for the number of records to return. stream()
# guarantees to never return more than limit. Default is no limit
# @param [Integer] page_size Number of records to fetch per request, when
# not set will use the default value of 50 records. If no page_size is defined
# but a limit is defined, stream() will attempt to read the limit with the most
# efficient page size, i.e. min(limit, 1000)
# @return [Enumerable] Enumerable that will yield up to limit results
def stream(date_created: :unset,date_test: :unset,date_created_before: :unset,date_created_after: :unset, limit: nil, page_size: nil)
limits = @version.read_limits(limit, page_size)

page = self.page(
date_created: date_created,
date_test: date_test,
date_created_before: date_created_before,
date_created_after: date_created_after,
page_size: limits[:page_size], )

@version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

##
# When passed a block, yields AccountInstance records from the API.
# This operation lazily loads records as efficiently as possible until the limit
# is reached.
def each
limits = @version.read_limits

page = self.page(page_size: limits[:page_size], )

@version.stream(page,
limit: limits[:limit],
page_limit: limits[:page_limit]).each {|x| yield x}
end

##
# Retrieve a single page of AccountInstance records from the API.
# Request is executed immediately.
# @param [Time] date_created
# @param [Date] date_test
# @param [Time] date_created_before
# @param [Time] date_created_after
# @param [String] page_token PageToken provided by the API
# @param [Integer] page_number Page Number, this value is simply for client state
# @param [Integer] page_size Number of records to return, defaults to 50
# @return [Page] Page of AccountInstance
def page(date_created: :unset,date_test: :unset,date_created_before: :unset,date_created_after: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
params = Twilio::Values.of({

'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),

'Date.Test' => Twilio.serialize_iso8601_date(date_test),

'DateCreated<' => Twilio.serialize_iso8601_datetime(date_created_before),

'DateCreated>' => Twilio.serialize_iso8601_datetime(date_created_after),

'PageToken' => page_token,
'Page' => page_number,
'PageSize' => page_size,
})

response = @version.page('GET', @uri, params: params)

AccountPage.new(@version, response, @solution)
end

##
# Retrieve a single page of AccountInstance records from the API.
# Request is executed immediately.
# @param [String] target_url API-generated URL for the requested results page
# @return [Page] Page of AccountInstance
def get_page(target_url)
response = @version.domain.request(
'GET',
target_url
)
AccountPage.new(@version, response, @solution)
end

##

# Provide a user friendly representation
def to_s
'#<Twilio.Api.V2010.AccountList>'
end
end
end
end
end
end
57 changes: 57 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,60 @@
#


module Twilio
module REST
class Api < Domain
class V2010 < Version
class CallList < ListResource
##
# Initialize the CallList
# @param [Version] version Version that contains the resource
# @return [CallList] CallList
def initialize(version, account_sid)
super(version)
# Path Solution
@solution = { account_sid: account_sid, }
@uri = "/Accounts/#{@solution[:account_sid]}/Calls.json"

end

##
# Create the CallInstance
# @param [String] required_string_property
# @param [String] test_method The HTTP method that we should use to request the &#x60;TestArrayOfUri&#x60;.
# @param [Array&lt;String&gt;] test_array_of_strings
# @param [Array&lt;String&gt;] test_array_of_uri
# @return [CallInstance] Created CallInstance
def create(required_string_property: nil,
test_method: nil,
test_array_of_strings: :unset,
test_array_of_uri: :unset
)
data = Twilio::Values.of(

'RequiredStringProperty' => required_string_property,

'TestMethod' => test_method,

'TestArrayOfStrings' => Twilio.serialize_list(test_array_of_strings) { |e| e },

'TestArrayOfUri' => Twilio.serialize_list(test_array_of_uri) { |e| e },
})

payload = @version.create('POST', @uri, data: data)

CallInstance.new(@version, payload, account_sid: @solution[:account_sid],)
end


##

# Provide a user friendly representation
def to_s
'#<Twilio.Api.V2010.CallList>'
end
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,32 @@
#


module Twilio
module REST
class Api < Domain
class V2010 < Version
class FeedbackCallSummaryList < ListResource
##
# Initialize the FeedbackCallSummaryList
# @param [Version] version Version that contains the resource
# @return [FeedbackCallSummaryList] FeedbackCallSummaryList
def initialize(version, account_sid)
super(version)
# Path Solution
@solution = { account_sid: account_sid, }


end


##

# Provide a user friendly representation
def to_s
'#<Twilio.Api.V2010.FeedbackCallSummaryList>'
end
end
end
end
end
end
15 changes: 0 additions & 15 deletions examples/ruby/lib/twilio-ruby/rest/api/v2010/v2010.rb

This file was deleted.

15 changes: 0 additions & 15 deletions examples/ruby/lib/twilio-ruby/rest/flexApi/v1/call.rb

This file was deleted.

15 changes: 0 additions & 15 deletions examples/ruby/lib/twilio-ruby/rest/flexApi/v1/credential.rb

This file was deleted.

0 comments on commit a1bdf1c

Please sign in to comment.