import {z} from 'zod' export type ConnActCommonCategoryDto = {id?: (string | null) | undefined}; export type ConnActCommonCreateUpdatePhoneNumberDto = {value?: (string | null) | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonEmailDto = {value: string, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonContactSocialPlatformDto = {value?: (string | null) | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonMessengerPlatformDto = {value?: (string | null) | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonContactUrlDto = {value?: (string | null) | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonContactDateDto = {value?: string | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonCoordinatesDto = {lat?: number | undefined, lng?: number | undefined}; export type ConnActCommonAddressDto = {addressLine?: (string | null) | undefined, addressLine2?: (string | null) | undefined, city?: (string | null) | undefined, country?: (string | null) | undefined, postalCode?: (string | null) | undefined, coordinates?: ConnActCommonCoordinatesDto | undefined}; export type ConnActCommonContactAddressDto = {value?: ConnActCommonAddressDto | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonConnectionDto = {contactId?: (string | null) | undefined, category?: ConnActCommonCategoryDto | undefined}; export type ConnActCommonTrackingRadiusDto = 'City' | 'Region' | 'Country'; export type ConnActCommonTrackingSettingsDto = {trackingActivated?: boolean | undefined, notificationsEnabled?: boolean | undefined, trackingRadius?: ConnActCommonTrackingRadiusDto | undefined}; export type ConnActCommonLocationDto = {country?: (string | null) | undefined, region?: (string | null) | undefined, city?: (string | null) | undefined, coordinates?: ConnActCommonCoordinatesDto | undefined}; export type ConnActContactsCreateUpdateContactDto = {firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, nickName?: (string | null) | undefined, companyName?: (string | null) | undefined, groups?: (Array | null) | undefined, profilePicture?: (string | null) | undefined, phoneNumbers?: (Array | null) | undefined, emailAddresses?: (Array | null) | undefined, contactSocialPlatforms?: (Array | null) | undefined, contactMessengerPlatforms?: (Array | null) | undefined, urls?: (Array | null) | undefined, contactDates?: (Array | null) | undefined, addresses?: (Array | null) | undefined, connections?: (Array | null) | undefined, notes?: (Array | null) | undefined, trackingSettings?: ConnActCommonTrackingSettingsDto | undefined, location?: ConnActCommonLocationDto | undefined, isPoi?: boolean | undefined}; export type ConnActContactsUpdateContactDto = {id?: (string | null) | undefined, updated?: ConnActContactsCreateUpdateContactDto | undefined}; export type ConnActContactsUpdateManyContactsDto = {contacts?: (Array | null) | undefined}; export type UpdateApiApiAppContactsManyArgs = {body: ConnActContactsUpdateManyContactsDto}; export type UpdateApiApiAppContactsManyOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiApiAppContactsManyResponse = 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 }; /** * PUT /api/app/contacts/many */ export const updateApiApiAppContactsMany = async (args: UpdateApiApiAppContactsManyArgs, options: UpdateApiApiAppContactsManyOptions) => { 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(/\/+$/, '')}/api/app/contacts/many${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(updateApiApiAppContactsManyResponse, await res.json()) };