Repository navigation
Expand file tree
/
Copy pathIntegrations.php
More file actions
90 lines (82 loc) · 2.54 KB
/
Copy pathIntegrations.php
File metadata and controls
90 lines (82 loc) · 2.54 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace Github\Api;
/**
* @link https://developer.github.com/v3/integrations/
* @author Nils Adermann <naderman@naderman.de>
*/
class Integrations extends AbstractApi
{
/**
* Create an access token for an installation
*
* @param int $installationId An integration installation id
* @param int $userId An optional user id on behalf of whom the
* token will be requested
*
* @return array token and token metadata
*/
public function createInstallationToken($installationId, $userId = null)
{
$parameters = array();
if ($userId) {
$parameters['user_id'] = $userId;
}
return $this->post('/installations/'.rawurlencode($installationId).'/access_tokens', $parameters);
}
/**
* Find all installations for the authenticated integration.
*
* @link https://developer.github.com/v3/integrations/#find-installations
*
* @return array
*/
public function findInstallations()
{
return $this->get('/integration/installations');
}
/**
* List repositories that are accessible to the authenticated installation.
*
* @link https://developer.github.com/v3/integrations/installations/#list-repositories
*
* @param int $userId
*
* @return array
*/
public function listRepositories($userId = null)
{
$parameters = array();
if ($userId) {
$parameters['user_id'] = $userId;
}
return $this->get('/installation/repositories', $parameters);
}
/**
* Add a single repository to an installation.
*
* @link https://developer.github.com/v3/integrations/installations/#add-repository-to-installation
*
* @param int $installationId
* @param int $repositoryId
*
* @return array
*/
public function addRepository($installationId, $repositoryId)
{
return $this->put('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
}
/**
* Remove a single repository from an installation.
*
* @link https://developer.github.com/v3/integrations/installations/#remove-repository-from-installation
*
* @param int $installationId
* @param int $repositoryId
*
* @return array
*/
public function removeRepository($installationId, $repositoryId)
{
return $this->delete('/installations/'.rawurlencode($installationId).'/repositories/'.rawurlencode($repositoryId));
}
}