Class: Twilio::REST::FrontlineApi::V1::UserInstance

Inherits:
InstanceResource 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, payload, sid: nil) ⇒ UserInstance

Initialize the UserInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • sid (String) (defaults to: nil) —

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



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 141

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'identity' => payload['identity'],
      'friendly_name' => payload['friendly_name'],
      'avatar' => payload['avatar'],
      'state' => payload['state'],
      'is_available' => payload['is_available'],
      'url' => payload['url'],
  }

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

Instance Method Details

#avatar ⇒ String

Returns The avatar URL which will be shown in Frontline application.

Returns:

  • (String) —

    The avatar URL which will be shown in Frontline application



191
192
193
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 191

def avatar
  @properties['avatar']
end

#context ⇒ UserContext

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

Returns:



164
165
166
167
168
169
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 164

def context
  unless @instance_context
    @instance_context = UserContext.new(@version, @params['sid'], )
  end
  @instance_context
end

#fetch ⇒ UserInstance

Fetch the UserInstance

Returns:



216
217
218
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 216

def fetch
  context.fetch
end

#friendly_name ⇒ String

Returns The string that you assigned to describe the User.

Returns:

  • (String) —

    The string that you assigned to describe the User



185
186
187
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 185

def friendly_name
  @properties['friendly_name']
end

#identity ⇒ String

Returns The string that identifies the resource's User.

Returns:

  • (String) —

    The string that identifies the resource's User



179
180
181
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 179

def identity
  @properties['identity']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



250
251
252
253
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 250

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

#is_available ⇒ Boolean

Returns Whether the User is available for new conversations.

Returns:

  • (Boolean) —

    Whether the User is available for new conversations



203
204
205
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 203

def is_available
  @properties['is_available']
end

#sid ⇒ String

Returns The unique string that identifies the resource.

Returns:

  • (String) —

    The unique string that identifies the resource



173
174
175
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 173

def sid
  @properties['sid']
end

#state ⇒ user.StateType

Returns Current state of this user.

Returns:

  • (user.StateType) —

    Current state of this user



197
198
199
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 197

def state
  @properties['state']
end

#to_s ⇒ Object

Provide a user friendly representation



243
244
245
246
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 243

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

#update(friendly_name: :unset, avatar: :unset, state: :unset, is_available: :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.

  • is_available (Boolean) (defaults to: :unset) —

    Whether the User is available for new conversations. Set to false to prevent User from receiving new inbound conversations if you are using Pool Routing.

Returns:



232
233
234
235
236
237
238
239
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 232

def update(friendly_name: :unset, avatar: :unset, state: :unset, is_available: :unset)
  context.update(
      friendly_name: friendly_name,
      avatar: avatar,
      state: state,
      is_available: is_available,
  )
end

#url ⇒ String

Returns An absolute URL for this user.

Returns:

  • (String) —

    An absolute URL for this user.



209
210
211
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 209

def url
  @properties['url']
end