2022-09-09 22:46:53 +00:00
|
|
|
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 {
|
2022-09-09 22:46:53 +00:00
|
|
|
getAll() {
|
2023-03-21 05:48:22 +00:00
|
|
|
return this.http.get<LabelOut[]>({ url: route("/labels") });
|
2022-09-02 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
create(body: LabelCreate) {
|
2022-09-12 22:47:27 +00:00
|
|
|
return this.http.post<LabelCreate, LabelOut>({ url: route("/labels"), body });
|
2022-09-02 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
get(id: string) {
|
2022-09-12 22:47:27 +00:00
|
|
|
return this.http.get<LabelOut>({ url: route(`/labels/${id}`) });
|
2022-09-02 01:52:40 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 22:46:53 +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
|
|
|
}
|
|
|
|
|
2022-09-12 22:47:27 +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
|
|
|
}
|
|
|
|
}
|