import {z} from 'zod' export type Id = string; export type ConceptEmployeeMinimized = {id?: Id | undefined, personalDetails?: ({firstName?: (string | null) | undefined, lastName?: string | undefined, prefix?: (string | null) | undefined, initials?: (string | null) | undefined, formattedName?: (string | null) | undefined, lastNamePartner?: (string | null) | undefined, prefixPartner?: (string | null) | undefined, dateOfBirth?: (string | null) | undefined, placeOfBirth?: (string | null) | undefined, howToFormatLastName?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, title?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, gender?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, nationality?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, civilStatus?: ({key?: number | undefined, value?: string | undefined} | null) | undefined}) | undefined, contactInformation?: ({phoneNumber?: (string | null) | undefined, mobilePhoneNumber?: (string | null) | undefined, faxNumber?: (string | null) | undefined, emailAddress?: (string | null) | undefined} | null) | undefined, identityDocument?: ({typeOfDocument?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, documentIdentification?: (string | null) | undefined} | null) | undefined, address?: ({street?: (string | null) | undefined, city?: (string | null) | undefined, houseNumber?: (number | null) | undefined, houseNumberAddition?: (string | null) | undefined, furtherIndication?: ({key?: number | undefined, value?: string | undefined} | null) | undefined, postalCode?: (string | null) | undefined, location?: (string | null) | undefined, country?: ({key?: number | undefined, value?: string | undefined, isoCode?: string | undefined} | null) | undefined} | null) | undefined, iban?: (string | null) | undefined, applyPayrollTaxDeduction?: boolean | undefined}; export type UpdateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdArgs = {conceptEmployeeId: string, Authorization: string, Accept: string, body: ConceptEmployeeMinimized}; export type UpdateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const version = z.object({obsoleteDate: z.string().nullable().optional(), resourceVersion: z.string().optional()}); export const messageWarning = z.array(z.object({type: z.string().optional(), description: z.string().optional(), id: z.string().nullable().optional(), code: z.number().int().optional(), properties: z.array(z.string()).optional()})); export const id = z.string(); export const conceptEmployeeMinimized = z.object({id: id.optional(), personalDetails: z.object({firstName: z.string().max(28).nullable().optional(), lastName: z.string().max(25).optional(), prefix: z.string().max(10).nullable().optional(), initials: z.string().max(6).nullable().optional(), formattedName: z.string().max(82).nullable().optional(), lastNamePartner: z.string().max(25).nullable().optional(), prefixPartner: z.string().max(10).nullable().optional(), dateOfBirth: z.string().nullable().optional(), placeOfBirth: z.string().max(24).nullable().optional(), howToFormatLastName: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional(), title: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional(), gender: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional(), nationality: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional(), civilStatus: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional()}).optional(), contactInformation: z.object({phoneNumber: z.string().max(15).nullable().optional(), mobilePhoneNumber: z.string().max(15).nullable().optional(), faxNumber: z.string().max(15).nullable().optional(), emailAddress: z.string().max(255).nullable().optional()}).nullable().optional(), identityDocument: z.object({typeOfDocument: z.object({key: z.number().int().optional(), value: z.string().max(50).optional()}).nullable().optional(), documentIdentification: z.string().max(20).nullable().optional()}).nullable().optional(), address: z.object({street: z.string().max(24).nullable().optional(), city: z.string().max(24).nullable().optional(), houseNumber: z.number().int().nullable().optional(), houseNumberAddition: z.string().max(4).nullable().optional(), furtherIndication: z.object({key: z.number().int().optional(), value: z.string().optional()}).nullable().optional(), postalCode: z.string().max(9).nullable().optional(), location: z.string().max(35).nullable().optional(), country: z.object({key: z.number().int().optional(), value: z.string().max(50).optional(), isoCode: z.string().max(2).optional()}).nullable().optional()}).nullable().optional(), iban: z.string().max(35).nullable().optional(), applyPayrollTaxDeduction: z.boolean().optional()}); export const updateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdResponse = z.object({version: version.optional(), messages: messageWarning.optional(), content: conceptEmployeeMinimized.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 }; /** * Edit the details of a concept employee with fewer fields. * * PUT /v2/providers/employers/conceptemployees/minimized/{conceptEmployeeId} */ export const updateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeId = async (args: UpdateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdArgs, options?: UpdateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdOptions) => { const {baseUrl = "https://api.loket.nl", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json;version=2018-01-01") headers.set('accept', "application/json;version=2018-01-01") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.Accept != null) headers.set("Accept", String(args.Accept)) const url = `${baseUrl.replace(/\/+$/, '')}/v2/providers/employers/conceptemployees/minimized/${encodeURIComponent(String(args.conceptEmployeeId))}${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(updateApiV2ProvidersEmployersConceptemployeesMinimizedConceptEmployeeIdResponse, await res.json()) };