Class: GitlabQuality::TestTooling::Slack::PostToSlack

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_quality/test_tooling/slack/post_to_slack.rb

Direct Known Subclasses

PostToSlackDry

Instance Method Summary collapse

Constructor Details

#initialize(slack_webhook_url:, channel:, message:, username:, icon_emoji:) ⇒ PostToSlack

Returns a new instance of PostToSlack.



7
8
9
10
11
12
13
# File 'lib/gitlab_quality/test_tooling/slack/post_to_slack.rb', line 7

def initialize(slack_webhook_url:, channel:, message:, username:, icon_emoji:)
  @slack_webhook_url = slack_webhook_url
  @channel = channel
  @message = message
  @username = username
  @icon_emoji = icon_emoji
end

Instance Method Details

#invoke!Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitlab_quality/test_tooling/slack/post_to_slack.rb', line 15

def invoke!
  params = {}
  params['channel'] = channel
  params['username'] = username
  params['icon_emoji'] = icon_emoji
  params['text'] = message

  Support::HttpRequest.make_http_request(
    method: 'post',
    url: slack_webhook_url,
    params: params,
    show_response: true
  )
end