slack-ruby/slack-ruby-client

View on GitHub
lib/slack/web/api/endpoints/pins.rb

Summary

Maintainability
A
1 hr
Test Coverage
# frozen_string_literal: true
# This file was auto-generated by lib/tasks/web.rake

module Slack
  module Web
    module Api
      module Endpoints
        module Pins
          #
          # Pins an item to a channel.
          #
          # @option options [channel] :channel
          #   Channel to pin the messsage to. You must also include a timestamp when pinning messages.
          # @option options [string] :timestamp
          #   Timestamp of the message to pin. You must also include the channel.
          # @see https://api.slack.com/methods/pins.add
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.add.json
          def pins_add(options = {})
            raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
            options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
            post('pins.add', options)
          end

          #
          # Lists items pinned to a channel.
          #
          # @option options [channel] :channel
          #   Channel to get pinned items for.
          # @see https://api.slack.com/methods/pins.list
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.list.json
          def pins_list(options = {})
            raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
            options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
            post('pins.list', options)
          end

          #
          # Un-pins an item from a channel.
          #
          # @option options [channel] :channel
          #   Channel where the item is pinned to.
          # @option options [string] :timestamp
          #   Timestamp of the message to un-pin.
          # @see https://api.slack.com/methods/pins.remove
          # @see https://github.com/slack-ruby/slack-api-ref/blob/master/methods/pins/pins.remove.json
          def pins_remove(options = {})
            raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
            options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
            post('pins.remove', options)
          end
        end
      end
    end
  end
end