export type GetApiCallsIdStatsPassfailArgs = {id: string, kind: string, time: string, location_id?: string | undefined}; export type GetApiCallsIdStatsPassfailOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get the Pass/Fail Stats for an API Call for Specified Period * * GET /calls/{id}/stats/passfail */ export const getApiCallsIdStatsPassfail = async (args: GetApiCallsIdStatsPassfailArgs, options?: GetApiCallsIdStatsPassfailOptions) => { 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 (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/calls/${encodeURIComponent(String(args.id))}/stats/passfail${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 };