export type GetApiCallsIdStatsPassfailRangeArgs = {id: string, kind: string, time: string, location_id?: string | undefined, start: string, end: string}; export type GetApiCallsIdStatsPassfailRangeOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the Pass/Fail Stats for an API Call for a Time Range * * GET /calls/{id}/stats/passfail_range */ export const getApiCallsIdStatsPassfailRange = async (args: GetApiCallsIdStatsPassfailRangeArgs, options?: GetApiCallsIdStatsPassfailRangeOptions) => { const {baseUrl = "https://client.apimetrics.io/api/2", fetch: fetchFn = fetch, ApiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.kind != null) query.append("kind", String(args.kind)) if (args.time != null) query.append("time", String(args.time)) if (args.location_id != null) query.append("location_id", String(args.location_id)) if (args.start != null) query.append("start", String(args.start)) if (args.end != null) query.append("end", String(args.end)) if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/calls/${encodeURIComponent(String(args.id))}/stats/passfail_range${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 };