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

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, map_sid, key) ⇒ SyncMapItemContext

Initialize the SyncMapItemContext



234
235
236
237
238
239
240
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 234

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

#delete(if_match: :unset) ⇒ Boolean

Delete the SyncMapItemInstance



264
265
266
267
268
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 264

def delete(if_match: :unset)
  headers = Twilio::Values.of({'If-Match' => if_match, })

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

#fetchSyncMapItemInstance

Fetch the SyncMapItemInstance



245
246
247
248
249
250
251
252
253
254
255
# File 'lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb', line 245

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

  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



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

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

#to_sObject

Provide a user friendly representation



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

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

Update the SyncMapItemInstance



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

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({'If-Match' => if_match, })

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

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