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

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

  • list_sid (String)

    The SID of the Sync List with the Sync List Item resource to update. Can be the Sync List resource’s ‘sid` or its `unique_name`.

  • index (String)

    The index of the Sync List Item resource to update.



274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 274

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

#delete(if_match: :unset) ⇒ Boolean

Delete the SyncListItemInstance

Parameters:

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

    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](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 288

def delete(
  if_match: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadata(if_match: :unset) ⇒ Boolean

Delete the SyncListItemInstanceMetadata

Parameters:

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

    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](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 304

def (
  if_match: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      syncListItem_instance = SyncListItemInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      SyncListItemInstanceMetadata.new(@version, syncListItem_instance, response.headers, response.status_code)
end

#fetchSyncListItemInstance

Fetch the SyncListItemInstance

Returns:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 325

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    SyncListItemInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
end

#fetch_with_metadataSyncListItemInstance

Fetch the SyncListItemInstanceMetadata

Returns:



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 346

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    sync_list_item_instance = SyncListItemInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
    SyncListItemInstanceMetadata.new(
        @version,
        sync_list_item_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



464
465
466
467
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 464

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

#to_sObject

Provide a user friendly representation



457
458
459
460
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 457

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, if_match: :unset) ⇒ SyncListItemInstance

Update the SyncListItemInstance

Parameters:

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

    A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB 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](www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted.

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

    How long, [in seconds](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.

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

    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](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).

Returns:



378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 378

def update(
  data: :unset, 
  ttl: :unset, 
  item_ttl: :unset, 
  collection_ttl: :unset, 
  if_match: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    SyncListItemInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
end

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

Update the SyncListItemInstanceMetadata

Parameters:

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

    A JSON string that represents an arbitrary, schema-less object that the List Item stores. Can be up to 16 KiB 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](www.twilio.com/docs/sync/limits#sync-payload-limits), before the List Item expires (time-to-live) and is deleted.

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

    How long, [in seconds](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.

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

    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](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).

Returns:



417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_list/sync_list_item.rb', line 417

def (
  data: :unset, 
  ttl: :unset, 
  item_ttl: :unset, 
  collection_ttl: :unset, 
  if_match: :unset
)

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

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    sync_list_item_instance = SyncListItemInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        list_sid: @solution[:list_sid],
        index: @solution[:index],
    )
    SyncListItemInstanceMetadata.new(
        @version,
        sync_list_item_instance,
        response.headers,
        response.status_code
    )
end