Files
gemory/src/market/history/EsiMarketOrderHistory.ts
T
2024-05-22 09:59:13 +02:00

27 lines
769 B
TypeScript

import { esiAxiosInstance } from "@/service";
export type EsiMarketOrderHistory = {
average: number;
date: string;
highest: number;
lowest: number;
order_count: number;
volume: number;
}
// TODO use pinia store
const historyCache: { [key: number]: { [key: number]: EsiMarketOrderHistory[] } } = {};
export const getHistory = async (regionId: number, tyeId: number): Promise<EsiMarketOrderHistory[]> => {
if (historyCache[regionId]?.[tyeId]) {
return historyCache[regionId][tyeId];
}
const value = (await esiAxiosInstance.get(`/markets/${regionId}/history/`, { params: { type_id: tyeId } })).data;
historyCache[regionId] = historyCache[regionId] ?? {};
historyCache[regionId][tyeId] = value;
return value;
}