export type CreateApiApiPublicV1ChatArgs = {'X-VO-Api-Id': string, 'X-VO-Api-Key': string, body: {username: string, externalUsername: string, text: string, incidentId?: number | undefined, monitoringTool: string, tags?: Array | undefined}}; export type CreateApiApiPublicV1ChatOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Send a chat message into VictorOps * * POST /api-public/v1/chat */ export const createApiApiPublicV1Chat = async (args: CreateApiApiPublicV1ChatArgs, options?: CreateApiApiPublicV1ChatOptions) => { const {baseUrl = "https://api.victorops.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-VO-Api-Id'] != null) headers.set("X-VO-Api-Id", String(args['X-VO-Api-Id'])) if (args['X-VO-Api-Key'] != null) headers.set("X-VO-Api-Key", String(args['X-VO-Api-Key'])) const url = `${baseUrl.replace(/\/+$/, '')}/api-public/v1/chat${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 };