3 namespace app\Github\API\Repos
;
5 use app\Github\API\Call
;
6 use app\Github\Exception\RequestException
;
8 use http\Client\Request
;
10 class ListRepos
extends Call
12 function enqueue(callable
$callback) {
13 $url = $this->url
->mod(uri_template("./user/repos{?page,per_page}", $this->args
));
14 $request = new Request("GET", $url, [
15 "Authorization" => "token ". $this->api
->getToken(),
16 "Accept" => $this->config
->api
->accept
,
18 $this->api
->getClient()->enqueue($request, function($response) use($callback) {
19 if ($response->getResponseCode() >= 400 ||
null === ($json = json_decode($response->getBody()))) {
20 throw new RequestException($response);
22 $links = new Links($response->getHeader("Link"));
23 $this->saveToCache([$json, $links]);
24 $callback($json, $links);