export type GetApiAppYelpLeadsSummaryArgs = {businessId?: string | undefined, from?: string | undefined, to?: string | undefined}; export type GetApiAppYelpLeadsSummaryOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Lead totals (count, reply rate, avg response) over all stored leads in scope * * GET /app/yelp/leads/summary */ export const getApiAppYelpLeadsSummary = async (args: GetApiAppYelpLeadsSummaryArgs, options: GetApiAppYelpLeadsSummaryOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.businessId != null) query.append("businessId", String(args.businessId)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) const url = `${baseUrl.replace(/\/+$/, '')}/app/yelp/leads/summary${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 };