octonode
Advanced tools
Comparing version 0.6.2 to 0.6.3
@@ -17,2 +17,3 @@ // Generated by CoffeeScript 1.7.1 | ||
milestone: require('./octonode/milestone'), | ||
label: require('./octonode/label'), | ||
me: require('./octonode/me') | ||
@@ -19,0 +20,0 @@ }; |
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var Client, Gist, HttpError, Issue, Me, Milestone, Org, Pr, Repo, Search, Team, User, extend, request, url, | ||
var Client, Gist, HttpError, Issue, Label, Me, Milestone, Org, Pr, Repo, Search, Team, User, extend, request, url, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -31,2 +31,4 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
Label = require('./label'); | ||
extend = require('deep-extend'); | ||
@@ -104,2 +106,6 @@ | ||
Client.prototype.label = function(repo, name) { | ||
return new Label(repo, name, this); | ||
}; | ||
Client.prototype.requestOptions = function(params1, params2) { | ||
@@ -131,7 +137,9 @@ return extend(this.requestDefaults, params1, params2); | ||
} | ||
if (typeof this.token === 'string') { | ||
query.access_token = this.token; | ||
} else if (typeof this.token === 'object' && this.token.id) { | ||
query.client_id = this.token.id; | ||
query.client_secret = this.token.secret; | ||
if (this.token) { | ||
if (typeof this.token === 'string') { | ||
query.access_token = this.token; | ||
} else if (typeof this.token === 'object' && this.token.id) { | ||
query.client_id = this.token.id; | ||
query.client_secret = this.token.secret; | ||
} | ||
} | ||
@@ -156,2 +164,3 @@ if (query.q) { | ||
_url += "" + separator + "q=" + q; | ||
query.q = q; | ||
} | ||
@@ -158,0 +167,0 @@ return _url; |
@@ -257,2 +257,38 @@ // Generated by CoffeeScript 1.7.1 | ||
Repo.prototype.label = function(nameOrLabel, cb) { | ||
if (typeof cb === 'function' && typeof nameOrLabel === 'object') { | ||
return this.createLabel(nameOrLabel, cb); | ||
} else { | ||
return this.client.label(this.name, nameOrLabel); | ||
} | ||
}; | ||
Repo.prototype.labels = 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 + "/labels"].concat(__slice.call(params), [function(err, s, b, h) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (s !== 200) { | ||
return cb(new Error("Repo labels error")); | ||
} else { | ||
return cb(null, b, h); | ||
} | ||
}])); | ||
}; | ||
Repo.prototype.createLabel = function(label, cb) { | ||
return this.client.post("/repos/" + this.name + "/labels", label, function(err, s, b, h) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (s !== 201) { | ||
return cb(new Error("Repo createLabel error")); | ||
} else { | ||
return cb(null, b, h); | ||
} | ||
}); | ||
}; | ||
Repo.prototype.readme = function(cbOrRef, cb) { | ||
@@ -374,3 +410,3 @@ if ((cb == null) && cbOrRef) { | ||
} | ||
return this.client.get("/repos/" + this.name + "/" + format + "/" + cbOrRef, function(err, s, b, h) { | ||
return this.client.getNoFollow("/repos/" + this.name + "/" + format + "/" + cbOrRef, function(err, s, b, h) { | ||
if (err) { | ||
@@ -382,3 +418,3 @@ return cb(err); | ||
} else { | ||
return cb(null, h['Location'], h); | ||
return cb(null, h['location'], h); | ||
} | ||
@@ -488,2 +524,18 @@ }); | ||
Repo.prototype.createRef = function(ref, sha, cb) { | ||
return this.client.post("/repos/" + this.name + "/git/refs", { | ||
ref: ref, | ||
sha: sha | ||
}, function(err, s, b) { | ||
if (err) { | ||
return cb(err); | ||
} | ||
if (s !== 201) { | ||
return cb(new Error("Repo createRef error")); | ||
} else { | ||
return cb(null, b); | ||
} | ||
}); | ||
}; | ||
Repo.prototype.updateRef = function(ref, sha, cb) { | ||
@@ -490,0 +542,0 @@ return this.client.post("/repos/" + this.name + "/git/refs/" + ref, { |
{ | ||
"name": "octonode", | ||
"version": "0.6.2", | ||
"version": "0.6.3", | ||
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (http://pksunkara.github.com)", | ||
@@ -5,0 +5,0 @@ "description": "nodejs wrapper for github v3 api", |
@@ -1,2 +0,2 @@ | ||
# octonode | ||
# octonode [![Gitter chat](https://badges.gitter.im/pksunkara/octonode.png)](https://gitter.im/pksunkara/octonode) | ||
@@ -23,2 +23,3 @@ octonode is a library for nodejs to access the [github v3 api](http://developer.github.com) | ||
var ghmilestone = client.milestone('pksunkara/hub', 37); | ||
var ghlabel = client.label('pksunkara/hub', 'todo'); | ||
var ghpr = client.pr('pksunkara/hub', 37); | ||
@@ -522,2 +523,20 @@ var ghgist = client.gist(); | ||
#### Get the labels for a repository (GET /repos/pksunkara/hub/labels) | ||
This query supports [pagination](#pagination). | ||
```js | ||
ghrepo.labels(callback); //array of labels | ||
``` | ||
#### Create a label for a repository (POST /repos/pksunkara/hub/labels) | ||
```js | ||
ghrepo.label({ | ||
"name": "Priority", | ||
"color": "ff0000", | ||
}, callback); //label | ||
``` | ||
#### Get the pull requests for a repository (GET /repos/pksunkara/hub/pulls) | ||
@@ -733,2 +752,10 @@ | ||
#### List comments on an issue (GET /repos/pksunkara/hub/issues/37/comments) | ||
This query supports [pagination](#pagination). | ||
```js | ||
ghissue.comments(callback); //array of comments | ||
``` | ||
## Github milestones api | ||
@@ -742,3 +769,3 @@ | ||
#### Edit an milestone for a repository (PATCH /repos/pksunkara/hub/milestones/37) | ||
#### Edit a milestone for a repository (PATCH /repos/pksunkara/hub/milestones/37) | ||
@@ -751,10 +778,30 @@ ```js | ||
#### List comments on an issue (GET /repos/pksunkara/hub/issues/37/comments) | ||
#### Delete a milestone for a repository (DELETE /repos/pksunkara/hub/milestones/37) | ||
This query supports [pagination](#pagination). | ||
```js | ||
ghmilestone.delete(callback); //milestone | ||
``` | ||
## Github labels api | ||
#### Get a single label (GET /repos/pksunkara/hub/labels/todo) | ||
```js | ||
ghissue.comments(callback); //array of comments | ||
ghlabel.info(callback); //label | ||
``` | ||
#### Edit a label for a repository (PATCH /repos/pksunkara/hub/labels/todo) | ||
```js | ||
ghlabel.update({ | ||
"color": "000000", | ||
}, callback); //label | ||
``` | ||
#### Delete a label for a repository (PATCH /repos/pksunkara/hub/labels/todo) | ||
```js | ||
ghlabel.delete(callback); //label | ||
``` | ||
## Github pull requests api | ||
@@ -962,3 +1009,3 @@ | ||
```js | ||
ghteam.repos(callback); //Array of JSON | ||
ghteam.repos(callback); //array of repos | ||
``` | ||
@@ -1035,4 +1082,2 @@ | ||
org.update(dict_with_update_properties, callback); | ||
org.add_member('user', 'team', callback); | ||
org.remove_member('user', callback); | ||
org.get_public_members(callback); | ||
@@ -1039,0 +1084,0 @@ org.is_public_member('user', callback); |
99299
18
2197
1186