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 CreateHook
extends Call
13 $url = $this->url
->mod("./repos/". $this->args
["repo"] ."/hooks");
14 $request = new Request("POST", $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 $request->getBody()->append(json_encode([
32 "zend" => (int)!empty($this->args
["conf"]["zend"]),
33 "pecl" => (int)!empty($this->args
["conf"]["pecl"]),
34 "url" => $this->config
->hook
->url
,
35 "content_type" => $this->config
->hook
->content_type
,
36 "insecure_ssl" => $this->config
->hook
->insecure_ssl
,
37 "secret" => $this->config
->client
->secret
, // FIXME: bad idea?
44 function response(Response
$response) {
45 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
46 throw new RequestException($response);