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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, list_sid, index) ⇒ SyncListItemContext

Initialize the SyncListItemContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Sync Service](www.twilio.com/docs/sync/api/service) with the Sync List Item resource to fetch.

  • list_sid (String)

    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`.

  • index (String)

    The index of the Sync List Item resource to fetch.



243
244
245
246
247
248
249
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 243

def initialize(version, service_sid, list_sid, index)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, list_sid: list_sid, index: index, }
  @uri = "/Services/#{@solution[:service_sid]}/Lists/#{@solution[:list_sid]}/Items/#{@solution[:index]}"
end

Instance Method Details

#deleteBoolean

Deletes the SyncListItemInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



275
276
277
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 275

def delete
  @version.delete('delete', @uri)
end

#fetchSyncListItemInstance

Fetch a SyncListItemInstance

Returns:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 254

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  SyncListItemInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      list_sid: @solution[:list_sid],
      index: @solution[:index],
  )
end

#inspectObject

Provide a detailed, user friendly representation



329
330
331
332
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 329

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Sync.V1.SyncListItemContext #{context}>"
end

#to_sObject

Provide a user friendly representation



322
323
324
325
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 322

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Sync.V1.SyncListItemContext #{context}>"
end

#update(data: :unset, ttl: :unset, item_ttl: :unset, collection_ttl: :unset) ⇒ SyncListItemInstance

Update the SyncListItemInstance

Parameters:

  • data (Hash) (defaults to: :unset)

    A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16KB in length.

  • ttl (String) (defaults to: :unset)

    An alias for ‘item_ttl`. If both parameters are provided, this value is ignored.

  • item_ttl (String) (defaults to: :unset)

    How long, in seconds, before the List Item expires (time-to-live) and is deleted. Can be an integer from 0 to 31,536,000 (1 year). The default value is ‘0`, which means the List Item does not expire. The List Item will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources’s deletion.

  • collection_ttl (String) (defaults to: :unset)

    How long, in seconds, before the List Item’s parent Sync List expires (time-to-live) and is deleted. Can be an integer from 0 to 31,536,000 (1 year). The default value is ‘0`, which means the parent Sync List does not expire. The Sync List will be deleted automatically after it expires, but there can be a delay between the expiration time and the resources’s deletion.

Returns:



297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 297

def update(data: :unset, ttl: :unset, item_ttl: :unset, collection_ttl: :unset)
  data = Twilio::Values.of({
      'Data' => Twilio.serialize_object(data),
      'Ttl' => ttl,
      'ItemTtl' => item_ttl,
      'CollectionTtl' => collection_ttl,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  SyncListItemInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      list_sid: @solution[:list_sid],
      index: @solution[:index],
  )
end