mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-23 00:55:43 +00:00
b77c9be36f
* bump prettier/eslint-plugin * bump nuxt pwa * use typed imports * set vue version to fix layout errors * disable import
36 lines
1 KiB
TypeScript
36 lines
1 KiB
TypeScript
import { BaseAPI, route } from "../base";
|
|
import type { LocationOutCount, LocationCreate, LocationOut, LocationUpdate, TreeItem } from "../types/data-contracts";
|
|
|
|
export type LocationsQuery = {
|
|
filterChildren: boolean;
|
|
};
|
|
|
|
export type TreeQuery = {
|
|
withItems: boolean;
|
|
};
|
|
|
|
export class LocationsApi extends BaseAPI {
|
|
getAll(q: LocationsQuery = { filterChildren: false }) {
|
|
return this.http.get<LocationOutCount[]>({ url: route("/locations", q) });
|
|
}
|
|
|
|
getTree(tq = { withItems: false }) {
|
|
return this.http.get<TreeItem[]>({ url: route("/locations/tree", tq) });
|
|
}
|
|
|
|
create(body: LocationCreate) {
|
|
return this.http.post<LocationCreate, LocationOut>({ url: route("/locations"), body });
|
|
}
|
|
|
|
get(id: string) {
|
|
return this.http.get<LocationOut>({ url: route(`/locations/${id}`) });
|
|
}
|
|
|
|
delete(id: string) {
|
|
return this.http.delete<void>({ url: route(`/locations/${id}`) });
|
|
}
|
|
|
|
update(id: string, body: LocationUpdate) {
|
|
return this.http.put<LocationUpdate, LocationOut>({ url: route(`/locations/${id}`), body });
|
|
}
|
|
}
|