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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb

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)
  • map_sid (String)
  • key (String)


189
190
191
192
193
194
195
196
197
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 189

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

Parameters:

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

    The If-Match HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



202
203
204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 202

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

#fetchSyncMapItemInstance

Fetch the SyncMapItemInstance

Returns:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 216

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    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



274
275
276
277
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 274

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

#to_sObject

Provide a user friendly representation



267
268
269
270
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 267

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

#update(data: nil, if_match: :unset) ⇒ SyncMapItemInstance

Update the SyncMapItemInstance

Parameters:

  • data (Object) (defaults to: nil)
  • if_match (String) (defaults to: :unset)

    The If-Match HTTP request header

Returns:



239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
# File 'lib/twilio-ruby/rest/preview/sync/service/sync_map/sync_map_item.rb', line 239

def update(
    data: nil, 
    if_match: :unset
)

    data = Twilio::Values.of({
        'Data' => Twilio.serialize_object(data),
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', '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