export type ResponseType = 'attachment' | 'inline'; export type GetApiV7AgsLogArgs = {bgs_loca_id: string, response_type?: ResponseType | undefined}; export type GetApiV7AgsLogOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Generate Graphical Log * * GET /v7/ags_log/ */ export const getApiV7AgsLog = async (args: GetApiV7AgsLogArgs, options: GetApiV7AgsLogOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.bgs_loca_id != null) query.append("bgs_loca_id", String(args.bgs_loca_id)) if (args.response_type != null) query.append("response_type", String(args.response_type)) const url = `${baseUrl.replace(/\/+$/, '')}/v7/ags_log/${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() };