Repository navigation
Expand file tree
/
Copy pathHooks.php
More file actions
111 lines (101 loc) · 2.66 KB
/
Copy pathHooks.php
File metadata and controls
111 lines (101 loc) · 2.66 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
namespace Github\Api\Organization;
use Github\Api\AbstractApi;
use Github\Exception\MissingArgumentException;
class Hooks extends AbstractApi
{
/**
* List hooks.
*
* @link https://developer.github.com/v3/orgs/hooks/#list-hooks
*
* @param string $organization
*
* @return array
*/
public function all($organization)
{
return $this->get('/orgs/'.rawurlencode($organization).'/hooks');
}
/**
* Get a single hook.
*
* @link https://developer.github.com/v3/orgs/hooks/#get-single-hook
*
* @param string $organization
* @param int $id
*
* @return array
*/
public function show($organization, $id)
{
return $this->get('/orgs/'.rawurlencode($organization).'/hooks/'.rawurlencode($id));
}
/**
* Create a hook.
*
* @link https://developer.github.com/v3/orgs/hooks/#create-a-hook
*
* @param string $organization
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function create($organization, array $params)
{
if (!isset($params['name'], $params['config'])) {
throw new MissingArgumentException(['name', 'config']);
}
return $this->post('/orgs/'.rawurlencode($organization).'/hooks', $params);
}
/**
* Edit a hook.
*
* @link https://developer.github.com/v3/orgs/hooks/#edit-a-hook
*
* @param string $organization
* @param int $id
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function update($organization, $id, array $params)
{
if (!isset($params['config'])) {
throw new MissingArgumentException(['config']);
}
return $this->patch('/orgs/'.rawurlencode($organization).'/hooks/'.rawurlencode($id), $params);
}
/**
* Ping a hook.
*
* @link https://developer.github.com/v3/orgs/hooks/#ping-a-hook
*
* @param string $organization
* @param int $id
*
* @return null
*/
public function ping($organization, $id)
{
return $this->post('/orgs/'.rawurlencode($organization).'/hooks/'.rawurlencode($id).'/pings');
}
/**
* Delete a hook.
*
* @link https://developer.github.com/v3/orgs/hooks/#delete-a-hook
*
* @param string $organization
* @param int $id
*
* @return null
*/
public function remove($organization, $id)
{
return $this->delete('/orgs/'.rawurlencode($organization).'/hooks/'.rawurlencode($id));
}
}