Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move from https://github.com/c9/node-github3 to https://github.com/aj…

  • Loading branch information...
commit 4981dca691901fb5007b8926ac634c8b8d8d373f 1 parent 62b7735
@mikedeboer mikedeboer authored
Showing with 13,889 additions and 2,864 deletions.
  1. +1 −1  LICENSE
  2. +0 −10 NOTICE.txt
  3. +61 −38 README.md
  4. +3 −0  api/v2.0.0/routes.json
  5. +435 −0 api/v3.0.0/events.js
  6. +229 −0 api/v3.0.0/eventsTest.js
  7. +497 −0 api/v3.0.0/gists.js
  8. +245 −0 api/v3.0.0/gistsTest.js
  9. +531 −0 api/v3.0.0/gitdata.js
  10. +283 −0 api/v3.0.0/gitdataTest.js
  11. +39 −0 api/v3.0.0/index.js
  12. +965 −0 api/v3.0.0/issues.js
  13. +507 −0 api/v3.0.0/issuesTest.js
  14. +953 −0 api/v3.0.0/orgs.js
  15. +474 −0 api/v3.0.0/orgsTest.js
  16. +663 −0 api/v3.0.0/pullRequests.js
  17. +352 −0 api/v3.0.0/pullRequestsTest.js
  18. +2,002 −0 api/v3.0.0/repos.js
  19. +1,019 −0 api/v3.0.0/reposTest.js
  20. +2,411 −0 api/v3.0.0/routes.json
  21. +703 −0 api/v3.0.0/user.js
  22. +344 −0 api/v3.0.0/userTest.js
  23. +106 −0 error.js
  24. +225 −0 generate.js
  25. +529 −0 index.js
  26. +0 −309 lib/github.js
  27. +0 −28 lib/github/AbstractApi.js
  28. +0 −73 lib/github/AuthenticationTest.js
  29. +0 −57 lib/github/CommitApi.js
  30. +0 −43 lib/github/CommitApiTest.js
  31. +0 −72 lib/github/GistApi.js
  32. +0 −51 lib/github/GistApiTest.js
  33. +0 −231 lib/github/IssueApi.js
  34. +0 −118 lib/github/IssueApiTest.js
  35. +0 −93 lib/github/ObjectApi.js
  36. +0 −64 lib/github/ObjectApiTest.js
  37. +0 −196 lib/github/OrganizationApi.js
  38. +0 −128 lib/github/OrganizationApiTest.js
  39. +0 −63 lib/github/PullApi.js
  40. +0 −40 lib/github/PullApiTest.js
  41. +0 −313 lib/github/RepoApi.js
  42. +0 −163 lib/github/RepoApiTest.js
  43. +0 −263 lib/github/Request.js
  44. +0 −32 lib/github/RequestTest.js
  45. +0 −241 lib/github/UserApi.js
  46. +0 −160 lib/github/UserApiTest.js
  47. +0 −14 lib/github_all_tests.js
  48. +0 −39 lib/github_test.js
  49. +7 −7 package.json
  50. +10 −0 templates/after_request.js
  51. +21 −0 templates/handler.js
  52. +39 −0 templates/index.js
  53. +23 −0 templates/section.js
  54. +15 −0 templates/test_handler.js
  55. +28 −0 templates/test_section.js
  56. +33 −0 test/example.js
  57. +28 −17 {demo → test}/oauth.js
  58. +108 −0 util.js
View
2  LICENSE
@@ -1,6 +1,6 @@
The MIT License
-Copyright (c) 2010 ajax.org B.V (Fabian Jakobs)
+Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
10 NOTICE.txt
@@ -1,10 +0,0 @@
-node-github
-===========
-
-Copyright 2010 Ajax.org B.V.
-
-This product includes software developed by
-Ajax.org B.V. (http://www.ajax.org/).
-
-The library is based on the the "php-github-api" project by Thibault Duplessis
-(http://github.com/ornicar/php-github-api), which is MIT licensed
View
99 README.md
@@ -1,65 +1,95 @@
-# JavaScript GitHub API for node.js
+# JavaScript GitHub API for Node.JS
-A node.js module, which provides an object oriented wrapper for the GitHub v2 API. This library is a direct port of [php-github-api](http://github.com/ornicar/php-github-api) by Thibault Duplessis to JavaScript. The only major difference is that the JavaScript code is fully asynchronous.
+A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.
## Installation
- Install with the node package manager [npm](http://npmjs.org/):
+ Install with the Node.JS package manager [npm](http://npmjs.org/):
- $ npm install github
+ $ npm install node-github
or
Install via git clone:
- $ git clone git://github.com/ajaxorg/node-github.git
- $ cd node-github
+ $ git clone git://github.com/c9/node-github3.git
+ $ cd node-github3
$ npm install
+## Documentation
+
+You can find the docs for the API of this client at [http://c9.github.com/node-github3/](http://c9.github.com/node-github3/)
+
+Additionally, the [official Github documentation](http://developer.github.com/)
+is a very useful resource.
+
## Example
-Print all followers of the user "fjakobs" to the console.
+Print all followers of the user "mikedeboer" to the console.
- var GitHubApi = require("github").GitHubApi;
+ var GitHubApi = require("node-github");
- var github = new GitHubApi(true);
- github.getUserApi().getFollowers('fjakobs', function(err, followers) {
- console.log(followers.join('\n'));
+ var github = new GitHubApi({
+ version: "3.0.0"
+ });
+ github.user.getFollowingFromUser({
+ user: "mikedeboer"
+ }, function(err, res) {
+ console.log(JSON.stringify(res));
});
-First the _GitHubApi_ class is imported from the _github_ module. This class provides access to all of GitHub's APIs (e.g. user, commit or repository APIs). The _getFollowers_ method lists all followers of a given GitHub user. Is is part of the user API. It takes the user name as first argument and a callback as last argument. Once the follower list is returned from the server, the callback is called.
+First the _GitHubApi_ class is imported from the _node-github_ module. This class provides
+access to all of GitHub's APIs (e.g. user, issues or repo APIs). The _getFollowingFromUser_
+method lists all followers of a given GitHub user. Is is part of the user API. It
+takes the user name as first argument and a callback as last argument. Once the
+follower list is returned from the server, the callback is called.
-Like in node.js callbacks are always the last argument. If the functions fails an error object is passed as first argument to the callback.
+Like in Node.JS, callbacks are always the last argument. If the functions fails an
+error object is passed as first argument to the callback.
## Authentication
-Most GitHub API calls don't require authentication. As a rule of thumb: If you can see the information by visiting the site without being logged in, you don't have to be authenticated to retrieve the same information through the API. Of course calls, which change data or read sensitive information have to be authenticated.
+Most GitHub API calls don't require authentication. As a rule of thumb: If you
+can see the information by visiting the site without being logged in, you don't
+have to be authenticated to retrieve the same information through the API. Of
+course calls, which change data or read sensitive information have to be authenticated.
-You need the GitHub user name and the API key for authentication. The API key can be found in the user's _Account Settings_ page.
+You need the GitHub user name and the API key for authentication. The API key can
+be found in the user's _Account Settings_ page.
-This example shows how to authenticate and then change _location_ field of the account settings to _Argentina_:
+This example shows how to authenticate and then change _location_ field of the
+account settings to _Argentina_:
- github.authenticate(username, token);
- github.getUserApi().update(username, {location: "Argentina"}, function(err) {
+ github.authenticate({
+ type: "basic",
+ username: username,
+ password: password
+ });
+ github.user.update({
+ location: "Argentina"
+ }, function(err) {
console.log("done!");
});
-Note that the _authenticate_ method is synchronous because it only stores the credentials for the next request.
+Note that the _authenticate_ method is synchronous because it only stores the
+credentials for the next request.
## Implemented GitHub APIs
-* User API: 100%
-* Commit API: 100%
-* Object API: 100%
-* Repository API: 90%, missing repo visibility, deploy keys
-* Issues API: 100%
-* Pulls API: only _getList_ is implemented
-* Gist API: 100% v1 Gist API implemented. 0% v3 API
-* Network API: still missing
+* Gists: 100%
+* Git Data: 100%
+* Issues: 100%
+* Orgs: 100%
+* Pull Requests: 100%
+* Repos: 100%
+* Users: 100%
+* Events: 100%
## Running the Tests
-The unit tests are based on the [node-async-test](http://github.com/bentomas/node-async-testing) module, which is provided as a git submodule. To run the tests make sure that the npm dependencies are installed by running `npm install` from the project directory.
+The unit tests are based on the [ayncjs](https://github.com/ajaxorg/async.js)
+module, which is provided as an npm dependency. To run the tests make sure that the
+npm dependencies are installed by running `npm install` from the project directory.
Running all unit tests:
@@ -67,25 +97,18 @@ Running all unit tests:
or
- node lib/github_all_tests.js
+ node test/all.js
The test classes can also be run separately. This will e.g. run the UserApi test:
- node lib/github_test.js
+ node api/v3.0.0/userTest.js
Note that a connection to the internet is required to run the tests.
## TODO
-* API docs
- * fix and polish (there might still be some PHP-isms)
- * generate API documentation
-* Documentation
+* generate Client documentation
## LICENSE
MIT license. See the LICENSE file for details.
-
-## Credits
-
-Thanks to Thibault Duplessis for the excellent php-github-api library, which is the blueprint of this library. Especially the unit tests proved to be very helpful.
View
3  api/v2.0.0/routes.json
@@ -0,0 +1,3 @@
+{
+
+}
View
435 api/v3.0.0/events.js
@@ -0,0 +1,435 @@
+/**
+ * mixin events
+ *
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ **/
+
+"use strict";
+
+var error = require("./../../error");
+var Util = require("./../../util");
+
+var events = module.exports = {
+ events: {}
+};
+
+(function() {
+ /**
+ * events#get(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.get = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromRepo(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromRepo = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromRepoIssues(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromRepoIssues = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromRepoNetwork(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromRepoNetwork = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromOrg(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - org (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromOrg = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getReceived(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getReceived = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getReceivedPublic(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getReceivedPublic = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromUser(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromUser = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromUserPublic(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromUserPublic = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * events#getFromUserOrg(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - org (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromUserOrg = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+}).call(events.events);
View
229 api/v3.0.0/eventsTest.js
@@ -0,0 +1,229 @@
+/*
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ */
+
+"use strict";
+
+var Assert = require("assert");
+var Client = require("./../../index");
+
+var username = "fjakobstest";
+var token = "b98166e45acf66df70a992e2de56b92a";
+
+var test = module.exports = {
+ setUp: function() {
+ this.client = new Client({
+ version: "3.0.0"
+ });
+ },
+
+ "test: GET /events (get)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.get(
+ {
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/events (getFromRepo)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromRepo(
+ {
+ user: "String",
+ repo: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/issues/events (getFromRepoIssues)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromRepoIssues(
+ {
+ user: "String",
+ repo: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /networks/:user/:repo/events (getFromRepoNetwork)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromRepoNetwork(
+ {
+ user: "String",
+ repo: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /orgs/:org/events (getFromOrg)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromOrg(
+ {
+ org: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /users/:user/received_events (getReceived)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getReceived(
+ {
+ user: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /users/:user/received_events/public (getReceivedPublic)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getReceivedPublic(
+ {
+ user: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /users/:user/events (getFromUser)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromUser(
+ {
+ user: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /users/:user/events/public (getFromUserPublic)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromUserPublic(
+ {
+ user: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /users/:user/events/orgs/:org (getFromUserOrg)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.events.getFromUserOrg(
+ {
+ user: "String",
+ org: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ }
+};
+
+!module.parent && require("asyncjs").test.testcase(module.exports).exec();
View
497 api/v3.0.0/gists.js
@@ -0,0 +1,497 @@
+/**
+ * mixin gists
+ *
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ **/
+
+"use strict";
+
+var error = require("./../../error");
+var Util = require("./../../util");
+
+var gists = module.exports = {
+ gists: {}
+};
+
+(function() {
+ /**
+ * gists#getAll(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getAll = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#getFromUser(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getFromUser = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#create(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - description (String): Optional.
+ * - public (Boolean): Required.
+ * - files (Json): Required. Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content'
+ **/
+ this.create = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#edit(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ * - description (String): Optional.
+ * - files (Json): Required. Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content'
+ **/
+ this.edit = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#public(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * No params, simply pass an empty Object literal `{}`
+ **/
+ this.public = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#starred(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * No params, simply pass an empty Object literal `{}`
+ **/
+ this.starred = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#get(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.get = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#star(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.star = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#deleteStar(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.deleteStar = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#checkStar(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.checkStar = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#fork(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.fork = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gists#delete(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - id (Number): Required. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.delete = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+}).call(gists.gists);
View
245 api/v3.0.0/gistsTest.js
@@ -0,0 +1,245 @@
+/*
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ */
+
+"use strict";
+
+var Assert = require("assert");
+var Client = require("./../../index");
+
+var username = "fjakobstest";
+var token = "b98166e45acf66df70a992e2de56b92a";
+
+var test = module.exports = {
+ setUp: function() {
+ this.client = new Client({
+ version: "3.0.0"
+ });
+ },
+
+ "test: GET /gists (getAll)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.getAll(
+ {
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET :user/gists (getFromUser)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.getFromUser(
+ {
+ user: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /gists (create)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.create(
+ {
+ description: "String",
+ public: "Boolean",
+ files: "Json"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: PATCH /gists/:id (edit)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.edit(
+ {
+ id: "Number",
+ description: "String",
+ files: "Json"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /gists/public (public)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.public(
+ {},
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /gists/starred (starred)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.starred(
+ {},
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /gists/get/:id (get)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.get(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: PUT /gists/:id/star (star)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.star(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: DELETE /gists/:id/star (deleteStar)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.deleteStar(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /gists/:id/star (checkStar)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.checkStar(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /gists/:id/fork (fork)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.fork(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: DELETE /gists/:id (delete)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gists.delete(
+ {
+ id: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ }
+};
+
+!module.parent && require("asyncjs").test.testcase(module.exports).exec();
View
531 api/v3.0.0/gitdata.js
@@ -0,0 +1,531 @@
+/**
+ * mixin gitdata
+ *
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ **/
+
+"use strict";
+
+var error = require("./../../error");
+var Util = require("./../../util");
+
+var gitdata = module.exports = {
+ gitdata: {}
+};
+
+(function() {
+ /**
+ * gitdata#getBlob(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - sha (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getBlob = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#createBlob(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - content (String): Required.
+ * - encoding (String): Required.
+ **/
+ this.createBlob = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#getCommit(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - sha (String): Required.
+ **/
+ this.getCommit = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#createCommit(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - message (String): Required. String of the commit message
+ * - tree (String): Required. String of the SHA of the tree object this commit points to
+ * - parents (Array): Required. Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided.
+ * - author (Json): Optional.
+ * - committer (Json): Optional.
+ **/
+ this.createCommit = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#getReference(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - ref (String): Required. String of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.
+ **/
+ this.getReference = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#getAllReferences(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getAllReferences = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#createReference(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - refs (String): Required. String of the name of the fully qualified reference (ie: refs/heads/master). If it doesn’t start with ‘refs’ and have at least two slashes, it will be rejected.
+ * - sha (String): Required.
+ **/
+ this.createReference = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#updateReference(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - sha (String): Required.
+ * - force (Boolean): Required. Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is false, so leaving this out or setting it to false will make sure you’re not overwriting work.
+ **/
+ this.updateReference = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#getTag(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - sha (String): Required.
+ **/
+ this.getTag = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#createTag(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - tag (String): Required. String of the tag
+ * - message (String): Required. String of the tag message
+ * - object (String): Required. String of the SHA of the git object this is tagging
+ * - type (String): Required. String of the type of the object we’re tagging. Normally this is a commit but it can also be a tree or a blob.
+ * - tagger.name (String): Required. String of the name of the author of the tag
+ * - tagger.email (String): Required. String of the email of the author of the tag
+ * - tagger.date (String): Required. Timestamp of when this object was tagged
+ **/
+ this.createTag = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#getTree(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - sha (String): Required.
+ * - recursive (Boolean): Optional.
+ **/
+ this.getTree = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * gitdata#createTree(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - tree (Json): Required.
+ **/
+ this.createTree = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+}).call(gitdata.gitdata);
View
283 api/v3.0.0/gitdataTest.js
@@ -0,0 +1,283 @@
+/*
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ */
+
+"use strict";
+
+var Assert = require("assert");
+var Client = require("./../../index");
+
+var username = "fjakobstest";
+var token = "b98166e45acf66df70a992e2de56b92a";
+
+var test = module.exports = {
+ setUp: function() {
+ this.client = new Client({
+ version: "3.0.0"
+ });
+ },
+
+ "test: GET /repos/:user/:repo/git/blobs/:sha (getBlob)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getBlob(
+ {
+ user: "String",
+ repo: "String",
+ sha: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST repos/:user/:repo/git/blobs (createBlob)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.createBlob(
+ {
+ user: "String",
+ repo: "String",
+ content: "String",
+ encoding: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/git/commits/:sha (getCommit)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getCommit(
+ {
+ user: "String",
+ repo: "String",
+ sha: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /repos/:user/:repo/git/commits (createCommit)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.createCommit(
+ {
+ user: "String",
+ repo: "String",
+ message: "String",
+ tree: "String",
+ parents: "Array",
+ author: "Json",
+ committer: "Json"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/git/refs/:ref (getReference)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getReference(
+ {
+ user: "String",
+ repo: "String",
+ ref: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/git/refs (getAllReferences)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getAllReferences(
+ {
+ user: "String",
+ repo: "String",
+ page: "Number",
+ per_page: "Number"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /repos/:user/:repo/git/refs (createReference)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.createReference(
+ {
+ user: "String",
+ repo: "String",
+ refs: "String",
+ sha: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: PATCH /repos/:user/:repo/git/refs/:ref (updateReference)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.updateReference(
+ {
+ user: "String",
+ repo: "String",
+ sha: "String",
+ force: "Boolean"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/git/tags/:sha (getTag)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getTag(
+ {
+ user: "String",
+ repo: "String",
+ sha: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /repos/:user/:repo/git/tags (createTag)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.createTag(
+ {
+ user: "String",
+ repo: "String",
+ tag: "String",
+ message: "String",
+ object: "String",
+ type: "String",
+ tagger.name: "String",
+ tagger.email: "String",
+ tagger.date: "String"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: GET /repos/:user/:repo/git/trees/:sha (getTree)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.getTree(
+ {
+ user: "String",
+ repo: "String",
+ sha: "String",
+ recursive: "Boolean"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ },
+
+ "test: POST /repos/:user/:repo/git/trees (createTree)": function(next) {
+ var self = this;
+ this.client.authenticate({
+ type: "token",
+ username: username,
+ token: token
+ });
+ this.client.gitdata.createTree(
+ {
+ user: "String",
+ repo: "String",
+ tree: "Json"
+ },
+ function(err, res) {
+ Assert.equal(err, null);
+ // other assertions go here
+ }
+ );
+ }
+};
+
+!module.parent && require("asyncjs").test.testcase(module.exports).exec();
View
39 api/v3.0.0/index.js
@@ -0,0 +1,39 @@
+/**
+ * class Github
+ *
+ * A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.
+ *
+ * Copyright 2012 Ajax.org Services B.V.
+ *
+ * This product includes software developed by
+ * Ajax.org Services B.V. (http://www.ajax.org/).
+ *
+ * Author: Mike de Boer <mike@ajax.org>
+ **/
+
+"use strict";
+
+var Fs = require("fs");
+var Util = require("./../../util");
+var error = require("./../../error");
+
+var GithubHandler = module.exports = function(client) {
+ this.client = client;
+ this.routes = JSON.parse(Fs.readFileSync(__dirname + "/routes.json", "utf8"));
+};
+
+var proto = {
+ sendError: function(err, block, msg, callback) {
+ Util.log(err, block, msg.user, "error");
+ if (typeof err == "string")
+ err = new error.InternalServerError(err);
+ if (callback)
+ callback(err);
+ }
+};
+
+["gists", "gitdata", "issues", "orgs", "pullRequests", "repos", "user", "events"].forEach(function(api) {
+ Util.extend(proto, require("./" + api));
+});
+
+GithubHandler.prototype = proto;
View
965 api/v3.0.0/issues.js
@@ -0,0 +1,965 @@
+/**
+ * mixin issues
+ *
+ * Copyright 2012 Cloud9 IDE, Inc.
+ *
+ * This product includes software developed by
+ * Cloud9 IDE, Inc (http://c9.io).
+ *
+ * Author: Mike de Boer <mike@c9.io>
+ **/
+
+"use strict";
+
+var error = require("./../../error");
+var Util = require("./../../util");
+
+var issues = module.exports = {
+ issues: {}
+};
+
+(function() {
+ /**
+ * issues#getAll(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - filter (String): Optional. Validation rule: ` ^(assigned|created|mentioned||subscribed)$ `.
+ * - state (String): Optional. Validation rule: ` ^(open|closed)$ `.
+ * - labels (String): Optional. String list of comma separated Label names. Example: bug,ui,@high
+ * - sort (String): Optional. Validation rule: ` ^(created|updated|comments)$ `.
+ * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `.
+ * - since (Date): Optional. Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.getAll = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * issues#repoIssues(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
+ *
+ * ##### Params on the `msg` object:
+ *
+ * - user (String): Required.
+ * - repo (String): Required.
+ * - milestone (String): Required. Validation rule: ` ^([0-9]+|none|\*)$ `.
+ * - state (String): Optional. Validation rule: ` ^(open|closed)$ `.
+ * - assignee (String): Required. String User login, `none` for Issues with no assigned User. `*` for Issues with any assigned User.
+ * - mentioned (String): Optional. String User login.
+ * - labels (String): Optional. String list of comma separated Label names. Example: bug,ui,@high
+ * - sort (String): Optional. Validation rule: ` ^(created|updated|comments)$ `.
+ * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `.
+ * - since (Date): Optional. Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
+ * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
+ * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
+ **/
+ this.repoIssues = function(msg, block, callback) {
+ var self = this;
+ this.client.httpSend(msg, block, function(err, res) {
+ if (err)
+ return self.sendError(err, null, msg, callback);
+
+ var ret;
+ try {
+ ret = JSON.parse(res.data);
+ }
+ catch (ex) {
+ if (callback)
+ callback(new error.InternalServerError(ex.message), res);
+ return;
+ }
+
+ if (!ret)
+ ret = {};
+ if (!ret.meta)
+ ret.meta = {};
+ ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) {
+ if (res.headers[header])
+ ret.meta[header] = res.headers[header];
+ });
+
+ if (callback)
+ callback(null, ret);
+ });
+ };
+
+ /**
+ * issues#getRepoIssue(msg, callback) -> null
+ * - msg (Object): Object that contains the parameters and their values to be sent to the server.
+ * - callback (Function): function to call when the request is finished with an error