class Twilio::REST::Sync::V1::ServiceContext::SyncListContext::SyncListItemList
Public Class Methods
Initialize the SyncListItemList
@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.
@param [String] list_sid The SID of the Sync
List that contains the List Item. @return [SyncListItemList] SyncListItemList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb 24 def initialize(version, service_sid: nil, list_sid: nil) 25 super(version) 26 27 # Path Solution 28 @solution = {service_sid: service_sid, list_sid: list_sid} 29 @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Items" 30 end
Public Instance Methods
Create the SyncListItemInstance
@param [Hash] data A JSON string that represents an arbitrary, schema-less
object that the List Item stores. Can be up to 16 KiB in length.
@param [String] ttl An alias for `item_ttl`. If both parameters are provided,
this value is ignored.
@param [String] item_ttl How long, {in
seconds}[https://www.twilio.com/docs/sync/limits#sync-payload-limits], before the List Item expires (time-to-live) and is deleted.
@param [String] collection_ttl How long, {in
seconds}[https://www.twilio.com/docs/sync/limits#sync-payload-limits], before the List Item's parent Sync List expires (time-to-live) and is deleted.
@return [SyncListItemInstance] Created SyncListItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb 45 def create(data: nil, ttl: :unset, item_ttl: :unset, collection_ttl: :unset) 46 data = Twilio::Values.of({ 47 'Data' => Twilio.serialize_object(data), 48 'Ttl' => ttl, 49 'ItemTtl' => item_ttl, 50 'CollectionTtl' => collection_ttl, 51 }) 52 53 payload = @version.create('POST', @uri, data: data) 54 55 SyncListItemInstance.new( 56 @version, 57 payload, 58 service_sid: @solution[:service_sid], 59 list_sid: @solution[:list_sid], 60 ) 61 end
When passed a block, yields SyncListItemInstance
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/sync_list_item.rb 119 def each 120 limits = @version.read_limits 121 122 page = self.page(page_size: limits[:page_size], ) 123 124 @version.stream(page, 125 limit: limits[:limit], 126 page_limit: limits[:page_limit]).each {|x| yield x} 127 end
Retrieve a single page of SyncListItemInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of SyncListItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb 165 def get_page(target_url) 166 response = @version.domain.request( 167 'GET', 168 target_url 169 ) 170 SyncListItemPage.new(@version, response, @solution) 171 end
Lists SyncListItemInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [sync_list_item.QueryResultOrder] order How to order the List Items
returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending.
@param [String] from The `index` of the first Sync
List Item resource to read.
See also `bounds`.
@param [sync_list_item.QueryFromBoundType] bounds Whether to include the List
Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`.
@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/sync_list_item.rb 83 def list(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) 84 self.stream(order: order, from: from, bounds: bounds, limit: limit, page_size: page_size).entries 85 end
Retrieve a single page of SyncListItemInstance
records from the API. Request
is executed immediately. @param [sync_list_item.QueryResultOrder] order How to order the List Items
returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending.
@param [String] from The `index` of the first Sync
List Item resource to read.
See also `bounds`.
@param [sync_list_item.QueryFromBoundType] bounds Whether to include the List
Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`.
@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 SyncListItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb 145 def page(order: :unset, from: :unset, bounds: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 146 params = Twilio::Values.of({ 147 'Order' => order, 148 'From' => from, 149 'Bounds' => bounds, 150 'PageToken' => page_token, 151 'Page' => page_number, 152 'PageSize' => page_size, 153 }) 154 155 response = @version.page('GET', @uri, params: params) 156 157 SyncListItemPage.new(@version, response, @solution) 158 end
Streams SyncListItemInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [sync_list_item.QueryResultOrder] order How to order the List Items
returned by their `index` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending.
@param [String] from The `index` of the first Sync
List Item resource to read.
See also `bounds`.
@param [sync_list_item.QueryFromBoundType] bounds Whether to include the List
Item referenced by the `from` parameter. Can be: `inclusive` to include the List Item referenced by the `from` parameter or `exclusive` to start with the next List Item. The default value is `inclusive`.
@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/sync_list_item.rb 107 def stream(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) 108 limits = @version.read_limits(limit, page_size) 109 110 page = self.page(order: order, from: from, bounds: bounds, page_size: limits[:page_size], ) 111 112 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 113 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb 175 def to_s 176 '#<Twilio.Sync.V1.SyncListItemList>' 177 end