inital commit
[pharext/pharext.org] / app / Github / Fetch / Repo.php
1 <?php
2
3 namespace app\Github\Fetch;
4
5 use app\Github\Exception\ReposFetchFailed;
6 use app\Github\Fetch;
7
8 use http\Client\Request;
9
10 class Repo extends Fetch
11 {
12 function getRequest() {
13 $url = $this->url->mod("/repos/" . $this->args["repo"]);
14 return new Request("GET", $url, [
15 "Accept" => "application/vnd.github.v3+json",
16 "Authorization" => "token " . $this->api->getToken(),
17 ]);
18 }
19
20 function getException($message, $code, $previous = null) {
21 return new ReposFetchFailed($message, $code, $previous);
22 }
23
24 function getCacheKey() {
25 return $this->api->getCacheKey(sprintf("repo:%s", $this->args["repo"]));
26 }
27 }