Class: SlackbotFrd::SlackMethods::ReactionsAdd

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/slackbot_frd/slack_methods/reactions_add.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, name:, channel: nil, timestamp: nil) ⇒ ReactionsAdd

Returns a new instance of ReactionsAdd.



15
16
17
18
19
20
# File 'lib/slackbot_frd/slack_methods/reactions_add.rb', line 15

def initialize(token:, name:, channel: nil, timestamp: nil)
  @token = token
  @name = name
  @channel = channel
  @timestamp = timestamp
end

Class Method Details

.add(token:, name:, channel: nil, timestamp: nil) ⇒ Object



10
11
12
13
# File 'lib/slackbot_frd/slack_methods/reactions_add.rb', line 10

def self.add(token:, name:, channel: nil, timestamp: nil)
  r = ReactionsAdd.new(token: token, name: name, channel: channel, timestamp: timestamp)
  r.add
end

Instance Method Details

#addObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/slackbot_frd/slack_methods/reactions_add.rb', line 22

def add
  body = {
    token: @token,
    name: @name
  }

  if @channel && @timestamp
    body.merge!({
      channel: @channel,
      timestamp: @timestamp
    })
  end

  @response = self.class.post('', :body => body)
  ValidateSlack.response(@response)
  @response
end