Class: FightClub::Commenter

Inherits:
Object
  • Object
show all
Defined in:
lib/fight_club/commenter.rb

Class Method Summary collapse

Class Method Details

.comment(pr, message) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fight_club/commenter.rb', line 3

def self.comment(pr, message)
  unless FightClub.config.comment_check.call(pr, message)
    HTTParty.post(
      pr["_links"]["comments"]["href"],
      body: {
        body: message,
      }.to_json,
      headers: {
        'Content-Type' => 'application/json',
        'User-Agent' => 'ruby',
        "Authorization" => "token #{FightClub.config.oauth}"
      }
    )

    FightClub.config.save_comment.call(pr, message)
    Logger.new(STDOUT).info "Left a comment on #{pr["number"]} with message: #{message}"
  end
end