export type CreateApiTopicsTopicIdHistoryArgs = {topicId: number, body: {from: string, to: string}}; export type CreateApiTopicsTopicIdHistoryOptions = {baseUrl?: string | undefined, ApiKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Start history collection * * POST /topics/{topicId}/history * * Also accepts auth: ApiKeyQuery */ export const createApiTopicsTopicIdHistory = async (args: CreateApiTopicsTopicIdHistoryArgs, options?: CreateApiTopicsTopicIdHistoryOptions) => { const {baseUrl = "https://api.youscan.io/api/external", fetch: fetchFn = fetch, ApiKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (ApiKeyHeader !== undefined) headers.set("X-API-KEY", ApiKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/topics/${encodeURIComponent(String(args.topicId))}/history${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };