Class: Twilio::REST::Memory::V1::IdentifierContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, store_id, profile_id, id_type) ⇒ IdentifierContext

Initialize the IdentifierContext

Parameters:

  • version (Version)

    Version that contains the resource

  • store_id (String)

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

  • profile_id (String)

    The unique identifier for the profile using Twilio Type ID (TTID) format.

  • id_type (String)

    Identifier type configured for the service (for example ‘email`, `phone`, or `externalId`).



288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 288

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

    # Path Solution
    @solution = { store_id: store_id, profile_id: profile_id, id_type: id_type,  }
    @uri = "/Stores/#{@solution[:store_id]}/Profiles/#{@solution[:profile_id]}/Identifiers/#{@solution[:id_type]}"

    
end

Instance Method Details

#delete(remove_all: :unset) ⇒ Boolean

Delete the IdentifierInstance

Parameters:

  • remove_all (Boolean) (defaults to: :unset)

    When true, removes every stored value for the identifier type in a single operation. Defaults to false.

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 303

def delete(
  remove_all: :unset
)

    params = Twilio::Values.of({
        'removeAll' => remove_all,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    response = @version.('DELETE', @uri, params: params, headers: headers)
    IdentifierInstance.new(
      @version,
      response.body,
        store_id: @solution[:store_id],
        profile_id: @solution[:profile_id],
        id_type: @solution[:id_type],
    )
    
end

#delete_with_metadata(remove_all: :unset) ⇒ Boolean

Delete the IdentifierInstanceMetadata

Parameters:

  • remove_all (Boolean) (defaults to: :unset)

    When true, removes every stored value for the identifier type in a single operation. Defaults to false.

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 329

def (
  remove_all: :unset
)

    params = Twilio::Values.of({
        'removeAll' => remove_all,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, params: params, headers: headers)
      identifier_instance = IdentifierInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      IdentifierInstanceMetadata.new(@version, identifier_instance, response.headers, response.status_code)
end

#fetchIdentifierInstance

Fetch the IdentifierInstance

Returns:



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

def fetch

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

#fetch_with_metadataIdentifierInstance

Fetch the IdentifierInstanceMetadata

Returns:



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

def 

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

#inspectObject

Provide a detailed, user friendly representation



460
461
462
463
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 460

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

#patch(identifier_update: nil) ⇒ IdentifierInstance

Patch the IdentifierInstance

Parameters:

  • identifier_update (IdentifierUpdate) (defaults to: nil)

Returns:



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 402

def patch(identifier_update: nil
)

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

#patch_with_metadata(identifier_update: nil) ⇒ IdentifierInstance

Patch the IdentifierInstanceMetadata

Parameters:

  • identifier_update (IdentifierUpdate) (defaults to: nil)

Returns:



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 425

def (identifier_update: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PATCH', @uri, headers: headers, data: identifier_update.to_json)
    identifier_instance = IdentifierInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
        profile_id: @solution[:profile_id],
        id_type: @solution[:id_type],
    )
    IdentifierInstanceMetadata.new(
        @version,
        identifier_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



453
454
455
456
# File 'lib/twilio-ruby/rest/memory/v1/identifier.rb', line 453

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