Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Ruby add Page template #412

Merged
merged 3 commits into from
Jan 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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