From 8d060e2b5be79d291b1bc58c7f6bd8dcf77f2a85 Mon Sep 17 00:00:00 2001 From: Rohith Prakash Date: Wed, 25 Jan 2023 17:15:14 +0530 Subject: [PATCH] chore: Ruby add Page template (#412) # 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. --- .../lib/twilio-ruby/rest/api/v2010/account.rb | 28 +++++++++++++++++++ .../rest/api/v2010/account/call.rb | 28 +++++++++++++++++++ .../account/call/feedback_call_summary.rb | 28 +++++++++++++++++++ .../lib/twilio-ruby/rest/flex_api/v1/call.rb | 28 +++++++++++++++++++ .../rest/flex_api/v1/credential.rb | 28 +++++++++++++++++++ .../rest/flex_api/v1/credential/aws.rb | 28 +++++++++++++++++++ .../flex_api/v1/credential/aws/history.rb | 28 +++++++++++++++++++ .../flex_api/v1/credential/new_credentials.rb | 28 +++++++++++++++++++ .../versionless/deployed_devices/fleet.rb | 28 +++++++++++++++++++ .../rest/versionless/understand/assistant.rb | 28 +++++++++++++++++++ src/main/resources/twilio-ruby/api.mustache | 1 + src/main/resources/twilio-ruby/page.mustache | 28 +++++++++++++++++++ 12 files changed, 309 insertions(+) create mode 100644 src/main/resources/twilio-ruby/page.mustache diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb index d810eeebf..d8e29ab03 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb @@ -179,6 +179,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call.rb index 3ea9cb7af..cd132084f 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call.rb @@ -66,6 +66,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call/feedback_call_summary.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call/feedback_call_summary.rb index 013842d78..4e120024e 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call/feedback_call_summary.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account/call/feedback_call_summary.rb @@ -38,6 +38,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/call.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/call.rb index ba1fd2fcd..dfc943061 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/call.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/call.rb @@ -38,6 +38,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential.rb index 67a4f7e49..a701a4867 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential.rb @@ -52,6 +52,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb index f84f235de..172a27c4c 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws.rb @@ -123,6 +123,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws/history.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws/history.rb index 53cdb1a29..083611453 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws/history.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/aws/history.rb @@ -38,6 +38,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/new_credentials.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/new_credentials.rb index 9021444e1..b77b5f1a4 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/new_credentials.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1/credential/new_credentials.rb @@ -118,6 +118,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices/fleet.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices/fleet.rb index 8c93c2bb0..c3188a744 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices/fleet.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices/fleet.rb @@ -54,6 +54,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb index eaf653a4e..972c21328 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb @@ -123,6 +123,34 @@ def to_s '#' 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 + '' + end + end end end end diff --git a/src/main/resources/twilio-ruby/api.mustache b/src/main/resources/twilio-ruby/api.mustache index a442606c7..13b45f1f0 100644 --- a/src/main/resources/twilio-ruby/api.mustache +++ b/src/main/resources/twilio-ruby/api.mustache @@ -6,6 +6,7 @@ module Twilio class {{domainName}} < Domain class {{apiVersionClass}} < Version {{>list}} +{{>page}} end end end diff --git a/src/main/resources/twilio-ruby/page.mustache b/src/main/resources/twilio-ruby/page.mustache new file mode 100644 index 000000000..23d5265f7 --- /dev/null +++ b/src/main/resources/twilio-ruby/page.mustache @@ -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 + '' + end + end \ No newline at end of file