Class: Solicit::PostToSlack

Inherits:
Object
  • Object
show all
Defined in:
app/use_cases/solicit/post_to_slack.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, channel:, username:, payload:) ⇒ PostToSlack

Returns a new instance of PostToSlack.



5
6
7
8
9
10
11
# File 'app/use_cases/solicit/post_to_slack.rb', line 5

def initialize(url:, channel:, username:, payload:)
  @url      = url
  @channel  = channel
  @username = username
  @payload  = payload
  @text     = I18n.t(:"engines.solicit.title", title_options)
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



3
4
5
# File 'app/use_cases/solicit/post_to_slack.rb', line 3

def text
  @text
end

Class Method Details

.perform(*args) ⇒ Object



13
14
15
# File 'app/use_cases/solicit/post_to_slack.rb', line 13

def self.perform(*args)
  new(*args).tap(&:perform)
end

Instance Method Details

#performObject



17
18
19
20
21
22
23
24
25
26
27
# File 'app/use_cases/solicit/post_to_slack.rb', line 17

def perform
  Slack::Notifier.new(@url, channel: @channel, username: @username).ping(
    text: text,
    attachments: [{
      title: I18n.t(:"engines.solicit.review"),
      callback_id: callback_id,
      color: :warning,
      actions: [claim_action],
    }]
  )
end