export type GetApiPartnersExportArgs = {company_id?: number | undefined, contact_id?: number | undefined, isThirdParty?: ('yes' | 'no') | undefined, search?: string | undefined, 'sort[asc]'?: ('id' | 'company_id' | 'contact_id' | 'isThirdParty' | 'createdOn' | 'modifiedOn') | undefined, 'sort[desc]'?: ('id' | 'company_id' | 'contact_id' | 'isThirdParty' | 'createdOn' | 'modifiedOn') | undefined, filters?: Record | undefined}; export type GetApiPartnersExportOptions = {baseUrl?: string | undefined, passport?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export partners * * GET /partners/export */ export const getApiPartnersExport = async (args: GetApiPartnersExportArgs, options?: GetApiPartnersExportOptions) => { const {baseUrl = "http://localhost/app4legal/api/v2/money", fetch: fetchFn = fetch, passport} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.company_id != null) query.append("company_id", String(args.company_id)) if (args.contact_id != null) query.append("contact_id", String(args.contact_id)) if (args.isThirdParty != null) query.append("isThirdParty", String(args.isThirdParty)) if (args.search != null) query.append("search", String(args.search)) if (args['sort[asc]'] != null) query.append("sort[asc]", String(args['sort[asc]'])) if (args['sort[desc]'] != null) query.append("sort[desc]", String(args['sort[desc]'])) if (args.filters != null) query.append("filters", JSON.stringify(args.filters)) if (passport !== undefined) headers.set('authorization', `Bearer ${passport}`) const url = `${baseUrl.replace(/\/+$/, '')}/partners/export${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 };