Skip to content

Commit cea5a2b

Browse files
committed
fix: Fixing Todos support. If todoId was not passed, an undefined value would be introduced into the url
1 parent a7b29c1 commit cea5a2b

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/services/Todos.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import { BaseService, RequestHelper } from '../infrastructure';
2-
import { RequestOptions } from '../infrastructure/RequestHelper';
3-
import { MergeRequestId } from './MergeRequests';
42

5-
type TodoId = string | number;
6-
interface TodosOptions {
7-
todoId: TodoId;
8-
}
93
class Todos extends BaseService {
10-
all(options: RequestOptions) {
4+
all(options?: PaginatedRequestOptions) {
115
return RequestHelper.get(this, 'todos', options);
126
}
137

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+
);
1814
}
1915

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}`;
2220

23-
return RequestHelper.delete(this, `todos/${tId}/mark_as_done`);
21+
return RequestHelper.del(this, `todos/${url}`, options);
2422
}
2523
}
2624

0 commit comments

Comments
 (0)