import {z} from 'zod' export type IntectTimeEntryTypeTranslation = {Id?: number | undefined, TimeEntryTypeId?: number | undefined, LanguageId?: number | undefined, Name?: string | undefined, Description?: string | undefined, DefaultPayslipText?: string | undefined, StatusId?: number | undefined, Comment?: string | undefined}; export type IntectTimeEntryTypeConfiguration = {Id?: number | undefined, TimeEntryTypeId?: number | undefined, SalaryTypeId?: number | undefined, Description?: string | undefined, Amount?: (number | null) | undefined, AmountPerUnit?: (number | null) | undefined, AppliesBefore?: (string | null) | undefined, AppliesAfter?: (string | null) | undefined, AppliesHolidays?: boolean | undefined, AmountPerKilometer?: (number | null) | undefined, EmploymentTemplateId?: (number | null) | undefined, TargetUnitTypeId?: (number | null) | undefined, ConversionFactor?: (number | null) | undefined, UserEmploymentId?: (number | null) | undefined, AppliesSaturdays?: boolean | undefined, AppliesSundays?: boolean | undefined, UseDefaultRate?: boolean | undefined, ConversionFactorAffectsRate?: boolean | undefined, LegacyFlexEarningPercentage?: (number | null) | undefined, NewFlexEarningPercentage?: (number | null) | undefined, PensionPercentage?: (number | null) | undefined, AppliesMondays?: boolean | undefined, AppliesTuesdays?: boolean | undefined, AppliesWednesdays?: boolean | undefined, AppliesThursdays?: boolean | undefined, AppliesFridays?: boolean | undefined, LimitToDepartmentId?: (number | null) | undefined, LimitToDimension1ValueId?: (number | null) | undefined, LimitToDimension2ValueId?: (number | null) | undefined, LimitToDimension3ValueId?: (number | null) | undefined, PensionPercentageEmployee?: (number | null) | undefined, SeniorityMonthsFrom?: (number | null) | undefined, SeniorityMonthsLessThan?: (number | null) | undefined}; export type IntectTimeEntryTypeCountryMapping = {Id?: number | undefined, BaseTimeEntryTypeId?: number | undefined, CountryId?: number | undefined, TimeEntryType?: IntectTimeEntryType | undefined}; export type IntectTimeEntryType = {Id?: number | undefined, BaseTimeEntryTypeId?: (number | null) | undefined, CompanyId?: (number | null) | undefined, Name?: string | undefined, Description?: string | undefined, IsActive?: (boolean | null) | undefined, UnitTypeId?: (number | null) | undefined, ExternalReference?: string | undefined, SortOrder?: (number | null) | undefined, DefaultPayslipText?: string | undefined, AllowEditUnitType?: (boolean | null) | undefined, IsIllness?: (boolean | null) | undefined, InternalReferenceId?: (number | null) | undefined, Identifier?: string | undefined, StatisticsFieldCode?: string | undefined, MandatoryDescription?: (boolean | null) | undefined, IsReimbursable?: (boolean | null) | undefined, BaseTimeEntryType?: IntectTimeEntryType | undefined, TimeEntryTypeTranslations?: Array | undefined, TimeEntryTypeConfigurations?: Array | undefined, TimeEntryTypeCountryMappings?: Array | undefined}; export type PatchApiApiTimeentrytypesArgs = {body: IntectTimeEntryType}; export type PatchApiApiTimeentrytypesOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const intectTimeEntryTypeTranslation = z.object({Id: z.number().int().optional(), TimeEntryTypeId: z.number().int().optional(), LanguageId: z.number().int().optional(), Name: z.string().optional(), Description: z.string().optional(), DefaultPayslipText: z.string().optional(), StatusId: z.number().int().optional(), Comment: z.string().optional()}); export const intectTimeEntryTypeConfiguration = z.object({Id: z.number().int().optional(), TimeEntryTypeId: z.number().int().optional(), SalaryTypeId: z.number().int().optional(), Description: z.string().optional(), Amount: z.number().nullable().optional(), AmountPerUnit: z.number().nullable().optional(), AppliesBefore: z.string().nullable().optional(), AppliesAfter: z.string().nullable().optional(), AppliesHolidays: z.boolean().optional(), AmountPerKilometer: z.number().nullable().optional(), EmploymentTemplateId: z.number().int().nullable().optional(), TargetUnitTypeId: z.number().int().nullable().optional(), ConversionFactor: z.number().nullable().optional(), UserEmploymentId: z.number().int().nullable().optional(), AppliesSaturdays: z.boolean().optional(), AppliesSundays: z.boolean().optional(), UseDefaultRate: z.boolean().optional(), ConversionFactorAffectsRate: z.boolean().optional(), LegacyFlexEarningPercentage: z.number().nullable().optional(), NewFlexEarningPercentage: z.number().nullable().optional(), PensionPercentage: z.number().nullable().optional(), AppliesMondays: z.boolean().optional(), AppliesTuesdays: z.boolean().optional(), AppliesWednesdays: z.boolean().optional(), AppliesThursdays: z.boolean().optional(), AppliesFridays: z.boolean().optional(), LimitToDepartmentId: z.number().int().nullable().optional(), LimitToDimension1ValueId: z.number().int().nullable().optional(), LimitToDimension2ValueId: z.number().int().nullable().optional(), LimitToDimension3ValueId: z.number().int().nullable().optional(), PensionPercentageEmployee: z.number().nullable().optional(), SeniorityMonthsFrom: z.number().int().nullable().optional(), SeniorityMonthsLessThan: z.number().int().nullable().optional()}); export const intectTimeEntryTypeCountryMapping = z.object({Id: z.number().int().optional(), BaseTimeEntryTypeId: z.number().int().optional(), CountryId: z.number().int().optional(), TimeEntryType: z.lazy(() => intectTimeEntryType.optional())}); export const intectTimeEntryType: z.ZodType = z.object({Id: z.number().int().optional(), BaseTimeEntryTypeId: z.number().int().nullable().optional(), CompanyId: z.number().int().nullable().optional(), Name: z.string().optional(), Description: z.string().optional(), IsActive: z.boolean().nullable().optional(), UnitTypeId: z.number().int().nullable().optional(), ExternalReference: z.string().optional(), SortOrder: z.number().int().nullable().optional(), DefaultPayslipText: z.string().optional(), AllowEditUnitType: z.boolean().nullable().optional(), IsIllness: z.boolean().nullable().optional(), InternalReferenceId: z.number().int().nullable().optional(), Identifier: z.string().optional(), StatisticsFieldCode: z.string().optional(), MandatoryDescription: z.boolean().nullable().optional(), IsReimbursable: z.boolean().nullable().optional(), BaseTimeEntryType: z.lazy(() => intectTimeEntryType.optional()), TimeEntryTypeTranslations: z.array(intectTimeEntryTypeTranslation).optional(), TimeEntryTypeConfigurations: z.array(intectTimeEntryTypeConfiguration).optional(), TimeEntryTypeCountryMappings: z.array(intectTimeEntryTypeCountryMapping).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 time entry type. NOTE: Ensure that you use this in conjunction with the /raw method to avoid unintentionally inheriting a base time entry type. * * PATCH /api/timeentrytypes */ export const patchApiApiTimeentrytypes = async (args: PatchApiApiTimeentrytypesArgs, options?: PatchApiApiTimeentrytypesOptions) => { 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/timeentrytypes${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(intectTimeEntryType, await res.json()) };