mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-17 06:08:42 +00:00
75c633dcb5
* dummy commit * cleanup workflows * setup and run eslint * add linter to CI * use eslint for formatting * reorder rules * drop editor config
36 lines
941 B
TypeScript
36 lines
941 B
TypeScript
import { BaseAPI, route } from "../base";
|
|
import { Item } from "./items";
|
|
import { Details, OutType, Results } from "./types";
|
|
|
|
export type LocationCreate = Details;
|
|
|
|
export type Location = LocationCreate &
|
|
OutType & {
|
|
groupId: string;
|
|
items: Item[];
|
|
itemCount: number;
|
|
};
|
|
|
|
export type LocationUpdate = LocationCreate;
|
|
|
|
export class LocationsApi extends BaseAPI {
|
|
getAll() {
|
|
return this.http.get<Results<Location>>({ url: route("/locations") });
|
|
}
|
|
|
|
create(body: LocationCreate) {
|
|
return this.http.post<LocationCreate, Location>({ url: route("/locations"), body });
|
|
}
|
|
|
|
get(id: string) {
|
|
return this.http.get<Location>({ 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, Location>({ url: route(`/locations/${id}`), body });
|
|
}
|
|
}
|