3 namespace app\Github\Create
;
6 use app\Github\Exception\WebhookCreateFailed
;
7 use http\Client\Request
;
9 class Webhook
extends Create
11 function getRequest() {
12 $url = $this->url
->mod("./repos/". $this->args
["repo"] ."/hooks");
13 $request = new Request("POST", $url, [
14 "Accept" => "application/vnd.github.v3+json",
15 "Content-Type" => "application/json",
16 "Authorization" => "token " . $this->api
->getToken(),
19 if (!empty($this->args
["conf"]["tag"])) {
22 if (!empty($this->args
["conf"]["release"])) {
23 $events[] = "release";
26 $request->getBody()->append(json_encode([
30 "url" => $this->config
->hook
->url
,
31 "content_type" => $this->config
->hook
->content_type
,
32 "insecure_ssl" => $this->config
->hook
->insecure_ssl
,
33 "secret" => $this->config
->client
->secret
, // FIXME: bad idea?
39 function getException($message, $code, $previous = null) {
40 return new WebhookCreateFailed($message, $code, $previous);