Class: Popper::Action::Webhook

Inherits:
Base
  • Object
show all
Defined in:
lib/popper/action/webhook.rb

Class Method Summary collapse

Methods inherited from Base

action_name, do_action?, next_action, next_run, run

Class Method Details

.check_paramsObject



9
10
11
# File 'lib/popper/action/webhook.rb', line 9

def self.check_params
  @action_config.respond_to?(:webhook_url)
end

.post!(url, subject, body) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/popper/action/webhook.rb', line 13

def self.post!(url, subject, body)
  request_body = { subject: subject, body: body }.to_json

  Faraday.post(
    url,
    request_body,
    "Content-Type" => "application/json"
  )
end

.task(mail, params = {}) ⇒ Object



3
4
5
6
7
# File 'lib/popper/action/webhook.rb', line 3

def self.task(mail, params = {})
  post!(@action_config.webhook_url, mail.subject, mail.utf_body)

  params
end