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

Commit 8c1dcaa

Browse files
authored
Merge pull request #28 from dubisdev/dubisdev/issue27
feat: task.reopen() task.delete methods()
2 parents 05226f4 + 1512d2a commit 8c1dcaa

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/__tests__/task.tests.ts

Lines changed: 15 additions & 2 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" });
@@ -89,11 +102,11 @@ describe("API Tasks Functions", () => {
89102
expect(secondTaskExists).toBe(true);
90103
});
91104

92-
test("Complete All Previous Tasks", async () => {
105+
test("Delete All Previous Tasks", async () => {
93106
let allTasksJSON = await myClient.task.getAllJSON();
94107

95108
for (let i = 0; i < allTasksJSON.length; ++i) {
96-
let status = (await myClient.task.closeTask(allTasksJSON[i].id)).status;
109+
let status = (await myClient.task.delete(allTasksJSON[i].id)).status;
97110
expect(status).toBe(204);
98111
}
99112
});

src/definitions/Submodules.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ declare interface TaskModule {
2424
id: number | string,
2525
task: TaskUpdatableParameters
2626
) => Promise<AxiosResponse>;
27+
delete: (id: number | string) => Promise<AxiosResponse>;
28+
reopen: (id: number | string) => Promise<AxiosResponse>;
2729
}

src/submodules/task.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ 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+
49+
delete: async (id) => {
50+
return await axios.delete(`https://api.todoist.com/rest/v1/tasks/${id}`, {
51+
headers,
52+
});
53+
},
54+
4055
getAll: async () => {
4156
let json = await getAllJSON(headers);
4257
let arrayTasks: string[] = [];

0 commit comments

Comments
 (0)