53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import { api } from "@/config";
|
|
import {
|
|
API_GET_ALARMS,
|
|
API_GET_GPS,
|
|
API_GET_SHIP_GROUPS,
|
|
API_GET_SHIP_TYPES,
|
|
API_PATH_ENTITIES,
|
|
API_PATH_SEARCH_THINGS,
|
|
API_PATH_SHIP_TRACK_POINTS,
|
|
API_SOS,
|
|
} from "@/constants";
|
|
import { transformEntityResponse } from "@/utils/tranform";
|
|
|
|
export async function queryGpsData() {
|
|
return api.get<Model.GPSResponse>(API_GET_GPS);
|
|
}
|
|
|
|
export async function queryAlarm() {
|
|
return api.get<Model.AlarmResponse>(API_GET_ALARMS);
|
|
}
|
|
|
|
export async function queryTrackPoints() {
|
|
return api.get<Model.ShipTrackPoint[]>(API_PATH_SHIP_TRACK_POINTS);
|
|
}
|
|
|
|
export async function queryEntities(): Promise<Model.TransformedEntity[]> {
|
|
const response = await api.get<Model.EntityResponse[]>(API_PATH_ENTITIES);
|
|
return response.data.map(transformEntityResponse);
|
|
}
|
|
|
|
export async function queryGetSos() {
|
|
return await api.get<Model.SosResponse>(API_SOS);
|
|
}
|
|
export async function queryDeleteSos() {
|
|
return await api.delete<Model.SosResponse>(API_SOS);
|
|
}
|
|
|
|
export async function querySendSosMessage(message: string) {
|
|
return await api.put<Model.SosRequest>(API_SOS, { message });
|
|
}
|
|
|
|
export async function querySearchThings(body: Model.SearchThingBody) {
|
|
return await api.post<Model.ThingsResponse>(API_PATH_SEARCH_THINGS, body);
|
|
}
|
|
|
|
export async function queryShipTypes() {
|
|
return await api.get<Model.ShipType[]>(API_GET_SHIP_TYPES);
|
|
}
|
|
|
|
export async function queryShipGroups() {
|
|
return await api.get<Model.ShipGroup[]>(API_GET_SHIP_GROUPS);
|
|
}
|