21 lines
1.0 KiB
TypeScript
21 lines
1.0 KiB
TypeScript
import { ndmClient, userClient, type Station } from '@/apis';
|
|
import { unwrapResponse } from '@/utils';
|
|
|
|
export async function retentionDaysApi(method: 'get', options?: { stationCode?: Station['code']; signal?: AbortSignal }): Promise<number>;
|
|
export async function retentionDaysApi(method: 'post', options: { days: number; stationCode?: Station['code']; signal?: AbortSignal }): Promise<number>;
|
|
export async function retentionDaysApi(method: 'get' | 'post', options?: { days?: number; stationCode?: Station['code']; signal?: AbortSignal }) {
|
|
const { days, stationCode, signal } = options ?? {};
|
|
const client = stationCode ? ndmClient : userClient;
|
|
const prefix = stationCode ? `/${stationCode}` : '';
|
|
const endpoint = `${prefix}/api/ndm/ndmSnap/retentionDays`;
|
|
if (method === 'get') {
|
|
const resp = await client.get<number>(endpoint, { signal });
|
|
const data = unwrapResponse(resp);
|
|
return data;
|
|
} else {
|
|
const resp = await client.post<number>(endpoint, days, { signal });
|
|
const data = unwrapResponse(resp);
|
|
return data;
|
|
}
|
|
}
|