-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
64 lines (58 loc) · 1.48 KB
/
code.power
File metadata and controls
64 lines (58 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Get available issue templates for a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
*
* @return array|null
* @since 3.2.0
**/
public function issue(string $owner, string $repo): ?array
{
// Build the request path.
$path = "/repos/{$owner}/{$repo}/issue_templates";
// Get the URI.
$uri = $this->uri->get($path);
// Send the GET request.
return $this->response->get(
$this->http->get($uri)
);
}
/**
* Create a repository using a template.
*
* @param string $templateOwner The template owner's name.
* @param string $templateRepo The template repository name.
* @param string $name The name of the new repository.
* @param array $options Optional. Additional options for the new repository.
*
* @return object|null
* @since 3.2.0
**/
public function repo(
string $templateOwner,
string $templateRepo,
string $name,
array $options = []
): ?object
{
// Build the request path.
$path = "/repos/{$templateOwner}/{$templateRepo}/generate";
// Set the repo data.
$data = new \stdClass();
$data->name = $name;
foreach ($options as $key => $value)
{
if ($value !== null)
{
$data->{$key} = $value;
}
}
// Send the post request.
return $this->response->get(
$this->http->post(
$this->uri->get($path),
json_encode($data)
), 201
);
}