class Twilio::REST::Sync::V1::ServiceContext::SyncListList
Public Class Methods
Initialize the SyncListList
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the {Sync
Service}[https://www.twilio.com/docs/sync/api/service] the resource is associated with.
@return [SyncListList] SyncListList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 22 def initialize(version, service_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {service_sid: service_sid} 27 @uri = "/Services/#{@solution[:service_sid]}/Lists" 28 end
Public Instance Methods
Create the SyncListInstance
@param [String] unique_name An application-defined string that uniquely
identifies the resource. This value must be unique within its Service and it can be up to 320 characters long. The `unique_name` value can be used as an alternative to the `sid` in the URL path to address the resource.
@param [String] ttl Alias for collection_ttl. If both are provided, this value
is ignored.
@param [String] collection_ttl How long, {in
seconds}[https://www.twilio.com/docs/sync/limits#sync-payload-limits], before the Sync List expires (time-to-live) and is deleted.
@return [SyncListInstance] Created SyncListInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 42 def create(unique_name: :unset, ttl: :unset, collection_ttl: :unset) 43 data = Twilio::Values.of({ 44 'UniqueName' => unique_name, 45 'Ttl' => ttl, 46 'CollectionTtl' => collection_ttl, 47 }) 48 49 payload = @version.create('POST', @uri, data: data) 50 51 SyncListInstance.new(@version, payload, service_sid: @solution[:service_sid], ) 52 end
When passed a block, yields SyncListInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 92 def each 93 limits = @version.read_limits 94 95 page = self.page(page_size: limits[:page_size], ) 96 97 @version.stream(page, 98 limit: limits[:limit], 99 page_limit: limits[:page_limit]).each {|x| yield x} 100 end
Retrieve a single page of SyncListInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of SyncListInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 126 def get_page(target_url) 127 response = @version.domain.request( 128 'GET', 129 target_url 130 ) 131 SyncListPage.new(@version, response, @solution) 132 end
Lists SyncListInstance
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
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 65 def list(limit: nil, page_size: nil) 66 self.stream(limit: limit, page_size: page_size).entries 67 end
Retrieve a single page of SyncListInstance
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 SyncListInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 109 def page(page_token: :unset, page_number: :unset, page_size: :unset) 110 params = Twilio::Values.of({ 111 'PageToken' => page_token, 112 'Page' => page_number, 113 'PageSize' => page_size, 114 }) 115 116 response = @version.page('GET', @uri, params: params) 117 118 SyncListPage.new(@version, response, @solution) 119 end
Streams SyncListInstance
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
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 80 def stream(limit: nil, page_size: nil) 81 limits = @version.read_limits(limit, page_size) 82 83 page = self.page(page_size: limits[:page_size], ) 84 85 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 86 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service/sync_list.rb 136 def to_s 137 '#<Twilio.Sync.V1.SyncListList>' 138 end