3 namespace app\Github\API\Releases
;
5 use app\Github\API\Call
;
6 use app\Github\Exception\RequestException
;
7 use http\Client\Request
;
9 class PublishRelease
extends Call
11 function enqueue(callable
$callback) {
12 $url = $this->url
->mod(uri_template("./repos/{+repo}/releases{/id}", $this->args
));
13 $request = new Request("PATCH", $url, [
14 "Authorization" => "token ". $this->api
->getToken(),
15 "Accept" => $this->config
->api
->accept
,
16 "Content-Type" => "application/json",
18 $request->getBody()->append(json_encode([
20 "tag_name" => $this->args
["tag"],
22 $this->api
->getClient()->enqueue($request, function($response) use($callback) {
23 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
24 throw new RequestException($response);
26 $this->result
= [$json];