From d4741c55f30cd2331b5991bc11edf8f28cd17c6b Mon Sep 17 00:00:00 2001 From: Justin Dalrymple Date: Mon, 15 Oct 2018 12:45:26 -0400 Subject: [PATCH] fix: Fixing Todos support. If todoId was not passed, an undefined value would be introduced into the url --- src/services/Todos.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/services/Todos.ts b/src/services/Todos.ts index 1e9e0320b..1fe1b34cf 100644 --- a/src/services/Todos.ts +++ b/src/services/Todos.ts @@ -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}`); } }