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