class RocketChat::User

Rocket.Chat User

Attributes

data[R]

Raw user data

Public Class Methods

new(data) click to toggle source

@param [Hash] data Raw user data

# File lib/rocket_chat/user.rb, line 14
def initialize(data)
  @data = Util.stringify_hash_keys data
end

Public Instance Methods

active?() click to toggle source

User active

# File lib/rocket_chat/user.rb, line 64
def active?
  data['active']
end
email() click to toggle source

User email

# File lib/rocket_chat/user.rb, line 34
def email
  emails.first && emails.first['address']
end
email_verified?() click to toggle source

User email verified

# File lib/rocket_chat/user.rb, line 39
def email_verified?
  emails.first && emails.first['verified']
end
emails() click to toggle source

User emails

# File lib/rocket_chat/user.rb, line 29
def emails
  data['emails'] || []
end
id() click to toggle source

User ID

# File lib/rocket_chat/user.rb, line 19
def id
  data['_id']
end
inspect() click to toggle source
# File lib/rocket_chat/user.rb, line 88
def inspect
  format(
    '#<%<class_name>s:0x%<object_id>p @id="%<id>s" @username="%<username>s" @active="%<active>s">',
    class_name: self.class.name,
    object_id: object_id,
    id: id,
    username: username,
    active: active?
  )
end
name() click to toggle source

User name

# File lib/rocket_chat/user.rb, line 24
def name
  data['name']
end
roles() click to toggle source

User roles

# File lib/rocket_chat/user.rb, line 69
def roles
  data['roles']
end
rooms() click to toggle source

User rooms

# File lib/rocket_chat/user.rb, line 74
def rooms
  return [] unless data['rooms'].is_a? Array

  data['rooms'].map do |hash|
    # the users.info API returns the rooms data with the subscription ID as `_id` and room ID as `rid`
    if hash['rid']
      hash['subscription_id'] = hash['_id']
      hash['_id'] = hash['rid']
    end

    RocketChat::Room.new hash
  end
end
status() click to toggle source

User status

# File lib/rocket_chat/user.rb, line 44
def status
  data['status']
end
status_connection() click to toggle source

User connection status

# File lib/rocket_chat/user.rb, line 49
def status_connection
  data['statusConnection']
end
username() click to toggle source

User username

# File lib/rocket_chat/user.rb, line 54
def username
  data['username']
end
utc_offset() click to toggle source

User UTC offset

# File lib/rocket_chat/user.rb, line 59
def utc_offset
  data['utcOffset']
end