Skip to content

Commit ef8eec4

Browse files
committed
plugin api: create task API return task object
1 parent 32ac915 commit ef8eec4

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

plugin/src/api/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ export class TodoistApiClient {
3131
}
3232
}
3333

34-
public async createTask(content: string, options?: CreateTaskParams): Promise<void> {
34+
public async createTask(content: string, options?: CreateTaskParams): Promise<Task> {
3535
const body = snakify({
3636
content: content,
3737
...(options ?? {}),
3838
});
39-
await this.do("/tasks", "POST", body);
39+
const response = await this.do("/tasks", "POST", body);
40+
return camelize(JSON.parse(response.body)) as Task;
4041
}
4142

4243
public async closeTask(id: TaskId): Promise<void> {

plugin/src/data/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class LabelsRepository extends Repository<LabelId, Label> {
3939
export class TodoistAdapter {
4040
public actions = {
4141
closeTask: async (id: TaskId) => await this.closeTask(id),
42-
createTask: async (content: string, params: CreateTaskParams) =>
42+
createTask: async (content: string, params: CreateTaskParams): Promise<ApiTask> =>
4343
await this.api.withInner((api) => api.createTask(content, params)),
4444
};
4545

0 commit comments

Comments
 (0)