3 namespace app\Github\API\Hooks
;
5 use app\Github\API\Call
;
6 use app\Github\Exception\RequestException
;
7 use http\Client\Request
;
8 use http\Client\Response
;
10 class UpdateHook
extends Call
13 $url = $this->url
->mod(uri_template("./repos/{+repo}/hooks{/id}", $this->args
));
14 $request = new Request("PATCH", $url, [
15 "Authorization" => "token ". $this->api
->getToken(),
16 "Accept" => $this->config
->api
->accept
,
17 "Content-Type" => "application/json",
21 if (!empty($this->args
["conf"]["tag"])) {
24 if (!empty($this->args
["conf"]["release"])) {
25 $events[] = "release";
28 "zend" => (int)!empty($this->args
["conf"]["zend"]),
29 "pecl" => (int)!empty($this->args
["conf"]["pecl"]),
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?
36 $request->getBody()->append(json_encode(compact("events", "config")));
40 function response(Response
$response) {
41 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
42 throw new RequestException($response);