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

Commit c7aaed1

Browse files
committed
change create functions: return boolean
1 parent cfd5764 commit c7aaed1

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

core/TDSClient.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,13 @@ export default class TDSClient {
3535
return await TypeManager.getToday();
3636
}
3737

38-
/** 🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈Implement thiss"""🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈🎈
39-
* Method for find a todoist resource by type (task, project, etc.) using its ID.
40-
* The resource type is given by params.
41-
* Returns the name/content of the resource specified
42-
*/
43-
async findByID({ type = "task", id } = {}) {
44-
const TypeManager = new IManager(type, this.headers);
45-
return await TypeManager.findById(id);
46-
}
47-
4838
/**
4939
* Method for creating todoist resources (task, project, etc.). The resource type ond object are given by params.
5040
* If no params, creates a NO_CONTENT task
41+
* Returns true if all ok, then false.
5142
*/
5243
create({ type = "task" } = {}, ObjectFromType) {
5344
const TypeManager = new IManager(type, this.headers);
54-
TypeManager.create(ObjectFromType);
45+
return TypeManager.create(ObjectFromType);
5546
}
5647
}

core/managers/ProjectsManager.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@ export default class ProjectsManager {
77
}
88

99
create(project = new Project()) {
10-
axios
10+
return axios
1111
.post(`https://api.todoist.com/rest/v1/projects`, project, this.headers)
1212
.then(() => true)
13-
.catch((err) => console.error(err));
13+
.catch((err) => {
14+
console.log(err);
15+
return false;
16+
});
1417
}
1518

1619
/**

core/managers/TasksManager.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ export default class TasksManager {
77
}
88

99
create(task = new Task()) {
10-
axios
10+
return axios
1111
.post(`https://api.todoist.com/rest/v1/tasks`, task, this.headers)
12-
.then(() => true);
12+
.then(() => true)
13+
.catch((err) => {
14+
console.log(err);
15+
return false;
16+
});
1317
}
1418

1519
/**

0 commit comments

Comments
 (0)