flush
[pharext/pharext.org] / app / Github / Create / Release.php
1 <?php
2
3 namespace app\Github\Create;
4
5 use app\Github\Create;
6 use app\Github\Exception\ReleaseCreateFailed;
7 use http\Client\Request;
8
9 class Release extends Create
10 {
11 function getRequest() {
12 $url = $this->url->mod("/repos/". $this->args["repo"] ."/releases");
13 $request = new Request("POST", $url, [
14 "Accept" => "application/vnd.github.v3+json",
15 "Content-Type" => "application/json",
16 "Authorization" => "token ". $this->api->getToken()
17 ]);
18 $request->getBody()->append(json_encode([
19 "tag_name" => $this->args["tag"]
20 ]));
21 return $request;
22 }
23
24 function getException($message, $code, $previous = null) {
25 return new ReleaseCreateFailed($message, $code, $previous);
26 }
27 }