export type GetApiCallsIdStatsSinceArgs = {id: string, kind: string, time: string, type: string, location_id?: string | undefined, limit: number}; export type GetApiCallsIdStatsSinceOptions = {baseUrl?: string | undefined, ApiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List Stats Since a Specified Date for an API Call * * GET /calls/{id}/stats/since */ export const getApiCallsIdStatsSince = async (args: GetApiCallsIdStatsSinceArgs, options?: GetApiCallsIdStatsSinceOptions) => { 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.type != null) query.append("type", String(args.type)) if (args.location_id != null) query.append("location_id", String(args.location_id)) if (args.limit != null) query.append("limit", String(args.limit)) if (ApiKeyAuth !== undefined) headers.set("Authorization", ApiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/calls/${encodeURIComponent(String(args.id))}/stats/since${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 };