module Boty module Slack class Users include Slack::URL url "https://slack.com/api/users" 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 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 def by_name(name) list.find { |user| user.name == name } end end end end