class Twilio::REST::Sync::V1::ServiceContext::SyncMapContext::SyncMapItemList
Public Class Methods
Initialize the SyncMapItemList
@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] map_sid The SID of the Sync
Map that contains the Map Item. @return [SyncMapItemList] SyncMapItemList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 24 def initialize(version, service_sid: nil, map_sid: nil) 25 super(version) 26 27 # Path Solution 28 @solution = {service_sid: service_sid, map_sid: map_sid} 29 @uri = "/Services/#{@solution[:service_sid]}/Maps/#{@solution[:map_sid]}/Items" 30 end
Public Instance Methods
Create the SyncMapItemInstance
@param [String] key The unique, user-defined key for the Map Item. Can be up to
320 characters long.
@param [Hash] data A JSON string that represents an arbitrary, schema-less
object that the Map 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 Map 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 Map Item's parent Sync Map expires (time-to-live) and is deleted.
@return [SyncMapItemInstance] Created SyncMapItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 47 def create(key: nil, data: nil, ttl: :unset, item_ttl: :unset, collection_ttl: :unset) 48 data = Twilio::Values.of({ 49 'Key' => key, 50 'Data' => Twilio.serialize_object(data), 51 'Ttl' => ttl, 52 'ItemTtl' => item_ttl, 53 'CollectionTtl' => collection_ttl, 54 }) 55 56 payload = @version.create('POST', @uri, data: data) 57 58 SyncMapItemInstance.new( 59 @version, 60 payload, 61 service_sid: @solution[:service_sid], 62 map_sid: @solution[:map_sid], 63 ) 64 end
When passed a block, yields SyncMapItemInstance
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_map/sync_map_item.rb 126 def each 127 limits = @version.read_limits 128 129 page = self.page(page_size: limits[:page_size], ) 130 131 @version.stream(page, 132 limit: limits[:limit], 133 page_limit: limits[:page_limit]).each {|x| yield x} 134 end
Retrieve a single page of SyncMapItemInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of SyncMapItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 174 def get_page(target_url) 175 response = @version.domain.request( 176 'GET', 177 target_url 178 ) 179 SyncMapItemPage.new(@version, response, @solution) 180 end
Lists SyncMapItemInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [sync_map_item.QueryResultOrder] order How to order the Map Items
returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are {ordered lexicographically}[https://en.wikipedia.org/wiki/Lexicographical_order] by Item key.
@param [String] from The `key` of the first Sync
Map Item resource to read. See
also `bounds`.
@param [sync_map_item.QueryFromBoundType] bounds Whether to include the Map Item
referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map 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_map/sync_map_item.rb 88 def list(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) 89 self.stream(order: order, from: from, bounds: bounds, limit: limit, page_size: page_size).entries 90 end
Retrieve a single page of SyncMapItemInstance
records from the API. Request
is executed immediately. @param [sync_map_item.QueryResultOrder] order How to order the Map Items
returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are {ordered lexicographically}[https://en.wikipedia.org/wiki/Lexicographical_order] by Item key.
@param [String] from The `key` of the first Sync
Map Item resource to read. See
also `bounds`.
@param [sync_map_item.QueryFromBoundType] bounds Whether to include the Map Item
referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map 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 SyncMapItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 154 def page(order: :unset, from: :unset, bounds: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 155 params = Twilio::Values.of({ 156 'Order' => order, 157 'From' => from, 158 'Bounds' => bounds, 159 'PageToken' => page_token, 160 'Page' => page_number, 161 'PageSize' => page_size, 162 }) 163 164 response = @version.page('GET', @uri, params: params) 165 166 SyncMapItemPage.new(@version, response, @solution) 167 end
Streams SyncMapItemInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [sync_map_item.QueryResultOrder] order How to order the Map Items
returned by their `key` value. Can be: `asc` (ascending) or `desc` (descending) and the default is ascending. Map Items are {ordered lexicographically}[https://en.wikipedia.org/wiki/Lexicographical_order] by Item key.
@param [String] from The `key` of the first Sync
Map Item resource to read. See
also `bounds`.
@param [sync_map_item.QueryFromBoundType] bounds Whether to include the Map Item
referenced by the `from` parameter. Can be: `inclusive` to include the Map Item referenced by the `from` parameter or `exclusive` to start with the next Map 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_map/sync_map_item.rb 114 def stream(order: :unset, from: :unset, bounds: :unset, limit: nil, page_size: nil) 115 limits = @version.read_limits(limit, page_size) 116 117 page = self.page(order: order, from: from, bounds: bounds, page_size: limits[:page_size], ) 118 119 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 120 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 184 def to_s 185 '#<Twilio.Sync.V1.SyncMapItemList>' 186 end