3 namespace app\Github\API\Releases
;
5 use app\Github\API\Call
;
6 use app\Github\Exception\RequestException
;
7 use http\Client\Request
;
10 class CreateReleaseAsset
extends Call
12 function enqueue(callable
$callback) {
13 $body = new Body(fopen($this->args
["asset"], "rb"));
14 $request = new Request("POST", $this->args
["url"], [
15 "Authorization" => "token ". $this->api
->getToken(),
16 "Accept" => $this->config
->api
->accept
,
17 "Content-Type" => $this->args
["type"],
19 $this->api
->getClient()->enqueue($request, function($response) use($callback) {
20 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
21 throw new RequestException($response);
23 $this->result
= [$json];