octonode
Advanced tools
Comparing version 0.9.5 to 0.10.0
// Generated by CoffeeScript 1.12.7 | ||
(function() { | ||
var Client, Gist, HttpError, Issue, Label, Me, Milestone, Notification, Org, Pr, Project, Promise, Release, Repo, Search, Team, User, extend, request, url, | ||
var Client, Gist, HttpError, Issue, Label, Me, Milestone, Notification, Org, Pr, Project, Promise, Release, Repo, Search, Team, User, extend, pkg, request, url, | ||
extend1 = 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; }, | ||
@@ -15,2 +15,4 @@ hasProp = {}.hasOwnProperty, | ||
pkg = require('../../package.json'); | ||
Me = require('./me'); | ||
@@ -69,3 +71,3 @@ | ||
headers: { | ||
'User-Agent': 'octonode/0.3 (https://github.com/pksunkara/octonode) terminal/0.0' | ||
'User-Agent': "octonode/" + pkg.version + " (https://github.com/pksunkara/octonode) terminal/0.0" | ||
} | ||
@@ -305,2 +307,22 @@ }; | ||
Client.prototype.getAccept = function() { | ||
var accept, callback, i, params, path; | ||
path = arguments[0], accept = arguments[1], params = 4 <= arguments.length ? slice.call(arguments, 2, i = arguments.length - 1) : (i = 2, []), callback = arguments[i++]; | ||
return this.request(this.requestOptions({ | ||
uri: this.buildUrl.apply(this, [path].concat(slice.call(params))), | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': "application/vnd.github." + accept + "+json" | ||
} | ||
}), (function(_this) { | ||
return function(err, res, body) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return _this.errorHandle(res, body, callback); | ||
}; | ||
})(this)); | ||
}; | ||
Client.prototype.post = function(path, content, options, callback) { | ||
@@ -351,2 +373,21 @@ var reqDefaultOption, reqOpt; | ||
Client.prototype.patchAccept = function(path, accept, content, callback) { | ||
return this.request(this.requestOptions({ | ||
uri: this.buildUrl(path), | ||
method: 'PATCH', | ||
body: JSON.stringify(content), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': "application/vnd.github." + accept + "+json" | ||
} | ||
}), (function(_this) { | ||
return function(err, res, body) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return _this.errorHandle(res, body, callback); | ||
}; | ||
})(this)); | ||
}; | ||
Client.prototype.put = function(path, content, options, callback) { | ||
@@ -392,2 +433,21 @@ if (!callback && options) { | ||
Client.prototype.delAccept = function(path, accept, content, callback) { | ||
return this.request(this.requestOptions({ | ||
uri: this.buildUrl(path), | ||
method: 'DELETE', | ||
body: JSON.stringify(content), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'Accept': "application/vnd.github." + accept + "+json" | ||
} | ||
}), (function(_this) { | ||
return function(err, res, body) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
return _this.errorHandle(res, body, callback); | ||
}; | ||
})(this)); | ||
}; | ||
Client.prototype.limit = function(callback) { | ||
@@ -394,0 +454,0 @@ return this.get('/rate_limit', function(err, s, b) { |
@@ -77,4 +77,6 @@ // Generated by CoffeeScript 1.12.7 | ||
Pr.prototype.commits = function(cb) { | ||
return this.client.get("/repos/" + this.repo + "/pulls/" + this.number + "/commits", function(err, s, b, h) { | ||
Pr.prototype.commits = function() { | ||
var cb, i, params, 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 + "/pulls/" + this.number + "/commits"].concat(slice.call(params), [function(err, s, b, h) { | ||
if (err) { | ||
@@ -88,3 +90,3 @@ return cb(err); | ||
} | ||
}); | ||
}])); | ||
}; | ||
@@ -91,0 +93,0 @@ |
@@ -12,4 +12,3 @@ // Generated by CoffeeScript 1.12.7 | ||
function Project(repo, number, client) { | ||
this.repo = repo; | ||
function Project(number, client) { | ||
this.number = number; | ||
@@ -20,3 +19,3 @@ this.client = client; | ||
Project.prototype.info = function(cb) { | ||
return this.client.get("/repos/" + this.repo + "/projects/" + this.number, function(err, s, b, h) { | ||
return this.client.getAccept("/projects/" + this.number, 'inertia-preview', function(err, s, b, h) { | ||
if (err) { | ||
@@ -34,3 +33,3 @@ return cb(err); | ||
Project.prototype.update = function(obj, cb) { | ||
return this.client.post("/repos/" + this.repo + "/projects/" + this.number, obj, function(err, s, b, h) { | ||
return this.client.patchAccept("/projects/" + this.number, 'inertia-preview', obj, function(err, s, b, h) { | ||
if (err) { | ||
@@ -48,3 +47,3 @@ return cb(err); | ||
Project.prototype["delete"] = function(cb) { | ||
return this.client.del("/repos/" + this.repo + "/projects/" + this.number, {}, function(err, s, b, h) { | ||
return this.client.delAccept("/projects/" + this.number, 'inertia-preview', {}, function(err, s, b, h) { | ||
if (err) { | ||
@@ -51,0 +50,0 @@ return cb(err); |
@@ -403,3 +403,3 @@ // Generated by CoffeeScript 1.12.7 | ||
params = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), cb = arguments[i++]; | ||
return (ref1 = this.client).get.apply(ref1, ["/repos/" + this.name + "/projects"].concat(slice.call(params), [function(err, s, b, h) { | ||
return (ref1 = this.client).getAccept.apply(ref1, ["/repos/" + this.name + "/projects", 'inertia-preview'].concat(slice.call(params), [function(err, s, b, h) { | ||
if (err) { | ||
@@ -406,0 +406,0 @@ return cb(err); |
{ | ||
"name": "octonode", | ||
"version": "0.9.5", | ||
"version": "0.10.0", | ||
"author": "Pavan Kumar Sunkara <pavan.sss1991@gmail.com> (http://pksunkara.github.com)", | ||
@@ -15,5 +15,4 @@ "description": "nodejs wrapper for github v3 api", | ||
"scripts": { | ||
"test": "vows --spec test/auth/index.js", | ||
"lib": "./node_modules/coffee-script/bin/cake lib", | ||
"watch": "./node_modules/coffee-script/bin/cake watch" | ||
"test": "npm run lib && vows --spec test/auth/index.js", | ||
"lib": "coffee -c -o lib src" | ||
}, | ||
@@ -27,5 +26,5 @@ "dependencies": { | ||
"devDependencies": { | ||
"coffee-script": "^1.12.4", | ||
"nock": "^10.0.0", | ||
"vows": "^0.8.1" | ||
"coffeescript": "^1.12.7", | ||
"nock": "^13.0.5", | ||
"vows": "^0.8.2" | ||
}, | ||
@@ -32,0 +31,0 @@ "engines": { |
@@ -1,3 +0,2 @@ | ||
# octonode [![Gitter chat](https://badges.gitter.im/pksunkara/octonode.svg)](https://gitter.im/pksunkara/octonode) | ||
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpksunkara%2Foctonode.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpksunkara%2Foctonode?ref=badge_shield) | ||
# octonode | ||
@@ -29,3 +28,3 @@ octonode is a library for nodejs to access the [github v3 api](https://developer.github.com/) | ||
var ghteam = client.team(37); | ||
var ghproject = client.project('pksunkara/hub', 37); | ||
var ghproject = client.project(37); | ||
var ghnotification = client.notification(37); | ||
@@ -49,3 +48,3 @@ | ||
```js | ||
var client = github.client('someaccesstoken'); | ||
var client = github.client('some_access_token'); | ||
@@ -57,28 +56,2 @@ client.get('/user', {}, function (err, status, body, headers) { | ||
#### Build a client from credentials | ||
```js | ||
var client = github.client({ | ||
username: 'pksunkara', | ||
password: 'password' | ||
}); | ||
client.get('/user', {}, function (err, status, body, headers) { | ||
console.log(body); //json object | ||
}); | ||
``` | ||
#### Build a client from client keys | ||
```js | ||
var client = github.client({ | ||
id: 'abcdefghijklmno', | ||
secret: 'abcdefghijk' | ||
}); | ||
client.get('/user', {}, function (err, status, body, headers) { | ||
console.log(body); //json object | ||
}); | ||
``` | ||
#### Build a client from a different host | ||
@@ -88,6 +61,3 @@ You can configure the `protocol`, `hostname` and `port` to use. For example to connect to a GitHub Enterprise instance. | ||
```js | ||
var client = github.client({ | ||
username: 'pksunkara', | ||
password: 'password' | ||
},{ | ||
var client = github.client('some_access_token', { | ||
hostname: 'mydomain.com/api/v3' | ||
@@ -151,13 +121,2 @@ }); | ||
#### Revoke authentication to github in cli mode (desktop application) | ||
```js | ||
github.auth.config({ | ||
username: 'pksunkara', | ||
password: 'password' | ||
}).revoke(id, function (err) { | ||
if (err) throw err; | ||
}); | ||
``` | ||
#### Authenticate to github in web mode (web application) | ||
@@ -239,3 +198,3 @@ | ||
If you would like to work with promises rather than callbacks, you can call the promise based version of any of the api calls by appending `Async` to the function call. | ||
If you would like to work with promises rather than callbacks, you can call the promise based version of any of the api calls by appending `Async` to the function call. | ||
@@ -1088,3 +1047,3 @@ For example `prs()` becomes `prsAsync()` like this: | ||
#### Get a single project (GET /repos/pksunkara/hub/projects/37) | ||
#### Get a single project (GET /projects/37) | ||
@@ -1095,3 +1054,3 @@ ```js | ||
#### Edit a project for a repository (PATCH /repos/pksunkara/hub/projects/37) | ||
#### Edit a project for a repository (PATCH /projects/37) | ||
@@ -1104,3 +1063,3 @@ ```js | ||
#### Delete a project for a repository (DELETE /repos/pksunkara/hub/projects/37) | ||
#### Delete a project for a repository (DELETE /projects/37) | ||
@@ -1308,3 +1267,3 @@ ```js | ||
}; | ||
ghrelease.uplaodAssets(image, options, callback) | ||
ghrelease.uploadAssets(image, options, callback) | ||
``` | ||
@@ -1685,3 +1644,3 @@ ## Github gists api | ||
__I accept pull requests and guarantee a reply back within a day__ | ||
__I accept pull requests__ | ||
@@ -1691,7 +1650,6 @@ ## License | ||
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fpksunkara%2Foctonode.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fpksunkara%2Foctonode?ref=badge_large) | ||
## Bug Reports | ||
Report [here](https://github.com/pksunkara/octonode/issues). __Guaranteed reply within a day__. | ||
Report [here](https://github.com/pksunkara/octonode/issues). | ||
@@ -1698,0 +1656,0 @@ ## Contact |
158105
3537
1648