import {z} from 'zod' export type CreateApiBlinketV1AttendanceListAddManuallyArgs = {body: {eventId: string, ticketId: string, name: string, document: string, documentType: 'cpf' | 'passport', email: string, phone: string, useStock: boolean}}; export type CreateApiBlinketV1AttendanceListAddManuallyOptions = {baseUrl?: string | undefined, eduzzAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiBlinketV1AttendanceListAddManuallyResponse = z.object({id: z.string(), inviteKey: z.string(), name: z.string(), document: z.string(), documentType: z.enum(["cpf", "passport"]), phoneNumber: z.string(), email: z.string(), status: z.string(), manuallyCreated: z.boolean(), modifiedAt: z.string(), eduzzId: z.string(), invoiceId: z.string()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Adicionar participante * * POST /blinket/v1/attendance-list/add-manually */ export const createApiBlinketV1AttendanceListAddManually = async (args: CreateApiBlinketV1AttendanceListAddManuallyArgs, options?: CreateApiBlinketV1AttendanceListAddManuallyOptions) => { const {baseUrl = "https://api.eduzz.com", fetch: fetchFn = fetch, eduzzAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (eduzzAuth !== undefined) headers.set('authorization', `Bearer ${eduzzAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/blinket/v1/attendance-list/add-manually${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 validateResponse(createApiBlinketV1AttendanceListAddManuallyResponse, await res.json()) };