import { ndmClient, userClient, type Station } from '@/apis'; import { unwrapResponse } from '@/utils'; export async function retentionDaysApi(method: 'get', options?: { stationCode?: Station['code']; signal?: AbortSignal }): Promise; export async function retentionDaysApi(method: 'post', options: { days: number; stationCode?: Station['code']; signal?: AbortSignal }): Promise; 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(endpoint, { signal }); const data = unwrapResponse(resp); return data; } else { const resp = await client.post(endpoint, days, { signal }); const data = unwrapResponse(resp); return data; } }