37 lines
800 B
Ruby
37 lines
800 B
Ruby
class Webhook::IssueCommentClient
|
|
|
|
include Webhook::Client
|
|
|
|
attr_accessor :webhook, :issue, :journal, :sender, :event
|
|
|
|
def initialize(webhook, issue, journal, sender, event)
|
|
@webhook = webhook
|
|
@issue = issue
|
|
@journal = journal
|
|
@sender = sender
|
|
@event = event
|
|
|
|
# 构建client参数
|
|
super({
|
|
uuid: SecureRandom.uuid,
|
|
event: @event,
|
|
webhook: @webhook,
|
|
payload_content: payload_content
|
|
})
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def payload_content
|
|
{
|
|
"action": "created",
|
|
"issue": JSON.parse(@issue.to_builder.target!),
|
|
"journal": JSON.parse(@journal.to_builder.target!),
|
|
"project": JSON.parse(@issue.project.to_builder.target!),
|
|
"sender": JSON.parse(@sender.to_builder.target!),
|
|
"is_pull": false
|
|
}
|
|
end
|
|
end |