class Twilio::REST::Sync::V1::ServiceContext::SyncListContext::SyncListItemContext

Public Class Methods

new(version, service_sid, list_sid, index) click to toggle source

Initialize the SyncListItemContext @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] with the Sync List Item
resource to fetch.

@param [String] list_sid The SID of the Sync List with the Sync List Item

resource to fetch. Can be the Sync List resource's `sid` or its `unique_name`.

@param [String] index The index of the Sync List Item resource to fetch. @return [SyncListItemContext] SyncListItemContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
225 def initialize(version, service_sid, list_sid, index)
226   super(version)
227 
228   # Path Solution
229   @solution = {service_sid: service_sid, list_sid: list_sid, index: index, }
230   @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Items/#{@solution[:index]}"
231 end

Public Instance Methods

delete(if_match: :unset) click to toggle source

Delete the SyncListItemInstance @param [String] if_match If provided, applies this mutation if (and only if) the

“revision” field of this {map item] matches the provided value. This matches the
semantics of (and is implemented with) the HTTP [If-Match
header}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match].

@return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
255 def delete(if_match: :unset)
256   headers = Twilio::Values.of({'If-Match' => if_match, })
257 
258    @version.delete('DELETE', @uri, headers: headers)
259 end
fetch() click to toggle source

Fetch the SyncListItemInstance @return [SyncListItemInstance] Fetched SyncListItemInstance

    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
236 def fetch
237   payload = @version.fetch('GET', @uri)
238 
239   SyncListItemInstance.new(
240       @version,
241       payload,
242       service_sid: @solution[:service_sid],
243       list_sid: @solution[:list_sid],
244       index: @solution[:index],
245   )
246 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
309 def inspect
310   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
311   "#<Twilio.Sync.V1.SyncListItemContext #{context}>"
312 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
302 def to_s
303   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
304   "#<Twilio.Sync.V1.SyncListItemContext #{context}>"
305 end
update(data: :unset, ttl: :unset, item_ttl: :unset, collection_ttl: :unset, if_match: :unset) click to toggle source

Update 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. This
parameter can only be used when the List Item's `data` or `ttl` is updated in
the same request.

@param [String] if_match If provided, applies this mutation if (and only if) the

“revision” field of this {map item] matches the provided value. This matches the
semantics of (and is implemented with) the HTTP [If-Match
header}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match].

@return [SyncListItemInstance] Updated SyncListItemInstance

    # File lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb
280 def update(data: :unset, ttl: :unset, item_ttl: :unset, collection_ttl: :unset, if_match: :unset)
281   data = Twilio::Values.of({
282       'Data' => Twilio.serialize_object(data),
283       'Ttl' => ttl,
284       'ItemTtl' => item_ttl,
285       'CollectionTtl' => collection_ttl,
286   })
287   headers = Twilio::Values.of({'If-Match' => if_match, })
288 
289   payload = @version.update('POST', @uri, data: data, headers: headers)
290 
291   SyncListItemInstance.new(
292       @version,
293       payload,
294       service_sid: @solution[:service_sid],
295       list_sid: @solution[:list_sid],
296       index: @solution[:index],
297   )
298 end