Class: Twilio::REST::Memory::V1::StoreContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/memory/v1/store.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, store_id) ⇒ StoreContext

Initialize the StoreContext

Parameters:

  • version (Version)

    Version that contains the resource

  • store_id (String)

    A unique Memory Store ID using Twilio Type ID (TTID) format



292
293
294
295
296
297
298
299
300
301
302
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 292

def initialize(version, store_id)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)

    # Path Solution
    @solution = { store_id: store_id,  }
    @uri = "/ControlPlane/Stores/#{@solution[:store_id]}"

    
end

Instance Method Details

#fetchStoreInstance

Fetch the StoreInstance

Returns:



306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 306

def fetch

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

#fetch_with_metadataStoreInstance

Fetch the StoreInstanceMetadata

Returns:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 325

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    store_instance = StoreInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
    )
    StoreInstanceMetadata.new(
        @version,
        store_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



411
412
413
414
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 411

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

#patch(if_match: :unset, patch_store_request: :unset) ⇒ StoreInstance

Patch the StoreInstance

Parameters:

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

    Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource’s current Entity Tag (ETag) matches the one provided, preventing accidental overwrites.

  • patch_store_request (PatchStoreRequest) (defaults to: :unset)

Returns:



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 352

def patch(
  if_match: :unset,
  patch_store_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.patch('PATCH', @uri, headers: headers, data: patch_store_request.to_json)
    StoreInstance.new(
        @version,
        payload,
        store_id: @solution[:store_id],
    )
end

#patch_with_metadata(if_match: :unset, patch_store_request: :unset) ⇒ StoreInstance

Patch the StoreInstanceMetadata

Parameters:

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

    Allows for optimistic concurrency control by making the request conditional. Server will only act if the resource’s current Entity Tag (ETag) matches the one provided, preventing accidental overwrites.

  • patch_store_request (PatchStoreRequest) (defaults to: :unset)

Returns:



376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 376

def (
  if_match: :unset,
patch_store_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PATCH', @uri, headers: headers, data: patch_store_request.to_json)
    store_instance = StoreInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
    )
    StoreInstanceMetadata.new(
        @version,
        store_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



404
405
406
407
# File 'lib/twilio-ruby/rest/memory/v1/store.rb', line 404

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