Skip to content

Commit

Permalink
fix: Fixing Todos support. If todoId was not passed, an undefined val…
Browse files Browse the repository at this point in the history
…ue would be introduced into the url
  • Loading branch information
jdalrymple committed May 25, 2019
1 parent a7b29c1 commit cea5a2b
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/services/Todos.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
import { BaseService, RequestHelper } from '../infrastructure';
import { RequestOptions } from '../infrastructure/RequestHelper';
import { MergeRequestId } from './MergeRequests';

type TodoId = string | number;
interface TodosOptions {
todoId: TodoId;
}
class Todos extends BaseService {
all(options: RequestOptions) {
all(options?: PaginatedRequestOptions) {
return RequestHelper.get(this, 'todos', options);
}

create(projectId: ProjectId, mergerequestId: MergeRequestId) {
const [pId, mId] = [projectId, mergerequestId].map(encodeURIComponent);

return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/todo`);
create(projectId: ProjectId, mergerequestId: MergeRequestId, options?: Sudo) {
return RequestHelper.post(
this,
`projects/${projectId}/merge_requests/${mergerequestId}/todo`,
options,
);
}

done({ todoId }: TodosOptions) {
const tId = encodeURIComponent(todoId);
done({ todoId, ...options }: { todoId?: TodoId } & Sudo) {
let url = 'mark_as_done';

if (todoId) url = `${todoId}/${url}`;

return RequestHelper.delete(this, `todos/${tId}/mark_as_done`);
return RequestHelper.del(this, `todos/${url}`, options);
}
}

Expand Down

0 comments on commit cea5a2b

Please sign in to comment.