Class: Boty::Slack::Users

Inherits:
Object
  • Object
show all
Includes:
URL
Defined in:
lib/boty/slack/users.rb

Instance Method Summary collapse

Methods included from URL

get, included

Instance Method Details

#by_name(name) ⇒ Object



23
24
25
# File 'lib/boty/slack/users.rb', line 23

def by_name(name)
  list.find { |user| user.name == name }
end

#info(user_id, parameters = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/boty/slack/users.rb', line 7

def info(user_id, parameters = {})
  defaults = { user: user_id }
  url = parameterize defaults.merge(parameters), path: ".info"
  info = URL.get url
  Slack::User.new info["user"]
end

#list(parameters = {}) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/boty/slack/users.rb', line 14

def list(parameters = {})
  # TODO: this call should be cached.
  url = parameterize parameters, path: ".list"
  users = URL.get url
  users["members"].map { |info|
    Slack::User.new info
  }
end