export type GetApiCaApiGetCashFlowV2Args = {cadence?: ('daily' | 'monthly' | 'quarterly' | 'weekly' | 'yearly') | undefined, end_date?: string | undefined, entity?: number | undefined, entity_rollup?: boolean | undefined, start_date?: string | undefined}; export type GetApiCaApiGetCashFlowV2Options = {baseUrl?: string | undefined, knoxApiToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get Cash Flow Statement * * GET /ca/api/get_cash_flow_v2 */ export const getApiCaApiGetCashFlowV2 = async (args: GetApiCaApiGetCashFlowV2Args, options?: GetApiCaApiGetCashFlowV2Options) => { const {baseUrl = "https://api.meetcampfire.com", fetch: fetchFn = fetch, knoxApiToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.cadence != null) query.append("cadence", String(args.cadence)) if (args.end_date != null) query.append("end_date", String(args.end_date)) if (args.entity != null) query.append("entity", String(args.entity)) if (args.entity_rollup != null) query.append("entity_rollup", String(args.entity_rollup)) if (args.start_date != null) query.append("start_date", String(args.start_date)) if (knoxApiToken !== undefined) headers.set("Authorization", knoxApiToken) const url = `${baseUrl.replace(/\/+$/, '')}/ca/api/get_cash_flow_v2${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 };