export type CreateSupportTicketDto = {contactEmail: string, type: 'BILLING' | 'TECHNICAL' | 'GENERAL' | 'OTHER', subject: string, message: string, platformName: string, memberName: string}; export type CreateApiV1TicketsArgs = {body: CreateSupportTicketDto}; export type CreateApiV1TicketsOptions = {baseUrl: string, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new support ticket * * POST /v1/tickets */ export const createApiV1Tickets = async (args: CreateApiV1TicketsArgs, options: CreateApiV1TicketsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/tickets${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 };