Skip to content

Commit

Permalink
resources: tune projects to return data directly.
Browse files Browse the repository at this point in the history
  • Loading branch information
narekhovhannisyan committed Nov 10, 2023
1 parent b5b0d94 commit 78e5191
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/lib/api/resources/Projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,24 @@ export default class ProjectsApi {
*/
public async create(projectName: string) {
const data = { project: { name: projectName } };
const apiResponse = await this.client.post<Project>(this.projectsURL, data);

return apiResponse.data;
return this.client.post<Project, Project>(this.projectsURL, data);
}

/**
* Lists projects and their inboxes to which the API token has access.
*/
public async getList() {
const apiResponse = await this.client.get<Project[]>(this.projectsURL);

return apiResponse.data;
return this.client.get<Project[], Project[]>(this.projectsURL);
}

/**
* Gets the project and it's inboxes.
*/
public async getById(projectId: number) {
const url = `${this.projectsURL}/${projectId}`;
const apiResponse = await this.client.get<Project>(url);

return apiResponse.data;
return this.client.get<Project, Project>(url);
}

/**
Expand All @@ -55,18 +51,16 @@ export default class ProjectsApi {
public async update(projectId: number, updatedName: string) {
const url = `${this.projectsURL}/${projectId}`;
const data = { project: { name: updatedName } };
const apiResponse = await this.client.patch<Project>(url, data);

return apiResponse.data;
return this.client.patch<Project, Project>(url, data);
}

/**
* Deletes a project by its ID.
*/
public async delete(projectId: number) {
const url = `${this.projectsURL}/${projectId}`;
const apiResponse = await this.client.delete<Project>(url);

return apiResponse.data;
return this.client.delete<Project, Project>(url);
}
}

0 comments on commit 78e5191

Please sign in to comment.