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

26 lines
718 B
TypeScript
Raw Normal View History

import { BaseAPI, route } from "../base";
import { LabelCreate, LabelOut } from "../types/data-contracts";
import { Results } from "./types";
2022-09-02 01:52:40 +00:00
export class LabelsApi extends BaseAPI {
getAll() {
return this.http.get<Results<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
}
}