3 namespace app\Github\Fetch
;
5 use app\Github\Exception\ContentsFetchFailed
;
7 use http\Client\Request
;
9 class Contents
extends Fetch
11 function getRequest() {
12 $url = $this->url
->mod(sprintf("/repos/%s/contents/%s",
13 $this->args
["repo"], $this->args
["path"]));
14 return new Request("GET", $url, [
15 "Accept" => "application/vnd.github.v3+json",
16 "Authorization" => "token " . $this->api
->getToken()
20 function getException($message, $code, $previous = null) {
21 return new ContentsFetchFailed($message, $code, $previous);
24 function getCacheKey() {
25 return $this->api
->getCacheKey(sprintf("contents:%s:%s",
26 $this->args
["repo"], $this->args
["path"]));