Module: Slack::Web::Api::Endpoints::Reactions

Included in:
Slack::Web::Api::Endpoints
Defined in:
lib/slack/web/api/endpoints/reactions.rb

Instance Method Summary collapse

Instance Method Details

#reactions_add(options = {}) ⇒ Object

Adds a reaction to an item.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel where the message to add reaction to was posted.

  • :name (string)

    Reaction (emoji) name.

  • :timestamp (string)

    Timestamp of the message to add reaction to.

Raises:

  • (ArgumentError)

See Also:



20
21
22
23
24
25
26
# File 'lib/slack/web/api/endpoints/reactions.rb', line 20

def reactions_add(options = {})
  raise ArgumentError, 'Required arguments :channel missing' if options[:channel].nil?
  raise ArgumentError, 'Required arguments :name missing' if options[:name].nil?
  raise ArgumentError, 'Required arguments :timestamp missing' if options[:timestamp].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('reactions.add', options)
end

#reactions_get(options = {}) ⇒ Object

Gets reactions for an item.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :channel (channel)

    Channel where the message to get reactions for was posted.

  • :file (file)

    File to get reactions for.

  • :file_comment (string)

    File comment to get reactions for.

  • :full (boolean)

    If true always return the complete reaction list.

  • :timestamp (string)

    Timestamp of the message to get reactions for.

See Also:



43
44
45
46
# File 'lib/slack/web/api/endpoints/reactions.rb', line 43

def reactions_get(options = {})
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('reactions.get', options)
end

#reactions_list(options = {}) ⇒ Object

Lists reactions made by a user.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :cursor (string)

    Parameter for pagination. Set cursor equal to the next_cursor attribute returned by the previous request’s response_metadata. This parameter is optional, but pagination is mandatory: the default value simply fetches the first “page” of the collection. See pagination for more details.

  • :full (boolean)

    If true always return the complete reaction list.

  • :limit (integer)

    The maximum number of items to return. Fewer than the requested number of items may be returned, even if the end of the list hasn’t been reached.

  • :team_id (string)

    encoded team id to list reactions in, required if org token is used.

  • :user (user)

    Show reactions made by this user. Defaults to the authed user.

See Also:



63
64
65
66
67
68
69
70
71
72
# File 'lib/slack/web/api/endpoints/reactions.rb', line 63

def reactions_list(options = {})
  options = options.merge(user: users_id(options)['user']['id']) if options[:user]
  if block_given?
    Pagination::Cursor.new(self, :reactions_list, options).each do |page|
      yield page
    end
  else
    post('reactions.list', options)
  end
end

#reactions_remove(options = {}) ⇒ Object

Removes a reaction from an item.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :name (string)

    Reaction (emoji) name.

  • :channel (channel)

    Channel where the message to remove reaction from was posted.

  • :file (file)

    File to remove reaction from.

  • :file_comment (string)

    File comment to remove reaction from.

  • :timestamp (string)

    Timestamp of the message to remove reaction from.

Raises:

  • (ArgumentError)

See Also:



89
90
91
92
93
# File 'lib/slack/web/api/endpoints/reactions.rb', line 89

def reactions_remove(options = {})
  raise ArgumentError, 'Required arguments :name missing' if options[:name].nil?
  options = options.merge(channel: conversations_id(options)['channel']['id']) if options[:channel]
  post('reactions.remove', options)
end