export type GetApiApiCommercialPurchasesDocumentsArgs = {'filter[document_no]'?: string | undefined, 'filter[status]'?: string | undefined, 'filter[supplier_tax_registration_number]'?: string | undefined}; export type GetApiApiCommercialPurchasesDocumentsOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Obter Todos os Documentos de Compra * * GET /api/commercial_purchases_documents */ export const getApiApiCommercialPurchasesDocuments = async (args: GetApiApiCommercialPurchasesDocumentsArgs, options: GetApiApiCommercialPurchasesDocumentsOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['filter[document_no]'] != null) query.append("filter[document_no]", String(args['filter[document_no]'])) if (args['filter[status]'] != null) query.append("filter[status]", String(args['filter[status]'])) if (args['filter[supplier_tax_registration_number]'] != null) query.append("filter[supplier_tax_registration_number]", String(args['filter[supplier_tax_registration_number]'])) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/commercial_purchases_documents${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 undefined };