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 Oct 15, 2018
1 parent b222cb6 commit d4741c5
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/services/Todos.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
import { BaseService, RequestHelper } from '../infrastructure';

interface TodosOptions {
todoId?: string;
}
class Todos extends BaseService {
all(options) {
return RequestHelper.get(this, 'todos', options);
}

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

return RequestHelper.post(this, `projects/${pId}/merge_requests/${mId}/todo`);
create(projectId: number, mergerequestId: number) {
return RequestHelper.post(this, `projects/${projectId}/merge_requests/${mergerequestId}/todo`);
}

done({ todoId }: TodosOptions = {}) {
const tId = encodeURIComponent(todoId);
done({ todoId }: { todoId?: number } = {}) {
let url = 'mark_as_done';

return RequestHelper.delete(this, `todos/${tId}/mark_as_done`);
if (todoId) url = `${todoId}/${url}`

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

Expand Down

0 comments on commit d4741c5

Please sign in to comment.