import {z} from 'zod' export type ObjectReference = {id?: number | undefined, name?: (string | null) | undefined}; export type CustomerTenantType = 0 | 1 | 2; export type EntityStatus = 0 | 1; export type Organization = {id?: number | undefined, name?: (string | null) | undefined, parentId?: number | undefined, crayonCompanyName?: (string | null) | undefined, accountNumber?: (string | null) | undefined}; export type SubscriptionPriceType = 1 | 2 | 3; export type AgreementTypeConsent = 0 | 1; export type CustomerTenantAgreement = {firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, phoneNumber?: (string | null) | undefined, email?: (string | null) | undefined, sameAsPrimaryContact?: boolean | undefined, dateAgreed?: (string | null) | undefined, accepted?: boolean | undefined, agreementType?: AgreementTypeConsent | undefined}; export type CustomerTenantExtended = {invoiceProfile?: ObjectReference | undefined, id?: number | undefined, name?: (string | null) | undefined, publisher?: ObjectReference | undefined, program?: ObjectReference | undefined, publisherCustomerId?: (string | null) | undefined, externalPublisherCustomerId?: (string | null) | undefined, domain?: (string | null) | undefined, domainPrefix?: (string | null) | undefined, reference?: (string | null) | undefined, customerTenantType?: CustomerTenantType | undefined, entityStatus?: EntityStatus | undefined, organization?: Organization | undefined, consumer?: ObjectReference | undefined, resellerMarkup?: number | undefined, defaultSubscriptionPriceType?: SubscriptionPriceType | undefined, agreement?: CustomerTenantAgreement | undefined}; export type CustomerTenantUser = {userName?: (string | null) | undefined, password?: (string | null) | undefined}; export type CustomerTenantContact = {firstName?: (string | null) | undefined, lastName?: (string | null) | undefined, email?: (string | null) | undefined, phoneNumber?: (string | null) | undefined}; export type CustomerTenantAddress = {firstName?: (string | null) | undefined, middleName?: (string | null) | undefined, lastName?: (string | null) | undefined, addressLine1?: (string | null) | undefined, addressLine2?: (string | null) | undefined, addressLine3?: (string | null) | undefined, city?: (string | null) | undefined, region?: (string | null) | undefined, postalCode?: (string | null) | undefined, countryCode?: (string | null) | undefined, countryName?: (string | null) | undefined}; export type CustomerTenantProfile = {cultureCode?: (string | null) | undefined, languageCode?: (string | null) | undefined, contact?: CustomerTenantContact | undefined, address?: CustomerTenantAddress | undefined, agreement?: CustomerTenantAgreement | undefined}; export type CustomerTenantCompany = {organizationRegistrationNumber?: (string | null) | undefined}; export type CustomerTenantDetailed = {tenant?: CustomerTenantExtended | undefined, user?: CustomerTenantUser | undefined, profile?: CustomerTenantProfile | undefined, company?: CustomerTenantCompany | undefined}; export type CreateApiApiV1CustomerTenantsExistingArgs = {syncFromPublisher?: boolean | undefined, body: CustomerTenantDetailed}; export type CreateApiApiV1CustomerTenantsExistingOptions = {baseUrl: string, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; export const objectReference = z.object({id: z.number().int().optional(), name: z.string().nullable().optional()}); export const customerTenantType = z.union([z.literal(0), z.literal(1), z.literal(2)]); export const entityStatus = z.union([z.literal(0), z.literal(1)]); export const organization = z.object({id: z.number().int().optional(), name: z.string().nullable().optional(), parentId: z.number().int().optional(), crayonCompanyName: z.string().nullable().optional(), accountNumber: z.string().nullable().optional()}); export const subscriptionPriceType = z.union([z.literal(1), z.literal(2), z.literal(3)]); export const agreementTypeConsent = z.union([z.literal(0), z.literal(1)]); export const customerTenantAgreement = z.object({firstName: z.string().nullable().optional(), lastName: z.string().nullable().optional(), phoneNumber: z.string().nullable().optional(), email: z.string().nullable().optional(), sameAsPrimaryContact: z.boolean().optional(), dateAgreed: z.string().nullable().optional(), accepted: z.boolean().optional(), agreementType: agreementTypeConsent.optional()}); export const customerTenantExtended = z.object({invoiceProfile: objectReference.optional(), id: z.number().int().optional(), name: z.string().nullable().optional(), publisher: objectReference.optional(), program: objectReference.optional(), publisherCustomerId: z.string().nullable().optional(), externalPublisherCustomerId: z.string().nullable().optional(), domain: z.string().nullable().optional(), domainPrefix: z.string().nullable().optional(), reference: z.string().nullable().optional(), customerTenantType: customerTenantType.optional(), entityStatus: entityStatus.optional(), organization: organization.optional(), consumer: objectReference.optional(), resellerMarkup: z.number().optional(), defaultSubscriptionPriceType: subscriptionPriceType.optional(), agreement: customerTenantAgreement.optional()}); export const customerTenantUser = z.object({userName: z.string().nullable().optional(), password: z.string().nullable().optional()}); export const customerTenantContact = z.object({firstName: z.string().nullable().optional(), lastName: z.string().nullable().optional(), email: z.string().nullable().optional(), phoneNumber: z.string().nullable().optional()}); export const customerTenantAddress = z.object({firstName: z.string().nullable().optional(), middleName: z.string().nullable().optional(), lastName: z.string().nullable().optional(), addressLine1: z.string().nullable().optional(), addressLine2: z.string().nullable().optional(), addressLine3: z.string().nullable().optional(), city: z.string().nullable().optional(), region: z.string().nullable().optional(), postalCode: z.string().nullable().optional(), countryCode: z.string().nullable().optional(), countryName: z.string().nullable().optional()}); export const customerTenantProfile = z.object({cultureCode: z.string().nullable().optional(), languageCode: z.string().nullable().optional(), contact: customerTenantContact.optional(), address: customerTenantAddress.optional(), agreement: customerTenantAgreement.optional()}); export const customerTenantCompany = z.object({organizationRegistrationNumber: z.string().nullable().optional()}); export const customerTenantDetailed = z.object({tenant: customerTenantExtended.optional(), user: customerTenantUser.optional(), profile: customerTenantProfile.optional(), company: customerTenantCompany.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 }; /** * POST /api/v1/CustomerTenants/existing */ export const createApiApiV1CustomerTenantsExisting = async (args: CreateApiApiV1CustomerTenantsExistingArgs, options: CreateApiApiV1CustomerTenantsExistingOptions) => { const {baseUrl, fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.syncFromPublisher != null) query.append("syncFromPublisher", String(args.syncFromPublisher)) if (Bearer !== undefined) headers.set("Authorization", Bearer) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/CustomerTenants/existing${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(customerTenantDetailed, await res.json()) };