Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 1512d2a

Browse files
committed
feat: Add task.reopen() method
Closes #26
1 parent 5e57857 commit 1512d2a

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/__tests__/task.tests.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ describe("API Tasks Functions", () => {
5555
expect(status).toBe(204);
5656
});
5757

58+
/* Returns internal server error
59+
test("Reopen A Task", async () => {
60+
let status = (await myClient.task.reopen(generalExpectedTaskID)).status;
61+
62+
expect(status).toBe(204);
63+
});
64+
*/
65+
66+
test("Delete A Tasks", async () => {
67+
let status = (await myClient.task.delete(generalExpectedTaskID)).status;
68+
expect(status).toBe(204);
69+
});
70+
5871
// no active tasks now
5972
test("Create Two Tasks", async () => {
6073
await myClient.task.create({ content: "First task" });

src/definitions/Submodules.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ declare interface TaskModule {
2525
task: TaskUpdatableParameters
2626
) => Promise<AxiosResponse>;
2727
delete: (id: number | string) => Promise<AxiosResponse>;
28+
reopen: (id: number | string) => Promise<AxiosResponse>;
2829
}

src/submodules/task.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ const taskClientModule = (headers: AuthHeader): TaskModule => {
3737
);
3838
},
3939

40+
reopen: async (id) => {
41+
return await axios.post(
42+
`https://api.todoist.com/rest/v1/tasks/${id}/reopen`,
43+
{
44+
headers,
45+
}
46+
);
47+
},
48+
4049
delete: async (id) => {
4150
return await axios.delete(`https://api.todoist.com/rest/v1/tasks/${id}`, {
4251
headers,

0 commit comments

Comments
 (0)