3 namespace app\Github\API\Hooks
;
5 class UpdateHook
extends \app\Github\API\Call
7 function enqueue(callable
$callback) {
8 $url = $this->url
->mod(uri_template("./repos/{+repo}/hooks{/id}", $this->args
));
9 $request = new \http\Client\
Request("PATCH", $url, [
10 "Authorization" => "token ". $this->api
->getToken(),
11 "Accept" => $this->config
->api
->accept
,
12 "Content-Type" => "application/json",
16 if (!empty($this->args
["conf"]["tag"])) {
19 if (!empty($this->args
["conf"]["release"])) {
20 $events[] = "release";
23 "zend" => (int)!empty($this->args
["conf"]["zend"]),
24 "pecl" => (int)!empty($this->args
["conf"]["pecl"]),
25 "url" => $this->config
->hook
->url
,
26 "content_type" => $this->config
->hook
->content_type
,
27 "insecure_ssl" => $this->config
->hook
->insecure_ssl
,
28 "secret" => $this->config
->client
->secret
, // FIXME: bad idea?
31 $request->getBody()->append(json_encode(compact("events", "config")));
32 $this->api
->getClient()->enqueue($request, function($response) use($callback) {
33 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
34 throw new \app\Github\Exception\
RequestException($response);
36 $this->result
= [$json];