Skip to content

Commit

Permalink
chore: Ruby add Page template (#412)
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
-->

# Chore #

Adds ruby page class template

### 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 authored Jan 25, 2023
1 parent 6ed2a9f commit 8d060e2
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 0 deletions.
28 changes: 28 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 @@ -179,6 +179,34 @@ def to_s
'#<Twilio.Api.V2010.AccountList>'
end
end
class AccountPage < Page
##
# Initialize the AccountPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [AccountPage] AccountPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of AccountInstance
# @param [Hash] payload Payload response from the API
# @return [AccountInstance] AccountInstance
def get_instance(payload)
AccountInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.Api.V2010.AccountPage>'
end
end
end
end
end
Expand Down
28 changes: 28 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 @@ -66,6 +66,34 @@ def to_s
'#<Twilio.Api.V2010.CallList>'
end
end
class CallPage < Page
##
# Initialize the CallPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [CallPage] CallPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of CallInstance
# @param [Hash] payload Payload response from the API
# @return [CallInstance] CallInstance
def get_instance(payload)
CallInstance.new(@version, payload, account_sid: @solution[:account_sid])
end

##
# Provide a user friendly representation
def to_s
'<Twilio.Api.V2010.CallPage>'
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ def to_s
'#<Twilio.Api.V2010.FeedbackCallSummaryList>'
end
end
class FeedbackCallSummaryPage < Page
##
# Initialize the FeedbackCallSummaryPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [FeedbackCallSummaryPage] FeedbackCallSummaryPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of FeedbackCallSummaryInstance
# @param [Hash] payload Payload response from the API
# @return [FeedbackCallSummaryInstance] FeedbackCallSummaryInstance
def get_instance(payload)
FeedbackCallSummaryInstance.new(@version, payload, account_sid: @solution[:account_sid])
end

##
# Provide a user friendly representation
def to_s
'<Twilio.Api.V2010.FeedbackCallSummaryPage>'
end
end
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/flex_api/v1/call.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ def to_s
'#<Twilio.FlexApi.V1.CallList>'
end
end
class CallPage < Page
##
# Initialize the CallPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [CallPage] CallPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of CallInstance
# @param [Hash] payload Payload response from the API
# @return [CallInstance] CallInstance
def get_instance(payload)
CallInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.FlexApi.V1.CallPage>'
end
end
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,34 @@ def to_s
'#<Twilio.FlexApi.V1.CredentialList>'
end
end
class CredentialPage < Page
##
# Initialize the CredentialPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [CredentialPage] CredentialPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of CredentialInstance
# @param [Hash] payload Payload response from the API
# @return [CredentialInstance] CredentialInstance
def get_instance(payload)
CredentialInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.FlexApi.V1.CredentialPage>'
end
end
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,34 @@ def to_s
'#<Twilio.FlexApi.V1.AwsList>'
end
end
class AwsPage < Page
##
# Initialize the AwsPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [AwsPage] AwsPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of AwsInstance
# @param [Hash] payload Payload response from the API
# @return [AwsInstance] AwsInstance
def get_instance(payload)
AwsInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.FlexApi.V1.AwsPage>'
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ def to_s
'#<Twilio.FlexApi.V1.HistoryList>'
end
end
class HistoryPage < Page
##
# Initialize the HistoryPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [HistoryPage] HistoryPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of HistoryInstance
# @param [Hash] payload Payload response from the API
# @return [HistoryInstance] HistoryInstance
def get_instance(payload)
HistoryInstance.new(@version, payload, sid: @solution[:sid])
end

##
# Provide a user friendly representation
def to_s
'<Twilio.FlexApi.V1.HistoryPage>'
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,34 @@ def to_s
'#<Twilio.FlexApi.V1.NewCredentialsList>'
end
end
class NewCredentialsPage < Page
##
# Initialize the NewCredentialsPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [NewCredentialsPage] NewCredentialsPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of NewCredentialsInstance
# @param [Hash] payload Payload response from the API
# @return [NewCredentialsInstance] NewCredentialsInstance
def get_instance(payload)
NewCredentialsInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.FlexApi.V1.NewCredentialsPage>'
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,34 @@ def to_s
'#<Twilio.Versionless.DeployedDevices.FleetList>'
end
end
class FleetPage < Page
##
# Initialize the FleetPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [FleetPage] FleetPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of FleetInstance
# @param [Hash] payload Payload response from the API
# @return [FleetInstance] FleetInstance
def get_instance(payload)
FleetInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.Versionless.DeployedDevices.FleetPage>'
end
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,34 @@ def to_s
'#<Twilio.Versionless.Understand.AssistantList>'
end
end
class AssistantPage < Page
##
# Initialize the AssistantPage
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [AssistantPage] AssistantPage
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of AssistantInstance
# @param [Hash] payload Payload response from the API
# @return [AssistantInstance] AssistantInstance
def get_instance(payload)
AssistantInstance.new(@version, payload)
end

##
# Provide a user friendly representation
def to_s
'<Twilio.Versionless.Understand.AssistantPage>'
end
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/twilio-ruby/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Twilio
class {{domainName}} < Domain
class {{apiVersionClass}} < Version
{{>list}}
{{>page}}
end
end
end
Expand Down
28 changes: 28 additions & 0 deletions src/main/resources/twilio-ruby/page.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class {{apiName}}Page < Page
##
# Initialize the {{apiName}}Page
# @param [Version] version Version that contains the resource
# @param [Response] response Response from the API
# @param [Hash] solution Path solution for the resource
# @return [{{apiName}}Page] {{apiName}}Page
def initialize(version, response, solution)
super(version, response)

# Path Solution
@solution = solution
end

##
# Build an instance of {{apiName}}Instance
# @param [Hash] payload Payload response from the API
# @return [{{apiName}}Instance] {{apiName}}Instance
def get_instance(payload)
{{apiName}}Instance.new(@version, payload{{#listPathParams}}, {{paramName}}: @solution[:{{paramName}}]{{/listPathParams}})
end

##
# Provide a user friendly representation
def to_s
'<Twilio.{{domainName}}.{{apiVersionClass}}.{{apiName}}Page>'
end
end

0 comments on commit 8d060e2

Please sign in to comment.