import {z} from 'zod' export type IntectCountry = {IsSupported?: boolean | undefined, DefaultLanguageId?: number | undefined, ReleaseNoteLink?: string | undefined, GetHelpOnlineLink?: string | undefined, OperatingStatus?: string | undefined, StaticDataId?: number | undefined, Key?: string | undefined, Id?: number | undefined, Name?: string | undefined, Description?: string | undefined, SortKey?: string | undefined}; export type IntectUnitType = {RelevantCountries?: Array | undefined, StaticDataId?: number | undefined, Key?: string | undefined, Id?: number | undefined, Name?: string | undefined, Description?: string | undefined, SortKey?: string | undefined}; export type IntectSalaryRecordPersistenceType = {StaticDataId?: number | undefined, Key?: string | undefined, Id?: number | undefined, Name?: string | undefined, Description?: string | undefined, SortKey?: string | undefined}; export type IntectFormula = {Id?: number | undefined, CompanyId?: (number | null) | undefined, AccountId?: (number | null) | undefined, Name?: string | undefined, Description?: string | undefined, Expression?: string | undefined, FormulaOutputTypeId?: number | undefined}; export type IntectTemplateSalaryRecord = {UnitType?: IntectUnitType | undefined, PersistenceType?: IntectSalaryRecordPersistenceType | undefined, Id?: number | undefined, EmploymentTemplateId?: number | undefined, Units?: (number | null) | undefined, IsActive?: boolean | undefined, Description?: string | undefined, UnitTypeId?: (number | null) | undefined, AmountPerUnit?: (number | null) | undefined, Amount?: (number | null) | undefined, BaseAmount?: (number | null) | undefined, SalaryTypeId?: number | undefined, PersistenceTypeId?: number | undefined, SortOrder?: number | undefined, Formula1Id?: (number | null) | undefined, Formula2Id?: (number | null) | undefined, Formula3Id?: (number | null) | undefined, Formula1?: IntectFormula | undefined, Formula2?: IntectFormula | undefined, Formula3?: IntectFormula | undefined}; export type PatchApiApiEmploymenttemplatesTemplateIdSalaryrecordsArgs = {templateId: string, body: IntectTemplateSalaryRecord}; export type PatchApiApiEmploymenttemplatesTemplateIdSalaryrecordsOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const intectCountry = z.object({IsSupported: z.boolean().optional(), DefaultLanguageId: z.number().int().optional(), ReleaseNoteLink: z.string().optional(), GetHelpOnlineLink: z.string().optional(), OperatingStatus: z.string().optional(), StaticDataId: z.number().int().optional(), Key: z.string().optional(), Id: z.number().int().optional(), Name: z.string().optional(), Description: z.string().optional(), SortKey: z.string().optional()}); export const intectUnitType = z.object({RelevantCountries: z.array(intectCountry).optional(), StaticDataId: z.number().int().optional(), Key: z.string().optional(), Id: z.number().int().optional(), Name: z.string().optional(), Description: z.string().optional(), SortKey: z.string().optional()}); export const intectSalaryRecordPersistenceType = z.object({StaticDataId: z.number().int().optional(), Key: z.string().optional(), Id: z.number().int().optional(), Name: z.string().optional(), Description: z.string().optional(), SortKey: z.string().optional()}); export const intectFormula = z.object({Id: z.number().int().optional(), CompanyId: z.number().int().nullable().optional(), AccountId: z.number().int().nullable().optional(), Name: z.string().optional(), Description: z.string().optional(), Expression: z.string().optional(), FormulaOutputTypeId: z.number().int().optional()}); export const intectTemplateSalaryRecord = z.object({UnitType: intectUnitType.optional(), PersistenceType: intectSalaryRecordPersistenceType.optional(), Id: z.number().int().optional(), EmploymentTemplateId: z.number().int().optional(), Units: z.number().nullable().optional(), IsActive: z.boolean().optional(), Description: z.string().optional(), UnitTypeId: z.number().int().nullable().optional(), AmountPerUnit: z.number().nullable().optional(), Amount: z.number().nullable().optional(), BaseAmount: z.number().nullable().optional(), SalaryTypeId: z.number().int().optional(), PersistenceTypeId: z.number().int().optional(), SortOrder: z.number().int().optional(), Formula1Id: z.number().int().nullable().optional(), Formula2Id: z.number().int().nullable().optional(), Formula3Id: z.number().int().nullable().optional(), Formula1: intectFormula.optional(), Formula2: intectFormula.optional(), Formula3: intectFormula.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 an existing TemplateSalaryRecord. * * PATCH /api/employmenttemplates/{templateId}/salaryrecords */ export const patchApiApiEmploymenttemplatesTemplateIdSalaryrecords = async (args: PatchApiApiEmploymenttemplatesTemplateIdSalaryrecordsArgs, options?: PatchApiApiEmploymenttemplatesTemplateIdSalaryrecordsOptions) => { const {baseUrl = "https://api.intect.app", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/employmenttemplates/${encodeURIComponent(String(args.templateId))}/salaryrecords${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(intectTemplateSalaryRecord, await res.json()) };