export type CreateApiAdminValidationsIdDuplicateArgs = {id: string}; export type CreateApiAdminValidationsIdDuplicateOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Duplicates a validation, overwriting its arguments to copy its data to another object in the system. This is intended to be used when creating a more specific version of a validation. For example, a user-level validation that needs to be \"locked\" to a booking by using a user_id,booking_id tuple. Send the tuple you wish this duplicate to use as its identifier as the new_args key in the body. * * POST /admin/validations/{id}/duplicate * * Also accepts auth: API-Key */ export const createApiAdminValidationsIdDuplicate = async (args: CreateApiAdminValidationsIdDuplicateArgs, options: CreateApiAdminValidationsIdDuplicateOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/admin/validations/${encodeURIComponent(String(args.id))}/duplicate${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };