Sha256: 7e4ea2f7ea231a6d6a614ae898e1125e6bcceb5635488b5d9ba324994267b0b7

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

module Slack
  module API
    class Channels < Base
      def all(exclude_archived=false, page: nil)
        responses = with_paging(page) do |pager|
          request :get,
                  'channels.list',
                  exclude_archived: exclude_archived ? 1 : 0,
                  **pager.to_h
        end

        Slack::Channel.parse_all responses, 'channels'
      end

      def archive(id)
        with_nil_response { request :post, 'channels.archive', channel: id }
      end

      def create(name)
        response = request :post, 'channels.create', name: name
        Slack::Channel.parse response, 'channel'
      end

      def find(id)
        response = request :get, 'channels.info', channel: id
        Slack::Channel.parse response, 'channel'
      end

      def unarchive(id)
        with_nil_response { request :post, 'channels.unarchive', channel: id }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
laziness-0.2.6 lib/laziness/api/channels.rb
laziness-0.2.5 lib/laziness/api/channels.rb