Class: Twilio::REST::Chat::V1::ServiceContext::UserInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, 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.



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 289

def initialize(version, payload , service_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'attributes' => payload['attributes'],
        'friendly_name' => payload['friendly_name'],
        'role_sid' => payload['role_sid'],
        'identity' => payload['identity'],
        'is_online' => payload['is_online'],
        'is_notifiable' => payload['is_notifiable'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'joined_channels_count' => payload['joined_channels_count'] == nil ? payload['joined_channels_count'] : payload['joined_channels_count'].to_i,
        'links' => payload['links'],
        'url' => payload['url'],
    }

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

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/api/rest/account) that created the User resource.

Returns:



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

def 
    @properties['account_sid']
end

#attributesString

Returns The JSON string that stores application-specific data. Note If this property has been assigned a value, it’s only displayed in a FETCH action that returns a single resource; otherwise, it’s null. If the attributes have not been set, ‘{}` is returned.

Returns:

  • (String)

    The JSON string that stores application-specific data. Note If this property has been assigned a value, it’s only displayed in a FETCH action that returns a single resource; otherwise, it’s null. If the attributes have not been set, ‘{}` is returned.



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

def attributes
    @properties['attributes']
end

#contextUserContext

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

Returns:



319
320
321
322
323
324
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 319

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

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



382
383
384
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 382

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



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

def date_updated
    @properties['date_updated']
end

#deleteBoolean

Delete the UserInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



413
414
415
416
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 413

def delete

    context.delete
end

#fetchUserInstance

Fetch the UserInstance

Returns:



421
422
423
424
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 421

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource.



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

def friendly_name
    @properties['friendly_name']
end

#identityString

Returns The application-defined string that uniquely identifies the resource’s User within the [Service](www.twilio.com/docs/api/chat/rest/services). This value is often a username or an email address. See [access tokens](www.twilio.com/docs/api/chat/guides/create-tokens) for more info.

Returns:



364
365
366
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 364

def identity
    @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



461
462
463
464
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 461

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

#is_notifiableBoolean

Returns Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, ‘true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service’s ‘reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service’s ‘reachability_enabled` is `true`.

Returns:

  • (Boolean)

    Whether the User has a potentially valid Push Notification registration (APN or GCM) for the Service instance. If at least one registration exists, ‘true`; otherwise `false`. This value is only returned by Fetch actions that return a single resource and `null` is always returned by a Read action. This value is `null` if the Service’s ‘reachability_enabled` is `false`, and if the User has never had a notification registration, even if the Service’s ‘reachability_enabled` is `true`.



376
377
378
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 376

def is_notifiable
    @properties['is_notifiable']
end

#is_onlineBoolean

Returns Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and ‘null` is always returned by a Read action. This value is `null` if the Service’s ‘reachability_enabled` is `false`, if the User has never been online for the Service instance, even if the Service’s ‘reachability_enabled` is `true`.

Returns:

  • (Boolean)

    Whether the User is actively connected to the Service instance and online. This value is only returned by Fetch actions that return a single resource and ‘null` is always returned by a Read action. This value is `null` if the Service’s ‘reachability_enabled` is `false`, if the User has never been online for the Service instance, even if the Service’s ‘reachability_enabled` is `true`.



370
371
372
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 370

def is_online
    @properties['is_online']
end

#joined_channels_countString

Returns The number of Channels this User is a Member of.

Returns:

  • (String)

    The number of Channels this User is a Member of.



394
395
396
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 394

def joined_channels_count
    @properties['joined_channels_count']
end

Returns The absolute URLs of the [Channel](www.twilio.com/docs/chat/api/channels) and [Binding](www.twilio.com/docs/chat/rest/bindings-resource) resources related to the user.

Returns:



400
401
402
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 400

def links
    @properties['links']
end

#role_sidString

Returns The SID of the [Role](www.twilio.com/docs/api/chat/rest/roles) assigned to the user.

Returns:



358
359
360
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 358

def role_sid
    @properties['role_sid']
end

#service_sidString

Returns The SID of the [Service](www.twilio.com/docs/api/chat/rest/services) the resource is associated with.

Returns:



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

def service_sid
    @properties['service_sid']
end

#sidString

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.



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

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



454
455
456
457
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 454

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

#update(role_sid: :unset, attributes: :unset, friendly_name: :unset) ⇒ UserInstance

Update the UserInstance

Parameters:

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

    The SID of the [Role](www.twilio.com/docs/api/chat/rest/roles) assigned to this user.

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

    A valid JSON string that contains application-specific data.

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

    A descriptive string that you create to describe the resource. It is often used for display purposes.

Returns:



432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 432

def update(
    role_sid: :unset, 
    attributes: :unset, 
    friendly_name: :unset
)

    context.update(
        role_sid: role_sid, 
        attributes: attributes, 
        friendly_name: friendly_name, 
    )
end

#urlString

Returns The absolute URL of the User resource.

Returns:

  • (String)

    The absolute URL of the User resource.



406
407
408
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 406

def url
    @properties['url']
end

#user_channelsuser_channels

Access the user_channels

Returns:



448
449
450
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 448

def user_channels
    context.user_channels
end