export type GetApiEcommerceReceiptBatchProtocolArgs = {protocol: string, document?: (string | null) | undefined}; export type GetApiEcommerceReceiptBatchProtocolOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Busca um lote de recibos. * * GET /ecommerce/receipt-batch/{protocol} */ export const getApiEcommerceReceiptBatchProtocol = async (args: GetApiEcommerceReceiptBatchProtocolArgs, options?: GetApiEcommerceReceiptBatchProtocolOptions) => { const {baseUrl = "https://api.b2b.usezapay.com.br/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") if (args.document != null) query.append("document", String(args.document)) const url = `${baseUrl.replace(/\/+$/, '')}/ecommerce/receipt-batch/${encodeURIComponent(String(args.protocol))}${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() };