import {z} from 'zod' export type AdaptekApiCommonConstantsPeopleSocialSecurityBenefitType = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8; export type AdaptekApiApplicationPersonSocialSecurityCommandsUpsertPersonSocialSecurityUpsertPersonSocialSecurityCommand = {useParentTransaction?: boolean | undefined, personId?: number | undefined, expectedAgeAtDeath?: (number | null) | undefined, primaryInsuranceAmount?: number | undefined, currentBenefitAmount?: (number | null) | undefined, benefitFirstReceivedDate?: (string | null) | undefined, ssdiBenefitAmount?: (number | null) | undefined, currentAnnualIncome?: number | undefined, socialSecurityBenefitTypeID?: AdaptekApiCommonConstantsPeopleSocialSecurityBenefitType | undefined, anticipatedBenefitAge?: number | undefined, colaAssumption?: number | undefined, includeMedicareEstimates?: boolean | undefined, exsDateOfBirth?: (string | null) | undefined, exsPrimaryInsuranceAmount?: number | undefined, deceasedDateOfBirth?: (string | null) | undefined, deceasedPrimaryInsuranceAmount?: number | undefined, spousalSurvivorBenefitAmount?: number | undefined, hasWorkedAsGovernmentEmployee?: boolean | undefined, deceasedBenefitAmount?: (number | null) | undefined, deceasedBenefitFirstReceivedDate?: (string | null) | undefined, deceasedDateOfDeath?: (string | null) | undefined, deceasedReceivingAtDeath?: boolean | undefined, receivingPensionWithoutSocialSecurity?: boolean | undefined, currentMarriageStartedAfterSixty?: boolean | undefined, hasBeenWidowed?: boolean | undefined, caseCentralModifiedAgentId?: (number | null) | undefined, caseCentralDateModified?: (string | null) | undefined}; export type UpdateApiV1PersonSocialSecurityArgs = {body: AdaptekApiApplicationPersonSocialSecurityCommandsUpsertPersonSocialSecurityUpsertPersonSocialSecurityCommand}; export type UpdateApiV1PersonSocialSecurityOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiV1PersonSocialSecurityResponse = z.number().int(); 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 }; /** * Creates or Updates a single Social Security * * PUT /v1/PersonSocialSecurity */ export const updateApiV1PersonSocialSecurity = async (args: UpdateApiV1PersonSocialSecurityArgs, options: UpdateApiV1PersonSocialSecurityOptions) => { 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/PersonSocialSecurity${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(updateApiV1PersonSocialSecurityResponse, await res.json()) };