-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathorganizations.js
More file actions
68 lines (51 loc) · 1.43 KB
/
organizations.js
File metadata and controls
68 lines (51 loc) · 1.43 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
/*
# Organizations features
## Setup
```javascript
const GitHubClient = require('../libs/GitHubClient.js').GitHubClient;
const organizations = require('../libs/features/organizations');
let githubCli = new GitHubClient({
baseUri: "http://github.at.home/api/v3",
token: process.env.TOKEN_GHITHUB_ENTERPRISE
}, organizations); //<-- add organizations features
```
*/
/*
## createOrganization
- parameters: `login, admin, profile_name`
- return: `Promise`
```
login: The organization's username.
admin: The login of the user who will manage this organization.
profile_name: The organization's display name.
```
### Description
`createOrganization` creates an organization
*/
function createOrganization({login, admin, profile_name}) {
return this.postData({path:`/admin/organizations`, data:{
login: login,
admin: admin,
profile_name: profile_name
}}).then(response => {
return response.data;
});
}
/*
## addOrganizationMembership
- parameters: `org, userName, role`
- return: `Promise`
### Description
`addOrganizationMembership` adds a role for a user of an organization
*/
function addOrganizationMembership({org, userName, role}) {
return this.putData({path:`/orgs/${org}/memberships/${userName}`, data:{
role: role // member, maintener
}}).then(response => {
return response.data;
});
}
module.exports = {
createOrganization: createOrganization,
addOrganizationMembership: addOrganizationMembership
};