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

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

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

  • account_sid (String) —

    The SID of the Account that created this User resource.

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

    The SID of the Call resource to fetch.



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 283

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.



334
335
336
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 334

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:



307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 307

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

#fetch ⇒ UserInstance

Fetch the UserInstance

Returns:



359
360
361
362
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 359

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.



328
329
330
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 328

def friendly_name
    @properties['friendly_name']
end

#identity ⇒ String

Returns The application-defined string that uniquely identifies the resource's User. This value is often a username or an email address, and is case-sensitive.

Returns:

  • (String) —

    The application-defined string that uniquely identifies the resource's User. This value is often a username or an email address, and is case-sensitive.



322
323
324
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 322

def identity
    @properties['identity']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



395
396
397
398
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 395

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. Defaults to false for new users.

Returns:

  • (Boolean) —

    Whether the User is available for new conversations. Defaults to false for new users.



346
347
348
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 346

def is_available
    @properties['is_available']
end

#sid ⇒ String

Returns The unique string that we created to identify the User resource.

Returns:

  • (String) —

    The unique string that we created to identify the User resource.



316
317
318
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 316

def sid
    @properties['sid']
end

#state ⇒ StateType

Returns:

  • (StateType)


340
341
342
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 340

def state
    @properties['state']
end

#to_s ⇒ Object

Provide a user friendly representation



388
389
390
391
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 388

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 (StateType) (defaults to: :unset)
  • 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:



371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 371

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 API resource URL for this user.

Returns:

  • (String) —

    An absolute API resource URL for this user.



352
353
354
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 352

def url
    @properties['url']
end