diff --git a/lib/octonode/team.js b/lib/octonode/team.js index e80e07a..abbea40 100644 --- a/lib/octonode/team.js +++ b/lib/octonode/team.js @@ -165,6 +165,26 @@ }])); }; + Team.prototype.addRepo = function(repo, cbOrOptions, cb) { + var param; + if ((cb == null) && cbOrOptions) { + cb = cbOrOptions; + param = {}; + } else if (typeof cbOrOptions === 'object') { + param = cbOrOptions; + } + return this.client.put("/teams/" + this.id + "/repos/" + repo, param, function(err, s, b, h) { + if (err) { + return cb(err); + } + if (s !== 204) { + return cb(new Error("Team addRepo error")); + } else { + return cb(null, b, h); + } + }); + }; + Team.prototype.removeRepo = function(repo, cb) { return this.client.del("/teams/" + this.id + "/repos/" + repo, {}, function(err, s, b, h) { if (err) { diff --git a/src/octonode/team.coffee b/src/octonode/team.coffee index 2895864..06a4be2 100644 --- a/src/octonode/team.coffee +++ b/src/octonode/team.coffee @@ -99,6 +99,18 @@ class Team extends Base return cb(err) if err if s isnt 200 then cb(new Error("Team repos error")) else cb null, b, h + # Add repo to a team + # '/teams/37/repos/flatiron/hub' PUT + addRepo: (repo, cbOrOptions, cb) -> + if !cb? and cbOrOptions + cb = cbOrOptions + param = {} + else if typeof cbOrOptions is 'object' + param = cbOrOptions + @client.put "/teams/#{@id}/repos/#{repo}", param, (err, s, b, h) -> + return cb(err) if err + if s isnt 204 then cb(new Error("Team addRepo error")) else cb null, b, h + # Remove repo from a team # '/teams/37/repos/flatiron/hub' DELETE removeRepo: (repo, cb) ->