Sha256: e6816610c9acf8d3bf1bbad4e3bc6a10082971b30091f4840c9a165611e91c24

Contents?: true

Size: 884 Bytes

Versions: 12

Compression:

Stored size: 884 Bytes

Contents

module Slack
  module Web
    module Api
      module Mixins
        module Groups
          #
          # This method returns a group ID given a group name.
          #
          # @option options [channel] :channel
          #   Group channel to get ID for, prefixed with #.
          def groups_id(options = {})
            name = options[: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
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
slack-ruby-client-0.8.0 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.9 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.8 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.7 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.6 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.5 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.4 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.3 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.2 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.1 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.7.0 lib/slack/web/api/mixins/groups.id.rb
slack-ruby-client-0.6.0 lib/slack/web/api/mixins/groups.id.rb