export type CreateApiV2TicketingTicketTicketIdCommentArgs = {ticketId: number, body: BodyInit}; export type CreateApiV2TicketingTicketTicketIdCommentOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add comment to ticket * * POST /v2/ticketing/ticket/{ticketId}/comment * * Also accepts auth: sessionKey */ export const createApiV2TicketingTicketTicketIdComment = async (args: CreateApiV2TicketingTicketTicketIdCommentArgs, options: CreateApiV2TicketingTicketTicketIdCommentOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/ticketing/ticket/${encodeURIComponent(String(args.ticketId))}/comment${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) 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 };