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