Class: Twilio::REST::FrontlineApi::V1::UserContext

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

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the User resource to fetch. This value can be either the `sid` or the `identity` of the User resource to fetch.


74
75
76
77
78
79
80
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 74

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/Users/#{@solution[:sid]}"
end

Instance Method Details

#fetchUserInstance

Fetch the UserInstance

Returns:


85
86
87
88
89
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 85

def fetch
  payload = @version.fetch('GET', @uri)

  UserInstance.new(@version, payload, sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


116
117
118
119
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 116

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

#to_sObject

Provide a user friendly representation


109
110
111
112
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 109

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

#update(friendly_name: :unset, avatar: :unset, state: :unset) ⇒ UserInstance

Update the UserInstance

Parameters:

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

    The string that you assigned to describe the User.

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

    The avatar URL which will be shown in Frontline application.

  • state (user.StateType) (defaults to: :unset)

    Current state of this user. Can be either `active` or `deactivated` and defaults to `active`

Returns:


99
100
101
102
103
104
105
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 99

def update(friendly_name: :unset, avatar: :unset, state: :unset)
  data = Twilio::Values.of({'FriendlyName' => friendly_name, 'Avatar' => avatar, 'State' => state, })

  payload = @version.update('POST', @uri, data: data)

  UserInstance.new(@version, payload, sid: @solution[:sid], )
end