diff --git a/README.md b/README.md index 679bd44e9..efc884092 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,18 @@ let projects = await gitlab.projects.all(); console.log(projects); ``` +General rule about all the function parameters: +- If its a required parameter, it is a named argument in the functions +- If its an optional parameter, it is defined in a options object following the named arguments + +ie. + +```javascript +GitlabAPI.projects.create(projectId, { + //options defined in the gitlab api documentation +}) +``` + Contributors ------------ This started off as a fork from [node-gitlab](https://github.com/node-gitlab/node-gitlab) but I ended up rewriting 90% of the code. Here are the original work's [contributers](https://github.com/node-gitlab/node-gitlab#contributors). @@ -52,6 +64,12 @@ MIT Changelog ========= +[1.0.4](https://github.com/jdalrymple/node-gitlab-api/commit/fe5a5fbb8d01fb670b7c7b14ce2c5b7f30d71fe5) (2017-06-23) +------------------ +- Adding more to the labels API +- Removed the old 'list' calls for projects and issues which displayed a deprecated message. Only all is available now. +- Cleaned up the Issues class + [1.0.3](https://github.com/jdalrymple/node-gitlab-api/commit/fe5a5fbb8d01fb670b7c7b14ce2c5b7f30d71fe5) (2017-06-23) ------------------ - Updating problems within the Milestone API diff --git a/package.json b/package.json index 6dd91f078..b8f2c602a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-gitlab-api", - "version": "1.0.3", + "version": "1.0.4", "description": "Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.", "main": "src/index.js", "directories": {}, diff --git a/src/Models/Issues.js b/src/Models/Issues.js index 9d62ba765..ed826a595 100644 --- a/src/Models/Issues.js +++ b/src/Models/Issues.js @@ -10,48 +10,7 @@ class Issues extends BaseModel { options.page = options.page || 1; options.per_page = options.per_page || 100; - return this.get("issues", arguments[0]); - } - - show(projectId, issueId) { - projectId = Utils.parse(projectId); - issueId = Utils.parse(issueId); - - return this.get(`projects/${projectId}/issues/${issueId}`); - } - - create(projectId, options = {}) { - projectId = Utils.parse(projectId); - - return this.post(`projects/${projectId}/issues`, options); - } - - edit(projectId, issueId, options = {}) { - projectId = Utils.parse(projectId); - issueId = Utils.parse(issueId); - - return this.put(`projects/${projectId}/issues/${issueId}`, options); - } - - remove(projectId, issueId) { - projectId = Utils.parse(projectId); - issueId = Utils.parse(issueId); - - return this.delete(`projects/${projectId}/issues/${issueId}`); - } - - subscribe(projectId, issueId, options = {}) { - projectId = Utils.parse(projectId); - issueId = Utils.parse(issueId); - - return this.post(`projects/${projectId}/issues/${issueId}/subscription`, options); - } - - unsubscribe(projectId, issueId) { - projectId = Utils.parse(projectId); - issueId = Utils.parse(issueId); - - return this.delete(`projects/${projectId}/issues/${issueId}/subscription`); + return this.get("issues", options); } } diff --git a/src/Models/Labels.js b/src/Models/Labels.js index 0bddc2ee5..20ae0f64b 100644 --- a/src/Models/Labels.js +++ b/src/Models/Labels.js @@ -6,9 +6,43 @@ class Labels extends BaseModel { super(...args); } + all(options = {}) { + options.page = options.page || 1; + options.per_page = options.per_page || 100; + + return this.get(`projects/${Utils.parse(projectId)}/labels`, options); + } + create(projectId, options = {}) { return this.post(`projects/${Utils.parse(projectId)}/labels`, options); } + + edit(projectId, labelName, options = {}) { + projectId = Utils.parse(projectId); + options.name = labelName + + return this.put(`projects/${Utils.parse(projectId)}/labels`, options); + } + + remove(projectId, labelName) { + projectId = Utils.parse(projectId); + + return this.delete(`projects/${Utils.parse(projectId)}/labels`, { name: labelName }); + } + + subscribe(projectId, labelId, options = {}) { + projectId = Utils.parse(projectId); + labelId = Utils.parse(labelId); + + return this.post(`projects/${projectId}/issues/${labelId}/subscribe`, options); + } + + unsubscribe(projectId, labelId) { + projectId = Utils.parse(projectId); + labelId = Utils.parse(labelId); + + return this.delete(`projects/${projectId}/issues/${labelId}/unsubscribe`); + } } module.exports = Labels; diff --git a/src/Models/ProjectIssues.js b/src/Models/ProjectIssues.js index f85a6d897..572d067db 100644 --- a/src/Models/ProjectIssues.js +++ b/src/Models/ProjectIssues.js @@ -8,12 +8,53 @@ class ProjectIssues extends BaseModel { this.notes = IssueNotes; } - list(projectId, options = {}) { - options.page = options.page || 1; + all(projectId, options = {}) { + options.page = options.page || 1; options.per_page = options.per_page || 100; return this.get(`projects/${Utils.parseProjectId(projectId)}/issues`, options); } + + create(projectId, options = {}) { + projectId = Utils.parse(projectId); + + return this.post(`projects/${projectId}/issues`, options); + } + + edit(projectId, issueId, options = {}) { + projectId = Utils.parse(projectId); + issueId = Utils.parse(issueId); + + return this.put(`projects/${projectId}/issues/${issueId}`, options); + } + + remove(projectId, issueId) { + projectId = Utils.parse(projectId); + issueId = Utils.parse(issueId); + + return this.delete(`projects/${projectId}/issues/${issueId}`); + } + + show(projectId, issueId) { + projectId = Utils.parse(projectId); + issueId = Utils.parse(issueId); + + return this.get(`projects/${projectId}/issues/${issueId}`); + } + + subscribe(projectId, issueId, options = {}) { + projectId = Utils.parse(projectId); + issueId = Utils.parse(issueId); + + return this.post(`projects/${projectId}/issues/${issueId}/subscribe`, options); + } + + unsubscribe(projectId, issueId) { + projectId = Utils.parse(projectId); + issueId = Utils.parse(issueId); + + return this.delete(`projects/${projectId}/issues/${issueId}/unsubscribe`); + } } module.exports = ProjectIssues;