homebox/frontend/lib/api/classes/labels.ts

25 lines
681 B
TypeScript
Raw Permalink Normal View History

import { BaseAPI, route } from "../base";
2024-03-01 17:21:45 +00:00
import type { LabelCreate, LabelOut } from "../types/data-contracts";
2022-09-02 01:52:40 +00:00
export class LabelsApi extends BaseAPI {
getAll() {
return this.http.get<LabelOut[]>({ url: route("/labels") });
2022-09-02 01:52:40 +00:00
}
create(body: LabelCreate) {
return this.http.post<LabelCreate, LabelOut>({ url: route("/labels"), body });
2022-09-02 01:52:40 +00:00
}
get(id: string) {
return this.http.get<LabelOut>({ url: route(`/labels/${id}`) });
2022-09-02 01:52:40 +00:00
}
delete(id: string) {
2022-09-09 06:05:23 +00:00
return this.http.delete<void>({ url: route(`/labels/${id}`) });
2022-09-02 01:52:40 +00:00
}
update(id: string, body: LabelCreate) {
return this.http.put<LabelCreate, LabelOut>({ url: route(`/labels/${id}`), body });
2022-09-02 01:52:40 +00:00
}
}