Class: Twilio::REST::Sync::V1::ServiceContext::SyncMapContext::SyncMapItemContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_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, map_sid, key) ⇒ SyncMapItemContext

Initialize the SyncMapItemContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • map_sid (String)

    The map_sid

  • key (String)

    The key



237
238
239
240
241
242
243
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 237

def initialize(version, service_sid, map_sid, key)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, map_sid: map_sid, key: key, }
  @uri = "/Services/#{@solution[:service_sid]}/Maps/#{@solution[:map_sid]}/Items/#{@solution[:key]}"
end

Instance Method Details

#deleteBoolean

Deletes the SyncMapItemInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



269
270
271
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 269

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

#fetchSyncMapItemInstance

Fetch a SyncMapItemInstance

Returns:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 248

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

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

  SyncMapItemInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      map_sid: @solution[:map_sid],
      key: @solution[:key],
  )
end

#inspectObject

Provide a detailed, user friendly representation



320
321
322
323
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 320

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

#to_sObject

Provide a user friendly representation



313
314
315
316
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 313

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

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

Update the SyncMapItemInstance

Parameters:

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

    Contains an arbitrary JSON object to be stored in this Map Item. Serialized to string to respect HTTP form input, up to 16KB.

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

    Alias for item_ttl. If both are provided, this value is ignored.

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

    Time-to-live of this item in seconds, defaults to no expiration. In the range [1, 31 536 000 (1 year)], or 0 for infinity. Upon expiry, the map item will be cleaned up at least in a matter of hours, and often within seconds, making this a good tool for garbage management.

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

    Time-to-live of this item’s parent Map in seconds, defaults to no expiration. In the range [1, 31 536 000 (1 year)], or 0 for infinity. This parameter can only be used when the map item’s data or ttl is updated in the same request.

Returns:



288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 288

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,
  )

  SyncMapItemInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      map_sid: @solution[:map_sid],
      key: @solution[:key],
  )
end