From 0be24a84ffac1efef59b9ff5af4a4d89c1eca2fc Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 5 Jul 2023 23:51:46 +0530 Subject: [PATCH 1/4] Add block parsing support --- .../com/twilio/oai/common/ApplicationConstants.java | 1 + .../oai/resolver/ruby/RubyParameterResolver.java | 2 ++ src/main/resources/twilio-ruby/list.mustache | 10 ++++------ .../java/com/twilio/oai/TwilioGeneratorTest.java | 12 +++--------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/twilio/oai/common/ApplicationConstants.java b/src/main/java/com/twilio/oai/common/ApplicationConstants.java index b4af490f3..f01446327 100644 --- a/src/main/java/com/twilio/oai/common/ApplicationConstants.java +++ b/src/main/java/com/twilio/oai/common/ApplicationConstants.java @@ -41,6 +41,7 @@ public class ApplicationConstants { public static final String PROMOTION_EXTENSION_NAME = "x-promotions"; public static final String VENDOR_PREFIX = "x-"; public static final String SERIALIZE_VEND_EXT = "x-serialize"; + public static final String IS_SERIALIZE_LIST_EXT = "isList"; public static final String DESERIALIZE_VEND_EXT = "x-deserialize"; public static final String ENUM = "Enum"; public static final String RESOURCE = "Resource"; diff --git a/src/main/java/com/twilio/oai/resolver/ruby/RubyParameterResolver.java b/src/main/java/com/twilio/oai/resolver/ruby/RubyParameterResolver.java index 1bba6f73d..983e4fe86 100644 --- a/src/main/java/com/twilio/oai/resolver/ruby/RubyParameterResolver.java +++ b/src/main/java/com/twilio/oai/resolver/ruby/RubyParameterResolver.java @@ -9,6 +9,7 @@ import java.util.List; import static com.twilio.oai.common.ApplicationConstants.SERIALIZE_VEND_EXT; +import static com.twilio.oai.common.ApplicationConstants.IS_SERIALIZE_LIST_EXT; public class RubyParameterResolver extends LanguageParamResolver { public static final String ARRAY_OF_OBJECT = "Array[Object]"; @@ -25,6 +26,7 @@ public CodegenParameter resolve(final CodegenParameter codegenParameter, ApiReso codegenParameter.dataType = codegenParameter.dataType.replaceAll("<", "["); codegenParameter.dataType = codegenParameter.dataType.replaceAll(">", "]"); codegenParameter.vendorExtensions.put(SERIALIZE_VEND_EXT, "Twilio.serialize_list"); + codegenParameter.vendorExtensions.put(IS_SERIALIZE_LIST_EXT, "true"); } if (codegenParameter.dataType.equals("Time")) { codegenParameter.vendorExtensions.put(SERIALIZE_VEND_EXT, "Twilio.serialize_iso8601_datetime"); diff --git a/src/main/resources/twilio-ruby/list.mustache b/src/main/resources/twilio-ruby/list.mustache index b8524c81e..6a1ebafc5 100644 --- a/src/main/resources/twilio-ruby/list.mustache +++ b/src/main/resources/twilio-ruby/list.mustache @@ -101,12 +101,10 @@ # @return [Page] Page of {{apiName}}Instance def page({{#readParams.0}}{{#readParams}}{{>params}}{{/readParams}}, {{/readParams.0}}page_token: :unset, page_number: :unset, page_size: :unset) params = Twilio::Values.of({ - {{#readParams}}{{^vendorExtensions.x-serialize}} - '{{{baseName}}}' => {{paramName}}, - {{/vendorExtensions.x-serialize}}{{#vendorExtensions.x-serialize}} - '{{{baseName}}}' => {{vendorExtensions.x-serialize}}({{paramName}}), - {{/vendorExtensions.x-serialize}}{{/readParams}} - 'PageToken' => page_token, + {{#readParams}}{{^vendorExtensions.x-serialize}}'{{{baseName}}}' => {{paramName}}, + {{/vendorExtensions.x-serialize}}{{#vendorExtensions.x-serialize}}{{^vendorExtensions.isList}}'{{{baseName}}}' => {{vendorExtensions.x-serialize}}({{paramName}}),{{/vendorExtensions.isList}} + {{#vendorExtensions.isList}}'{{{baseName}}}' => {{vendorExtensions.x-serialize}}({{paramName}}) { |e| e }, + {{/vendorExtensions.isList}}{{/vendorExtensions.x-serialize}}{{/readParams}}'PageToken' => page_token, 'Page' => page_number, 'PageSize' => page_size, }) diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index c93ef5293..69bd85223 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -28,14 +28,8 @@ public class TwilioGeneratorTest { @Parameterized.Parameters public static Collection generators() { - return Arrays.asList(Generator.TWILIO_CSHARP, - Generator.TWILIO_GO, - Generator.TWILIO_JAVA, - Generator.TWILIO_NODE, - Generator.TWILIO_PHP, - Generator.TWILIO_PYTHON, - Generator.TWILIO_RUBY, - Generator.TWILIO_TERRAFORM); + return Arrays.asList( + Generator.TWILIO_RUBY); } private final Generator generator; @@ -47,7 +41,7 @@ public static void setUp() { @Test public void launchGenerator() { - final String pathname = "examples/spec/twilio_api_v2010.yaml"; + final String pathname = "/Users/asabu/di/github/twilio-oai/spec/yaml/twilio_video_v1.yaml"; File filesList[] ; File directoryPath = new File(pathname); if (directoryPath.isDirectory()) { From 78dd77ed6f4446fdbd3f859b0cde13f436138ad1 Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Wed, 5 Jul 2023 23:52:36 +0530 Subject: [PATCH 2/4] Add block parsing support --- .../java/com/twilio/oai/TwilioGeneratorTest.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java index 69bd85223..c93ef5293 100644 --- a/src/test/java/com/twilio/oai/TwilioGeneratorTest.java +++ b/src/test/java/com/twilio/oai/TwilioGeneratorTest.java @@ -28,8 +28,14 @@ public class TwilioGeneratorTest { @Parameterized.Parameters public static Collection generators() { - return Arrays.asList( - Generator.TWILIO_RUBY); + return Arrays.asList(Generator.TWILIO_CSHARP, + Generator.TWILIO_GO, + Generator.TWILIO_JAVA, + Generator.TWILIO_NODE, + Generator.TWILIO_PHP, + Generator.TWILIO_PYTHON, + Generator.TWILIO_RUBY, + Generator.TWILIO_TERRAFORM); } private final Generator generator; @@ -41,7 +47,7 @@ public static void setUp() { @Test public void launchGenerator() { - final String pathname = "/Users/asabu/di/github/twilio-oai/spec/yaml/twilio_video_v1.yaml"; + final String pathname = "examples/spec/twilio_api_v2010.yaml"; File filesList[] ; File directoryPath = new File(pathname); if (directoryPath.isDirectory()) { From a21b8c29d75ebdff5604681e6d35d757ef6f648e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 13 Jul 2023 18:50:32 +0530 Subject: [PATCH 3/4] Ruby test file changes --- .../ruby/lib/twilio-ruby/rest/api/v2010.rb | 90 +- .../lib/twilio-ruby/rest/api/v2010/account.rb | 981 +++++++++--------- .../rest/api/v2010/account/call.rb | 717 ++++++------- .../account/call/feedback_call_summary.rb | 592 +++++------ .../ruby/lib/twilio-ruby/rest/flex_api/v1.rb | 75 +- .../lib/twilio-ruby/rest/flex_api/v1/call.rb | 310 +++--- .../rest/flex_api/v1/credential.rb | 185 ++-- .../rest/flex_api/v1/credential/aws.rb | 679 ++++++------ .../flex_api/v1/credential/aws/history.rb | 380 +++---- .../flex_api/v1/credential/new_credentials.rb | 366 +++---- .../rest/versionless/deployed_devices.rb | 62 +- .../versionless/deployed_devices/fleet.rb | 377 +++---- .../rest/versionless/understand.rb | 43 +- .../rest/versionless/understand/assistant.rb | 363 +++---- 14 files changed, 2635 insertions(+), 2585 deletions(-) diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb index b17766770..4c3bc4b98 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb @@ -13,55 +13,51 @@ # 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 - end - - ## - # Account provided as the authenticating account - def account - @account ||= AccountContext.new(self, @domain.client.account_sid) - end - - ## - # Setter to override the primary account - def account=(value) - @account = value - end + module REST + class Api + class V2010 < Version + ## + # Initialize the V2010 version of Api + def initialize(domain) + super + @version = '2010-04-01' + @accounts = nil + end - def calls(test_integer = :unset) - self.account.calls(test_integer) - 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 + ## + # Account provided as the authenticating account + def account + @account ||= AccountContext.new(self, @domain.client.account_sid) + end - ## - # Provide a user friendly representation - def to_s - ''; + ## + # Setter to override the primary account + def account=(value) + @account = value + end + def calls(test_integer =:unset) + self.account.calls(test_integer) + 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 + ## + # Provide a user friendly representation + def to_s + ''; + end + end end - end end - end end 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 54b988d8f..878c9e48f 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb @@ -12,502 +12,499 @@ # Do not edit the class manually. # + module Twilio - module REST - class Api < ApiBase - 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] recording_status_callback - # @param [Array[String]] recording_status_callback_event - # @param [String] twiml - # @param [String] x_twilio_webhook_enabled - # @return [AccountInstance] Created AccountInstance - def create( - recording_status_callback: :unset, - recording_status_callback_event: :unset, - twiml: :unset, - x_twilio_webhook_enabled: :unset - ) - - data = Twilio::Values.of({ - 'RecordingStatusCallback' => recording_status_callback, - 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| - e - }, - 'Twiml' => twiml, - }) - - headers = Twilio::Values.of({ 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) - payload = @version.create('POST', @uri, data: data, headers: headers) - 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, + module REST + class Api < ApiBase + 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] recording_status_callback + # @param [Array[String]] recording_status_callback_event + # @param [String] twiml + # @param [String] x_twilio_webhook_enabled + # @return [AccountInstance] Created AccountInstance + def create( + recording_status_callback: :unset, + recording_status_callback_event: :unset, + twiml: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e }, + 'Twiml' => twiml, + }) + + headers = Twilio::Values.of({ 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + payload = @version.create('POST', @uri, data: data, headers: headers) + 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 - '#' - end - end - - class AccountContext < InstanceContext - ## - # Initialize the AccountContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [AccountContext] AccountContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Accounts/#{@solution[:sid]}.json" - - # Dependents - @calls = nil - end - - ## - # Delete the AccountInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - @version.delete('DELETE', @uri) - end - - ## - # Fetch the AccountInstance - # @return [AccountInstance] Fetched AccountInstance - def fetch - payload = @version.fetch('GET', @uri) - AccountInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Update the AccountInstance - # @param [String] pause_behavior - # @param [Status] status - # @return [AccountInstance] Updated AccountInstance - def update( - pause_behavior: :unset, - status: nil - ) - - data = Twilio::Values.of({ - 'Status' => status, - 'PauseBehavior' => pause_behavior, - }) - - payload = @version.update('POST', @uri, data: data) - AccountInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Access the calls - # @return [CallList] - # @return [CallContext] if sid was passed. - def calls(test_integer = :unset) - raise ArgumentError, 'test_integer cannot be nil' if test_integer.nil? - - if test_integer != :unset - return CallContext.new(@version, @solution[:sid], test_integer) - end - - unless @calls - @calls = CallList.new( - @version, - ) - end - - @calls - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 + 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 + '#' + end + end + + + class AccountContext < InstanceContext + ## + # Initialize the AccountContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [AccountContext] AccountContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Accounts/#{@solution[:sid]}.json" + + # Dependents + @calls = nil + end + ## + # Delete the AccountInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + @version.delete('DELETE', @uri) + end + + ## + # Fetch the AccountInstance + # @return [AccountInstance] Fetched AccountInstance + def fetch + + payload = @version.fetch('GET', @uri) + AccountInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Update the AccountInstance + # @param [String] pause_behavior + # @param [Status] status + # @return [AccountInstance] Updated AccountInstance + def update( + pause_behavior: :unset, + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'PauseBehavior' => pause_behavior, + }) + + payload = @version.update('POST', @uri, data: data) + AccountInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Access the calls + # @return [CallList] + # @return [CallContext] if sid was passed. + def calls(test_integer=:unset) + + raise ArgumentError, 'test_integer cannot be nil' if test_integer.nil? + + if test_integer != :unset + return CallContext.new(@version, @solution[:sid],test_integer ) + end + + unless @calls + @calls = CallList.new( + @version, ) + end + + @calls + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + 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 + class AccountInstance < InstanceResource + ## + # Initialize the AccountInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Account + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AccountInstance] AccountInstance + def initialize(version, payload , sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AccountContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = AccountContext.new(@version , @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] + end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Delete the AccountInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + context.delete + end + + ## + # Fetch the AccountInstance + # @return [AccountInstance] Fetched AccountInstance + def fetch + + context.fetch + end + + ## + # Update the AccountInstance + # @param [String] pause_behavior + # @param [Status] status + # @return [AccountInstance] Updated AccountInstance + def update( + pause_behavior: :unset, + status: nil + ) + + context.update( + pause_behavior: pause_behavior, + status: status, + ) + end + + ## + # Access the calls + # @return [calls] calls + def calls + context.calls + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end - class AccountInstance < InstanceResource - ## - # Initialize the AccountInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Account - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AccountInstance] AccountInstance - def initialize(version, payload, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [AccountContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = AccountContext.new(@version, @params['sid']) end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Delete the AccountInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - context.delete - end - - ## - # Fetch the AccountInstance - # @return [AccountInstance] Fetched AccountInstance - def fetch - context.fetch - end - - ## - # Update the AccountInstance - # @param [String] pause_behavior - # @param [Status] status - # @return [AccountInstance] Updated AccountInstance - def update( - pause_behavior: :unset, - status: nil - ) - - context.update( - pause_behavior: pause_behavior, - status: status, - ) - end - - ## - # Access the calls - # @return [calls] calls - def calls - context.calls - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end 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 3c205d7df..9d5fadba8 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 @@ -12,365 +12,368 @@ # Do not edit the class manually. # -module Twilio - module REST - class Api < ApiBase - class V2010 < Version - class AccountContext < InstanceContext - class CallList < ListResource - ## - # Initialize the CallList - # @param [Version] version Version that contains the resource - # @return [CallList] CallList - def initialize(version, account_sid: nil) - super(version) - # Path Solution - @solution = { account_sid: account_sid } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json" - # Components - @feedback_call_summary = nil - end - - ## - # Create the CallInstance - # @param [String] required_string_property - # @param [Array[String]] test_array_of_strings - # @param [Array[String]] test_array_of_uri - # @param [String] test_method The HTTP method that we should use to request the `TestArrayOfUri`. - # @return [CallInstance] Created CallInstance - def create( - required_string_property: nil, - test_array_of_strings: :unset, - test_array_of_uri: :unset, - test_method: nil - ) - - 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 - - ## - # Access the feedback_call_summary - # @return [FeedbackCallSummaryList] - # @return [FeedbackCallSummaryContext] - def feedback_call_summary - @feedback_call_summary ||= FeedbackCallSummaryList.new(@version, - account_sid: @solution[:account_sid]) - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - class CallContext < InstanceContext - ## - # Initialize the CallContext - # @param [Version] version Version that contains the resource - # @param [String] account_sid - # @param [String] test_integer INTEGER ID param!!! - # @return [CallContext] CallContext - def initialize(version, account_sid, test_integer) - super(version) - - # Path Solution - @solution = { account_sid: account_sid, test_integer: test_integer, } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:test_integer]}.json" - - # Dependents - @feedback_call_summary = nil - end - - ## - # Delete the CallInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - @version.delete('DELETE', @uri) - end - - ## - # Fetch the CallInstance - # @return [CallInstance] Fetched CallInstance - def fetch - payload = @version.fetch('GET', @uri) - CallInstance.new( - @version, - payload, - account_sid: @solution[:account_sid], - test_integer: @solution[:test_integer], - ) - end - - ## - # Access the feedback_call_summary - # @return [FeedbackCallSummaryList] - # @return [FeedbackCallSummaryContext] if sid was passed. - def feedback_call_summary(sid = :unset) - raise ArgumentError, 'sid cannot be nil' if sid.nil? - - if sid != :unset - return FeedbackCallSummaryContext.new(@version, @solution[:account_sid], - @solution[:test_integer], sid) - end - - unless @feedback_call_summary - @feedback_call_summary = FeedbackCallSummaryList.new( - @version, - ) - end - - @feedback_call_summary - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 - - class CallInstance < InstanceResource - ## - # Initialize the CallInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CallInstance] CallInstance - def initialize(version, payload, account_sid: nil, test_integer: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'account_sid' => account_sid, - 'test_integer' => test_integer || @properties['test_integer'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [CallContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = CallContext.new(@version, @params['account_sid'], - @params['test_integer']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Delete the CallInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - context.delete - end - ## - # Fetch the CallInstance - # @return [CallInstance] Fetched CallInstance - def fetch - context.fetch - end - - ## - # Access the feedback_call_summary - # @return [feedback_call_summary] feedback_call_summary - def feedback_call_summary - context.feedback_call_summary - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" +module Twilio + module REST + class Api < ApiBase + class V2010 < Version + class AccountContext < InstanceContext + + class CallList < ListResource + ## + # Initialize the CallList + # @param [Version] version Version that contains the resource + # @return [CallList] CallList + def initialize(version, account_sid: nil) + super(version) + # Path Solution + @solution = { account_sid: account_sid } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json" + # Components + @feedback_call_summary = nil + end + ## + # Create the CallInstance + # @param [String] required_string_property + # @param [Array[String]] test_array_of_strings + # @param [Array[String]] test_array_of_uri + # @param [String] test_method The HTTP method that we should use to request the `TestArrayOfUri`. + # @return [CallInstance] Created CallInstance + def create( + required_string_property: nil, + test_array_of_strings: :unset, + test_array_of_uri: :unset, + test_method: nil + ) + + 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 + + + + ## + # Access the feedback_call_summary + # @return [FeedbackCallSummaryList] + # @return [FeedbackCallSummaryContext] + def feedback_call_summary + @feedback_call_summary ||= FeedbackCallSummaryList.new(@version, account_sid: @solution[:account_sid] ) + end + + # Provide a user friendly representation + def to_s + '#' + end + end + + + class CallContext < InstanceContext + ## + # Initialize the CallContext + # @param [Version] version Version that contains the resource + # @param [String] account_sid + # @param [String] test_integer INTEGER ID param!!! + # @return [CallContext] CallContext + def initialize(version, account_sid, test_integer) + super(version) + + # Path Solution + @solution = { account_sid: account_sid, test_integer: test_integer, } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:test_integer]}.json" + + # Dependents + @feedback_call_summary = nil + end + ## + # Delete the CallInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + @version.delete('DELETE', @uri) + end + + ## + # Fetch the CallInstance + # @return [CallInstance] Fetched CallInstance + def fetch + + payload = @version.fetch('GET', @uri) + CallInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + test_integer: @solution[:test_integer], + ) + end + + ## + # Access the feedback_call_summary + # @return [FeedbackCallSummaryList] + # @return [FeedbackCallSummaryContext] if sid was passed. + def feedback_call_summary(sid=:unset) + + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return FeedbackCallSummaryContext.new(@version, @solution[:account_sid], @solution[:test_integer],sid ) + end + + unless @feedback_call_summary + @feedback_call_summary = FeedbackCallSummaryList.new( + @version, ) + end + + @feedback_call_summary + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + 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 + class CallInstance < InstanceResource + ## + # Initialize the CallInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CallInstance] CallInstance + def initialize(version, payload , account_sid: nil, test_integer: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'account_sid' => account_sid ,'test_integer' => test_integer || @properties['test_integer'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [CallContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = CallContext.new(@version , @params['account_sid'], @params['test_integer']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] + end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Delete the CallInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + context.delete + end + + ## + # Fetch the CallInstance + # @return [CallInstance] Fetched CallInstance + def fetch + + context.fetch + end + + ## + # Access the feedback_call_summary + # @return [feedback_call_summary] feedback_call_summary + def feedback_call_summary + context.feedback_call_summary + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + + end end - end 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 d650d54ab..8cf75d0cb 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 @@ -12,304 +12,314 @@ # Do not edit the class manually. # -module Twilio - module REST - class Api < ApiBase - class V2010 < Version - class AccountContext < InstanceContext - class CallContext < InstanceContext - class FeedbackCallSummaryList < ListResource - ## - # Initialize the FeedbackCallSummaryList - # @param [Version] version Version that contains the resource - # @return [FeedbackCallSummaryList] FeedbackCallSummaryList - def initialize(version, account_sid: nil) - super(version) - # Path Solution - @solution = { account_sid: account_sid } - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - class FeedbackCallSummaryContext < InstanceContext - ## - # Initialize the FeedbackCallSummaryContext - # @param [Version] version Version that contains the resource - # @param [String] account_sid - # @param [String] sid - # @return [FeedbackCallSummaryContext] FeedbackCallSummaryContext - def initialize(version, account_sid, sid) - super(version) - - # Path Solution - @solution = { account_sid: account_sid, sid: sid, } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls/Feedback/Summary/#{@solution[:sid]}.json" - end - - ## - # Update the FeedbackCallSummaryInstance - # @param [String] account_sid - # @param [Date] end_date - # @param [Date] start_date - # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance - def update( - account_sid: :unset, - end_date: nil, - start_date: nil - ) - - data = Twilio::Values.of({ - 'EndDate' => Twilio.serialize_iso8601_date(end_date), - 'StartDate' => Twilio.serialize_iso8601_date(start_date), - 'AccountSid' => account_sid, - }) - - payload = @version.update('POST', @uri, data: data) - FeedbackCallSummaryInstance.new( - @version, - payload, - account_sid: @solution[:account_sid], - sid: @solution[:sid], - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 - - class FeedbackCallSummaryInstance < InstanceResource - ## - # Initialize the FeedbackCallSummaryInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this FeedbackCallSummary - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [FeedbackCallSummaryInstance] FeedbackCallSummaryInstance - def initialize(version, payload, account_sid: nil, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'account_sid' => account_sid, 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [FeedbackCallSummaryContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = FeedbackCallSummaryContext.new(@version, @params['account_sid'], - @params['sid']) +module Twilio + module REST + class Api < ApiBase + class V2010 < Version + class AccountContext < InstanceContext + class CallContext < InstanceContext + + class FeedbackCallSummaryList < ListResource + ## + # Initialize the FeedbackCallSummaryList + # @param [Version] version Version that contains the resource + # @return [FeedbackCallSummaryList] FeedbackCallSummaryList + def initialize(version, account_sid: nil) + super(version) + # Path Solution + @solution = { account_sid: account_sid } + + + end + + + + # Provide a user friendly representation + def to_s + '#' + end end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - ## - # @return [String] - def sid - @properties['sid'] - end - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Update the FeedbackCallSummaryInstance - # @param [String] account_sid - # @param [Date] end_date - # @param [Date] start_date - # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance - def update( - account_sid: :unset, - end_date: nil, - start_date: nil - ) - - context.update( - account_sid: account_sid, - end_date: end_date, - start_date: start_date, - ) - end + class FeedbackCallSummaryContext < InstanceContext + ## + # Initialize the FeedbackCallSummaryContext + # @param [Version] version Version that contains the resource + # @param [String] account_sid + # @param [String] sid + # @return [FeedbackCallSummaryContext] FeedbackCallSummaryContext + def initialize(version, account_sid, sid) + super(version) + + # Path Solution + @solution = { account_sid: account_sid, sid: sid, } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/Feedback/Summary/#{@solution[:sid]}.json" + + + end + ## + # Update the FeedbackCallSummaryInstance + # @param [String] account_sid + # @param [Date] end_date + # @param [Date] start_date + # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance + def update( + account_sid: :unset, + end_date: nil, + start_date: nil + ) + + data = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'AccountSid' => account_sid, + }) + + payload = @version.update('POST', @uri, data: data) + FeedbackCallSummaryInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + end + + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - 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 + class FeedbackCallSummaryInstance < InstanceResource + ## + # Initialize the FeedbackCallSummaryInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this FeedbackCallSummary + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [FeedbackCallSummaryInstance] FeedbackCallSummaryInstance + def initialize(version, payload , account_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'account_sid' => account_sid ,'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [FeedbackCallSummaryContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = FeedbackCallSummaryContext.new(@version , @params['account_sid'], @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] + end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Update the FeedbackCallSummaryInstance + # @param [String] account_sid + # @param [Date] end_date + # @param [Date] start_date + # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance + def update( + account_sid: :unset, + end_date: nil, + start_date: nil + ) + + context.update( + account_sid: account_sid, + end_date: end_date, + start_date: start_date, + ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end + end + end end - end end - end end - end end + + diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb index 7bd18e916..f615eccbc 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb @@ -13,46 +13,43 @@ # module Twilio - module REST - class FlexApi - class V1 < Version - ## - # Initialize the V1 version of FlexApi - def initialize(domain) - super - @version = 'v1' - @calls = nil - @credentials = nil - end - - ## - # @param [String] sid - # @return [Twilio::REST::FlexApi::V1::CallContext] if sid was passed. - # @return [Twilio::REST::FlexApi::V1::CallList] - def calls(sid = :unset) - if sid.nil? - raise ArgumentError, 'sid cannot be nil' - end - - if sid == :unset - @calls ||= CallList.new self - else - CallContext.new(self, sid) - end - end - - ## - # @return [Twilio::REST::FlexApi::V1::CredentialList] - def credentials - @credentials ||= CredentialList.new self - end + module REST + class FlexApi + class V1 < Version + ## + # Initialize the V1 version of FlexApi + def initialize(domain) + super + @version = 'v1' + @calls = nil + @credentials = nil + end - ## - # Provide a user friendly representation - def to_s - ''; + ## + # @param [String] sid + # @return [Twilio::REST::FlexApi::V1::CallContext] if sid was passed. + # @return [Twilio::REST::FlexApi::V1::CallList] + def calls(sid=:unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if sid == :unset + @calls ||= CallList.new self + else + CallContext.new(self, sid) + end + end + ## + # @return [Twilio::REST::FlexApi::V1::CredentialList] + def credentials + @credentials ||= CredentialList.new self + end + ## + # Provide a user friendly representation + def to_s + ''; + end + end 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 f5bd0283b..46034f99b 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 @@ -12,159 +12,169 @@ # Do not edit the class manually. # -module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CallList < ListResource - ## - # Initialize the CallList - # @param [Version] version Version that contains the resource - # @return [CallList] CallList - def initialize(version) - super(version) - # Path Solution - @solution = {} - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - class CallContext < InstanceContext - ## - # Initialize the CallContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [CallContext] CallContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Voice/#{@solution[:sid]}" - end - - ## - # Update the CallInstance - # @return [CallInstance] Updated CallInstance - def update - payload = @version.update('POST', @uri) - CallInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 +module Twilio + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CallList < ListResource + ## + # Initialize the CallList + # @param [Version] version Version that contains the resource + # @return [CallList] CallList + def initialize(version) + super(version) + # Path Solution + @solution = { } + + + end + + + + # Provide a user friendly representation + def to_s + '#' + end + end + + + class CallContext < InstanceContext + ## + # Initialize the CallContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [CallContext] CallContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Voice/#{@solution[:sid]}" + + + end + ## + # Update the CallInstance + # @return [CallInstance] Updated CallInstance + def update + + payload = @version.update('POST', @uri) + CallInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + 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 + class CallInstance < InstanceResource + ## + # Initialize the CallInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CallInstance] CallInstance + def initialize(version, payload , sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'] == nil ? payload['sid'] : payload['sid'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [CallContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = CallContext.new(@version , @params['sid']) + end + @instance_context + end + + ## + # @return [String] Non-string path parameter in the response. + def sid + @properties['sid'] + end + + ## + # Update the CallInstance + # @return [CallInstance] Updated CallInstance + def update + + context.update + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end - class CallInstance < InstanceResource - ## - # Initialize the CallInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CallInstance] CallInstance - def initialize(version, payload, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'sid' => payload['sid'] == nil ? payload['sid'] : payload['sid'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [CallContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = CallContext.new(@version, @params['sid']) end - @instance_context - end - - ## - # @return [String] Non-string path parameter in the response. - def sid - @properties['sid'] - end - - ## - # Update the CallInstance - # @return [CallInstance] Updated CallInstance - def update - context.update - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end 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 be8d63b4e..527e3f073 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 @@ -12,109 +12,112 @@ # Do not edit the class manually. # -module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - ## - # Initialize the CredentialList - # @param [Version] version Version that contains the resource - # @return [CredentialList] CredentialList - def initialize(version) - super(version) - # Path Solution - @solution = {} - @uri = "/Credentials" - # Components - @new_credentials = nil - @aws = nil - end - ## - # Access the new_credentials - # @return [NewCredentialsList] - # @return [NewCredentialsContext] - def new_credentials - @new_credentials ||= NewCredentialsList.new(@version) - end +module Twilio + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + ## + # Initialize the CredentialList + # @param [Version] version Version that contains the resource + # @return [CredentialList] CredentialList + def initialize(version) + super(version) + # Path Solution + @solution = { } + @uri = "/Credentials" + # Components + @new_credentials = nil + @aws = nil + end + - ## - # Access the aws - # @return [AwsList] - # @return [AwsContext] if sid was passed. - def aws(sid = :unset) - raise ArgumentError, 'sid cannot be nil' if sid.nil? + ## + # Access the new_credentials + # @return [NewCredentialsList] + # @return [NewCredentialsContext] + def new_credentials + @new_credentials ||= NewCredentialsList.new(@version ) + end + ## + # Access the aws + # @return [AwsList] + # @return [AwsContext] if sid was passed. + def aws(sid=:unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? - if sid != :unset - return AwsContext.new(@version, sid) - end + if sid != :unset + return AwsContext.new(@version,sid ) + end - @aws ||= AwsList.new(@version) - end + @aws ||= AwsList.new(@version ) + end - # Provide a user friendly representation - def to_s - '#' - end - end + # Provide a user friendly representation + 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) + 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 + # 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 + ## + # 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 + ## + # Provide a user friendly representation + def to_s + '' + end + end + class CredentialInstance < InstanceResource + ## + # Initialize the CredentialInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Credential + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CredentialInstance] CredentialInstance + def initialize(version ) + super(version) + + end - class CredentialInstance < InstanceResource - ## - # Initialize the CredentialInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Credential - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CredentialInstance] CredentialInstance - def initialize(version) - super(version) - end + + ## + # Provide a user friendly representation + def to_s + "" + end - ## - # Provide a user friendly representation - def to_s - "" - end + ## + # Provide a detailed, user friendly representation + def inspect + "" + end + end - ## - # Provide a detailed, user friendly representation - def inspect - "" - end + end 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 2acdbf143..0615515c9 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 @@ -12,343 +12,352 @@ # Do not edit the class manually. # -module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - class AwsList < ListResource - ## - # Initialize the AwsList - # @param [Version] version Version that contains the resource - # @return [AwsList] AwsList - def initialize(version) - super(version) - # Path Solution - @solution = {} - @uri = "/Credentials/AWS" - end - - ## - # Lists AwsInstance records from the API as a list. - # Unlike stream(), this operation is eager and will load `limit` records into - # memory before returning. - # @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(limit: nil, page_size: nil) - self.stream( - 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 [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(limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - - page = self.page( - page_size: limits[:page_size], - ) - - @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end - - ## - # When passed a block, yields AwsInstance 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 AwsInstance records from the API. - # Request is executed immediately. - # @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 AwsInstance - def page(page_token: :unset, page_number: :unset, page_size: :unset) - params = Twilio::Values.of({ - - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) - - response = @version.page('GET', @uri, params: params) - - AwsPage.new(@version, response, @solution) - end - - ## - # Retrieve a single page of AwsInstance records from the API. - # Request is executed immediately. - # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of AwsInstance - def get_page(target_url) - response = @version.domain.request( - 'GET', - target_url - ) - AwsPage.new(@version, response, @solution) - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - class AwsContext < InstanceContext - ## - # Initialize the AwsContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [AwsContext] AwsContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Credentials/AWS/#{@solution[:sid]}" - - # Dependents - @history = nil - end - - ## - # Delete the AwsInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - @version.delete('DELETE', @uri) - end - - ## - # Fetch the AwsInstance - # @return [AwsInstance] Fetched AwsInstance - def fetch - payload = @version.fetch('GET', @uri) - AwsInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Update the AwsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @return [AwsInstance] Updated AwsInstance - def update( - test_string: :unset, - test_boolean: :unset - ) - - data = Twilio::Values.of({ - 'TestString' => test_string, - 'TestBoolean' => test_boolean, - }) - - payload = @version.update('POST', @uri, data: data) - AwsInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Access the history - # @return [HistoryList] - # @return [HistoryContext] - def history - HistoryContext.new( - @version, - @solution[:sid] - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 - - class AwsInstance < InstanceResource - ## - # Initialize the AwsInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Aws - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AwsInstance] AwsInstance - def initialize(version, payload, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [AwsContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = AwsContext.new(@version, @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Delete the AwsInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - context.delete - end - - ## - # Fetch the AwsInstance - # @return [AwsInstance] Fetched AwsInstance - def fetch - context.fetch - end - - ## - # Update the AwsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @return [AwsInstance] Updated AwsInstance - def update( - test_string: :unset, - test_boolean: :unset - ) - - context.update( - test_string: test_string, - test_boolean: test_boolean, - ) - end - - ## - # Access the history - # @return [history] history - def history - context.history - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" +module Twilio + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + + class AwsList < ListResource + ## + # Initialize the AwsList + # @param [Version] version Version that contains the resource + # @return [AwsList] AwsList + def initialize(version) + super(version) + # Path Solution + @solution = { } + @uri = "/Credentials/AWS" + + end + + ## + # Lists AwsInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @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(limit: nil, page_size: nil) + self.stream( + 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 [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(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields AwsInstance 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 AwsInstance records from the API. + # Request is executed immediately. + # @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 AwsInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + AwsPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of AwsInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of AwsInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + AwsPage.new(@version, response, @solution) + end + + + + # Provide a user friendly representation + def to_s + '#' + end + end + + + class AwsContext < InstanceContext + ## + # Initialize the AwsContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [AwsContext] AwsContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Credentials/AWS/#{@solution[:sid]}" + + # Dependents + @history = nil + end + ## + # Delete the AwsInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + @version.delete('DELETE', @uri) + end + + ## + # Fetch the AwsInstance + # @return [AwsInstance] Fetched AwsInstance + def fetch + + payload = @version.fetch('GET', @uri) + AwsInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Update the AwsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @return [AwsInstance] Updated AwsInstance + def update( + test_string: :unset, + test_boolean: :unset + ) + + data = Twilio::Values.of({ + 'TestString' => test_string, + 'TestBoolean' => test_boolean, + }) + + payload = @version.update('POST', @uri, data: data) + AwsInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Access the history + # @return [HistoryList] + # @return [HistoryContext] + def history + HistoryContext.new( + @version, + @solution[:sid] + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + 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 + class AwsInstance < InstanceResource + ## + # Initialize the AwsInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Aws + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AwsInstance] AwsInstance + def initialize(version, payload , sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AwsContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = AwsContext.new(@version , @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Delete the AwsInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + + context.delete + end + + ## + # Fetch the AwsInstance + # @return [AwsInstance] Fetched AwsInstance + def fetch + + context.fetch + end + + ## + # Update the AwsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @return [AwsInstance] Updated AwsInstance + def update( + test_string: :unset, + test_boolean: :unset + ) + + context.update( + test_string: test_string, + test_boolean: test_boolean, + ) + end + + ## + # Access the history + # @return [history] history + def history + context.history + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end + + end end - end 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 84fa208aa..748ead41b 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 @@ -12,196 +12,208 @@ # Do not edit the class manually. # + module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - class AwsContext < InstanceContext - class HistoryList < ListResource - ## - # Initialize the HistoryList - # @param [Version] version Version that contains the resource - # @return [HistoryList] HistoryList - def initialize(version, sid: nil) - super(version) - # Path Solution - @solution = { sid: sid } - end - - # Provide a user friendly representation - def to_s - '#' - end - end + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + class AwsContext < InstanceContext + + class HistoryList < ListResource + ## + # Initialize the HistoryList + # @param [Version] version Version that contains the resource + # @return [HistoryList] HistoryList + def initialize(version, sid: nil) + super(version) + # Path Solution + @solution = { sid: sid } + + + end + + + + # Provide a user friendly representation + def to_s + '#' + end + end - class HistoryContext < InstanceContext - ## - # Initialize the HistoryContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [HistoryContext] HistoryContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Credentials/AWS/#{@solution[:sid]}/History" - end - - ## - # Fetch the HistoryInstance - # @param [Hash] add_ons_data - # @return [HistoryInstance] Fetched HistoryInstance - def fetch( - add_ons_data: :unset - ) - - params = Twilio::Values.of({}) - params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) - payload = @version.fetch('GET', @uri, params: params) - HistoryInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 + class HistoryContext < InstanceContext + ## + # Initialize the HistoryContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [HistoryContext] HistoryContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Credentials/AWS/#{@solution[:sid]}/History" + + + end + ## + # Fetch the HistoryInstance + # @param [Hash] add_ons_data + # @return [HistoryInstance] Fetched HistoryInstance + def fetch( + add_ons_data: :unset + ) + + params = Twilio::Values.of({ + }) + params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) + payload = @version.fetch('GET', @uri, params: params) + HistoryInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + end - class HistoryInstance < InstanceResource - ## - # Initialize the HistoryInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this History - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [HistoryInstance] HistoryInstance - def initialize(version, payload, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [HistoryContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = HistoryContext.new(@version, @params['sid']) + 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 + class HistoryInstance < InstanceResource + ## + # Initialize the HistoryInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this History + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [HistoryInstance] HistoryInstance + def initialize(version, payload , sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [HistoryContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = HistoryContext.new(@version , @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Fetch the HistoryInstance + # @param [Hash] add_ons_data + # @return [HistoryInstance] Fetched HistoryInstance + def fetch( + add_ons_data: :unset + ) + + context.fetch( + add_ons_data: add_ons_data, + ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Fetch the HistoryInstance - # @param [Hash] add_ons_data - # @return [HistoryInstance] Fetched HistoryInstance - def fetch( - add_ons_data: :unset - ) - - context.fetch( - add_ons_data: add_ons_data, - ) - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end + + end + end end - end 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 2bcd67c1f..0019252b9 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 @@ -12,189 +12,193 @@ # Do not edit the class manually. # -module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - class NewCredentialsList < ListResource - ## - # Initialize the NewCredentialsList - # @param [Version] version Version that contains the resource - # @return [NewCredentialsList] NewCredentialsList - def initialize(version) - super(version) - # Path Solution - @solution = {} - @uri = "/Credentials/AWS" - end - - ## - # Create the NewCredentialsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @param [String] test_integer - # @param [Float] test_number - # @param [Float] test_number_float - # @param [Float] test_number_double - # @param [Float] test_number_int32 - # @param [String] test_number_int64 - # @param [Hash] test_object - # @param [Time] test_date_time - # @param [Date] test_date - # @param [Status] test_enum - # @param [Array[Hash]] test_object_array - # @param [Object] test_any_type - # @param [Array[Hash]] test_any_array - # @param [Array[String]] permissions A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. - # @param [String] some_a2p_thing - # @return [NewCredentialsInstance] Created NewCredentialsInstance - def create( - test_string: nil, - test_boolean: :unset, - test_integer: :unset, - test_number: :unset, - test_number_float: :unset, - test_number_double: :unset, - test_number_int32: :unset, - test_number_int64: :unset, - test_object: :unset, - test_date_time: :unset, - test_date: :unset, - test_enum: :unset, - test_object_array: :unset, - test_any_type: :unset, - test_any_array: :unset, - permissions: :unset, - some_a2p_thing: :unset - ) - - data = Twilio::Values.of({ - 'TestString' => test_string, - 'TestBoolean' => test_boolean, - 'TestInteger' => test_integer, - 'TestNumber' => test_number, - 'TestNumberFloat' => test_number_float, - 'TestNumberDouble' => test_number_double, - 'TestNumberInt32' => test_number_int32, - 'TestNumberInt64' => test_number_int64, - 'TestObject' => Twilio.serialize_object(test_object), - 'TestDateTime' => Twilio.serialize_iso8601_datetime(test_date_time), - 'TestDate' => Twilio.serialize_iso8601_date(test_date), - 'TestEnum' => test_enum, - 'TestObjectArray' => Twilio.serialize_list(test_object_array) { |e| - Twilio.serialize_object(e) - }, - 'TestAnyType' => Twilio.serialize_object(test_any_type), - 'TestAnyArray' => Twilio.serialize_list(test_any_array) { |e| - Twilio.serialize_object(e) - }, - 'Permissions' => Twilio.serialize_list(permissions) { |e| e }, - 'SomeA2PThing' => some_a2p_thing, - }) - - payload = @version.create('POST', @uri, data: data) - NewCredentialsInstance.new( - @version, - payload, - ) - end - - # Provide a user friendly representation - 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 - - class NewCredentialsInstance < InstanceResource - ## - # Initialize the NewCredentialsInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this NewCredentials - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [NewCredentialsInstance] NewCredentialsInstance - def initialize(version, payload) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Provide a user friendly representation - def to_s - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - "" +module Twilio + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + + class NewCredentialsList < ListResource + ## + # Initialize the NewCredentialsList + # @param [Version] version Version that contains the resource + # @return [NewCredentialsList] NewCredentialsList + def initialize(version) + super(version) + # Path Solution + @solution = { } + @uri = "/Credentials/AWS" + + end + ## + # Create the NewCredentialsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @param [String] test_integer + # @param [Float] test_number + # @param [Float] test_number_float + # @param [Float] test_number_double + # @param [Float] test_number_int32 + # @param [String] test_number_int64 + # @param [Hash] test_object + # @param [Time] test_date_time + # @param [Date] test_date + # @param [Status] test_enum + # @param [Array[Hash]] test_object_array + # @param [Object] test_any_type + # @param [Array[Hash]] test_any_array + # @param [Array[String]] permissions A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. + # @param [String] some_a2p_thing + # @return [NewCredentialsInstance] Created NewCredentialsInstance + def create( + test_string: nil, + test_boolean: :unset, + test_integer: :unset, + test_number: :unset, + test_number_float: :unset, + test_number_double: :unset, + test_number_int32: :unset, + test_number_int64: :unset, + test_object: :unset, + test_date_time: :unset, + test_date: :unset, + test_enum: :unset, + test_object_array: :unset, + test_any_type: :unset, + test_any_array: :unset, + permissions: :unset, + some_a2p_thing: :unset + ) + + data = Twilio::Values.of({ + 'TestString' => test_string, + 'TestBoolean' => test_boolean, + 'TestInteger' => test_integer, + 'TestNumber' => test_number, + 'TestNumberFloat' => test_number_float, + 'TestNumberDouble' => test_number_double, + 'TestNumberInt32' => test_number_int32, + 'TestNumberInt64' => test_number_int64, + 'TestObject' => Twilio.serialize_object(test_object), + 'TestDateTime' => Twilio.serialize_iso8601_datetime(test_date_time), + 'TestDate' => Twilio.serialize_iso8601_date(test_date), + 'TestEnum' => test_enum, + 'TestObjectArray' => Twilio.serialize_list(test_object_array) { |e| Twilio.serialize_object(e) }, + 'TestAnyType' => Twilio.serialize_object(test_any_type), + 'TestAnyArray' => Twilio.serialize_list(test_any_array) { |e| Twilio.serialize_object(e) }, + 'Permissions' => Twilio.serialize_list(permissions) { |e| e }, + 'SomeA2PThing' => some_a2p_thing, + }) + + payload = @version.create('POST', @uri, data: data) + NewCredentialsInstance.new( + @version, + payload, + ) + end + + + + + # Provide a user friendly representation + 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 + class NewCredentialsInstance < InstanceResource + ## + # Initialize the NewCredentialsInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this NewCredentials + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [NewCredentialsInstance] NewCredentialsInstance + def initialize(version, payload ) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + end + + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Provide a user friendly representation + def to_s + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + "" + end + end + + end end - end end - end end - end end + + diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb index 777cb0278..d30c57bc7 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb @@ -13,39 +13,37 @@ # module Twilio - module REST - class Versionless - class DeployedDevices < Version - ## - # Initialize the DeployedDevices version of Versionless - def initialize(domain) - super - @version = 'DeployedDevices' - @fleets = nil - end - - ## - # @param [String] sid - # @return [Twilio::REST::Versionless::DeployedDevices::FleetContext] if sid was passed. - # @return [Twilio::REST::Versionless::DeployedDevices::FleetList] - def fleets(sid = :unset) - if sid.nil? - raise ArgumentError, 'sid cannot be nil' - end - - if sid == :unset - @fleets ||= FleetList.new self - else - FleetContext.new(self, sid) - end - end + module REST + class Versionless + class DeployedDevices < Version + ## + # Initialize the DeployedDevices version of Versionless + def initialize(domain) + super + @version = 'DeployedDevices' + @fleets = nil + end - ## - # Provide a user friendly representation - def to_s - ''; + ## + # @param [String] sid + # @return [Twilio::REST::Versionless::DeployedDevices::FleetContext] if sid was passed. + # @return [Twilio::REST::Versionless::DeployedDevices::FleetList] + def fleets(sid=:unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + if sid == :unset + @fleets ||= FleetList.new self + else + FleetContext.new(self, sid) + end + end + ## + # Provide a user friendly representation + def to_s + ''; + end + end 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 58323ae0e..c42f3acd8 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 @@ -12,193 +12,202 @@ # Do not edit the class manually. # -module Twilio - module REST - class Versionless < VersionlessBase - class DeployedDevices < Version - class FleetList < ListResource - ## - # Initialize the FleetList - # @param [Version] version Version that contains the resource - # @return [FleetList] FleetList - def initialize(version) - super(version) - # Path Solution - @solution = {} - @uri = "/Fleets" - end - - ## - # Create the FleetInstance - # @param [String] name - # @return [FleetInstance] Created FleetInstance - def create( - name: :unset - ) - - data = Twilio::Values.of({ - 'Name' => name, - }) - - payload = @version.create('POST', @uri, data: data) - FleetInstance.new( - @version, - payload, - ) - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - class FleetContext < InstanceContext - ## - # Initialize the FleetContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [FleetContext] FleetContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Fleets/#{@solution[:sid]}" - end - - ## - # Fetch the FleetInstance - # @return [FleetInstance] Fetched FleetInstance - def fetch - payload = @version.fetch('GET', @uri) - FleetInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') - "#" - 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 +module Twilio + module REST + class Versionless < VersionlessBase + class DeployedDevices < Version + class FleetList < ListResource + ## + # Initialize the FleetList + # @param [Version] version Version that contains the resource + # @return [FleetList] FleetList + def initialize(version) + super(version) + # Path Solution + @solution = { } + @uri = "/Fleets" + + end + ## + # Create the FleetInstance + # @param [String] name + # @return [FleetInstance] Created FleetInstance + def create( + name: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + }) + + payload = @version.create('POST', @uri, data: data) + FleetInstance.new( + @version, + payload, + ) + end + + + + + # Provide a user friendly representation + def to_s + '#' + end + end + + + class FleetContext < InstanceContext + ## + # Initialize the FleetContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [FleetContext] FleetContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Fleets/#{@solution[:sid]}" + + + end + ## + # Fetch the FleetInstance + # @return [FleetInstance] Fetched FleetInstance + def fetch + + payload = @version.fetch('GET', @uri) + FleetInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + + ## + # Provide a user friendly representation + def to_s + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') + "#" + 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 + class FleetInstance < InstanceResource + ## + # Initialize the FleetInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Fleet + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [FleetInstance] FleetInstance + def initialize(version, payload , sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'name' => payload['name'], + 'sid' => payload['sid'], + 'friendly_name' => payload['friendly_name'], + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'] , } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [FleetContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = FleetContext.new(@version , @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def name + @properties['name'] + end + + ## + # @return [String] A string that uniquely identifies this Fleet. + def sid + @properties['sid'] + end + + ## + # @return [String] A human readable description for this Fleet. + def friendly_name + @properties['friendly_name'] + end + + ## + # Fetch the FleetInstance + # @return [FleetInstance] Fetched FleetInstance + def fetch + + context.fetch + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") + "" + end + end - class FleetInstance < InstanceResource - ## - # Initialize the FleetInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Fleet - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [FleetInstance] FleetInstance - def initialize(version, payload, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'name' => payload['name'], - 'sid' => payload['sid'], - 'friendly_name' => payload['friendly_name'], - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'], } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [FleetContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = FleetContext.new(@version, @params['sid']) end - @instance_context - end - - ## - # @return [String] - def name - @properties['name'] - end - - ## - # @return [String] A string that uniquely identifies this Fleet. - def sid - @properties['sid'] - end - - ## - # @return [String] A human readable description for this Fleet. - def friendly_name - @properties['friendly_name'] - end - - ## - # Fetch the FleetInstance - # @return [FleetInstance] Fetched FleetInstance - def fetch - context.fetch - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") - "" - end end - end end - end end diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb index c55a7abe3..4654f1ba7 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb @@ -13,29 +13,28 @@ # module Twilio - module REST - class Versionless - class Understand < Version - ## - # Initialize the Understand version of Versionless - def initialize(domain) - super - @version = 'understand' - @assistants = nil - end - - ## - # @return [Twilio::REST::Versionless::Understand::AssistantList] - def assistants - @assistants ||= AssistantList.new self - end + module REST + class Versionless + class Understand < Version + ## + # Initialize the Understand version of Versionless + def initialize(domain) + super + @version = 'understand' + @assistants = nil + end - ## - # Provide a user friendly representation - def to_s - ''; + ## + # @return [Twilio::REST::Versionless::Understand::AssistantList] + def assistants + @assistants ||= AssistantList.new self + end + ## + # Provide a user friendly representation + def to_s + ''; + end + end 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 997f18541..a751a9dfc 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb @@ -12,188 +12,191 @@ # Do not edit the class manually. # + module Twilio - module REST - class Versionless < VersionlessBase - class Understand < Version - class AssistantList < ListResource - ## - # Initialize the AssistantList - # @param [Version] version Version that contains the resource - # @return [AssistantList] AssistantList - def initialize(version) - super(version) - # Path Solution - @solution = {} - @uri = "/Assistants" - end - - ## - # Lists AssistantInstance records from the API as a list. - # Unlike stream(), this operation is eager and will load `limit` records into - # memory before returning. - # @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(limit: nil, page_size: nil) - self.stream( - 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 [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(limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - - page = self.page( - page_size: limits[:page_size], - ) - - @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end - - ## - # When passed a block, yields AssistantInstance 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, + module REST + class Versionless < VersionlessBase + class Understand < Version + class AssistantList < ListResource + ## + # Initialize the AssistantList + # @param [Version] version Version that contains the resource + # @return [AssistantList] AssistantList + def initialize(version) + super(version) + # Path Solution + @solution = { } + @uri = "/Assistants" + + end + + ## + # Lists AssistantInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @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(limit: nil, page_size: nil) + self.stream( + 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 [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(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + page_size: limits[:page_size], ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields AssistantInstance 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 AssistantInstance records from the API. - # Request is executed immediately. - # @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 AssistantInstance - def page(page_token: :unset, page_number: :unset, page_size: :unset) - params = Twilio::Values.of({ - - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) - - response = @version.page('GET', @uri, params: params) - - AssistantPage.new(@version, response, @solution) - end - - ## - # Retrieve a single page of AssistantInstance records from the API. - # Request is executed immediately. - # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of AssistantInstance - def get_page(target_url) - response = @version.domain.request( - 'GET', - target_url - ) - AssistantPage.new(@version, response, @solution) - end - - # Provide a user friendly representation - 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 - - class AssistantInstance < InstanceResource - ## - # Initialize the AssistantInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Assistant - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AssistantInstance] AssistantInstance - def initialize(version, payload) - super(version) - - # Marshaled Properties - @properties = { - 'sid' => payload['sid'], - 'friendly_name' => payload['friendly_name'], - } - end - - ## - # @return [String] A string that uniquely identifies this Fleet. - def sid - @properties['sid'] - end - - ## - # @return [String] A human readable description for this Fleet. - def friendly_name - @properties['friendly_name'] - end - - ## - # Provide a user friendly representation - def to_s - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - "" - end + page_limit: limits[:page_limit]).each {|x| yield x} + end + + ## + # Retrieve a single page of AssistantInstance records from the API. + # Request is executed immediately. + # @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 AssistantInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + AssistantPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of AssistantInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of AssistantInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + AssistantPage.new(@version, response, @solution) + end + + + + # Provide a user friendly representation + 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 + class AssistantInstance < InstanceResource + ## + # Initialize the AssistantInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Assistant + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AssistantInstance] AssistantInstance + def initialize(version, payload ) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'friendly_name' => payload['friendly_name'], + } + end + + + ## + # @return [String] A string that uniquely identifies this Fleet. + def sid + @properties['sid'] + end + + ## + # @return [String] A human readable description for this Fleet. + def friendly_name + @properties['friendly_name'] + end + + ## + # Provide a user friendly representation + def to_s + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + "" + end + end + + end end - end end - end end From cf13a7715a097fd64b1c4f52da816a355a885b5e Mon Sep 17 00:00:00 2001 From: AsabuHere Date: Thu, 13 Jul 2023 19:05:54 +0530 Subject: [PATCH 4/4] generated changes --- .../spec/integration/apiIntegration.spec.ts | 2 +- examples/node/spec/unit/account.spec.ts | 2 +- examples/node/src/rest/api/v2010/account.ts | 81 +- .../node/src/rest/api/v2010/account/call.ts | 48 +- .../v2010/account/call/feedbackCallSummary.ts | 28 +- examples/node/src/rest/flexApi/v1/call.ts | 23 +- .../node/src/rest/flexApi/v1/credential.ts | 4 +- .../src/rest/flexApi/v1/credential/aws.ts | 71 +- .../rest/flexApi/v1/credential/aws/history.ts | 31 +- .../flexApi/v1/credential/newCredentials.ts | 23 +- .../versionless/deployed_devices/fleet.ts | 29 +- .../rest/versionless/understand/assistant.ts | 35 +- .../ruby/lib/twilio-ruby/rest/api/v2010.rb | 90 +- .../lib/twilio-ruby/rest/api/v2010/account.rb | 976 +++++++++--------- .../rest/api/v2010/account/call.rb | 717 +++++++------ .../account/call/feedback_call_summary.rb | 592 ++++++----- .../ruby/lib/twilio-ruby/rest/flex_api/v1.rb | 75 +- .../lib/twilio-ruby/rest/flex_api/v1/call.rb | 310 +++--- .../rest/flex_api/v1/credential.rb | 185 ++-- .../rest/flex_api/v1/credential/aws.rb | 678 ++++++------ .../flex_api/v1/credential/aws/history.rb | 380 ++++--- .../flex_api/v1/credential/new_credentials.rb | 366 ++++--- .../rest/versionless/deployed_devices.rb | 62 +- .../versionless/deployed_devices/fleet.rb | 377 ++++--- .../rest/versionless/understand.rb | 43 +- .../rest/versionless/understand/assistant.rb | 362 ++++--- 26 files changed, 2785 insertions(+), 2805 deletions(-) diff --git a/examples/node/spec/integration/apiIntegration.spec.ts b/examples/node/spec/integration/apiIntegration.spec.ts index 9e2888944..159f620bf 100644 --- a/examples/node/spec/integration/apiIntegration.spec.ts +++ b/examples/node/spec/integration/apiIntegration.spec.ts @@ -51,7 +51,7 @@ describe("Integration tests", () => { .calls.feedbackCallSummary("CR12345678123456781234567812345678") .update(params); expect(result.testArrayOfObjects[0].description).toEqual( - "issue description" + "issue description", ); expect(result.testArrayOfObjects[0].count).toEqual(4); }); diff --git a/examples/node/spec/unit/account.spec.ts b/examples/node/spec/unit/account.spec.ts index e4956655e..60be507c5 100644 --- a/examples/node/spec/unit/account.spec.ts +++ b/examples/node/spec/unit/account.spec.ts @@ -118,7 +118,7 @@ describe("account", () => { .page(params) .then((accountPage) => { expect(accountPage.getNextPageUrl()).toEqual( - "http://api.twilio.com/2010-04-01/Accounts.json?FriendlyName=friendly_name&Status=active&PageSize=50&Page=50" + "http://api.twilio.com/2010-04-01/Accounts.json?FriendlyName=friendly_name&Status=active&PageSize=50&Page=50", ); expect(accountPage.instances[0].testObject.mms).toEqual(true); expect(accountPage.instances[0].testObject.sms).toEqual(false); diff --git a/examples/node/src/rest/api/v2010/account.ts b/examples/node/src/rest/api/v2010/account.ts index ac4ed2471..c00f6bcab 100644 --- a/examples/node/src/rest/api/v2010/account.ts +++ b/examples/node/src/rest/api/v2010/account.ts @@ -130,7 +130,7 @@ export interface AccountContext { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise; /** @@ -141,7 +141,7 @@ export interface AccountContext { * @returns Resolves to processed AccountInstance */ fetch( - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise; /** @@ -154,7 +154,7 @@ export interface AccountContext { */ update( params: AccountContextUpdateOptions, - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise; /** @@ -174,7 +174,10 @@ export class AccountContextImpl implements AccountContext { protected _calls?: CallListInstance; - constructor(protected _version: V2010, sid: string) { + constructor( + protected _version: V2010, + sid: string, + ) { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); } @@ -190,7 +193,7 @@ export class AccountContextImpl implements AccountContext { } remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -201,13 +204,13 @@ export class AccountContextImpl implements AccountContext { operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } fetch( - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -218,19 +221,19 @@ export class AccountContextImpl implements AccountContext { operationPromise = operationPromise.then( (payload) => - new AccountInstance(operationVersion, payload, instance._solution.sid) + new AccountInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } update( params: AccountContextUpdateOptions, - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise { if (params === null || params === undefined) { throw new Error('Required parameter "params" missing.'); @@ -261,12 +264,12 @@ export class AccountContextImpl implements AccountContext { operationPromise = operationPromise.then( (payload) => - new AccountInstance(operationVersion, payload, instance._solution.sid) + new AccountInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -316,7 +319,7 @@ export class AccountInstance { constructor( protected _version: V2010, payload: AccountResource, - sid?: string + sid?: string, ) { this.accountSid = payload.account_sid; this.sid = payload.sid; @@ -378,7 +381,7 @@ export class AccountInstance { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { return this._proxy.remove(callback); } @@ -391,7 +394,7 @@ export class AccountInstance { * @returns Resolves to processed AccountInstance */ fetch( - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise { return this._proxy.fetch(callback); } @@ -406,12 +409,12 @@ export class AccountInstance { */ update( params: AccountContextUpdateOptions, - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise; update( params?: any, - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise { return this._proxy.update(params, callback); } @@ -473,7 +476,7 @@ export interface AccountListInstance { * @returns Resolves to processed AccountInstance */ create( - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise; /** * Create a AccountInstance @@ -485,7 +488,7 @@ export interface AccountListInstance { */ create( params: AccountListInstanceCreateOptions, - callback?: (error: Error | null, item?: AccountInstance) => any + callback?: (error: Error | null, item?: AccountInstance) => any, ): Promise; /** @@ -504,11 +507,11 @@ export interface AccountListInstance { * @param { function } [callback] - Function to process each record */ each( - callback?: (item: AccountInstance, done: (err?: Error) => void) => void + callback?: (item: AccountInstance, done: (err?: Error) => void) => void, ): void; each( params: AccountListInstanceEachOptions, - callback?: (item: AccountInstance, done: (err?: Error) => void) => void + callback?: (item: AccountInstance, done: (err?: Error) => void) => void, ): void; /** * Retrieve a single target page of AccountInstance records from the API. @@ -520,7 +523,7 @@ export interface AccountListInstance { */ getPage( targetUrl: string, - callback?: (error: Error | null, items: AccountPage) => any + callback?: (error: Error | null, items: AccountPage) => any, ): Promise; /** * Lists AccountInstance records from the API as a list. @@ -532,11 +535,11 @@ export interface AccountListInstance { * @param { function } [callback] - Callback to handle list of records */ list( - callback?: (error: Error | null, items: AccountInstance[]) => any + callback?: (error: Error | null, items: AccountInstance[]) => any, ): Promise; list( params: AccountListInstanceOptions, - callback?: (error: Error | null, items: AccountInstance[]) => any + callback?: (error: Error | null, items: AccountInstance[]) => any, ): Promise; /** * Retrieve a single page of AccountInstance records from the API. @@ -550,11 +553,11 @@ export interface AccountListInstance { * @param { function } [callback] - Callback to handle list of records */ page( - callback?: (error: Error | null, items: AccountPage) => any + callback?: (error: Error | null, items: AccountPage) => any, ): Promise; page( params: AccountListInstancePageOptions, - callback?: (error: Error | null, items: AccountPage) => any + callback?: (error: Error | null, items: AccountPage) => any, ): Promise; /** @@ -579,7 +582,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { params?: | AccountListInstanceCreateOptions | ((error: Error | null, items: AccountInstance) => any), - callback?: (error: Error | null, items: AccountInstance) => any + callback?: (error: Error | null, items: AccountInstance) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -595,7 +598,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { if (params["recordingStatusCallbackEvent"] !== undefined) data["RecordingStatusCallbackEvent"] = serialize.map( params["recordingStatusCallbackEvent"], - (e: string) => e + (e: string) => e, ); if (params["twiml"] !== undefined) data["Twiml"] = serialize.twiml(params["twiml"]); @@ -614,12 +617,12 @@ export function AccountListInstance(version: V2010): AccountListInstance { }); operationPromise = operationPromise.then( - (payload) => new AccountInstance(operationVersion, payload) + (payload) => new AccountInstance(operationVersion, payload), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -628,7 +631,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { params?: | AccountListInstancePageOptions | ((error: Error | null, items: AccountPage) => any), - callback?: (error: Error | null, items: AccountPage) => any + callback?: (error: Error | null, items: AccountPage) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -645,11 +648,11 @@ export function AccountListInstance(version: V2010): AccountListInstance { data["Date.Test"] = serialize.iso8601Date(params["date.test"]); if (params["dateCreatedBefore"] !== undefined) data["DateCreated<"] = serialize.iso8601DateTime( - params["dateCreatedBefore"] + params["dateCreatedBefore"], ); if (params["dateCreatedAfter"] !== undefined) data["DateCreated>"] = serialize.iso8601DateTime( - params["dateCreatedAfter"] + params["dateCreatedAfter"], ); if (params["pageSize"] !== undefined) data["PageSize"] = params["pageSize"]; @@ -668,12 +671,12 @@ export function AccountListInstance(version: V2010): AccountListInstance { operationPromise = operationPromise.then( (payload) => - new AccountPage(operationVersion, payload, instance._solution) + new AccountPage(operationVersion, payload, instance._solution), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -682,7 +685,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { instance.getPage = function getPage( targetUrl: string, - callback?: (error: Error | null, items: AccountPage) => any + callback?: (error: Error | null, items: AccountPage) => any, ): Promise { const operationPromise = instance._version._domain.twilio.request({ method: "get", @@ -691,7 +694,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { let pagePromise = operationPromise.then( (payload) => - new AccountPage(instance._version, payload, instance._solution) + new AccountPage(instance._version, payload, instance._solution), ); pagePromise = instance._version.setPromiseCallback(pagePromise, callback); return pagePromise; @@ -703,7 +706,7 @@ export function AccountListInstance(version: V2010): AccountListInstance { instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; @@ -727,7 +730,7 @@ export class AccountPage extends Page< constructor( version: V2010, response: Response, - solution: AccountSolution + solution: AccountSolution, ) { super(version, response, solution); } diff --git a/examples/node/src/rest/api/v2010/account/call.ts b/examples/node/src/rest/api/v2010/account/call.ts index 104465870..08edabcb0 100644 --- a/examples/node/src/rest/api/v2010/account/call.ts +++ b/examples/node/src/rest/api/v2010/account/call.ts @@ -56,7 +56,7 @@ export interface CallContext { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise; /** @@ -67,7 +67,7 @@ export interface CallContext { * @returns Resolves to processed CallInstance */ fetch( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise; /** @@ -89,7 +89,7 @@ export class CallContextImpl implements CallContext { constructor( protected _version: V2010, accountSid: string, - testInteger: number + testInteger: number, ) { if (!isValidPathParam(accountSid)) { throw new Error("Parameter 'accountSid' is not valid."); @@ -104,7 +104,7 @@ export class CallContextImpl implements CallContext { } remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -115,13 +115,13 @@ export class CallContextImpl implements CallContext { operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } fetch( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -136,13 +136,13 @@ export class CallContextImpl implements CallContext { operationVersion, payload, instance._solution.accountSid, - instance._solution.testInteger - ) + instance._solution.testInteger, + ), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -191,7 +191,7 @@ export class CallInstance { protected _version: V2010, payload: CallResource, accountSid: string, - testInteger?: number + testInteger?: number, ) { this.accountSid = payload.account_sid; this.sid = payload.sid; @@ -247,7 +247,7 @@ export class CallInstance { new CallContextImpl( this._version, this._solution.accountSid, - this._solution.testInteger + this._solution.testInteger, ); return this._context; } @@ -260,7 +260,7 @@ export class CallInstance { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { return this._proxy.remove(callback); } @@ -273,7 +273,7 @@ export class CallInstance { * @returns Resolves to processed CallInstance */ fetch( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise { return this._proxy.fetch(callback); } @@ -335,7 +335,7 @@ export interface CallListInstance { */ create( params: CallListInstanceCreateOptions, - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise; /** @@ -347,7 +347,7 @@ export interface CallListInstance { export function CallListInstance( version: V2010, - accountSid: string + accountSid: string, ): CallListInstance { if (!isValidPathParam(accountSid)) { throw new Error("Parameter 'accountSid' is not valid."); @@ -369,7 +369,7 @@ export function CallListInstance( if (!instance._feedbackCallSummary) { instance._feedbackCallSummary = FeedbackCallSummaryListInstance( instance._version, - instance._solution.accountSid + instance._solution.accountSid, ); } return instance._feedbackCallSummary; @@ -378,7 +378,7 @@ export function CallListInstance( instance.create = function create( params: CallListInstanceCreateOptions, - callback?: (error: Error | null, items: CallInstance) => any + callback?: (error: Error | null, items: CallInstance) => any, ): Promise { if (params === null || params === undefined) { throw new Error('Required parameter "params" missing.'); @@ -389,7 +389,7 @@ export function CallListInstance( params["requiredStringProperty"] === undefined ) { throw new Error( - "Required parameter \"params['requiredStringProperty']\" missing." + "Required parameter \"params['requiredStringProperty']\" missing.", ); } @@ -403,12 +403,12 @@ export function CallListInstance( if (params["testArrayOfStrings"] !== undefined) data["TestArrayOfStrings"] = serialize.map( params["testArrayOfStrings"], - (e: string) => e + (e: string) => e, ); if (params["testArrayOfUri"] !== undefined) data["TestArrayOfUri"] = serialize.map( params["testArrayOfUri"], - (e: string) => e + (e: string) => e, ); data["TestMethod"] = params["testMethod"]; @@ -429,13 +429,13 @@ export function CallListInstance( new CallInstance( operationVersion, payload, - instance._solution.accountSid - ) + instance._solution.accountSid, + ), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -446,7 +446,7 @@ export function CallListInstance( instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts b/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts index d61eb1877..f1edee7dc 100644 --- a/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts +++ b/examples/node/src/rest/api/v2010/account/call/feedbackCallSummary.ts @@ -55,7 +55,7 @@ export interface FeedbackCallSummaryContext { */ update( params: FeedbackCallSummaryContextUpdateOptions, - callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any + callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any, ): Promise; /** @@ -76,7 +76,11 @@ export class FeedbackCallSummaryContextImpl protected _solution: FeedbackCallSummaryContextSolution; protected _uri: string; - constructor(protected _version: V2010, accountSid: string, sid: string) { + constructor( + protected _version: V2010, + accountSid: string, + sid: string, + ) { if (!isValidPathParam(accountSid)) { throw new Error("Parameter 'accountSid' is not valid."); } @@ -91,7 +95,7 @@ export class FeedbackCallSummaryContextImpl update( params: FeedbackCallSummaryContextUpdateOptions, - callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any + callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any, ): Promise { if (params === null || params === undefined) { throw new Error('Required parameter "params" missing.'); @@ -132,13 +136,13 @@ export class FeedbackCallSummaryContextImpl operationVersion, payload, instance._solution.accountSid, - instance._solution.sid - ) + instance._solution.sid, + ), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -187,7 +191,7 @@ export class FeedbackCallSummaryInstance { protected _version: V2010, payload: FeedbackCallSummaryResource, accountSid: string, - sid?: string + sid?: string, ) { this.accountSid = payload.account_sid; this.sid = payload.sid; @@ -240,7 +244,7 @@ export class FeedbackCallSummaryInstance { new FeedbackCallSummaryContextImpl( this._version, this._solution.accountSid, - this._solution.sid + this._solution.sid, ); return this._context; } @@ -255,12 +259,12 @@ export class FeedbackCallSummaryInstance { */ update( params: FeedbackCallSummaryContextUpdateOptions, - callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any + callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any, ): Promise; update( params?: any, - callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any + callback?: (error: Error | null, item?: FeedbackCallSummaryInstance) => any, ): Promise { return this._proxy.update(params, callback); } @@ -318,7 +322,7 @@ export interface FeedbackCallSummaryListInstance { export function FeedbackCallSummaryListInstance( version: V2010, - accountSid: string + accountSid: string, ): FeedbackCallSummaryListInstance { if (!isValidPathParam(accountSid)) { throw new Error("Parameter 'accountSid' is not valid."); @@ -341,7 +345,7 @@ export function FeedbackCallSummaryListInstance( instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/flexApi/v1/call.ts b/examples/node/src/rest/flexApi/v1/call.ts index ff02d0fe6..578b2d70c 100644 --- a/examples/node/src/rest/flexApi/v1/call.ts +++ b/examples/node/src/rest/flexApi/v1/call.ts @@ -27,7 +27,7 @@ export interface CallContext { * @returns Resolves to processed CallInstance */ update( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise; /** @@ -45,7 +45,10 @@ export class CallContextImpl implements CallContext { protected _solution: CallContextSolution; protected _uri: string; - constructor(protected _version: V1, sid: string) { + constructor( + protected _version: V1, + sid: string, + ) { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); } @@ -55,7 +58,7 @@ export class CallContextImpl implements CallContext { } update( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -66,12 +69,12 @@ export class CallContextImpl implements CallContext { operationPromise = operationPromise.then( (payload) => - new CallInstance(operationVersion, payload, instance._solution.sid) + new CallInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -100,7 +103,11 @@ export class CallInstance { protected _solution: CallContextSolution; protected _context?: CallContext; - constructor(protected _version: V1, payload: CallResource, sid?: string) { + constructor( + protected _version: V1, + payload: CallResource, + sid?: string, + ) { this.sid = deserialize.integer(payload.sid); this._solution = { sid: sid || this.sid.toString() }; @@ -125,7 +132,7 @@ export class CallInstance { * @returns Resolves to processed CallInstance */ update( - callback?: (error: Error | null, item?: CallInstance) => any + callback?: (error: Error | null, item?: CallInstance) => any, ): Promise { return this._proxy.update(callback); } @@ -180,7 +187,7 @@ export function CallListInstance(version: V1): CallListInstance { instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/flexApi/v1/credential.ts b/examples/node/src/rest/flexApi/v1/credential.ts index 880619ae2..7cf3bf7a3 100644 --- a/examples/node/src/rest/flexApi/v1/credential.ts +++ b/examples/node/src/rest/flexApi/v1/credential.ts @@ -59,7 +59,7 @@ export function CredentialListInstance(version: V1): CredentialListInstance { get: function newCredentials() { if (!instance._newCredentials) { instance._newCredentials = NewCredentialsListInstance( - instance._version + instance._version, ); } return instance._newCredentials; @@ -72,7 +72,7 @@ export function CredentialListInstance(version: V1): CredentialListInstance { instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/flexApi/v1/credential/aws.ts b/examples/node/src/rest/flexApi/v1/credential/aws.ts index 9396f98f0..343e72270 100644 --- a/examples/node/src/rest/flexApi/v1/credential/aws.ts +++ b/examples/node/src/rest/flexApi/v1/credential/aws.ts @@ -77,7 +77,7 @@ export interface AwsContext { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise; /** @@ -88,7 +88,7 @@ export interface AwsContext { * @returns Resolves to processed AwsInstance */ fetch( - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise; /** @@ -99,7 +99,7 @@ export interface AwsContext { * @returns Resolves to processed AwsInstance */ update( - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise; /** * Update a AwsInstance @@ -111,7 +111,7 @@ export interface AwsContext { */ update( params: AwsContextUpdateOptions, - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise; /** @@ -131,7 +131,10 @@ export class AwsContextImpl implements AwsContext { protected _history?: HistoryListInstance; - constructor(protected _version: V1, sid: string) { + constructor( + protected _version: V1, + sid: string, + ) { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); } @@ -147,7 +150,7 @@ export class AwsContextImpl implements AwsContext { } remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -158,13 +161,13 @@ export class AwsContextImpl implements AwsContext { operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } fetch( - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -175,12 +178,12 @@ export class AwsContextImpl implements AwsContext { operationPromise = operationPromise.then( (payload) => - new AwsInstance(operationVersion, payload, instance._solution.sid) + new AwsInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -189,7 +192,7 @@ export class AwsContextImpl implements AwsContext { params?: | AwsContextUpdateOptions | ((error: Error | null, item?: AwsInstance) => any), - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -219,12 +222,12 @@ export class AwsContextImpl implements AwsContext { operationPromise = operationPromise.then( (payload) => - new AwsInstance(operationVersion, payload, instance._solution.sid) + new AwsInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -258,7 +261,11 @@ export class AwsInstance { protected _solution: AwsContextSolution; protected _context?: AwsContext; - constructor(protected _version: V1, payload: AwsResource, sid?: string) { + constructor( + protected _version: V1, + payload: AwsResource, + sid?: string, + ) { this.accountSid = payload.account_sid; this.sid = payload.sid; this.testString = payload.test_string; @@ -286,7 +293,7 @@ export class AwsInstance { * @returns Resolves to processed boolean */ remove( - callback?: (error: Error | null, item?: boolean) => any + callback?: (error: Error | null, item?: boolean) => any, ): Promise { return this._proxy.remove(callback); } @@ -299,7 +306,7 @@ export class AwsInstance { * @returns Resolves to processed AwsInstance */ fetch( - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise { return this._proxy.fetch(callback); } @@ -312,7 +319,7 @@ export class AwsInstance { * @returns Resolves to processed AwsInstance */ update( - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise; /** * Update a AwsInstance @@ -324,12 +331,12 @@ export class AwsInstance { */ update( params: AwsContextUpdateOptions, - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise; update( params?: any, - callback?: (error: Error | null, item?: AwsInstance) => any + callback?: (error: Error | null, item?: AwsInstance) => any, ): Promise { return this._proxy.update(params, callback); } @@ -386,11 +393,11 @@ export interface AwsListInstance { * @param { function } [callback] - Function to process each record */ each( - callback?: (item: AwsInstance, done: (err?: Error) => void) => void + callback?: (item: AwsInstance, done: (err?: Error) => void) => void, ): void; each( params: AwsListInstanceEachOptions, - callback?: (item: AwsInstance, done: (err?: Error) => void) => void + callback?: (item: AwsInstance, done: (err?: Error) => void) => void, ): void; /** * Retrieve a single target page of AwsInstance records from the API. @@ -402,7 +409,7 @@ export interface AwsListInstance { */ getPage( targetUrl: string, - callback?: (error: Error | null, items: AwsPage) => any + callback?: (error: Error | null, items: AwsPage) => any, ): Promise; /** * Lists AwsInstance records from the API as a list. @@ -414,11 +421,11 @@ export interface AwsListInstance { * @param { function } [callback] - Callback to handle list of records */ list( - callback?: (error: Error | null, items: AwsInstance[]) => any + callback?: (error: Error | null, items: AwsInstance[]) => any, ): Promise; list( params: AwsListInstanceOptions, - callback?: (error: Error | null, items: AwsInstance[]) => any + callback?: (error: Error | null, items: AwsInstance[]) => any, ): Promise; /** * Retrieve a single page of AwsInstance records from the API. @@ -432,11 +439,11 @@ export interface AwsListInstance { * @param { function } [callback] - Callback to handle list of records */ page( - callback?: (error: Error | null, items: AwsPage) => any + callback?: (error: Error | null, items: AwsPage) => any, ): Promise; page( params: AwsListInstancePageOptions, - callback?: (error: Error | null, items: AwsPage) => any + callback?: (error: Error | null, items: AwsPage) => any, ): Promise; /** @@ -461,7 +468,7 @@ export function AwsListInstance(version: V1): AwsListInstance { params?: | AwsListInstancePageOptions | ((error: Error | null, items: AwsPage) => any), - callback?: (error: Error | null, items: AwsPage) => any + callback?: (error: Error | null, items: AwsPage) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -488,12 +495,12 @@ export function AwsListInstance(version: V1): AwsListInstance { }); operationPromise = operationPromise.then( - (payload) => new AwsPage(operationVersion, payload, instance._solution) + (payload) => new AwsPage(operationVersion, payload, instance._solution), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -502,7 +509,7 @@ export function AwsListInstance(version: V1): AwsListInstance { instance.getPage = function getPage( targetUrl: string, - callback?: (error: Error | null, items: AwsPage) => any + callback?: (error: Error | null, items: AwsPage) => any, ): Promise { const operationPromise = instance._version._domain.twilio.request({ method: "get", @@ -510,7 +517,7 @@ export function AwsListInstance(version: V1): AwsListInstance { }); let pagePromise = operationPromise.then( - (payload) => new AwsPage(instance._version, payload, instance._solution) + (payload) => new AwsPage(instance._version, payload, instance._solution), ); pagePromise = instance._version.setPromiseCallback(pagePromise, callback); return pagePromise; @@ -522,7 +529,7 @@ export function AwsListInstance(version: V1): AwsListInstance { instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/flexApi/v1/credential/aws/history.ts b/examples/node/src/rest/flexApi/v1/credential/aws/history.ts index e6caf2e86..5905ba494 100644 --- a/examples/node/src/rest/flexApi/v1/credential/aws/history.ts +++ b/examples/node/src/rest/flexApi/v1/credential/aws/history.ts @@ -35,7 +35,7 @@ export interface HistoryContext { * @returns Resolves to processed HistoryInstance */ fetch( - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise; /** * Fetch a HistoryInstance @@ -47,7 +47,7 @@ export interface HistoryContext { */ fetch( params: HistoryContextFetchOptions, - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise; /** @@ -65,7 +65,10 @@ export class HistoryContextImpl implements HistoryContext { protected _solution: HistoryContextSolution; protected _uri: string; - constructor(protected _version: V1, sid: string) { + constructor( + protected _version: V1, + sid: string, + ) { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); } @@ -78,7 +81,7 @@ export class HistoryContextImpl implements HistoryContext { params?: | HistoryContextFetchOptions | ((error: Error | null, item?: HistoryInstance) => any), - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -108,12 +111,12 @@ export class HistoryContextImpl implements HistoryContext { operationPromise = operationPromise.then( (payload) => - new HistoryInstance(operationVersion, payload, instance._solution.sid) + new HistoryInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -145,7 +148,11 @@ export class HistoryInstance { protected _solution: HistoryContextSolution; protected _context?: HistoryContext; - constructor(protected _version: V1, payload: HistoryResource, sid: string) { + constructor( + protected _version: V1, + payload: HistoryResource, + sid: string, + ) { this.accountSid = payload.account_sid; this.sid = payload.sid; this.testString = payload.test_string; @@ -174,7 +181,7 @@ export class HistoryInstance { * @returns Resolves to processed HistoryInstance */ fetch( - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise; /** * Fetch a HistoryInstance @@ -186,12 +193,12 @@ export class HistoryInstance { */ fetch( params: HistoryContextFetchOptions, - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise; fetch( params?: any, - callback?: (error: Error | null, item?: HistoryInstance) => any + callback?: (error: Error | null, item?: HistoryInstance) => any, ): Promise { return this._proxy.fetch(params, callback); } @@ -236,7 +243,7 @@ export interface HistoryListInstance { export function HistoryListInstance( version: V1, - sid: string + sid: string, ): HistoryListInstance { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); @@ -258,7 +265,7 @@ export function HistoryListInstance( instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/flexApi/v1/credential/newCredentials.ts b/examples/node/src/rest/flexApi/v1/credential/newCredentials.ts index 179992879..0c662fd68 100644 --- a/examples/node/src/rest/flexApi/v1/credential/newCredentials.ts +++ b/examples/node/src/rest/flexApi/v1/credential/newCredentials.ts @@ -83,7 +83,7 @@ export interface NewCredentialsListInstance { */ create( params: NewCredentialsListInstanceCreateOptions, - callback?: (error: Error | null, item?: NewCredentialsInstance) => any + callback?: (error: Error | null, item?: NewCredentialsInstance) => any, ): Promise; /** @@ -94,7 +94,7 @@ export interface NewCredentialsListInstance { } export function NewCredentialsListInstance( - version: V1 + version: V1, ): NewCredentialsListInstance { const instance = {} as NewCredentialsListInstance; @@ -104,7 +104,7 @@ export function NewCredentialsListInstance( instance.create = function create( params: NewCredentialsListInstanceCreateOptions, - callback?: (error: Error | null, items: NewCredentialsInstance) => any + callback?: (error: Error | null, items: NewCredentialsInstance) => any, ): Promise { if (params === null || params === undefined) { throw new Error('Required parameter "params" missing.'); @@ -141,18 +141,18 @@ export function NewCredentialsListInstance( if (params["testObjectArray"] !== undefined) data["TestObjectArray"] = serialize.map( params["testObjectArray"], - (e: object) => e + (e: object) => e, ); if (params["testAnyType"] !== undefined) data["TestAnyType"] = serialize.object(params["testAnyType"]); if (params["testAnyArray"] !== undefined) data["TestAnyArray"] = serialize.map(params["testAnyArray"], (e: any) => - serialize.object(e) + serialize.object(e), ); if (params["permissions"] !== undefined) data["Permissions"] = serialize.map( params["permissions"], - (e: string) => e + (e: string) => e, ); if (params["someA2PThing"] !== undefined) data["SomeA2PThing"] = params["someA2PThing"]; @@ -169,12 +169,12 @@ export function NewCredentialsListInstance( }); operationPromise = operationPromise.then( - (payload) => new NewCredentialsInstance(operationVersion, payload) + (payload) => new NewCredentialsInstance(operationVersion, payload), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -185,7 +185,7 @@ export function NewCredentialsListInstance( instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; @@ -203,7 +203,10 @@ interface NewCredentialsResource { } export class NewCredentialsInstance { - constructor(protected _version: V1, payload: NewCredentialsResource) { + constructor( + protected _version: V1, + payload: NewCredentialsResource, + ) { this.accountSid = payload.account_sid; this.sid = payload.sid; this.testString = payload.test_string; diff --git a/examples/node/src/rest/versionless/deployed_devices/fleet.ts b/examples/node/src/rest/versionless/deployed_devices/fleet.ts index 209d81dcd..637f88887 100644 --- a/examples/node/src/rest/versionless/deployed_devices/fleet.ts +++ b/examples/node/src/rest/versionless/deployed_devices/fleet.ts @@ -35,7 +35,7 @@ export interface FleetContext { * @returns Resolves to processed FleetInstance */ fetch( - callback?: (error: Error | null, item?: FleetInstance) => any + callback?: (error: Error | null, item?: FleetInstance) => any, ): Promise; /** @@ -53,7 +53,10 @@ export class FleetContextImpl implements FleetContext { protected _solution: FleetContextSolution; protected _uri: string; - constructor(protected _version: DeployedDevices, sid: string) { + constructor( + protected _version: DeployedDevices, + sid: string, + ) { if (!isValidPathParam(sid)) { throw new Error("Parameter 'sid' is not valid."); } @@ -63,7 +66,7 @@ export class FleetContextImpl implements FleetContext { } fetch( - callback?: (error: Error | null, item?: FleetInstance) => any + callback?: (error: Error | null, item?: FleetInstance) => any, ): Promise { const instance = this; let operationVersion = instance._version, @@ -74,12 +77,12 @@ export class FleetContextImpl implements FleetContext { operationPromise = operationPromise.then( (payload) => - new FleetInstance(operationVersion, payload, instance._solution.sid) + new FleetInstance(operationVersion, payload, instance._solution.sid), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; } @@ -113,7 +116,7 @@ export class FleetInstance { constructor( protected _version: DeployedDevices, payload: FleetResource, - sid?: string + sid?: string, ) { this.name = payload.name; this.sid = payload.sid; @@ -146,7 +149,7 @@ export class FleetInstance { * @returns Resolves to processed FleetInstance */ fetch( - callback?: (error: Error | null, item?: FleetInstance) => any + callback?: (error: Error | null, item?: FleetInstance) => any, ): Promise { return this._proxy.fetch(callback); } @@ -187,7 +190,7 @@ export interface FleetListInstance { * @returns Resolves to processed FleetInstance */ create( - callback?: (error: Error | null, item?: FleetInstance) => any + callback?: (error: Error | null, item?: FleetInstance) => any, ): Promise; /** * Create a FleetInstance @@ -199,7 +202,7 @@ export interface FleetListInstance { */ create( params: FleetListInstanceCreateOptions, - callback?: (error: Error | null, item?: FleetInstance) => any + callback?: (error: Error | null, item?: FleetInstance) => any, ): Promise; /** @@ -224,7 +227,7 @@ export function FleetListInstance(version: DeployedDevices): FleetListInstance { params?: | FleetListInstanceCreateOptions | ((error: Error | null, items: FleetInstance) => any), - callback?: (error: Error | null, items: FleetInstance) => any + callback?: (error: Error | null, items: FleetInstance) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -249,12 +252,12 @@ export function FleetListInstance(version: DeployedDevices): FleetListInstance { }); operationPromise = operationPromise.then( - (payload) => new FleetInstance(operationVersion, payload) + (payload) => new FleetInstance(operationVersion, payload), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -265,7 +268,7 @@ export function FleetListInstance(version: DeployedDevices): FleetListInstance { instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; diff --git a/examples/node/src/rest/versionless/understand/assistant.ts b/examples/node/src/rest/versionless/understand/assistant.ts index 930e247fe..45da858c5 100644 --- a/examples/node/src/rest/versionless/understand/assistant.ts +++ b/examples/node/src/rest/versionless/understand/assistant.ts @@ -79,11 +79,11 @@ export interface AssistantListInstance { * @param { function } [callback] - Function to process each record */ each( - callback?: (item: AssistantInstance, done: (err?: Error) => void) => void + callback?: (item: AssistantInstance, done: (err?: Error) => void) => void, ): void; each( params: AssistantListInstanceEachOptions, - callback?: (item: AssistantInstance, done: (err?: Error) => void) => void + callback?: (item: AssistantInstance, done: (err?: Error) => void) => void, ): void; /** * Retrieve a single target page of AssistantInstance records from the API. @@ -95,7 +95,7 @@ export interface AssistantListInstance { */ getPage( targetUrl: string, - callback?: (error: Error | null, items: AssistantPage) => any + callback?: (error: Error | null, items: AssistantPage) => any, ): Promise; /** * Lists AssistantInstance records from the API as a list. @@ -107,11 +107,11 @@ export interface AssistantListInstance { * @param { function } [callback] - Callback to handle list of records */ list( - callback?: (error: Error | null, items: AssistantInstance[]) => any + callback?: (error: Error | null, items: AssistantInstance[]) => any, ): Promise; list( params: AssistantListInstanceOptions, - callback?: (error: Error | null, items: AssistantInstance[]) => any + callback?: (error: Error | null, items: AssistantInstance[]) => any, ): Promise; /** * Retrieve a single page of AssistantInstance records from the API. @@ -125,11 +125,11 @@ export interface AssistantListInstance { * @param { function } [callback] - Callback to handle list of records */ page( - callback?: (error: Error | null, items: AssistantPage) => any + callback?: (error: Error | null, items: AssistantPage) => any, ): Promise; page( params: AssistantListInstancePageOptions, - callback?: (error: Error | null, items: AssistantPage) => any + callback?: (error: Error | null, items: AssistantPage) => any, ): Promise; /** @@ -140,7 +140,7 @@ export interface AssistantListInstance { } export function AssistantListInstance( - version: Understand + version: Understand, ): AssistantListInstance { const instance = {} as AssistantListInstance; @@ -152,7 +152,7 @@ export function AssistantListInstance( params?: | AssistantListInstancePageOptions | ((error: Error | null, items: AssistantPage) => any), - callback?: (error: Error | null, items: AssistantPage) => any + callback?: (error: Error | null, items: AssistantPage) => any, ): Promise { if (params instanceof Function) { callback = params; @@ -180,12 +180,12 @@ export function AssistantListInstance( operationPromise = operationPromise.then( (payload) => - new AssistantPage(operationVersion, payload, instance._solution) + new AssistantPage(operationVersion, payload, instance._solution), ); operationPromise = instance._version.setPromiseCallback( operationPromise, - callback + callback, ); return operationPromise; }; @@ -194,7 +194,7 @@ export function AssistantListInstance( instance.getPage = function getPage( targetUrl: string, - callback?: (error: Error | null, items: AssistantPage) => any + callback?: (error: Error | null, items: AssistantPage) => any, ): Promise { const operationPromise = instance._version._domain.twilio.request({ method: "get", @@ -203,7 +203,7 @@ export function AssistantListInstance( let pagePromise = operationPromise.then( (payload) => - new AssistantPage(instance._version, payload, instance._solution) + new AssistantPage(instance._version, payload, instance._solution), ); pagePromise = instance._version.setPromiseCallback(pagePromise, callback); return pagePromise; @@ -215,7 +215,7 @@ export function AssistantListInstance( instance[inspect.custom] = function inspectImpl( _depth: any, - options: InspectOptions + options: InspectOptions, ) { return inspect(instance.toJSON(), options); }; @@ -233,7 +233,10 @@ interface AssistantResource { } export class AssistantInstance { - constructor(protected _version: Understand, payload: AssistantResource) { + constructor( + protected _version: Understand, + payload: AssistantResource, + ) { this.sid = payload.sid; this.friendlyName = payload.friendly_name; } @@ -280,7 +283,7 @@ export class AssistantPage extends Page< constructor( version: Understand, response: Response, - solution: AssistantSolution + solution: AssistantSolution, ) { super(version, response, solution); } diff --git a/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb index 4c3bc4b98..b17766770 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010.rb @@ -13,51 +13,55 @@ # 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 - end + module REST + class Api + class V2010 < Version + ## + # Initialize the V2010 version of Api + def initialize(domain) + super + @version = '2010-04-01' + @accounts = nil + end + + ## + # Account provided as the authenticating account + def account + @account ||= AccountContext.new(self, @domain.client.account_sid) + end + + ## + # Setter to override the primary account + def account=(value) + @account = value + end - ## - # Account provided as the authenticating account - def account - @account ||= AccountContext.new(self, @domain.client.account_sid) - end + def calls(test_integer = :unset) + self.account.calls(test_integer) + 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 - ## - # Setter to override the primary account - def account=(value) - @account = value - end - def calls(test_integer =:unset) - self.account.calls(test_integer) - 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 - ## - # Provide a user friendly representation - def to_s - ''; - end - 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.rb b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb index 878c9e48f..011e1c849 100644 --- a/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb +++ b/examples/ruby/lib/twilio-ruby/rest/api/v2010/account.rb @@ -12,499 +12,497 @@ # Do not edit the class manually. # - module Twilio - module REST - class Api < ApiBase - 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] recording_status_callback - # @param [Array[String]] recording_status_callback_event - # @param [String] twiml - # @param [String] x_twilio_webhook_enabled - # @return [AccountInstance] Created AccountInstance - def create( - recording_status_callback: :unset, - recording_status_callback_event: :unset, - twiml: :unset, - x_twilio_webhook_enabled: :unset - ) - - data = Twilio::Values.of({ - 'RecordingStatusCallback' => recording_status_callback, - 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| e }, - 'Twiml' => twiml, - }) - - headers = Twilio::Values.of({ 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) - payload = @version.create('POST', @uri, data: data, headers: headers) - 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, + module REST + class Api < ApiBase + 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] recording_status_callback + # @param [Array[String]] recording_status_callback_event + # @param [String] twiml + # @param [String] x_twilio_webhook_enabled + # @return [AccountInstance] Created AccountInstance + def create( + recording_status_callback: :unset, + recording_status_callback_event: :unset, + twiml: :unset, + x_twilio_webhook_enabled: :unset + ) + + data = Twilio::Values.of({ + 'RecordingStatusCallback' => recording_status_callback, + 'RecordingStatusCallbackEvent' => Twilio.serialize_list(recording_status_callback_event) { |e| + e + }, + 'Twiml' => twiml, + }) + + headers = Twilio::Values.of({ 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) + payload = @version.create('POST', @uri, data: data, headers: headers) + 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 - '#' - end - end - - - class AccountContext < InstanceContext - ## - # Initialize the AccountContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [AccountContext] AccountContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Accounts/#{@solution[:sid]}.json" - - # Dependents - @calls = nil - end - ## - # Delete the AccountInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - @version.delete('DELETE', @uri) - end - - ## - # Fetch the AccountInstance - # @return [AccountInstance] Fetched AccountInstance - def fetch - - payload = @version.fetch('GET', @uri) - AccountInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Update the AccountInstance - # @param [String] pause_behavior - # @param [Status] status - # @return [AccountInstance] Updated AccountInstance - def update( - pause_behavior: :unset, - status: nil - ) - - data = Twilio::Values.of({ - 'Status' => status, - 'PauseBehavior' => pause_behavior, - }) - - payload = @version.update('POST', @uri, data: data) - AccountInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Access the calls - # @return [CallList] - # @return [CallContext] if sid was passed. - def calls(test_integer=:unset) - - raise ArgumentError, 'test_integer cannot be nil' if test_integer.nil? - - if test_integer != :unset - return CallContext.new(@version, @solution[:sid],test_integer ) - end - - unless @calls - @calls = CallList.new( - @version, ) - end - - @calls - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - class AccountInstance < InstanceResource - ## - # Initialize the AccountInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Account - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AccountInstance] AccountInstance - def initialize(version, payload , sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [AccountContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = AccountContext.new(@version , @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Delete the AccountInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - context.delete - end - - ## - # Fetch the AccountInstance - # @return [AccountInstance] Fetched AccountInstance - def fetch - - context.fetch - end - - ## - # Update the AccountInstance - # @param [String] pause_behavior - # @param [Status] status - # @return [AccountInstance] Updated AccountInstance - def update( - pause_behavior: :unset, - status: nil - ) - - context.update( - pause_behavior: pause_behavior, - status: status, - ) - end - - ## - # Access the calls - # @return [calls] calls - def calls - context.calls - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - end + 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 + '#' + end + end + + class AccountContext < InstanceContext + ## + # Initialize the AccountContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [AccountContext] AccountContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Accounts/#{@solution[:sid]}.json" + + # Dependents + @calls = nil + end + + ## + # Delete the AccountInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + @version.delete('DELETE', @uri) + end + + ## + # Fetch the AccountInstance + # @return [AccountInstance] Fetched AccountInstance + def fetch + payload = @version.fetch('GET', @uri) + AccountInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Update the AccountInstance + # @param [String] pause_behavior + # @param [Status] status + # @return [AccountInstance] Updated AccountInstance + def update( + pause_behavior: :unset, + status: nil + ) + + data = Twilio::Values.of({ + 'Status' => status, + 'PauseBehavior' => pause_behavior, + }) + + payload = @version.update('POST', @uri, data: data) + AccountInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Access the calls + # @return [CallList] + # @return [CallContext] if sid was passed. + def calls(test_integer = :unset) + raise ArgumentError, 'test_integer cannot be nil' if test_integer.nil? + + if test_integer != :unset + return CallContext.new(@version, @solution[:sid], test_integer) + end + + unless @calls + @calls = CallList.new( + @version, + ) + end + + @calls + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + class AccountInstance < InstanceResource + ## + # Initialize the AccountInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Account + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AccountInstance] AccountInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AccountContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = AccountContext.new(@version, @params['sid']) end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] + end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Delete the AccountInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + context.delete + end + + ## + # Fetch the AccountInstance + # @return [AccountInstance] Fetched AccountInstance + def fetch + context.fetch + end + + ## + # Update the AccountInstance + # @param [String] pause_behavior + # @param [Status] status + # @return [AccountInstance] Updated AccountInstance + def update( + pause_behavior: :unset, + status: nil + ) + + context.update( + pause_behavior: pause_behavior, + status: status, + ) + end + + ## + # Access the calls + # @return [calls] calls + def calls + context.calls + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end 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 9d5fadba8..3c205d7df 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 @@ -12,368 +12,365 @@ # Do not edit the class manually. # - module Twilio - module REST - class Api < ApiBase - class V2010 < Version - class AccountContext < InstanceContext - - class CallList < ListResource - ## - # Initialize the CallList - # @param [Version] version Version that contains the resource - # @return [CallList] CallList - def initialize(version, account_sid: nil) - super(version) - # Path Solution - @solution = { account_sid: account_sid } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json" - # Components - @feedback_call_summary = nil - end - ## - # Create the CallInstance - # @param [String] required_string_property - # @param [Array[String]] test_array_of_strings - # @param [Array[String]] test_array_of_uri - # @param [String] test_method The HTTP method that we should use to request the `TestArrayOfUri`. - # @return [CallInstance] Created CallInstance - def create( - required_string_property: nil, - test_array_of_strings: :unset, - test_array_of_uri: :unset, - test_method: nil - ) - - 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 - - - - ## - # Access the feedback_call_summary - # @return [FeedbackCallSummaryList] - # @return [FeedbackCallSummaryContext] - def feedback_call_summary - @feedback_call_summary ||= FeedbackCallSummaryList.new(@version, account_sid: @solution[:account_sid] ) - end - - # Provide a user friendly representation - def to_s - '#' - end - end - - - class CallContext < InstanceContext - ## - # Initialize the CallContext - # @param [Version] version Version that contains the resource - # @param [String] account_sid - # @param [String] test_integer INTEGER ID param!!! - # @return [CallContext] CallContext - def initialize(version, account_sid, test_integer) - super(version) - - # Path Solution - @solution = { account_sid: account_sid, test_integer: test_integer, } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:test_integer]}.json" - - # Dependents - @feedback_call_summary = nil - end - ## - # Delete the CallInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - @version.delete('DELETE', @uri) - end - - ## - # Fetch the CallInstance - # @return [CallInstance] Fetched CallInstance - def fetch - - payload = @version.fetch('GET', @uri) - CallInstance.new( - @version, - payload, - account_sid: @solution[:account_sid], - test_integer: @solution[:test_integer], - ) - end - - ## - # Access the feedback_call_summary - # @return [FeedbackCallSummaryList] - # @return [FeedbackCallSummaryContext] if sid was passed. - def feedback_call_summary(sid=:unset) - - raise ArgumentError, 'sid cannot be nil' if sid.nil? - - if sid != :unset - return FeedbackCallSummaryContext.new(@version, @solution[:account_sid], @solution[:test_integer],sid ) - end - - unless @feedback_call_summary - @feedback_call_summary = FeedbackCallSummaryList.new( - @version, ) - end - - @feedback_call_summary - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - class CallInstance < InstanceResource - ## - # Initialize the CallInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CallInstance] CallInstance - def initialize(version, payload , account_sid: nil, test_integer: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'account_sid' => account_sid ,'test_integer' => test_integer || @properties['test_integer'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [CallContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = CallContext.new(@version , @params['account_sid'], @params['test_integer']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Delete the CallInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - context.delete - end - - ## - # Fetch the CallInstance - # @return [CallInstance] Fetched CallInstance - def fetch - - context.fetch - end - - ## - # Access the feedback_call_summary - # @return [feedback_call_summary] feedback_call_summary - def feedback_call_summary - context.feedback_call_summary - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - end - - end + module REST + class Api < ApiBase + class V2010 < Version + class AccountContext < InstanceContext + class CallList < ListResource + ## + # Initialize the CallList + # @param [Version] version Version that contains the resource + # @return [CallList] CallList + def initialize(version, account_sid: nil) + super(version) + # Path Solution + @solution = { account_sid: account_sid } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls.json" + # Components + @feedback_call_summary = nil + end + + ## + # Create the CallInstance + # @param [String] required_string_property + # @param [Array[String]] test_array_of_strings + # @param [Array[String]] test_array_of_uri + # @param [String] test_method The HTTP method that we should use to request the `TestArrayOfUri`. + # @return [CallInstance] Created CallInstance + def create( + required_string_property: nil, + test_array_of_strings: :unset, + test_array_of_uri: :unset, + test_method: nil + ) + + 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 + + ## + # Access the feedback_call_summary + # @return [FeedbackCallSummaryList] + # @return [FeedbackCallSummaryContext] + def feedback_call_summary + @feedback_call_summary ||= FeedbackCallSummaryList.new(@version, + account_sid: @solution[:account_sid]) + end + + # Provide a user friendly representation + def to_s + '#' + end + end + + class CallContext < InstanceContext + ## + # Initialize the CallContext + # @param [Version] version Version that contains the resource + # @param [String] account_sid + # @param [String] test_integer INTEGER ID param!!! + # @return [CallContext] CallContext + def initialize(version, account_sid, test_integer) + super(version) + + # Path Solution + @solution = { account_sid: account_sid, test_integer: test_integer, } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/#{@solution[:test_integer]}.json" + + # Dependents + @feedback_call_summary = nil + end + + ## + # Delete the CallInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + @version.delete('DELETE', @uri) + end + + ## + # Fetch the CallInstance + # @return [CallInstance] Fetched CallInstance + def fetch + payload = @version.fetch('GET', @uri) + CallInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + test_integer: @solution[:test_integer], + ) + end + + ## + # Access the feedback_call_summary + # @return [FeedbackCallSummaryList] + # @return [FeedbackCallSummaryContext] if sid was passed. + def feedback_call_summary(sid = :unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? + + if sid != :unset + return FeedbackCallSummaryContext.new(@version, @solution[:account_sid], + @solution[:test_integer], sid) + end + + unless @feedback_call_summary + @feedback_call_summary = FeedbackCallSummaryList.new( + @version, + ) + end + + @feedback_call_summary + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + + class CallInstance < InstanceResource + ## + # Initialize the CallInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CallInstance] CallInstance + def initialize(version, payload, account_sid: nil, test_integer: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'account_sid' => account_sid, + 'test_integer' => test_integer || @properties['test_integer'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [CallContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = CallContext.new(@version, @params['account_sid'], + @params['test_integer']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Delete the CallInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + context.delete + end + + ## + # Fetch the CallInstance + # @return [CallInstance] Fetched CallInstance + def fetch + context.fetch + end + + ## + # Access the feedback_call_summary + # @return [feedback_call_summary] feedback_call_summary + def feedback_call_summary + context.feedback_call_summary + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + end 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 8cf75d0cb..d650d54ab 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 @@ -12,314 +12,304 @@ # Do not edit the class manually. # - module Twilio - module REST - class Api < ApiBase - class V2010 < Version - class AccountContext < InstanceContext - class CallContext < InstanceContext - - class FeedbackCallSummaryList < ListResource - ## - # Initialize the FeedbackCallSummaryList - # @param [Version] version Version that contains the resource - # @return [FeedbackCallSummaryList] FeedbackCallSummaryList - def initialize(version, account_sid: nil) - super(version) - # Path Solution - @solution = { account_sid: account_sid } - - - end - - - - # Provide a user friendly representation - def to_s - '#' - end - end + module REST + class Api < ApiBase + class V2010 < Version + class AccountContext < InstanceContext + class CallContext < InstanceContext + class FeedbackCallSummaryList < ListResource + ## + # Initialize the FeedbackCallSummaryList + # @param [Version] version Version that contains the resource + # @return [FeedbackCallSummaryList] FeedbackCallSummaryList + def initialize(version, account_sid: nil) + super(version) + # Path Solution + @solution = { account_sid: account_sid } + end + + # Provide a user friendly representation + def to_s + '#' + end + end + class FeedbackCallSummaryContext < InstanceContext + ## + # Initialize the FeedbackCallSummaryContext + # @param [Version] version Version that contains the resource + # @param [String] account_sid + # @param [String] sid + # @return [FeedbackCallSummaryContext] FeedbackCallSummaryContext + def initialize(version, account_sid, sid) + super(version) - class FeedbackCallSummaryContext < InstanceContext - ## - # Initialize the FeedbackCallSummaryContext - # @param [Version] version Version that contains the resource - # @param [String] account_sid - # @param [String] sid - # @return [FeedbackCallSummaryContext] FeedbackCallSummaryContext - def initialize(version, account_sid, sid) - super(version) - - # Path Solution - @solution = { account_sid: account_sid, sid: sid, } - @uri = "/Accounts/#{@solution[:account_sid]}/Calls/Feedback/Summary/#{@solution[:sid]}.json" - - - end - ## - # Update the FeedbackCallSummaryInstance - # @param [String] account_sid - # @param [Date] end_date - # @param [Date] start_date - # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance - def update( - account_sid: :unset, - end_date: nil, - start_date: nil - ) - - data = Twilio::Values.of({ - 'EndDate' => Twilio.serialize_iso8601_date(end_date), - 'StartDate' => Twilio.serialize_iso8601_date(start_date), - 'AccountSid' => account_sid, - }) - - payload = @version.update('POST', @uri, data: data) - FeedbackCallSummaryInstance.new( - @version, - payload, - account_sid: @solution[:account_sid], - sid: @solution[:sid], - ) - end - - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - end + # Path Solution + @solution = { account_sid: account_sid, sid: sid, } + @uri = "/Accounts/#{@solution[:account_sid]}/Calls/Feedback/Summary/#{@solution[:sid]}.json" + 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 - class FeedbackCallSummaryInstance < InstanceResource - ## - # Initialize the FeedbackCallSummaryInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this FeedbackCallSummary - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [FeedbackCallSummaryInstance] FeedbackCallSummaryInstance - def initialize(version, payload , account_sid: nil, sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - 'test_object' => payload['test_object'], - 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), - 'test_number' => payload['test_number'], - 'from' => payload['from'], - 'price_unit' => payload['price_unit'], - 'test_number_float' => payload['test_number_float'], - 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, - 'test_enum' => payload['test_enum'], - 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], - 'test_array_of_integers' => payload['test_array_of_integers'], - 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], - 'test_array_of_objects' => payload['test_array_of_objects'], - 'test_array_of_enum' => payload['test_array_of_enum'], - } - - # Context - @instance_context = nil - @params = { 'account_sid' => account_sid ,'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [FeedbackCallSummaryContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = FeedbackCallSummaryContext.new(@version , @params['account_sid'], @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # @return [TestResponseObjectTestObject] - def test_object - @properties['test_object'] - end - - ## - # @return [Time] - def test_date_time - @properties['test_date_time'] - end - - ## - # @return [Float] - def test_number - @properties['test_number'] - end - - ## - # @return [String] - def from - @properties['from'] - end - - ## - # @return [String] - def price_unit - @properties['price_unit'] - end - - ## - # @return [Float] - def test_number_float - @properties['test_number_float'] - end - - ## - # @return [Float] - def test_number_decimal - @properties['test_number_decimal'] - end - - ## - # @return [Status] - def test_enum - @properties['test_enum'] - end - - ## - # @return [String] A2P Messaging Profile Bundle BundleSid - def a2p_profile_bundle_sid - @properties['a2p_profile_bundle_sid'] - end - - ## - # @return [Array] - def test_array_of_integers - @properties['test_array_of_integers'] - end - - ## - # @return [Array>] - def test_array_of_array_of_integers - @properties['test_array_of_array_of_integers'] - end - - ## - # @return [Array] - def test_array_of_objects - @properties['test_array_of_objects'] - end - - ## - # @return [Array] Permissions authorized to the app - def test_array_of_enum - @properties['test_array_of_enum'] - end - - ## - # Update the FeedbackCallSummaryInstance - # @param [String] account_sid - # @param [Date] end_date - # @param [Date] start_date - # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance - def update( - account_sid: :unset, - end_date: nil, - start_date: nil - ) - - context.update( - account_sid: account_sid, - end_date: end_date, - start_date: start_date, - ) - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end + ## + # Update the FeedbackCallSummaryInstance + # @param [String] account_sid + # @param [Date] end_date + # @param [Date] start_date + # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance + def update( + account_sid: :unset, + end_date: nil, + start_date: nil + ) + + data = Twilio::Values.of({ + 'EndDate' => Twilio.serialize_iso8601_date(end_date), + 'StartDate' => Twilio.serialize_iso8601_date(start_date), + 'AccountSid' => account_sid, + }) + + payload = @version.update('POST', @uri, data: data) + FeedbackCallSummaryInstance.new( + @version, + payload, + account_sid: @solution[:account_sid], + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + + class FeedbackCallSummaryInstance < InstanceResource + ## + # Initialize the FeedbackCallSummaryInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this FeedbackCallSummary + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [FeedbackCallSummaryInstance] FeedbackCallSummaryInstance + def initialize(version, payload, account_sid: nil, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + 'test_object' => payload['test_object'], + 'test_date_time' => Twilio.deserialize_rfc2822(payload['test_date_time']), + 'test_number' => payload['test_number'], + 'from' => payload['from'], + 'price_unit' => payload['price_unit'], + 'test_number_float' => payload['test_number_float'], + 'test_number_decimal' => payload['test_number_decimal'] == nil ? payload['test_number_decimal'] : payload['test_number_decimal'].to_f, + 'test_enum' => payload['test_enum'], + 'a2p_profile_bundle_sid' => payload['a2p_profile_bundle_sid'], + 'test_array_of_integers' => payload['test_array_of_integers'], + 'test_array_of_array_of_integers' => payload['test_array_of_array_of_integers'], + 'test_array_of_objects' => payload['test_array_of_objects'], + 'test_array_of_enum' => payload['test_array_of_enum'], + } + + # Context + @instance_context = nil + @params = { 'account_sid' => account_sid, 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [FeedbackCallSummaryContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = FeedbackCallSummaryContext.new(@version, @params['account_sid'], + @params['sid']) end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end - end - end + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # @return [TestResponseObjectTestObject] + def test_object + @properties['test_object'] + end + + ## + # @return [Time] + def test_date_time + @properties['test_date_time'] + end + + ## + # @return [Float] + def test_number + @properties['test_number'] + end + + ## + # @return [String] + def from + @properties['from'] + end + + ## + # @return [String] + def price_unit + @properties['price_unit'] + end + + ## + # @return [Float] + def test_number_float + @properties['test_number_float'] + end + + ## + # @return [Float] + def test_number_decimal + @properties['test_number_decimal'] + end + + ## + # @return [Status] + def test_enum + @properties['test_enum'] + end + + ## + # @return [String] A2P Messaging Profile Bundle BundleSid + def a2p_profile_bundle_sid + @properties['a2p_profile_bundle_sid'] + end + + ## + # @return [Array] + def test_array_of_integers + @properties['test_array_of_integers'] + end + + ## + # @return [Array>] + def test_array_of_array_of_integers + @properties['test_array_of_array_of_integers'] + end + + ## + # @return [Array] + def test_array_of_objects + @properties['test_array_of_objects'] + end + + ## + # @return [Array] Permissions authorized to the app + def test_array_of_enum + @properties['test_array_of_enum'] + end + + ## + # Update the FeedbackCallSummaryInstance + # @param [String] account_sid + # @param [Date] end_date + # @param [Date] start_date + # @return [FeedbackCallSummaryInstance] Updated FeedbackCallSummaryInstance + def update( + account_sid: :unset, + end_date: nil, + start_date: nil + ) + + context.update( + account_sid: account_sid, + end_date: end_date, + start_date: start_date, + ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end end + end end + end end + end end - - diff --git a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb index f615eccbc..7bd18e916 100644 --- a/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb +++ b/examples/ruby/lib/twilio-ruby/rest/flex_api/v1.rb @@ -13,43 +13,46 @@ # module Twilio - module REST - class FlexApi - class V1 < Version - ## - # Initialize the V1 version of FlexApi - def initialize(domain) - super - @version = 'v1' - @calls = nil - @credentials = nil - end + module REST + class FlexApi + class V1 < Version + ## + # Initialize the V1 version of FlexApi + def initialize(domain) + super + @version = 'v1' + @calls = nil + @credentials = nil + end + + ## + # @param [String] sid + # @return [Twilio::REST::FlexApi::V1::CallContext] if sid was passed. + # @return [Twilio::REST::FlexApi::V1::CallList] + def calls(sid = :unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + + if sid == :unset + @calls ||= CallList.new self + else + CallContext.new(self, sid) + end + end + + ## + # @return [Twilio::REST::FlexApi::V1::CredentialList] + def credentials + @credentials ||= CredentialList.new self + end - ## - # @param [String] sid - # @return [Twilio::REST::FlexApi::V1::CallContext] if sid was passed. - # @return [Twilio::REST::FlexApi::V1::CallList] - def calls(sid=:unset) - if sid.nil? - raise ArgumentError, 'sid cannot be nil' - end - if sid == :unset - @calls ||= CallList.new self - else - CallContext.new(self, sid) - end - end - ## - # @return [Twilio::REST::FlexApi::V1::CredentialList] - def credentials - @credentials ||= CredentialList.new self - end - ## - # Provide a user friendly representation - def to_s - ''; - end - 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 46034f99b..f5bd0283b 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 @@ -12,169 +12,159 @@ # Do not edit the class manually. # - module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CallList < ListResource - ## - # Initialize the CallList - # @param [Version] version Version that contains the resource - # @return [CallList] CallList - def initialize(version) - super(version) - # Path Solution - @solution = { } - - - end - - - - # Provide a user friendly representation - def to_s - '#' - end - end - - - class CallContext < InstanceContext - ## - # Initialize the CallContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [CallContext] CallContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Voice/#{@solution[:sid]}" - - - end - ## - # Update the CallInstance - # @return [CallInstance] Updated CallInstance - def update - - payload = @version.update('POST', @uri) - CallInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - class CallInstance < InstanceResource - ## - # Initialize the CallInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CallInstance] CallInstance - def initialize(version, payload , sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'sid' => payload['sid'] == nil ? payload['sid'] : payload['sid'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [CallContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = CallContext.new(@version , @params['sid']) - end - @instance_context - end - - ## - # @return [String] Non-string path parameter in the response. - def sid - @properties['sid'] - end - - ## - # Update the CallInstance - # @return [CallInstance] Updated CallInstance - def update - - context.update - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - end + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CallList < ListResource + ## + # Initialize the CallList + # @param [Version] version Version that contains the resource + # @return [CallList] CallList + def initialize(version) + super(version) + # Path Solution + @solution = {} + end + + # Provide a user friendly representation + def to_s + '#' + end + end + + class CallContext < InstanceContext + ## + # Initialize the CallContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [CallContext] CallContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Voice/#{@solution[:sid]}" + end + + ## + # Update the CallInstance + # @return [CallInstance] Updated CallInstance + def update + payload = @version.update('POST', @uri) + CallInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + class CallInstance < InstanceResource + ## + # Initialize the CallInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Call + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CallInstance] CallInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'] == nil ? payload['sid'] : payload['sid'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [CallContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = CallContext.new(@version, @params['sid']) end + @instance_context + end + + ## + # @return [String] Non-string path parameter in the response. + def sid + @properties['sid'] + end + + ## + # Update the CallInstance + # @return [CallInstance] Updated CallInstance + def update + context.update + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end 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 527e3f073..be8d63b4e 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 @@ -12,112 +12,109 @@ # Do not edit the class manually. # - module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - ## - # Initialize the CredentialList - # @param [Version] version Version that contains the resource - # @return [CredentialList] CredentialList - def initialize(version) - super(version) - # Path Solution - @solution = { } - @uri = "/Credentials" - # Components - @new_credentials = nil - @aws = nil - end - + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + ## + # Initialize the CredentialList + # @param [Version] version Version that contains the resource + # @return [CredentialList] CredentialList + def initialize(version) + super(version) + # Path Solution + @solution = {} + @uri = "/Credentials" + # Components + @new_credentials = nil + @aws = nil + end + + ## + # Access the new_credentials + # @return [NewCredentialsList] + # @return [NewCredentialsContext] + def new_credentials + @new_credentials ||= NewCredentialsList.new(@version) + end - ## - # Access the new_credentials - # @return [NewCredentialsList] - # @return [NewCredentialsContext] - def new_credentials - @new_credentials ||= NewCredentialsList.new(@version ) - end - ## - # Access the aws - # @return [AwsList] - # @return [AwsContext] if sid was passed. - def aws(sid=:unset) - raise ArgumentError, 'sid cannot be nil' if sid.nil? + ## + # Access the aws + # @return [AwsList] + # @return [AwsContext] if sid was passed. + def aws(sid = :unset) + raise ArgumentError, 'sid cannot be nil' if sid.nil? - if sid != :unset - return AwsContext.new(@version,sid ) - end + if sid != :unset + return AwsContext.new(@version, sid) + end - @aws ||= AwsList.new(@version ) - end + @aws ||= AwsList.new(@version) + end - # Provide a user friendly representation - def to_s - '#' - end - end + # Provide a user friendly representation + 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) + 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 + # 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 + ## + # 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 - class CredentialInstance < InstanceResource - ## - # Initialize the CredentialInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Credential - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [CredentialInstance] CredentialInstance - def initialize(version ) - super(version) - - end + ## + # Provide a user friendly representation + def to_s + '' + end + end - - ## - # Provide a user friendly representation - def to_s - "" - end + class CredentialInstance < InstanceResource + ## + # Initialize the CredentialInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Credential + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [CredentialInstance] CredentialInstance + def initialize(version) + super(version) + end - ## - # Provide a detailed, user friendly representation - def inspect - "" - end - end + ## + # Provide a user friendly representation + def to_s + "" + end - end + ## + # Provide a detailed, user friendly representation + def inspect + "" + end 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 0615515c9..c02d7120b 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 @@ -12,352 +12,342 @@ # Do not edit the class manually. # - module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - - class AwsList < ListResource - ## - # Initialize the AwsList - # @param [Version] version Version that contains the resource - # @return [AwsList] AwsList - def initialize(version) - super(version) - # Path Solution - @solution = { } - @uri = "/Credentials/AWS" - - end - - ## - # Lists AwsInstance records from the API as a list. - # Unlike stream(), this operation is eager and will load `limit` records into - # memory before returning. - # @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(limit: nil, page_size: nil) - self.stream( - 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 [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(limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - - page = self.page( - page_size: limits[:page_size], ) - - @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end - - ## - # When passed a block, yields AwsInstance 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 AwsInstance records from the API. - # Request is executed immediately. - # @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 AwsInstance - def page(page_token: :unset, page_number: :unset, page_size: :unset) - params = Twilio::Values.of({ - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) - - response = @version.page('GET', @uri, params: params) - - AwsPage.new(@version, response, @solution) - end - - ## - # Retrieve a single page of AwsInstance records from the API. - # Request is executed immediately. - # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of AwsInstance - def get_page(target_url) - response = @version.domain.request( - 'GET', - target_url - ) - AwsPage.new(@version, response, @solution) - end - - - - # Provide a user friendly representation - def to_s - '#' - end - end - - - class AwsContext < InstanceContext - ## - # Initialize the AwsContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [AwsContext] AwsContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Credentials/AWS/#{@solution[:sid]}" - - # Dependents - @history = nil - end - ## - # Delete the AwsInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - @version.delete('DELETE', @uri) - end - - ## - # Fetch the AwsInstance - # @return [AwsInstance] Fetched AwsInstance - def fetch - - payload = @version.fetch('GET', @uri) - AwsInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Update the AwsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @return [AwsInstance] Updated AwsInstance - def update( - test_string: :unset, - test_boolean: :unset - ) - - data = Twilio::Values.of({ - 'TestString' => test_string, - 'TestBoolean' => test_boolean, - }) - - payload = @version.update('POST', @uri, data: data) - AwsInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - ## - # Access the history - # @return [HistoryList] - # @return [HistoryContext] - def history - HistoryContext.new( - @version, - @solution[:sid] - ) - end - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - class AwsInstance < InstanceResource - ## - # Initialize the AwsInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Aws - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AwsInstance] AwsInstance - def initialize(version, payload , sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [AwsContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = AwsContext.new(@version , @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Delete the AwsInstance - # @return [Boolean] True if delete succeeds, false otherwise - def delete - - context.delete - end - - ## - # Fetch the AwsInstance - # @return [AwsInstance] Fetched AwsInstance - def fetch - - context.fetch - end - - ## - # Update the AwsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @return [AwsInstance] Updated AwsInstance - def update( - test_string: :unset, - test_boolean: :unset - ) - - context.update( - test_string: test_string, - test_boolean: test_boolean, - ) - end - - ## - # Access the history - # @return [history] history - def history - context.history - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - end - - end + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + class AwsList < ListResource + ## + # Initialize the AwsList + # @param [Version] version Version that contains the resource + # @return [AwsList] AwsList + def initialize(version) + super(version) + # Path Solution + @solution = {} + @uri = "/Credentials/AWS" + end + + ## + # Lists AwsInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @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(limit: nil, page_size: nil) + self.stream( + 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 [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(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + page_size: limits[:page_size], + ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields AwsInstance 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 AwsInstance records from the API. + # Request is executed immediately. + # @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 AwsInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + AwsPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of AwsInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of AwsInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + AwsPage.new(@version, response, @solution) + end + + # Provide a user friendly representation + def to_s + '#' + end + end + + class AwsContext < InstanceContext + ## + # Initialize the AwsContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [AwsContext] AwsContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Credentials/AWS/#{@solution[:sid]}" + + # Dependents + @history = nil + end + + ## + # Delete the AwsInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + @version.delete('DELETE', @uri) + end + + ## + # Fetch the AwsInstance + # @return [AwsInstance] Fetched AwsInstance + def fetch + payload = @version.fetch('GET', @uri) + AwsInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Update the AwsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @return [AwsInstance] Updated AwsInstance + def update( + test_string: :unset, + test_boolean: :unset + ) + + data = Twilio::Values.of({ + 'TestString' => test_string, + 'TestBoolean' => test_boolean, + }) + + payload = @version.update('POST', @uri, data: data) + AwsInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Access the history + # @return [HistoryList] + # @return [HistoryContext] + def history + HistoryContext.new( + @version, + @solution[:sid] + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + + class AwsInstance < InstanceResource + ## + # Initialize the AwsInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Aws + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AwsInstance] AwsInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [AwsContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = AwsContext.new(@version, @params['sid']) + end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Delete the AwsInstance + # @return [Boolean] True if delete succeeds, false otherwise + def delete + context.delete + end + + ## + # Fetch the AwsInstance + # @return [AwsInstance] Fetched AwsInstance + def fetch + context.fetch + end + + ## + # Update the AwsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @return [AwsInstance] Updated AwsInstance + def update( + test_string: :unset, + test_boolean: :unset + ) + + context.update( + test_string: test_string, + test_boolean: test_boolean, + ) + end + + ## + # Access the history + # @return [history] history + def history + context.history + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + end 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 748ead41b..84fa208aa 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 @@ -12,208 +12,196 @@ # Do not edit the class manually. # - module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - class AwsContext < InstanceContext - - class HistoryList < ListResource - ## - # Initialize the HistoryList - # @param [Version] version Version that contains the resource - # @return [HistoryList] HistoryList - def initialize(version, sid: nil) - super(version) - # Path Solution - @solution = { sid: sid } - - - end - - - - # Provide a user friendly representation - def to_s - '#' - end - end + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + class AwsContext < InstanceContext + class HistoryList < ListResource + ## + # Initialize the HistoryList + # @param [Version] version Version that contains the resource + # @return [HistoryList] HistoryList + def initialize(version, sid: nil) + super(version) + # Path Solution + @solution = { sid: sid } + end + + # Provide a user friendly representation + def to_s + '#' + end + end + class HistoryContext < InstanceContext + ## + # Initialize the HistoryContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [HistoryContext] HistoryContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Credentials/AWS/#{@solution[:sid]}/History" + end + + ## + # Fetch the HistoryInstance + # @param [Hash] add_ons_data + # @return [HistoryInstance] Fetched HistoryInstance + def fetch( + add_ons_data: :unset + ) + + params = Twilio::Values.of({}) + params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) + payload = @version.fetch('GET', @uri, params: params) + HistoryInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + end - class HistoryContext < InstanceContext - ## - # Initialize the HistoryContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [HistoryContext] HistoryContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Credentials/AWS/#{@solution[:sid]}/History" - - - end - ## - # Fetch the HistoryInstance - # @param [Hash] add_ons_data - # @return [HistoryInstance] Fetched HistoryInstance - def fetch( - add_ons_data: :unset - ) - - params = Twilio::Values.of({ - }) - params.merge!(Twilio.prefixed_collapsible_map(add_ons_data, 'AddOns')) - payload = @version.fetch('GET', @uri, params: params) - HistoryInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - 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 - class HistoryInstance < InstanceResource - ## - # Initialize the HistoryInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this History - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [HistoryInstance] HistoryInstance - def initialize(version, payload , sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [HistoryContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = HistoryContext.new(@version , @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Fetch the HistoryInstance - # @param [Hash] add_ons_data - # @return [HistoryInstance] Fetched HistoryInstance - def fetch( - add_ons_data: :unset - ) - - context.fetch( - add_ons_data: add_ons_data, - ) - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end + class HistoryInstance < InstanceResource + ## + # Initialize the HistoryInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this History + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [HistoryInstance] HistoryInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [HistoryContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = HistoryContext.new(@version, @params['sid']) end - - end - end + @instance_context + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] + end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Fetch the HistoryInstance + # @param [Hash] add_ons_data + # @return [HistoryInstance] Fetched HistoryInstance + def fetch( + add_ons_data: :unset + ) + + context.fetch( + add_ons_data: add_ons_data, + ) + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end end + end 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 0019252b9..2bcd67c1f 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 @@ -12,193 +12,189 @@ # Do not edit the class manually. # - module Twilio - module REST - class FlexApi < FlexApiBase - class V1 < Version - class CredentialList < ListResource - - class NewCredentialsList < ListResource - ## - # Initialize the NewCredentialsList - # @param [Version] version Version that contains the resource - # @return [NewCredentialsList] NewCredentialsList - def initialize(version) - super(version) - # Path Solution - @solution = { } - @uri = "/Credentials/AWS" - - end - ## - # Create the NewCredentialsInstance - # @param [String] test_string - # @param [Boolean] test_boolean - # @param [String] test_integer - # @param [Float] test_number - # @param [Float] test_number_float - # @param [Float] test_number_double - # @param [Float] test_number_int32 - # @param [String] test_number_int64 - # @param [Hash] test_object - # @param [Time] test_date_time - # @param [Date] test_date - # @param [Status] test_enum - # @param [Array[Hash]] test_object_array - # @param [Object] test_any_type - # @param [Array[Hash]] test_any_array - # @param [Array[String]] permissions A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. - # @param [String] some_a2p_thing - # @return [NewCredentialsInstance] Created NewCredentialsInstance - def create( - test_string: nil, - test_boolean: :unset, - test_integer: :unset, - test_number: :unset, - test_number_float: :unset, - test_number_double: :unset, - test_number_int32: :unset, - test_number_int64: :unset, - test_object: :unset, - test_date_time: :unset, - test_date: :unset, - test_enum: :unset, - test_object_array: :unset, - test_any_type: :unset, - test_any_array: :unset, - permissions: :unset, - some_a2p_thing: :unset - ) - - data = Twilio::Values.of({ - 'TestString' => test_string, - 'TestBoolean' => test_boolean, - 'TestInteger' => test_integer, - 'TestNumber' => test_number, - 'TestNumberFloat' => test_number_float, - 'TestNumberDouble' => test_number_double, - 'TestNumberInt32' => test_number_int32, - 'TestNumberInt64' => test_number_int64, - 'TestObject' => Twilio.serialize_object(test_object), - 'TestDateTime' => Twilio.serialize_iso8601_datetime(test_date_time), - 'TestDate' => Twilio.serialize_iso8601_date(test_date), - 'TestEnum' => test_enum, - 'TestObjectArray' => Twilio.serialize_list(test_object_array) { |e| Twilio.serialize_object(e) }, - 'TestAnyType' => Twilio.serialize_object(test_any_type), - 'TestAnyArray' => Twilio.serialize_list(test_any_array) { |e| Twilio.serialize_object(e) }, - 'Permissions' => Twilio.serialize_list(permissions) { |e| e }, - 'SomeA2PThing' => some_a2p_thing, - }) - - payload = @version.create('POST', @uri, data: data) - NewCredentialsInstance.new( - @version, - payload, - ) - end - - - - - # Provide a user friendly representation - 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 - class NewCredentialsInstance < InstanceResource - ## - # Initialize the NewCredentialsInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this NewCredentials - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [NewCredentialsInstance] NewCredentialsInstance - def initialize(version, payload ) - super(version) - - # Marshaled Properties - @properties = { - 'account_sid' => payload['account_sid'], - 'sid' => payload['sid'], - 'test_string' => payload['test_string'], - 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, - } - end - - - ## - # @return [String] - def account_sid - @properties['account_sid'] - end - - ## - # @return [String] - def sid - @properties['sid'] - end - - ## - # @return [String] - def test_string - @properties['test_string'] - end - - ## - # @return [String] - def test_integer - @properties['test_integer'] - end - - ## - # Provide a user friendly representation - def to_s - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - "" - end - end - - end + module REST + class FlexApi < FlexApiBase + class V1 < Version + class CredentialList < ListResource + class NewCredentialsList < ListResource + ## + # Initialize the NewCredentialsList + # @param [Version] version Version that contains the resource + # @return [NewCredentialsList] NewCredentialsList + def initialize(version) + super(version) + # Path Solution + @solution = {} + @uri = "/Credentials/AWS" + end + + ## + # Create the NewCredentialsInstance + # @param [String] test_string + # @param [Boolean] test_boolean + # @param [String] test_integer + # @param [Float] test_number + # @param [Float] test_number_float + # @param [Float] test_number_double + # @param [Float] test_number_int32 + # @param [String] test_number_int64 + # @param [Hash] test_object + # @param [Time] test_date_time + # @param [Date] test_date + # @param [Status] test_enum + # @param [Array[Hash]] test_object_array + # @param [Object] test_any_type + # @param [Array[Hash]] test_any_array + # @param [Array[String]] permissions A comma-separated list of the permissions you will request from the users of this ConnectApp. Can include: `get-all` and `post-all`. + # @param [String] some_a2p_thing + # @return [NewCredentialsInstance] Created NewCredentialsInstance + def create( + test_string: nil, + test_boolean: :unset, + test_integer: :unset, + test_number: :unset, + test_number_float: :unset, + test_number_double: :unset, + test_number_int32: :unset, + test_number_int64: :unset, + test_object: :unset, + test_date_time: :unset, + test_date: :unset, + test_enum: :unset, + test_object_array: :unset, + test_any_type: :unset, + test_any_array: :unset, + permissions: :unset, + some_a2p_thing: :unset + ) + + data = Twilio::Values.of({ + 'TestString' => test_string, + 'TestBoolean' => test_boolean, + 'TestInteger' => test_integer, + 'TestNumber' => test_number, + 'TestNumberFloat' => test_number_float, + 'TestNumberDouble' => test_number_double, + 'TestNumberInt32' => test_number_int32, + 'TestNumberInt64' => test_number_int64, + 'TestObject' => Twilio.serialize_object(test_object), + 'TestDateTime' => Twilio.serialize_iso8601_datetime(test_date_time), + 'TestDate' => Twilio.serialize_iso8601_date(test_date), + 'TestEnum' => test_enum, + 'TestObjectArray' => Twilio.serialize_list(test_object_array) { |e| + Twilio.serialize_object(e) + }, + 'TestAnyType' => Twilio.serialize_object(test_any_type), + 'TestAnyArray' => Twilio.serialize_list(test_any_array) { |e| + Twilio.serialize_object(e) + }, + 'Permissions' => Twilio.serialize_list(permissions) { |e| e }, + 'SomeA2PThing' => some_a2p_thing, + }) + + payload = @version.create('POST', @uri, data: data) + NewCredentialsInstance.new( + @version, + payload, + ) + end + + # Provide a user friendly representation + 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 + + class NewCredentialsInstance < InstanceResource + ## + # Initialize the NewCredentialsInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this NewCredentials + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [NewCredentialsInstance] NewCredentialsInstance + def initialize(version, payload) + super(version) + + # Marshaled Properties + @properties = { + 'account_sid' => payload['account_sid'], + 'sid' => payload['sid'], + 'test_string' => payload['test_string'], + 'test_integer' => payload['test_integer'] == nil ? payload['test_integer'] : payload['test_integer'].to_i, + } + end + + ## + # @return [String] + def account_sid + @properties['account_sid'] end + + ## + # @return [String] + def sid + @properties['sid'] + end + + ## + # @return [String] + def test_string + @properties['test_string'] + end + + ## + # @return [String] + def test_integer + @properties['test_integer'] + end + + ## + # Provide a user friendly representation + def to_s + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + "" + end + end end + end end + end end - - diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb index d30c57bc7..777cb0278 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/deployed_devices.rb @@ -13,37 +13,39 @@ # module Twilio - module REST - class Versionless - class DeployedDevices < Version - ## - # Initialize the DeployedDevices version of Versionless - def initialize(domain) - super - @version = 'DeployedDevices' - @fleets = nil - end + module REST + class Versionless + class DeployedDevices < Version + ## + # Initialize the DeployedDevices version of Versionless + def initialize(domain) + super + @version = 'DeployedDevices' + @fleets = nil + end + + ## + # @param [String] sid + # @return [Twilio::REST::Versionless::DeployedDevices::FleetContext] if sid was passed. + # @return [Twilio::REST::Versionless::DeployedDevices::FleetList] + def fleets(sid = :unset) + if sid.nil? + raise ArgumentError, 'sid cannot be nil' + end + + if sid == :unset + @fleets ||= FleetList.new self + else + FleetContext.new(self, sid) + end + end - ## - # @param [String] sid - # @return [Twilio::REST::Versionless::DeployedDevices::FleetContext] if sid was passed. - # @return [Twilio::REST::Versionless::DeployedDevices::FleetList] - def fleets(sid=:unset) - if sid.nil? - raise ArgumentError, 'sid cannot be nil' - end - if sid == :unset - @fleets ||= FleetList.new self - else - FleetContext.new(self, sid) - end - end - ## - # Provide a user friendly representation - def to_s - ''; - end - 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 c42f3acd8..58323ae0e 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 @@ -12,202 +12,193 @@ # Do not edit the class manually. # - module Twilio - module REST - class Versionless < VersionlessBase - class DeployedDevices < Version - class FleetList < ListResource - ## - # Initialize the FleetList - # @param [Version] version Version that contains the resource - # @return [FleetList] FleetList - def initialize(version) - super(version) - # Path Solution - @solution = { } - @uri = "/Fleets" - - end - ## - # Create the FleetInstance - # @param [String] name - # @return [FleetInstance] Created FleetInstance - def create( - name: :unset - ) - - data = Twilio::Values.of({ - 'Name' => name, - }) - - payload = @version.create('POST', @uri, data: data) - FleetInstance.new( - @version, - payload, - ) - end - - - - - # Provide a user friendly representation - def to_s - '#' - end - end - - - class FleetContext < InstanceContext - ## - # Initialize the FleetContext - # @param [Version] version Version that contains the resource - # @param [String] sid - # @return [FleetContext] FleetContext - def initialize(version, sid) - super(version) - - # Path Solution - @solution = { sid: sid, } - @uri = "/Fleets/#{@solution[:sid]}" - - - end - ## - # Fetch the FleetInstance - # @return [FleetInstance] Fetched FleetInstance - def fetch - - payload = @version.fetch('GET', @uri) - FleetInstance.new( - @version, - payload, - sid: @solution[:sid], - ) - end - - - ## - # Provide a user friendly representation - def to_s - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - end - - ## - # Provide a detailed, user friendly representation - def inspect - context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') - "#" - 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 - class FleetInstance < InstanceResource - ## - # Initialize the FleetInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Fleet - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [FleetInstance] FleetInstance - def initialize(version, payload , sid: nil) - super(version) - - # Marshaled Properties - @properties = { - 'name' => payload['name'], - 'sid' => payload['sid'], - 'friendly_name' => payload['friendly_name'], - } - - # Context - @instance_context = nil - @params = { 'sid' => sid || @properties['sid'] , } - end - - ## - # Generate an instance context for the instance, the context is capable of - # performing various actions. All instance actions are proxied to the context - # @return [FleetContext] CallContext for this CallInstance - def context - unless @instance_context - @instance_context = FleetContext.new(@version , @params['sid']) - end - @instance_context - end - - ## - # @return [String] - def name - @properties['name'] - end - - ## - # @return [String] A string that uniquely identifies this Fleet. - def sid - @properties['sid'] - end - - ## - # @return [String] A human readable description for this Fleet. - def friendly_name - @properties['friendly_name'] - end - - ## - # Fetch the FleetInstance - # @return [FleetInstance] Fetched FleetInstance - def fetch - - context.fetch - end - - ## - # Provide a user friendly representation - def to_s - values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") - "" - end - end + module REST + class Versionless < VersionlessBase + class DeployedDevices < Version + class FleetList < ListResource + ## + # Initialize the FleetList + # @param [Version] version Version that contains the resource + # @return [FleetList] FleetList + def initialize(version) + super(version) + # Path Solution + @solution = {} + @uri = "/Fleets" + end + + ## + # Create the FleetInstance + # @param [String] name + # @return [FleetInstance] Created FleetInstance + def create( + name: :unset + ) + + data = Twilio::Values.of({ + 'Name' => name, + }) + + payload = @version.create('POST', @uri, data: data) + FleetInstance.new( + @version, + payload, + ) + end + + # Provide a user friendly representation + def to_s + '#' + end + end + + class FleetContext < InstanceContext + ## + # Initialize the FleetContext + # @param [Version] version Version that contains the resource + # @param [String] sid + # @return [FleetContext] FleetContext + def initialize(version, sid) + super(version) + + # Path Solution + @solution = { sid: sid, } + @uri = "/Fleets/#{@solution[:sid]}" + end + + ## + # Fetch the FleetInstance + # @return [FleetInstance] Fetched FleetInstance + def fetch + payload = @version.fetch('GET', @uri) + FleetInstance.new( + @version, + payload, + sid: @solution[:sid], + ) + end + + ## + # Provide a user friendly representation + def to_s + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + end + + ## + # Provide a detailed, user friendly representation + def inspect + context = @solution.map { |k, v| "#{k}: #{v}" }.join(',') + "#" + 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 + class FleetInstance < InstanceResource + ## + # Initialize the FleetInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Fleet + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [FleetInstance] FleetInstance + def initialize(version, payload, sid: nil) + super(version) + + # Marshaled Properties + @properties = { + 'name' => payload['name'], + 'sid' => payload['sid'], + 'friendly_name' => payload['friendly_name'], + } + + # Context + @instance_context = nil + @params = { 'sid' => sid || @properties['sid'], } + end + + ## + # Generate an instance context for the instance, the context is capable of + # performing various actions. All instance actions are proxied to the context + # @return [FleetContext] CallContext for this CallInstance + def context + unless @instance_context + @instance_context = FleetContext.new(@version, @params['sid']) end + @instance_context + end + + ## + # @return [String] + def name + @properties['name'] + end + + ## + # @return [String] A string that uniquely identifies this Fleet. + def sid + @properties['sid'] + end + + ## + # @return [String] A human readable description for this Fleet. + def friendly_name + @properties['friendly_name'] + end + + ## + # Fetch the FleetInstance + # @return [FleetInstance] Fetched FleetInstance + def fetch + context.fetch + end + + ## + # Provide a user friendly representation + def to_s + values = @params.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + values = @properties.map { |k, v| "#{k}: #{v}" }.join(" ") + "" + end end + end end + end end diff --git a/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb b/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb index 4654f1ba7..c55a7abe3 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand.rb @@ -13,28 +13,29 @@ # module Twilio - module REST - class Versionless - class Understand < Version - ## - # Initialize the Understand version of Versionless - def initialize(domain) - super - @version = 'understand' - @assistants = nil - end + module REST + class Versionless + class Understand < Version + ## + # Initialize the Understand version of Versionless + def initialize(domain) + super + @version = 'understand' + @assistants = nil + end + + ## + # @return [Twilio::REST::Versionless::Understand::AssistantList] + def assistants + @assistants ||= AssistantList.new self + end - ## - # @return [Twilio::REST::Versionless::Understand::AssistantList] - def assistants - @assistants ||= AssistantList.new self - end - ## - # Provide a user friendly representation - def to_s - ''; - end - 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 a751a9dfc..279b9a648 100644 --- a/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb +++ b/examples/ruby/lib/twilio-ruby/rest/versionless/understand/assistant.rb @@ -12,191 +12,187 @@ # Do not edit the class manually. # - module Twilio - module REST - class Versionless < VersionlessBase - class Understand < Version - class AssistantList < ListResource - ## - # Initialize the AssistantList - # @param [Version] version Version that contains the resource - # @return [AssistantList] AssistantList - def initialize(version) - super(version) - # Path Solution - @solution = { } - @uri = "/Assistants" - - end - - ## - # Lists AssistantInstance records from the API as a list. - # Unlike stream(), this operation is eager and will load `limit` records into - # memory before returning. - # @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(limit: nil, page_size: nil) - self.stream( - 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 [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(limit: nil, page_size: nil) - limits = @version.read_limits(limit, page_size) - - page = self.page( - page_size: limits[:page_size], ) - - @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) - end - - ## - # When passed a block, yields AssistantInstance 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, + module REST + class Versionless < VersionlessBase + class Understand < Version + class AssistantList < ListResource + ## + # Initialize the AssistantList + # @param [Version] version Version that contains the resource + # @return [AssistantList] AssistantList + def initialize(version) + super(version) + # Path Solution + @solution = {} + @uri = "/Assistants" + end + + ## + # Lists AssistantInstance records from the API as a list. + # Unlike stream(), this operation is eager and will load `limit` records into + # memory before returning. + # @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(limit: nil, page_size: nil) + self.stream( + 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 [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(limit: nil, page_size: nil) + limits = @version.read_limits(limit, page_size) + + page = self.page( + page_size: limits[:page_size], + ) + + @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) + end + + ## + # When passed a block, yields AssistantInstance 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 AssistantInstance records from the API. - # Request is executed immediately. - # @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 AssistantInstance - def page(page_token: :unset, page_number: :unset, page_size: :unset) - params = Twilio::Values.of({ - 'PageToken' => page_token, - 'Page' => page_number, - 'PageSize' => page_size, - }) - - response = @version.page('GET', @uri, params: params) - - AssistantPage.new(@version, response, @solution) - end - - ## - # Retrieve a single page of AssistantInstance records from the API. - # Request is executed immediately. - # @param [String] target_url API-generated URL for the requested results page - # @return [Page] Page of AssistantInstance - def get_page(target_url) - response = @version.domain.request( - 'GET', - target_url - ) - AssistantPage.new(@version, response, @solution) - end - - - - # Provide a user friendly representation - 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 - class AssistantInstance < InstanceResource - ## - # Initialize the AssistantInstance - # @param [Version] version Version that contains the resource - # @param [Hash] payload payload that contains response from Twilio - # @param [String] account_sid The SID of the - # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Assistant - # resource. - # @param [String] sid The SID of the Call resource to fetch. - # @return [AssistantInstance] AssistantInstance - def initialize(version, payload ) - super(version) - - # Marshaled Properties - @properties = { - 'sid' => payload['sid'], - 'friendly_name' => payload['friendly_name'], - } - end - - - ## - # @return [String] A string that uniquely identifies this Fleet. - def sid - @properties['sid'] - end - - ## - # @return [String] A human readable description for this Fleet. - def friendly_name - @properties['friendly_name'] - end - - ## - # Provide a user friendly representation - def to_s - "" - end - - ## - # Provide a detailed, user friendly representation - def inspect - "" - end - end - - end + page_limit: limits[:page_limit]).each { |x| yield x } + end + + ## + # Retrieve a single page of AssistantInstance records from the API. + # Request is executed immediately. + # @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 AssistantInstance + def page(page_token: :unset, page_number: :unset, page_size: :unset) + params = Twilio::Values.of({ + 'PageToken' => page_token, + 'Page' => page_number, + 'PageSize' => page_size, + }) + + response = @version.page('GET', @uri, params: params) + + AssistantPage.new(@version, response, @solution) + end + + ## + # Retrieve a single page of AssistantInstance records from the API. + # Request is executed immediately. + # @param [String] target_url API-generated URL for the requested results page + # @return [Page] Page of AssistantInstance + def get_page(target_url) + response = @version.domain.request( + 'GET', + target_url + ) + AssistantPage.new(@version, response, @solution) + end + + # Provide a user friendly representation + 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 + + class AssistantInstance < InstanceResource + ## + # Initialize the AssistantInstance + # @param [Version] version Version that contains the resource + # @param [Hash] payload payload that contains response from Twilio + # @param [String] account_sid The SID of the + # {Account}[https://www.twilio.com/docs/iam/api/account] that created this Assistant + # resource. + # @param [String] sid The SID of the Call resource to fetch. + # @return [AssistantInstance] AssistantInstance + def initialize(version, payload) + super(version) + + # Marshaled Properties + @properties = { + 'sid' => payload['sid'], + 'friendly_name' => payload['friendly_name'], + } + end + + ## + # @return [String] A string that uniquely identifies this Fleet. + def sid + @properties['sid'] + end + + ## + # @return [String] A human readable description for this Fleet. + def friendly_name + @properties['friendly_name'] + end + + ## + # Provide a user friendly representation + def to_s + "" + end + + ## + # Provide a detailed, user friendly representation + def inspect + "" + end end + end end + end end