Sha256: 6082f37321f64c4edd97a439ade7e2423ee4c106c3b24318cfd11db47adb12e8

Contents?: true

Size: 537 Bytes

Versions: 2

Compression:

Stored size: 537 Bytes

Contents

# frozen_string_literal: true

require 'faraday'

module ExampleHelper
  def self.print_output(line)
    warn line unless ENV.fetch('SUPPRESS_WEBHOOK_MESSAGE', nil) == 'true'
  end

  def self.post_to_slack(body)
    if Config.webhook_url
      print_output 'Posting to Slack ...'
      Faraday.post(
        Config.webhook_url,
        body.to_json,
        'Content-Type' => 'application/json'
      )
    else
      print_output 'Set a "webhook_url" in "./config.rb" in order to test sending this message to Slack.'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
slack-ruby-block-kit-0.25.0 examples/example_helper.rb
slack-ruby-block-kit-0.24.0 examples/example_helper.rb