import {z} from 'zod' export type AdaptekApiCommonConstantsCommonStateOrProvinceType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56; export type AdaptekApiCommonConstantsPeopleGenderType = 0 | 1 | 2; export type AdaptekApiCommonConstantsPeoplePersonStatusType = 1 | 2 | 3 | 4 | 5 | 7; export type AdaptekApiApplicationPeopleFTKCommandsUpdateFTKPersonUpdateFTKPersonDisciplineAgentCommand = {id?: number | undefined, agentId?: number | undefined, consumerDisciplineId?: number | undefined}; export type AdaptekApiApplicationPeopleFTKCommandsUpdateFTKPersonUpdateFTKPersonDisciplineCommand = {id?: number | undefined, consumerId?: number | undefined, agencyId?: number | undefined, discipline?: (string | null) | undefined, status?: (string | null) | undefined, disciplineAgents?: (Array | null) | undefined}; export type AdaptekApiApplicationPeopleFTKCommandsUpdateFTKPersonUpdateFTKPersonCommand = {id?: number | undefined, firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, dateOfBirth?: string | undefined, driversLicenseStateTypeId?: AdaptekApiCommonConstantsCommonStateOrProvinceType | undefined, genderTypeId?: AdaptekApiCommonConstantsPeopleGenderType | undefined, statusTypeId?: AdaptekApiCommonConstantsPeoplePersonStatusType | undefined, disciplines?: (Array | null) | undefined}; export type UpdateApiV1PeopleFTKArgs = {body: AdaptekApiApplicationPeopleFTKCommandsUpdateFTKPersonUpdateFTKPersonCommand}; export type UpdateApiV1PeopleFTKOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const microsoftAspNetCoreMvcNoContentResult = z.object({statusCode: z.number().int().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 }; /** * Updates a Person record and its Disciplines and DisciplineAgents * * PUT /v1/PeopleFTK */ export const updateApiV1PeopleFTK = async (args: UpdateApiV1PeopleFTKArgs, options: UpdateApiV1PeopleFTKOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/PeopleFTK${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(microsoftAspNetCoreMvcNoContentResult, await res.json()) };