Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Now every api returns headers

  • Loading branch information...
commit 5b8df89df74a685db73bf2059f7fa113a47d9e91 1 parent 7f4f2be
Pavan Kumar Sunkara authored
3  README.md
View
@@ -162,9 +162,10 @@ client.limit(function (err, left, max) {
__All the callbacks for the following will take first an error argument, then a data argument, like this:__
```js
-ghme.info(function(err, data) {
+ghme.info(function(err, data, headers) {
console.log("error: " + err);
console.log("data: " + data);
+ console.log("headers:" + headers);
});
```
60 lib/octonode/gist.js
View
@@ -11,14 +11,14 @@
Gist.prototype.list = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/gists"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/gists"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist list error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -26,14 +26,14 @@
Gist.prototype["public"] = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/gists/public"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/gists/public"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist public error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -41,14 +41,14 @@
Gist.prototype.starred = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/gists/starred"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/gists/starred"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist starred error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -56,60 +56,60 @@
Gist.prototype.user = function() {
var cb, params, user, _i, _ref;
params = 3 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 2) : (_i = 0, []), user = arguments[_i++], cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/users/" + user + "/gists"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/users/" + user + "/gists"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist user error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
Gist.prototype.get = function(id, cb) {
- return this.client.get("/gists/" + id, function(err, s, b) {
+ return this.client.get("/gists/" + id, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist get error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.create = function(gist, cb) {
- return this.client.post("/gists", gist, function(err, s, b) {
+ return this.client.post("/gists", gist, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('Gist create error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.edit = function(id, gist, cb) {
- return this.client.post("/gists/" + id, gist, function(err, s, b) {
+ return this.client.post("/gists/" + id, gist, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist edit error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype["delete"] = function(id) {
var _this = this;
- return this.client.del("/gists/" + id, {}, function(err, s, b) {
+ return this.client.del("/gists/" + id, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this["delete"](id);
}
@@ -117,21 +117,21 @@
};
Gist.prototype.fork = function(id) {
- return this.client.post("/gists/" + id + "/forks", {}, function(err, s, b) {
+ return this.client.post("/gists/" + id + "/forks", {}, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('Gist fork error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.star = function(id) {
var _this = this;
- return this.client.put("/gists/" + id + "/star", {}, function(err, s, b) {
+ return this.client.put("/gists/" + id + "/star", {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.star(id);
}
@@ -140,7 +140,7 @@
Gist.prototype.unstar = function(id) {
var _this = this;
- return this.client.del("/gists/" + id + "/unstar", {}, function(err, s, b) {
+ return this.client.del("/gists/" + id + "/unstar", {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.unstar(id);
}
@@ -148,69 +148,69 @@
};
Gist.prototype.check = function(id) {
- return this.client.get("/gists/" + id + "/star", function(err, s, b) {
+ return this.client.get("/gists/" + id + "/star", function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, s === 204);
+ return cb(null, s === 204, h);
});
};
Gist.prototype.listComments = function(id, cb) {
- return this.client.get("/gists/" + id + "/comments", function(err, s, b) {
+ return this.client.get("/gists/" + id + "/comments", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist comments error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.getComment = function(id, cb) {
- return this.client.get("/gists/comments/" + id, function(err, s, b) {
+ return this.client.get("/gists/comments/" + id, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist getComment error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.createComment = function(id, comment, cb) {
- return this.client.post("/gists/" + id + "/comments", comment, function(err, s, b) {
+ return this.client.post("/gists/" + id + "/comments", comment, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('Gist createComment error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.updateComment = function(id, comment, cb) {
- return this.client.post("/gists/comments/" + id, comment, function(err, s, b) {
+ return this.client.post("/gists/comments/" + id, comment, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Gist updateComment error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Gist.prototype.deleteComment = function(id) {
var _this = this;
- return this.client.del("/gists/comments/" + id, {}, function(err, s, b) {
+ return this.client.del("/gists/comments/" + id, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.deleteComment(id);
}
12 lib/octonode/issue.js
View
@@ -11,27 +11,27 @@
}
Issue.prototype.info = function(cb) {
- return this.client.get("/repos/" + this.repo + "/issues/" + this.number, function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/issues/" + this.number, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Issue info error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Issue.prototype.update = function(obj, cb) {
- return this.client.post("/repos/" + this.repo + "/issues/" + this.number, obj, function(err, s, b) {
+ return this.client.post("/repos/" + this.repo + "/issues/" + this.number, obj, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Issue update error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -39,14 +39,14 @@
Issue.prototype.comments = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/repos/" + this.repo + "/issues/" + this.number + "/comments"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/repos/" + this.repo + "/issues/" + this.number + "/comments"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Issue Comments error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
84 lib/octonode/me.js
View
@@ -16,27 +16,27 @@
};
Me.prototype.info = function(cb) {
- return this.client.get('/user', function(err, s, b) {
+ return this.client.get('/user', function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User info error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.update = function(info, cb) {
- return this.client.post('/user', info, function(err, s, b) {
+ return this.client.post('/user', info, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User update error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -48,35 +48,35 @@
return this.deleteEmails(cbOrEmails);
} else {
cb = cbOrEmails;
- return this.client.get('/user/emails', function(err, s, b) {
+ return this.client.get('/user/emails', function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User emails error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
}
};
Me.prototype.setEmails = function(emails, cb) {
- return this.client.post('/user/emails', emails, function(err, s, b) {
+ return this.client.post('/user/emails', emails, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('User setEmails error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.deleteEmails = function(emails) {
var _this = this;
- return this.client.del('/user/emails', emails, function(err, s, b) {
+ return this.client.del('/user/emails', emails, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.deleteEmails(emails);
}
@@ -86,14 +86,14 @@
Me.prototype.followers = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ['/user/followers'].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ['/user/followers'].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User followers error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -103,31 +103,31 @@
return this.checkFollowing(cbOrUser, cb);
} else {
cb = cbOrUser;
- return this.client.get('/user/following', function(err, s, b) {
+ return this.client.get('/user/following', function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User following error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
}
};
Me.prototype.checkFollowing = function(user, cb) {
- return this.client.get("/user/following/" + user, function(err, s, b) {
+ return this.client.get("/user/following/" + user, function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, s === 204);
+ return cb(null, s === 204, h);
});
};
Me.prototype.follow = function(user) {
var _this = this;
- return this.client.put("/user/following/" + user, {}, function(err, s, b) {
+ return this.client.put("/user/following/" + user, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.follow(user);
}
@@ -136,7 +136,7 @@
Me.prototype.unfollow = function(user) {
var _this = this;
- return this.client.del("/user/following/" + user, {}, function(err, s, b) {
+ return this.client.del("/user/following/" + user, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.unfollow(user);
}
@@ -148,31 +148,31 @@
return this.checkStarred(cbOrRepo, cb);
} else {
cb = cbOrRepo;
- return this.client.get('/user/starred', function(err, s, b) {
+ return this.client.get('/user/starred', function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User starred error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
}
};
Me.prototype.checkStarred = function(repo, cb) {
- return this.client.get("/user/starred/" + repo, function(err, s, b) {
+ return this.client.get("/user/starred/" + repo, function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, s === 204);
+ return cb(null, s === 204, h);
});
};
Me.prototype.star = function(repo) {
var _this = this;
- return this.client.put("/user/starred/" + repo, {}, function(err, s, b) {
+ return this.client.put("/user/starred/" + repo, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.star(repo);
}
@@ -181,7 +181,7 @@
Me.prototype.unstar = function(repo) {
var _this = this;
- return this.client.del("/user/starred/" + repo, {}, function(err, s, b) {
+ return this.client.del("/user/starred/" + repo, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.unstar(repo);
}
@@ -191,14 +191,14 @@
Me.prototype.watched = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ['/user/subscriptions'].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ['/user/subscriptions'].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User subscription error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -214,61 +214,61 @@
return this.updateKey(cbOrIdOrKey, cbOrKey, cb);
} else {
cb = cbOrIdOrKey;
- return this.client.get('/user/keys', function(err, s, b) {
+ return this.client.get('/user/keys', function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User keys error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
}
};
Me.prototype.getKey = function(id, cb) {
- return this.client.get("/user/keys/" + id, function(err, s, b) {
+ return this.client.get("/user/keys/" + id, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User getKey error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.createKey = function(key, cb) {
- return this.client.post('/user/keys', key, function(err, s, b) {
+ return this.client.post('/user/keys', key, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('User createKey error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.updateKey = function(id, key, cb) {
- return this.client.post("/user/keys/" + id, key, function(err, s, b) {
+ return this.client.post("/user/keys/" + id, key, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User updateKey error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.deleteKey = function(id) {
var _this = this;
- return this.client.del("/user/keys/" + id, {}, function(err, s, b) {
+ return this.client.del("/user/keys/" + id, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.deleteKey(id);
}
@@ -282,14 +282,14 @@
Me.prototype.orgs = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/user/orgs"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/user/orgs"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User orgs error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -305,40 +305,40 @@
Me.prototype.repos = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/user/repos"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/user/repos"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User repos error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
Me.prototype.createRepo = function(repo, cb) {
- return this.client.post("/user/repos", repo, function(err, s, b) {
+ return this.client.post("/user/repos", repo, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('User createRepo error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Me.prototype.fork = function(repo, cb) {
- return this.client.post("/repos/" + repo + "/forks", {}, function(err, s, b) {
+ return this.client.post("/repos/" + repo + "/forks", {}, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 202) {
return cb(new Error('User fork error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
28 lib/octonode/org.js
View
@@ -10,27 +10,27 @@
}
Org.prototype.info = function(cb) {
- return this.client.get("/orgs/" + this.name, function(err, s, b) {
+ return this.client.get("/orgs/" + this.name, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Org info error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Org.prototype.update = function(info, cb) {
- return this.client.post("/orgs/" + this.name, info, function(err, s, b) {
+ return this.client.post("/orgs/" + this.name, info, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Org update error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -46,63 +46,63 @@
Org.prototype.repos = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/orgs/" + this.name + "/repos"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/orgs/" + this.name + "/repos"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Org repos error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
Org.prototype.createRepo = function(repo, cb) {
- return this.client.post("/orgs/" + this.name + "/repos", repo, function(err, s, b) {
+ return this.client.post("/orgs/" + this.name + "/repos", repo, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error('Org createRepo error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Org.prototype.teams = function(cb) {
- return this.client.get("/orgs/" + this.name + "/teams", function(err, s, b) {
+ return this.client.get("/orgs/" + this.name + "/teams", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Org teams error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Org.prototype.members = function(cb) {
- return this.client.get("/orgs/" + this.name + "/members", function(err, s, b) {
+ return this.client.get("/orgs/" + this.name + "/members", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Org members error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Org.prototype.member = function(user, cb) {
- return this.client.getNoFollow("/orgs/" + this.name + "/members/" + user, function(err, s, b) {
+ return this.client.getNoFollow("/orgs/" + this.name + "/members/" + user, function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, s === 204);
+ return cb(null, s === 204, h);
});
};
40 lib/octonode/pr.js
View
@@ -10,27 +10,27 @@
}
Pr.prototype.info = function(cb) {
- return this.client.get("/repos/" + this.repo + "/pulls/" + this.number, function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/pulls/" + this.number, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Pr info error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Pr.prototype.update = function(obj, cb) {
- return this.client.post("/repos/" + this.repo + "/pulls/" + this.number, obj, function(err, s, b) {
+ return this.client.post("/repos/" + this.repo + "/pulls/" + this.number, obj, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Pr update error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -42,64 +42,66 @@
};
Pr.prototype.merged = function(cb) {
- return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/merge", function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/merge", function(err, s, b, h) {
if (err && err.message === 'null') {
return cb(null, false);
}
- if (s !== 204) {
- return cb(new Error("Pr merged error"));
- } else {
- return cb(null, true);
- }
+ return cb(null, s === 204, h);
});
};
Pr.prototype.merge = function(msg, cb) {
- return this.client.put("/repos/" + this.repo + "/pulls/" + this.number + "/merge", {
+ var commit;
+ commit = {
commit_message: msg
- }, function(err, s, b) {
+ };
+ return this.client.put("/repos/" + this.repo + "/pulls/" + this.number + "/merge", commit, function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, b);
+ if (s !== 200) {
+ return cb(new Error("Pr merge error"));
+ } else {
+ return cb(null, b, h);
+ }
});
};
Pr.prototype.commits = function(cb) {
- return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/commits", function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/commits", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Pr commits error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Pr.prototype.comments = function(cb) {
- return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/comments", function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/comments", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Pr comments error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Pr.prototype.files = function(cb) {
- return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/files", function(err, s, b) {
+ return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/files", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Pr files error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
105 lib/octonode/repo.js
View
@@ -10,14 +10,14 @@
}
Repo.prototype.info = function(cb) {
- return this.client.get("/repos/" + this.name, function(err, s, b) {
+ return this.client.get("/repos/" + this.name, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo info error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -27,119 +27,115 @@
return this.hasCollaborator(cbOrUser, cb);
} else {
cb = cbOrUser;
- return this.client.get("repos/" + this.name + "/collaborators", function(err, s, b) {
+ return this.client.get("repos/" + this.name + "/collaborators", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo collaborators error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
}
};
Repo.prototype.hasCollaborator = function(user, cb) {
- return this.client.get("repos/" + this.name + "/collaborators/" + user, function(err, s, b) {
+ return this.client.get("repos/" + this.name + "/collaborators/" + user, function(err, s, b, h) {
if (err) {
return cb(err);
}
- if (s !== 204 && s !== 404) {
- return cb(new Error("Repo hasCollaborator error"));
- } else {
- return cb(null, b);
- }
+ return cb(null, s === 204, h);
});
};
Repo.prototype.commits = function(cb) {
- return this.client.get("/repos/" + this.name + "/commits", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/commits", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo commits error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.commit = function(sha, cb) {
- return this.client.get("/repos/" + this.name + "/commits/" + sha, function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/commits/" + sha, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo commits error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.tags = function(cb) {
- return this.client.get("/repos/" + this.name + "/tags", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/tags", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo tags error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.languages = function(cb) {
- return this.client.get("/repos/" + this.name + "/languages", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/languages", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo languages error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.contributors = function(cb) {
- return this.client.get("/repos/" + this.name + "/contributors", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/contributors", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo contributors error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.teams = function(cb) {
- return this.client.get("/repos/" + this.name + "/teams", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/teams", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo teams error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.branches = function(cb) {
- return this.client.get("/repos/" + this.name + "/branches", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/branches", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo branches error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -155,24 +151,27 @@
Repo.prototype.issues = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/repos/" + this.name + "/issues"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/repos/" + this.name + "/issues"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo issues error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
Repo.prototype.createIssue = function(issue, cb) {
- return this.client.post("/repos/" + this.name + "/issues", issue, function(err, s, b) {
+ return this.client.post("/repos/" + this.name + "/issues", issue, function(err, s, b, h) {
+ if (err) {
+ return cb(err);
+ }
if (s !== 201) {
return cb(new Error("Repo createIssue error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -182,14 +181,14 @@
cb = cbOrRef;
cbOrRef = 'master';
}
- return this.client.get("/repos/" + this.name + "/readme?ref=" + cbOrRef, function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/readme?ref=" + cbOrRef, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo readme error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -199,14 +198,14 @@
cb = cbOrRef;
cbOrRef = 'master';
}
- return this.client.get("/repos/" + this.name + "/contents/" + path + "?ref=" + cbOrRef, function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/contents/" + path + "?ref=" + cbOrRef, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo contents error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -223,20 +222,20 @@
if (s !== 302) {
return cb(new Error("Repo archive error"));
} else {
- return cb(null, h['Location']);
+ return cb(null, h['Location'], h);
}
});
};
Repo.prototype.forks = function(cb) {
- return this.client.get("/repos/" + this.name + "/forks", function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/forks", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo forks error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -244,14 +243,14 @@
Repo.prototype.blob = function(sha, cb) {
return this.client.get("/repos/" + this.name + "/git/blobs/" + sha, {
Accept: 'application/vnd.github.raw'
- }, function(err, s, b) {
+ }, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo blob error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -266,21 +265,21 @@
if (cbOrRecursive) {
url += "?recursive=1";
}
- return this.client.get(url, function(err, s, b) {
+ return this.client.get(url, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo tree error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.destroy = function() {
var _this = this;
- return this.client.del("/repos/" + this.name, {}, function(err, s, b) {
+ return this.client.del("/repos/" + this.name, {}, function(err, s, b, h) {
if ((err != null) || s !== 204) {
return _this.destroy();
}
@@ -298,72 +297,70 @@
Repo.prototype.prs = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/repos/" + this.name + "/pulls"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/repos/" + this.name + "/pulls"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo prs error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
Repo.prototype.createPr = function(pr, cb) {
- return this.client.post("/repos/" + this.name + "/pulls", pr, function(err, s, b) {
+ return this.client.post("/repos/" + this.name + "/pulls", pr, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error("Repo createPr error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.statuses = function(ref, cb) {
- return this.client.get("/repos/" + this.name + "/statuses/" + ref, function(err, s, b) {
+ return this.client.get("/repos/" + this.name + "/statuses/" + ref, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo statuses error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.status = function(sha, obj, cb) {
- return this.client.post("/repos/" + this.name + "/statuses/" + sha, obj, function(err, s, b) {
+ return this.client.post("/repos/" + this.name + "/statuses/" + sha, obj, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 201) {
return cb(new Error("Repo status error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Repo.prototype.stargazers = function() {
- var cb, page, params, per_page, _i;
+ var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- page = params[0] || 1;
- per_page = params[1] || 30;
- return this.client.get("/repos/" + this.name + "/stargazers", page, per_page, function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/repos/" + this.name + "/stargazers"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo stargazers error"));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
- });
+ }]));
};
return Repo;
16 lib/octonode/search.js
View
@@ -11,14 +11,14 @@
if (state !== 'closed') {
state = 'open';
}
- return this.client.get("/legacy/issues/search/" + repo + "/" + state + "/" + keyword, function(err, s, b) {
+ return this.client.get("/legacy/issues/search/" + repo + "/" + state + "/" + keyword, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Search issues error'));
} else {
- return cb(null, b.issues);
+ return cb(null, b.issues, h);
}
});
};
@@ -32,14 +32,14 @@
if (start_page) {
param += "start_page=" + start_page + "&";
}
- return this.client.get("/legacy/repos/search/" + keyword + "?" + param, function(err, s, b) {
+ return this.client.get("/legacy/repos/search/" + keyword + "?" + param, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Search repos error'));
} else {
- return cb(null, b.repositories);
+ return cb(null, b.repositories, h);
}
});
};
@@ -50,27 +50,27 @@
if (start_page) {
param += "start_page=" + start_page + "&";
}
- return this.client.get("/legacy/user/search/" + keyword + "?" + param, function(err, s, b) {
+ return this.client.get("/legacy/user/search/" + keyword + "?" + param, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Search users error'));
} else {
- return cb(null, b.users);
+ return cb(null, b.users, h);
}
});
};
Search.prototype.emails = function(email, cb) {
- return this.client.get("/legacy/user/email/" + email, function(err, s, b) {
+ return this.client.get("/legacy/user/email/" + email, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Search email error'));
} else {
- return cb(null, b.user);
+ return cb(null, b.user, h);
}
});
};
12 lib/octonode/team.js
View
@@ -9,37 +9,37 @@
}
Team.prototype.info = function(cb) {
- return this.client.get("/teams/" + this.id, function(err, s, b) {
+ return this.client.get("/teams/" + this.id, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Team info error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Team.prototype.members = function(cb) {
- return this.client.get("/teams/" + this.id + "/members", function(err, s, b) {
+ return this.client.get("/teams/" + this.id + "/members", function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('Team members error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
Team.prototype.member = function(user, cb) {
- return this.client.get("/teams/" + this.id + "/members/" + user, function(err, s, b) {
+ return this.client.get("/teams/" + this.id + "/members/" + user, function(err, s, b, h) {
if (err) {
return cb(err);
}
- return cb(null, s === 204);
+ return cb(null, s === 204, h);
});
};
23 lib/octonode/user.js
View
@@ -17,14 +17,14 @@
};
User.prototype.info = function(cb) {
- return this.client.get("/users/" + this.login, function(err, s, b) {
+ return this.client.get("/users/" + this.login, function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User info error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
});
};
@@ -32,14 +32,14 @@
User.prototype.followers = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/followers"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/followers"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User followers error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -47,14 +47,14 @@
User.prototype.following = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/following"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/following"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User following error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
@@ -68,30 +68,31 @@
} else if (!Array.isArray(events)) {
events = [events];
}
- return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/events"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/events"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User events error'));
}
- return cb(null, b.filter(function(event) {
+ b = b.filter(function(event) {
return events.indexOf(event.type) !== -1;
- }));
+ });
+ return cb(null, b, h);
}]));
};
User.prototype.orgs = function() {
var cb, params, _i, _ref;
params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
- return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/orgs"].concat(__slice.call(params), [function(err, s, b) {
+ return (_ref = this.client).get.apply(_ref, ["/users/" + this.login + "/orgs"].concat(__slice.call(params), [function(err, s, b, h) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error('User organizations error'));
} else {
- return cb(null, b);
+ return cb(null, b, h);
}
}]));
};
60 src/octonode/gist.coffee
View
@@ -16,122 +16,122 @@ class Gist
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
list: (params..., cb) ->
- @client.get "/gists", params..., (err, s, b) ->
+ @client.get "/gists", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist list error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist list error')) else cb null, b, h
# List authenticated user's public gists
# '/gists/public' GET
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
public: (params..., cb) ->
- @client.get "/gists/public", params..., (err, s, b) ->
+ @client.get "/gists/public", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist public error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist public error')) else cb null, b, h
# List authenticated user's starred gists
# '/gists/starred' GET
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
starred: (params..., cb) ->
- @client.get "/gists/starred", params..., (err, s, b) ->
+ @client.get "/gists/starred", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist starred error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist starred error')) else cb null, b, h
# List a user's public gists
# '/users/pksunkara/gists' GET
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
user: (params..., user, cb) ->
- @client.get "/users/#{user}/gists", params..., (err, s, b) ->
+ @client.get "/users/#{user}/gists", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist user error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist user error')) else cb null, b, h
# Get a single gist
# '/gists/37' GET
get: (id, cb) ->
- @client.get "/gists/#{id}", (err, s, b) ->
+ @client.get "/gists/#{id}", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist get error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist get error')) else cb null, b, h
# Create a gist
# '/gists' POST
create: (gist, cb) ->
- @client.post "/gists", gist, (err, s, b) ->
+ @client.post "/gists", gist, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('Gist create error')) else cb null, b
+ if s isnt 201 then cb(new Error('Gist create error')) else cb null, b, h
# Edit a gist
# '/gists/37' PATCH
edit: (id, gist, cb) ->
- @client.post "/gists/#{id}", gist, (err, s, b) ->
+ @client.post "/gists/#{id}", gist, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist edit error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist edit error')) else cb null, b, h
# Delete a gist
# '/gists/37' DELETE
delete: (id) ->
- @client.del "/gists/#{id}", {}, (err, s, b) =>
+ @client.del "/gists/#{id}", {}, (err, s, b, h) =>
@delete(id) if err? or s isnt 204
# Fork a gist
# '/gists/37/forks' POST
fork: (id) ->
- @client.post "/gists/#{id}/forks", {}, (err, s, b) ->
+ @client.post "/gists/#{id}/forks", {}, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('Gist fork error')) else cb null, b
+ if s isnt 201 then cb(new Error('Gist fork error')) else cb null, b, h
# Star a gist
# '/gists/37/star' PUT
star: (id) ->
- @client.put "/gists/#{id}/star", {}, (err, s, b) =>
+ @client.put "/gists/#{id}/star", {}, (err, s, b, h) =>
@star(id) if err? or s isnt 204
# Unstar a gist
# '/gists/37/unstar' DELETE
unstar: (id) ->
- @client.del "/gists/#{id}/unstar", {}, (err, s, b) =>
+ @client.del "/gists/#{id}/unstar", {}, (err, s, b, h) =>
@unstar(id) if err? or s isnt 204
# Check if a gist is starred
# '/gists/37/star' GET
check: (id) ->
- @client.get "/gists/#{id}/star", (err, s, b) ->
+ @client.get "/gists/#{id}/star", (err, s, b, h) ->
return cb(err) if err
- cb null, s is 204
+ cb null, s is 204, h
# List comments on a gist
# '/gists/37/comments' GET
listComments: (id, cb) ->
- @client.get "/gists/#{id}/comments", (err, s, b) ->
+ @client.get "/gists/#{id}/comments", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist comments error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist comments error')) else cb null, b, h
# Get a single comment
# '/gists/comments/1' GET
getComment: (id, cb) ->
- @client.get "/gists/comments/#{id}", (err, s, b) ->
+ @client.get "/gists/comments/#{id}", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist getComment error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist getComment error')) else cb null, b, h
# Create a comment
# '/gists/37/comments' POST
createComment: (id, comment, cb) ->
- @client.post "/gists/#{id}/comments", comment, (err, s, b) ->
+ @client.post "/gists/#{id}/comments", comment, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('Gist createComment error')) else cb null, b
+ if s isnt 201 then cb(new Error('Gist createComment error')) else cb null, b, h
# Edit a comment
# '/gists/comments/1' POST
updateComment: (id, comment, cb) ->
- @client.post "/gists/comments/#{id}", comment, (err, s, b) ->
+ @client.post "/gists/comments/#{id}", comment, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Gist updateComment error')) else cb null, b
+ if s isnt 200 then cb(new Error('Gist updateComment error')) else cb null, b, h
# Delete a comment
# '/gists/comments/1' DELETE
deleteComment: (id) ->
- @client.del "/gists/comments/#{id}", {}, (err, s, b) =>
+ @client.del "/gists/comments/#{id}", {}, (err, s, b, h) =>
@deleteComment(id) if err? or s isnt 204
comments: (id, cbOrCmnt, cb) ->
12 src/octonode/issue.coffee
View
@@ -12,25 +12,25 @@ class Issue
# Get a single issue
# '/repos/pksunkara/hub/issues/37' GET
info: (cb) ->
- @client.get "/repos/#{@repo}/issues/#{@number}", (err, s, b) ->
+ @client.get "/repos/#{@repo}/issues/#{@number}", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error("Issue info error")) else cb null, b
+ if s isnt 200 then cb(new Error("Issue info error")) else cb null, b, h
# Edit an issue for a repository
# '/repos/pksunkara/hub/issues/37' PATCH
update: (obj, cb) ->
- @client.post "/repos/#{@repo}/issues/#{@number}", obj, (err, s, b) ->
+ @client.post "/repos/#{@repo}/issues/#{@number}", obj, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error("Issue update error")) else cb null, b
+ if s isnt 200 then cb(new Error("Issue update error")) else cb null, b, h
# List comments on an issue
# '/repos/pksunkara/hub/issues/37/comments' GET
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
comments: (params..., cb) ->
- @client.get "/repos/" + @repo + "/issues/" + @number + "/comments", params..., (err, s, b) ->
+ @client.get "/repos/" + @repo + "/issues/" + @number + "/comments", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Issue Comments error')) else cb null, b
+ if s isnt 200 then cb(new Error('Issue Comments error')) else cb null, b, h
# Export module
module.exports = Issue
84 src/octonode/me.coffee
View
@@ -16,16 +16,16 @@ class Me
# Get a user
# '/user' GET
info: (cb) ->
- @client.get '/user', (err, s, b) ->
+ @client.get '/user', (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User info error')) else cb null, b
+ if s isnt 200 then cb(new Error('User info error')) else cb null, b, h
# Update user
# '/user' PATCH
update: (info, cb) ->
- @client.post '/user', info, (err, s, b) ->
+ @client.post '/user', info, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User update error')) else cb null, b
+ if s isnt 200 then cb(new Error('User update error')) else cb null, b, h
# Get emails of the user
# '/user/emails' GET
@@ -36,21 +36,21 @@ class Me
@deleteEmails cbOrEmails
else
cb = cbOrEmails
- @client.get '/user/emails', (err, s, b) ->
+ @client.get '/user/emails', (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User emails error')) else cb null, b
+ if s isnt 200 then cb(new Error('User emails error')) else cb null, b, h
# Set emails of the user
# '/user/emails' POST
setEmails: (emails, cb) ->
- @client.post '/user/emails', emails, (err, s, b) ->
+ @client.post '/user/emails', emails, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('User setEmails error')) else cb null, b
+ if s isnt 201 then cb(new Error('User setEmails error')) else cb null, b, h
# Delete emails of the user
# '/user/emails' DELETE
deleteEmails: (emails) ->
- @client.del '/user/emails', emails, (err, s, b) =>
+ @client.del '/user/emails', emails, (err, s, b, h) =>
@deleteEmails(emails) if err? or s isnt 204
# Get the followers of the user
@@ -58,9 +58,9 @@ class Me
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
followers: (params..., cb) ->
- @client.get '/user/followers', params..., (err, s, b) ->
+ @client.get '/user/followers', params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User followers error')) else cb null, b
+ if s isnt 200 then cb(new Error('User followers error')) else cb null, b, h
# Get the followings of the user
# '/user/following' GET
@@ -70,27 +70,27 @@ class Me
@checkFollowing cbOrUser, cb
else
cb = cbOrUser
- @client.get '/user/following', (err, s, b) ->
+ @client.get '/user/following', (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User following error')) else cb null, b
+ if s isnt 200 then cb(new Error('User following error')) else cb null, b, h
# Check if you are following a user
# '/user/following/pksunkara' GET
checkFollowing: (user, cb) ->
- @client.get "/user/following/#{user}", (err, s, b) ->
+ @client.get "/user/following/#{user}", (err, s, b, h) ->
return cb(err) if err
- cb null, s is 204
+ cb null, s is 204, h
# Follow a user
# '/user/following/pksunkara' PUT
follow: (user) ->
- @client.put "/user/following/#{user}", {}, (err, s, b) =>
+ @client.put "/user/following/#{user}", {}, (err, s, b, h) =>
@follow(user) if err? or s isnt 204
# Unfollow a user
# '/user/following/pksunkara' DELETE
unfollow: (user) ->
- @client.del "/user/following/#{user}", {}, (err, s, b) =>
+ @client.del "/user/following/#{user}", {}, (err, s, b, h) =>
@unfollow(user) if err? or s isnt 204
# Get the starred repos for the user
@@ -101,27 +101,27 @@ class Me
@checkStarred cbOrRepo, cb
else
cb = cbOrRepo
- @client.get '/user/starred', (err, s, b) ->
+ @client.get '/user/starred', (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User starred error')) else cb null, b
+ if s isnt 200 then cb(new Error('User starred error')) else cb null, b, h
# Check if you have starred a repository
# '/user/starred/pksunkara/octonode' GET
checkStarred: (repo, cb) ->
- @client.get "/user/starred/#{repo}", (err, s, b) ->
+ @client.get "/user/starred/#{repo}", (err, s, b, h) ->
return cb(err) if err
- cb null, s is 204
+ cb null, s is 204, h
# Star a repository
# '/user/starred/pksunkara/octonode' PUT
star: (repo) ->
- @client.put "/user/starred/#{repo}", {}, (err, s, b) =>
+ @client.put "/user/starred/#{repo}", {}, (err, s, b, h) =>
@star(repo) if err? or s isnt 204
# Unstar a repository
# '/user/starred/pksunkara/octonode' DELETE
unstar: (repo) ->
- @client.del "/user/starred/#{repo}", {}, (err, s, b) =>
+ @client.del "/user/starred/#{repo}", {}, (err, s, b, h) =>
@unstar(repo) if err? or s isnt 204
# Get the subscriptions of the user (what she watches)
@@ -129,9 +129,9 @@ class Me
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
watched: (params..., cb) ->
- @client.get '/user/subscriptions', params..., (err, s, b) ->
+ @client.get '/user/subscriptions', params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User subscription error')) else cb null, b
+ if s isnt 200 then cb(new Error('User subscription error')) else cb null, b, h
# Get public keys of a user
# '/user/keys' GET
@@ -146,35 +146,35 @@ class Me
@updateKey cbOrIdOrKey, cbOrKey, cb
else
cb = cbOrIdOrKey
- @client.get '/user/keys', (err, s, b) ->
+ @client.get '/user/keys', (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User keys error')) else cb null, b
+ if s isnt 200 then cb(new Error('User keys error')) else cb null, b, h
# Get a single public key
# '/user/keys/1' GET
getKey: (id, cb) ->
- @client.get "/user/keys/#{id}", (err, s, b) ->
+ @client.get "/user/keys/#{id}", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User getKey error')) else cb null, b
+ if s isnt 200 then cb(new Error('User getKey error')) else cb null, b, h
# Create a public key
# '/user/keys' POST
createKey: (key, cb) ->
- @client.post '/user/keys', key, (err, s, b) ->
+ @client.post '/user/keys', key, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('User createKey error')) else cb null, b
+ if s isnt 201 then cb(new Error('User createKey error')) else cb null, b, h
# Update a public key
# '/user/keys/1' PATCH
updateKey: (id, key, cb) ->
- @client.post "/user/keys/#{id}", key, (err, s, b) ->
+ @client.post "/user/keys/#{id}", key, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User updateKey error')) else cb null, b
+ if s isnt 200 then cb(new Error('User updateKey error')) else cb null, b, h
# Delete a public key
# '/user/keys/1' DELETE
deleteKey: (id) ->
- @client.del "/user/keys/#{id}", {}, (err, s, b) =>
+ @client.del "/user/keys/#{id}", {}, (err, s, b, h) =>
@deleteKey(id) if err? or s isnt 204
# Get organization instance for client
@@ -186,9 +186,9 @@ class Me
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
orgs: (params..., cb) ->
- @client.get "/user/orgs", params..., (err, s, b) ->
+ @client.get "/user/orgs", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User orgs error')) else cb null, b
+ if s isnt 200 then cb(new Error('User orgs error')) else cb null, b, h
# Get repository instance for client
repo: (nameOrRepo, cb) ->
@@ -202,23 +202,23 @@ class Me
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
repos: (params..., cb) ->
- @client.get "/user/repos", params..., (err, s, b) ->
+ @client.get "/user/repos", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('User repos error')) else cb null, b
+ if s isnt 200 then cb(new Error('User repos error')) else cb null, b, h
# Create a repository
# '/user/repos' POST
createRepo: (repo, cb) ->
- @client.post "/user/repos", repo, (err, s, b) ->
+ @client.post "/user/repos", repo, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('User createRepo error')) else cb null, b
+ if s isnt 201 then cb(new Error('User createRepo error')) else cb null, b, h
# Fork a repo
# '/repos/pksunkara/hub/forks' POST
fork: (repo, cb) ->
- @client.post "/repos/#{repo}/forks", {}, (err, s, b) ->
+ @client.post "/repos/#{repo}/forks", {}, (err, s, b, h) ->
return cb(err) if err
- if s isnt 202 then cb(new Error('User fork error')) else cb null, b
+ if s isnt 202 then cb(new Error('User fork error')) else cb null, b, h
# Get pull-request instance for client
pr: (repo, number) ->
28 src/octonode/org.coffee
View
@@ -14,16 +14,16 @@ class Org
# Get an organization
# '/orgs/flatiron' GET
info: (cb) ->
- @client.get "/orgs/#{@name}", (err, s, b) ->
+ @client.get "/orgs/#{@name}", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Org info error')) else cb null, b
+ if s isnt 200 then cb(new Error('Org info error')) else cb null, b, h
# Edit an organization
# '/orgs/flatiron' POST
update: (info, cb) ->
- @client.post "/orgs/#{@name}", info, (err, s, b) ->
+ @client.post "/orgs/#{@name}", info, (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Org update error')) else cb null, b
+ if s isnt 200 then cb(new Error('Org update error')) else cb null, b, h
# Get repository instance for client
repo: (nameOrRepo, cb) ->
@@ -37,37 +37,37 @@ class Org
# - page or query object, optional - params[0]
# - per_page, optional - params[1]
repos: (params..., cb) ->
- @client.get "/orgs/#{@name}/repos", params..., (err, s, b) ->
+ @client.get "/orgs/#{@name}/repos", params..., (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Org repos error')) else cb null, b
+ if s isnt 200 then cb(new Error('Org repos error')) else cb null, b, h
# Create an organisation repository
# '/orgs/flatiron/repos' POST
createRepo: (repo, cb) ->
- @client.post "/orgs/#{@name}/repos", repo, (err, s, b) ->
+ @client.post "/orgs/#{@name}/repos", repo, (err, s, b, h) ->
return cb(err) if err
- if s isnt 201 then cb(new Error('Org createRepo error')) else cb null, b
+ if s isnt 201 then cb(new Error('Org createRepo error')) else cb null, b, h
# Get an organization's teams.
# '/orgs/flatiron/teams' GET
teams: (cb) ->
- @client.get "/orgs/#{@name}/teams", (err, s, b) ->
+ @client.get "/orgs/#{@name}/teams", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Org teams error')) else cb null, b
+ if s isnt 200 then cb(new Error('Org teams error')) else cb null, b, h
# Get an organization's members.
# '/orgs/flatiron/members' GET
members: (cb) ->
- @client.get "/orgs/#{@name}/members", (err, s, b) ->
+ @client.get "/orgs/#{@name}/members", (err, s, b, h) ->
return cb(err) if err
- if s isnt 200 then cb(new Error('Org members error')) else cb null, b
+ if s isnt 200 then cb(new Error('Org members error')) else cb null, b, h
# Check an organization's member.
# '/orgs/flatiron/members/pksunkara' GET
member: (user, cb) ->
- @client.getNoFollow "/orgs/#{@name}/members/#{user}", (err, s, b) ->
+ @client.getNoFollow "/orgs/#{@name}/members/#{user}", (err, s, b, h) ->
return cb(err) if err
- cb null, s is 204