|
| 1 | +(function() { |
| 2 | + var BaseModel, ProjectBuilds, Utils, |
| 3 | + bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
| 4 | + extend = 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; }, |
| 5 | + hasProp = {}.hasOwnProperty; |
| 6 | + |
| 7 | + BaseModel = require('../BaseModel'); |
| 8 | + |
| 9 | + Utils = require('../Utils'); |
| 10 | + |
| 11 | + ProjectBuilds = (function(superClass) { |
| 12 | + extend(ProjectBuilds, superClass); |
| 13 | + |
| 14 | + function ProjectBuilds() { |
| 15 | + this.triggerBuild = bind(this.triggerBuild, this); |
| 16 | + this.showBuild = bind(this.showBuild, this); |
| 17 | + this.listBuilds = bind(this.listBuilds, this); |
| 18 | + return ProjectBuilds.__super__.constructor.apply(this, arguments); |
| 19 | + } |
| 20 | + |
| 21 | + ProjectBuilds.prototype.listBuilds = function(projectId, fn) { |
| 22 | + if (fn == null) { |
| 23 | + fn = null; |
| 24 | + } |
| 25 | + this.debug("Projects::listBuilds()"); |
| 26 | + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds", (function(_this) { |
| 27 | + return function(data) { |
| 28 | + if (fn) { |
| 29 | + return fn(data); |
| 30 | + } |
| 31 | + }; |
| 32 | + })(this)); |
| 33 | + }; |
| 34 | + |
| 35 | + ProjectBuilds.prototype.showBuild = function(projectId, buildId, fn) { |
| 36 | + if (fn == null) { |
| 37 | + fn = null; |
| 38 | + } |
| 39 | + this.debug("Projects::build()"); |
| 40 | + return this.get("projects/" + (Utils.parseProjectId(projectId)) + "/builds/" + buildId, null, (function(_this) { |
| 41 | + return function(data) { |
| 42 | + if (fn) { |
| 43 | + return fn(data); |
| 44 | + } |
| 45 | + }; |
| 46 | + })(this)); |
| 47 | + }; |
| 48 | + |
| 49 | + ProjectBuilds.prototype.triggerBuild = function(params, fn) { |
| 50 | + if (params == null) { |
| 51 | + params = {}; |
| 52 | + } |
| 53 | + if (fn == null) { |
| 54 | + fn = null; |
| 55 | + } |
| 56 | + this.debug("Projects::triggerBuild()"); |
| 57 | + return this.post("projects/" + (Utils.parseProjectId(params.projectId)) + "/trigger/builds", params, null, (function(_this) { |
| 58 | + return function(data) { |
| 59 | + if (fn) { |
| 60 | + return fn(data); |
| 61 | + } |
| 62 | + }; |
| 63 | + })(this)); |
| 64 | + }; |
| 65 | + |
| 66 | + return ProjectBuilds; |
| 67 | + |
| 68 | + })(BaseModel); |
| 69 | + |
| 70 | + module.exports = function(client) { |
| 71 | + return new ProjectBuilds(client); |
| 72 | + }; |
| 73 | + |
| 74 | +}).call(this); |
0 commit comments