import {z} from 'zod' export type LanguageIdEnum = unknown; export type ActorDetailsRequest = {ActorDescription?: (string | null) | undefined, ActorCode?: number | undefined, ActorContact?: (string | null) | undefined, ActorTypeID?: number | undefined, StatusID?: number | undefined, CurrencyID?: number | undefined, TimeZoneKey?: number | undefined, CountryID?: number | undefined, CultureID?: number | undefined, GeoOverrideInheritanceBit?: boolean | undefined, GeoSearchAddress?: (string | null) | undefined, GeoCountryID?: (number | null) | undefined, GeoStateName?: (string | null) | undefined, GeoCityName?: (string | null) | undefined, GeoStreetName?: (string | null) | undefined, GeoStreetNumber?: (string | null) | undefined, GeoLogitude?: (number | null) | undefined, GeoLatitude?: (number | null) | undefined, GeoZoom?: number | undefined, GeoZipCode?: (string | null) | undefined, LanguageID?: LanguageIdEnum | undefined, MCCCode?: (string | null) | undefined}; export type ActorBillingGatewaysRequest = {BillingProviderID?: number | undefined, TerminalID?: number | undefined, ShvaZField?: (string | null) | undefined, TransactionKey?: (string | null) | undefined, ZFieldAllowedBit?: boolean | undefined, MerchantID?: (string | null) | undefined, SubMerchantID?: (string | null) | undefined, Username?: (string | null) | undefined, Password?: (string | null) | undefined, WithZipCodeBit?: boolean | undefined, SupportForcedTransactionsBit?: boolean | undefined, ForcedTransactionTerminalID?: (number | null) | undefined, AVSOnlyBit?: boolean | undefined, PartialConfirmationBit?: boolean | undefined, DisableDebitCards?: boolean | undefined, DebitCardPrefix?: (string | null) | undefined, DisableMagStripeBit?: boolean | undefined, FiscalBit?: boolean | undefined, OverrideURL?: (string | null) | undefined, RemoteStartID?: number | undefined, EnableMultiBillingProvidersBit?: boolean | undefined, RuleSetID?: number | undefined, CustomData?: ({[key: string]: unknown} | null) | undefined}; export type ActorCreateRequest = {ActorDetails?: ActorDetailsRequest | undefined, ActorBillingGateways?: (Array | null) | undefined, ActorBillingPlanID?: number | undefined}; export type CreateApiV2ActorsParentActorIDArgs = {ParentActorID: number, body: ActorCreateRequest}; export type CreateApiV2ActorsParentActorIDOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const languageIdEnum = z.unknown(); export const actorCreateResponse = z.object({ParentActorID: z.number().int().nullable().optional(), ActorID: z.number().int().optional(), ActorDescription: z.string().nullable().optional(), ActorCode: z.number().int().nullable().optional(), ActorContact: z.string().nullable().optional(), ActorTypeID: z.number().int().optional(), ActorStatus: z.number().int().optional(), ActorHierarchyLevel: z.number().int().optional(), CurrencyID: z.number().int().optional(), LastUpdated: z.string().optional(), TimeZoneKey: z.number().int().nullable().optional(), CountryID: z.number().int().nullable().optional(), OperatorActorID: z.number().int().nullable().optional(), DistributorActorID: z.number().int().optional(), ActorHierarchy: z.string().nullable().optional(), ActorCreatedBy: z.number().int().optional(), ActorCreationDate: z.string().optional(), UpdateBy: z.number().int().optional(), CultureID: z.number().int().nullable().optional(), GeoCountryID: z.number().int().nullable().optional(), GeoState: z.string().nullable().optional(), GeoCity: z.string().nullable().optional(), GeoAddress: z.string().nullable().optional(), GeoStreetNumber: z.string().nullable().optional(), GeoLongitude: z.number().nullable().optional(), GeoLatitude: z.number().nullable().optional(), GeoZipCode: z.string().nullable().optional(), GeoZoom: z.number().int().nullable().optional(), ActorLanguageID: languageIdEnum.optional(), OverrideGeoInherritcanceBit: z.boolean().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 }; /** * Create a New Actor * * POST /v2/actors/{ParentActorID} */ export const createApiV2ActorsParentActorID = async (args: CreateApiV2ActorsParentActorIDArgs, options?: CreateApiV2ActorsParentActorIDOptions) => { const {baseUrl = "https://example.com:443", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/actors/${encodeURIComponent(String(args.ParentActorID))}${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(actorCreateResponse, await res.json()) };