2022-09-09 22:46:53 +00:00
|
|
|
import { BaseAPI, route } from "../base";
|
2022-09-27 23:52:13 +00:00
|
|
|
import { LocationOutCount, LocationCreate, LocationOut } from "../types/data-contracts";
|
2022-09-12 22:47:27 +00:00
|
|
|
import { Results } from "./types";
|
2022-08-31 05:22:10 +00:00
|
|
|
|
2022-09-01 22:32:03 +00:00
|
|
|
export type LocationUpdate = LocationCreate;
|
|
|
|
|
2022-08-31 05:22:10 +00:00
|
|
|
export class LocationsApi extends BaseAPI {
|
2022-09-09 22:46:53 +00:00
|
|
|
getAll() {
|
2022-09-27 23:52:13 +00:00
|
|
|
return this.http.get<Results<LocationOutCount>>({ url: route("/locations") });
|
2022-08-31 05:22:10 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
create(body: LocationCreate) {
|
2022-09-12 22:47:27 +00:00
|
|
|
return this.http.post<LocationCreate, LocationOut>({ url: route("/locations"), body });
|
2022-08-31 05:22:10 +00:00
|
|
|
}
|
2022-09-01 22:32:03 +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<LocationOut>({ url: route(`/locations/${id}`) });
|
2022-09-01 22:32:03 +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(`/locations/${id}`) });
|
2022-09-01 22:32:03 +00:00
|
|
|
}
|
|
|
|
|
2022-09-09 22:46:53 +00:00
|
|
|
update(id: string, body: LocationUpdate) {
|
2022-09-12 22:47:27 +00:00
|
|
|
return this.http.put<LocationUpdate, LocationOut>({ url: route(`/locations/${id}`), body });
|
2022-09-01 22:32:03 +00:00
|
|
|
}
|
2022-08-31 05:22:10 +00:00
|
|
|
}
|