export type GetApiCompanyDomainCompaniesInvoicesArgs = {companyDomain: string, page: number, pageSize: number, query?: string | undefined, orderBy?: string | undefined, orderByDescending?: string | undefined, isPending?: boolean | undefined, isPaid?: boolean | undefined, isUnpaid?: string | undefined, isPaidOffline?: boolean | undefined, isWrittenOff?: boolean | undefined}; export type GetApiCompanyDomainCompaniesInvoicesOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; /** * Company invoices * * GET /{companyDomain}/companies/invoices */ export const getApiCompanyDomainCompaniesInvoices = async (args: GetApiCompanyDomainCompaniesInvoicesArgs, options?: GetApiCompanyDomainCompaniesInvoicesOptions) => { const {baseUrl = "https://public.billsby.com/api/v1/rest/core", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.page != null) query.append("page", String(args.page)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.query != null) query.append("query", String(args.query)) if (args.orderBy != null) query.append("orderBy", String(args.orderBy)) if (args.orderByDescending != null) query.append("orderByDescending", String(args.orderByDescending)) if (args.isPending != null) query.append("isPending", String(args.isPending)) if (args.isPaid != null) query.append("isPaid", String(args.isPaid)) if (args.isUnpaid != null) query.append("isUnpaid", String(args.isUnpaid)) if (args.isPaidOffline != null) query.append("isPaidOffline", String(args.isPaidOffline)) if (args.isWrittenOff != null) query.append("isWrittenOff", String(args.isWrittenOff)) if (sec0 !== undefined) headers.set("ApiKey", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.companyDomain))}/companies/invoices${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 (await res.json()) as unknown };