Skip to content

Commit

Permalink
- Added addTimeEstimate, addTimeSpent, timeStats, resetTimeSpent and …
Browse files Browse the repository at this point in the history
…resetTimeEstimate to the Issues API. Requested in PR [#68](#68)

**Breaking Change**

- Renamed timeEstimate to addTimeEstimate, and timeSpend to addTimeSpent, in the MergeRequests API
  • Loading branch information
jdalrymple committed Apr 16, 2018
1 parent 027d2c4 commit aeb4cb4
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 26 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,14 @@ This started off as a fork from [node-gitlab](https://github.com/node-gitlab/nod

## Changelog

[3.1.0](https://github.com/jdalrymple/node-gitlab-api/tags/3.1.0) (2018-4-16)
------------------
- Added addTimeEstimate, addTimeSpent, timeStats, resetTimeSpent and resetTimeEstimate to the Issues API. Requested in PR [#68](https://github.com/jdalrymple/node-gitlab-api/pull/68)

**Breaking Change**

- Renamed timeEstimate to addTimeEstimate, and timeSpend to addTimeSpent, in the MergeRequests API

[3.0.4](https://github.com/jdalrymple/node-gitlab-api/tags/3.0.4) (2018-4-13)
------------------
- Fixed endpoint for MergeRequestNotes thanks to [Ev Haus](https://github.com/EvHaus) in PR [#63](https://github.com/jdalrymple/node-gitlab-api/pull/63)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gitlab",
"version": "3.0.4",
"version": "3.1.0",
"description": "Full NodeJS implementation of the GitLab API. Supports Promises, Async/Await.",
"main": "dist/latest/index.js",
"engines": {
Expand Down
34 changes: 34 additions & 0 deletions src/services/Issues.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
import { BaseService, RequestHelper } from '../infrastructure';

class Issues extends BaseService {
addSpentTime(projectId, issueId, duration) {
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${iId}/add_spent_time`, {
duration,
});
}

addTimeEstimate(projectId, issueId, duration) {
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${iId}/time_estimate`, {
duration,
});
}

all({ projectId, ...options }) {
const url = projectId ? `projects/${encodeURIComponent(projectId)}/issues` : 'issues';

Expand Down Expand Up @@ -36,6 +52,18 @@ class Issues extends BaseService {
return RequestHelper.delete(this, `projects/${pId}/issues/${iId}`);
}

resetSpentTime(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${mId}/reset_spent_time`);
}

resetTimeEstimate(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${mId}/reset_time_estimate`);
}

show(projectId, issueId) {
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);

Expand All @@ -48,6 +76,12 @@ class Issues extends BaseService {
return RequestHelper.post(this, `projects/${pId}/issues/${iId}/subscribe`, options);
}

timeStats(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.get(this, `projects/${pId}/issues/${mId}/time_stats`);
}

unsubscribe(projectId, issueId) {
const [pId, iId] = [projectId, issueId].map(encodeURIComponent);

Expand Down
42 changes: 18 additions & 24 deletions src/services/MergeRequests.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ class MergeRequests extends BaseService {
return RequestHelper.put(this, `projects/${pId}/merge_requests/${mId}/merge`, options);
}

addSpentTime(projectId, mergerequestId, duration) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${mId}/add_spent_time`, {
duration,
});
}

addTimeEstimate(projectId, mergerequestId, duration) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/issues/${mId}/time_estimate`, {
duration,
});
}

approve(projectId, mergerequestId, { sha }) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

Expand Down Expand Up @@ -88,18 +104,6 @@ class MergeRequests extends BaseService {
return RequestHelper.delete(this, `projects/${pId}/merge_requests/${mId}`);
}

show(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}`);
}

subscribe(projectId, mergerequestId, options) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/subscribe`, options);
}

resetSpentTime(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

Expand All @@ -112,20 +116,10 @@ class MergeRequests extends BaseService {
return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/reset_time_estimate`);
}

spentTime(projectId, mergerequestId, duration) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/add_spent_time`, {
duration,
});
}

timeEstimate(projectId, mergerequestId, duration) {
show(projectId, mergerequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/time_estimate`, {
duration,
});
return RequestHelper.get(this, `projects/${pId}/merge_requests/${mId}`);
}

timeStats(projectId, mergerequestId) {
Expand Down

0 comments on commit aeb4cb4

Please sign in to comment.