Comparing version 0.1.13 to 0.1.14
@@ -19,2 +19,4 @@ /* | ||
this.timeout(10000); | ||
beforeEach(function() { | ||
@@ -49,3 +51,3 @@ client = new Client({ | ||
Assert.equal(err, null); | ||
Assert.equal(res.length, 2); | ||
Assert.equal(res.length, 1); | ||
@@ -66,3 +68,3 @@ client.authorization["delete"]( | ||
Assert.equal(err, null); | ||
Assert.equal(res.length, 1); | ||
Assert.equal(res.length, 0); | ||
@@ -69,0 +71,0 @@ next(); |
@@ -511,2 +511,207 @@ /** | ||
/** section: github | ||
* gists#getComments(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: | ||
* | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - gist_id (String): Required. Id (SHA1 hash) of the gist. | ||
**/ | ||
this.getComments = 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 = res.data && 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", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { | ||
if (res.headers[header]) | ||
ret.meta[header] = res.headers[header]; | ||
}); | ||
if (callback) | ||
callback(null, ret); | ||
}); | ||
}; | ||
/** section: github | ||
* gists#getComment(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: | ||
* | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - gist_id (String): Required. Id (SHA1 hash) of the gist. | ||
* - id (String): Required. | ||
**/ | ||
this.getComment = 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 = res.data && 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", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { | ||
if (res.headers[header]) | ||
ret.meta[header] = res.headers[header]; | ||
}); | ||
if (callback) | ||
callback(null, ret); | ||
}); | ||
}; | ||
/** section: github | ||
* gists#createComment(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: | ||
* | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - gist_id (String): Required. Id (SHA1 hash) of the gist. | ||
* - body (String): Required. | ||
**/ | ||
this.createComment = 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 = res.data && 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", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { | ||
if (res.headers[header]) | ||
ret.meta[header] = res.headers[header]; | ||
}); | ||
if (callback) | ||
callback(null, ret); | ||
}); | ||
}; | ||
/** section: github | ||
* gists#editComment(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: | ||
* | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - gist_id (String): Required. Id (SHA1 hash) of the gist. | ||
* - id (String): Required. | ||
* - body (String): Required. | ||
**/ | ||
this.editComment = 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 = res.data && 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", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { | ||
if (res.headers[header]) | ||
ret.meta[header] = res.headers[header]; | ||
}); | ||
if (callback) | ||
callback(null, ret); | ||
}); | ||
}; | ||
/** section: github | ||
* gists#deleteComment(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: | ||
* | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - gist_id (String): Required. Id (SHA1 hash) of the gist. | ||
* - id (String): Required. | ||
**/ | ||
this.deleteComment = 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 = res.data && 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", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { | ||
if (res.headers[header]) | ||
ret.meta[header] = res.headers[header]; | ||
}); | ||
if (callback) | ||
callback(null, ret); | ||
}); | ||
}; | ||
}).call(gists.gists); |
@@ -422,2 +422,185 @@ /* | ||
}); | ||
it("should successfully execute GET /gists/:gist_id/comments/:id (getComments)", function(next) { | ||
client.gists.createComment( | ||
{ | ||
gist_id: "3047099", | ||
body: "This is a test comment.", | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists.getComments( | ||
{ | ||
gist_id: "3047099" | ||
}, | ||
function(err, res) { | ||
var comment = res.pop(); | ||
Assert.equal(err, null); | ||
Assert.equal(comment.user.login, "mikedeboertest"); | ||
Assert.equal(comment.id, id); | ||
Assert.equal(comment.body, "This is a test comment."); | ||
client.gists["deleteComment"]( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
next(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
it("should successfully execute GET /gists/:gist_id/comments/:id (getComment)", function(next) { | ||
client.gists.createComment( | ||
{ | ||
gist_id: "3047099", | ||
body: "This is a test comment.", | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists.getComment( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
Assert.equal(res.user.login, "mikedeboertest"); | ||
Assert.equal(res.id, id); | ||
Assert.equal(res.body, "This is a test comment."); | ||
client.gists["deleteComment"]( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
next(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
it("should successfully execute POST /gists/:gist_id/comments (createComment)", function(next) { | ||
client.gists.createComment( | ||
{ | ||
gist_id: "3047099", | ||
body: "This is a test comment.", | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists.getComment( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
Assert.equal(res.user.login, "mikedeboertest"); | ||
Assert.equal(res.id, id); | ||
Assert.equal(res.body, "This is a test comment."); | ||
client.gists["deleteComment"]( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
next(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
it("should successfully execute PATCH /gists/:gist_id/comments/:id (editComment)", function(next) { | ||
client.gists.createComment( | ||
{ | ||
gist_id: "3047099", | ||
body: "This is a test comment.", | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists.editComment( | ||
{ | ||
gist_id: "3047099", | ||
id: id, | ||
body: "This comment has been edited." | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists.getComment( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
Assert.equal(res.user.login, "mikedeboertest"); | ||
Assert.equal(res.id, id); | ||
Assert.equal(res.body, "This comment has been edited."); | ||
client.gists["deleteComment"]( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
next(); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
it("should successfully execute DELETE /gists/:gist_id/comments/:id (deleteComment)", function(next) { | ||
client.gists.createComment( | ||
{ | ||
gist_id: "3047099", | ||
body: "This is a test comment.", | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
var id = res.id; | ||
client.gists["deleteComment"]( | ||
{ | ||
gist_id: "3047099", | ||
id: id | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
next(); | ||
} | ||
); | ||
} | ||
); | ||
}); | ||
}); |
@@ -337,3 +337,3 @@ /** | ||
* - 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. | ||
* - force (Boolean): Optional. 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. | ||
**/ | ||
@@ -340,0 +340,0 @@ this.updateReference = function(msg, block, callback) { |
@@ -527,2 +527,19 @@ /* | ||
}); | ||
it("should successfully execute GET /repos/:user/:repo/contents/:path (createContent)", function(next) { | ||
client.repos.getContent( | ||
{ | ||
user: "String", | ||
repo: "String", | ||
path: "String", | ||
ref: "String", | ||
content:"String", | ||
message:"String" | ||
}, | ||
function(err, res) { | ||
Assert.equal(err, null); | ||
// other assertions go here | ||
next(); | ||
} | ||
); | ||
}); | ||
@@ -529,0 +546,0 @@ it("should successfully execute PUT /repos/:user/:repo/contents/:path (createFile)", function(next) { |
@@ -30,6 +30,5 @@ /** | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - user (String): Required. | ||
* - repo (String): Required. | ||
* - state (String): Required. open or closed Validation rule: ` ^(open|closed)$ `. | ||
* - keyword (String): Required. Search term | ||
* - q (String): Required. Search Term | ||
* - sort (String): Optional. comments, created, or updated Validation rule: ` ^(comments|created|updated)$ `. | ||
* - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. | ||
**/ | ||
@@ -74,5 +73,5 @@ this.issues = function(msg, block, callback) { | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - keyword (String): Required. Search term | ||
* - language (String): Optional. Filter results by language, see https://github.com/languages | ||
* - start_page (Number): Optional. Page number to fetch Validation rule: ` ^[0-9]+$ `. | ||
* - q (String): Required. Search Term | ||
* - sort (String): Optional. stars, forks, or updated Validation rule: ` ^(stars|forks|updated)$ `. | ||
* - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. | ||
**/ | ||
@@ -117,4 +116,5 @@ this.repos = function(msg, block, callback) { | ||
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. | ||
* - keyword (String): Required. Keyword search parameters | ||
* - start_page (Number): Optional. Page number to fetch Validation rule: ` ^[0-9]+$ `. | ||
* - q (String): Required. Search Term | ||
* - sort (String): Optional. followers, repositories, or joined Validation rule: ` ^(followers|repositories|joined)$ `. | ||
* - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. | ||
**/ | ||
@@ -121,0 +121,0 @@ this.users = function(msg, block, callback) { |
13
index.js
@@ -744,9 +744,10 @@ "use strict"; | ||
res.on("end", function() { | ||
if (!callbackCalled && res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { | ||
callbackCalled = true; | ||
callback(new error.HttpError(data, res.statusCode)) | ||
} | ||
else if (!callbackCalled) { | ||
if (callbackCalled) | ||
return; | ||
callbackCalled = true; | ||
if (res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { | ||
callback(new error.HttpError(data, res.statusCode)); | ||
} else { | ||
res.data = data; | ||
callbackCalled = true; | ||
callback(null, res); | ||
@@ -753,0 +754,0 @@ } |
{ | ||
"name" : "github", | ||
"version" : "0.1.13", | ||
"version" : "0.1.14", | ||
"description" : "NodeJS wrapper for the GitHub API", | ||
@@ -5,0 +5,0 @@ "author": "Mike de Boer <info@mikedeboer.nl>", |
@@ -7,3 +7,3 @@ # JavaScript GitHub API for Node.JS | ||
Install with the Node.JS package manager [npm](http://npmjs.org/): | ||
Install with the Node.JS package manager [npm](http://npmjs.org/) ![NPM version](https://badge.fury.io/js/github.png): | ||
@@ -10,0 +10,0 @@ $ npm install github |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
665534
16133