export type Search = {query?: string | undefined, from?: string | undefined, to?: string | undefined}; export type CreateApiV3MessagesLogIdFixArgs = {logId: string, body: Search}; export type CreateApiV3MessagesLogIdFixOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Mark a list of messages as fixed by logid and query. * * POST /v3/messages/{logId}/_fix */ export const createApiV3MessagesLogIdFix = async (args: CreateApiV3MessagesLogIdFixArgs, options: CreateApiV3MessagesLogIdFixOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) query.set("api_key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v3/messages/${encodeURIComponent(String(args.logId))}/_fix${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 };