Class: Twilio::REST::Memory::V1::TraitGroupContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, store_id, trait_group_name) ⇒ TraitGroupContext

Initialize the TraitGroupContext

Parameters:

  • version (Version)

    Version that contains the resource

  • store_id (String)

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

  • trait_group_name (String)

    A unique Name of the TraitGroup



415
416
417
418
419
420
421
422
423
424
425
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 415

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the TraitGroupInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 429

def delete

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

#delete_with_metadataBoolean

Delete the TraitGroupInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 448

def 

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

#fetch(include_traits: :unset, page_size: :unset, page_token: :unset, order_by: :unset) ⇒ TraitGroupInstance

Fetch the TraitGroupInstance

Parameters:

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

    Whether to include trait definitions in the response

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

    The maximum number of items to return per page, maximum of 100.

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

    The token for the page of results to retrieve.

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

    Either ‘ASC’ or ‘DESC’ to sort results ascending or descending respectively.

Returns:



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 471

def fetch(
  include_traits: :unset, 
  page_size: :unset, 
  page_token: :unset, 
  order_by: :unset
)

    params = Twilio::Values.of({
        'includeTraits' => include_traits,
        'pageSize' => page_size,
        'pageToken' => page_token,
        'orderBy' => order_by,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, params: params, headers: headers)
    TraitGroupInstance.new(
        @version,
        payload,
        store_id: @solution[:store_id],
        trait_group_name: @solution[:trait_group_name],
    )
end

#fetch_with_metadata(include_traits: :unset, page_size: :unset, page_token: :unset, order_by: :unset) ⇒ TraitGroupInstance

Fetch the TraitGroupInstanceMetadata

Parameters:

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

    Whether to include trait definitions in the response

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

    The maximum number of items to return per page, maximum of 100.

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

    The token for the page of results to retrieve.

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

    Either ‘ASC’ or ‘DESC’ to sort results ascending or descending respectively.

Returns:



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 506

def (
  include_traits: :unset, 
  page_size: :unset, 
  page_token: :unset, 
  order_by: :unset
)

    params = Twilio::Values.of({
        'includeTraits' => include_traits,
        'pageSize' => page_size,
        'pageToken' => page_token,
        'orderBy' => order_by,
    })
    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, params: params, headers: headers)
    trait_group_instance = TraitGroupInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
        trait_group_name: @solution[:trait_group_name],
    )
    TraitGroupInstanceMetadata.new(
        @version,
        trait_group_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



606
607
608
609
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 606

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

#patch(if_match: :unset, patch_trait_group_request: :unset) ⇒ TraitGroupInstance

Patch the TraitGroupInstance

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_trait_group_request (PatchTraitGroupRequest) (defaults to: :unset)

Returns:



545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 545

def patch(
  if_match: :unset,
  patch_trait_group_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_trait_group_request.to_json)
    TraitGroupInstance.new(
        @version,
        payload,
        store_id: @solution[:store_id],
        trait_group_name: @solution[:trait_group_name],
    )
end

#patch_with_metadata(if_match: :unset, patch_trait_group_request: :unset) ⇒ TraitGroupInstance

Patch the TraitGroupInstanceMetadata

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_trait_group_request (PatchTraitGroupRequest) (defaults to: :unset)

Returns:



570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 570

def (
  if_match: :unset,
patch_trait_group_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_trait_group_request.to_json)
    trait_group_instance = TraitGroupInstance.new(
        @version,
        response.body,
        store_id: @solution[:store_id],
        trait_group_name: @solution[:trait_group_name],
    )
    TraitGroupInstanceMetadata.new(
        @version,
        trait_group_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



599
600
601
602
# File 'lib/twilio-ruby/rest/memory/v1/trait_group.rb', line 599

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