export type UserReactionCreateModel = {reaction: string}; export type CreateApiV1ReactionsToggleArgs = {DealLogId?: number | undefined, TicketLogId?: number | undefined, body: UserReactionCreateModel}; export type CreateApiV1ReactionsToggleOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a Reaction * * POST /v1/reactions/toggle * * Also accepts auth: API Key */ export const createApiV1ReactionsToggle = async (args: CreateApiV1ReactionsToggleArgs, options: CreateApiV1ReactionsToggleOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.DealLogId != null) query.append("DealLogId", String(args.DealLogId)) if (args.TicketLogId != null) query.append("TicketLogId", String(args.TicketLogId)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/reactions/toggle${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 };