Class: Twilio::REST::Memory::V1::ProfileInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, store_id: nil, profile_id: nil) ⇒ ProfileInstance

Initialize the ProfileInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Profile resource.

  • sid (String)

    The SID of the Call resource to fetch.



603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 603

def initialize(version, payload , store_id: nil, profile_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'id' => payload['id'],
        'message' => payload['message'],
        'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
        'traits' => payload['traits'],
        'profiles' => payload['profiles'],
        'meta' => payload['meta'],
    }

    # Context
    @instance_context = nil
    @params = { 'store_id' => store_id  || @properties['store_id']  ,'profile_id' => profile_id  || @properties['profile_id']  , }
end

Instance Method Details

#contextProfileContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



627
628
629
630
631
632
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 627

def context
    unless @instance_context
        @instance_context = ProfileContext.new(@version , @params['store_id'], @params['profile_id'])
    end
    @instance_context
end

#created_atTime

Returns The time the profile was created.

Returns:

  • (Time)

    The time the profile was created.



648
649
650
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 648

def created_at
    @properties['created_at']
end

#deleteBoolean

Delete the ProfileInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



673
674
675
676
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 673

def delete

    context.delete
end

#fetch(trait_groups: :unset) ⇒ ProfileInstance

Fetch the ProfileInstance

Parameters:

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

    Comma separated list of trait group names to include.

Returns:



682
683
684
685
686
687
688
689
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 682

def fetch(
  trait_groups: :unset
)

    context.fetch(
        trait_groups: trait_groups, 
    )
end

#idString

Returns The canonical profile ID.

Returns:

  • (String)

    The canonical profile ID.



636
637
638
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 636

def id
    @properties['id']
end

#inspectObject

Provide a detailed, user friendly representation



712
713
714
715
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 712

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Memory.V1.ProfileInstance #{values}>"
end

#messageString

Returns:

  • (String)


642
643
644
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 642

def message
    @properties['message']
end

#metaProfilesMeta

Returns:

  • (ProfilesMeta)


666
667
668
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 666

def meta
    @properties['meta']
end

#patch(profile_patch: nil) ⇒ ProfileInstance

Patch the ProfileInstance

Parameters:

  • profile_patch (ProfilePatch) (defaults to: nil)

Returns:



695
696
697
698
699
700
701
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 695

def patch(profile_patch: nil
)

    context.patch(
        profile_patch: profile_patch, 
    )
end

#profilesArray<String>

Returns:

  • (Array<String>)


660
661
662
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 660

def profiles
    @properties['profiles']
end

#to_sObject

Provide a user friendly representation



705
706
707
708
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 705

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Memory.V1.ProfileInstance #{values}>"
end

#traitsHash<String, Hash<String, Object>>

Returns Multiple trait groups.

Returns:

  • (Hash<String, Hash<String, Object>>)

    Multiple trait groups.



654
655
656
# File 'lib/twilio-ruby/rest/memory/v1/profile.rb', line 654

def traits
    @properties['traits']
end