export type GetApiApiTaxesArgs = {'filter[tax_country_region]'?: string | undefined, 'filter[tax_code]'?: string | undefined, 'filter[tax_percentage]'?: string | undefined}; export type GetApiApiTaxesOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Obter Todas as Taxas * * GET /api/taxes */ export const getApiApiTaxes = async (args: GetApiApiTaxesArgs, options: GetApiApiTaxesOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['filter[tax_country_region]'] != null) query.append("filter[tax_country_region]", String(args['filter[tax_country_region]'])) if (args['filter[tax_code]'] != null) query.append("filter[tax_code]", String(args['filter[tax_code]'])) if (args['filter[tax_percentage]'] != null) query.append("filter[tax_percentage]", String(args['filter[tax_percentage]'])) if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/taxes${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 };