export type GetApiPayeesArgs = {'Company-Id': string, account_name?: string | undefined, account_number?: string | undefined, sort_code?: string | undefined, is_active?: boolean | undefined}; export type GetApiPayeesOptions = {baseUrl?: string | undefined, token?: string | undefined, fetch?: typeof fetch | undefined}; /** * List all payees * * GET /payees */ export const getApiPayees = async (args: GetApiPayeesArgs, options?: GetApiPayeesOptions) => { const {baseUrl = "https://test-api.acquired.com/v1", fetch: fetchFn = fetch, token} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Company-Id'] != null) headers.set("Company-Id", String(args['Company-Id'])) if (args.account_name != null) query.append("account_name", String(args.account_name)) if (args.account_number != null) query.append("account_number", String(args.account_number)) if (args.sort_code != null) query.append("sort_code", String(args.sort_code)) if (args.is_active != null) query.append("is_active", String(args.is_active)) if (token !== undefined) headers.set('authorization', `Bearer ${token}`) const url = `${baseUrl.replace(/\/+$/, '')}/payees${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 };