Skip to content
This repository

Support for listReleases #33

Open
wants to merge 4 commits into from

5 participants

Guy Bedford Nicu Ciocan Artem Polikarpov Robert Nelson Ruben Daniels
Guy Bedford

I haven't got to adding all of the releases support, but this is a start, and the others should fall quite simply after this.

I had to add the custom media type support in the block itself (http://developer.github.com/v3/media/).

Feedback appreciated for getting this included.

Artem Polikarpov

It looks like you are the first who’ve started on Releases API. Great! Can’t wait for other methods, especially for creating releases and uploading assets.

Nicu Ciocan

@artpolikarpov I have been working on the Releases API in the last 3 days, for the company I work on and I published a node module on NPM, you can find it here: https://github.com/nicu/grel

It's not complete yet, but it does what we need: create, find, remove releases and attach files.

Robert Nelson

This project seems dormant. I've forked it to http://github.com/open-sw/node-github2 and added full release support. I've also fixed some bugs and greatly simplified the code.

Ruben Daniels
Owner

Hey guys, this project has moved to https://github.com/mikedeboer/node-github. Good Luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
42 api/v3.0.0/repos.js
@@ -413,6 +413,48 @@ var repos = module.exports = {
413 413 callback(null, ret);
414 414 });
415 415 };
  416 +
  417 + /** section: github
  418 + * repos#listReleases(msg, callback) -> null
  419 + * - msg (Object): Object that contains the parameters and their values to be sent to the server.
  420 + * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
  421 + *
  422 + * ##### Params on the `msg` object:
  423 + *
  424 + * - user (String): Required.
  425 + * - repo (String): Required.
  426 + * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `.
  427 + * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `.
  428 + **/
  429 + this.listReleases = function(msg, block, callback) {
  430 + var self = this;
  431 + this.client.httpSend(msg, block, function(err, res) {
  432 + if (err)
  433 + return self.sendError(err, null, msg, callback);
  434 +
  435 + var ret;
  436 + try {
  437 + ret = res.data && JSON.parse(res.data);
  438 + }
  439 + catch (ex) {
  440 + if (callback)
  441 + callback(new error.InternalServerError(ex.message), res);
  442 + return;
  443 + }
  444 +
  445 + if (!ret)
  446 + ret = {};
  447 + if (!ret.meta)
  448 + ret.meta = {};
  449 + ["x-ratelimit-limit", "x-ratelimit-remaining", "x-oauth-scopes", "link"].forEach(function(header) {
  450 + if (res.headers[header])
  451 + ret.meta[header] = res.headers[header];
  452 + });
  453 +
  454 + if (callback)
  455 + callback(null, ret);
  456 + });
  457 + };
416 458
417 459 /** section: github
418 460 * repos#getContributors(msg, callback) -> null
16 api/v3.0.0/reposTest.js
@@ -186,6 +186,22 @@ describe("[repos]", function() {
186 186 }
187 187 );
188 188 });
  189 +
  190 + it("should successfully execute GET /repos/:user/:repo/releases (listReleases)", function(next) {
  191 + client.repos.listReleases(
  192 + {
  193 + user: "String",
  194 + repo: "String",
  195 + page: "Number",
  196 + per_page: "Number"
  197 + },
  198 + function(err, res) {
  199 + Assert.equal(err, null);
  200 + // other assertions go here
  201 + next();
  202 + }
  203 + );
  204 + });
189 205
190 206 it("should successfully execute GET /repos/:user/:repo/contributors (getContributors)", function(next) {
191 207 client.repos.getContributors(
12 api/v3.0.0/routes.json
@@ -1808,6 +1808,18 @@
1808 1808 }
1809 1809 }
1810 1810 },
  1811 +
  1812 + "list-releases": {
  1813 + "url": "/repos/:user/:repo/releases",
  1814 + "method": "GET",
  1815 + "media-type": "application/vnd.github.manifold-preview",
  1816 + "params": {
  1817 + "$user": null,
  1818 + "$repo": null,
  1819 + "$page": null,
  1820 + "$per_page": null
  1821 + }
  1822 + },
1811 1823
1812 1824 "get-contributors": {
1813 1825 "url": "/repos/:user/:repo/contributors",
5 index.js
@@ -631,6 +631,11 @@ var Client = module.exports = function(config) {
631 631 ? "application/json"
632 632 : "application/x-www-form-urlencoded";
633 633 }
  634 + // custom block media types (http://developer.github.com/v3/media/)
  635 + if (block['media-type']) {
  636 + headers["accept"] = block['media-type'];
  637 + }
  638 +
634 639 if (this.auth) {
635 640 var basic;
636 641 switch (this.auth.type) {

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.