-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathhooks.js
More file actions
65 lines (50 loc) · 1.37 KB
/
hooks.js
File metadata and controls
65 lines (50 loc) · 1.37 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
/*
# Hooks features
## Setup
```javascript
const GitHubClient = require('../libs/GitHubClient.js').GitHubClient;
const hooks = require('../libs/features/hooks');
let githubCli = new GitHubClient({
baseUri: "http://github.at.home/api/v3",
token: process.env.TOKEN_GHITHUB_ENTERPRISE
}, hooks); //<-- add hooks features
```
*/
/*
## createHook
- parameter: `owner, repository, hookName, hookConfig, hookEvents, active`
- return: `Promise`
### Description
`createHook` creates a hook for a repository
*/
function createHook({owner, repository, hookName, hookConfig, hookEvents, active}) {
return this.postData({path:`/repos/${owner}/${repository}/hooks`, data:{
name: hookName
, config: hookConfig
, events: hookEvents
, active: active
}}).then(response => {
return response.data;
});
}
/*
## createOrganizationHook
- parameter: `org, hookName, hookConfig, hookEvents, active`
- return: `Promise`
### Description
`createOrganizationHook` creates a hook for an organization
*/
function createOrganizationHook({org, hookName, hookConfig, hookEvents, active}) {
return this.postData({path:`/orgs/${org}/hooks`, data:{
name: hookName
, config: hookConfig
, events: hookEvents
, active: active
}}).then(response => {
return response.data;
});
}
module.exports = {
createHook: createHook,
createOrganizationHook: createOrganizationHook
};