Skip to content

Commit 09018b6

Browse files
committed
Merge pull request octokit#231 from airpair/master
addTeamMebership, editOrganizationMemebership + fix for querying all pull requests
2 parents 26d3023 + 46130b3 commit 09018b6

File tree

3 files changed

+120
-2
lines changed

3 files changed

+120
-2
lines changed

api/v3.0.0/orgs.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,47 @@ var orgs = module.exports = {
808808
});
809809
};
810810

811+
/** section: github
812+
* orgs#addTeamMembership(msg, callback) -> null
813+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
814+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
815+
*
816+
* ##### Params on the `msg` object:
817+
*
818+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
819+
* - id (String): Required.
820+
* - user (String): Required.
821+
**/
822+
this.addTeamMembership = function(msg, block, callback) {
823+
var self = this;
824+
this.client.httpSend(msg, block, function(err, res) {
825+
if (err)
826+
return self.sendError(err, null, msg, callback);
827+
828+
var ret;
829+
try {
830+
ret = res.data && JSON.parse(res.data);
831+
}
832+
catch (ex) {
833+
if (callback)
834+
callback(new error.InternalServerError(ex.message), res);
835+
return;
836+
}
837+
838+
if (!ret)
839+
ret = {};
840+
if (!ret.meta)
841+
ret.meta = {};
842+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
843+
if (res.headers[header])
844+
ret.meta[header] = res.headers[header];
845+
});
846+
847+
if (callback)
848+
callback(null, ret);
849+
});
850+
};
851+
811852
/** section: github
812853
* orgs#getTeamRepos(msg, callback) -> null
813854
* - msg (Object): Object that contains the parameters and their values to be sent to the server.

api/v3.0.0/routes.json

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,6 +1509,15 @@
15091509
}
15101510
},
15111511

1512+
"add-team-membership": {
1513+
"url": "/teams/:id/memberships/:user",
1514+
"method": "PUT",
1515+
"params": {
1516+
"$id": null,
1517+
"$user": null
1518+
}
1519+
},
1520+
15121521
"get-team-repos": {
15131522
"url": "/teams/:id/repos",
15141523
"method": "GET",
@@ -1624,8 +1633,20 @@
16241633
"invalidmsg": "open, closed, all, default: open",
16251634
"description": "open, closed, or all"
16261635
},
1627-
"$head": null,
1628-
"$base": null,
1636+
"head": {
1637+
"type": "String",
1638+
"required": false,
1639+
"validation": "",
1640+
"invalidmsg": "",
1641+
"description": ""
1642+
},
1643+
"base": {
1644+
"type": "String",
1645+
"required": false,
1646+
"validation": "",
1647+
"invalidmsg": "",
1648+
"description": ""
1649+
},
16291650
"$page": null,
16301651
"$per_page": null,
16311652
"sort": {
@@ -3012,6 +3033,21 @@
30123033
}
30133034
},
30143035

3036+
"edit-organization-membership": {
3037+
"url": "/user/memberships/orgs/:org",
3038+
"method": "PATCH",
3039+
"params": {
3040+
"$org": null,
3041+
"state": {
3042+
"type": "String",
3043+
"required": true,
3044+
"validation": "^(open|closed|active)$",
3045+
"invalidmsg": "",
3046+
"description": ""
3047+
}
3048+
}
3049+
},
3050+
30153051
"get-teams": {
30163052
"url": "/user/teams",
30173053
"method": "GET",

api/v3.0.0/user.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,48 @@ var user = module.exports = {
225225
callback(null, ret);
226226
});
227227
};
228+
229+
/** section: github
230+
* user#editOrgMembership(msg, callback) -> null
231+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
232+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
233+
*
234+
* ##### Params on the `msg` object:
235+
*
236+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
237+
* - org (String): Required.
238+
* - state (String): Required
239+
**/
240+
this.editOrganizationMembership = function(msg, block, callback) {
241+
var self = this;
242+
this.client.httpSend(msg, block, function(err, res) {
243+
if (err)
244+
return self.sendError(err, null, msg, callback);
228245

246+
var ret;
247+
try {
248+
ret = res.data && JSON.parse(res.data);
249+
}
250+
catch (ex) {
251+
if (callback)
252+
callback(new error.InternalServerError(ex.message), res);
253+
return;
254+
}
255+
256+
if (!ret)
257+
ret = {};
258+
if (!ret.meta)
259+
ret.meta = {};
260+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
261+
if (res.headers[header])
262+
ret.meta[header] = res.headers[header];
263+
});
264+
265+
if (callback)
266+
callback(null, ret);
267+
});
268+
};
269+
229270
/** section: github
230271
* user#getTeams(msg, callback) -> null
231272
* - msg (Object): Object that contains the parameters and their values to be sent to the server.

0 commit comments

Comments
 (0)