Module: Slack::Web::Api::Mixins::Users
- Included in:
- Endpoints
- Defined in:
- lib/slack/web/api/mixins/users.id.rb
Instance Method Summary collapse
-
#users_id(options = {}) ⇒ Object
This method returns a user ID given a user name.
Instance Method Details
#users_id(options = {}) ⇒ Object
This method returns a user ID given a user name.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/slack/web/api/mixins/users.id.rb', line 11 def users_id( = {}) name = [:user] throw ArgumentError.new('Required arguments :user missing') if name.nil? return { 'ok' => true, 'user' => { 'id' => name } } unless name[0] == '@' users_list.tap do |list| list['members'].each do |user| return { 'ok' => true, 'user' => { 'id' => user['id'] } } if user['name'] == name[1..-1] end end fail Slack::Web::Api::Error, 'user_not_found' end |