import {z} from 'zod' export type AdaptekApiCommonConstantsPeopleGenderType = 0 | 1 | 2; export type AdaptekApiCommonConstantsPeopleMaritalStatusType = 1 | 2 | 3 | 4; export type AdaptekApiCommonConstantsPersonEmailAddressesEmailAddressType = 1 | 2 | 3 | 4; export type AdaptekApiApplicationPersonEmailAddressesCommandsCreatePersonEmailAddressUpsertPersonEmailAddressCommand = {personId?: (string | null) | undefined, personEmailId?: (number | null) | undefined, emailAddressType?: AdaptekApiCommonConstantsPersonEmailAddressesEmailAddressType | undefined, emailAddress?: (string | null) | undefined, isUnsubscribedFromCampaigns?: boolean | undefined, isUndeliverable?: boolean | undefined, undeliverableReason?: (string | null) | undefined, isPreferred?: boolean | undefined, remarks?: (string | null) | undefined, salesforceId?: (string | null) | undefined}; 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 AdaptekApiApplicationPersonPhysicalAddressesCommandsUpsertPersonPhysicalAddressUpsertPersonPhysicalAddressCommand = {addressId?: (number | null) | undefined, personId?: number | undefined, street?: (string | null) | undefined, street2?: (string | null) | undefined, city?: (string | null) | undefined, zipCode?: number | undefined, isPreferred?: boolean | undefined, addressType?: number | undefined, stateOrProvinceId?: AdaptekApiCommonConstantsCommonStateOrProvinceType | undefined, salesforceId?: (string | null) | undefined}; export type AdaptekApiApplicationPersonPhoneNumbersCommandsUpsertPersonPhoneNumberUpsertPersonPhoneNumberCommand = {phoneNumberId?: (number | null) | undefined, personId?: number | undefined, phoneNumber?: number | undefined, phoneNumberTypeId?: number | undefined, isPreferred?: boolean | undefined, salesforceId?: (string | null) | undefined}; export type AdaptekApiApplicationPersonElectronicContactCommandsUpsertPersonElectronicContactCommand = {electronicContactId?: (number | null) | undefined, personId?: number | undefined, electronicContactTypeID?: number | undefined, electronicContact?: (string | null) | undefined, isPreferred?: boolean | undefined, remarks?: (string | null) | undefined, salesforceId?: (string | null) | undefined, isUpdate?: boolean | undefined}; export type AdaptekApiApplicationPeopleFullPersonDto = {personId?: (number | null) | undefined, agentId?: number | undefined, salesforcePersonId?: (string | null) | undefined, wealthboxId?: (number | null) | undefined, firstName?: (string | null) | undefined, middleName?: (string | null) | undefined, lastName?: (string | null) | undefined, genderTypeId?: AdaptekApiCommonConstantsPeopleGenderType | undefined, dateOfBirth?: (string | null) | undefined, ssn?: (string | null) | undefined, greeting?: (string | null) | undefined, driversLicenseNumber?: (string | null) | undefined, driversLicenseExpiration?: (string | null) | undefined, driversLicenseState?: (number | null) | undefined, driversLicenseIssueDate?: (string | null) | undefined, age?: (number | null) | undefined, maritalStatusTypeId?: AdaptekApiCommonConstantsPeopleMaritalStatusType | undefined, personStatus?: (number | null) | undefined, lifecycleStatus?: (string | null) | undefined, service?: (string | null) | undefined, emailAddresses?: (Array | null) | undefined, physicalAddresses?: (Array | null) | undefined, phoneNumbers?: (Array | null) | undefined, electronicContacts?: (Array | null) | undefined, isUpdate?: boolean | undefined}; export type AdaptekApiApplicationPeopleCommandsBulkUpsertFullPersonUpsertBulkConsumersCommand = {consumers?: (Array | null) | undefined}; export type CreateApiV1SalesForceBulkPersonAccountsArgs = {body: AdaptekApiApplicationPeopleCommandsBulkUpsertFullPersonUpsertBulkConsumersCommand}; export type CreateApiV1SalesForceBulkPersonAccountsOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonRejectedItemResponse = z.object({salesforceId: z.string().nullable().optional(), errorMessage: z.string().nullable().optional()}); export const adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonBulkConsumerIdsResponse = z.object({kmeId: z.number().int().optional(), salesforceId: z.string().nullable().optional(), wealthboxId: z.number().int().nullable().optional(), emailIds: z.record(z.string(), z.number().int().nullable()).nullable().optional(), phoneNumberIds: z.record(z.string(), z.number().int().nullable()).nullable().optional(), addressIds: z.record(z.string(), z.number().int().nullable()).nullable().optional(), electronicIds: z.record(z.string(), z.number().int().nullable()).nullable().optional(), rejectedAddresses: z.array(adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonRejectedItemResponse).nullable().optional(), rejectedPhoneNumbers: z.array(adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonRejectedItemResponse).nullable().optional()}); export const adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonFailedConsumerResponse = z.object({personId: z.number().int().nullable().optional(), salesforcePersonId: z.string().nullable().optional(), wealthboxId: z.number().int().nullable().optional(), agentId: z.number().int().optional(), errorMessage: z.string().nullable().optional()}); export const adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonUpsertBulkConsumersResponse = z.object({isSuccessful: z.boolean().optional(), recordsSynced: z.number().int().optional(), syncedIds: z.array(adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonBulkConsumerIdsResponse).nullable().optional(), failedRecords: z.array(adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonFailedConsumerResponse).nullable().optional()}); export const createApiV1SalesForceBulkPersonAccountsResponse = z.array(adaptekApiApplicationPeopleCommandsBulkUpsertFullPersonUpsertBulkConsumersResponse); 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 }; /** * POST /v1/SalesForce/BulkPersonAccounts */ export const createApiV1SalesForceBulkPersonAccounts = async (args: CreateApiV1SalesForceBulkPersonAccountsArgs, options: CreateApiV1SalesForceBulkPersonAccountsOptions) => { 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/SalesForce/BulkPersonAccounts${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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(createApiV1SalesForceBulkPersonAccountsResponse, await res.json()) };