Class: Twilio::REST::FlexApi::V2::FlexUserContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/flex_api/v2/flex_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, instance_sid, flex_user_sid) ⇒ FlexUserContext

Initialize the FlexUserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • instance_sid (String)

    The unique ID created by Twilio to identify a Flex instance.

  • flex_user_sid (String)

    The unique id for the flex user.



50
51
52
53
54
55
56
57
58
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 50

def initialize(version, instance_sid, flex_user_sid)
    super(version)

    # Path Solution
    @solution = { instance_sid: instance_sid, flex_user_sid: flex_user_sid,  }
    @uri = "/Instances/#{@solution[:instance_sid]}/Users/#{@solution[:flex_user_sid]}"

    
end

Instance Method Details

#fetchFlexUserInstance

Fetch the FlexUserInstance

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 62

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



131
132
133
134
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 131

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

#to_sObject

Provide a user friendly representation



124
125
126
127
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 124

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

#update(first_name: :unset, last_name: :unset, email: :unset, friendly_name: :unset, user_sid: :unset, locale: :unset) ⇒ FlexUserInstance

Update the FlexUserInstance

Parameters:

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

    First name of the User.

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

    Last name of the User.

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

    Email of the User.

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

    Friendly name of the User.

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

    The unique SID identifier of the Twilio Unified User.

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

    The locale preference of the user.

Returns:



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 88

def update(
    first_name: :unset, 
    last_name: :unset, 
    email: :unset, 
    friendly_name: :unset, 
    user_sid: :unset, 
    locale: :unset
)

    data = Twilio::Values.of({
        'FirstName' => first_name,
        'LastName' => last_name,
        'Email' => email,
        'FriendlyName' => friendly_name,
        'UserSid' => user_sid,
        'Locale' => locale,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    FlexUserInstance.new(
        @version,
        payload,
        instance_sid: @solution[:instance_sid],
        flex_user_sid: @solution[:flex_user_sid],
    )
end