|
1 | 1 | import { BaseService, RequestHelper } from '../infrastructure';
|
2 |
| -import { RequestOptions } from '../infrastructure/RequestHelper'; |
3 |
| -import { MergeRequestId } from './MergeRequests'; |
4 | 2 |
|
5 |
| -type TodoId = string | number; |
6 |
| -interface TodosOptions { |
7 |
| - todoId: TodoId; |
8 |
| -} |
9 | 3 | class Todos extends BaseService {
|
10 |
| - all(options: RequestOptions) { |
| 4 | + all(options?: PaginatedRequestOptions) { |
11 | 5 | return RequestHelper.get(this, 'todos', options);
|
12 | 6 | }
|
13 | 7 |
|
14 |
| - create(projectId: ProjectId, mergerequestId: MergeRequestId) { |
15 |
| - const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent); |
16 |
| - |
17 |
| - return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/todo`); |
| 8 | + create(projectId: ProjectId, mergerequestId: MergeRequestId, options?: Sudo) { |
| 9 | + return RequestHelper.post( |
| 10 | + this, |
| 11 | + `projects/${projectId}/merge_requests/${mergerequestId}/todo`, |
| 12 | + options, |
| 13 | + ); |
18 | 14 | }
|
19 | 15 |
|
20 |
| - done({ todoId }: TodosOptions) { |
21 |
| - const tId = encodeURIComponent(todoId); |
| 16 | + done({ todoId, ...options }: { todoId?: TodoId } & Sudo) { |
| 17 | + let url = 'mark_as_done'; |
| 18 | + |
| 19 | + if (todoId) url = `${todoId}/${url}`; |
22 | 20 |
|
23 |
| - return RequestHelper.delete(this, `todos/${tId}/mark_as_done`); |
| 21 | + return RequestHelper.del(this, `todos/${url}`, options); |
24 | 22 | }
|
25 | 23 | }
|
26 | 24 |
|
|
0 commit comments