Skip to content

Commit

Permalink
Updating changeset, adding new labels functionality , and cleaning up…
Browse files Browse the repository at this point in the history
… the issues class
  • Loading branch information
jdalrymple committed Jun 23, 2017
1 parent ae48fbc commit 9d9ef26
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 45 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down
43 changes: 1 addition & 42 deletions src/Models/Issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
34 changes: 34 additions & 0 deletions src/Models/Labels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
45 changes: 43 additions & 2 deletions src/Models/ProjectIssues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 9d9ef26

Please sign in to comment.