export type GetApiAppsAtPtV1EntrySiloEntryIdSaftArgs = {silo_entry_id: string, year: number, period?: number | undefined}; export type GetApiAppsAtPtV1EntrySiloEntryIdSaftOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate and download a SAF-T PT report for the specified period. * * GET /apps/at-pt/v1/entry/{silo_entry_id}/saft */ export const getApiAppsAtPtV1EntrySiloEntryIdSaft = async (args: GetApiAppsAtPtV1EntrySiloEntryIdSaftArgs, options?: GetApiAppsAtPtV1EntrySiloEntryIdSaftOptions) => { const {baseUrl = "https://api.invopop.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/xml") if (args.year != null) query.append("year", String(args.year)) if (args.period != null) query.append("period", String(args.period)) const url = `${baseUrl.replace(/\/+$/, '')}/apps/at-pt/v1/entry/${encodeURIComponent(String(args.silo_entry_id))}/saft${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };