import {z} from 'zod' export type UpdateApiCustomFormsIdArgs = {id: number, body: {name?: string | undefined, type?: number | undefined, status?: boolean | undefined, pipelines?: (Array<{id?: number | undefined}>) | undefined, activityTypes?: (Array<{id?: number | undefined}>) | undefined, page_title?: string | undefined, page_content?: string | undefined, page_background_color?: string | undefined, page_text_color?: string | undefined, form_text_color?: string | undefined, page_logo_url?: string | undefined, form_background_color?: string | undefined, form_button_background_color?: string | undefined, form_button_text_color?: string | undefined, form_with_rounded_borders?: boolean | undefined, form_show_icons?: boolean | undefined, fields?: ({'0'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '1'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '2'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '3'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '4'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '5'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '6'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '7'?: ({required?: boolean | undefined, custom_field_id?: number | undefined, native_field_type?: number | undefined, native_field_entity?: number | undefined}) | undefined, '8'?: Record | undefined}) | undefined}}; export type UpdateApiCustomFormsIdOptions = {baseUrl?: string | undefined, sec0?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiCustomFormsIdResponse = z.object({id: z.number().int().optional(), account_id: z.number().int().optional(), name: z.string().optional(), type: z.number().int().optional(), status: z.boolean().optional(), page_title: z.string().optional(), page_content: z.string().optional(), page_background_color: z.string().optional(), page_text_color: z.string().optional(), page_logo_url: z.unknown(), form_background_color: z.string().optional(), form_text_color: z.string().optional(), form_button_background_color: z.string().optional(), form_button_text_color: z.string().optional(), form_with_rounded_borders: z.number().int().optional(), form_show_icons: z.boolean().optional(), fields: z.array(z.object({id: z.number().int().optional(), account_id: z.number().int().optional(), custom_form_id: z.number().int().optional(), custom_field_id: z.unknown(), native_field_name: z.string().optional(), native_field_type: z.number().int().optional(), native_field_entity: z.number().int().optional(), required: z.boolean().optional(), order: z.number().int().optional(), created_at: z.string().optional(), updated_at: z.string().optional()})).optional(), activityTypes: z.array(z.object({id: z.number().int().optional(), account_id: z.number().int().optional(), activity_type_id: z.unknown(), name: z.string().optional(), icon: z.string().optional(), description: z.unknown(), active: z.number().int().optional(), send_integration: z.number().int().optional()})).optional(), pipelines: z.array(z.object({id: z.number().int().optional(), account_id: z.number().int().optional(), funnel_type: z.number().int().optional(), funnel_type_name: z.string().optional(), user_id: z.number().int().optional(), name: z.string().optional(), description: z.string().optional(), order: z.number().int().optional(), is_main: z.boolean().optional(), limit_time: z.number().int().optional(), visibility: z.number().int().optional()})).optional()}); 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 }; /** * Atualizar formulário customizado * * PUT /customForms/{id} */ export const updateApiCustomFormsId = async (args: UpdateApiCustomFormsIdArgs, options?: UpdateApiCustomFormsIdOptions) => { const {baseUrl = "https://api.pipe.run/v1", fetch: fetchFn = fetch, sec0} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (sec0 !== undefined) headers.set("token", sec0) const url = `${baseUrl.replace(/\/+$/, '')}/customForms/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(updateApiCustomFormsIdResponse, await res.json()) };