class Twilio::REST::Sync::V1::ServiceContext::SyncMapContext::SyncMapItemContext
Public Class Methods
Initialize the SyncMapItemContext
@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 Map Item resource to fetch.
@param [String] map_sid The SID of the Sync
Map with the Sync
Map Item resource
to fetch. Can be the Sync Map resource's `sid` or its `unique_name`.
@param [String] key The `key` value of the Sync
Map Item resource to fetch. @return [SyncMapItemContext] SyncMapItemContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 234 def initialize(version, service_sid, map_sid, key) 235 super(version) 236 237 # Path Solution 238 @solution = {service_sid: service_sid, map_sid: map_sid, key: key, } 239 @uri = "/Services/#{@solution[:service_sid]}/Maps/#{@solution[:map_sid]}/Items/#{@solution[:key]}" 240 end
Public Instance Methods
Delete the SyncMapItemInstance
@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_map/sync_map_item.rb 264 def delete(if_match: :unset) 265 headers = Twilio::Values.of({'If-Match' => if_match, }) 266 267 @version.delete('DELETE', @uri, headers: headers) 268 end
Fetch the SyncMapItemInstance
@return [SyncMapItemInstance] Fetched SyncMapItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 245 def fetch 246 payload = @version.fetch('GET', @uri) 247 248 SyncMapItemInstance.new( 249 @version, 250 payload, 251 service_sid: @solution[:service_sid], 252 map_sid: @solution[:map_sid], 253 key: @solution[:key], 254 ) 255 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 318 def inspect 319 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 320 "#<Twilio.Sync.V1.SyncMapItemContext #{context}>" 321 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 311 def to_s 312 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 313 "#<Twilio.Sync.V1.SyncMapItemContext #{context}>" 314 end
Update the SyncMapItemInstance
@param [Hash] data A JSON string that represents an arbitrary, schema-less
object that the Map 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 Map 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 Map Item's parent Sync Map expires (time-to-live) and is deleted. This parameter can only be used when the Map 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 [SyncMapItemInstance] Updated SyncMapItemInstance
# File lib/twilio-ruby/rest/sync/v1/service/sync_map/sync_map_item.rb 289 def update(data: :unset, ttl: :unset, item_ttl: :unset, collection_ttl: :unset, if_match: :unset) 290 data = Twilio::Values.of({ 291 'Data' => Twilio.serialize_object(data), 292 'Ttl' => ttl, 293 'ItemTtl' => item_ttl, 294 'CollectionTtl' => collection_ttl, 295 }) 296 headers = Twilio::Values.of({'If-Match' => if_match, }) 297 298 payload = @version.update('POST', @uri, data: data, headers: headers) 299 300 SyncMapItemInstance.new( 301 @version, 302 payload, 303 service_sid: @solution[:service_sid], 304 map_sid: @solution[:map_sid], 305 key: @solution[:key], 306 ) 307 end