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