diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c95eff..6601f01 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Publish v3 to NPM (latest) +name: Publish v3 to NPM (beta) on: push: @@ -30,7 +30,7 @@ jobs: *) echo "ERROR: package.json version must be 3.x.x for v3 tags" && exit 1 ;; esac - - name: Publish to NPM with dist-tag "latest" - run: npm run prepack && npm publish --tag latest --//registry.npmjs.org/:_authToken="$NPM_TOKEN" + - name: Publish to NPM with dist-tag "beta" + run: npm run prepack && npm publish --tag beta --//registry.npmjs.org/:_authToken="$NPM_TOKEN" env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 80d73ab..4e452cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +### v3.25.0-beta.1 (2026-05-14) +* * * + +### Experimental +- **Zod-backed request validation (beta)** — Enable `enableValidation` on the client to validate outgoing request payloads against generated Zod schemas before each API call; invalid payloads raise `ChargebeeZodValidationError` with the original `ZodError` for inspection. +- **Runtime dependency** — Added [`zod`](https://www.npmjs.com/package/zod) (v4) as a dependency to support the above. + + ### v3.24.0 (2026-05-04) * * * ### New Resources: diff --git a/README.md b/README.md index 8c17df0..4adc586 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,45 @@ try { } ``` +### Request parameter validation (Zod) + +When `enableValidation` is set to `true`, the SDK validates parameters for **every** API request against Zod schemas **before** the HTTP call is made. If you omit the params object on a call, it is validated as `{}`. This is **off by default**. Schemas are included for API actions that support them; actions without a bundled schema behave as usual. + +```typescript +import Chargebee, { ChargebeeZodValidationError } from 'chargebee'; + +const chargebee = new Chargebee({ + site: '{{site}}', + apiKey: '{{api-key}}', + enableValidation: true, +}); + +try { + await chargebee.customer.create({ + id: 'a'.repeat(100), + auto_collection: 'invalid', + }); +} catch (err) { + if (err instanceof ChargebeeZodValidationError) { + console.error(err.message); + console.error(err.actionName); + console.error(err.zodError.issues); + } else { + throw err; + } +} +``` + +Invalid parameters produce a `ChargebeeZodValidationError`. The error message lists every problem (field path and message). You can also inspect `actionName` (the API action, for example `create`) and `zodError` (Zod’s `ZodError`, including `issues`) for structured handling. + +**Example message:** + +```text +ChargebeeZodValidationError: [Chargebee] Validation failed for 'create': id: Too big: expected string to have <=50 characters; auto_collection: Invalid option: expected one of "on"|"off" +``` + +The same `ChargebeeZodValidationError` shape applies to any action with a schema when parameters are invalid (for example bad filters or limits on `list`). + ### Using filters in the List API For pagination, `offset` is the parameter that is being used. The value used for this parameter must be the value returned for `next_offset` parameter in the previous API call. diff --git a/VERSION b/VERSION index 954e228..2914650 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.24.0 +3.25.0-beta.1 diff --git a/package-lock.json b/package-lock.json index 203c313..610cfe0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,15 @@ { "name": "chargebee", - "version": "3.24.0", + "version": "3.25.0-beta.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "chargebee", - "version": "3.24.0", + "version": "3.25.0-beta.1", + "dependencies": { + "zod": "^4.3.6" + }, "devDependencies": { "@types/chai": "^4.3.5", "@types/mocha": "^10.0.10", @@ -1282,6 +1285,15 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zod": { + "version": "4.3.6", + "resolved": "https://registry.npmjs.org/zod/-/zod-4.3.6.tgz", + "integrity": "sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/colinhacks" + } } } } diff --git a/package.json b/package.json index 7a2889e..3598397 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chargebee", - "version": "3.24.0", + "version": "3.25.0-beta.1", "description": "A library for integrating with Chargebee.", "scripts": { "prepack": "npm install && npm run build", @@ -75,5 +75,8 @@ "semi": true, "singleQuote": true, "parser": "typescript" + }, + "dependencies": { + "zod": "^4.3.6" } } diff --git a/src/RequestWrapper.ts b/src/RequestWrapper.ts index 878304c..da2a0a6 100644 --- a/src/RequestWrapper.ts +++ b/src/RequestWrapper.ts @@ -18,6 +18,9 @@ import { } from './types.js'; import { handleResponse } from './coreCommon.js'; import { Buffer } from 'node:buffer'; +import type { ZodObject, ZodRawShape } from 'zod'; +import { ChargebeeZodValidationError } from './chargebeeZodValidationError.js'; +import { getSchema } from './validationLoader.js'; export class RequestWrapper { private readonly args: IArguments; @@ -42,6 +45,22 @@ export class RequestWrapper { return idParam; } + /** + * Validate parameters against the action's Zod schema when enableValidation is true. + * Query params are validated as `params ?? {}`; body params are validated when `params` is non-null. + * Throws a descriptive error listing every validation violation. + */ + private static _validateParams( + params: JSONValue, + schema: ZodObject, + actionName: string, + ): void { + const result = schema.safeParse(params); + if (!result.success) { + throw new ChargebeeZodValidationError(actionName, result.error); + } + } + private static parseRetryAfter(retryAfter?: string): number | null { if (!retryAfter) return null; const seconds = parseInt(retryAfter, 10); @@ -71,6 +90,33 @@ export class RequestWrapper { : this.args[0]; let headers = this.apiCall.hasIdInUrl ? this.args[2] : this.args[1]; + // Lazy-load Zod schema when enableValidation is true + if ( + env.enableValidation && + this.apiCall.resourceKey && + this.apiCall.actionName + ) { + const schema = await getSchema( + this.apiCall.resourceKey, + this.apiCall.actionName, + ); + if (schema) { + if (this.apiCall.httpMethod === 'GET') { + RequestWrapper._validateParams( + params ?? {}, + schema, + this.apiCall.methodName, + ); + } else if (params != null) { + RequestWrapper._validateParams( + params, + schema, + this.apiCall.methodName, + ); + } + } + } + Object.assign(this.httpHeaders, headers); if ( diff --git a/src/chargebee.cjs.ts b/src/chargebee.cjs.ts index b2aa811..76cb6f5 100644 --- a/src/chargebee.cjs.ts +++ b/src/chargebee.cjs.ts @@ -9,6 +9,7 @@ import { WebhookPayloadParseError, } from './resources/webhook/handler.js'; import { basicAuthValidator } from './resources/webhook/auth.js'; +import { ChargebeeZodValidationError } from './chargebeeZodValidationError.js'; const httpClient = new FetchHttpClient(); const Chargebee = CreateChargebee(httpClient); @@ -27,6 +28,9 @@ module.exports.WebhookAuthenticationError = WebhookAuthenticationError; module.exports.WebhookPayloadValidationError = WebhookPayloadValidationError; module.exports.WebhookPayloadParseError = WebhookPayloadParseError; +// Export validation error class +module.exports.ChargebeeZodValidationError = ChargebeeZodValidationError; + // Export webhook types export type { WebhookEvent, diff --git a/src/chargebee.cjs.worker.ts b/src/chargebee.cjs.worker.ts index aab09dd..aecb259 100644 --- a/src/chargebee.cjs.worker.ts +++ b/src/chargebee.cjs.worker.ts @@ -1,5 +1,6 @@ import { CreateChargebee } from './createChargebee.js'; import { FetchHttpClient } from './net/FetchClient.js'; +import { ChargebeeZodValidationError } from './chargebeeZodValidationError.js'; const httpClient = new FetchHttpClient(); const Chargebee = CreateChargebee(httpClient); @@ -29,3 +30,4 @@ export type { RequestValidator, } from './resources/webhook/handler.js'; export type { CredentialValidator } from './resources/webhook/auth.js'; +module.exports.ChargebeeZodValidationError = ChargebeeZodValidationError; diff --git a/src/chargebee.esm.ts b/src/chargebee.esm.ts index 5fa6393..8e3e36b 100644 --- a/src/chargebee.esm.ts +++ b/src/chargebee.esm.ts @@ -19,6 +19,9 @@ export { WebhookPayloadParseError, } from './resources/webhook/handler.js'; +// Export validation error class +export { ChargebeeZodValidationError } from './chargebeeZodValidationError.js'; + // Export webhook types export type { WebhookEvent, diff --git a/src/chargebee.esm.worker.ts b/src/chargebee.esm.worker.ts index 5fa6393..dde8dd8 100644 --- a/src/chargebee.esm.worker.ts +++ b/src/chargebee.esm.worker.ts @@ -28,3 +28,4 @@ export type { RequestValidator, } from './resources/webhook/handler.js'; export type { CredentialValidator } from './resources/webhook/auth.js'; +export { ChargebeeZodValidationError } from './chargebeeZodValidationError.js'; diff --git a/src/chargebeeZodValidationError.ts b/src/chargebeeZodValidationError.ts new file mode 100644 index 0000000..3766bd5 --- /dev/null +++ b/src/chargebeeZodValidationError.ts @@ -0,0 +1,18 @@ +import type { ZodError } from 'zod'; + +export class ChargebeeZodValidationError extends Error { + readonly actionName: string; + readonly zodError: ZodError; + + constructor(actionName: string, zodError: ZodError) { + const messages = zodError.issues + .map((e) => `${e.path.join('.')}: ${e.message}`) + .join('; '); + super(`[Chargebee] Validation failed for '${actionName}': ${messages}`); + Object.setPrototypeOf(this, new.target.prototype); + this.name = 'ChargebeeZodValidationError'; + this.actionName = actionName; + this.zodError = zodError; + Error.captureStackTrace?.(this, this.constructor); + } +} diff --git a/src/createChargebee.ts b/src/createChargebee.ts index 3ec3082..094a29d 100644 --- a/src/createChargebee.ts +++ b/src/createChargebee.ts @@ -105,6 +105,11 @@ export const CreateChargebee = (httpClient: HttpClientInterface) => { jsonKeys: metaArr[7], options: metaArr[8], }; + if (this._env.enableValidation) { + // Store resource and action for lazy schema loading in RequestWrapper + apiCall.resourceKey = res; + apiCall.actionName = metaArr[0] as string; + } this[res][apiCall.methodName] = this._createApiFunc( apiCall, this._env, diff --git a/src/environment.ts b/src/environment.ts index 09dc710..a78c9bb 100644 --- a/src/environment.ts +++ b/src/environment.ts @@ -9,7 +9,7 @@ export const Environment = { hostSuffix: '.chargebee.com', apiPath: '/api/v2', timeout: DEFAULT_TIME_OUT, - clientVersion: 'v3.24.0', + clientVersion: 'v3.25.0-beta.1', port: DEFAULT_PORT, timemachineWaitInMillis: DEFAULT_TIME_MACHINE_WAIT, exportWaitInMillis: DEFAULT_EXPORT_WAIT, diff --git a/src/schema/addon.schema.ts b/src/schema/addon.schema.ts new file mode 100644 index 0000000..61dcc6c --- /dev/null +++ b/src/schema/addon.schema.ts @@ -0,0 +1,160 @@ +// Generated Zod schemas: Addon +// Actions: create, update, copy +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Addon.create + +const CreateAddonMetaDataSchema = z.looseObject({}); +const CreateAddonTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CreateAddonTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const CreateAddonBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(100), + invoice_name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + charge_type: z.enum(['recurring', 'non_recurring']), + price: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + period: z.number().int().min(1).optional(), + period_unit: z + .enum(['day', 'week', 'month', 'year', 'not_applicable']) + .optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + type: z + .enum(['on_off', 'quantity', 'tiered', 'volume', 'stairstep']) + .optional(), + unit: z.string().max(30).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + taxable: z.boolean().default(true).optional(), + tax_profile_id: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + taxjar_product_code: z.string().max(50).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: CreateAddonMetaDataSchema.optional(), + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), + is_shippable: z.boolean().default(false).optional(), + shipping_frequency_period: z.number().int().min(1).optional(), + shipping_frequency_period_unit: z + .enum(['year', 'month', 'week', 'day']) + .optional(), + included_in_mrr: z.boolean().optional(), + show_description_in_invoices: z.boolean().default(false).optional(), + show_description_in_quotes: z.boolean().default(false).optional(), + price_in_decimal: z.string().max(39).optional(), + proration_type: z + .enum(['site_default', 'partial_term', 'full_term']) + .optional(), + status: z.enum(['active', 'archived']).optional(), + tiers: CreateAddonTiersSchema.optional(), + tax_providers_fields: CreateAddonTaxProvidersFieldsSchema.optional(), +}); +export { CreateAddonBodySchema }; +export type CreateAddonBody = z.infer; + +//Addon.update + +const UpdateAddonMetaDataSchema = z.looseObject({}); +const UpdateAddonTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const UpdateAddonTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const UpdateAddonBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + invoice_name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + charge_type: z.enum(['recurring', 'non_recurring']).optional(), + price: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + period: z.number().int().min(1).optional(), + period_unit: z + .enum(['day', 'week', 'month', 'year', 'not_applicable']) + .optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + type: z + .enum(['on_off', 'quantity', 'tiered', 'volume', 'stairstep']) + .optional(), + unit: z.string().max(30).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + taxable: z.boolean().default(true).optional(), + tax_profile_id: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + taxjar_product_code: z.string().max(50).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdateAddonMetaDataSchema.optional(), + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), + is_shippable: z.boolean().default(false).optional(), + shipping_frequency_period: z.number().int().min(1).optional(), + shipping_frequency_period_unit: z + .enum(['year', 'month', 'week', 'day']) + .optional(), + included_in_mrr: z.boolean().optional(), + show_description_in_invoices: z.boolean().default(false).optional(), + show_description_in_quotes: z.boolean().default(false).optional(), + price_in_decimal: z.string().max(39).optional(), + proration_type: z + .enum(['site_default', 'partial_term', 'full_term']) + .optional(), + tiers: UpdateAddonTiersSchema.optional(), + tax_providers_fields: UpdateAddonTaxProvidersFieldsSchema.optional(), +}); +export { UpdateAddonBodySchema }; +export type UpdateAddonBody = z.infer; + +//Addon.copy + +const CopyAddonBodySchema = z.looseObject({ + from_site: z.string().max(50), + id_at_from_site: z.string().max(100), + id: z.string().max(100).optional(), + for_site_merging: z.boolean().default(false).optional(), +}); +export { CopyAddonBodySchema }; +export type CopyAddonBody = z.infer; diff --git a/src/schema/address.schema.ts b/src/schema/address.schema.ts new file mode 100644 index 0000000..2640758 --- /dev/null +++ b/src/schema/address.schema.ts @@ -0,0 +1,39 @@ +// Generated Zod schemas: Address +// Actions: retrieve, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Address.retrieve + +const RetrieveAddressBodySchema = z.looseObject({ + subscription_id: z.string().max(50), + label: z.string().max(50), +}); +export { RetrieveAddressBodySchema }; +export type RetrieveAddressBody = z.infer; + +//Address.update + +const UpdateAddressBodySchema = z.looseObject({ + subscription_id: z.string().max(50), + label: z.string().max(50), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + addr: z.string().max(150).optional(), + extended_addr: z.string().max(150).optional(), + extended_addr2: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +export { UpdateAddressBodySchema }; +export type UpdateAddressBody = z.infer; diff --git a/src/schema/alert.schema.ts b/src/schema/alert.schema.ts new file mode 100644 index 0000000..f146b48 --- /dev/null +++ b/src/schema/alert.schema.ts @@ -0,0 +1,42 @@ +// Generated Zod schemas: Alert +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Alert.create + +const CreateAlertThresholdSchema = z.object({ + mode: z.enum(['absolute', 'percentage']), + value: z.number(), +}); +const CreateAlertFilterConditionsSchema = z.object({ + field: z.array(z.enum(['plan_price_id']).optional()).optional(), + operator: z.array(z.enum(['equals', 'not_equals']).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateAlertBodySchema = z.looseObject({ + type: z.enum(['usage_exceeded']), + name: z.string().max(50), + description: z.string().max(65000).optional(), + metered_feature_id: z.string().max(50), + subscription_id: z.string().max(50).optional(), + meta: z.string().max(65000).optional(), + threshold: CreateAlertThresholdSchema.optional(), + filter_conditions: CreateAlertFilterConditionsSchema.optional(), +}); +export { CreateAlertBodySchema }; +export type CreateAlertBody = z.infer; + +//Alert.update + +const UpdateAlertThresholdSchema = z.object({ + mode: z.enum(['absolute', 'percentage']).optional(), + value: z.number().optional(), +}); +const UpdateAlertBodySchema = z.looseObject({ + status: z.enum(['enabled', 'disabled']).optional(), + threshold: UpdateAlertThresholdSchema.optional(), +}); +export { UpdateAlertBodySchema }; +export type UpdateAlertBody = z.infer; diff --git a/src/schema/attached_item.schema.ts b/src/schema/attached_item.schema.ts new file mode 100644 index 0000000..a0da71f --- /dev/null +++ b/src/schema/attached_item.schema.ts @@ -0,0 +1,76 @@ +// Generated Zod schemas: AttachedItem +// Actions: create, update, retrieve, delete +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//AttachedItem.create + +const CreateAttachedItemBodySchema = z.looseObject({ + item_id: z.string().max(100), + type: z.enum(['recommended', 'mandatory', 'optional']).optional(), + billing_cycles: z.number().int().min(1).optional(), + quantity: z.number().int().min(1).optional(), + quantity_in_decimal: z.string().max(33).optional(), + charge_on_event: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), + charge_once: z.boolean().optional(), + business_entity_id: z.string().max(50).optional(), +}); +export { CreateAttachedItemBodySchema }; +export type CreateAttachedItemBody = z.infer< + typeof CreateAttachedItemBodySchema +>; + +//AttachedItem.update + +const UpdateAttachedItemBodySchema = z.looseObject({ + parent_item_id: z.string().max(100), + type: z.enum(['recommended', 'mandatory', 'optional']).optional(), + billing_cycles: z.number().int().min(1).optional(), + quantity: z.number().int().min(1).optional(), + quantity_in_decimal: z.string().max(33).optional(), + charge_on_event: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), + charge_once: z.boolean().optional(), +}); +export { UpdateAttachedItemBodySchema }; +export type UpdateAttachedItemBody = z.infer< + typeof UpdateAttachedItemBodySchema +>; + +//AttachedItem.retrieve + +const RetrieveAttachedItemBodySchema = z.looseObject({ + parent_item_id: z.string().max(100), +}); +export { RetrieveAttachedItemBodySchema }; +export type RetrieveAttachedItemBody = z.infer< + typeof RetrieveAttachedItemBodySchema +>; + +//AttachedItem.delete + +const DeleteAttachedItemBodySchema = z.looseObject({ + parent_item_id: z.string().max(100), +}); +export { DeleteAttachedItemBodySchema }; +export type DeleteAttachedItemBody = z.infer< + typeof DeleteAttachedItemBodySchema +>; diff --git a/src/schema/business_entity.schema.ts b/src/schema/business_entity.schema.ts new file mode 100644 index 0000000..d1b67b1 --- /dev/null +++ b/src/schema/business_entity.schema.ts @@ -0,0 +1,55 @@ +// Generated Zod schemas: BusinessEntity +// Actions: createTransfers, getTransfers +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//BusinessEntity.createTransfers + +const CreateTransfersBusinessEntityBodySchema = z.looseObject({ + active_resource_ids: z.array(z.string().max(50).optional()), + destination_business_entity_ids: z.array(z.string().max(50).optional()), + source_business_entity_ids: z.array(z.string().max(50).optional()).optional(), + resource_types: z.array(z.string().max(50).optional()), + reason_codes: z.array(z.string().max(50).optional()), +}); +export { CreateTransfersBusinessEntityBodySchema }; +export type CreateTransfersBusinessEntityBody = z.infer< + typeof CreateTransfersBusinessEntityBodySchema +>; + +//BusinessEntity.getTransfers + +const GetTransfersBusinessEntityResourceTypeSchema = z.object({ + is: z.string().min(1).optional(), +}); +const GetTransfersBusinessEntityResourceIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const GetTransfersBusinessEntityActiveResourceIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const GetTransfersBusinessEntityCreatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const GetTransfersBusinessEntitySortBySchema = z.looseObject({ + asc: z.enum(['created_at']).optional(), + desc: z.enum(['created_at']).optional(), +}); +const GetTransfersBusinessEntityBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + resource_type: GetTransfersBusinessEntityResourceTypeSchema.optional(), + resource_id: GetTransfersBusinessEntityResourceIdSchema.optional(), + active_resource_id: + GetTransfersBusinessEntityActiveResourceIdSchema.optional(), + created_at: GetTransfersBusinessEntityCreatedAtSchema.optional(), + sort_by: GetTransfersBusinessEntitySortBySchema.optional(), +}); +export { GetTransfersBusinessEntityBodySchema }; +export type GetTransfersBusinessEntityBody = z.infer< + typeof GetTransfersBusinessEntityBodySchema +>; diff --git a/src/schema/card.schema.ts b/src/schema/card.schema.ts new file mode 100644 index 0000000..ccfaff7 --- /dev/null +++ b/src/schema/card.schema.ts @@ -0,0 +1,178 @@ +// Generated Zod schemas: Card +// Actions: updateCardForCustomer, switchGatewayForCustomer, copyCardForCustomer +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Card.updateCardForCustomer + +const UpdateCardForCustomerCardCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), +}); +const UpdateCardForCustomerCardBodySchema = z.looseObject({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500), + expiry_month: z.number().int().min(1).max(12), + expiry_year: z.number().int(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + customer: UpdateCardForCustomerCardCustomerSchema.optional(), +}); +export { UpdateCardForCustomerCardBodySchema }; +export type UpdateCardForCustomerCardBody = z.infer< + typeof UpdateCardForCustomerCardBodySchema +>; + +//Card.switchGatewayForCustomer + +const SwitchGatewayForCustomerCardBodySchema = z.looseObject({ + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'wirecard', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50), +}); +export { SwitchGatewayForCustomerCardBodySchema }; +export type SwitchGatewayForCustomerCardBody = z.infer< + typeof SwitchGatewayForCustomerCardBodySchema +>; + +//Card.copyCardForCustomer + +const CopyCardForCustomerCardBodySchema = z.looseObject({ + gateway_account_id: z.string().max(50), +}); +export { CopyCardForCustomerCardBodySchema }; +export type CopyCardForCustomerCardBody = z.infer< + typeof CopyCardForCustomerCardBodySchema +>; diff --git a/src/schema/comment.schema.ts b/src/schema/comment.schema.ts new file mode 100644 index 0000000..7d57952 --- /dev/null +++ b/src/schema/comment.schema.ts @@ -0,0 +1,73 @@ +// Generated Zod schemas: Comment +// Actions: create, list +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Comment.create + +const CreateCommentBodySchema = z.looseObject({ + entity_type: z.enum([ + 'customer', + 'subscription', + 'invoice', + 'quote', + 'credit_note', + 'transaction', + 'plan', + 'addon', + 'coupon', + 'order', + 'business_entity', + 'item_family', + 'item', + 'item_price', + 'price_variant', + ]), + entity_id: z.string().max(100), + notes: z.string().max(1000), + added_by: z.string().max(100).optional(), +}); +export { CreateCommentBodySchema }; +export type CreateCommentBody = z.infer; + +//Comment.list + +const ListCommentCreatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ListCommentSortBySchema = z.looseObject({ + asc: z.enum(['created_at']).optional(), + desc: z.enum(['created_at']).optional(), +}); +const ListCommentBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + entity_type: z + .enum([ + 'customer', + 'subscription', + 'invoice', + 'quote', + 'credit_note', + 'transaction', + 'plan', + 'addon', + 'coupon', + 'order', + 'business_entity', + 'item_family', + 'item', + 'item_price', + 'price_variant', + ]) + .optional(), + entity_id: z.string().max(100).optional(), + created_at: ListCommentCreatedAtSchema.optional(), + sort_by: ListCommentSortBySchema.optional(), +}); +export { ListCommentBodySchema }; +export type ListCommentBody = z.infer; diff --git a/src/schema/coupon.schema.ts b/src/schema/coupon.schema.ts new file mode 100644 index 0000000..6afa57e --- /dev/null +++ b/src/schema/coupon.schema.ts @@ -0,0 +1,236 @@ +// Generated Zod schemas: Coupon +// Actions: create, createForItems, updateForItems, update, copy +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Coupon.create + +const CreateCouponMetaDataSchema = z.looseObject({}); +const CreateCouponBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(50), + invoice_name: z.string().max(100).optional(), + discount_type: z + .enum(['fixed_amount', 'percentage', 'offer_quantity']) + .optional(), + discount_amount: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + discount_percentage: z.number().min(0.01).max(100).optional(), + discount_quantity: z.number().int().min(1).optional(), + apply_on: z.enum([ + 'invoice_amount', + 'specified_items_total', + 'each_specified_item', + 'each_unit_of_specified_items', + ]), + duration_type: z.enum(['one_time', 'forever', 'limited_period']).optional(), + duration_month: z.number().int().min(1).max(240).optional(), + valid_till: z.number().int().optional(), + max_redemptions: z.number().int().min(1).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: CreateCouponMetaDataSchema.optional(), + included_in_mrr: z.boolean().optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + plan_constraint: z.enum(['none', 'all', 'specific']).optional(), + addon_constraint: z.enum(['none', 'all', 'specific']).optional(), + plan_ids: z.array(z.string().max(100).optional()).optional(), + addon_ids: z.array(z.string().max(100).optional()).optional(), + status: z.enum(['active', 'archived']).optional(), +}); +export { CreateCouponBodySchema }; +export type CreateCouponBody = z.infer; + +//Coupon.createForItems + +const CreateForItemsCouponMetaDataSchema = z.looseObject({}); +const CreateForItemsCouponItemConstraintsSchema = z.object({ + constraint: z.array( + z.enum(['none', 'all', 'specific', 'criteria']).optional(), + ), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()), + item_price_ids: z.array(z.array(z.string().optional()).optional()).optional(), +}); +const CreateForItemsCouponItemConstraintCriteriaSchema = z.object({ + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + item_family_ids: z + .array(z.array(z.string().optional()).optional()) + .optional(), + currencies: z.array(z.array(z.string().optional()).optional()).optional(), + item_price_periods: z + .array(z.array(z.string().optional()).optional()) + .optional(), +}); +const CreateForItemsCouponCouponConstraintsSchema = z.object({ + entity_type: z.array(z.enum(['customer']).optional()), + type: z.array( + z + .enum([ + 'max_redemptions', + 'unique_by', + 'existing_customer', + 'new_customer', + ]) + .optional(), + ), + value: z.array(z.string().max(65000).optional()).optional(), +}); +const CreateForItemsCouponBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(50), + invoice_name: z.string().max(100).optional(), + discount_type: z + .enum(['fixed_amount', 'percentage', 'offer_quantity']) + .optional(), + discount_amount: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + discount_percentage: z.number().min(0.01).max(100).optional(), + discount_quantity: z.number().int().min(1).optional(), + apply_on: z.enum([ + 'invoice_amount', + 'specified_items_total', + 'each_specified_item', + 'each_unit_of_specified_items', + ]), + duration_type: z.enum(['one_time', 'forever', 'limited_period']).optional(), + duration_month: z.number().int().min(1).max(240).optional(), + valid_from: z.number().int().optional(), + valid_till: z.number().int().optional(), + max_redemptions: z.number().int().min(1).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: CreateForItemsCouponMetaDataSchema.optional(), + included_in_mrr: z.boolean().optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + status: z.enum(['active', 'archived']).optional(), + item_constraints: CreateForItemsCouponItemConstraintsSchema.optional(), + item_constraint_criteria: + CreateForItemsCouponItemConstraintCriteriaSchema.optional(), + coupon_constraints: CreateForItemsCouponCouponConstraintsSchema.optional(), +}); +export { CreateForItemsCouponBodySchema }; +export type CreateForItemsCouponBody = z.infer< + typeof CreateForItemsCouponBodySchema +>; + +//Coupon.updateForItems + +const UpdateForItemsCouponMetaDataSchema = z.looseObject({}); +const UpdateForItemsCouponItemConstraintsSchema = z.object({ + constraint: z.array( + z.enum(['none', 'all', 'specific', 'criteria']).optional(), + ), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()), + item_price_ids: z.array(z.array(z.string().optional()).optional()).optional(), +}); +const UpdateForItemsCouponItemConstraintCriteriaSchema = z.object({ + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + item_family_ids: z + .array(z.array(z.string().optional()).optional()) + .optional(), + currencies: z.array(z.array(z.string().optional()).optional()).optional(), + item_price_periods: z + .array(z.array(z.string().optional()).optional()) + .optional(), +}); +const UpdateForItemsCouponCouponConstraintsSchema = z.object({ + entity_type: z.array(z.enum(['customer']).optional()), + type: z.array( + z + .enum([ + 'max_redemptions', + 'unique_by', + 'existing_customer', + 'new_customer', + ]) + .optional(), + ), + value: z.array(z.string().max(65000).optional()).optional(), +}); +const UpdateForItemsCouponBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + invoice_name: z.string().max(100).optional(), + discount_type: z + .enum(['fixed_amount', 'percentage', 'offer_quantity']) + .optional(), + discount_amount: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + discount_percentage: z.number().min(0.01).max(100).optional(), + discount_quantity: z.number().int().min(1).optional(), + apply_on: z + .enum([ + 'invoice_amount', + 'specified_items_total', + 'each_specified_item', + 'each_unit_of_specified_items', + ]) + .optional(), + duration_type: z.enum(['one_time', 'forever', 'limited_period']).optional(), + duration_month: z.number().int().min(1).max(240).optional(), + valid_from: z.number().int().optional(), + valid_till: z.number().int().optional(), + max_redemptions: z.number().int().min(1).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdateForItemsCouponMetaDataSchema.optional(), + included_in_mrr: z.boolean().optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + item_constraints: UpdateForItemsCouponItemConstraintsSchema.optional(), + item_constraint_criteria: + UpdateForItemsCouponItemConstraintCriteriaSchema.optional(), + coupon_constraints: UpdateForItemsCouponCouponConstraintsSchema.optional(), +}); +export { UpdateForItemsCouponBodySchema }; +export type UpdateForItemsCouponBody = z.infer< + typeof UpdateForItemsCouponBodySchema +>; + +//Coupon.update + +const UpdateCouponMetaDataSchema = z.looseObject({}); +const UpdateCouponBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + invoice_name: z.string().max(100).optional(), + discount_type: z + .enum(['fixed_amount', 'percentage', 'offer_quantity']) + .optional(), + discount_amount: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + discount_percentage: z.number().min(0.01).max(100).optional(), + discount_quantity: z.number().int().min(1).optional(), + apply_on: z + .enum([ + 'invoice_amount', + 'specified_items_total', + 'each_specified_item', + 'each_unit_of_specified_items', + ]) + .optional(), + duration_type: z.enum(['one_time', 'forever', 'limited_period']).optional(), + duration_month: z.number().int().min(1).max(240).optional(), + valid_till: z.number().int().optional(), + max_redemptions: z.number().int().min(1).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdateCouponMetaDataSchema.optional(), + included_in_mrr: z.boolean().optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + plan_constraint: z.enum(['none', 'all', 'specific']).optional(), + addon_constraint: z.enum(['none', 'all', 'specific']).optional(), + plan_ids: z.array(z.string().max(100).optional()).optional(), + addon_ids: z.array(z.string().max(100).optional()).optional(), +}); +export { UpdateCouponBodySchema }; +export type UpdateCouponBody = z.infer; + +//Coupon.copy + +const CopyCouponBodySchema = z.looseObject({ + from_site: z.string().max(50), + id_at_from_site: z.string().max(100), + id: z.string().max(100).optional(), + for_site_merging: z.boolean().default(false).optional(), +}); +export { CopyCouponBodySchema }; +export type CopyCouponBody = z.infer; diff --git a/src/schema/coupon_code.schema.ts b/src/schema/coupon_code.schema.ts new file mode 100644 index 0000000..578f591 --- /dev/null +++ b/src/schema/coupon_code.schema.ts @@ -0,0 +1,15 @@ +// Generated Zod schemas: CouponCode +// Actions: create +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//CouponCode.create + +const CreateCouponCodeBodySchema = z.looseObject({ + coupon_id: z.string().max(100), + coupon_set_name: z.string().max(50), + code: z.string().max(50), +}); +export { CreateCouponCodeBodySchema }; +export type CreateCouponCodeBody = z.infer; diff --git a/src/schema/coupon_set.schema.ts b/src/schema/coupon_set.schema.ts new file mode 100644 index 0000000..13b259c --- /dev/null +++ b/src/schema/coupon_set.schema.ts @@ -0,0 +1,37 @@ +// Generated Zod schemas: CouponSet +// Actions: create, addCouponCodes, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//CouponSet.create + +const CreateCouponSetMetaDataSchema = z.looseObject({}); +const CreateCouponSetBodySchema = z.looseObject({ + coupon_id: z.string().max(100), + name: z.string().max(50), + id: z.string().max(50), + meta_data: CreateCouponSetMetaDataSchema.optional(), +}); +export { CreateCouponSetBodySchema }; +export type CreateCouponSetBody = z.infer; + +//CouponSet.addCouponCodes + +const AddCouponCodesCouponSetBodySchema = z.looseObject({ + code: z.array(z.string().max(50).optional()).optional(), +}); +export { AddCouponCodesCouponSetBodySchema }; +export type AddCouponCodesCouponSetBody = z.infer< + typeof AddCouponCodesCouponSetBodySchema +>; + +//CouponSet.update + +const UpdateCouponSetMetaDataSchema = z.looseObject({}); +const UpdateCouponSetBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + meta_data: UpdateCouponSetMetaDataSchema.optional(), +}); +export { UpdateCouponSetBodySchema }; +export type UpdateCouponSetBody = z.infer; diff --git a/src/schema/credit_note.schema.ts b/src/schema/credit_note.schema.ts new file mode 100644 index 0000000..1d52afe --- /dev/null +++ b/src/schema/credit_note.schema.ts @@ -0,0 +1,338 @@ +// Generated Zod schemas: CreditNote +// Actions: create, retrieve, pdf, refund, recordRefund, voidCreditNote, creditNotesForCustomer, delete, removeTaxWithheldRefund, importCreditNote +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//CreditNote.create + +const CreateCreditNoteLineItemsSchema = z.object({ + reference_line_item_id: z.array(z.string().max(40).optional()).optional(), + unit_amount: z.array(z.number().int().optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity: z.array(z.number().int().optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + amount: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + entity_type: z + .array( + z + .enum([ + 'adhoc', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan', + 'addon', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateCreditNoteBodySchema = z.looseObject({ + reference_invoice_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), + total: z.number().int().min(0).optional(), + type: z.enum(['adjustment', 'refundable', 'store']), + reason_code: z + .enum([ + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + ]) + .optional(), + create_reason_code: z.string().max(100).optional(), + date: z.number().int().optional(), + customer_notes: z.string().max(2000).optional(), + currency_code: z.string().max(3).optional(), + comment: z.string().max(300).optional(), + line_items: CreateCreditNoteLineItemsSchema.optional(), +}); +export { CreateCreditNoteBodySchema }; +export type CreateCreditNoteBody = z.infer; + +//CreditNote.retrieve + +const RetrieveCreditNoteSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const RetrieveCreditNoteCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const RetrieveCreditNoteLineItemSchema = z.object({ + subscription_id: RetrieveCreditNoteSubscriptionIdSchema.optional(), + customer_id: RetrieveCreditNoteCustomerIdSchema.optional(), +}); +const RetrieveCreditNoteBodySchema = z.looseObject({ + line_items_limit: z.number().int().min(1).max(300).optional(), + line_items_offset: z.string().max(1000).optional(), + line_item: RetrieveCreditNoteLineItemSchema.optional(), +}); +export { RetrieveCreditNoteBodySchema }; +export type RetrieveCreditNoteBody = z.infer< + typeof RetrieveCreditNoteBodySchema +>; + +//CreditNote.pdf + +const PdfCreditNoteBodySchema = z.looseObject({ + disposition_type: z.enum(['attachment', 'inline']).optional(), +}); +export { PdfCreditNoteBodySchema }; +export type PdfCreditNoteBody = z.infer; + +//CreditNote.refund + +const RefundCreditNoteBodySchema = z.looseObject({ + refund_amount: z.number().int().min(1).optional(), + customer_notes: z.string().max(2000).optional(), + refund_reason_code: z.string().max(100).optional(), +}); +export { RefundCreditNoteBodySchema }; +export type RefundCreditNoteBody = z.infer; + +//CreditNote.recordRefund + +const RecordRefundCreditNoteTransactionSchema = z.object({ + id: z.string().max(40).optional(), + amount: z.number().int().min(0).optional(), + payment_method: z.enum([ + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]), + reference_number: z.string().max(100).optional(), + custom_payment_method_id: z.string().max(50).optional(), + date: z.number().int(), +}); +const RecordRefundCreditNoteBodySchema = z.looseObject({ + refund_reason_code: z.string().max(100).optional(), + comment: z.string().max(300).optional(), + transaction: RecordRefundCreditNoteTransactionSchema.optional(), +}); +export { RecordRefundCreditNoteBodySchema }; +export type RecordRefundCreditNoteBody = z.infer< + typeof RecordRefundCreditNoteBodySchema +>; + +//CreditNote.voidCreditNote + +const VoidCreditNoteCreditNoteBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { VoidCreditNoteCreditNoteBodySchema }; +export type VoidCreditNoteCreditNoteBody = z.infer< + typeof VoidCreditNoteCreditNoteBodySchema +>; + +//CreditNote.creditNotesForCustomer + +const CreditNotesForCustomerCreditNoteBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { CreditNotesForCustomerCreditNoteBodySchema }; +export type CreditNotesForCustomerCreditNoteBody = z.infer< + typeof CreditNotesForCustomerCreditNoteBodySchema +>; + +//CreditNote.delete + +const DeleteCreditNoteBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { DeleteCreditNoteBodySchema }; +export type DeleteCreditNoteBody = z.infer; + +//CreditNote.removeTaxWithheldRefund + +const RemoveTaxWithheldRefundCreditNoteTaxWithheldSchema = z.object({ + id: z.string().max(40), +}); +const RemoveTaxWithheldRefundCreditNoteBodySchema = z.looseObject({ + tax_withheld: RemoveTaxWithheldRefundCreditNoteTaxWithheldSchema.optional(), +}); +export { RemoveTaxWithheldRefundCreditNoteBodySchema }; +export type RemoveTaxWithheldRefundCreditNoteBody = z.infer< + typeof RemoveTaxWithheldRefundCreditNoteBodySchema +>; + +//CreditNote.importCreditNote + +const ImportCreditNoteCreditNoteLineItemsSchema = z.object({ + reference_line_item_id: z.array(z.string().max(40).optional()).optional(), + id: z.array(z.string().max(40).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), + subscription_id: z.array(z.string().max(50).optional()).optional(), + description: z.array(z.string().max(250).optional()), + unit_amount: z.array(z.number().int().optional()).optional(), + quantity: z.array(z.number().int().optional()).optional(), + amount: z.array(z.number().int().optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + entity_type: z + .array( + z + .enum([ + 'adhoc', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan_setup', + 'plan', + 'addon', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), + item_level_discount1_entity_id: z + .array(z.string().max(100).optional()) + .optional(), + item_level_discount1_amount: z + .array(z.number().int().min(0).optional()) + .optional(), + item_level_discount2_entity_id: z + .array(z.string().max(100).optional()) + .optional(), + item_level_discount2_amount: z + .array(z.number().int().min(0).optional()) + .optional(), + tax1_name: z.array(z.string().max(50).optional()).optional(), + tax1_amount: z.array(z.number().int().min(0).optional()).optional(), + tax2_name: z.array(z.string().max(50).optional()).optional(), + tax2_amount: z.array(z.number().int().min(0).optional()).optional(), + tax3_name: z.array(z.string().max(50).optional()).optional(), + tax3_amount: z.array(z.number().int().min(0).optional()).optional(), + tax4_name: z.array(z.string().max(50).optional()).optional(), + tax4_amount: z.array(z.number().int().min(0).optional()).optional(), + tax5_name: z.array(z.string().max(50).optional()).optional(), + tax5_amount: z.array(z.number().int().min(0).optional()).optional(), + tax6_name: z.array(z.string().max(50).optional()).optional(), + tax6_amount: z.array(z.number().int().min(0).optional()).optional(), + tax7_name: z.array(z.string().max(50).optional()).optional(), + tax7_amount: z.array(z.number().int().min(0).optional()).optional(), + tax8_name: z.array(z.string().max(50).optional()).optional(), + tax8_amount: z.array(z.number().int().min(0).optional()).optional(), + tax9_name: z.array(z.string().max(50).optional()).optional(), + tax9_amount: z.array(z.number().int().min(0).optional()).optional(), + tax10_name: z.array(z.string().max(50).optional()).optional(), + tax10_amount: z.array(z.number().int().min(0).optional()).optional(), +}); +const ImportCreditNoteCreditNoteLineItemTiersSchema = z.object({ + line_item_id: z.array(z.string().max(40).optional()), + starting_unit: z.array(z.number().int().min(0).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + quantity_used: z.array(z.number().int().min(0).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + quantity_used_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(40).optional()).optional(), +}); +const ImportCreditNoteCreditNoteDiscountsSchema = z.object({ + line_item_id: z.array(z.string().max(40).optional()).optional(), + entity_type: z.array( + z + .enum([ + 'item_level_coupon', + 'document_level_coupon', + 'promotional_credits', + 'item_level_discount', + 'document_level_discount', + ]) + .optional(), + ), + entity_id: z.array(z.string().max(100).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()), +}); +const ImportCreditNoteCreditNoteTaxesSchema = z.object({ + name: z.array(z.string().max(100).optional()), + rate: z.array(z.number().min(0).max(100).optional()), + amount: z.array(z.number().int().min(0).optional()).optional(), + description: z.array(z.string().max(50).optional()).optional(), + juris_type: z + .array( + z + .enum([ + 'country', + 'federal', + 'state', + 'county', + 'city', + 'special', + 'unincorporated', + 'other', + ]) + .optional(), + ) + .optional(), + juris_name: z.array(z.string().max(250).optional()).optional(), + juris_code: z.array(z.string().max(250).optional()).optional(), +}); +const ImportCreditNoteCreditNoteAllocationsSchema = z.object({ + invoice_id: z.array(z.string().max(50).optional()), + allocated_amount: z.array(z.number().int().min(1).optional()), + allocated_at: z.array(z.number().int().optional()), +}); +const ImportCreditNoteCreditNoteLinkedRefundsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + amount: z.array(z.number().int().min(1).optional()), + payment_method: z.array( + z + .enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]) + .optional(), + ), + date: z.array(z.number().int().optional()), + reference_number: z.array(z.string().max(100).min(1).optional()).optional(), +}); +const ImportCreditNoteCreditNoteBodySchema = z.looseObject({ + id: z.string().max(50), + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + reference_invoice_id: z.string().max(50), + type: z.enum(['adjustment', 'refundable', 'store']), + currency_code: z.string().max(3).optional(), + create_reason_code: z.string().max(100), + date: z.number().int(), + status: z.enum(['adjusted', 'refunded', 'refund_due', 'voided']).optional(), + total: z.number().int().min(0).optional(), + refunded_at: z.number().int().optional(), + voided_at: z.number().int().optional(), + sub_total: z.number().int().min(0).optional(), + round_off_amount: z.number().int().min(-99).max(99).optional(), + fractional_correction: z.number().int().min(-50000).max(50000).optional(), + vat_number_prefix: z.string().max(10).optional(), + line_items: ImportCreditNoteCreditNoteLineItemsSchema.optional(), + line_item_tiers: ImportCreditNoteCreditNoteLineItemTiersSchema.optional(), + discounts: ImportCreditNoteCreditNoteDiscountsSchema.optional(), + taxes: ImportCreditNoteCreditNoteTaxesSchema.optional(), + allocations: ImportCreditNoteCreditNoteAllocationsSchema.optional(), + linked_refunds: ImportCreditNoteCreditNoteLinkedRefundsSchema.optional(), +}); +export { ImportCreditNoteCreditNoteBodySchema }; +export type ImportCreditNoteCreditNoteBody = z.infer< + typeof ImportCreditNoteCreditNoteBodySchema +>; diff --git a/src/schema/currency.schema.ts b/src/schema/currency.schema.ts new file mode 100644 index 0000000..d1de6ed --- /dev/null +++ b/src/schema/currency.schema.ts @@ -0,0 +1,44 @@ +// Generated Zod schemas: Currency +// Actions: list, create, update, addSchedule +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Currency.list + +const ListCurrencyBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { ListCurrencyBodySchema }; +export type ListCurrencyBody = z.infer; + +//Currency.create + +const CreateCurrencyBodySchema = z.looseObject({ + currency_code: z.string().max(3), + forex_type: z.enum(['manual', 'auto']), + manual_exchange_rate: z.string().max(20).optional(), +}); +export { CreateCurrencyBodySchema }; +export type CreateCurrencyBody = z.infer; + +//Currency.update + +const UpdateCurrencyBodySchema = z.looseObject({ + forex_type: z.enum(['manual', 'auto']), + manual_exchange_rate: z.string().max(20).optional(), +}); +export { UpdateCurrencyBodySchema }; +export type UpdateCurrencyBody = z.infer; + +//Currency.addSchedule + +const AddScheduleCurrencyBodySchema = z.looseObject({ + manual_exchange_rate: z.string().max(20), + schedule_at: z.number().int(), +}); +export { AddScheduleCurrencyBodySchema }; +export type AddScheduleCurrencyBody = z.infer< + typeof AddScheduleCurrencyBodySchema +>; diff --git a/src/schema/customer.schema.ts b/src/schema/customer.schema.ts new file mode 100644 index 0000000..34ddc1a --- /dev/null +++ b/src/schema/customer.schema.ts @@ -0,0 +1,1095 @@ +// Generated Zod schemas: Customer +// Actions: create, update, updatePaymentMethod, updateBillingInfo, contactsForCustomer, assignPaymentRole, addContact, updateContact, deleteContact, addPromotionalCredits, deductPromotionalCredits, setPromotionalCredits, recordExcessPayment, collectPayment, delete, move, changeBillingDate, merge, relationships, hierarchy, listHierarchyDetail, updateHierarchySettings +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Customer.create + +const CreateCustomerMetaDataSchema = z.looseObject({}); +const CreateCustomerAdditionalInformationSchema = z.looseObject({}); +const CreateCustomerCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: CreateCustomerAdditionalInformationSchema.optional(), +}); +const CreateCustomerBillingAddressSchema = z.looseObject({}); +const CreateCustomerBankAccountSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + iban: z.string().max(50).min(10).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + bank_name: z.string().max(100).optional(), + account_number: z.string().max(17).min(4).optional(), + routing_number: z.string().max(9).min(3).optional(), + bank_code: z.string().max(20).optional(), + account_type: z + .enum(['checking', 'savings', 'business_checking', 'current']) + .optional(), + account_holder_type: z.enum(['individual', 'company']).optional(), + echeck_type: z.enum(['web', 'ppd', 'ccd']).optional(), + issuing_country: z.string().max(50).optional(), + swedish_identity_number: z.string().max(12).min(10).optional(), + billing_address: CreateCustomerBillingAddressSchema.optional(), +}); +const CreateCustomerPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: CreateCustomerAdditionalInformationSchema.optional(), +}); +const CreateCustomerPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: CreateCustomerAdditionalInformationSchema.optional(), +}); +const CreateCustomerEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const CreateCustomerTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateCustomerBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + preferred_currency_code: z.string().max(3).optional(), + phone: z.string().max(50).optional(), + company: z.string().max(250).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + net_term_days: z.number().int().optional(), + allow_direct_debit: z.boolean().default(false).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), + registered_for_gst: z.boolean().optional(), + is_einvoice_enabled: z.boolean().optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), + client_profile_id: z.string().max(50).optional(), + taxjar_exemption_category: z + .enum(['wholesale', 'government', 'other']) + .optional(), + business_customer_without_vat_number: z.boolean().optional(), + locale: z.string().max(50).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + meta_data: CreateCustomerMetaDataSchema.optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + auto_close_invoices: z.boolean().optional(), + consolidated_invoicing: z.boolean().optional(), + token_id: z.string().max(40).optional(), + business_entity_id: z.string().max(50).optional(), + created_from_ip: z.string().max(50).optional(), + invoice_notes: z.string().max(2000).optional(), + card: CreateCustomerCardSchema.optional(), + bank_account: CreateCustomerBankAccountSchema.optional(), + payment_method: CreateCustomerPaymentMethodSchema.optional(), + payment_intent: CreateCustomerPaymentIntentSchema.optional(), + billing_address: CreateCustomerBillingAddressSchema.optional(), + entity_identifiers: CreateCustomerEntityIdentifiersSchema.optional(), + tax_providers_fields: CreateCustomerTaxProvidersFieldsSchema.optional(), +}); +export { CreateCustomerBodySchema }; +export type CreateCustomerBody = z.infer; + +//Customer.update + +const UpdateCustomerMetaDataSchema = z.looseObject({}); +const UpdateCustomerTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const UpdateCustomerBodySchema = z.looseObject({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + preferred_currency_code: z.string().max(3).optional(), + phone: z.string().max(50).optional(), + company: z.string().max(250).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + allow_direct_debit: z.boolean().default(false).optional(), + net_term_days: z.number().int().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), + client_profile_id: z.string().max(50).optional(), + taxjar_exemption_category: z + .enum(['wholesale', 'government', 'other']) + .optional(), + locale: z.string().max(50).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + invoice_notes: z.string().max(2000).optional(), + auto_close_invoices: z.boolean().optional(), + meta_data: UpdateCustomerMetaDataSchema.optional(), + fraud_flag: z.enum(['safe', 'fraudulent']).optional(), + consolidated_invoicing: z.boolean().optional(), + tax_providers_fields: UpdateCustomerTaxProvidersFieldsSchema.optional(), +}); +export { UpdateCustomerBodySchema }; +export type UpdateCustomerBody = z.infer; + +//Customer.updatePaymentMethod + +const UpdatePaymentMethodCustomerAdditionalInformationSchema = z.looseObject( + {}, +); +const UpdatePaymentMethodCustomerPaymentMethodSchema = z.object({ + type: z.enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + UpdatePaymentMethodCustomerAdditionalInformationSchema.optional(), +}); +const UpdatePaymentMethodCustomerBodySchema = z.looseObject({ + payment_method: UpdatePaymentMethodCustomerPaymentMethodSchema.optional(), +}); +export { UpdatePaymentMethodCustomerBodySchema }; +export type UpdatePaymentMethodCustomerBody = z.infer< + typeof UpdatePaymentMethodCustomerBodySchema +>; + +//Customer.updateBillingInfo + +const UpdateBillingInfoCustomerBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateBillingInfoCustomerEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + operation: z + .array(z.enum(['create', 'update', 'delete']).optional()) + .optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const UpdateBillingInfoCustomerTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const UpdateBillingInfoCustomerBodySchema = z.looseObject({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), + registered_for_gst: z.boolean().optional(), + business_customer_without_vat_number: z.boolean().optional(), + is_einvoice_enabled: z.boolean().optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + billing_address: UpdateBillingInfoCustomerBillingAddressSchema.optional(), + entity_identifiers: + UpdateBillingInfoCustomerEntityIdentifiersSchema.optional(), + tax_providers_fields: + UpdateBillingInfoCustomerTaxProvidersFieldsSchema.optional(), +}); +export { UpdateBillingInfoCustomerBodySchema }; +export type UpdateBillingInfoCustomerBody = z.infer< + typeof UpdateBillingInfoCustomerBodySchema +>; + +//Customer.contactsForCustomer + +const ContactsForCustomerCustomerBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { ContactsForCustomerCustomerBodySchema }; +export type ContactsForCustomerCustomerBody = z.infer< + typeof ContactsForCustomerCustomerBodySchema +>; + +//Customer.assignPaymentRole + +const AssignPaymentRoleCustomerBodySchema = z.looseObject({ + payment_source_id: z.string().max(40), + role: z.enum(['primary', 'backup', 'none']), +}); +export { AssignPaymentRoleCustomerBodySchema }; +export type AssignPaymentRoleCustomerBody = z.infer< + typeof AssignPaymentRoleCustomerBodySchema +>; + +//Customer.addContact + +const AddContactCustomerContactSchema = z.object({ + id: z.string().max(150).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70), + phone: z.string().max(50).optional(), + label: z.string().max(50).optional(), + enabled: z.boolean().default(false).optional(), + send_billing_email: z.boolean().default(false).optional(), + send_account_email: z.boolean().default(false).optional(), +}); +const AddContactCustomerBodySchema = z.looseObject({ + contact: AddContactCustomerContactSchema.optional(), +}); +export { AddContactCustomerBodySchema }; +export type AddContactCustomerBody = z.infer< + typeof AddContactCustomerBodySchema +>; + +//Customer.updateContact + +const UpdateContactCustomerContactSchema = z.object({ + id: z.string().max(150), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + label: z.string().max(50).optional(), + enabled: z.boolean().default(false).optional(), + send_billing_email: z.boolean().default(false).optional(), + send_account_email: z.boolean().default(false).optional(), +}); +const UpdateContactCustomerBodySchema = z.looseObject({ + contact: UpdateContactCustomerContactSchema.optional(), +}); +export { UpdateContactCustomerBodySchema }; +export type UpdateContactCustomerBody = z.infer< + typeof UpdateContactCustomerBodySchema +>; + +//Customer.deleteContact + +const DeleteContactCustomerContactSchema = z.object({ + id: z.string().max(150), +}); +const DeleteContactCustomerBodySchema = z.looseObject({ + contact: DeleteContactCustomerContactSchema.optional(), +}); +export { DeleteContactCustomerBodySchema }; +export type DeleteContactCustomerBody = z.infer< + typeof DeleteContactCustomerBodySchema +>; + +//Customer.addPromotionalCredits + +const AddPromotionalCreditsCustomerBodySchema = z.looseObject({ + amount: z.number().int().min(1), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { AddPromotionalCreditsCustomerBodySchema }; +export type AddPromotionalCreditsCustomerBody = z.infer< + typeof AddPromotionalCreditsCustomerBodySchema +>; + +//Customer.deductPromotionalCredits + +const DeductPromotionalCreditsCustomerBodySchema = z.looseObject({ + amount: z.number().int().min(1), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { DeductPromotionalCreditsCustomerBodySchema }; +export type DeductPromotionalCreditsCustomerBody = z.infer< + typeof DeductPromotionalCreditsCustomerBodySchema +>; + +//Customer.setPromotionalCredits + +const SetPromotionalCreditsCustomerBodySchema = z.looseObject({ + amount: z.number().int().min(0), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { SetPromotionalCreditsCustomerBodySchema }; +export type SetPromotionalCreditsCustomerBody = z.infer< + typeof SetPromotionalCreditsCustomerBodySchema +>; + +//Customer.recordExcessPayment + +const RecordExcessPaymentCustomerTransactionSchema = z.object({ + id: z.string().max(40).optional(), + amount: z.number().int().min(0), + currency_code: z.string().max(3).optional(), + date: z.number().int(), + payment_method: z.enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]), + reference_number: z.string().max(100).optional(), + custom_payment_method_id: z.string().max(50).optional(), +}); +const RecordExcessPaymentCustomerBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + transaction: RecordExcessPaymentCustomerTransactionSchema.optional(), +}); +export { RecordExcessPaymentCustomerBodySchema }; +export type RecordExcessPaymentCustomerBody = z.infer< + typeof RecordExcessPaymentCustomerBodySchema +>; + +//Customer.collectPayment + +const CollectPaymentCustomerAdditionalInformationSchema = z.looseObject({}); +const CollectPaymentCustomerPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + additional_information: + CollectPaymentCustomerAdditionalInformationSchema.optional(), +}); +const CollectPaymentCustomerCardSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + additional_information: + CollectPaymentCustomerAdditionalInformationSchema.optional(), +}); +const CollectPaymentCustomerPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gw_payment_method_id: z.string().max(65000).optional(), + reference_id: z.string().max(65000).optional(), + additional_information: + CollectPaymentCustomerAdditionalInformationSchema.optional(), +}); +const CollectPaymentCustomerInvoiceAllocationsSchema = z.object({ + invoice_id: z.array(z.string().max(50).optional()), + allocation_amount: z.array(z.number().int().min(0).optional()).optional(), +}); +const CollectPaymentCustomerBodySchema = z.looseObject({ + amount: z.number().int().min(0).optional(), + payment_source_id: z.string().max(40).optional(), + token_id: z.string().max(40).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + retain_payment_source: z.boolean().default(false).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + payment_method: CollectPaymentCustomerPaymentMethodSchema.optional(), + card: CollectPaymentCustomerCardSchema.optional(), + payment_intent: CollectPaymentCustomerPaymentIntentSchema.optional(), + invoice_allocations: + CollectPaymentCustomerInvoiceAllocationsSchema.optional(), +}); +export { CollectPaymentCustomerBodySchema }; +export type CollectPaymentCustomerBody = z.infer< + typeof CollectPaymentCustomerBodySchema +>; + +//Customer.delete + +const DeleteCustomerBodySchema = z.looseObject({ + delete_payment_method: z.boolean().default(true).optional(), +}); +export { DeleteCustomerBodySchema }; +export type DeleteCustomerBody = z.infer; + +//Customer.move + +const MoveCustomerBodySchema = z.looseObject({ + id_at_from_site: z.string().max(100), + from_site: z.string().max(50), +}); +export { MoveCustomerBodySchema }; +export type MoveCustomerBody = z.infer; + +//Customer.changeBillingDate + +const ChangeBillingDateCustomerBodySchema = z.looseObject({ + billing_date: z.number().int().min(1).max(31).optional(), + billing_month: z.number().int().min(1).max(12).optional(), + billing_date_mode: z.enum(['using_defaults', 'manually_set']).optional(), + billing_day_of_week: z + .enum([ + 'sunday', + 'monday', + 'tuesday', + 'wednesday', + 'thursday', + 'friday', + 'saturday', + ]) + .optional(), + billing_day_of_week_mode: z + .enum(['using_defaults', 'manually_set']) + .optional(), +}); +export { ChangeBillingDateCustomerBodySchema }; +export type ChangeBillingDateCustomerBody = z.infer< + typeof ChangeBillingDateCustomerBodySchema +>; + +//Customer.merge + +const MergeCustomerBodySchema = z.looseObject({ + from_customer_id: z.string().max(50), + to_customer_id: z.string().max(50), +}); +export { MergeCustomerBodySchema }; +export type MergeCustomerBody = z.infer; + +//Customer.relationships + +const RelationshipsCustomerParentAccountAccessSchema = z.object({ + portal_edit_child_subscriptions: z + .enum(['yes', 'view_only', 'no']) + .optional(), + portal_download_child_invoices: z.enum(['yes', 'view_only', 'no']).optional(), + send_subscription_emails: z.boolean().optional(), + send_payment_emails: z.boolean().optional(), + send_invoice_emails: z.boolean().optional(), +}); +const RelationshipsCustomerChildAccountAccessSchema = z.object({ + portal_edit_subscriptions: z.enum(['yes', 'view_only']).optional(), + portal_download_invoices: z.enum(['yes', 'view_only', 'no']).optional(), + send_subscription_emails: z.boolean().optional(), + send_payment_emails: z.boolean().optional(), + send_invoice_emails: z.boolean().optional(), +}); +const RelationshipsCustomerBodySchema = z.looseObject({ + parent_id: z.string().max(50).optional(), + payment_owner_id: z.string().max(50).optional(), + invoice_owner_id: z.string().max(50).optional(), + use_default_hierarchy_settings: z.boolean().default(true).optional(), + parent_account_access: + RelationshipsCustomerParentAccountAccessSchema.optional(), + child_account_access: + RelationshipsCustomerChildAccountAccessSchema.optional(), +}); +export { RelationshipsCustomerBodySchema }; +export type RelationshipsCustomerBody = z.infer< + typeof RelationshipsCustomerBodySchema +>; + +//Customer.hierarchy + +const HierarchyCustomerBodySchema = z.looseObject({ + hierarchy_operation_type: z.enum([ + 'complete_hierarchy', + 'subordinates', + 'path_to_root', + 'subordinates_with_unbilled_charges_payable_by_parent', + 'immediate_children', + ]), +}); +export { HierarchyCustomerBodySchema }; +export type HierarchyCustomerBody = z.infer; + +//Customer.listHierarchyDetail + +const ListHierarchyDetailCustomerBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + hierarchy_operation_type: z.enum([ + 'complete_hierarchy', + 'subordinates', + 'path_to_root', + 'subordinates_with_unbilled_charges_payable_by_parent', + 'immediate_children', + ]), +}); +export { ListHierarchyDetailCustomerBodySchema }; +export type ListHierarchyDetailCustomerBody = z.infer< + typeof ListHierarchyDetailCustomerBodySchema +>; + +//Customer.updateHierarchySettings + +const UpdateHierarchySettingsCustomerParentAccountAccessSchema = z.object({ + portal_edit_child_subscriptions: z + .enum(['yes', 'view_only', 'no']) + .optional(), + portal_download_child_invoices: z.enum(['yes', 'view_only', 'no']).optional(), + send_subscription_emails: z.boolean().optional(), + send_payment_emails: z.boolean().optional(), + send_invoice_emails: z.boolean().optional(), +}); +const UpdateHierarchySettingsCustomerChildAccountAccessSchema = z.object({ + portal_edit_subscriptions: z.enum(['yes', 'view_only']).optional(), + portal_download_invoices: z.enum(['yes', 'view_only', 'no']).optional(), + send_subscription_emails: z.boolean().optional(), + send_payment_emails: z.boolean().optional(), + send_invoice_emails: z.boolean().optional(), +}); +const UpdateHierarchySettingsCustomerBodySchema = z.looseObject({ + use_default_hierarchy_settings: z.boolean().default(true).optional(), + parent_account_access: + UpdateHierarchySettingsCustomerParentAccountAccessSchema.optional(), + child_account_access: + UpdateHierarchySettingsCustomerChildAccountAccessSchema.optional(), +}); +export { UpdateHierarchySettingsCustomerBodySchema }; +export type UpdateHierarchySettingsCustomerBody = z.infer< + typeof UpdateHierarchySettingsCustomerBodySchema +>; diff --git a/src/schema/customer_entitlement.schema.ts b/src/schema/customer_entitlement.schema.ts new file mode 100644 index 0000000..cb9e4c9 --- /dev/null +++ b/src/schema/customer_entitlement.schema.ts @@ -0,0 +1,17 @@ +// Generated Zod schemas: CustomerEntitlement +// Actions: entitlementsForCustomer +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//CustomerEntitlement.entitlementsForCustomer + +const EntitlementsForCustomerCustomerEntitlementBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + consolidate_entitlements: z.boolean().default(false).optional(), +}); +export { EntitlementsForCustomerCustomerEntitlementBodySchema }; +export type EntitlementsForCustomerCustomerEntitlementBody = z.infer< + typeof EntitlementsForCustomerCustomerEntitlementBodySchema +>; diff --git a/src/schema/differential_price.schema.ts b/src/schema/differential_price.schema.ts new file mode 100644 index 0000000..2a656d8 --- /dev/null +++ b/src/schema/differential_price.schema.ts @@ -0,0 +1,86 @@ +// Generated Zod schemas: DifferentialPrice +// Actions: create, retrieve, update, delete +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//DifferentialPrice.create + +const CreateDifferentialPriceParentPeriodsSchema = z.object({ + period_unit: z.array(z.enum(['day', 'week', 'month', 'year']).optional()), + period: z.array(z.array(z.string().optional()).optional()).optional(), +}); +const CreateDifferentialPriceTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateDifferentialPriceBodySchema = z.looseObject({ + parent_item_id: z.string().max(100), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + business_entity_id: z.string().max(50).optional(), + parent_periods: CreateDifferentialPriceParentPeriodsSchema.optional(), + tiers: CreateDifferentialPriceTiersSchema.optional(), +}); +export { CreateDifferentialPriceBodySchema }; +export type CreateDifferentialPriceBody = z.infer< + typeof CreateDifferentialPriceBodySchema +>; + +//DifferentialPrice.retrieve + +const RetrieveDifferentialPriceBodySchema = z.looseObject({ + item_price_id: z.string().max(100), +}); +export { RetrieveDifferentialPriceBodySchema }; +export type RetrieveDifferentialPriceBody = z.infer< + typeof RetrieveDifferentialPriceBodySchema +>; + +//DifferentialPrice.update + +const UpdateDifferentialPriceParentPeriodsSchema = z.object({ + period_unit: z.array(z.enum(['day', 'week', 'month', 'year']).optional()), + period: z.array(z.array(z.string().optional()).optional()).optional(), +}); +const UpdateDifferentialPriceTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const UpdateDifferentialPriceBodySchema = z.looseObject({ + item_price_id: z.string().max(100), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + parent_periods: UpdateDifferentialPriceParentPeriodsSchema.optional(), + tiers: UpdateDifferentialPriceTiersSchema.optional(), +}); +export { UpdateDifferentialPriceBodySchema }; +export type UpdateDifferentialPriceBody = z.infer< + typeof UpdateDifferentialPriceBodySchema +>; + +//DifferentialPrice.delete + +const DeleteDifferentialPriceBodySchema = z.looseObject({ + item_price_id: z.string().max(100), +}); +export { DeleteDifferentialPriceBodySchema }; +export type DeleteDifferentialPriceBody = z.infer< + typeof DeleteDifferentialPriceBodySchema +>; diff --git a/src/schema/entitlement.schema.ts b/src/schema/entitlement.schema.ts new file mode 100644 index 0000000..36da7cb --- /dev/null +++ b/src/schema/entitlement.schema.ts @@ -0,0 +1,30 @@ +// Generated Zod schemas: Entitlement +// Actions: create +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Entitlement.create + +const CreateEntitlementEntitlementsSchema = z.object({ + entity_id: z.array(z.string().max(100).optional()), + feature_id: z.array(z.string().max(50).optional()), + entity_type: z + .array( + z + .enum(['plan', 'addon', 'charge', 'plan_price', 'addon_price']) + .optional(), + ) + .optional(), + value: z.array(z.string().max(50).optional()).optional(), + apply_grandfathering: z + .array(z.boolean().default(false).optional()) + .optional(), +}); +const CreateEntitlementBodySchema = z.looseObject({ + action: z.enum(['upsert', 'remove']), + change_reason: z.string().max(100).optional(), + entitlements: CreateEntitlementEntitlementsSchema.optional(), +}); +export { CreateEntitlementBodySchema }; +export type CreateEntitlementBody = z.infer; diff --git a/src/schema/entitlement_override.schema.ts b/src/schema/entitlement_override.schema.ts new file mode 100644 index 0000000..47a8c8b --- /dev/null +++ b/src/schema/entitlement_override.schema.ts @@ -0,0 +1,47 @@ +// Generated Zod schemas: EntitlementOverride +// Actions: addEntitlementOverrideForSubscription, listEntitlementOverrideForSubscription +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//EntitlementOverride.addEntitlementOverrideForSubscription + +const AddEntitlementOverrideForSubscriptionEntitlementOverrideEntitlementOverridesSchema = + z.object({ + feature_id: z.array(z.string().max(50).optional()), + entity_id: z.array(z.string().max(50).optional()).optional(), + entity_type: z + .array(z.enum(['plan_price', 'addon_price', 'charge']).optional()) + .optional(), + value: z.array(z.string().max(50).optional()).optional(), + expires_at: z.array(z.number().int().optional()).optional(), + effective_from: z.array(z.number().int().optional()).optional(), + is_enabled: z.array(z.boolean().optional()).optional(), + }); +const AddEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema = + z.looseObject({ + action: z.enum(['upsert', 'remove']).optional(), + entitlement_overrides: + AddEntitlementOverrideForSubscriptionEntitlementOverrideEntitlementOverridesSchema.optional(), + }); +export { AddEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema }; +export type AddEntitlementOverrideForSubscriptionEntitlementOverrideBody = + z.infer< + typeof AddEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema + >; + +//EntitlementOverride.listEntitlementOverrideForSubscription + +const ListEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema = + z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + embed: z.string().max(1000).optional(), + include_drafts: z.boolean().default(false).optional(), + include_scheduled_overrides: z.boolean().default(false).optional(), + }); +export { ListEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema }; +export type ListEntitlementOverrideForSubscriptionEntitlementOverrideBody = + z.infer< + typeof ListEntitlementOverrideForSubscriptionEntitlementOverrideBodySchema + >; diff --git a/src/schema/estimate.schema.ts b/src/schema/estimate.schema.ts new file mode 100644 index 0000000..88533ae --- /dev/null +++ b/src/schema/estimate.schema.ts @@ -0,0 +1,1682 @@ +// Generated Zod schemas: Estimate +// Actions: createSubscription, createSubItemEstimate, createSubForCustomerEstimate, createSubItemForCustomerEstimate, updateSubscription, updateSubscriptionForItems, renewalEstimate, advanceInvoiceEstimate, regenerateInvoiceEstimate, upcomingInvoicesEstimate, changeTermEnd, cancelSubscription, cancelSubscriptionForItems, pauseSubscription, resumeSubscription, giftSubscription, giftSubscriptionForItems, createInvoice, createInvoiceForItems, paymentSchedules +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Estimate.createSubscription + +const CreateSubscriptionEstimateSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const CreateSubscriptionEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubscriptionEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubscriptionEstimateCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), +}); +const CreateSubscriptionEstimateContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubscriptionEstimateAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const CreateSubscriptionEstimateEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CreateSubscriptionEstimateTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateSubscriptionEstimateBodySchema = z.looseObject({ + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + invoice_immediately: z.boolean().optional(), + invoice_date: z.number().int().optional(), + client_profile_id: z.string().max(50).optional(), + subscription: CreateSubscriptionEstimateSubscriptionSchema.optional(), + billing_address: CreateSubscriptionEstimateBillingAddressSchema.optional(), + shipping_address: CreateSubscriptionEstimateShippingAddressSchema.optional(), + customer: CreateSubscriptionEstimateCustomerSchema.optional(), + contract_term: CreateSubscriptionEstimateContractTermSchema.optional(), + addons: CreateSubscriptionEstimateAddonsSchema.optional(), + event_based_addons: + CreateSubscriptionEstimateEventBasedAddonsSchema.optional(), + tax_providers_fields: + CreateSubscriptionEstimateTaxProvidersFieldsSchema.optional(), +}); +export { CreateSubscriptionEstimateBodySchema }; +export type CreateSubscriptionEstimateBody = z.infer< + typeof CreateSubscriptionEstimateBodySchema +>; + +//Estimate.createSubItemEstimate + +const CreateSubItemEstimateEstimateSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + trial_end: z.number().int().optional(), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const CreateSubItemEstimateEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemEstimateEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemEstimateEstimateCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), +}); +const CreateSubItemEstimateEstimateContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + contract_start: z.number().int().optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubItemEstimateEstimateSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const CreateSubItemEstimateEstimateDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateSubItemEstimateEstimateItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateSubItemEstimateEstimateTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateSubItemEstimateEstimateBodySchema = z.looseObject({ + billing_cycles: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + invoice_immediately: z.boolean().optional(), + invoice_date: z.number().int().optional(), + client_profile_id: z.string().max(50).optional(), + subscription: CreateSubItemEstimateEstimateSubscriptionSchema.optional(), + billing_address: CreateSubItemEstimateEstimateBillingAddressSchema.optional(), + shipping_address: + CreateSubItemEstimateEstimateShippingAddressSchema.optional(), + customer: CreateSubItemEstimateEstimateCustomerSchema.optional(), + contract_term: CreateSubItemEstimateEstimateContractTermSchema.optional(), + subscription_items: + CreateSubItemEstimateEstimateSubscriptionItemsSchema.optional(), + discounts: CreateSubItemEstimateEstimateDiscountsSchema.optional(), + item_tiers: CreateSubItemEstimateEstimateItemTiersSchema.optional(), + tax_providers_fields: + CreateSubItemEstimateEstimateTaxProvidersFieldsSchema.optional(), +}); +export { CreateSubItemEstimateEstimateBodySchema }; +export type CreateSubItemEstimateEstimateBody = z.infer< + typeof CreateSubItemEstimateEstimateBodySchema +>; + +//Estimate.createSubForCustomerEstimate + +const CreateSubForCustomerEstimateEstimateSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const CreateSubForCustomerEstimateEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubForCustomerEstimateEstimateContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubForCustomerEstimateEstimateAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const CreateSubForCustomerEstimateEstimateEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CreateSubForCustomerEstimateEstimateBodySchema = z.looseObject({ + use_existing_balances: z.boolean().default(true).optional(), + invoice_immediately: z.boolean().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + invoice_date: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + subscription: + CreateSubForCustomerEstimateEstimateSubscriptionSchema.optional(), + shipping_address: + CreateSubForCustomerEstimateEstimateShippingAddressSchema.optional(), + contract_term: + CreateSubForCustomerEstimateEstimateContractTermSchema.optional(), + addons: CreateSubForCustomerEstimateEstimateAddonsSchema.optional(), + event_based_addons: + CreateSubForCustomerEstimateEstimateEventBasedAddonsSchema.optional(), +}); +export { CreateSubForCustomerEstimateEstimateBodySchema }; +export type CreateSubForCustomerEstimateEstimateBody = z.infer< + typeof CreateSubForCustomerEstimateEstimateBodySchema +>; + +//Estimate.createSubItemForCustomerEstimate + +const CreateSubItemForCustomerEstimateEstimateSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + trial_end: z.number().int().optional(), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const CreateSubItemForCustomerEstimateEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemForCustomerEstimateEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemForCustomerEstimateEstimateContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + contract_start: z.number().int().optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubItemForCustomerEstimateEstimateBillingOverrideSchema = z.object({ + max_excess_payment_usage: z.number().int().min(-1).optional(), + max_refundable_credits_usage: z.number().int().min(-1).optional(), +}); +const CreateSubItemForCustomerEstimateEstimateSubscriptionItemsSchema = + z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z + .array(z.enum(['plan', 'addon', 'charge']).optional()) + .optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + }); +const CreateSubItemForCustomerEstimateEstimateDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateSubItemForCustomerEstimateEstimateItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateSubItemForCustomerEstimateEstimateBodySchema = z.looseObject({ + use_existing_balances: z.boolean().default(true).optional(), + invoice_immediately: z.boolean().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + invoice_date: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + subscription: + CreateSubItemForCustomerEstimateEstimateSubscriptionSchema.optional(), + shipping_address: + CreateSubItemForCustomerEstimateEstimateShippingAddressSchema.optional(), + billing_address: + CreateSubItemForCustomerEstimateEstimateBillingAddressSchema.optional(), + contract_term: + CreateSubItemForCustomerEstimateEstimateContractTermSchema.optional(), + billing_override: + CreateSubItemForCustomerEstimateEstimateBillingOverrideSchema.optional(), + subscription_items: + CreateSubItemForCustomerEstimateEstimateSubscriptionItemsSchema.optional(), + discounts: CreateSubItemForCustomerEstimateEstimateDiscountsSchema.optional(), + item_tiers: + CreateSubItemForCustomerEstimateEstimateItemTiersSchema.optional(), +}); +export { CreateSubItemForCustomerEstimateEstimateBodySchema }; +export type CreateSubItemForCustomerEstimateEstimateBody = z.infer< + typeof CreateSubItemForCustomerEstimateEstimateBodySchema +>; + +//Estimate.updateSubscription + +const UpdateSubscriptionEstimateSubscriptionSchema = z.object({ + id: z.string().max(50), + plan_id: z.string().max(100).optional(), + plan_quantity: z.number().int().min(1).optional(), + plan_unit_price: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const UpdateSubscriptionEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionEstimateCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), +}); +const UpdateSubscriptionEstimateAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + proration_type: z + .array(z.enum(['full_term', 'partial_term', 'none']).optional()) + .optional(), +}); +const UpdateSubscriptionEstimateEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const UpdateSubscriptionEstimateBodySchema = z.looseObject({ + changes_scheduled_at: z.number().int().optional(), + change_option: z + .enum(['immediately', 'end_of_term', 'specific_date']) + .optional(), + replace_addon_list: z.boolean().default(false).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + invoice_date: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + prorate: z.boolean().optional(), + end_of_term: z.boolean().default(false).optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + include_delayed_charges: z.boolean().default(false).optional(), + use_existing_balances: z.boolean().default(true).optional(), + invoice_immediately: z.boolean().optional(), + subscription: UpdateSubscriptionEstimateSubscriptionSchema.optional(), + billing_address: UpdateSubscriptionEstimateBillingAddressSchema.optional(), + shipping_address: UpdateSubscriptionEstimateShippingAddressSchema.optional(), + customer: UpdateSubscriptionEstimateCustomerSchema.optional(), + addons: UpdateSubscriptionEstimateAddonsSchema.optional(), + event_based_addons: + UpdateSubscriptionEstimateEventBasedAddonsSchema.optional(), +}); +export { UpdateSubscriptionEstimateBodySchema }; +export type UpdateSubscriptionEstimateBody = z.infer< + typeof UpdateSubscriptionEstimateBodySchema +>; + +//Estimate.updateSubscriptionForItems + +const UpdateSubscriptionForItemsEstimateSubscriptionSchema = z.object({ + id: z.string().max(50), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), +}); +const UpdateSubscriptionForItemsEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionForItemsEstimateShippingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionForItemsEstimateCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), +}); +const UpdateSubscriptionForItemsEstimateBillingOverrideSchema = z.object({ + max_excess_payment_usage: z.number().int().min(-1).optional(), + max_refundable_credits_usage: z.number().int().min(-1).optional(), +}); +const UpdateSubscriptionForItemsEstimateSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + proration_type: z + .array(z.enum(['full_term', 'partial_term', 'none']).optional()) + .optional(), +}); +const UpdateSubscriptionForItemsEstimateDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + operation_type: z.array(z.enum(['add', 'remove']).optional()), + id: z.array(z.string().max(50).optional()).optional(), +}); +const UpdateSubscriptionForItemsEstimateItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const UpdateSubscriptionForItemsEstimateBodySchema = z.looseObject({ + changes_scheduled_at: z.number().int().optional(), + change_option: z + .enum(['immediately', 'end_of_term', 'specific_date']) + .optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + replace_items_list: z.boolean().default(false).optional(), + invoice_date: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + prorate: z.boolean().optional(), + end_of_term: z.boolean().default(false).optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + include_delayed_charges: z.boolean().default(false).optional(), + use_existing_balances: z.boolean().default(true).optional(), + invoice_immediately: z.boolean().optional(), + invoice_usages: z.boolean().default(false).optional(), + subscription: UpdateSubscriptionForItemsEstimateSubscriptionSchema.optional(), + billing_address: + UpdateSubscriptionForItemsEstimateBillingAddressSchema.optional(), + shipping_address: + UpdateSubscriptionForItemsEstimateShippingAddressSchema.optional(), + customer: UpdateSubscriptionForItemsEstimateCustomerSchema.optional(), + billing_override: + UpdateSubscriptionForItemsEstimateBillingOverrideSchema.optional(), + subscription_items: + UpdateSubscriptionForItemsEstimateSubscriptionItemsSchema.optional(), + discounts: UpdateSubscriptionForItemsEstimateDiscountsSchema.optional(), + item_tiers: UpdateSubscriptionForItemsEstimateItemTiersSchema.optional(), +}); +export { UpdateSubscriptionForItemsEstimateBodySchema }; +export type UpdateSubscriptionForItemsEstimateBody = z.infer< + typeof UpdateSubscriptionForItemsEstimateBodySchema +>; + +//Estimate.renewalEstimate + +const RenewalEstimateEstimateBodySchema = z.looseObject({ + include_delayed_charges: z.boolean().default(true).optional(), + use_existing_balances: z.boolean().default(true).optional(), + ignore_scheduled_cancellation: z.boolean().default(false).optional(), + ignore_scheduled_changes: z.boolean().default(false).optional(), + exclude_tax_type: z.enum(['exclusive', 'none']).optional(), +}); +export { RenewalEstimateEstimateBodySchema }; +export type RenewalEstimateEstimateBody = z.infer< + typeof RenewalEstimateEstimateBodySchema +>; + +//Estimate.advanceInvoiceEstimate + +const AdvanceInvoiceEstimateEstimateFixedIntervalScheduleSchema = z.object({ + number_of_occurrences: z.number().int().min(1).optional(), + days_before_renewal: z.number().int().min(1).optional(), + end_schedule_on: z + .enum(['after_number_of_intervals', 'specific_date', 'subscription_end']) + .optional(), + end_date: z.number().int().optional(), +}); +const AdvanceInvoiceEstimateEstimateSpecificDatesScheduleSchema = z.object({ + terms_to_charge: z.array(z.number().int().optional()).optional(), + date: z.array(z.number().int().optional()).optional(), +}); +const AdvanceInvoiceEstimateEstimateBodySchema = z.looseObject({ + terms_to_charge: z.number().int().min(1).optional(), + invoice_immediately: z.boolean().optional(), + schedule_type: z + .enum(['immediate', 'specific_dates', 'fixed_intervals']) + .optional(), + fixed_interval_schedule: + AdvanceInvoiceEstimateEstimateFixedIntervalScheduleSchema.optional(), + specific_dates_schedule: + AdvanceInvoiceEstimateEstimateSpecificDatesScheduleSchema.optional(), +}); +export { AdvanceInvoiceEstimateEstimateBodySchema }; +export type AdvanceInvoiceEstimateEstimateBody = z.infer< + typeof AdvanceInvoiceEstimateEstimateBodySchema +>; + +//Estimate.regenerateInvoiceEstimate + +const RegenerateInvoiceEstimateEstimateBodySchema = z.looseObject({ + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), + prorate: z.boolean().optional(), + invoice_immediately: z.boolean().optional(), +}); +export { RegenerateInvoiceEstimateEstimateBodySchema }; +export type RegenerateInvoiceEstimateEstimateBody = z.infer< + typeof RegenerateInvoiceEstimateEstimateBodySchema +>; + +//Estimate.upcomingInvoicesEstimate + +const UpcomingInvoicesEstimateEstimateBodySchema = z.looseObject({ + include_usage_charges: z.boolean().default(false).optional(), +}); +export { UpcomingInvoicesEstimateEstimateBodySchema }; +export type UpcomingInvoicesEstimateEstimateBody = z.infer< + typeof UpcomingInvoicesEstimateEstimateBodySchema +>; + +//Estimate.changeTermEnd + +const ChangeTermEndEstimateBodySchema = z.looseObject({ + term_ends_at: z.number().int(), + prorate: z.boolean().optional(), + invoice_immediately: z.boolean().optional(), +}); +export { ChangeTermEndEstimateBodySchema }; +export type ChangeTermEndEstimateBody = z.infer< + typeof ChangeTermEndEstimateBodySchema +>; + +//Estimate.cancelSubscription + +const CancelSubscriptionEstimateEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), +}); +const CancelSubscriptionEstimateBodySchema = z.looseObject({ + cancel_option: z + .enum([ + 'immediately', + 'end_of_term', + 'specific_date', + 'end_of_billing_term', + ]) + .optional(), + end_of_term: z.boolean().default(false).optional(), + cancel_at: z.number().int().optional(), + credit_option_for_current_term_charges: z + .enum(['none', 'prorate', 'full']) + .optional(), + unbilled_charges_option: z.enum(['invoice', 'delete']).optional(), + account_receivables_handling: z + .enum(['no_action', 'schedule_payment_collection', 'write_off']) + .optional(), + refundable_credits_handling: z + .enum(['no_action', 'schedule_refund']) + .optional(), + contract_term_cancel_option: z + .enum([ + 'terminate_immediately', + 'end_of_contract_term', + 'specific_date', + 'end_of_subscription_billing_term', + ]) + .optional(), + invoice_date: z.number().int().optional(), + cancel_reason_code: z.string().max(100).optional(), + event_based_addons: + CancelSubscriptionEstimateEventBasedAddonsSchema.optional(), +}); +export { CancelSubscriptionEstimateBodySchema }; +export type CancelSubscriptionEstimateBody = z.infer< + typeof CancelSubscriptionEstimateBodySchema +>; + +//Estimate.cancelSubscriptionForItems + +const CancelSubscriptionForItemsEstimateSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), +}); +const CancelSubscriptionForItemsEstimateBodySchema = z.looseObject({ + cancel_option: z + .enum([ + 'immediately', + 'end_of_term', + 'specific_date', + 'end_of_billing_term', + ]) + .optional(), + end_of_term: z.boolean().default(false).optional(), + cancel_at: z.number().int().optional(), + credit_option_for_current_term_charges: z + .enum(['none', 'prorate', 'full']) + .optional(), + unbilled_charges_option: z.enum(['invoice', 'delete']).optional(), + account_receivables_handling: z + .enum(['no_action', 'schedule_payment_collection', 'write_off']) + .optional(), + refundable_credits_handling: z + .enum(['no_action', 'schedule_refund']) + .optional(), + contract_term_cancel_option: z + .enum([ + 'terminate_immediately', + 'end_of_contract_term', + 'specific_date', + 'end_of_subscription_billing_term', + ]) + .optional(), + invoice_date: z.number().int().optional(), + cancel_reason_code: z.string().max(100).optional(), + subscription_items: + CancelSubscriptionForItemsEstimateSubscriptionItemsSchema.optional(), +}); +export { CancelSubscriptionForItemsEstimateBodySchema }; +export type CancelSubscriptionForItemsEstimateBody = z.infer< + typeof CancelSubscriptionForItemsEstimateBodySchema +>; + +//Estimate.pauseSubscription + +const PauseSubscriptionEstimateSubscriptionSchema = z.object({ + pause_date: z.number().int().optional(), + resume_date: z.number().int().optional(), + skip_billing_cycles: z.number().int().min(1).optional(), +}); +const PauseSubscriptionEstimateBodySchema = z.looseObject({ + pause_option: z + .enum(['immediately', 'end_of_term', 'specific_date', 'billing_cycles']) + .optional(), + unbilled_charges_handling: z.enum(['no_action', 'invoice']).optional(), + subscription: PauseSubscriptionEstimateSubscriptionSchema.optional(), +}); +export { PauseSubscriptionEstimateBodySchema }; +export type PauseSubscriptionEstimateBody = z.infer< + typeof PauseSubscriptionEstimateBodySchema +>; + +//Estimate.resumeSubscription + +const ResumeSubscriptionEstimateSubscriptionSchema = z.object({ + resume_date: z.number().int().optional(), +}); +const ResumeSubscriptionEstimateBodySchema = z.looseObject({ + resume_option: z.enum(['immediately', 'specific_date']).optional(), + charges_handling: z + .enum(['invoice_immediately', 'add_to_unbilled_charges']) + .optional(), + subscription: ResumeSubscriptionEstimateSubscriptionSchema.optional(), +}); +export { ResumeSubscriptionEstimateBodySchema }; +export type ResumeSubscriptionEstimateBody = z.infer< + typeof ResumeSubscriptionEstimateBodySchema +>; + +//Estimate.giftSubscription + +const GiftSubscriptionEstimateGiftSchema = z.object({ + scheduled_at: z.number().int().optional(), + auto_claim: z.boolean().default(false).optional(), + no_expiry: z.boolean().optional(), + claim_expiry_date: z.number().int().optional(), +}); +const GiftSubscriptionEstimateGifterSchema = z.object({ + customer_id: z.string().max(50), + signature: z.string().max(50), + note: z.string().max(500).optional(), + payment_src_id: z.string().max(40).optional(), +}); +const GiftSubscriptionEstimateGiftReceiverSchema = z.object({ + customer_id: z.string().max(50), + first_name: z.string().max(150), + last_name: z.string().max(150), + email: z.string().email().max(70), +}); +const GiftSubscriptionEstimateAdditionalInformationSchema = z.looseObject({}); +const GiftSubscriptionEstimatePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + GiftSubscriptionEstimateAdditionalInformationSchema.optional(), +}); +const GiftSubscriptionEstimateShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const GiftSubscriptionEstimateSubscriptionSchema = z.object({ + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), +}); +const GiftSubscriptionEstimateAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), +}); +const GiftSubscriptionEstimateBodySchema = z.looseObject({ + coupon_ids: z.array(z.string().max(100).optional()).optional(), + gift: GiftSubscriptionEstimateGiftSchema.optional(), + gifter: GiftSubscriptionEstimateGifterSchema.optional(), + gift_receiver: GiftSubscriptionEstimateGiftReceiverSchema.optional(), + payment_intent: GiftSubscriptionEstimatePaymentIntentSchema.optional(), + shipping_address: GiftSubscriptionEstimateShippingAddressSchema.optional(), + subscription: GiftSubscriptionEstimateSubscriptionSchema.optional(), + addons: GiftSubscriptionEstimateAddonsSchema.optional(), +}); +export { GiftSubscriptionEstimateBodySchema }; +export type GiftSubscriptionEstimateBody = z.infer< + typeof GiftSubscriptionEstimateBodySchema +>; + +//Estimate.giftSubscriptionForItems + +const GiftSubscriptionForItemsEstimateGiftSchema = z.object({ + scheduled_at: z.number().int().optional(), + auto_claim: z.boolean().default(false).optional(), + no_expiry: z.boolean().optional(), + claim_expiry_date: z.number().int().optional(), +}); +const GiftSubscriptionForItemsEstimateGifterSchema = z.object({ + customer_id: z.string().max(50), + signature: z.string().max(50), + note: z.string().max(500).optional(), + payment_src_id: z.string().max(40).optional(), +}); +const GiftSubscriptionForItemsEstimateGiftReceiverSchema = z.object({ + customer_id: z.string().max(50), + first_name: z.string().max(150), + last_name: z.string().max(150), + email: z.string().email().max(70), +}); +const GiftSubscriptionForItemsEstimateAdditionalInformationSchema = + z.looseObject({}); +const GiftSubscriptionForItemsEstimatePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + GiftSubscriptionForItemsEstimateAdditionalInformationSchema.optional(), +}); +const GiftSubscriptionForItemsEstimateShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const GiftSubscriptionForItemsEstimateSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const GiftSubscriptionForItemsEstimateItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const GiftSubscriptionForItemsEstimateBodySchema = z.looseObject({ + coupon_ids: z.array(z.string().max(100).optional()).optional(), + gift: GiftSubscriptionForItemsEstimateGiftSchema.optional(), + gifter: GiftSubscriptionForItemsEstimateGifterSchema.optional(), + gift_receiver: GiftSubscriptionForItemsEstimateGiftReceiverSchema.optional(), + payment_intent: + GiftSubscriptionForItemsEstimatePaymentIntentSchema.optional(), + shipping_address: + GiftSubscriptionForItemsEstimateShippingAddressSchema.optional(), + subscription_items: + GiftSubscriptionForItemsEstimateSubscriptionItemsSchema.optional(), + item_tiers: GiftSubscriptionForItemsEstimateItemTiersSchema.optional(), +}); +export { GiftSubscriptionForItemsEstimateBodySchema }; +export type GiftSubscriptionForItemsEstimateBody = z.infer< + typeof GiftSubscriptionForItemsEstimateBodySchema +>; + +//Estimate.createInvoice + +const CreateInvoiceEstimateInvoiceSchema = z.object({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), +}); +const CreateInvoiceEstimateShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateInvoiceEstimateAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceEstimateChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceEstimateNotesToRemoveSchema = z.object({ + entity_type: z + .array( + z + .enum(['plan', 'addon', 'customer', 'subscription', 'coupon']) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateInvoiceEstimateTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateInvoiceEstimateBodySchema = z.looseObject({ + currency_code: z.string().max(3).optional(), + invoice_note: z.string().max(2000).optional(), + remove_general_note: z.boolean().default(false).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + authorization_transaction_id: z.string().max(40).optional(), + payment_source_id: z.string().max(40).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + invoice_date: z.number().int().optional(), + invoice: CreateInvoiceEstimateInvoiceSchema.optional(), + shipping_address: CreateInvoiceEstimateShippingAddressSchema.optional(), + addons: CreateInvoiceEstimateAddonsSchema.optional(), + charges: CreateInvoiceEstimateChargesSchema.optional(), + notes_to_remove: CreateInvoiceEstimateNotesToRemoveSchema.optional(), + tax_providers_fields: + CreateInvoiceEstimateTaxProvidersFieldsSchema.optional(), +}); +export { CreateInvoiceEstimateBodySchema }; +export type CreateInvoiceEstimateBody = z.infer< + typeof CreateInvoiceEstimateBodySchema +>; + +//Estimate.createInvoiceForItems + +const CreateInvoiceForItemsEstimateInvoiceSchema = z.object({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), +}); +const CreateInvoiceForItemsEstimateShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateInvoiceForItemsEstimateBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateInvoiceForItemsEstimateItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceForItemsEstimateItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateInvoiceForItemsEstimateChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceForItemsEstimateNotesToRemoveSchema = z.object({ + entity_type: z + .array( + z + .enum([ + 'customer', + 'subscription', + 'coupon', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateInvoiceForItemsEstimateDiscountsSchema = z.object({ + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateInvoiceForItemsEstimateTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateInvoiceForItemsEstimateBodySchema = z.looseObject({ + currency_code: z.string().max(3).optional(), + invoice_note: z.string().max(2000).optional(), + remove_general_note: z.boolean().default(false).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + authorization_transaction_id: z.string().max(40).optional(), + payment_source_id: z.string().max(40).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + invoice_date: z.number().int().optional(), + invoice: CreateInvoiceForItemsEstimateInvoiceSchema.optional(), + shipping_address: + CreateInvoiceForItemsEstimateShippingAddressSchema.optional(), + billing_address: CreateInvoiceForItemsEstimateBillingAddressSchema.optional(), + item_prices: CreateInvoiceForItemsEstimateItemPricesSchema.optional(), + item_tiers: CreateInvoiceForItemsEstimateItemTiersSchema.optional(), + charges: CreateInvoiceForItemsEstimateChargesSchema.optional(), + notes_to_remove: CreateInvoiceForItemsEstimateNotesToRemoveSchema.optional(), + discounts: CreateInvoiceForItemsEstimateDiscountsSchema.optional(), + tax_providers_fields: + CreateInvoiceForItemsEstimateTaxProvidersFieldsSchema.optional(), +}); +export { CreateInvoiceForItemsEstimateBodySchema }; +export type CreateInvoiceForItemsEstimateBody = z.infer< + typeof CreateInvoiceForItemsEstimateBodySchema +>; + +//Estimate.paymentSchedules + +const PaymentSchedulesEstimateBodySchema = z.looseObject({ + scheme_id: z.string(), + amount: z.number().int().min(0).optional(), + invoice_id: z.string().optional(), + payment_schedule_start_date: z.number().int().optional(), +}); +export { PaymentSchedulesEstimateBodySchema }; +export type PaymentSchedulesEstimateBody = z.infer< + typeof PaymentSchedulesEstimateBodySchema +>; diff --git a/src/schema/export.schema.ts b/src/schema/export.schema.ts new file mode 100644 index 0000000..8ce0b8f --- /dev/null +++ b/src/schema/export.schema.ts @@ -0,0 +1,1579 @@ +// Generated Zod schemas: Export +// Actions: customers, creditNotes, transactions, orders, itemFamilies, items, attachedItems, priceVariants +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Export.customers + +const CustomersExportBusinessEntityIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const CustomersExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CustomersExportFirstNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const CustomersExportLastNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const CustomersExportEmailSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const CustomersExportCompanySchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const CustomersExportPhoneSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const CustomersExportAutoCollectionSchema = z.object({ + is: z.enum(['on', 'off']).optional(), + is_not: z.enum(['on', 'off']).optional(), + in: z.enum(['on', 'off']).optional(), + not_in: z.enum(['on', 'off']).optional(), +}); +const CustomersExportTaxabilitySchema = z.object({ + is: z.enum(['taxable', 'exempt']).optional(), + is_not: z.enum(['taxable', 'exempt']).optional(), + in: z.enum(['taxable', 'exempt']).optional(), + not_in: z.enum(['taxable', 'exempt']).optional(), +}); +const CustomersExportCreatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const CustomersExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const CustomersExportOfflinePaymentMethodSchema = z.object({ + is: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + is_not: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + in: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + not_in: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), +}); +const CustomersExportAutoCloseInvoicesSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const CustomersExportChannelSchema = z.object({ + is: z.enum(['web', 'app_store', 'play_store']).optional(), + is_not: z.enum(['web', 'app_store', 'play_store']).optional(), + in: z.enum(['web', 'app_store', 'play_store']).optional(), + not_in: z.enum(['web', 'app_store', 'play_store']).optional(), +}); +const CustomersExportCustomerItemSchema = z.object({ + id: CustomersExportIdSchema.optional(), + first_name: CustomersExportFirstNameSchema.optional(), + last_name: CustomersExportLastNameSchema.optional(), + email: CustomersExportEmailSchema.optional(), + company: CustomersExportCompanySchema.optional(), + phone: CustomersExportPhoneSchema.optional(), + auto_collection: CustomersExportAutoCollectionSchema.optional(), + taxability: CustomersExportTaxabilitySchema.optional(), + created_at: CustomersExportCreatedAtSchema.optional(), + updated_at: CustomersExportUpdatedAtSchema.optional(), + offline_payment_method: CustomersExportOfflinePaymentMethodSchema.optional(), + auto_close_invoices: CustomersExportAutoCloseInvoicesSchema.optional(), + channel: CustomersExportChannelSchema.optional(), +}); +const CustomersExportParentIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const CustomersExportPaymentOwnerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const CustomersExportInvoiceOwnerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const CustomersExportRelationshipSchema = z.object({ + parent_id: CustomersExportParentIdSchema.optional(), + payment_owner_id: CustomersExportPaymentOwnerIdSchema.optional(), + invoice_owner_id: CustomersExportInvoiceOwnerIdSchema.optional(), +}); +const CustomersExportBodySchema = z.looseObject({ + export_type: z.enum(['data', 'import_friendly_data']).optional(), + business_entity_id: CustomersExportBusinessEntityIdSchema.optional(), + customer: z.array(CustomersExportCustomerItemSchema.optional()).optional(), + relationship: CustomersExportRelationshipSchema.optional(), +}); +export { CustomersExportBodySchema }; +export type CustomersExportBody = z.infer; + +//Export.creditNotes + +const CreditNotesExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CreditNotesExportCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CreditNotesExportSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CreditNotesExportReferenceInvoiceIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CreditNotesExportTypeSchema = z.object({ + is: z.enum(['adjustment', 'refundable', 'store']).optional(), + is_not: z.enum(['adjustment', 'refundable', 'store']).optional(), + in: z.enum(['adjustment', 'refundable', 'store']).optional(), + not_in: z.enum(['adjustment', 'refundable', 'store']).optional(), +}); +const CreditNotesExportReasonCodeSchema = z.object({ + is: z + .enum([ + 'write_off', + 'subscription_change', + 'subscription_cancellation', + 'subscription_pause', + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + 'fraudulent', + ]) + .optional(), + is_not: z + .enum([ + 'write_off', + 'subscription_change', + 'subscription_cancellation', + 'subscription_pause', + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + 'fraudulent', + ]) + .optional(), + in: z + .enum([ + 'write_off', + 'subscription_change', + 'subscription_cancellation', + 'subscription_pause', + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + 'fraudulent', + ]) + .optional(), + not_in: z + .enum([ + 'write_off', + 'subscription_change', + 'subscription_cancellation', + 'subscription_pause', + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + 'fraudulent', + ]) + .optional(), +}); +const CreditNotesExportCreateReasonCodeSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const CreditNotesExportStatusSchema = z.object({ + is: z.enum(['adjusted', 'refunded', 'refund_due', 'voided']).optional(), + is_not: z.enum(['adjusted', 'refunded', 'refund_due', 'voided']).optional(), + in: z.enum(['adjusted', 'refunded', 'refund_due', 'voided']).optional(), + not_in: z.enum(['adjusted', 'refunded', 'refund_due', 'voided']).optional(), +}); +const CreditNotesExportDateSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const CreditNotesExportTotalSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const CreditNotesExportPriceTypeSchema = z.object({ + is: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + is_not: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + in: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + not_in: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), +}); +const CreditNotesExportAmountAllocatedSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const CreditNotesExportAmountRefundedSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const CreditNotesExportAmountAvailableSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const CreditNotesExportVoidedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const CreditNotesExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const CreditNotesExportChannelSchema = z.object({ + is: z.enum(['web', 'app_store', 'play_store']).optional(), + is_not: z.enum(['web', 'app_store', 'play_store']).optional(), + in: z.enum(['web', 'app_store', 'play_store']).optional(), + not_in: z.enum(['web', 'app_store', 'play_store']).optional(), +}); +const CreditNotesExportCreditNoteItemSchema = z.object({ + id: CreditNotesExportIdSchema.optional(), + customer_id: CreditNotesExportCustomerIdSchema.optional(), + subscription_id: CreditNotesExportSubscriptionIdSchema.optional(), + reference_invoice_id: CreditNotesExportReferenceInvoiceIdSchema.optional(), + type: CreditNotesExportTypeSchema.optional(), + reason_code: CreditNotesExportReasonCodeSchema.optional(), + create_reason_code: CreditNotesExportCreateReasonCodeSchema.optional(), + status: CreditNotesExportStatusSchema.optional(), + date: CreditNotesExportDateSchema.optional(), + total: CreditNotesExportTotalSchema.optional(), + price_type: CreditNotesExportPriceTypeSchema.optional(), + amount_allocated: CreditNotesExportAmountAllocatedSchema.optional(), + amount_refunded: CreditNotesExportAmountRefundedSchema.optional(), + amount_available: CreditNotesExportAmountAvailableSchema.optional(), + voided_at: CreditNotesExportVoidedAtSchema.optional(), + updated_at: CreditNotesExportUpdatedAtSchema.optional(), + channel: CreditNotesExportChannelSchema.optional(), +}); +const CreditNotesExportBodySchema = z.looseObject({ + credit_note: z + .array(CreditNotesExportCreditNoteItemSchema.optional()) + .optional(), +}); +export { CreditNotesExportBodySchema }; +export type CreditNotesExportBody = z.infer; + +//Export.transactions + +const TransactionsExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const TransactionsExportCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const TransactionsExportSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const TransactionsExportPaymentSourceIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const TransactionsExportPaymentMethodSchema = z.object({ + is: z + .enum([ + 'card', + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'amazon_payments', + 'paypal_express_checkout', + 'direct_debit', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ach_credit', + 'sepa_credit', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'other', + 'app_store', + 'upi', + 'netbanking_emandates', + 'play_store', + 'custom', + 'boleto', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + is_not: z + .enum([ + 'card', + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'amazon_payments', + 'paypal_express_checkout', + 'direct_debit', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ach_credit', + 'sepa_credit', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'other', + 'app_store', + 'upi', + 'netbanking_emandates', + 'play_store', + 'custom', + 'boleto', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + in: z + .enum([ + 'card', + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'amazon_payments', + 'paypal_express_checkout', + 'direct_debit', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ach_credit', + 'sepa_credit', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'other', + 'app_store', + 'upi', + 'netbanking_emandates', + 'play_store', + 'custom', + 'boleto', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + not_in: z + .enum([ + 'card', + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'amazon_payments', + 'paypal_express_checkout', + 'direct_debit', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ach_credit', + 'sepa_credit', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'other', + 'app_store', + 'upi', + 'netbanking_emandates', + 'play_store', + 'custom', + 'boleto', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), +}); +const TransactionsExportGatewaySchema = z.object({ + is: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + 'not_applicable', + ]) + .optional(), + is_not: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + 'not_applicable', + ]) + .optional(), + in: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + 'not_applicable', + ]) + .optional(), + not_in: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + 'not_applicable', + ]) + .optional(), +}); +const TransactionsExportGatewayAccountIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const TransactionsExportIdAtGatewaySchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const TransactionsExportReferenceNumberSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const TransactionsExportTypeSchema = z.object({ + is: z + .enum(['authorization', 'payment', 'refund', 'payment_reversal']) + .optional(), + is_not: z + .enum(['authorization', 'payment', 'refund', 'payment_reversal']) + .optional(), + in: z + .enum(['authorization', 'payment', 'refund', 'payment_reversal']) + .optional(), + not_in: z + .enum(['authorization', 'payment', 'refund', 'payment_reversal']) + .optional(), +}); +const TransactionsExportDateSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const TransactionsExportAmountSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const TransactionsExportAmountCapturableSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const TransactionsExportStatusSchema = z.object({ + is: z + .enum([ + 'in_progress', + 'success', + 'voided', + 'failure', + 'timeout', + 'needs_attention', + 'late_failure', + ]) + .optional(), + is_not: z + .enum([ + 'in_progress', + 'success', + 'voided', + 'failure', + 'timeout', + 'needs_attention', + 'late_failure', + ]) + .optional(), + in: z + .enum([ + 'in_progress', + 'success', + 'voided', + 'failure', + 'timeout', + 'needs_attention', + 'late_failure', + ]) + .optional(), + not_in: z + .enum([ + 'in_progress', + 'success', + 'voided', + 'failure', + 'timeout', + 'needs_attention', + 'late_failure', + ]) + .optional(), +}); +const TransactionsExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const TransactionsExportTransactionItemSchema = z.object({ + id: TransactionsExportIdSchema.optional(), + customer_id: TransactionsExportCustomerIdSchema.optional(), + subscription_id: TransactionsExportSubscriptionIdSchema.optional(), + payment_source_id: TransactionsExportPaymentSourceIdSchema.optional(), + payment_method: TransactionsExportPaymentMethodSchema.optional(), + gateway: TransactionsExportGatewaySchema.optional(), + gateway_account_id: TransactionsExportGatewayAccountIdSchema.optional(), + id_at_gateway: TransactionsExportIdAtGatewaySchema.optional(), + reference_number: TransactionsExportReferenceNumberSchema.optional(), + type: TransactionsExportTypeSchema.optional(), + date: TransactionsExportDateSchema.optional(), + amount: TransactionsExportAmountSchema.optional(), + amount_capturable: TransactionsExportAmountCapturableSchema.optional(), + status: TransactionsExportStatusSchema.optional(), + updated_at: TransactionsExportUpdatedAtSchema.optional(), +}); +const TransactionsExportBodySchema = z.looseObject({ + transaction: z + .array(TransactionsExportTransactionItemSchema.optional()) + .optional(), +}); +export { TransactionsExportBodySchema }; +export type TransactionsExportBody = z.infer< + typeof TransactionsExportBodySchema +>; + +//Export.orders + +const OrdersExportTotalSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const OrdersExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const OrdersExportSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const OrdersExportCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const OrdersExportStatusSchema = z.object({ + is: z + .enum([ + 'new', + 'processing', + 'complete', + 'cancelled', + 'voided', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]) + .optional(), + is_not: z + .enum([ + 'new', + 'processing', + 'complete', + 'cancelled', + 'voided', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]) + .optional(), + in: z + .enum([ + 'new', + 'processing', + 'complete', + 'cancelled', + 'voided', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]) + .optional(), + not_in: z + .enum([ + 'new', + 'processing', + 'complete', + 'cancelled', + 'voided', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]) + .optional(), +}); +const OrdersExportPriceTypeSchema = z.object({ + is: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + is_not: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + in: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + not_in: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), +}); +const OrdersExportOrderDateSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportShippingDateSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportShippedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportDeliveredAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportCancelledAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportAmountPaidSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const OrdersExportRefundableCreditsSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const OrdersExportRefundableCreditsIssuedSchema = z.object({ + is: z.string().regex(RegExp('^-?d+$')).optional(), + is_not: z.string().regex(RegExp('^-?d+$')).optional(), + lt: z.string().regex(RegExp('^-?d+$')).optional(), + lte: z.string().regex(RegExp('^-?d+$')).optional(), + gt: z.string().regex(RegExp('^-?d+$')).optional(), + gte: z.string().regex(RegExp('^-?d+$')).optional(), + between: z.string().regex(RegExp('^[-?d+,-?d+]$')).optional(), +}); +const OrdersExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const OrdersExportResentStatusSchema = z.object({ + is: z.enum(['fully_resent', 'partially_resent']).optional(), + is_not: z.enum(['fully_resent', 'partially_resent']).optional(), + in: z.enum(['fully_resent', 'partially_resent']).optional(), + not_in: z.enum(['fully_resent', 'partially_resent']).optional(), +}); +const OrdersExportIsResentSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const OrdersExportOriginalOrderIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const OrdersExportOrderItemSchema = z.object({ + id: OrdersExportIdSchema.optional(), + subscription_id: OrdersExportSubscriptionIdSchema.optional(), + customer_id: OrdersExportCustomerIdSchema.optional(), + status: OrdersExportStatusSchema.optional(), + price_type: OrdersExportPriceTypeSchema.optional(), + order_date: OrdersExportOrderDateSchema.optional(), + shipping_date: OrdersExportShippingDateSchema.optional(), + shipped_at: OrdersExportShippedAtSchema.optional(), + delivered_at: OrdersExportDeliveredAtSchema.optional(), + cancelled_at: OrdersExportCancelledAtSchema.optional(), + amount_paid: OrdersExportAmountPaidSchema.optional(), + refundable_credits: OrdersExportRefundableCreditsSchema.optional(), + refundable_credits_issued: + OrdersExportRefundableCreditsIssuedSchema.optional(), + updated_at: OrdersExportUpdatedAtSchema.optional(), + resent_status: OrdersExportResentStatusSchema.optional(), + is_resent: OrdersExportIsResentSchema.optional(), + original_order_id: OrdersExportOriginalOrderIdSchema.optional(), +}); +const OrdersExportBodySchema = z.looseObject({ + total: OrdersExportTotalSchema.optional(), + order: z.array(OrdersExportOrderItemSchema.optional()).optional(), +}); +export { OrdersExportBodySchema }; +export type OrdersExportBody = z.infer; + +//Export.itemFamilies + +const ItemFamiliesExportBusinessEntityIdSchema = z.object({ + is_present: z.enum(['true', 'false']).optional(), + is: z.string().min(1).optional(), +}); +const ItemFamiliesExportIncludeSiteLevelResourcesSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemFamiliesExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const ItemFamiliesExportNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ItemFamiliesExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ItemFamiliesExportItemFamilyItemSchema = z.object({ + id: ItemFamiliesExportIdSchema.optional(), + name: ItemFamiliesExportNameSchema.optional(), + updated_at: ItemFamiliesExportUpdatedAtSchema.optional(), +}); +const ItemFamiliesExportBodySchema = z.looseObject({ + business_entity_id: ItemFamiliesExportBusinessEntityIdSchema.optional(), + include_site_level_resources: + ItemFamiliesExportIncludeSiteLevelResourcesSchema.optional(), + item_family: z + .array(ItemFamiliesExportItemFamilyItemSchema.optional()) + .optional(), +}); +export { ItemFamiliesExportBodySchema }; +export type ItemFamiliesExportBody = z.infer< + typeof ItemFamiliesExportBodySchema +>; + +//Export.items + +const ItemsExportBusinessEntityIdSchema = z.object({ + is_present: z.enum(['true', 'false']).optional(), + is: z.string().min(1).optional(), +}); +const ItemsExportIncludeSiteLevelResourcesSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemsExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const ItemsExportItemFamilyIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const ItemsExportTypeSchema = z.object({ + is: z.enum(['plan', 'addon', 'charge']).optional(), + is_not: z.enum(['plan', 'addon', 'charge']).optional(), + in: z.enum(['plan', 'addon', 'charge']).optional(), + not_in: z.enum(['plan', 'addon', 'charge']).optional(), +}); +const ItemsExportNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ItemsExportItemApplicabilitySchema = z.object({ + is: z.enum(['all', 'restricted']).optional(), + is_not: z.enum(['all', 'restricted']).optional(), + in: z.enum(['all', 'restricted']).optional(), + not_in: z.enum(['all', 'restricted']).optional(), +}); +const ItemsExportStatusSchema = z.object({ + is: z.enum(['active', 'archived', 'deleted']).optional(), + is_not: z.enum(['active', 'archived', 'deleted']).optional(), + in: z.enum(['active', 'archived', 'deleted']).optional(), + not_in: z.enum(['active', 'archived', 'deleted']).optional(), +}); +const ItemsExportIsGiftableSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemsExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ItemsExportEnabledForCheckoutSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemsExportEnabledInPortalSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemsExportMeteredSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const ItemsExportUsageCalculationSchema = z.object({ + is: z.enum(['sum_of_usages', 'last_usage', 'max_usage']).optional(), + is_not: z.enum(['sum_of_usages', 'last_usage', 'max_usage']).optional(), + in: z.enum(['sum_of_usages', 'last_usage', 'max_usage']).optional(), + not_in: z.enum(['sum_of_usages', 'last_usage', 'max_usage']).optional(), +}); +const ItemsExportChannelSchema = z.object({ + is: z.enum(['web', 'app_store', 'play_store']).optional(), + is_not: z.enum(['web', 'app_store', 'play_store']).optional(), + in: z.enum(['web', 'app_store', 'play_store']).optional(), + not_in: z.enum(['web', 'app_store', 'play_store']).optional(), +}); +const ItemsExportItemItemSchema = z.object({ + id: ItemsExportIdSchema.optional(), + item_family_id: ItemsExportItemFamilyIdSchema.optional(), + type: ItemsExportTypeSchema.optional(), + name: ItemsExportNameSchema.optional(), + item_applicability: ItemsExportItemApplicabilitySchema.optional(), + status: ItemsExportStatusSchema.optional(), + is_giftable: ItemsExportIsGiftableSchema.optional(), + updated_at: ItemsExportUpdatedAtSchema.optional(), + enabled_for_checkout: ItemsExportEnabledForCheckoutSchema.optional(), + enabled_in_portal: ItemsExportEnabledInPortalSchema.optional(), + metered: ItemsExportMeteredSchema.optional(), + usage_calculation: ItemsExportUsageCalculationSchema.optional(), + channel: ItemsExportChannelSchema.optional(), +}); +const ItemsExportBodySchema = z.looseObject({ + business_entity_id: ItemsExportBusinessEntityIdSchema.optional(), + include_site_level_resources: + ItemsExportIncludeSiteLevelResourcesSchema.optional(), + item: z.array(ItemsExportItemItemSchema.optional()).optional(), +}); +export { ItemsExportBodySchema }; +export type ItemsExportBody = z.infer; + +//Export.attachedItems + +const AttachedItemsExportItemTypeSchema = z.object({ + is: z.enum(['plan', 'addon', 'charge']).optional(), + is_not: z.enum(['plan', 'addon', 'charge']).optional(), + in: z.enum(['plan', 'addon', 'charge']).optional(), + not_in: z.enum(['plan', 'addon', 'charge']).optional(), +}); +const AttachedItemsExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const AttachedItemsExportItemIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const AttachedItemsExportTypeSchema = z.object({ + is: z.enum(['recommended', 'mandatory', 'optional']).optional(), + is_not: z.enum(['recommended', 'mandatory', 'optional']).optional(), + in: z.enum(['recommended', 'mandatory', 'optional']).optional(), + not_in: z.enum(['recommended', 'mandatory', 'optional']).optional(), +}); +const AttachedItemsExportChargeOnEventSchema = z.object({ + is: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), + is_not: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), + in: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), + not_in: z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + 'on_demand', + ]) + .optional(), +}); +const AttachedItemsExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const AttachedItemsExportParentItemIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const AttachedItemsExportAttachedItemItemSchema = z.object({ + id: AttachedItemsExportIdSchema.optional(), + item_id: AttachedItemsExportItemIdSchema.optional(), + type: AttachedItemsExportTypeSchema.optional(), + charge_on_event: AttachedItemsExportChargeOnEventSchema.optional(), + updated_at: AttachedItemsExportUpdatedAtSchema.optional(), + parent_item_id: AttachedItemsExportParentItemIdSchema.optional(), +}); +const AttachedItemsExportBodySchema = z.looseObject({ + item_type: AttachedItemsExportItemTypeSchema.optional(), + attached_item: z + .array(AttachedItemsExportAttachedItemItemSchema.optional()) + .optional(), +}); +export { AttachedItemsExportBodySchema }; +export type AttachedItemsExportBody = z.infer< + typeof AttachedItemsExportBodySchema +>; + +//Export.priceVariants + +const PriceVariantsExportBusinessEntityIdSchema = z.object({ + is_present: z.enum(['true', 'false']).optional(), + is: z.string().min(1).optional(), +}); +const PriceVariantsExportIncludeSiteLevelResourcesSchema = z.object({ + is: z.enum(['true', 'false']).optional(), +}); +const PriceVariantsExportIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const PriceVariantsExportNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), + not_in: z.string().regex(RegExp('^[(.*)(,.*)*]$')).optional(), +}); +const PriceVariantsExportStatusSchema = z.object({ + is: z.enum(['active', 'archived']).optional(), + is_not: z.enum(['active', 'archived']).optional(), + in: z.enum(['active', 'archived']).optional(), + not_in: z.enum(['active', 'archived']).optional(), +}); +const PriceVariantsExportUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const PriceVariantsExportCreatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const PriceVariantsExportPriceVariantItemSchema = z.object({ + id: PriceVariantsExportIdSchema.optional(), + name: PriceVariantsExportNameSchema.optional(), + status: PriceVariantsExportStatusSchema.optional(), + updated_at: PriceVariantsExportUpdatedAtSchema.optional(), + created_at: PriceVariantsExportCreatedAtSchema.optional(), +}); +const PriceVariantsExportBodySchema = z.looseObject({ + business_entity_id: PriceVariantsExportBusinessEntityIdSchema.optional(), + include_site_level_resources: + PriceVariantsExportIncludeSiteLevelResourcesSchema.optional(), + price_variant: z + .array(PriceVariantsExportPriceVariantItemSchema.optional()) + .optional(), +}); +export { PriceVariantsExportBodySchema }; +export type PriceVariantsExportBody = z.infer< + typeof PriceVariantsExportBodySchema +>; diff --git a/src/schema/feature.schema.ts b/src/schema/feature.schema.ts new file mode 100644 index 0000000..03da765 --- /dev/null +++ b/src/schema/feature.schema.ts @@ -0,0 +1,41 @@ +// Generated Zod schemas: Feature +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Feature.create + +const CreateFeatureLevelsSchema = z.object({ + name: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + is_unlimited: z.array(z.boolean().optional()).optional(), + level: z.array(z.number().int().optional()).optional(), +}); +const CreateFeatureBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + name: z.string().max(50), + description: z.string().max(500).optional(), + type: z.enum(['switch', 'custom', 'quantity', 'range']).optional(), + unit: z.string().max(50).optional(), + levels: CreateFeatureLevelsSchema.optional(), +}); +export { CreateFeatureBodySchema }; +export type CreateFeatureBody = z.infer; + +//Feature.update + +const UpdateFeatureLevelsSchema = z.object({ + name: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + is_unlimited: z.array(z.boolean().optional()).optional(), + level: z.array(z.number().int().optional()).optional(), +}); +const UpdateFeatureBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + description: z.string().max(500).optional(), + unit: z.string().max(50).optional(), + levels: UpdateFeatureLevelsSchema.optional(), +}); +export { UpdateFeatureBodySchema }; +export type UpdateFeatureBody = z.infer; diff --git a/src/schema/gift.schema.ts b/src/schema/gift.schema.ts new file mode 100644 index 0000000..fa87617 --- /dev/null +++ b/src/schema/gift.schema.ts @@ -0,0 +1,290 @@ +// Generated Zod schemas: Gift +// Actions: create, createForItems, list, updateGift +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Gift.create + +const CreateGiftGifterSchema = z.object({ + customer_id: z.string().max(50), + signature: z.string().max(50), + note: z.string().max(500).optional(), + payment_src_id: z.string().max(40).optional(), +}); +const CreateGiftGiftReceiverSchema = z.object({ + customer_id: z.string().max(50), + first_name: z.string().max(150), + last_name: z.string().max(150), + email: z.string().email().max(70), +}); +const CreateGiftAdditionalInformationSchema = z.looseObject({}); +const CreateGiftPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: CreateGiftAdditionalInformationSchema.optional(), +}); +const CreateGiftShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateGiftSubscriptionSchema = z.looseObject({ + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), +}); +const CreateGiftAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), +}); +const CreateGiftBodySchema = z.looseObject({ + scheduled_at: z.number().int().optional(), + auto_claim: z.boolean().default(false).optional(), + no_expiry: z.boolean().optional(), + claim_expiry_date: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + gifter: CreateGiftGifterSchema.optional(), + gift_receiver: CreateGiftGiftReceiverSchema.optional(), + payment_intent: CreateGiftPaymentIntentSchema.optional(), + shipping_address: CreateGiftShippingAddressSchema.optional(), + subscription: CreateGiftSubscriptionSchema.optional(), + addons: CreateGiftAddonsSchema.optional(), +}); +export { CreateGiftBodySchema }; +export type CreateGiftBody = z.infer; + +//Gift.createForItems + +const CreateForItemsGiftMetaDataSchema = z.looseObject({}); +const CreateForItemsGiftGifterSchema = z.object({ + customer_id: z.string().max(50), + signature: z.string().max(50), + note: z.string().max(500).optional(), + payment_src_id: z.string().max(40).optional(), +}); +const CreateForItemsGiftGiftReceiverSchema = z.object({ + customer_id: z.string().max(50), + first_name: z.string().max(150), + last_name: z.string().max(150), + email: z.string().email().max(70), +}); +const CreateForItemsGiftAdditionalInformationSchema = z.looseObject({}); +const CreateForItemsGiftPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + CreateForItemsGiftAdditionalInformationSchema.optional(), +}); +const CreateForItemsGiftShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForItemsGiftSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CreateForItemsGiftItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CreateForItemsGiftBodySchema = z.looseObject({ + scheduled_at: z.number().int().optional(), + auto_claim: z.boolean().default(false).optional(), + no_expiry: z.boolean().optional(), + claim_expiry_date: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + meta_data: CreateForItemsGiftMetaDataSchema.optional(), + gifter: CreateForItemsGiftGifterSchema.optional(), + gift_receiver: CreateForItemsGiftGiftReceiverSchema.optional(), + payment_intent: CreateForItemsGiftPaymentIntentSchema.optional(), + shipping_address: CreateForItemsGiftShippingAddressSchema.optional(), + subscription_items: CreateForItemsGiftSubscriptionItemsSchema.optional(), + item_tiers: CreateForItemsGiftItemTiersSchema.optional(), +}); +export { CreateForItemsGiftBodySchema }; +export type CreateForItemsGiftBody = z.infer< + typeof CreateForItemsGiftBodySchema +>; + +//Gift.list + +const ListGiftStatusSchema = z.object({ + is: z + .enum(['scheduled', 'unclaimed', 'claimed', 'cancelled', 'expired']) + .optional(), + is_not: z + .enum(['scheduled', 'unclaimed', 'claimed', 'cancelled', 'expired']) + .optional(), + in: z + .enum(['scheduled', 'unclaimed', 'claimed', 'cancelled', 'expired']) + .optional(), + not_in: z + .enum(['scheduled', 'unclaimed', 'claimed', 'cancelled', 'expired']) + .optional(), +}); +const ListGiftEmailSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListGiftCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListGiftGiftReceiverSchema = z.object({ + email: ListGiftEmailSchema.optional(), + customer_id: ListGiftCustomerIdSchema.optional(), +}); +const ListGiftGifterSchema = z.object({ + customer_id: ListGiftCustomerIdSchema.optional(), +}); +const ListGiftBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + status: ListGiftStatusSchema.optional(), + gift_receiver: ListGiftGiftReceiverSchema.optional(), + gifter: ListGiftGifterSchema.optional(), +}); +export { ListGiftBodySchema }; +export type ListGiftBody = z.infer; + +//Gift.updateGift + +const UpdateGiftGiftBodySchema = z.looseObject({ + scheduled_at: z.number().int(), + comment: z.string().max(250).optional(), +}); +export { UpdateGiftGiftBodySchema }; +export type UpdateGiftGiftBody = z.infer; diff --git a/src/schema/hosted_page.schema.ts b/src/schema/hosted_page.schema.ts new file mode 100644 index 0000000..a8fa0c6 --- /dev/null +++ b/src/schema/hosted_page.schema.ts @@ -0,0 +1,1765 @@ +// Generated Zod schemas: HostedPage +// Actions: checkoutNew, checkoutOneTime, checkoutOneTimeForItems, checkoutNewForItems, checkoutExisting, checkoutExistingForItems, updateCard, updatePaymentMethod, managePaymentSources, collectNow, acceptQuote, extendSubscription, checkoutGift, checkoutGiftForItems, claimGift, retrieveAgreementPdf, preCancel, events, viewVoucher +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//HostedPage.checkoutNew + +const CheckoutNewHostedPageSubscriptionSchema = z.looseObject({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + invoice_notes: z.string().max(2000).optional(), + affiliate_token: z.string().max(250).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const CheckoutNewHostedPageCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + consolidated_invoicing: z.boolean().optional(), +}); +const CheckoutNewHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutNewHostedPageBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutNewHostedPageShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutNewHostedPageContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CheckoutNewHostedPageAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), +}); +const CheckoutNewHostedPageEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CheckoutNewHostedPageBodySchema = z.looseObject({ + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + embed: z.boolean().default(true).optional(), + iframe_messaging: z.boolean().default(false).optional(), + allow_offline_payment_methods: z.boolean().optional(), + subscription: CheckoutNewHostedPageSubscriptionSchema.optional(), + customer: CheckoutNewHostedPageCustomerSchema.optional(), + card: CheckoutNewHostedPageCardSchema.optional(), + billing_address: CheckoutNewHostedPageBillingAddressSchema.optional(), + shipping_address: CheckoutNewHostedPageShippingAddressSchema.optional(), + contract_term: CheckoutNewHostedPageContractTermSchema.optional(), + addons: CheckoutNewHostedPageAddonsSchema.optional(), + event_based_addons: CheckoutNewHostedPageEventBasedAddonsSchema.optional(), +}); +export { CheckoutNewHostedPageBodySchema }; +export type CheckoutNewHostedPageBody = z.infer< + typeof CheckoutNewHostedPageBodySchema +>; + +//HostedPage.checkoutOneTime + +const CheckoutOneTimeHostedPageCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + consolidated_invoicing: z.boolean().optional(), +}); +const CheckoutOneTimeHostedPageInvoiceSchema = z.object({ + po_number: z.string().max(100).optional(), +}); +const CheckoutOneTimeHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutOneTimeHostedPageBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutOneTimeHostedPageShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutOneTimeHostedPageAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CheckoutOneTimeHostedPageChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CheckoutOneTimeHostedPageBodySchema = z.looseObject({ + currency_code: z.string().max(3).optional(), + invoice_note: z.string().max(2000).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + embed: z.boolean().default(true).optional(), + iframe_messaging: z.boolean().default(false).optional(), + customer: CheckoutOneTimeHostedPageCustomerSchema.optional(), + invoice: CheckoutOneTimeHostedPageInvoiceSchema.optional(), + card: CheckoutOneTimeHostedPageCardSchema.optional(), + billing_address: CheckoutOneTimeHostedPageBillingAddressSchema.optional(), + shipping_address: CheckoutOneTimeHostedPageShippingAddressSchema.optional(), + addons: CheckoutOneTimeHostedPageAddonsSchema.optional(), + charges: CheckoutOneTimeHostedPageChargesSchema.optional(), +}); +export { CheckoutOneTimeHostedPageBodySchema }; +export type CheckoutOneTimeHostedPageBody = z.infer< + typeof CheckoutOneTimeHostedPageBodySchema +>; + +//HostedPage.checkoutOneTimeForItems + +const CheckoutOneTimeForItemsHostedPageCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + is_einvoice_enabled: z.boolean().optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), + consolidated_invoicing: z.boolean().optional(), +}); +const CheckoutOneTimeForItemsHostedPageInvoiceSchema = z.object({ + po_number: z.string().max(100).optional(), +}); +const CheckoutOneTimeForItemsHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutOneTimeForItemsHostedPageBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutOneTimeForItemsHostedPageShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutOneTimeForItemsHostedPageItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CheckoutOneTimeForItemsHostedPageItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CheckoutOneTimeForItemsHostedPageChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CheckoutOneTimeForItemsHostedPageDiscountsSchema = z.object({ + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const CheckoutOneTimeForItemsHostedPageEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + operation: z + .array(z.enum(['create', 'update', 'delete']).optional()) + .optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const CheckoutOneTimeForItemsHostedPageBodySchema = z.looseObject({ + business_entity_id: z.string().max(50).optional(), + layout: z.enum(['in_app', 'full_page']).optional(), + invoice_note: z.string().max(2000).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + currency_code: z.string().max(3).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + customer: CheckoutOneTimeForItemsHostedPageCustomerSchema.optional(), + invoice: CheckoutOneTimeForItemsHostedPageInvoiceSchema.optional(), + card: CheckoutOneTimeForItemsHostedPageCardSchema.optional(), + billing_address: + CheckoutOneTimeForItemsHostedPageBillingAddressSchema.optional(), + shipping_address: + CheckoutOneTimeForItemsHostedPageShippingAddressSchema.optional(), + item_prices: CheckoutOneTimeForItemsHostedPageItemPricesSchema.optional(), + item_tiers: CheckoutOneTimeForItemsHostedPageItemTiersSchema.optional(), + charges: CheckoutOneTimeForItemsHostedPageChargesSchema.optional(), + discounts: CheckoutOneTimeForItemsHostedPageDiscountsSchema.optional(), + entity_identifiers: + CheckoutOneTimeForItemsHostedPageEntityIdentifiersSchema.optional(), +}); +export { CheckoutOneTimeForItemsHostedPageBodySchema }; +export type CheckoutOneTimeForItemsHostedPageBody = z.infer< + typeof CheckoutOneTimeForItemsHostedPageBodySchema +>; + +//HostedPage.checkoutNewForItems + +const CheckoutNewForItemsHostedPageSubscriptionSchema = z.looseObject({ + id: z.string().max(50).optional(), + trial_end: z.number().int().optional(), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + invoice_notes: z.string().max(2000).optional(), + po_number: z.string().max(100).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const CheckoutNewForItemsHostedPageCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + is_einvoice_enabled: z.boolean().optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), +}); +const CheckoutNewForItemsHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutNewForItemsHostedPageBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutNewForItemsHostedPageShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CheckoutNewForItemsHostedPageContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CheckoutNewForItemsHostedPageSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const CheckoutNewForItemsHostedPageDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), +}); +const CheckoutNewForItemsHostedPageItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CheckoutNewForItemsHostedPageEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + operation: z + .array(z.enum(['create', 'update', 'delete']).optional()) + .optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const CheckoutNewForItemsHostedPageBodySchema = z.looseObject({ + layout: z.enum(['in_app', 'full_page']).optional(), + business_entity_id: z.string().max(50).optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + allow_offline_payment_methods: z.boolean().optional(), + subscription: CheckoutNewForItemsHostedPageSubscriptionSchema.optional(), + customer: CheckoutNewForItemsHostedPageCustomerSchema.optional(), + card: CheckoutNewForItemsHostedPageCardSchema.optional(), + billing_address: CheckoutNewForItemsHostedPageBillingAddressSchema.optional(), + shipping_address: + CheckoutNewForItemsHostedPageShippingAddressSchema.optional(), + contract_term: CheckoutNewForItemsHostedPageContractTermSchema.optional(), + subscription_items: + CheckoutNewForItemsHostedPageSubscriptionItemsSchema.optional(), + discounts: CheckoutNewForItemsHostedPageDiscountsSchema.optional(), + item_tiers: CheckoutNewForItemsHostedPageItemTiersSchema.optional(), + entity_identifiers: + CheckoutNewForItemsHostedPageEntityIdentifiersSchema.optional(), +}); +export { CheckoutNewForItemsHostedPageBodySchema }; +export type CheckoutNewForItemsHostedPageBody = z.infer< + typeof CheckoutNewForItemsHostedPageBodySchema +>; + +//HostedPage.checkoutExisting + +const CheckoutExistingHostedPageSubscriptionSchema = z.looseObject({ + id: z.string().max(50), + plan_id: z.string().max(100).optional(), + plan_quantity: z.number().int().min(1).optional(), + plan_unit_price: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + invoice_notes: z.string().max(2000).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const CheckoutExistingHostedPageCustomerSchema = z.looseObject({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), +}); +const CheckoutExistingHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutExistingHostedPageContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CheckoutExistingHostedPageAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CheckoutExistingHostedPageEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CheckoutExistingHostedPageBodySchema = z.looseObject({ + replace_addon_list: z.boolean().default(false).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + invoice_date: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + force_term_reset: z.boolean().default(false).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + embed: z.boolean().default(true).optional(), + iframe_messaging: z.boolean().default(false).optional(), + allow_offline_payment_methods: z.boolean().optional(), + subscription: CheckoutExistingHostedPageSubscriptionSchema.optional(), + customer: CheckoutExistingHostedPageCustomerSchema.optional(), + card: CheckoutExistingHostedPageCardSchema.optional(), + contract_term: CheckoutExistingHostedPageContractTermSchema.optional(), + addons: CheckoutExistingHostedPageAddonsSchema.optional(), + event_based_addons: + CheckoutExistingHostedPageEventBasedAddonsSchema.optional(), +}); +export { CheckoutExistingHostedPageBodySchema }; +export type CheckoutExistingHostedPageBody = z.infer< + typeof CheckoutExistingHostedPageBodySchema +>; + +//HostedPage.checkoutExistingForItems + +const CheckoutExistingForItemsHostedPageSubscriptionSchema = z.looseObject({ + id: z.string().max(50), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + invoice_notes: z.string().max(2000).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const CheckoutExistingForItemsHostedPageCustomerSchema = z.looseObject({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + is_einvoice_enabled: z.boolean().optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), +}); +const CheckoutExistingForItemsHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CheckoutExistingForItemsHostedPageContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CheckoutExistingForItemsHostedPageSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), +}); +const CheckoutExistingForItemsHostedPageDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + operation_type: z.array(z.enum(['add', 'remove']).optional()), + id: z.array(z.string().max(50).optional()).optional(), +}); +const CheckoutExistingForItemsHostedPageItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CheckoutExistingForItemsHostedPageEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + operation: z + .array(z.enum(['create', 'update', 'delete']).optional()) + .optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const CheckoutExistingForItemsHostedPageBodySchema = z.looseObject({ + layout: z.enum(['in_app', 'full_page']).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + replace_items_list: z.boolean().default(false).optional(), + invoice_date: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + force_term_reset: z.boolean().default(false).optional(), + change_option: z + .enum(['immediately', 'end_of_term', 'specific_date']) + .optional(), + changes_scheduled_at: z.number().int().optional(), + invoice_usages: z.boolean().default(false).optional(), + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + allow_offline_payment_methods: z.boolean().optional(), + subscription: CheckoutExistingForItemsHostedPageSubscriptionSchema.optional(), + customer: CheckoutExistingForItemsHostedPageCustomerSchema.optional(), + card: CheckoutExistingForItemsHostedPageCardSchema.optional(), + contract_term: + CheckoutExistingForItemsHostedPageContractTermSchema.optional(), + subscription_items: + CheckoutExistingForItemsHostedPageSubscriptionItemsSchema.optional(), + discounts: CheckoutExistingForItemsHostedPageDiscountsSchema.optional(), + item_tiers: CheckoutExistingForItemsHostedPageItemTiersSchema.optional(), + entity_identifiers: + CheckoutExistingForItemsHostedPageEntityIdentifiersSchema.optional(), +}); +export { CheckoutExistingForItemsHostedPageBodySchema }; +export type CheckoutExistingForItemsHostedPageBody = z.infer< + typeof CheckoutExistingForItemsHostedPageBodySchema +>; + +//HostedPage.updateCard + +const UpdateCardHostedPageCustomerSchema = z.object({ + id: z.string().max(50), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), +}); +const UpdateCardHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const UpdateCardHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + iframe_messaging: z.boolean().default(false).optional(), + customer: UpdateCardHostedPageCustomerSchema.optional(), + card: UpdateCardHostedPageCardSchema.optional(), + embed: z.boolean().default(true).optional(), +}); +export { UpdateCardHostedPageBodySchema }; +export type UpdateCardHostedPageBody = z.infer< + typeof UpdateCardHostedPageBodySchema +>; + +//HostedPage.updatePaymentMethod + +const UpdatePaymentMethodHostedPageCustomerSchema = z.object({ + id: z.string().max(50), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), +}); +const UpdatePaymentMethodHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const UpdatePaymentMethodHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + cancel_url: z.string().max(250).optional(), + pass_thru_content: z.string().max(2048).optional(), + iframe_messaging: z.boolean().default(false).optional(), + customer: UpdatePaymentMethodHostedPageCustomerSchema.optional(), + card: UpdatePaymentMethodHostedPageCardSchema.optional(), + embed: z.boolean().default(true).optional(), +}); +export { UpdatePaymentMethodHostedPageBodySchema }; +export type UpdatePaymentMethodHostedPageBody = z.infer< + typeof UpdatePaymentMethodHostedPageBodySchema +>; + +//HostedPage.managePaymentSources + +const ManagePaymentSourcesHostedPageCustomerSchema = z.object({ + id: z.string().max(50), +}); +const ManagePaymentSourcesHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const ManagePaymentSourcesHostedPageBodySchema = z.looseObject({ + business_entity_id: z.string().max(50).optional(), + redirect_url: z.string().max(250).optional(), + customer: ManagePaymentSourcesHostedPageCustomerSchema.optional(), + card: ManagePaymentSourcesHostedPageCardSchema.optional(), +}); +export { ManagePaymentSourcesHostedPageBodySchema }; +export type ManagePaymentSourcesHostedPageBody = z.infer< + typeof ManagePaymentSourcesHostedPageBodySchema +>; + +//HostedPage.collectNow + +const CollectNowHostedPageCustomerSchema = z.object({ + id: z.string().max(50), +}); +const CollectNowHostedPageCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), +}); +const CollectNowHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + currency_code: z.string().max(3).optional(), + payment_method_save_policy: z.enum(['always', 'ask', 'never']).optional(), + customer: CollectNowHostedPageCustomerSchema.optional(), + card: CollectNowHostedPageCardSchema.optional(), +}); +export { CollectNowHostedPageBodySchema }; +export type CollectNowHostedPageBody = z.infer< + typeof CollectNowHostedPageBodySchema +>; + +//HostedPage.acceptQuote + +const AcceptQuoteHostedPageQuoteSchema = z.object({ + id: z.string().max(50), +}); +const AcceptQuoteHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + layout: z.enum(['in_app', 'full_page']).optional(), + quote: AcceptQuoteHostedPageQuoteSchema.optional(), +}); +export { AcceptQuoteHostedPageBodySchema }; +export type AcceptQuoteHostedPageBody = z.infer< + typeof AcceptQuoteHostedPageBodySchema +>; + +//HostedPage.extendSubscription + +const ExtendSubscriptionHostedPageSubscriptionSchema = z.object({ + id: z.string().max(50), +}); +const ExtendSubscriptionHostedPageBodySchema = z.looseObject({ + expiry: z.number().int().min(1).max(500).optional(), + billing_cycle: z.number().int().min(1).optional(), + subscription: ExtendSubscriptionHostedPageSubscriptionSchema.optional(), +}); +export { ExtendSubscriptionHostedPageBodySchema }; +export type ExtendSubscriptionHostedPageBody = z.infer< + typeof ExtendSubscriptionHostedPageBodySchema +>; + +//HostedPage.checkoutGift + +const CheckoutGiftHostedPageGifterSchema = z.object({ + customer_id: z.string().max(50).optional(), +}); +const CheckoutGiftHostedPageSubscriptionSchema = z.looseObject({ + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + coupon: z.string().max(100).optional(), +}); +const CheckoutGiftHostedPageAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), +}); +const CheckoutGiftHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + gifter: CheckoutGiftHostedPageGifterSchema.optional(), + subscription: CheckoutGiftHostedPageSubscriptionSchema.optional(), + addons: CheckoutGiftHostedPageAddonsSchema.optional(), +}); +export { CheckoutGiftHostedPageBodySchema }; +export type CheckoutGiftHostedPageBody = z.infer< + typeof CheckoutGiftHostedPageBodySchema +>; + +//HostedPage.checkoutGiftForItems + +const CheckoutGiftForItemsHostedPageGifterSchema = z.object({ + customer_id: z.string().max(50).optional(), +}); +const CheckoutGiftForItemsHostedPageSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CheckoutGiftForItemsHostedPageItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CheckoutGiftForItemsHostedPageBodySchema = z.looseObject({ + business_entity_id: z.string().max(50).optional(), + redirect_url: z.string().max(250).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + gifter: CheckoutGiftForItemsHostedPageGifterSchema.optional(), + subscription_items: + CheckoutGiftForItemsHostedPageSubscriptionItemsSchema.optional(), + item_tiers: CheckoutGiftForItemsHostedPageItemTiersSchema.optional(), +}); +export { CheckoutGiftForItemsHostedPageBodySchema }; +export type CheckoutGiftForItemsHostedPageBody = z.infer< + typeof CheckoutGiftForItemsHostedPageBodySchema +>; + +//HostedPage.claimGift + +const ClaimGiftHostedPageGiftSchema = z.object({ + id: z.string().max(150), +}); +const ClaimGiftHostedPageCustomerSchema = z.object({ + locale: z.string().max(50).optional(), +}); +const ClaimGiftHostedPageBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + gift: ClaimGiftHostedPageGiftSchema.optional(), + customer: ClaimGiftHostedPageCustomerSchema.optional(), +}); +export { ClaimGiftHostedPageBodySchema }; +export type ClaimGiftHostedPageBody = z.infer< + typeof ClaimGiftHostedPageBodySchema +>; + +//HostedPage.retrieveAgreementPdf + +const RetrieveAgreementPdfHostedPageBodySchema = z.looseObject({ + payment_source_id: z.string().max(40), +}); +export { RetrieveAgreementPdfHostedPageBodySchema }; +export type RetrieveAgreementPdfHostedPageBody = z.infer< + typeof RetrieveAgreementPdfHostedPageBodySchema +>; + +//HostedPage.preCancel + +const PreCancelHostedPageSubscriptionSchema = z.object({ + id: z.string().max(50), +}); +const PreCancelHostedPageBodySchema = z.looseObject({ + pass_thru_content: z.string().max(2048).optional(), + cancel_url: z.string().max(250).optional(), + redirect_url: z.string().max(250).optional(), + subscription: PreCancelHostedPageSubscriptionSchema.optional(), +}); +export { PreCancelHostedPageBodySchema }; +export type PreCancelHostedPageBody = z.infer< + typeof PreCancelHostedPageBodySchema +>; + +//HostedPage.events + +const EventsHostedPageEventDataSchema = z.looseObject({}); +const EventsHostedPageBodySchema = z.looseObject({ + event_name: z.enum(['cancellation_page_loaded']), + occurred_at: z.number().int().optional(), + event_data: EventsHostedPageEventDataSchema, +}); +export { EventsHostedPageBodySchema }; +export type EventsHostedPageBody = z.infer; + +//HostedPage.viewVoucher + +const ViewVoucherHostedPagePaymentVoucherSchema = z.object({ + id: z.string().max(40), +}); +const ViewVoucherHostedPageCustomerSchema = z.object({ + locale: z.string().max(50).optional(), +}); +const ViewVoucherHostedPageBodySchema = z.looseObject({ + payment_voucher: ViewVoucherHostedPagePaymentVoucherSchema.optional(), + customer: ViewVoucherHostedPageCustomerSchema.optional(), +}); +export { ViewVoucherHostedPageBodySchema }; +export type ViewVoucherHostedPageBody = z.infer< + typeof ViewVoucherHostedPageBodySchema +>; diff --git a/src/schema/in_app_subscription.schema.ts b/src/schema/in_app_subscription.schema.ts new file mode 100644 index 0000000..c248234 --- /dev/null +++ b/src/schema/in_app_subscription.schema.ts @@ -0,0 +1,87 @@ +// Generated Zod schemas: InAppSubscription +// Actions: processReceipt, importReceipt, importSubscription, retrieveStoreSubs +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//InAppSubscription.processReceipt + +const ProcessReceiptInAppSubscriptionProductSchema = z.object({ + id: z.string().max(96), + currency_code: z.string().max(3), + price: z.number().int().min(0), + name: z.string().max(46).optional(), + price_in_decimal: z.string().max(39).optional(), + period: z.string().max(3).optional(), + period_unit: z.string().max(3).optional(), +}); +const ProcessReceiptInAppSubscriptionCustomerSchema = z.object({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), +}); +const ProcessReceiptInAppSubscriptionBodySchema = z.looseObject({ + receipt: z.string().max(65000), + product: ProcessReceiptInAppSubscriptionProductSchema.optional(), + customer: ProcessReceiptInAppSubscriptionCustomerSchema.optional(), +}); +export { ProcessReceiptInAppSubscriptionBodySchema }; +export type ProcessReceiptInAppSubscriptionBody = z.infer< + typeof ProcessReceiptInAppSubscriptionBodySchema +>; + +//InAppSubscription.importReceipt + +const ImportReceiptInAppSubscriptionProductSchema = z.object({ + currency_code: z.string().max(3), +}); +const ImportReceiptInAppSubscriptionCustomerSchema = z.object({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), +}); +const ImportReceiptInAppSubscriptionBodySchema = z.looseObject({ + receipt: z.string().max(65000), + product: ImportReceiptInAppSubscriptionProductSchema.optional(), + customer: ImportReceiptInAppSubscriptionCustomerSchema.optional(), +}); +export { ImportReceiptInAppSubscriptionBodySchema }; +export type ImportReceiptInAppSubscriptionBody = z.infer< + typeof ImportReceiptInAppSubscriptionBodySchema +>; + +//InAppSubscription.importSubscription + +const ImportSubscriptionInAppSubscriptionSubscriptionSchema = z.object({ + id: z.string().max(50), + started_at: z.number().int(), + term_start: z.number().int(), + term_end: z.number().int(), + product_id: z.string().max(96), + currency_code: z.string().max(3), + transaction_id: z.string().max(43), + is_trial: z.boolean().default(false).optional(), +}); +const ImportSubscriptionInAppSubscriptionCustomerSchema = z.object({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), +}); +const ImportSubscriptionInAppSubscriptionBodySchema = z.looseObject({ + subscription: + ImportSubscriptionInAppSubscriptionSubscriptionSchema.optional(), + customer: ImportSubscriptionInAppSubscriptionCustomerSchema.optional(), +}); +export { ImportSubscriptionInAppSubscriptionBodySchema }; +export type ImportSubscriptionInAppSubscriptionBody = z.infer< + typeof ImportSubscriptionInAppSubscriptionBodySchema +>; + +//InAppSubscription.retrieveStoreSubs + +const RetrieveStoreSubsInAppSubscriptionBodySchema = z.looseObject({ + receipt: z.string().max(65000), +}); +export { RetrieveStoreSubsInAppSubscriptionBodySchema }; +export type RetrieveStoreSubsInAppSubscriptionBody = z.infer< + typeof RetrieveStoreSubsInAppSubscriptionBodySchema +>; diff --git a/src/schema/index.ts b/src/schema/index.ts new file mode 100644 index 0000000..3938ec0 --- /dev/null +++ b/src/schema/index.ts @@ -0,0 +1,64 @@ +// Auto-generated barrel export for Zod validators +export * from './addon.schema.js'; +export * from './address.schema.js'; +export * from './alert.schema.js'; +export * from './attached_item.schema.js'; +export * from './business_entity.schema.js'; +export * from './card.schema.js'; +export * from './comment.schema.js'; +export * from './coupon.schema.js'; +export * from './coupon_code.schema.js'; +export * from './coupon_set.schema.js'; +export * from './credit_note.schema.js'; +export * from './currency.schema.js'; +export * from './customer.schema.js'; +export * from './customer_entitlement.schema.js'; +export * from './differential_price.schema.js'; +export * from './entitlement.schema.js'; +export * from './entitlement_override.schema.js'; +export * from './estimate.schema.js'; +export * from './export.schema.js'; +export * from './feature.schema.js'; +export * from './gift.schema.js'; +export * from './hosted_page.schema.js'; +export * from './in_app_subscription.schema.js'; +export * from './invoice.schema.js'; +export * from './item.schema.js'; +export * from './item_entitlement.schema.js'; +export * from './item_family.schema.js'; +export * from './item_price.schema.js'; +export * from './non_subscription.schema.js'; +export * from './offer_event.schema.js'; +export * from './offer_fulfillment.schema.js'; +export * from './omnichannel_one_time_order.schema.js'; +export * from './omnichannel_subscription.schema.js'; +export * from './omnichannel_subscription_item.schema.js'; +export * from './order.schema.js'; +export * from './payment_intent.schema.js'; +export * from './payment_schedule_scheme.schema.js'; +export * from './payment_source.schema.js'; +export * from './payment_voucher.schema.js'; +export * from './personalized_offer.schema.js'; +export * from './plan.schema.js'; +export * from './portal_session.schema.js'; +export * from './price_variant.schema.js'; +export * from './pricing_page_session.schema.js'; +export * from './promotional_credit.schema.js'; +export * from './purchase.schema.js'; +export * from './quote.schema.js'; +export * from './ramp.schema.js'; +export * from './recorded_purchase.schema.js'; +export * from './resource_migration.schema.js'; +export * from './site_migration_detail.schema.js'; +export * from './subscription.schema.js'; +export * from './subscription_entitlement.schema.js'; +export * from './time_machine.schema.js'; +export * from './transaction.schema.js'; +export * from './unbilled_charge.schema.js'; +export * from './usage.schema.js'; +export * from './usage_charge.schema.js'; +export * from './usage_event.schema.js'; +export * from './usage_file.schema.js'; +export * from './usage_summary.schema.js'; +export * from './virtual_bank_account.schema.js'; +export * from './webhook_endpoint.schema.js'; diff --git a/src/schema/invoice.schema.ts b/src/schema/invoice.schema.ts new file mode 100644 index 0000000..7c57682 --- /dev/null +++ b/src/schema/invoice.schema.ts @@ -0,0 +1,1652 @@ +// Generated Zod schemas: Invoice +// Actions: create, createForChargeItemsAndCharges, charge, chargeAddon, createForChargeItem, stopDunning, pauseDunning, resumeDunning, importInvoice, applyPayments, deleteLineItems, applyCredits, invoicesForCustomer, invoicesForSubscription, retrieve, pdf, addCharge, addAddonCharge, addChargeItem, close, collectPayment, recordPayment, recordTaxWithheld, removeTaxWithheld, refund, recordRefund, removePayment, removeCreditNote, voidInvoice, writeOff, delete, updateDetails, applyPaymentScheduleScheme +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Invoice.create + +const CreateInvoiceShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateInvoiceStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const CreateInvoiceAdditionalInformationSchema = z.looseObject({}); +const CreateInvoiceCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: CreateInvoiceAdditionalInformationSchema.optional(), +}); +const CreateInvoiceBillingAddressSchema = z.looseObject({}); +const CreateInvoiceBankAccountSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + iban: z.string().max(50).min(10).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + bank_name: z.string().max(100).optional(), + account_number: z.string().max(17).min(4).optional(), + routing_number: z.string().max(9).min(3).optional(), + bank_code: z.string().max(20).optional(), + account_type: z + .enum(['checking', 'savings', 'business_checking', 'current']) + .optional(), + account_holder_type: z.enum(['individual', 'company']).optional(), + echeck_type: z.enum(['web', 'ppd', 'ccd']).optional(), + issuing_country: z.string().max(50).optional(), + swedish_identity_number: z.string().max(12).min(10).optional(), + billing_address: CreateInvoiceBillingAddressSchema.optional(), +}); +const CreateInvoicePaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: CreateInvoiceAdditionalInformationSchema.optional(), +}); +const CreateInvoicePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: CreateInvoiceAdditionalInformationSchema.optional(), +}); +const CreateInvoiceAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateInvoiceTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateInvoiceNotesToRemoveSchema = z.object({ + entity_type: z + .array( + z + .enum(['plan', 'addon', 'customer', 'subscription', 'coupon']) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateInvoiceBodySchema = z.looseObject({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + currency_code: z.string().max(3).optional(), + invoice_date: z.number().int().optional(), + invoice_note: z.string().max(2000).optional(), + remove_general_note: z.boolean().default(false).optional(), + po_number: z.string().max(100).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + authorization_transaction_id: z.string().max(40).optional(), + payment_source_id: z.string().max(40).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + token_id: z.string().max(40).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + retain_payment_source: z.boolean().default(true).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + shipping_address: CreateInvoiceShippingAddressSchema.optional(), + statement_descriptor: CreateInvoiceStatementDescriptorSchema.optional(), + card: CreateInvoiceCardSchema.optional(), + bank_account: CreateInvoiceBankAccountSchema.optional(), + payment_method: CreateInvoicePaymentMethodSchema.optional(), + payment_intent: CreateInvoicePaymentIntentSchema.optional(), + addons: CreateInvoiceAddonsSchema.optional(), + charges: CreateInvoiceChargesSchema.optional(), + tax_providers_fields: CreateInvoiceTaxProvidersFieldsSchema.optional(), + notes_to_remove: CreateInvoiceNotesToRemoveSchema.optional(), +}); +export { CreateInvoiceBodySchema }; +export type CreateInvoiceBody = z.infer; + +//Invoice.createForChargeItemsAndCharges + +const CreateForChargeItemsAndChargesInvoiceShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForChargeItemsAndChargesInvoiceStatementDescriptorSchema = z.object( + { + descriptor: z.string().max(65000).optional(), + }, +); +const CreateForChargeItemsAndChargesInvoiceAdditionalInformationSchema = + z.looseObject({}); +const CreateForChargeItemsAndChargesInvoiceCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: + CreateForChargeItemsAndChargesInvoiceAdditionalInformationSchema.optional(), +}); +const CreateForChargeItemsAndChargesInvoiceBillingAddressSchema = z.looseObject( + {}, +); +const CreateForChargeItemsAndChargesInvoiceBankAccountSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + iban: z.string().max(50).min(10).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + bank_name: z.string().max(100).optional(), + account_number: z.string().max(17).min(4).optional(), + routing_number: z.string().max(9).min(3).optional(), + bank_code: z.string().max(20).optional(), + account_type: z + .enum(['checking', 'savings', 'business_checking', 'current']) + .optional(), + account_holder_type: z.enum(['individual', 'company']).optional(), + echeck_type: z.enum(['web', 'ppd', 'ccd']).optional(), + issuing_country: z.string().max(50).optional(), + swedish_identity_number: z.string().max(12).min(10).optional(), + billing_address: + CreateForChargeItemsAndChargesInvoiceBillingAddressSchema.optional(), +}); +const CreateForChargeItemsAndChargesInvoicePaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + CreateForChargeItemsAndChargesInvoiceAdditionalInformationSchema.optional(), +}); +const CreateForChargeItemsAndChargesInvoicePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + CreateForChargeItemsAndChargesInvoiceAdditionalInformationSchema.optional(), +}); +const CreateForChargeItemsAndChargesInvoiceItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceNotesToRemoveSchema = z.object({ + entity_type: z + .array( + z + .enum([ + 'customer', + 'subscription', + 'coupon', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceDiscountsSchema = z.object({ + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateForChargeItemsAndChargesInvoiceBodySchema = z.looseObject({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + currency_code: z.string().max(3).optional(), + invoice_note: z.string().max(2000).optional(), + remove_general_note: z.boolean().default(false).optional(), + po_number: z.string().max(100).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + authorization_transaction_id: z.string().max(40).optional(), + payment_source_id: z.string().max(40).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + net_term_days: z.number().int().optional(), + invoice_date: z.number().int().optional(), + token_id: z.string().max(40).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + retain_payment_source: z.boolean().default(true).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + shipping_address: + CreateForChargeItemsAndChargesInvoiceShippingAddressSchema.optional(), + statement_descriptor: + CreateForChargeItemsAndChargesInvoiceStatementDescriptorSchema.optional(), + card: CreateForChargeItemsAndChargesInvoiceCardSchema.optional(), + bank_account: + CreateForChargeItemsAndChargesInvoiceBankAccountSchema.optional(), + payment_method: + CreateForChargeItemsAndChargesInvoicePaymentMethodSchema.optional(), + payment_intent: + CreateForChargeItemsAndChargesInvoicePaymentIntentSchema.optional(), + item_prices: CreateForChargeItemsAndChargesInvoiceItemPricesSchema.optional(), + item_tiers: CreateForChargeItemsAndChargesInvoiceItemTiersSchema.optional(), + charges: CreateForChargeItemsAndChargesInvoiceChargesSchema.optional(), + notes_to_remove: + CreateForChargeItemsAndChargesInvoiceNotesToRemoveSchema.optional(), + tax_providers_fields: + CreateForChargeItemsAndChargesInvoiceTaxProvidersFieldsSchema.optional(), + discounts: CreateForChargeItemsAndChargesInvoiceDiscountsSchema.optional(), +}); +export { CreateForChargeItemsAndChargesInvoiceBodySchema }; +export type CreateForChargeItemsAndChargesInvoiceBody = z.infer< + typeof CreateForChargeItemsAndChargesInvoiceBodySchema +>; + +//Invoice.charge + +const ChargeInvoiceTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const ChargeInvoiceBodySchema = z.looseObject({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + currency_code: z.string().max(3).optional(), + amount: z.number().int().min(1).optional(), + amount_in_decimal: z.string().max(39).optional(), + description: z.string().max(250), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + coupon: z.string().max(100).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + po_number: z.string().max(100).optional(), + invoice_date: z.number().int().optional(), + payment_source_id: z.string().max(40).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + tax_providers_fields: ChargeInvoiceTaxProvidersFieldsSchema.optional(), +}); +export { ChargeInvoiceBodySchema }; +export type ChargeInvoiceBody = z.infer; + +//Invoice.chargeAddon + +const ChargeAddonInvoiceBodySchema = z.looseObject({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + addon_id: z.string().max(100), + addon_quantity: z.number().int().min(1).optional(), + addon_unit_price: z.number().int().min(0).optional(), + addon_quantity_in_decimal: z.string().max(33).optional(), + addon_unit_price_in_decimal: z.string().max(39).optional(), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + coupon: z.string().max(100).optional(), + po_number: z.string().max(100).optional(), + invoice_date: z.number().int().optional(), + payment_source_id: z.string().max(40).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), +}); +export { ChargeAddonInvoiceBodySchema }; +export type ChargeAddonInvoiceBody = z.infer< + typeof ChargeAddonInvoiceBodySchema +>; + +//Invoice.createForChargeItem + +const CreateForChargeItemInvoiceItemPriceSchema = z.object({ + item_price_id: z.string().max(100), + quantity: z.number().int().min(1).optional(), + quantity_in_decimal: z.string().max(33).optional(), + unit_price: z.number().int().min(0).optional(), + unit_price_in_decimal: z.string().max(39).optional(), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +const CreateForChargeItemInvoiceItemTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateForChargeItemInvoiceBodySchema = z.looseObject({ + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + coupon: z.string().max(100).optional(), + payment_source_id: z.string().max(40).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + invoice_date: z.number().int().optional(), + item_price: CreateForChargeItemInvoiceItemPriceSchema.optional(), + item_tiers: CreateForChargeItemInvoiceItemTiersSchema.optional(), +}); +export { CreateForChargeItemInvoiceBodySchema }; +export type CreateForChargeItemInvoiceBody = z.infer< + typeof CreateForChargeItemInvoiceBodySchema +>; + +//Invoice.stopDunning + +const StopDunningInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { StopDunningInvoiceBodySchema }; +export type StopDunningInvoiceBody = z.infer< + typeof StopDunningInvoiceBodySchema +>; + +//Invoice.pauseDunning + +const PauseDunningInvoiceBodySchema = z.looseObject({ + expected_payment_date: z.number().int(), + comment: z.string().max(300).optional(), +}); +export { PauseDunningInvoiceBodySchema }; +export type PauseDunningInvoiceBody = z.infer< + typeof PauseDunningInvoiceBodySchema +>; + +//Invoice.resumeDunning + +const ResumeDunningInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { ResumeDunningInvoiceBodySchema }; +export type ResumeDunningInvoiceBody = z.infer< + typeof ResumeDunningInvoiceBodySchema +>; + +//Invoice.importInvoice + +const ImportInvoiceInvoiceCreditNoteSchema = z.object({ + id: z.string().max(50).optional(), +}); +const ImportInvoiceInvoiceBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportInvoiceInvoiceShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportInvoiceInvoiceLineItemsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), + subscription_id: z.array(z.string().max(50).optional()).optional(), + description: z.array(z.string().max(250).optional()), + unit_amount: z.array(z.number().int().optional()).optional(), + quantity: z.array(z.number().int().optional()).optional(), + amount: z.array(z.number().int().optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + entity_type: z + .array( + z + .enum([ + 'adhoc', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan_setup', + 'plan', + 'addon', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), + item_level_discount1_entity_id: z + .array(z.string().max(100).optional()) + .optional(), + item_level_discount1_amount: z + .array(z.number().int().min(0).optional()) + .optional(), + item_level_discount2_entity_id: z + .array(z.string().max(100).optional()) + .optional(), + item_level_discount2_amount: z + .array(z.number().int().min(0).optional()) + .optional(), + tax1_name: z.array(z.string().max(50).optional()).optional(), + tax1_amount: z.array(z.number().int().min(0).optional()).optional(), + tax2_name: z.array(z.string().max(50).optional()).optional(), + tax2_amount: z.array(z.number().int().min(0).optional()).optional(), + tax3_name: z.array(z.string().max(50).optional()).optional(), + tax3_amount: z.array(z.number().int().min(0).optional()).optional(), + tax4_name: z.array(z.string().max(50).optional()).optional(), + tax4_amount: z.array(z.number().int().min(0).optional()).optional(), + tax5_name: z.array(z.string().max(50).optional()).optional(), + tax5_amount: z.array(z.number().int().min(0).optional()).optional(), + tax6_name: z.array(z.string().max(50).optional()).optional(), + tax6_amount: z.array(z.number().int().min(0).optional()).optional(), + tax7_name: z.array(z.string().max(50).optional()).optional(), + tax7_amount: z.array(z.number().int().min(0).optional()).optional(), + tax8_name: z.array(z.string().max(50).optional()).optional(), + tax8_amount: z.array(z.number().int().min(0).optional()).optional(), + tax9_name: z.array(z.string().max(50).optional()).optional(), + tax9_amount: z.array(z.number().int().min(0).optional()).optional(), + tax10_name: z.array(z.string().max(50).optional()).optional(), + tax10_amount: z.array(z.number().int().min(0).optional()).optional(), + created_at: z.array(z.number().int().optional()).optional(), +}); +const ImportInvoiceInvoicePaymentReferenceNumbersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + type: z.array( + z.enum(['kid', 'ocr', 'frn', 'fik', 'swiss_reference']).optional(), + ), + number: z.array(z.string().max(100).optional()), +}); +const ImportInvoiceInvoiceLineItemTiersSchema = z.object({ + line_item_id: z.array(z.string().max(40).optional()), + starting_unit: z.array(z.number().int().min(0).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + quantity_used: z.array(z.number().int().min(0).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + quantity_used_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(40).optional()).optional(), +}); +const ImportInvoiceInvoiceDiscountsSchema = z.object({ + line_item_id: z.array(z.string().max(40).optional()).optional(), + entity_type: z.array( + z + .enum([ + 'item_level_coupon', + 'document_level_coupon', + 'promotional_credits', + 'item_level_discount', + 'document_level_discount', + ]) + .optional(), + ), + entity_id: z.array(z.string().max(100).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()), +}); +const ImportInvoiceInvoiceTaxesSchema = z.object({ + name: z.array(z.string().max(100).optional()), + rate: z.array(z.number().min(0).max(100).optional()), + amount: z.array(z.number().int().min(0).optional()).optional(), + description: z.array(z.string().max(50).optional()).optional(), + juris_type: z + .array( + z + .enum([ + 'country', + 'federal', + 'state', + 'county', + 'city', + 'special', + 'unincorporated', + 'other', + ]) + .optional(), + ) + .optional(), + juris_name: z.array(z.string().max(250).optional()).optional(), + juris_code: z.array(z.string().max(250).optional()).optional(), +}); +const ImportInvoiceInvoicePaymentsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + amount: z.array(z.number().int().min(1).optional()), + payment_method: z.array( + z + .enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]) + .optional(), + ), + date: z.array(z.number().int().optional()).optional(), + reference_number: z.array(z.string().max(100).min(1).optional()).optional(), +}); +const ImportInvoiceInvoiceNotesSchema = z.object({ + entity_type: z + .array( + z + .enum([ + 'coupon', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan', + 'addon', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(50).optional()).optional(), + note: z.array(z.string().max(65000).optional()).optional(), +}); +const ImportInvoiceInvoiceLineItemAddressesSchema = z.object({ + line_item_id: z.array(z.string().max(40).optional()).optional(), + first_name: z.array(z.string().max(150).optional()).optional(), + last_name: z.array(z.string().max(150).optional()).optional(), + email: z.array(z.string().email().max(70).optional()).optional(), + company: z.array(z.string().max(250).optional()).optional(), + phone: z.array(z.string().max(50).optional()).optional(), + line1: z.array(z.string().max(150).optional()).optional(), + line2: z.array(z.string().max(150).optional()).optional(), + line3: z.array(z.string().max(150).optional()).optional(), + city: z.array(z.string().max(50).optional()).optional(), + state_code: z.array(z.string().max(50).optional()).optional(), + state: z.array(z.string().max(50).optional()).optional(), + zip: z.array(z.string().max(20).optional()).optional(), + country: z.array(z.string().max(50).optional()).optional(), + validation_status: z + .array( + z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), + ) + .optional(), +}); +const ImportInvoiceInvoiceBodySchema = z.looseObject({ + id: z.string().max(50), + currency_code: z.string().max(3).optional(), + customer_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + price_type: z.enum(['tax_exclusive', 'tax_inclusive']).optional(), + tax_override_reason: z + .enum(['id_exempt', 'customer_exempt', 'export']) + .optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + date: z.number().int(), + total: z.number().int().min(0), + round_off: z.number().int().min(-99).max(99).optional(), + status: z + .enum(['paid', 'posted', 'payment_due', 'not_paid', 'voided', 'pending']) + .optional(), + voided_at: z.number().int().optional(), + void_reason_code: z.string().max(100).optional(), + is_written_off: z.boolean().default(false).optional(), + write_off_amount: z.number().int().min(0).optional(), + write_off_date: z.number().int().optional(), + due_date: z.number().int().optional(), + net_term_days: z.number().int().optional(), + has_advance_charges: z.boolean().default(false).optional(), + use_for_proration: z.boolean().default(false).optional(), + credit_note: ImportInvoiceInvoiceCreditNoteSchema.optional(), + billing_address: ImportInvoiceInvoiceBillingAddressSchema.optional(), + shipping_address: ImportInvoiceInvoiceShippingAddressSchema.optional(), + line_items: ImportInvoiceInvoiceLineItemsSchema.optional(), + payment_reference_numbers: + ImportInvoiceInvoicePaymentReferenceNumbersSchema.optional(), + line_item_tiers: ImportInvoiceInvoiceLineItemTiersSchema.optional(), + discounts: ImportInvoiceInvoiceDiscountsSchema.optional(), + taxes: ImportInvoiceInvoiceTaxesSchema.optional(), + payments: ImportInvoiceInvoicePaymentsSchema.optional(), + notes: ImportInvoiceInvoiceNotesSchema.optional(), + line_item_addresses: ImportInvoiceInvoiceLineItemAddressesSchema.optional(), +}); +export { ImportInvoiceInvoiceBodySchema }; +export type ImportInvoiceInvoiceBody = z.infer< + typeof ImportInvoiceInvoiceBodySchema +>; + +//Invoice.applyPayments + +const ApplyPaymentsInvoiceTransactionsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), +}); +const ApplyPaymentsInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + transactions: ApplyPaymentsInvoiceTransactionsSchema.optional(), +}); +export { ApplyPaymentsInvoiceBodySchema }; +export type ApplyPaymentsInvoiceBody = z.infer< + typeof ApplyPaymentsInvoiceBodySchema +>; + +//Invoice.deleteLineItems + +const DeleteLineItemsInvoiceLineItemsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), +}); +const DeleteLineItemsInvoiceBodySchema = z.looseObject({ + line_items: DeleteLineItemsInvoiceLineItemsSchema.optional(), +}); +export { DeleteLineItemsInvoiceBodySchema }; +export type DeleteLineItemsInvoiceBody = z.infer< + typeof DeleteLineItemsInvoiceBodySchema +>; + +//Invoice.applyCredits + +const ApplyCreditsInvoiceCreditNotesSchema = z.object({ + id: z.array(z.string().max(50).optional()).optional(), +}); +const ApplyCreditsInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + credit_notes: ApplyCreditsInvoiceCreditNotesSchema.optional(), +}); +export { ApplyCreditsInvoiceBodySchema }; +export type ApplyCreditsInvoiceBody = z.infer< + typeof ApplyCreditsInvoiceBodySchema +>; + +//Invoice.invoicesForCustomer + +const InvoicesForCustomerInvoiceBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { InvoicesForCustomerInvoiceBodySchema }; +export type InvoicesForCustomerInvoiceBody = z.infer< + typeof InvoicesForCustomerInvoiceBodySchema +>; + +//Invoice.invoicesForSubscription + +const InvoicesForSubscriptionInvoiceBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { InvoicesForSubscriptionInvoiceBodySchema }; +export type InvoicesForSubscriptionInvoiceBody = z.infer< + typeof InvoicesForSubscriptionInvoiceBodySchema +>; + +//Invoice.retrieve + +const RetrieveInvoiceSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const RetrieveInvoiceCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const RetrieveInvoiceLineItemSchema = z.object({ + subscription_id: RetrieveInvoiceSubscriptionIdSchema.optional(), + customer_id: RetrieveInvoiceCustomerIdSchema.optional(), +}); +const RetrieveInvoiceBodySchema = z.looseObject({ + line_items_limit: z.number().int().min(1).max(300).optional(), + line_items_offset: z.string().max(1000).optional(), + line_item: RetrieveInvoiceLineItemSchema.optional(), +}); +export { RetrieveInvoiceBodySchema }; +export type RetrieveInvoiceBody = z.infer; + +//Invoice.pdf + +const PdfInvoiceBodySchema = z.looseObject({ + disposition_type: z.enum(['attachment', 'inline']).optional(), +}); +export { PdfInvoiceBodySchema }; +export type PdfInvoiceBody = z.infer; + +//Invoice.addCharge + +const AddChargeInvoiceLineItemSchema = z.object({ + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +const AddChargeInvoiceBodySchema = z.looseObject({ + amount: z.number().int().min(1), + description: z.string().max(250), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + avalara_tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + taxjar_product_code: z.string().max(50).optional(), + comment: z.string().max(300).optional(), + subscription_id: z.string().max(50).optional(), + line_item: AddChargeInvoiceLineItemSchema.optional(), +}); +export { AddChargeInvoiceBodySchema }; +export type AddChargeInvoiceBody = z.infer; + +//Invoice.addAddonCharge + +const AddAddonChargeInvoiceLineItemSchema = z.object({ + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +const AddAddonChargeInvoiceBodySchema = z.looseObject({ + addon_id: z.string().max(100), + addon_quantity: z.number().int().min(1).optional(), + addon_unit_price: z.number().int().min(0).optional(), + addon_quantity_in_decimal: z.string().max(33).optional(), + addon_unit_price_in_decimal: z.string().max(39).optional(), + comment: z.string().max(300).optional(), + subscription_id: z.string().max(50).optional(), + line_item: AddAddonChargeInvoiceLineItemSchema.optional(), +}); +export { AddAddonChargeInvoiceBodySchema }; +export type AddAddonChargeInvoiceBody = z.infer< + typeof AddAddonChargeInvoiceBodySchema +>; + +//Invoice.addChargeItem + +const AddChargeItemInvoiceItemPriceSchema = z.object({ + item_price_id: z.string().max(100), + quantity: z.number().int().min(1).optional(), + quantity_in_decimal: z.string().max(33).optional(), + unit_price: z.number().int().min(0).optional(), + unit_price_in_decimal: z.string().max(39).optional(), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +const AddChargeItemInvoiceItemTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const AddChargeItemInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + subscription_id: z.string().max(50).optional(), + item_price: AddChargeItemInvoiceItemPriceSchema.optional(), + item_tiers: AddChargeItemInvoiceItemTiersSchema.optional(), +}); +export { AddChargeItemInvoiceBodySchema }; +export type AddChargeItemInvoiceBody = z.infer< + typeof AddChargeItemInvoiceBodySchema +>; + +//Invoice.close + +const CloseInvoiceNotesToRemoveSchema = z.object({ + entity_type: z + .array( + z + .enum([ + 'customer', + 'subscription', + 'coupon', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan', + 'addon', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), +}); +const CloseInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + invoice_note: z.string().max(2000).optional(), + remove_general_note: z.boolean().default(false).optional(), + invoice_date: z.number().int().optional(), + notes_to_remove: CloseInvoiceNotesToRemoveSchema.optional(), +}); +export { CloseInvoiceBodySchema }; +export type CloseInvoiceBody = z.infer; + +//Invoice.collectPayment + +const CollectPaymentInvoiceBodySchema = z.looseObject({ + amount: z.number().int().min(1).optional(), + authorization_transaction_id: z.string().max(40).optional(), + payment_source_id: z.string().max(40).optional(), + comment: z.string().max(300).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), +}); +export { CollectPaymentInvoiceBodySchema }; +export type CollectPaymentInvoiceBody = z.infer< + typeof CollectPaymentInvoiceBodySchema +>; + +//Invoice.recordPayment + +const RecordPaymentInvoiceTransactionSchema = z.object({ + amount: z.number().int().min(0).optional(), + payment_method: z.enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]), + reference_number: z.string().max(100).optional(), + custom_payment_method_id: z.string().max(50).optional(), + id_at_gateway: z.string().max(100).optional(), + status: z.enum(['success', 'failure', 'late_failure']).optional(), + date: z.number().int().optional(), + error_code: z.string().max(100).optional(), + error_text: z.string().max(65000).optional(), +}); +const RecordPaymentInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + transaction: RecordPaymentInvoiceTransactionSchema.optional(), +}); +export { RecordPaymentInvoiceBodySchema }; +export type RecordPaymentInvoiceBody = z.infer< + typeof RecordPaymentInvoiceBodySchema +>; + +//Invoice.recordTaxWithheld + +const RecordTaxWithheldInvoiceTaxWithheldSchema = z.object({ + amount: z.number().int().min(1), + reference_number: z.string().max(100).optional(), + date: z.number().int().optional(), + description: z.string().max(65000).optional(), +}); +const RecordTaxWithheldInvoiceBodySchema = z.looseObject({ + tax_withheld: RecordTaxWithheldInvoiceTaxWithheldSchema.optional(), +}); +export { RecordTaxWithheldInvoiceBodySchema }; +export type RecordTaxWithheldInvoiceBody = z.infer< + typeof RecordTaxWithheldInvoiceBodySchema +>; + +//Invoice.removeTaxWithheld + +const RemoveTaxWithheldInvoiceTaxWithheldSchema = z.object({ + id: z.string().max(40), +}); +const RemoveTaxWithheldInvoiceBodySchema = z.looseObject({ + tax_withheld: RemoveTaxWithheldInvoiceTaxWithheldSchema.optional(), +}); +export { RemoveTaxWithheldInvoiceBodySchema }; +export type RemoveTaxWithheldInvoiceBody = z.infer< + typeof RemoveTaxWithheldInvoiceBodySchema +>; + +//Invoice.refund + +const RefundInvoiceCreditNoteSchema = z.object({ + reason_code: z + .enum([ + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + ]) + .optional(), + create_reason_code: z.string().max(100).optional(), +}); +const RefundInvoiceBodySchema = z.looseObject({ + refund_amount: z.number().int().min(1).optional(), + comment: z.string().max(300).optional(), + customer_notes: z.string().max(2000).optional(), + credit_note: RefundInvoiceCreditNoteSchema.optional(), +}); +export { RefundInvoiceBodySchema }; +export type RefundInvoiceBody = z.infer; + +//Invoice.recordRefund + +const RecordRefundInvoiceTransactionSchema = z.object({ + amount: z.number().int().min(0).optional(), + payment_method: z.enum([ + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]), + reference_number: z.string().max(100).optional(), + custom_payment_method_id: z.string().max(50).optional(), + date: z.number().int(), +}); +const RecordRefundInvoiceCreditNoteSchema = z.object({ + reason_code: z + .enum([ + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + ]) + .optional(), + create_reason_code: z.string().max(100).optional(), +}); +const RecordRefundInvoiceBodySchema = z.looseObject({ + comment: z.string().max(65000).optional(), + customer_notes: z.string().max(2000).optional(), + transaction: RecordRefundInvoiceTransactionSchema.optional(), + credit_note: RecordRefundInvoiceCreditNoteSchema.optional(), +}); +export { RecordRefundInvoiceBodySchema }; +export type RecordRefundInvoiceBody = z.infer< + typeof RecordRefundInvoiceBodySchema +>; + +//Invoice.removePayment + +const RemovePaymentInvoiceTransactionSchema = z.object({ + id: z.string().max(40), +}); +const RemovePaymentInvoiceBodySchema = z.looseObject({ + transaction: RemovePaymentInvoiceTransactionSchema.optional(), +}); +export { RemovePaymentInvoiceBodySchema }; +export type RemovePaymentInvoiceBody = z.infer< + typeof RemovePaymentInvoiceBodySchema +>; + +//Invoice.removeCreditNote + +const RemoveCreditNoteInvoiceCreditNoteSchema = z.object({ + id: z.string().max(50), +}); +const RemoveCreditNoteInvoiceBodySchema = z.looseObject({ + credit_note: RemoveCreditNoteInvoiceCreditNoteSchema.optional(), +}); +export { RemoveCreditNoteInvoiceBodySchema }; +export type RemoveCreditNoteInvoiceBody = z.infer< + typeof RemoveCreditNoteInvoiceBodySchema +>; + +//Invoice.voidInvoice + +const VoidInvoiceInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), + void_reason_code: z.string().max(100).optional(), +}); +export { VoidInvoiceInvoiceBodySchema }; +export type VoidInvoiceInvoiceBody = z.infer< + typeof VoidInvoiceInvoiceBodySchema +>; + +//Invoice.writeOff + +const WriteOffInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { WriteOffInvoiceBodySchema }; +export type WriteOffInvoiceBody = z.infer; + +//Invoice.delete + +const DeleteInvoiceBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { DeleteInvoiceBodySchema }; +export type DeleteInvoiceBody = z.infer; + +//Invoice.updateDetails + +const UpdateDetailsInvoiceBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateDetailsInvoiceShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateDetailsInvoiceStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const UpdateDetailsInvoiceBodySchema = z.looseObject({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + po_number: z.string().max(100).optional(), + comment: z.string().max(300).optional(), + billing_address: UpdateDetailsInvoiceBillingAddressSchema.optional(), + shipping_address: UpdateDetailsInvoiceShippingAddressSchema.optional(), + statement_descriptor: + UpdateDetailsInvoiceStatementDescriptorSchema.optional(), +}); +export { UpdateDetailsInvoiceBodySchema }; +export type UpdateDetailsInvoiceBody = z.infer< + typeof UpdateDetailsInvoiceBodySchema +>; + +//Invoice.applyPaymentScheduleScheme + +const ApplyPaymentScheduleSchemeInvoiceBodySchema = z.looseObject({ + scheme_id: z.string(), + amount: z.number().int().min(0).optional(), +}); +export { ApplyPaymentScheduleSchemeInvoiceBodySchema }; +export type ApplyPaymentScheduleSchemeInvoiceBody = z.infer< + typeof ApplyPaymentScheduleSchemeInvoiceBodySchema +>; diff --git a/src/schema/item.schema.ts b/src/schema/item.schema.ts new file mode 100644 index 0000000..f0ec74a --- /dev/null +++ b/src/schema/item.schema.ts @@ -0,0 +1,95 @@ +// Generated Zod schemas: Item +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Item.create + +const CreateItemMetadataSchema = z.looseObject({}); +const CreateItemBundleConfigurationSchema = z.object({ + type: z.enum(['fixed']).optional(), +}); +const CreateItemBundleItemsToAddSchema = z.object({ + item_id: z.array(z.string().max(100).optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + price_allocation: z.array(z.number().min(0).max(100).optional()).optional(), +}); +const CreateItemBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(100), + type: z.enum(['plan', 'addon', 'charge']), + description: z.string().max(2000).optional(), + item_family_id: z.string().max(100), + is_giftable: z.boolean().default(false).optional(), + is_shippable: z.boolean().default(false).optional(), + external_name: z.string().max(100).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + redirect_url: z.string().max(500).optional(), + enabled_for_checkout: z.boolean().default(true).optional(), + item_applicability: z.enum(['all', 'restricted']).optional(), + applicable_items: z.array(z.string().max(100).optional()).optional(), + unit: z.string().max(30).optional(), + gift_claim_redirect_url: z.string().max(500).optional(), + included_in_mrr: z.boolean().optional(), + metered: z.boolean().default(false).optional(), + usage_calculation: z + .enum(['sum_of_usages', 'last_usage', 'max_usage']) + .optional(), + is_percentage_pricing: z.boolean().default(false).optional(), + metadata: CreateItemMetadataSchema.optional(), + business_entity_id: z.string().max(50).optional(), + bundle_configuration: CreateItemBundleConfigurationSchema.optional(), + bundle_items_to_add: CreateItemBundleItemsToAddSchema.optional(), +}); +export { CreateItemBodySchema }; +export type CreateItemBody = z.infer; + +//Item.update + +const UpdateItemMetadataSchema = z.looseObject({}); +const UpdateItemBundleConfigurationSchema = z.object({ + type: z.enum(['fixed']).optional(), +}); +const UpdateItemBundleItemsToAddSchema = z.object({ + item_id: z.array(z.string().max(100).optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + price_allocation: z.array(z.number().min(0).max(100).optional()).optional(), +}); +const UpdateItemBundleItemsToUpdateSchema = z.object({ + item_id: z.array(z.string().max(100).optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + price_allocation: z.array(z.number().min(0).max(100).optional()).optional(), +}); +const UpdateItemBundleItemsToRemoveSchema = z.object({ + item_id: z.array(z.string().max(100).optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), +}); +const UpdateItemBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + is_shippable: z.boolean().default(false).optional(), + external_name: z.string().max(100).optional(), + item_family_id: z.string().max(100).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + redirect_url: z.string().max(500).optional(), + enabled_for_checkout: z.boolean().default(true).optional(), + item_applicability: z.enum(['all', 'restricted']).optional(), + clear_applicable_items: z.boolean().default(false).optional(), + applicable_items: z.array(z.string().max(100).optional()).optional(), + unit: z.string().max(30).optional(), + gift_claim_redirect_url: z.string().max(500).optional(), + metadata: UpdateItemMetadataSchema.optional(), + included_in_mrr: z.boolean().optional(), + status: z.enum(['active', 'archived']).optional(), + is_percentage_pricing: z.boolean().default(false).optional(), + bundle_configuration: UpdateItemBundleConfigurationSchema.optional(), + bundle_items_to_add: UpdateItemBundleItemsToAddSchema.optional(), + bundle_items_to_update: UpdateItemBundleItemsToUpdateSchema.optional(), + bundle_items_to_remove: UpdateItemBundleItemsToRemoveSchema.optional(), +}); +export { UpdateItemBodySchema }; +export type UpdateItemBody = z.infer; diff --git a/src/schema/item_entitlement.schema.ts b/src/schema/item_entitlement.schema.ts new file mode 100644 index 0000000..5471a86 --- /dev/null +++ b/src/schema/item_entitlement.schema.ts @@ -0,0 +1,69 @@ +// Generated Zod schemas: ItemEntitlement +// Actions: itemEntitlementsForItem, itemEntitlementsForFeature, addItemEntitlements, upsertOrRemoveItemEntitlementsForItem +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//ItemEntitlement.itemEntitlementsForItem + +const ItemEntitlementsForItemItemEntitlementBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + include_drafts: z.boolean().default(false).optional(), + embed: z.string().max(1000).optional(), +}); +export { ItemEntitlementsForItemItemEntitlementBodySchema }; +export type ItemEntitlementsForItemItemEntitlementBody = z.infer< + typeof ItemEntitlementsForItemItemEntitlementBodySchema +>; + +//ItemEntitlement.itemEntitlementsForFeature + +const ItemEntitlementsForFeatureItemEntitlementBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + include_drafts: z.boolean().default(false).optional(), +}); +export { ItemEntitlementsForFeatureItemEntitlementBodySchema }; +export type ItemEntitlementsForFeatureItemEntitlementBody = z.infer< + typeof ItemEntitlementsForFeatureItemEntitlementBodySchema +>; + +//ItemEntitlement.addItemEntitlements + +const AddItemEntitlementsItemEntitlementItemEntitlementsSchema = z.object({ + item_id: z.array(z.string().max(100).optional()), + item_type: z + .array( + z.enum(['plan', 'addon', 'charge', 'subscription', 'item']).optional(), + ) + .optional(), + value: z.array(z.string().max(50).optional()).optional(), +}); +const AddItemEntitlementsItemEntitlementBodySchema = z.looseObject({ + action: z.enum(['upsert', 'remove']), + item_entitlements: + AddItemEntitlementsItemEntitlementItemEntitlementsSchema.optional(), +}); +export { AddItemEntitlementsItemEntitlementBodySchema }; +export type AddItemEntitlementsItemEntitlementBody = z.infer< + typeof AddItemEntitlementsItemEntitlementBodySchema +>; + +//ItemEntitlement.upsertOrRemoveItemEntitlementsForItem + +const UpsertOrRemoveItemEntitlementsForItemItemEntitlementItemEntitlementsSchema = + z.object({ + feature_id: z.array(z.string().max(50).optional()), + value: z.array(z.string().max(50).optional()).optional(), + }); +const UpsertOrRemoveItemEntitlementsForItemItemEntitlementBodySchema = + z.looseObject({ + action: z.enum(['upsert', 'remove']), + item_entitlements: + UpsertOrRemoveItemEntitlementsForItemItemEntitlementItemEntitlementsSchema.optional(), + }); +export { UpsertOrRemoveItemEntitlementsForItemItemEntitlementBodySchema }; +export type UpsertOrRemoveItemEntitlementsForItemItemEntitlementBody = z.infer< + typeof UpsertOrRemoveItemEntitlementsForItemItemEntitlementBodySchema +>; diff --git a/src/schema/item_family.schema.ts b/src/schema/item_family.schema.ts new file mode 100644 index 0000000..7b2ee15 --- /dev/null +++ b/src/schema/item_family.schema.ts @@ -0,0 +1,25 @@ +// Generated Zod schemas: ItemFamily +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//ItemFamily.create + +const CreateItemFamilyBodySchema = z.looseObject({ + id: z.string().max(50), + name: z.string().max(50), + description: z.string().max(500).optional(), + business_entity_id: z.string().max(50).optional(), +}); +export { CreateItemFamilyBodySchema }; +export type CreateItemFamilyBody = z.infer; + +//ItemFamily.update + +const UpdateItemFamilyBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + description: z.string().max(500).optional(), +}); +export { UpdateItemFamilyBodySchema }; +export type UpdateItemFamilyBody = z.infer; diff --git a/src/schema/item_price.schema.ts b/src/schema/item_price.schema.ts new file mode 100644 index 0000000..7910a11 --- /dev/null +++ b/src/schema/item_price.schema.ts @@ -0,0 +1,204 @@ +// Generated Zod schemas: ItemPrice +// Actions: create, update, findApplicableItems, findApplicableItemPrices +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//ItemPrice.create + +const CreateItemPriceMetadataSchema = z.looseObject({}); +const CreateItemPriceTaxDetailSchema = z.object({ + tax_profile_id: z.string().max(50).optional(), + avalara_tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + taxjar_product_code: z.string().max(50).optional(), +}); +const CreateItemPriceAccountingDetailSchema = z.object({ + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), +}); +const CreateItemPriceTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateItemPriceTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const CreateItemPriceBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(100), + description: z.string().max(2000).optional(), + item_id: z.string().max(100), + invoice_notes: z.string().max(2000).optional(), + proration_type: z + .enum(['site_default', 'partial_term', 'full_term']) + .optional(), + external_name: z.string().max(100).optional(), + currency_code: z.string().max(3).optional(), + price_variant_id: z.string().max(100).optional(), + is_taxable: z.boolean().default(true).optional(), + free_quantity: z.number().int().min(0).optional(), + free_quantity_in_decimal: z.string().max(33).optional(), + metadata: CreateItemPriceMetadataSchema.optional(), + show_description_in_invoices: z.boolean().default(false).optional(), + show_description_in_quotes: z.boolean().default(false).optional(), + usage_accumulation_reset_frequency: z + .enum(['never', 'subscription_billing_frequency']) + .optional(), + business_entity_id: z.string().max(50).optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + period: z.number().int().min(1).optional(), + trial_period_unit: z.enum(['day', 'month']).optional(), + trial_period: z.number().int().min(0).optional(), + shipping_period: z.number().int().min(1).optional(), + shipping_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + billing_cycles: z.number().int().min(1).optional(), + trial_end_action: z + .enum(['site_default', 'activate_subscription', 'cancel_subscription']) + .optional(), + tax_detail: CreateItemPriceTaxDetailSchema.optional(), + accounting_detail: CreateItemPriceAccountingDetailSchema.optional(), + tiers: CreateItemPriceTiersSchema.optional(), + tax_providers_fields: CreateItemPriceTaxProvidersFieldsSchema.optional(), +}); +export { CreateItemPriceBodySchema }; +export type CreateItemPriceBody = z.infer; + +//ItemPrice.update + +const UpdateItemPriceMetadataSchema = z.looseObject({}); +const UpdateItemPriceTaxDetailSchema = z.object({ + tax_profile_id: z.string().max(50).optional(), + avalara_tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + taxjar_product_code: z.string().max(50).optional(), +}); +const UpdateItemPriceAccountingDetailSchema = z.object({ + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), +}); +const UpdateItemPriceTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const UpdateItemPriceTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const UpdateItemPriceBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + proration_type: z + .enum(['site_default', 'partial_term', 'full_term']) + .optional(), + price_variant_id: z.string().max(100).optional(), + status: z.enum(['active', 'archived']).optional(), + external_name: z.string().max(100).optional(), + usage_accumulation_reset_frequency: z + .enum(['never', 'subscription_billing_frequency']) + .optional(), + currency_code: z.string().max(3).optional(), + invoice_notes: z.string().max(2000).optional(), + is_taxable: z.boolean().default(true).optional(), + free_quantity: z.number().int().min(0).optional(), + free_quantity_in_decimal: z.string().max(33).optional(), + metadata: UpdateItemPriceMetadataSchema.optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + period: z.number().int().min(1).optional(), + trial_period_unit: z.enum(['day', 'month']).optional(), + trial_period: z.number().int().min(0).optional(), + shipping_period: z.number().int().min(1).optional(), + shipping_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + billing_cycles: z.number().int().min(1).optional(), + trial_end_action: z + .enum(['site_default', 'activate_subscription', 'cancel_subscription']) + .optional(), + show_description_in_invoices: z.boolean().optional(), + show_description_in_quotes: z.boolean().optional(), + tax_detail: UpdateItemPriceTaxDetailSchema.optional(), + accounting_detail: UpdateItemPriceAccountingDetailSchema.optional(), + tiers: UpdateItemPriceTiersSchema.optional(), + tax_providers_fields: UpdateItemPriceTaxProvidersFieldsSchema.optional(), +}); +export { UpdateItemPriceBodySchema }; +export type UpdateItemPriceBody = z.infer; + +//ItemPrice.findApplicableItems + +const FindApplicableItemsItemPriceSortBySchema = z.looseObject({ + asc: z.enum(['name', 'id', 'updated_at']).optional(), + desc: z.enum(['name', 'id', 'updated_at']).optional(), +}); +const FindApplicableItemsItemPriceBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + sort_by: FindApplicableItemsItemPriceSortBySchema.optional(), +}); +export { FindApplicableItemsItemPriceBodySchema }; +export type FindApplicableItemsItemPriceBody = z.infer< + typeof FindApplicableItemsItemPriceBodySchema +>; + +//ItemPrice.findApplicableItemPrices + +const FindApplicableItemPricesItemPriceSortBySchema = z.looseObject({ + asc: z.enum(['name', 'id', 'updated_at']).optional(), + desc: z.enum(['name', 'id', 'updated_at']).optional(), +}); +const FindApplicableItemPricesItemPriceBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + item_id: z.string().max(100).optional(), + sort_by: FindApplicableItemPricesItemPriceSortBySchema.optional(), +}); +export { FindApplicableItemPricesItemPriceBodySchema }; +export type FindApplicableItemPricesItemPriceBody = z.infer< + typeof FindApplicableItemPricesItemPriceBodySchema +>; diff --git a/src/schema/non_subscription.schema.ts b/src/schema/non_subscription.schema.ts new file mode 100644 index 0000000..56c7aed --- /dev/null +++ b/src/schema/non_subscription.schema.ts @@ -0,0 +1,31 @@ +// Generated Zod schemas: NonSubscription +// Actions: processReceipt +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//NonSubscription.processReceipt + +const ProcessReceiptNonSubscriptionProductSchema = z.object({ + id: z.string().max(96), + currency_code: z.string().max(3), + price: z.number().int().min(0), + type: z.enum(['consumable', 'non_consumable', 'non_renewing_subscription']), + name: z.string().max(96).optional(), + price_in_decimal: z.string().max(39).optional(), +}); +const ProcessReceiptNonSubscriptionCustomerSchema = z.object({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), +}); +const ProcessReceiptNonSubscriptionBodySchema = z.looseObject({ + receipt: z.string().max(65000), + product: ProcessReceiptNonSubscriptionProductSchema.optional(), + customer: ProcessReceiptNonSubscriptionCustomerSchema.optional(), +}); +export { ProcessReceiptNonSubscriptionBodySchema }; +export type ProcessReceiptNonSubscriptionBody = z.infer< + typeof ProcessReceiptNonSubscriptionBodySchema +>; diff --git a/src/schema/offer_event.schema.ts b/src/schema/offer_event.schema.ts new file mode 100644 index 0000000..9577576 --- /dev/null +++ b/src/schema/offer_event.schema.ts @@ -0,0 +1,16 @@ +// Generated Zod schemas: OfferEvent +// Actions: offerEvents +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//OfferEvent.offerEvents + +const OfferEventsOfferEventBodySchema = z.looseObject({ + personalized_offer_id: z.string().max(50), + type: z.enum(['viewed', 'dismissed']), +}); +export { OfferEventsOfferEventBodySchema }; +export type OfferEventsOfferEventBody = z.infer< + typeof OfferEventsOfferEventBodySchema +>; diff --git a/src/schema/offer_fulfillment.schema.ts b/src/schema/offer_fulfillment.schema.ts new file mode 100644 index 0000000..aa30395 --- /dev/null +++ b/src/schema/offer_fulfillment.schema.ts @@ -0,0 +1,28 @@ +// Generated Zod schemas: OfferFulfillment +// Actions: offerFulfillments, offerFulfillmentsUpdate +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//OfferFulfillment.offerFulfillments + +const OfferFulfillmentsOfferFulfillmentBodySchema = z.looseObject({ + personalized_offer_id: z.string().max(50), + option_id: z.string().max(50), +}); +export { OfferFulfillmentsOfferFulfillmentBodySchema }; +export type OfferFulfillmentsOfferFulfillmentBody = z.infer< + typeof OfferFulfillmentsOfferFulfillmentBodySchema +>; + +//OfferFulfillment.offerFulfillmentsUpdate + +const OfferFulfillmentsUpdateOfferFulfillmentBodySchema = z.looseObject({ + id: z.string().max(50), + status: z.enum(['completed', 'failed']), + failure_reason: z.string().max(100).optional(), +}); +export { OfferFulfillmentsUpdateOfferFulfillmentBodySchema }; +export type OfferFulfillmentsUpdateOfferFulfillmentBody = z.infer< + typeof OfferFulfillmentsUpdateOfferFulfillmentBodySchema +>; diff --git a/src/schema/omnichannel_one_time_order.schema.ts b/src/schema/omnichannel_one_time_order.schema.ts new file mode 100644 index 0000000..77908da --- /dev/null +++ b/src/schema/omnichannel_one_time_order.schema.ts @@ -0,0 +1,29 @@ +// Generated Zod schemas: OmnichannelOneTimeOrder +// Actions: list +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//OmnichannelOneTimeOrder.list + +const ListOmnichannelOneTimeOrderSourceSchema = z.object({ + is: z.enum(['apple_app_store', 'google_play_store']).optional(), + is_not: z.enum(['apple_app_store', 'google_play_store']).optional(), + in: z.enum(['apple_app_store', 'google_play_store']).optional(), + not_in: z.enum(['apple_app_store', 'google_play_store']).optional(), +}); +const ListOmnichannelOneTimeOrderCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListOmnichannelOneTimeOrderBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + source: ListOmnichannelOneTimeOrderSourceSchema.optional(), + customer_id: ListOmnichannelOneTimeOrderCustomerIdSchema.optional(), +}); +export { ListOmnichannelOneTimeOrderBodySchema }; +export type ListOmnichannelOneTimeOrderBody = z.infer< + typeof ListOmnichannelOneTimeOrderBodySchema +>; diff --git a/src/schema/omnichannel_subscription.schema.ts b/src/schema/omnichannel_subscription.schema.ts new file mode 100644 index 0000000..91d817a --- /dev/null +++ b/src/schema/omnichannel_subscription.schema.ts @@ -0,0 +1,105 @@ +// Generated Zod schemas: OmnichannelSubscription +// Actions: list, omnichannel_transactionsForOmnichannelSubscription, move +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//OmnichannelSubscription.list + +const ListOmnichannelSubscriptionSourceSchema = z.object({ + is: z.enum(['apple_app_store', 'google_play_store']).optional(), + is_not: z.enum(['apple_app_store', 'google_play_store']).optional(), + in: z.enum(['apple_app_store', 'google_play_store']).optional(), + not_in: z.enum(['apple_app_store', 'google_play_store']).optional(), +}); +const ListOmnichannelSubscriptionCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListOmnichannelSubscriptionStatusSchema = z.object({ + is: z + .enum([ + 'active', + 'expired', + 'cancelled', + 'in_dunning', + 'in_grace_period', + 'paused', + ]) + .optional(), + is_not: z + .enum([ + 'active', + 'expired', + 'cancelled', + 'in_dunning', + 'in_grace_period', + 'paused', + ]) + .optional(), + in: z + .enum([ + 'active', + 'expired', + 'cancelled', + 'in_dunning', + 'in_grace_period', + 'paused', + ]) + .optional(), + not_in: z + .enum([ + 'active', + 'expired', + 'cancelled', + 'in_dunning', + 'in_grace_period', + 'paused', + ]) + .optional(), +}); +const ListOmnichannelSubscriptionItemIdAtSourceSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListOmnichannelSubscriptionOmnichannelSubscriptionItemSchema = z.object({ + status: ListOmnichannelSubscriptionStatusSchema.optional(), + item_id_at_source: ListOmnichannelSubscriptionItemIdAtSourceSchema.optional(), +}); +const ListOmnichannelSubscriptionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + source: ListOmnichannelSubscriptionSourceSchema.optional(), + customer_id: ListOmnichannelSubscriptionCustomerIdSchema.optional(), + omnichannel_subscription_item: + ListOmnichannelSubscriptionOmnichannelSubscriptionItemSchema.optional(), +}); +export { ListOmnichannelSubscriptionBodySchema }; +export type ListOmnichannelSubscriptionBody = z.infer< + typeof ListOmnichannelSubscriptionBodySchema +>; + +//OmnichannelSubscription.omnichannel_transactionsForOmnichannelSubscription + +const OmnichannelTransactionsforomnichannelsubscriptionOmnichannelSubscriptionBodySchema = + z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + }); +export { OmnichannelTransactionsforomnichannelsubscriptionOmnichannelSubscriptionBodySchema }; +export type OmnichannelTransactionsforomnichannelsubscriptionOmnichannelSubscriptionBody = + z.infer< + typeof OmnichannelTransactionsforomnichannelsubscriptionOmnichannelSubscriptionBodySchema + >; + +//OmnichannelSubscription.move + +const MoveOmnichannelSubscriptionBodySchema = z.looseObject({ + to_customer_id: z.string().max(50), +}); +export { MoveOmnichannelSubscriptionBodySchema }; +export type MoveOmnichannelSubscriptionBody = z.infer< + typeof MoveOmnichannelSubscriptionBodySchema +>; diff --git a/src/schema/omnichannel_subscription_item.schema.ts b/src/schema/omnichannel_subscription_item.schema.ts new file mode 100644 index 0000000..d63087f --- /dev/null +++ b/src/schema/omnichannel_subscription_item.schema.ts @@ -0,0 +1,18 @@ +// Generated Zod schemas: OmnichannelSubscriptionItem +// Actions: listOmniSubItemScheduleChanges +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//OmnichannelSubscriptionItem.listOmniSubItemScheduleChanges + +const ListOmniSubItemScheduleChangesOmnichannelSubscriptionItemBodySchema = + z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + }); +export { ListOmniSubItemScheduleChangesOmnichannelSubscriptionItemBodySchema }; +export type ListOmniSubItemScheduleChangesOmnichannelSubscriptionItemBody = + z.infer< + typeof ListOmniSubItemScheduleChangesOmnichannelSubscriptionItemBodySchema + >; diff --git a/src/schema/order.schema.ts b/src/schema/order.schema.ts new file mode 100644 index 0000000..ca4c564 --- /dev/null +++ b/src/schema/order.schema.ts @@ -0,0 +1,301 @@ +// Generated Zod schemas: Order +// Actions: create, update, importOrder, cancel, createRefundableCreditNote, reopen, ordersForInvoice, resend +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Order.create + +const CreateOrderBodySchema = z.looseObject({ + id: z.string().max(40).optional(), + invoice_id: z.string().max(50), + status: z + .enum(['new', 'processing', 'complete', 'cancelled', 'voided']) + .optional(), + reference_id: z.string().max(50).optional(), + fulfillment_status: z.string().max(50).optional(), + note: z.string().max(600).optional(), + tracking_id: z.string().max(50).optional(), + tracking_url: z.string().max(255).optional(), + batch_id: z.string().max(50).optional(), +}); +export { CreateOrderBodySchema }; +export type CreateOrderBody = z.infer; + +//Order.update + +const UpdateOrderShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateOrderOrderLineItemsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + status: z + .array( + z + .enum([ + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + 'cancelled', + ]) + .optional(), + ) + .optional(), + sku: z.array(z.string().max(250).optional()).optional(), +}); +const UpdateOrderBodySchema = z.looseObject({ + reference_id: z.string().max(50).optional(), + batch_id: z.string().max(50).optional(), + note: z.string().max(600).optional(), + shipping_date: z.number().int().optional(), + order_date: z.number().int().optional(), + cancelled_at: z.number().int().optional(), + cancellation_reason: z + .enum([ + 'shipping_cut_off_passed', + 'product_unsatisfactory', + 'third_party_cancellation', + 'product_not_required', + 'delivery_date_missed', + 'alternative_found', + 'invoice_written_off', + 'invoice_voided', + 'fraudulent_transaction', + 'payment_declined', + 'subscription_cancelled', + 'product_not_available', + 'others', + 'order_resent', + ]) + .optional(), + shipped_at: z.number().int().optional(), + delivered_at: z.number().int().optional(), + tracking_url: z.string().max(255).optional(), + tracking_id: z.string().max(50).optional(), + shipment_carrier: z.string().max(50).optional(), + fulfillment_status: z.string().max(50).optional(), + status: z + .enum([ + 'new', + 'processing', + 'complete', + 'cancelled', + 'voided', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]) + .optional(), + shipping_address: UpdateOrderShippingAddressSchema.optional(), + order_line_items: UpdateOrderOrderLineItemsSchema.optional(), +}); +export { UpdateOrderBodySchema }; +export type UpdateOrderBody = z.infer; + +//Order.importOrder + +const ImportOrderOrderShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportOrderOrderBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportOrderOrderBodySchema = z.looseObject({ + id: z.string().max(40).optional(), + document_number: z.string().max(50).optional(), + invoice_id: z.string().max(50), + status: z.enum([ + 'cancelled', + 'queued', + 'awaiting_shipment', + 'on_hold', + 'delivered', + 'shipped', + 'partially_delivered', + 'returned', + ]), + subscription_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), + created_at: z.number().int(), + order_date: z.number().int(), + shipping_date: z.number().int(), + reference_id: z.string().max(50).optional(), + fulfillment_status: z.string().max(50).optional(), + note: z.string().max(600).optional(), + tracking_id: z.string().max(50).optional(), + tracking_url: z.string().max(255).optional(), + batch_id: z.string().max(50).optional(), + shipment_carrier: z.string().max(50).optional(), + shipping_cut_off_date: z.number().int().optional(), + delivered_at: z.number().int().optional(), + shipped_at: z.number().int().optional(), + cancelled_at: z.number().int().optional(), + cancellation_reason: z + .enum([ + 'shipping_cut_off_passed', + 'product_unsatisfactory', + 'third_party_cancellation', + 'product_not_required', + 'delivery_date_missed', + 'alternative_found', + 'invoice_written_off', + 'invoice_voided', + 'fraudulent_transaction', + 'payment_declined', + 'subscription_cancelled', + 'product_not_available', + 'others', + 'order_resent', + ]) + .optional(), + refundable_credits_issued: z.number().int().min(0).optional(), + shipping_address: ImportOrderOrderShippingAddressSchema.optional(), + billing_address: ImportOrderOrderBillingAddressSchema.optional(), +}); +export { ImportOrderOrderBodySchema }; +export type ImportOrderOrderBody = z.infer; + +//Order.cancel + +const CancelOrderCreditNoteSchema = z.object({ + total: z.number().int().min(0).optional(), +}); +const CancelOrderBodySchema = z.looseObject({ + cancellation_reason: z.enum([ + 'shipping_cut_off_passed', + 'product_unsatisfactory', + 'third_party_cancellation', + 'product_not_required', + 'delivery_date_missed', + 'alternative_found', + 'invoice_written_off', + 'invoice_voided', + 'fraudulent_transaction', + 'payment_declined', + 'subscription_cancelled', + 'product_not_available', + 'others', + 'order_resent', + ]), + customer_notes: z.string().max(2000).optional(), + comment: z.string().max(300).optional(), + cancelled_at: z.number().int().optional(), + credit_note: CancelOrderCreditNoteSchema.optional(), +}); +export { CancelOrderBodySchema }; +export type CancelOrderBody = z.infer; + +//Order.createRefundableCreditNote + +const CreateRefundableCreditNoteOrderCreditNoteSchema = z.object({ + reason_code: z.enum([ + 'write_off', + 'subscription_change', + 'subscription_cancellation', + 'subscription_pause', + 'chargeback', + 'product_unsatisfactory', + 'service_unsatisfactory', + 'order_change', + 'order_cancellation', + 'waiver', + 'other', + 'fraudulent', + ]), + total: z.number().int().min(0), +}); +const CreateRefundableCreditNoteOrderBodySchema = z.looseObject({ + customer_notes: z.string().max(2000).optional(), + comment: z.string().max(300).optional(), + credit_note: CreateRefundableCreditNoteOrderCreditNoteSchema.optional(), +}); +export { CreateRefundableCreditNoteOrderBodySchema }; +export type CreateRefundableCreditNoteOrderBody = z.infer< + typeof CreateRefundableCreditNoteOrderBodySchema +>; + +//Order.reopen + +const ReopenOrderBodySchema = z.looseObject({ + void_cancellation_credit_notes: z.boolean().optional(), +}); +export { ReopenOrderBodySchema }; +export type ReopenOrderBody = z.infer; + +//Order.ordersForInvoice + +const OrdersForInvoiceOrderBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { OrdersForInvoiceOrderBodySchema }; +export type OrdersForInvoiceOrderBody = z.infer< + typeof OrdersForInvoiceOrderBodySchema +>; + +//Order.resend + +const ResendOrderOrderLineItemsSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + fulfillment_quantity: z.array(z.number().int().min(0).optional()).optional(), +}); +const ResendOrderBodySchema = z.looseObject({ + shipping_date: z.number().int().optional(), + resend_reason: z.string().max(100).optional(), + order_line_items: ResendOrderOrderLineItemsSchema.optional(), +}); +export { ResendOrderBodySchema }; +export type ResendOrderBody = z.infer; diff --git a/src/schema/payment_intent.schema.ts b/src/schema/payment_intent.schema.ts new file mode 100644 index 0000000..0d31854 --- /dev/null +++ b/src/schema/payment_intent.schema.ts @@ -0,0 +1,125 @@ +// Generated Zod schemas: PaymentIntent +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PaymentIntent.create + +const CreatePaymentIntentBodySchema = z.looseObject({ + business_entity_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), + amount: z.number().int().min(0), + currency_code: z.string().max(3), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + defer_payment_method_type: z.boolean().default(false).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + success_url: z.string().max(250).optional(), + failure_url: z.string().max(250).optional(), +}); +export { CreatePaymentIntentBodySchema }; +export type CreatePaymentIntentBody = z.infer< + typeof CreatePaymentIntentBodySchema +>; + +//PaymentIntent.update + +const UpdatePaymentIntentBodySchema = z.looseObject({ + amount: z.number().int().min(0).optional(), + currency_code: z.string().max(3).optional(), + gateway_account_id: z.string().max(50).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + success_url: z.string().max(250).optional(), + failure_url: z.string().max(250).optional(), +}); +export { UpdatePaymentIntentBodySchema }; +export type UpdatePaymentIntentBody = z.infer< + typeof UpdatePaymentIntentBodySchema +>; diff --git a/src/schema/payment_schedule_scheme.schema.ts b/src/schema/payment_schedule_scheme.schema.ts new file mode 100644 index 0000000..aafc73c --- /dev/null +++ b/src/schema/payment_schedule_scheme.schema.ts @@ -0,0 +1,24 @@ +// Generated Zod schemas: PaymentScheduleScheme +// Actions: create +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PaymentScheduleScheme.create + +const CreatePaymentScheduleSchemeFlexibleSchedulesSchema = z.object({ + period: z.array(z.number().int().min(0).max(52).optional()).optional(), + amount_percentage: z.array(z.number().min(1).max(100).optional()).optional(), +}); +const CreatePaymentScheduleSchemeBodySchema = z.looseObject({ + number_of_schedules: z.number().int().min(1).max(52), + period_unit: z.enum(['day', 'week', 'month']), + period: z.number().int().min(1).max(30).optional(), + name: z.string().max(100), + flexible_schedules: + CreatePaymentScheduleSchemeFlexibleSchedulesSchema.optional(), +}); +export { CreatePaymentScheduleSchemeBodySchema }; +export type CreatePaymentScheduleSchemeBody = z.infer< + typeof CreatePaymentScheduleSchemeBodySchema +>; diff --git a/src/schema/payment_source.schema.ts b/src/schema/payment_source.schema.ts new file mode 100644 index 0000000..ef514ab --- /dev/null +++ b/src/schema/payment_source.schema.ts @@ -0,0 +1,434 @@ +// Generated Zod schemas: PaymentSource +// Actions: createUsingTempToken, createUsingPermanentToken, createUsingToken, createUsingPaymentIntent, createVoucherPaymentSource, createCard, createBankAccount, updateCard, updateBankAccount, verifyBankAccount, switchGatewayAccount, exportPaymentSource +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PaymentSource.createUsingTempToken + +const CreateUsingTempTokenPaymentSourceAdditionalInformationSchema = + z.looseObject({}); +const CreateUsingTempTokenPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + gateway_account_id: z.string().max(50).optional(), + type: z.enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]), + tmp_token: z.string().max(65000), + issuing_country: z.string().max(50).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + additional_information: + CreateUsingTempTokenPaymentSourceAdditionalInformationSchema.optional(), +}); +export { CreateUsingTempTokenPaymentSourceBodySchema }; +export type CreateUsingTempTokenPaymentSourceBody = z.infer< + typeof CreateUsingTempTokenPaymentSourceBodySchema +>; + +//PaymentSource.createUsingPermanentToken + +const CreateUsingPermanentTokenPaymentSourceAdditionalInformationSchema = + z.looseObject({}); +const CreateUsingPermanentTokenPaymentSourceCardSchema = z.object({ + last4: z.string().max(4).min(4).optional(), + iin: z.string().max(6).min(6).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + brand: z + .enum([ + 'visa', + 'mastercard', + 'american_express', + 'discover', + 'jcb', + 'diners_club', + 'other', + 'bancontact', + 'cmr_falabella', + 'tarjeta_naranja', + 'nativa', + 'cencosud', + 'cabal', + 'argencard', + 'elo', + 'hipercard', + 'carnet', + 'rupay', + 'maestro', + 'dankort', + 'cartes_bancaires', + 'mada', + ]) + .optional(), + funding_type: z.enum(['credit', 'debit', 'prepaid', 'not_known']).optional(), +}); +const CreateUsingPermanentTokenPaymentSourceBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), +}); +const CreateUsingPermanentTokenPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + type: z.enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + issuing_country: z.string().max(50).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + payment_method_token: z.string().max(100).optional(), + customer_profile_token: z.string().max(100).optional(), + network_transaction_id: z.string().max(100).optional(), + mandate_id: z.string().max(100).optional(), + skip_retrieval: z.boolean().default(false).optional(), + additional_information: + CreateUsingPermanentTokenPaymentSourceAdditionalInformationSchema.optional(), + card: CreateUsingPermanentTokenPaymentSourceCardSchema.optional(), + billing_address: + CreateUsingPermanentTokenPaymentSourceBillingAddressSchema.optional(), +}); +export { CreateUsingPermanentTokenPaymentSourceBodySchema }; +export type CreateUsingPermanentTokenPaymentSourceBody = z.infer< + typeof CreateUsingPermanentTokenPaymentSourceBodySchema +>; + +//PaymentSource.createUsingToken + +const CreateUsingTokenPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + replace_primary_payment_source: z.boolean().default(false).optional(), + token_id: z.string().max(40), +}); +export { CreateUsingTokenPaymentSourceBodySchema }; +export type CreateUsingTokenPaymentSourceBody = z.infer< + typeof CreateUsingTokenPaymentSourceBodySchema +>; + +//PaymentSource.createUsingPaymentIntent + +const CreateUsingPaymentIntentPaymentSourceAdditionalInfoSchema = z.looseObject( + {}, +); +const CreateUsingPaymentIntentPaymentSourceAdditionalInformationSchema = + z.looseObject({}); +const CreateUsingPaymentIntentPaymentSourcePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_info: + CreateUsingPaymentIntentPaymentSourceAdditionalInfoSchema.optional(), + additional_information: + CreateUsingPaymentIntentPaymentSourceAdditionalInformationSchema.optional(), +}); +const CreateUsingPaymentIntentPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + replace_primary_payment_source: z.boolean().default(false).optional(), + payment_intent: + CreateUsingPaymentIntentPaymentSourcePaymentIntentSchema.optional(), +}); +export { CreateUsingPaymentIntentPaymentSourceBodySchema }; +export type CreateUsingPaymentIntentPaymentSourceBody = z.infer< + typeof CreateUsingPaymentIntentPaymentSourceBodySchema +>; + +//PaymentSource.createVoucherPaymentSource + +const CreateVoucherPaymentSourcePaymentSourceBillingAddressSchema = + z.looseObject({}); +const CreateVoucherPaymentSourcePaymentSourceVoucherPaymentSourceSchema = + z.object({ + voucher_type: z.enum(['boleto']), + gateway_account_id: z.string().max(50).optional(), + tax_id: z.string().max(20).optional(), + billing_address: + CreateVoucherPaymentSourcePaymentSourceBillingAddressSchema.optional(), + }); +const CreateVoucherPaymentSourcePaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + voucher_payment_source: + CreateVoucherPaymentSourcePaymentSourceVoucherPaymentSourceSchema.optional(), +}); +export { CreateVoucherPaymentSourcePaymentSourceBodySchema }; +export type CreateVoucherPaymentSourcePaymentSourceBody = z.infer< + typeof CreateVoucherPaymentSourcePaymentSourceBodySchema +>; + +//PaymentSource.createCard + +const CreateCardPaymentSourceAdditionalInformationSchema = z.looseObject({}); +const CreateCardPaymentSourceCardSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500), + expiry_month: z.number().int().min(1).max(12), + expiry_year: z.number().int(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + additional_information: + CreateCardPaymentSourceAdditionalInformationSchema.optional(), +}); +const CreateCardPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + replace_primary_payment_source: z.boolean().default(false).optional(), + card: CreateCardPaymentSourceCardSchema.optional(), +}); +export { CreateCardPaymentSourceBodySchema }; +export type CreateCardPaymentSourceBody = z.infer< + typeof CreateCardPaymentSourceBodySchema +>; + +//PaymentSource.createBankAccount + +const CreateBankAccountPaymentSourceBillingAddressSchema = z.looseObject({}); +const CreateBankAccountPaymentSourceBankAccountSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + iban: z.string().max(50).min(10).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + bank_name: z.string().max(100).optional(), + account_number: z.string().max(17).min(4).optional(), + routing_number: z.string().max(9).min(3).optional(), + bank_code: z.string().max(20).optional(), + account_type: z + .enum(['checking', 'savings', 'business_checking', 'current']) + .optional(), + account_holder_type: z.enum(['individual', 'company']).optional(), + echeck_type: z.enum(['web', 'ppd', 'ccd']).optional(), + swedish_identity_number: z.string().max(12).min(10).optional(), + billing_address: + CreateBankAccountPaymentSourceBillingAddressSchema.optional(), +}); +const CreateBankAccountPaymentSourceBodySchema = z.looseObject({ + customer_id: z.string().max(50), + issuing_country: z.string().max(50).optional(), + replace_primary_payment_source: z.boolean().default(false).optional(), + bank_account: CreateBankAccountPaymentSourceBankAccountSchema.optional(), +}); +export { CreateBankAccountPaymentSourceBodySchema }; +export type CreateBankAccountPaymentSourceBody = z.infer< + typeof CreateBankAccountPaymentSourceBodySchema +>; + +//PaymentSource.updateCard + +const UpdateCardPaymentSourceGatewayMetaDataSchema = z.looseObject({}); +const UpdateCardPaymentSourceAdditionalInformationSchema = z.looseObject({}); +const UpdateCardPaymentSourceCardSchema = z.object({ + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_country: z.string().max(50).optional(), + additional_information: + UpdateCardPaymentSourceAdditionalInformationSchema.optional(), +}); +const UpdateCardPaymentSourceBodySchema = z.looseObject({ + gateway_meta_data: UpdateCardPaymentSourceGatewayMetaDataSchema.optional(), + reference_transaction: z.string().max(50).optional(), + card: UpdateCardPaymentSourceCardSchema.optional(), +}); +export { UpdateCardPaymentSourceBodySchema }; +export type UpdateCardPaymentSourceBody = z.infer< + typeof UpdateCardPaymentSourceBodySchema +>; + +//PaymentSource.updateBankAccount + +const UpdateBankAccountPaymentSourceBankAccountSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), +}); +const UpdateBankAccountPaymentSourceBodySchema = z.looseObject({ + bank_account: UpdateBankAccountPaymentSourceBankAccountSchema.optional(), +}); +export { UpdateBankAccountPaymentSourceBodySchema }; +export type UpdateBankAccountPaymentSourceBody = z.infer< + typeof UpdateBankAccountPaymentSourceBodySchema +>; + +//PaymentSource.verifyBankAccount + +const VerifyBankAccountPaymentSourceBodySchema = z.looseObject({ + amount1: z.number().int().min(0), + amount2: z.number().int().min(0), +}); +export { VerifyBankAccountPaymentSourceBodySchema }; +export type VerifyBankAccountPaymentSourceBody = z.infer< + typeof VerifyBankAccountPaymentSourceBodySchema +>; + +//PaymentSource.switchGatewayAccount + +const SwitchGatewayAccountPaymentSourceBodySchema = z.looseObject({ + gateway_account_id: z.string().max(50), +}); +export { SwitchGatewayAccountPaymentSourceBodySchema }; +export type SwitchGatewayAccountPaymentSourceBody = z.infer< + typeof SwitchGatewayAccountPaymentSourceBodySchema +>; + +//PaymentSource.exportPaymentSource + +const ExportPaymentSourcePaymentSourceBodySchema = z.looseObject({ + gateway_account_id: z.string().max(50), +}); +export { ExportPaymentSourcePaymentSourceBodySchema }; +export type ExportPaymentSourcePaymentSourceBody = z.infer< + typeof ExportPaymentSourcePaymentSourceBodySchema +>; diff --git a/src/schema/payment_voucher.schema.ts b/src/schema/payment_voucher.schema.ts new file mode 100644 index 0000000..c378c16 --- /dev/null +++ b/src/schema/payment_voucher.schema.ts @@ -0,0 +1,71 @@ +// Generated Zod schemas: PaymentVoucher +// Actions: create, payment_vouchersForInvoice, payment_vouchersForCustomer +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PaymentVoucher.create + +const CreatePaymentVoucherVoucherPaymentSourceSchema = z.object({ + voucher_type: z.enum(['boleto']), +}); +const CreatePaymentVoucherInvoiceAllocationsSchema = z.object({ + invoice_id: z.array(z.string().max(50).optional()), +}); +const CreatePaymentVoucherBodySchema = z.looseObject({ + customer_id: z.string().max(50), + payment_source_id: z.string().max(40).optional(), + voucher_payment_source: + CreatePaymentVoucherVoucherPaymentSourceSchema.optional(), + invoice_allocations: CreatePaymentVoucherInvoiceAllocationsSchema.optional(), +}); +export { CreatePaymentVoucherBodySchema }; +export type CreatePaymentVoucherBody = z.infer< + typeof CreatePaymentVoucherBodySchema +>; + +//PaymentVoucher.payment_vouchersForInvoice + +const PaymentVouchersforinvoicePaymentVoucherStatusSchema = z.object({ + is: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + is_not: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + in: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + not_in: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), +}); +const PaymentVouchersforinvoicePaymentVoucherSortBySchema = z.looseObject({ + asc: z.enum(['date', 'updated_at']).optional(), + desc: z.enum(['date', 'updated_at']).optional(), +}); +const PaymentVouchersforinvoicePaymentVoucherBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + status: PaymentVouchersforinvoicePaymentVoucherStatusSchema.optional(), + sort_by: PaymentVouchersforinvoicePaymentVoucherSortBySchema.optional(), +}); +export { PaymentVouchersforinvoicePaymentVoucherBodySchema }; +export type PaymentVouchersforinvoicePaymentVoucherBody = z.infer< + typeof PaymentVouchersforinvoicePaymentVoucherBodySchema +>; + +//PaymentVoucher.payment_vouchersForCustomer + +const PaymentVouchersforcustomerPaymentVoucherStatusSchema = z.object({ + is: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + is_not: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + in: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), + not_in: z.enum(['active', 'consumed', 'expired', 'failure']).optional(), +}); +const PaymentVouchersforcustomerPaymentVoucherSortBySchema = z.looseObject({ + asc: z.enum(['date', 'updated_at']).optional(), + desc: z.enum(['date', 'updated_at']).optional(), +}); +const PaymentVouchersforcustomerPaymentVoucherBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + status: PaymentVouchersforcustomerPaymentVoucherStatusSchema.optional(), + sort_by: PaymentVouchersforcustomerPaymentVoucherSortBySchema.optional(), +}); +export { PaymentVouchersforcustomerPaymentVoucherBodySchema }; +export type PaymentVouchersforcustomerPaymentVoucherBody = z.infer< + typeof PaymentVouchersforcustomerPaymentVoucherBodySchema +>; diff --git a/src/schema/personalized_offer.schema.ts b/src/schema/personalized_offer.schema.ts new file mode 100644 index 0000000..200c282 --- /dev/null +++ b/src/schema/personalized_offer.schema.ts @@ -0,0 +1,32 @@ +// Generated Zod schemas: PersonalizedOffer +// Actions: personalizedOffers +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PersonalizedOffer.personalizedOffers + +const PersonalizedOffersPersonalizedOfferCustomSchema = z.looseObject({}); +const PersonalizedOffersPersonalizedOfferRequestContextSchema = z.object({ + user_agent: z.string().max(255).optional(), + locale: z.string().max(50).optional(), + timezone: z.string().max(64).optional(), + url: z.string().max(250).optional(), + referrer_url: z.string().max(250).optional(), +}); +const PersonalizedOffersPersonalizedOfferBodySchema = z.looseObject({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + roles: z.array(z.string().max(50).optional()).optional(), + external_user_id: z.string().max(50).optional(), + subscription_id: z.string().max(50).optional(), + customer_id: z.string().max(50), + custom: PersonalizedOffersPersonalizedOfferCustomSchema.optional(), + request_context: + PersonalizedOffersPersonalizedOfferRequestContextSchema.optional(), +}); +export { PersonalizedOffersPersonalizedOfferBodySchema }; +export type PersonalizedOffersPersonalizedOfferBody = z.infer< + typeof PersonalizedOffersPersonalizedOfferBodySchema +>; diff --git a/src/schema/plan.schema.ts b/src/schema/plan.schema.ts new file mode 100644 index 0000000..e7df77c --- /dev/null +++ b/src/schema/plan.schema.ts @@ -0,0 +1,236 @@ +// Generated Zod schemas: Plan +// Actions: create, update, copy +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Plan.create + +const CreatePlanMetaDataSchema = z.looseObject({}); +const CreatePlanTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CreatePlanTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const CreatePlanApplicableAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), +}); +const CreatePlanEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), +}); +const CreatePlanAttachedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + billing_cycles: z.array(z.number().int().min(1).optional()).optional(), + type: z.array(z.enum(['recommended', 'mandatory']).optional()).optional(), +}); +const CreatePlanBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(100), + invoice_name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + trial_period: z.number().int().min(1).optional(), + trial_period_unit: z.enum(['day', 'month']).optional(), + trial_end_action: z + .enum(['site_default', 'activate_subscription', 'cancel_subscription']) + .optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + setup_cost: z.number().int().min(1).optional(), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + currency_code: z.string().max(3).optional(), + billing_cycles: z.number().int().min(1).optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + charge_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + free_quantity: z.number().int().min(0).optional(), + free_quantity_in_decimal: z.string().max(33).optional(), + addon_applicability: z.enum(['all', 'restricted']).optional(), + downgrade_penalty: z.number().min(0.01).max(100).optional(), + redirect_url: z.string().max(500).optional(), + enabled_in_hosted_pages: z.boolean().default(true).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + taxable: z.boolean().default(true).optional(), + tax_profile_id: z.string().max(50).optional(), + tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + taxjar_product_code: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), + is_shippable: z.boolean().default(false).optional(), + shipping_frequency_period: z.number().int().min(1).optional(), + shipping_frequency_period_unit: z + .enum(['year', 'month', 'week', 'day']) + .optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: CreatePlanMetaDataSchema.optional(), + show_description_in_invoices: z.boolean().default(false).optional(), + show_description_in_quotes: z.boolean().default(false).optional(), + giftable: z.boolean().default(false).optional(), + status: z.enum(['active', 'archived']).optional(), + claim_url: z.string().max(500).optional(), + tiers: CreatePlanTiersSchema.optional(), + tax_providers_fields: CreatePlanTaxProvidersFieldsSchema.optional(), + applicable_addons: CreatePlanApplicableAddonsSchema.optional(), + event_based_addons: CreatePlanEventBasedAddonsSchema.optional(), + attached_addons: CreatePlanAttachedAddonsSchema.optional(), +}); +export { CreatePlanBodySchema }; +export type CreatePlanBody = z.infer; + +//Plan.update + +const UpdatePlanMetaDataSchema = z.looseObject({}); +const UpdatePlanTiersSchema = z.object({ + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const UpdatePlanTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()), + field_id: z.array(z.string().max(50).optional()), + field_value: z.array(z.string().max(50).optional()), +}); +const UpdatePlanApplicableAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), +}); +const UpdatePlanEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), +}); +const UpdatePlanAttachedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + billing_cycles: z.array(z.number().int().min(1).optional()).optional(), + type: z.array(z.enum(['recommended', 'mandatory']).optional()).optional(), +}); +const UpdatePlanBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + invoice_name: z.string().max(100).optional(), + description: z.string().max(2000).optional(), + trial_period: z.number().int().min(0).optional(), + trial_period_unit: z.enum(['day', 'month']).optional(), + trial_end_action: z + .enum(['site_default', 'activate_subscription', 'cancel_subscription']) + .optional(), + period: z.number().int().min(1).optional(), + period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + setup_cost: z.number().int().min(1).optional(), + price: z.number().int().min(0).optional(), + price_in_decimal: z.string().max(39).optional(), + currency_code: z.string().max(3).optional(), + billing_cycles: z.number().int().min(1).optional(), + pricing_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + charge_model: z + .enum(['flat_fee', 'per_unit', 'tiered', 'volume', 'stairstep']) + .optional(), + free_quantity: z.number().int().min(0).optional(), + free_quantity_in_decimal: z.string().max(33).optional(), + addon_applicability: z.enum(['all', 'restricted']).optional(), + downgrade_penalty: z.number().min(0.01).max(100).optional(), + redirect_url: z.string().max(500).optional(), + enabled_in_hosted_pages: z.boolean().default(true).optional(), + enabled_in_portal: z.boolean().default(true).optional(), + taxable: z.boolean().default(true).optional(), + tax_profile_id: z.string().max(50).optional(), + tax_code: z.string().max(50).optional(), + hsn_code: z.string().max(50).optional(), + taxjar_product_code: z.string().max(50).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + sku: z.string().max(100).optional(), + accounting_code: z.string().max(100).optional(), + accounting_category1: z.string().max(100).optional(), + accounting_category2: z.string().max(100).optional(), + accounting_category3: z.string().max(100).optional(), + accounting_category4: z.string().max(100).optional(), + is_shippable: z.boolean().default(false).optional(), + shipping_frequency_period: z.number().int().min(1).optional(), + shipping_frequency_period_unit: z + .enum(['year', 'month', 'week', 'day']) + .optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdatePlanMetaDataSchema.optional(), + show_description_in_invoices: z.boolean().default(false).optional(), + show_description_in_quotes: z.boolean().default(false).optional(), + tiers: UpdatePlanTiersSchema.optional(), + tax_providers_fields: UpdatePlanTaxProvidersFieldsSchema.optional(), + applicable_addons: UpdatePlanApplicableAddonsSchema.optional(), + event_based_addons: UpdatePlanEventBasedAddonsSchema.optional(), + attached_addons: UpdatePlanAttachedAddonsSchema.optional(), +}); +export { UpdatePlanBodySchema }; +export type UpdatePlanBody = z.infer; + +//Plan.copy + +const CopyPlanBodySchema = z.looseObject({ + from_site: z.string().max(50), + id_at_from_site: z.string().max(100), + id: z.string().max(100).optional(), + for_site_merging: z.boolean().default(false).optional(), +}); +export { CopyPlanBodySchema }; +export type CopyPlanBody = z.infer; diff --git a/src/schema/portal_session.schema.ts b/src/schema/portal_session.schema.ts new file mode 100644 index 0000000..21049c1 --- /dev/null +++ b/src/schema/portal_session.schema.ts @@ -0,0 +1,30 @@ +// Generated Zod schemas: PortalSession +// Actions: create, activate +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PortalSession.create + +const CreatePortalSessionCustomerSchema = z.object({ + id: z.string().max(50), +}); +const CreatePortalSessionBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + forward_url: z.string().max(250).optional(), + customer: CreatePortalSessionCustomerSchema.optional(), +}); +export { CreatePortalSessionBodySchema }; +export type CreatePortalSessionBody = z.infer< + typeof CreatePortalSessionBodySchema +>; + +//PortalSession.activate + +const ActivatePortalSessionBodySchema = z.looseObject({ + token: z.string().max(70), +}); +export { ActivatePortalSessionBodySchema }; +export type ActivatePortalSessionBody = z.infer< + typeof ActivatePortalSessionBodySchema +>; diff --git a/src/schema/price_variant.schema.ts b/src/schema/price_variant.schema.ts new file mode 100644 index 0000000..8f03b67 --- /dev/null +++ b/src/schema/price_variant.schema.ts @@ -0,0 +1,44 @@ +// Generated Zod schemas: PriceVariant +// Actions: create, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PriceVariant.create + +const CreatePriceVariantAttributesSchema = z.object({ + name: z.array(z.string().max(100).optional()), + value: z.array(z.string().max(100).optional()), +}); +const CreatePriceVariantBodySchema = z.looseObject({ + id: z.string().max(100), + name: z.string().max(100), + external_name: z.string().max(100).optional(), + description: z.string().max(500).optional(), + variant_group: z.string().max(100).optional(), + business_entity_id: z.string().max(50).optional(), + attributes: CreatePriceVariantAttributesSchema.optional(), +}); +export { CreatePriceVariantBodySchema }; +export type CreatePriceVariantBody = z.infer< + typeof CreatePriceVariantBodySchema +>; + +//PriceVariant.update + +const UpdatePriceVariantAttributesSchema = z.object({ + name: z.array(z.string().max(100).optional()), + value: z.array(z.string().max(100).optional()), +}); +const UpdatePriceVariantBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + external_name: z.string().max(100).optional(), + description: z.string().max(500).optional(), + variant_group: z.string().max(100).optional(), + status: z.enum(['active', 'archived']).optional(), + attributes: UpdatePriceVariantAttributesSchema.optional(), +}); +export { UpdatePriceVariantBodySchema }; +export type UpdatePriceVariantBody = z.infer< + typeof UpdatePriceVariantBodySchema +>; diff --git a/src/schema/pricing_page_session.schema.ts b/src/schema/pricing_page_session.schema.ts new file mode 100644 index 0000000..02b04f1 --- /dev/null +++ b/src/schema/pricing_page_session.schema.ts @@ -0,0 +1,172 @@ +// Generated Zod schemas: PricingPageSession +// Actions: createForNewSubscription, createForExistingSubscription +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PricingPageSession.createForNewSubscription + +const CreateForNewSubscriptionPricingPageSessionCustomSchema = z.looseObject( + {}, +); +const CreateForNewSubscriptionPricingPageSessionPricingPageSchema = z.object({ + id: z.string().max(50), +}); +const CreateForNewSubscriptionPricingPageSessionSubscriptionSchema = + z.looseObject({ + id: z.string().max(50).optional(), + }); +const CreateForNewSubscriptionPricingPageSessionCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), +}); +const CreateForNewSubscriptionPricingPageSessionBillingAddressSchema = z.object( + { + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), + }, +); +const CreateForNewSubscriptionPricingPageSessionShippingAddressSchema = + z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), + }); +const CreateForNewSubscriptionPricingPageSessionContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateForNewSubscriptionPricingPageSessionDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + label: z.array(z.string().max(100).optional()).optional(), +}); +const CreateForNewSubscriptionPricingPageSessionBodySchema = z.looseObject({ + redirect_url: z.string().max(250).optional(), + business_entity_id: z.string().max(50).optional(), + auto_select_local_currency: z.boolean().default(false).optional(), + custom: CreateForNewSubscriptionPricingPageSessionCustomSchema.optional(), + pricing_page: + CreateForNewSubscriptionPricingPageSessionPricingPageSchema.optional(), + subscription: + CreateForNewSubscriptionPricingPageSessionSubscriptionSchema.optional(), + customer: CreateForNewSubscriptionPricingPageSessionCustomerSchema.optional(), + billing_address: + CreateForNewSubscriptionPricingPageSessionBillingAddressSchema.optional(), + shipping_address: + CreateForNewSubscriptionPricingPageSessionShippingAddressSchema.optional(), + contract_term: + CreateForNewSubscriptionPricingPageSessionContractTermSchema.optional(), + discounts: + CreateForNewSubscriptionPricingPageSessionDiscountsSchema.optional(), +}); +export { CreateForNewSubscriptionPricingPageSessionBodySchema }; +export type CreateForNewSubscriptionPricingPageSessionBody = z.infer< + typeof CreateForNewSubscriptionPricingPageSessionBodySchema +>; + +//PricingPageSession.createForExistingSubscription + +const CreateForExistingSubscriptionPricingPageSessionCustomSchema = + z.looseObject({}); +const CreateForExistingSubscriptionPricingPageSessionPricingPageSchema = + z.object({ + id: z.string().max(50).optional(), + }); +const CreateForExistingSubscriptionPricingPageSessionSubscriptionSchema = + z.looseObject({ + id: z.string().max(50), + }); +const CreateForExistingSubscriptionPricingPageSessionContractTermSchema = + z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), + }); +const CreateForExistingSubscriptionPricingPageSessionDiscountsSchema = z.object( + { + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + label: z.array(z.string().max(100).optional()).optional(), + }, +); +const CreateForExistingSubscriptionPricingPageSessionBodySchema = z.looseObject( + { + redirect_url: z.string().max(250).optional(), + custom: + CreateForExistingSubscriptionPricingPageSessionCustomSchema.optional(), + pricing_page: + CreateForExistingSubscriptionPricingPageSessionPricingPageSchema.optional(), + subscription: + CreateForExistingSubscriptionPricingPageSessionSubscriptionSchema.optional(), + contract_term: + CreateForExistingSubscriptionPricingPageSessionContractTermSchema.optional(), + discounts: + CreateForExistingSubscriptionPricingPageSessionDiscountsSchema.optional(), + }, +); +export { CreateForExistingSubscriptionPricingPageSessionBodySchema }; +export type CreateForExistingSubscriptionPricingPageSessionBody = z.infer< + typeof CreateForExistingSubscriptionPricingPageSessionBodySchema +>; diff --git a/src/schema/promotional_credit.schema.ts b/src/schema/promotional_credit.schema.ts new file mode 100644 index 0000000..3b0901a --- /dev/null +++ b/src/schema/promotional_credit.schema.ts @@ -0,0 +1,96 @@ +// Generated Zod schemas: PromotionalCredit +// Actions: add, deduct, set, list +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//PromotionalCredit.add + +const AddPromotionalCreditBodySchema = z.looseObject({ + customer_id: z.string().max(50), + amount: z.number().int().min(0).optional(), + amount_in_decimal: z.string().max(33).optional(), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { AddPromotionalCreditBodySchema }; +export type AddPromotionalCreditBody = z.infer< + typeof AddPromotionalCreditBodySchema +>; + +//PromotionalCredit.deduct + +const DeductPromotionalCreditBodySchema = z.looseObject({ + customer_id: z.string().max(50), + amount: z.number().int().min(0).optional(), + amount_in_decimal: z.string().max(33).optional(), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { DeductPromotionalCreditBodySchema }; +export type DeductPromotionalCreditBody = z.infer< + typeof DeductPromotionalCreditBodySchema +>; + +//PromotionalCredit.set + +const SetPromotionalCreditBodySchema = z.looseObject({ + customer_id: z.string().max(50), + amount: z.number().int().min(0).optional(), + amount_in_decimal: z.string().max(33).optional(), + currency_code: z.string().max(3).optional(), + description: z.string().max(250), + credit_type: z + .enum(['loyalty_credits', 'referral_rewards', 'general']) + .optional(), + reference: z.string().max(500).optional(), +}); +export { SetPromotionalCreditBodySchema }; +export type SetPromotionalCreditBody = z.infer< + typeof SetPromotionalCreditBodySchema +>; + +//PromotionalCredit.list + +const ListPromotionalCreditIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListPromotionalCreditCreatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ListPromotionalCreditTypeSchema = z.object({ + is: z.enum(['increment', 'decrement']).optional(), + is_not: z.enum(['increment', 'decrement']).optional(), + in: z.enum(['increment', 'decrement']).optional(), + not_in: z.enum(['increment', 'decrement']).optional(), +}); +const ListPromotionalCreditCustomerIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListPromotionalCreditBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + id: ListPromotionalCreditIdSchema.optional(), + created_at: ListPromotionalCreditCreatedAtSchema.optional(), + type: ListPromotionalCreditTypeSchema.optional(), + customer_id: ListPromotionalCreditCustomerIdSchema.optional(), +}); +export { ListPromotionalCreditBodySchema }; +export type ListPromotionalCreditBody = z.infer< + typeof ListPromotionalCreditBodySchema +>; diff --git a/src/schema/purchase.schema.ts b/src/schema/purchase.schema.ts new file mode 100644 index 0000000..7b05376 --- /dev/null +++ b/src/schema/purchase.schema.ts @@ -0,0 +1,280 @@ +// Generated Zod schemas: Purchase +// Actions: create, estimate +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Purchase.create + +const CreatePurchaseInvoiceInfoSchema = z.object({ + po_number: z.string().max(100).optional(), + notes: z.string().max(2000).optional(), +}); +const CreatePurchasePaymentScheduleSchema = z.object({ + scheme_id: z.string().max(40).optional(), + amount: z.number().int().min(0).optional(), +}); +const CreatePurchaseStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const CreatePurchaseAdditionalInformationSchema = z.looseObject({}); +const CreatePurchasePaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: CreatePurchaseAdditionalInformationSchema.optional(), +}); +const CreatePurchasePurchaseItemsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), +}); +const CreatePurchaseItemTiersSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const CreatePurchaseShippingAddressesSchema = z.object({ + first_name: z.array(z.string().max(150).optional()).optional(), + last_name: z.array(z.string().max(150).optional()).optional(), + email: z.array(z.string().email().max(70).optional()).optional(), + company: z.array(z.string().max(250).optional()).optional(), + phone: z.array(z.string().max(50).optional()).optional(), + line1: z.array(z.string().max(150).optional()).optional(), + line2: z.array(z.string().max(150).optional()).optional(), + line3: z.array(z.string().max(150).optional()).optional(), + city: z.array(z.string().max(50).optional()).optional(), + state: z.array(z.string().max(50).optional()).optional(), + state_code: z.array(z.string().max(50).optional()).optional(), + country: z.array(z.string().max(50).optional()).optional(), + zip: z.array(z.string().max(20).optional()).optional(), + validation_status: z + .array( + z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), + ) + .optional(), +}); +const CreatePurchaseDiscountsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()).optional(), + coupon_id: z.array(z.string().max(100).optional()).optional(), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), +}); +const CreatePurchaseMetaDataItemSchema = z.looseObject({}); +const CreatePurchaseSubscriptionInfoSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + subscription_id: z.array(z.string().max(50).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + contract_term_billing_cycle_on_renewal: z + .array(z.number().int().min(1).max(100).optional()) + .optional(), + meta_data: z.array(CreatePurchaseMetaDataItemSchema.optional()).optional(), +}); +const CreatePurchaseContractTermsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + action_at_term_end: z + .array(z.enum(['renew', 'evergreen', 'cancel', 'renew_once']).optional()) + .optional(), + cancellation_cutoff_period: z.array(z.number().int().optional()).optional(), +}); +const CreatePurchaseBodySchema = z.looseObject({ + customer_id: z.string().max(50), + payment_source_id: z.string().max(40).optional(), + replace_primary_payment_source: z.boolean().default(true).optional(), + invoice_info: CreatePurchaseInvoiceInfoSchema.optional(), + payment_schedule: CreatePurchasePaymentScheduleSchema.optional(), + statement_descriptor: CreatePurchaseStatementDescriptorSchema.optional(), + payment_intent: CreatePurchasePaymentIntentSchema.optional(), + purchase_items: CreatePurchasePurchaseItemsSchema.optional(), + item_tiers: CreatePurchaseItemTiersSchema.optional(), + shipping_addresses: CreatePurchaseShippingAddressesSchema.optional(), + discounts: CreatePurchaseDiscountsSchema.optional(), + subscription_info: CreatePurchaseSubscriptionInfoSchema.optional(), + contract_terms: CreatePurchaseContractTermsSchema.optional(), +}); +export { CreatePurchaseBodySchema }; +export type CreatePurchaseBody = z.infer; + +//Purchase.estimate + +const EstimatePurchaseCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), +}); +const EstimatePurchaseBillingAddressSchema = z.object({ + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EstimatePurchasePurchaseItemsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), +}); +const EstimatePurchaseItemTiersSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const EstimatePurchaseShippingAddressesSchema = z.object({ + first_name: z.array(z.string().max(150).optional()).optional(), + last_name: z.array(z.string().max(150).optional()).optional(), + email: z.array(z.string().email().max(70).optional()).optional(), + company: z.array(z.string().max(250).optional()).optional(), + phone: z.array(z.string().max(50).optional()).optional(), + line1: z.array(z.string().max(150).optional()).optional(), + line2: z.array(z.string().max(150).optional()).optional(), + line3: z.array(z.string().max(150).optional()).optional(), + city: z.array(z.string().max(50).optional()).optional(), + state: z.array(z.string().max(50).optional()).optional(), + state_code: z.array(z.string().max(50).optional()).optional(), + country: z.array(z.string().max(50).optional()).optional(), + zip: z.array(z.string().max(20).optional()).optional(), + validation_status: z + .array( + z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), + ) + .optional(), +}); +const EstimatePurchaseDiscountsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()).optional(), + coupon_id: z.array(z.string().max(100).optional()).optional(), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), +}); +const EstimatePurchaseSubscriptionInfoSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + subscription_id: z.array(z.string().max(50).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + contract_term_billing_cycle_on_renewal: z + .array(z.number().int().min(1).max(100).optional()) + .optional(), +}); +const EstimatePurchaseContractTermsSchema = z.object({ + index: z.array(z.number().int().min(0).optional()), + action_at_term_end: z + .array(z.enum(['renew', 'evergreen', 'cancel', 'renew_once']).optional()) + .optional(), + cancellation_cutoff_period: z.array(z.number().int().optional()).optional(), +}); +const EstimatePurchaseBodySchema = z.looseObject({ + client_profile_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), + customer: EstimatePurchaseCustomerSchema.optional(), + billing_address: EstimatePurchaseBillingAddressSchema.optional(), + purchase_items: EstimatePurchasePurchaseItemsSchema.optional(), + item_tiers: EstimatePurchaseItemTiersSchema.optional(), + shipping_addresses: EstimatePurchaseShippingAddressesSchema.optional(), + discounts: EstimatePurchaseDiscountsSchema.optional(), + subscription_info: EstimatePurchaseSubscriptionInfoSchema.optional(), + contract_terms: EstimatePurchaseContractTermsSchema.optional(), +}); +export { EstimatePurchaseBodySchema }; +export type EstimatePurchaseBody = z.infer; diff --git a/src/schema/quote.schema.ts b/src/schema/quote.schema.ts new file mode 100644 index 0000000..517d891 --- /dev/null +++ b/src/schema/quote.schema.ts @@ -0,0 +1,1717 @@ +// Generated Zod schemas: Quote +// Actions: createSubForCustomerQuote, editCreateSubForCustomerQuote, updateSubscriptionQuote, editUpdateSubscriptionQuote, createForOnetimeCharges, editOneTimeQuote, createSubItemsForCustomerQuote, editCreateSubCustomerQuoteForItems, updateSubscriptionQuoteForItems, editUpdateSubscriptionQuoteForItems, createForChargeItemsAndCharges, editForChargeItemsAndCharges, quoteLineGroupsForQuote, convert, updateStatus, extendExpiryDate, delete, pdf, updateSignatureStatus +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Quote.createSubForCustomerQuote + +const CreateSubForCustomerQuoteQuoteSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const CreateSubForCustomerQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubForCustomerQuoteQuoteContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubForCustomerQuoteQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const CreateSubForCustomerQuoteQuoteEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CreateSubForCustomerQuoteQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + subscription: CreateSubForCustomerQuoteQuoteSubscriptionSchema.optional(), + shipping_address: + CreateSubForCustomerQuoteQuoteShippingAddressSchema.optional(), + contract_term: CreateSubForCustomerQuoteQuoteContractTermSchema.optional(), + addons: CreateSubForCustomerQuoteQuoteAddonsSchema.optional(), + event_based_addons: + CreateSubForCustomerQuoteQuoteEventBasedAddonsSchema.optional(), +}); +export { CreateSubForCustomerQuoteQuoteBodySchema }; +export type CreateSubForCustomerQuoteQuoteBody = z.infer< + typeof CreateSubForCustomerQuoteQuoteBodySchema +>; + +//Quote.editCreateSubForCustomerQuote + +const EditCreateSubForCustomerQuoteQuoteSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const EditCreateSubForCustomerQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditCreateSubForCustomerQuoteQuoteContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const EditCreateSubForCustomerQuoteQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const EditCreateSubForCustomerQuoteQuoteEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const EditCreateSubForCustomerQuoteQuoteBodySchema = z.looseObject({ + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + subscription: EditCreateSubForCustomerQuoteQuoteSubscriptionSchema.optional(), + shipping_address: + EditCreateSubForCustomerQuoteQuoteShippingAddressSchema.optional(), + contract_term: + EditCreateSubForCustomerQuoteQuoteContractTermSchema.optional(), + addons: EditCreateSubForCustomerQuoteQuoteAddonsSchema.optional(), + event_based_addons: + EditCreateSubForCustomerQuoteQuoteEventBasedAddonsSchema.optional(), +}); +export { EditCreateSubForCustomerQuoteQuoteBodySchema }; +export type EditCreateSubForCustomerQuoteQuoteBody = z.infer< + typeof EditCreateSubForCustomerQuoteQuoteBodySchema +>; + +//Quote.updateSubscriptionQuote + +const UpdateSubscriptionQuoteQuoteSubscriptionSchema = z.object({ + id: z.string().max(50), + plan_id: z.string().max(100).optional(), + plan_quantity: z.number().int().min(1).optional(), + plan_unit_price: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const UpdateSubscriptionQuoteQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionQuoteQuoteCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), +}); +const UpdateSubscriptionQuoteQuoteContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const UpdateSubscriptionQuoteQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const UpdateSubscriptionQuoteQuoteEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const UpdateSubscriptionQuoteQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + replace_addon_list: z.boolean().default(false).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + change_option: z.enum(['immediately', 'specific_date']).optional(), + changes_scheduled_at: z.number().int().optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + subscription: UpdateSubscriptionQuoteQuoteSubscriptionSchema.optional(), + billing_address: UpdateSubscriptionQuoteQuoteBillingAddressSchema.optional(), + shipping_address: + UpdateSubscriptionQuoteQuoteShippingAddressSchema.optional(), + customer: UpdateSubscriptionQuoteQuoteCustomerSchema.optional(), + contract_term: UpdateSubscriptionQuoteQuoteContractTermSchema.optional(), + addons: UpdateSubscriptionQuoteQuoteAddonsSchema.optional(), + event_based_addons: + UpdateSubscriptionQuoteQuoteEventBasedAddonsSchema.optional(), +}); +export { UpdateSubscriptionQuoteQuoteBodySchema }; +export type UpdateSubscriptionQuoteQuoteBody = z.infer< + typeof UpdateSubscriptionQuoteQuoteBodySchema +>; + +//Quote.editUpdateSubscriptionQuote + +const EditUpdateSubscriptionQuoteQuoteSubscriptionSchema = z.object({ + plan_id: z.string().max(100).optional(), + plan_quantity: z.number().int().min(1).optional(), + plan_unit_price: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const EditUpdateSubscriptionQuoteQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditUpdateSubscriptionQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditUpdateSubscriptionQuoteQuoteCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), +}); +const EditUpdateSubscriptionQuoteQuoteContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const EditUpdateSubscriptionQuoteQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const EditUpdateSubscriptionQuoteQuoteEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const EditUpdateSubscriptionQuoteQuoteBodySchema = z.looseObject({ + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + replace_addon_list: z.boolean().default(false).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + change_option: z.enum(['immediately', 'specific_date']).optional(), + changes_scheduled_at: z.number().int().optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + subscription: EditUpdateSubscriptionQuoteQuoteSubscriptionSchema.optional(), + billing_address: + EditUpdateSubscriptionQuoteQuoteBillingAddressSchema.optional(), + shipping_address: + EditUpdateSubscriptionQuoteQuoteShippingAddressSchema.optional(), + customer: EditUpdateSubscriptionQuoteQuoteCustomerSchema.optional(), + contract_term: EditUpdateSubscriptionQuoteQuoteContractTermSchema.optional(), + addons: EditUpdateSubscriptionQuoteQuoteAddonsSchema.optional(), + event_based_addons: + EditUpdateSubscriptionQuoteQuoteEventBasedAddonsSchema.optional(), +}); +export { EditUpdateSubscriptionQuoteQuoteBodySchema }; +export type EditUpdateSubscriptionQuoteQuoteBody = z.infer< + typeof EditUpdateSubscriptionQuoteQuoteBodySchema +>; + +//Quote.createForOnetimeCharges + +const CreateForOnetimeChargesQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForOnetimeChargesQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const CreateForOnetimeChargesQuoteChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const CreateForOnetimeChargesQuoteTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateForOnetimeChargesQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + customer_id: z.string().max(50), + po_number: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + currency_code: z.string().max(3).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + shipping_address: + CreateForOnetimeChargesQuoteShippingAddressSchema.optional(), + addons: CreateForOnetimeChargesQuoteAddonsSchema.optional(), + charges: CreateForOnetimeChargesQuoteChargesSchema.optional(), + tax_providers_fields: + CreateForOnetimeChargesQuoteTaxProvidersFieldsSchema.optional(), +}); +export { CreateForOnetimeChargesQuoteBodySchema }; +export type CreateForOnetimeChargesQuoteBody = z.infer< + typeof CreateForOnetimeChargesQuoteBodySchema +>; + +//Quote.editOneTimeQuote + +const EditOneTimeQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditOneTimeQuoteQuoteAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const EditOneTimeQuoteQuoteChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const EditOneTimeQuoteQuoteTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const EditOneTimeQuoteQuoteBodySchema = z.looseObject({ + po_number: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + currency_code: z.string().max(3).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + shipping_address: EditOneTimeQuoteQuoteShippingAddressSchema.optional(), + addons: EditOneTimeQuoteQuoteAddonsSchema.optional(), + charges: EditOneTimeQuoteQuoteChargesSchema.optional(), + tax_providers_fields: + EditOneTimeQuoteQuoteTaxProvidersFieldsSchema.optional(), +}); +export { EditOneTimeQuoteQuoteBodySchema }; +export type EditOneTimeQuoteQuoteBody = z.infer< + typeof EditOneTimeQuoteQuoteBodySchema +>; + +//Quote.createSubItemsForCustomerQuote + +const CreateSubItemsForCustomerQuoteQuoteSubscriptionSchema = z.looseObject({ + id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + trial_end: z.number().int().optional(), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteCouponsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const CreateSubItemsForCustomerQuoteQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + billing_start_option: z.enum(['immediately', 'on_specific_date']).optional(), + net_term_days: z.number().int().optional(), + subscription: + CreateSubItemsForCustomerQuoteQuoteSubscriptionSchema.optional(), + shipping_address: + CreateSubItemsForCustomerQuoteQuoteShippingAddressSchema.optional(), + contract_term: + CreateSubItemsForCustomerQuoteQuoteContractTermSchema.optional(), + billing_address: + CreateSubItemsForCustomerQuoteQuoteBillingAddressSchema.optional(), + subscription_items: + CreateSubItemsForCustomerQuoteQuoteSubscriptionItemsSchema.optional(), + discounts: CreateSubItemsForCustomerQuoteQuoteDiscountsSchema.optional(), + item_tiers: CreateSubItemsForCustomerQuoteQuoteItemTiersSchema.optional(), + coupons: CreateSubItemsForCustomerQuoteQuoteCouponsSchema.optional(), +}); +export { CreateSubItemsForCustomerQuoteQuoteBodySchema }; +export type CreateSubItemsForCustomerQuoteQuoteBody = z.infer< + typeof CreateSubItemsForCustomerQuoteQuoteBodySchema +>; + +//Quote.editCreateSubCustomerQuoteForItems + +const EditCreateSubCustomerQuoteForItemsQuoteSubscriptionSchema = z.looseObject( + { + id: z.string().max(50).optional(), + po_number: z.string().max(100).optional(), + trial_end: z.number().int().optional(), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + }, +); +const EditCreateSubCustomerQuoteForItemsQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteSubscriptionItemsSchema = z.object( + { + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z + .array(z.enum(['plan', 'addon', 'charge']).optional()) + .optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), + }, +); +const EditCreateSubCustomerQuoteForItemsQuoteDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteCouponsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const EditCreateSubCustomerQuoteForItemsQuoteBodySchema = z.looseObject({ + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + billing_start_option: z.enum(['immediately', 'on_specific_date']).optional(), + net_term_days: z.number().int().optional(), + subscription: + EditCreateSubCustomerQuoteForItemsQuoteSubscriptionSchema.optional(), + shipping_address: + EditCreateSubCustomerQuoteForItemsQuoteShippingAddressSchema.optional(), + contract_term: + EditCreateSubCustomerQuoteForItemsQuoteContractTermSchema.optional(), + billing_address: + EditCreateSubCustomerQuoteForItemsQuoteBillingAddressSchema.optional(), + subscription_items: + EditCreateSubCustomerQuoteForItemsQuoteSubscriptionItemsSchema.optional(), + discounts: EditCreateSubCustomerQuoteForItemsQuoteDiscountsSchema.optional(), + item_tiers: EditCreateSubCustomerQuoteForItemsQuoteItemTiersSchema.optional(), + coupons: EditCreateSubCustomerQuoteForItemsQuoteCouponsSchema.optional(), +}); +export { EditCreateSubCustomerQuoteForItemsQuoteBodySchema }; +export type EditCreateSubCustomerQuoteForItemsQuoteBody = z.infer< + typeof EditCreateSubCustomerQuoteForItemsQuoteBodySchema +>; + +//Quote.updateSubscriptionQuoteForItems + +const UpdateSubscriptionQuoteForItemsQuoteSubscriptionSchema = z.looseObject({ + id: z.string().max(50), + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + operation_type: z.array(z.enum(['add', 'remove']).optional()), + id: z.array(z.string().max(50).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteCouponsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const UpdateSubscriptionQuoteForItemsQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + replace_items_list: z.boolean().default(false).optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + change_option: z.enum(['immediately', 'specific_date']).optional(), + changes_scheduled_at: z.number().int().optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + net_term_days: z.number().int().optional(), + subscription: + UpdateSubscriptionQuoteForItemsQuoteSubscriptionSchema.optional(), + billing_address: + UpdateSubscriptionQuoteForItemsQuoteBillingAddressSchema.optional(), + shipping_address: + UpdateSubscriptionQuoteForItemsQuoteShippingAddressSchema.optional(), + customer: UpdateSubscriptionQuoteForItemsQuoteCustomerSchema.optional(), + contract_term: + UpdateSubscriptionQuoteForItemsQuoteContractTermSchema.optional(), + subscription_items: + UpdateSubscriptionQuoteForItemsQuoteSubscriptionItemsSchema.optional(), + discounts: UpdateSubscriptionQuoteForItemsQuoteDiscountsSchema.optional(), + item_tiers: UpdateSubscriptionQuoteForItemsQuoteItemTiersSchema.optional(), + coupons: UpdateSubscriptionQuoteForItemsQuoteCouponsSchema.optional(), +}); +export { UpdateSubscriptionQuoteForItemsQuoteBodySchema }; +export type UpdateSubscriptionQuoteForItemsQuoteBody = z.infer< + typeof UpdateSubscriptionQuoteForItemsQuoteBodySchema +>; + +//Quote.editUpdateSubscriptionQuoteForItems + +const EditUpdateSubscriptionQuoteForItemsQuoteSubscriptionSchema = + z.looseObject({ + setup_fee: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + }); +const EditUpdateSubscriptionQuoteForItemsQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + registered_for_gst: z.boolean().optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteSubscriptionItemsSchema = + z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + item_type: z + .array(z.enum(['plan', 'addon', 'charge']).optional()) + .optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), + }); +const EditUpdateSubscriptionQuoteForItemsQuoteDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + operation_type: z.array(z.enum(['add', 'remove']).optional()), + id: z.array(z.string().max(50).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), + ramp_tier_id: z.array(z.string().max(105).optional()).optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteCouponsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + start_date: z.array(z.number().int().optional()).optional(), + end_date: z.array(z.number().int().optional()).optional(), +}); +const EditUpdateSubscriptionQuoteForItemsQuoteBodySchema = z.looseObject({ + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + replace_items_list: z.boolean().default(false).optional(), + billing_cycles: z.number().int().min(0).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + change_option: z.enum(['immediately', 'specific_date']).optional(), + changes_scheduled_at: z.number().int().optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + net_term_days: z.number().int().optional(), + subscription: + EditUpdateSubscriptionQuoteForItemsQuoteSubscriptionSchema.optional(), + billing_address: + EditUpdateSubscriptionQuoteForItemsQuoteBillingAddressSchema.optional(), + shipping_address: + EditUpdateSubscriptionQuoteForItemsQuoteShippingAddressSchema.optional(), + customer: EditUpdateSubscriptionQuoteForItemsQuoteCustomerSchema.optional(), + contract_term: + EditUpdateSubscriptionQuoteForItemsQuoteContractTermSchema.optional(), + subscription_items: + EditUpdateSubscriptionQuoteForItemsQuoteSubscriptionItemsSchema.optional(), + discounts: EditUpdateSubscriptionQuoteForItemsQuoteDiscountsSchema.optional(), + item_tiers: + EditUpdateSubscriptionQuoteForItemsQuoteItemTiersSchema.optional(), + coupons: EditUpdateSubscriptionQuoteForItemsQuoteCouponsSchema.optional(), +}); +export { EditUpdateSubscriptionQuoteForItemsQuoteBodySchema }; +export type EditUpdateSubscriptionQuoteForItemsQuoteBody = z.infer< + typeof EditUpdateSubscriptionQuoteForItemsQuoteBodySchema +>; + +//Quote.createForChargeItemsAndCharges + +const CreateForChargeItemsAndChargesQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForChargeItemsAndChargesQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForChargeItemsAndChargesQuoteItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), +}); +const CreateForChargeItemsAndChargesQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateForChargeItemsAndChargesQuoteChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const CreateForChargeItemsAndChargesQuoteDiscountsSchema = z.object({ + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateForChargeItemsAndChargesQuoteTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateForChargeItemsAndChargesQuoteBodySchema = z.looseObject({ + name: z.string().max(100).optional(), + customer_id: z.string().max(50), + po_number: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + currency_code: z.string().max(3).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + net_term_days: z.number().int().optional(), + billing_address: + CreateForChargeItemsAndChargesQuoteBillingAddressSchema.optional(), + shipping_address: + CreateForChargeItemsAndChargesQuoteShippingAddressSchema.optional(), + item_prices: CreateForChargeItemsAndChargesQuoteItemPricesSchema.optional(), + item_tiers: CreateForChargeItemsAndChargesQuoteItemTiersSchema.optional(), + charges: CreateForChargeItemsAndChargesQuoteChargesSchema.optional(), + discounts: CreateForChargeItemsAndChargesQuoteDiscountsSchema.optional(), + tax_providers_fields: + CreateForChargeItemsAndChargesQuoteTaxProvidersFieldsSchema.optional(), +}); +export { CreateForChargeItemsAndChargesQuoteBodySchema }; +export type CreateForChargeItemsAndChargesQuoteBody = z.infer< + typeof CreateForChargeItemsAndChargesQuoteBodySchema +>; + +//Quote.editForChargeItemsAndCharges + +const EditForChargeItemsAndChargesQuoteBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditForChargeItemsAndChargesQuoteShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const EditForChargeItemsAndChargesQuoteItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), +}); +const EditForChargeItemsAndChargesQuoteItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const EditForChargeItemsAndChargesQuoteChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + service_period: z.array(z.number().int().optional()).optional(), +}); +const EditForChargeItemsAndChargesQuoteDiscountsSchema = z.object({ + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const EditForChargeItemsAndChargesQuoteTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const EditForChargeItemsAndChargesQuoteBodySchema = z.looseObject({ + po_number: z.string().max(100).optional(), + notes: z.string().max(10000).optional(), + expires_at: z.number().int().optional(), + currency_code: z.string().max(3).optional(), + coupon: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + net_term_days: z.number().int().optional(), + billing_address: + EditForChargeItemsAndChargesQuoteBillingAddressSchema.optional(), + shipping_address: + EditForChargeItemsAndChargesQuoteShippingAddressSchema.optional(), + item_prices: EditForChargeItemsAndChargesQuoteItemPricesSchema.optional(), + item_tiers: EditForChargeItemsAndChargesQuoteItemTiersSchema.optional(), + charges: EditForChargeItemsAndChargesQuoteChargesSchema.optional(), + discounts: EditForChargeItemsAndChargesQuoteDiscountsSchema.optional(), + tax_providers_fields: + EditForChargeItemsAndChargesQuoteTaxProvidersFieldsSchema.optional(), +}); +export { EditForChargeItemsAndChargesQuoteBodySchema }; +export type EditForChargeItemsAndChargesQuoteBody = z.infer< + typeof EditForChargeItemsAndChargesQuoteBodySchema +>; + +//Quote.quoteLineGroupsForQuote + +const QuoteLineGroupsForQuoteQuoteBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { QuoteLineGroupsForQuoteQuoteBodySchema }; +export type QuoteLineGroupsForQuoteQuoteBody = z.infer< + typeof QuoteLineGroupsForQuoteQuoteBodySchema +>; + +//Quote.convert + +const ConvertQuoteSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + po_number: z.string().max(100).optional(), + auto_close_invoices: z.boolean().optional(), +}); +const ConvertQuoteBodySchema = z.looseObject({ + invoice_date: z.number().int().optional(), + invoice_immediately: z.boolean().optional(), + create_pending_invoices: z.boolean().optional(), + first_invoice_pending: z.boolean().default(false).optional(), + subscription: ConvertQuoteSubscriptionSchema.optional(), +}); +export { ConvertQuoteBodySchema }; +export type ConvertQuoteBody = z.infer; + +//Quote.updateStatus + +const UpdateStatusQuoteBodySchema = z.looseObject({ + status: z.enum([ + 'open', + 'accepted', + 'declined', + 'proposed', + 'voided', + 'closed', + ]), + comment: z.string().max(300).optional(), +}); +export { UpdateStatusQuoteBodySchema }; +export type UpdateStatusQuoteBody = z.infer; + +//Quote.extendExpiryDate + +const ExtendExpiryDateQuoteBodySchema = z.looseObject({ + valid_till: z.number().int(), +}); +export { ExtendExpiryDateQuoteBodySchema }; +export type ExtendExpiryDateQuoteBody = z.infer< + typeof ExtendExpiryDateQuoteBodySchema +>; + +//Quote.delete + +const DeleteQuoteBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { DeleteQuoteBodySchema }; +export type DeleteQuoteBody = z.infer; + +//Quote.pdf + +const PdfQuoteBodySchema = z.looseObject({ + consolidated_view: z.boolean().default(false).optional(), + disposition_type: z.enum(['attachment', 'inline']).optional(), +}); +export { PdfQuoteBodySchema }; +export type PdfQuoteBody = z.infer; + +//Quote.updateSignatureStatus + +const UpdateSignatureStatusQuoteCpqQuoteSignatureSchema = z.object({ + status: z + .enum(['draft', 'active', 'signed', 'expired', 'cancelled', 'declined']) + .optional(), +}); +const UpdateSignatureStatusQuoteBodySchema = z.looseObject({ + cpq_quote_signature: + UpdateSignatureStatusQuoteCpqQuoteSignatureSchema.optional(), +}); +export { UpdateSignatureStatusQuoteBodySchema }; +export type UpdateSignatureStatusQuoteBody = z.infer< + typeof UpdateSignatureStatusQuoteBodySchema +>; diff --git a/src/schema/ramp.schema.ts b/src/schema/ramp.schema.ts new file mode 100644 index 0000000..91a72e3 --- /dev/null +++ b/src/schema/ramp.schema.ts @@ -0,0 +1,231 @@ +// Generated Zod schemas: Ramp +// Actions: createForSubscription, update +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Ramp.createForSubscription + +const CreateForSubscriptionRampContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), + renewal_billing_cycles: z.number().int().optional(), +}); +const CreateForSubscriptionRampItemsToAddSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const CreateForSubscriptionRampItemsToUpdateSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const CreateForSubscriptionRampItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateForSubscriptionRampCouponsToAddSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const CreateForSubscriptionRampDiscountsToAddSchema = z.object({ + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const CreateForSubscriptionRampBodySchema = z.looseObject({ + effective_from: z.number().int(), + description: z.string().max(250).optional(), + coupons_to_remove: z.array(z.string().max(100).optional()).optional(), + discounts_to_remove: z.array(z.string().max(100).optional()).optional(), + items_to_remove: z.array(z.string().max(100).optional()).optional(), + contract_term: CreateForSubscriptionRampContractTermSchema.optional(), + items_to_add: CreateForSubscriptionRampItemsToAddSchema.optional(), + items_to_update: CreateForSubscriptionRampItemsToUpdateSchema.optional(), + item_tiers: CreateForSubscriptionRampItemTiersSchema.optional(), + coupons_to_add: CreateForSubscriptionRampCouponsToAddSchema.optional(), + discounts_to_add: CreateForSubscriptionRampDiscountsToAddSchema.optional(), +}); +export { CreateForSubscriptionRampBodySchema }; +export type CreateForSubscriptionRampBody = z.infer< + typeof CreateForSubscriptionRampBodySchema +>; + +//Ramp.update + +const UpdateRampContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), + renewal_billing_cycles: z.number().int().optional(), +}); +const UpdateRampItemsToAddSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const UpdateRampItemsToUpdateSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), +}); +const UpdateRampItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const UpdateRampCouponsToAddSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const UpdateRampDiscountsToAddSchema = z.object({ + apply_on: z.array( + z.enum(['invoice_amount', 'specific_item_price']).optional(), + ), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), +}); +const UpdateRampBodySchema = z.looseObject({ + effective_from: z.number().int(), + description: z.string().max(250).optional(), + coupons_to_remove: z.array(z.string().max(100).optional()).optional(), + discounts_to_remove: z.array(z.string().max(100).optional()).optional(), + items_to_remove: z.array(z.string().max(100).optional()).optional(), + contract_term: UpdateRampContractTermSchema.optional(), + items_to_add: UpdateRampItemsToAddSchema.optional(), + items_to_update: UpdateRampItemsToUpdateSchema.optional(), + item_tiers: UpdateRampItemTiersSchema.optional(), + coupons_to_add: UpdateRampCouponsToAddSchema.optional(), + discounts_to_add: UpdateRampDiscountsToAddSchema.optional(), +}); +export { UpdateRampBodySchema }; +export type UpdateRampBody = z.infer; diff --git a/src/schema/recorded_purchase.schema.ts b/src/schema/recorded_purchase.schema.ts new file mode 100644 index 0000000..62e6ce9 --- /dev/null +++ b/src/schema/recorded_purchase.schema.ts @@ -0,0 +1,36 @@ +// Generated Zod schemas: RecordedPurchase +// Actions: create +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//RecordedPurchase.create + +const CreateRecordedPurchaseCustomerSchema = z.object({ + id: z.string().max(50), +}); +const CreateRecordedPurchaseAppleAppStoreSchema = z.object({ + transaction_id: z.string().max(100).optional(), + receipt: z.string().max(65000).optional(), + product_id: z.string().max(255).optional(), +}); +const CreateRecordedPurchaseGooglePlayStoreSchema = z.object({ + purchase_token: z.string().max(500).optional(), + product_id: z.string().max(255).optional(), + order_id: z.string().max(100).optional(), +}); +const CreateRecordedPurchaseOmnichannelSubscriptionSchema = z.object({ + id: z.string().max(50).optional(), +}); +const CreateRecordedPurchaseBodySchema = z.looseObject({ + app_id: z.string().max(100), + customer: CreateRecordedPurchaseCustomerSchema.optional(), + apple_app_store: CreateRecordedPurchaseAppleAppStoreSchema.optional(), + google_play_store: CreateRecordedPurchaseGooglePlayStoreSchema.optional(), + omnichannel_subscription: + CreateRecordedPurchaseOmnichannelSubscriptionSchema.optional(), +}); +export { CreateRecordedPurchaseBodySchema }; +export type CreateRecordedPurchaseBody = z.infer< + typeof CreateRecordedPurchaseBodySchema +>; diff --git a/src/schema/resource_migration.schema.ts b/src/schema/resource_migration.schema.ts new file mode 100644 index 0000000..b73062c --- /dev/null +++ b/src/schema/resource_migration.schema.ts @@ -0,0 +1,17 @@ +// Generated Zod schemas: ResourceMigration +// Actions: retrieveLatest +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//ResourceMigration.retrieveLatest + +const RetrieveLatestResourceMigrationBodySchema = z.looseObject({ + from_site: z.string().max(50).min(4), + entity_type: z.enum(['customer']), + entity_id: z.string().max(100), +}); +export { RetrieveLatestResourceMigrationBodySchema }; +export type RetrieveLatestResourceMigrationBody = z.infer< + typeof RetrieveLatestResourceMigrationBodySchema +>; diff --git a/src/schema/site_migration_detail.schema.ts b/src/schema/site_migration_detail.schema.ts new file mode 100644 index 0000000..f0b5987 --- /dev/null +++ b/src/schema/site_migration_detail.schema.ts @@ -0,0 +1,85 @@ +// Generated Zod schemas: SiteMigrationDetail +// Actions: list +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//SiteMigrationDetail.list + +const ListSiteMigrationDetailEntityIdAtOtherSiteSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListSiteMigrationDetailOtherSiteNameSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListSiteMigrationDetailEntityIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListSiteMigrationDetailEntityTypeSchema = z.object({ + is: z + .enum([ + 'customer', + 'subscription', + 'invoice', + 'credit_note', + 'transaction', + 'order', + ]) + .optional(), + is_not: z + .enum([ + 'customer', + 'subscription', + 'invoice', + 'credit_note', + 'transaction', + 'order', + ]) + .optional(), + in: z + .enum([ + 'customer', + 'subscription', + 'invoice', + 'credit_note', + 'transaction', + 'order', + ]) + .optional(), + not_in: z + .enum([ + 'customer', + 'subscription', + 'invoice', + 'credit_note', + 'transaction', + 'order', + ]) + .optional(), +}); +const ListSiteMigrationDetailStatusSchema = z.object({ + is: z.enum(['moved_in', 'moved_out', 'moving_out']).optional(), + is_not: z.enum(['moved_in', 'moved_out', 'moving_out']).optional(), + in: z.enum(['moved_in', 'moved_out', 'moving_out']).optional(), + not_in: z.enum(['moved_in', 'moved_out', 'moving_out']).optional(), +}); +const ListSiteMigrationDetailBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + entity_id_at_other_site: + ListSiteMigrationDetailEntityIdAtOtherSiteSchema.optional(), + other_site_name: ListSiteMigrationDetailOtherSiteNameSchema.optional(), + entity_id: ListSiteMigrationDetailEntityIdSchema.optional(), + entity_type: ListSiteMigrationDetailEntityTypeSchema.optional(), + status: ListSiteMigrationDetailStatusSchema.optional(), +}); +export { ListSiteMigrationDetailBodySchema }; +export type ListSiteMigrationDetailBody = z.infer< + typeof ListSiteMigrationDetailBodySchema +>; diff --git a/src/schema/subscription.schema.ts b/src/schema/subscription.schema.ts new file mode 100644 index 0000000..5af1f82 --- /dev/null +++ b/src/schema/subscription.schema.ts @@ -0,0 +1,3206 @@ +// Generated Zod schemas: Subscription +// Actions: create, createForCustomer, createWithItems, subscriptionsForCustomer, contractTermsForSubscription, listDiscounts, removeScheduledCancellation, removeCoupons, update, updateForItems, changeTermEnd, reactivate, addChargeAtTermEnd, chargeAddonAtTermEnd, chargeFutureRenewals, editAdvanceInvoiceSchedule, removeAdvanceInvoiceSchedule, regenerateInvoice, importSubscription, importForCustomer, importContractTerm, importUnbilledCharges, importForItems, overrideBillingProfile, pause, cancel, cancelForItems, resume, move +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Subscription.create + +const CreateSubscriptionMetaDataSchema = z.looseObject({}); +const CreateSubscriptionCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + net_term_days: z.number().int().optional(), + taxjar_exemption_category: z + .enum(['wholesale', 'government', 'other']) + .optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + allow_direct_debit: z.boolean().default(false).optional(), + consolidated_invoicing: z.boolean().optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + entity_identifier_scheme: z.string().max(50).optional(), + entity_identifier_standard: z.string().max(50).optional(), + is_einvoice_enabled: z.boolean().optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + registered_for_gst: z.boolean().optional(), + business_customer_without_vat_number: z.boolean().optional(), + exemption_details: z.array(z.string().optional()).optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), +}); +const CreateSubscriptionAdditionalInformationSchema = z.looseObject({}); +const CreateSubscriptionCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: + CreateSubscriptionAdditionalInformationSchema.optional(), +}); +const CreateSubscriptionBillingAddressSchema = z.looseObject({}); +const CreateSubscriptionBankAccountSchema = z.object({ + gateway_account_id: z.string().max(50).optional(), + iban: z.string().max(50).min(10).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + email: z.string().email().max(70).optional(), + phone: z.string().max(50).optional(), + bank_name: z.string().max(100).optional(), + account_number: z.string().max(17).min(4).optional(), + routing_number: z.string().max(9).min(3).optional(), + bank_code: z.string().max(20).optional(), + account_type: z + .enum(['checking', 'savings', 'business_checking', 'current']) + .optional(), + account_holder_type: z.enum(['individual', 'company']).optional(), + echeck_type: z.enum(['web', 'ppd', 'ccd']).optional(), + issuing_country: z.string().max(50).optional(), + swedish_identity_number: z.string().max(12).min(10).optional(), + billing_address: CreateSubscriptionBillingAddressSchema.optional(), +}); +const CreateSubscriptionPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + CreateSubscriptionAdditionalInformationSchema.optional(), +}); +const CreateSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + CreateSubscriptionAdditionalInformationSchema.optional(), +}); +const CreateSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const CreateSubscriptionContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateSubscriptionEntityIdentifiersSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + scheme: z.array(z.string().max(50).optional()).optional(), + value: z.array(z.string().max(50).optional()).optional(), + standard: z.array(z.string().max(50).optional()).optional(), +}); +const CreateSubscriptionTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateSubscriptionAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const CreateSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CreateSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const CreateSubscriptionBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + token_id: z.string().max(40).optional(), + affiliate_token: z.string().max(250).optional(), + created_from_ip: z.string().max(50).optional(), + invoice_notes: z.string().max(2000).optional(), + invoice_date: z.number().int().optional(), + meta_data: CreateSubscriptionMetaDataSchema.optional(), + invoice_immediately: z.boolean().optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), + client_profile_id: z.string().max(50).optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + customer: CreateSubscriptionCustomerSchema.optional(), + card: CreateSubscriptionCardSchema.optional(), + bank_account: CreateSubscriptionBankAccountSchema.optional(), + payment_method: CreateSubscriptionPaymentMethodSchema.optional(), + payment_intent: CreateSubscriptionPaymentIntentSchema.optional(), + billing_address: CreateSubscriptionBillingAddressSchema.optional(), + shipping_address: CreateSubscriptionShippingAddressSchema.optional(), + statement_descriptor: CreateSubscriptionStatementDescriptorSchema.optional(), + contract_term: CreateSubscriptionContractTermSchema.optional(), + entity_identifiers: CreateSubscriptionEntityIdentifiersSchema.optional(), + tax_providers_fields: CreateSubscriptionTaxProvidersFieldsSchema.optional(), + addons: CreateSubscriptionAddonsSchema.optional(), + event_based_addons: CreateSubscriptionEventBasedAddonsSchema.optional(), + coupons: CreateSubscriptionCouponsSchema.optional(), +}); +export { CreateSubscriptionBodySchema }; +export type CreateSubscriptionBody = z.infer< + typeof CreateSubscriptionBodySchema +>; + +//Subscription.createForCustomer + +const CreateForCustomerSubscriptionMetaDataSchema = z.looseObject({}); +const CreateForCustomerSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateForCustomerSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const CreateForCustomerSubscriptionAdditionalInformationSchema = z.looseObject( + {}, +); +const CreateForCustomerSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + CreateForCustomerSubscriptionAdditionalInformationSchema.optional(), +}); +const CreateForCustomerSubscriptionContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateForCustomerSubscriptionAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), +}); +const CreateForCustomerSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), +}); +const CreateForCustomerSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const CreateForCustomerSubscriptionBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + payment_source_id: z.string().max(40).optional(), + override_relationship: z.boolean().optional(), + invoice_notes: z.string().max(2000).optional(), + invoice_date: z.number().int().optional(), + meta_data: CreateForCustomerSubscriptionMetaDataSchema.optional(), + invoice_immediately: z.boolean().optional(), + replace_primary_payment_source: z.boolean().default(true).optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + shipping_address: + CreateForCustomerSubscriptionShippingAddressSchema.optional(), + statement_descriptor: + CreateForCustomerSubscriptionStatementDescriptorSchema.optional(), + payment_intent: CreateForCustomerSubscriptionPaymentIntentSchema.optional(), + contract_term: CreateForCustomerSubscriptionContractTermSchema.optional(), + addons: CreateForCustomerSubscriptionAddonsSchema.optional(), + event_based_addons: + CreateForCustomerSubscriptionEventBasedAddonsSchema.optional(), + coupons: CreateForCustomerSubscriptionCouponsSchema.optional(), +}); +export { CreateForCustomerSubscriptionBodySchema }; +export type CreateForCustomerSubscriptionBody = z.infer< + typeof CreateForCustomerSubscriptionBodySchema +>; + +//Subscription.createWithItems + +const CreateWithItemsSubscriptionMetaDataSchema = z.looseObject({}); +const CreateWithItemsSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const CreateWithItemsSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const CreateWithItemsSubscriptionAdditionalInformationSchema = z.looseObject( + {}, +); +const CreateWithItemsSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + CreateWithItemsSubscriptionAdditionalInformationSchema.optional(), +}); +const CreateWithItemsSubscriptionContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + contract_start: z.number().int().optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const CreateWithItemsSubscriptionBillingOverrideSchema = z.object({ + max_excess_payment_usage: z.number().int().min(-1).optional(), + max_refundable_credits_usage: z.number().int().min(-1).optional(), +}); +const CreateWithItemsSubscriptionSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + usage_accumulation_reset_frequency: z + .array(z.enum(['never', 'subscription_billing_frequency']).optional()) + .optional(), +}); +const CreateWithItemsSubscriptionDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateWithItemsSubscriptionItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateWithItemsSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const CreateWithItemsSubscriptionBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + business_entity_id: z.string().max(50).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + net_term_days: z.number().int().optional(), + start_date: z.number().int().optional(), + coupon: z.string().max(100).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + terms_to_charge: z.number().int().min(1).optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + payment_source_id: z.string().max(40).optional(), + override_relationship: z.boolean().optional(), + invoice_notes: z.string().max(2000).optional(), + invoice_date: z.number().int().optional(), + meta_data: CreateWithItemsSubscriptionMetaDataSchema.optional(), + invoice_immediately: z.boolean().optional(), + replace_primary_payment_source: z.boolean().default(true).optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + create_pending_invoices: z.boolean().optional(), + auto_close_invoices: z.boolean().optional(), + first_invoice_pending: z.boolean().default(false).optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + shipping_address: CreateWithItemsSubscriptionShippingAddressSchema.optional(), + statement_descriptor: + CreateWithItemsSubscriptionStatementDescriptorSchema.optional(), + payment_intent: CreateWithItemsSubscriptionPaymentIntentSchema.optional(), + contract_term: CreateWithItemsSubscriptionContractTermSchema.optional(), + billing_override: CreateWithItemsSubscriptionBillingOverrideSchema.optional(), + subscription_items: + CreateWithItemsSubscriptionSubscriptionItemsSchema.optional(), + discounts: CreateWithItemsSubscriptionDiscountsSchema.optional(), + item_tiers: CreateWithItemsSubscriptionItemTiersSchema.optional(), + coupons: CreateWithItemsSubscriptionCouponsSchema.optional(), +}); +export { CreateWithItemsSubscriptionBodySchema }; +export type CreateWithItemsSubscriptionBody = z.infer< + typeof CreateWithItemsSubscriptionBodySchema +>; + +//Subscription.subscriptionsForCustomer + +const SubscriptionsForCustomerSubscriptionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { SubscriptionsForCustomerSubscriptionBodySchema }; +export type SubscriptionsForCustomerSubscriptionBody = z.infer< + typeof SubscriptionsForCustomerSubscriptionBodySchema +>; + +//Subscription.contractTermsForSubscription + +const ContractTermsForSubscriptionSubscriptionSortBySchema = z.looseObject({ + asc: z.enum(['created_at']).optional(), + desc: z.enum(['created_at']).optional(), +}); +const ContractTermsForSubscriptionSubscriptionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + sort_by: ContractTermsForSubscriptionSubscriptionSortBySchema.optional(), +}); +export { ContractTermsForSubscriptionSubscriptionBodySchema }; +export type ContractTermsForSubscriptionSubscriptionBody = z.infer< + typeof ContractTermsForSubscriptionSubscriptionBodySchema +>; + +//Subscription.listDiscounts + +const ListDiscountsSubscriptionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { ListDiscountsSubscriptionBodySchema }; +export type ListDiscountsSubscriptionBody = z.infer< + typeof ListDiscountsSubscriptionBodySchema +>; + +//Subscription.removeScheduledCancellation + +const RemoveScheduledCancellationSubscriptionContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const RemoveScheduledCancellationSubscriptionBodySchema = z.looseObject({ + billing_cycles: z.number().int().min(0).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + contract_term: + RemoveScheduledCancellationSubscriptionContractTermSchema.optional(), +}); +export { RemoveScheduledCancellationSubscriptionBodySchema }; +export type RemoveScheduledCancellationSubscriptionBody = z.infer< + typeof RemoveScheduledCancellationSubscriptionBodySchema +>; + +//Subscription.removeCoupons + +const RemoveCouponsSubscriptionBodySchema = z.looseObject({ + coupon_ids: z.array(z.string().max(100).optional()).optional(), +}); +export { RemoveCouponsSubscriptionBodySchema }; +export type RemoveCouponsSubscriptionBody = z.infer< + typeof RemoveCouponsSubscriptionBodySchema +>; + +//Subscription.update + +const UpdateSubscriptionMetaDataSchema = z.looseObject({}); +const UpdateSubscriptionAdditionalInformationSchema = z.looseObject({}); +const UpdateSubscriptionCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: + UpdateSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateSubscriptionPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + UpdateSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + UpdateSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateSubscriptionBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const UpdateSubscriptionCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + entity_identifier_scheme: z.string().max(50).optional(), + is_einvoice_enabled: z.boolean().optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + entity_identifier_standard: z.string().max(50).optional(), + business_customer_without_vat_number: z.boolean().optional(), + registered_for_gst: z.boolean().optional(), +}); +const UpdateSubscriptionContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const UpdateSubscriptionAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + proration_type: z + .array(z.enum(['full_term', 'partial_term', 'none']).optional()) + .optional(), +}); +const UpdateSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + charge_on: z.array(z.enum(['immediately', 'on_event']).optional()).optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), +}); +const UpdateSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const UpdateSubscriptionBodySchema = z.looseObject({ + plan_id: z.string().max(100).optional(), + plan_quantity: z.number().int().min(1).optional(), + plan_unit_price: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + replace_addon_list: z.boolean().default(false).optional(), + mandatory_addons_to_remove: z + .array(z.string().max(100).optional()) + .optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + invoice_date: z.number().int().optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + coupon: z.string().max(100).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + prorate: z.boolean().optional(), + end_of_term: z.boolean().default(false).optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + token_id: z.string().max(40).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdateSubscriptionMetaDataSchema.optional(), + invoice_immediately: z.boolean().optional(), + override_relationship: z.boolean().optional(), + changes_scheduled_at: z.number().int().optional(), + change_option: z + .enum(['immediately', 'end_of_term', 'specific_date']) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), + card: UpdateSubscriptionCardSchema.optional(), + payment_method: UpdateSubscriptionPaymentMethodSchema.optional(), + payment_intent: UpdateSubscriptionPaymentIntentSchema.optional(), + billing_address: UpdateSubscriptionBillingAddressSchema.optional(), + shipping_address: UpdateSubscriptionShippingAddressSchema.optional(), + statement_descriptor: UpdateSubscriptionStatementDescriptorSchema.optional(), + customer: UpdateSubscriptionCustomerSchema.optional(), + contract_term: UpdateSubscriptionContractTermSchema.optional(), + addons: UpdateSubscriptionAddonsSchema.optional(), + event_based_addons: UpdateSubscriptionEventBasedAddonsSchema.optional(), + coupons: UpdateSubscriptionCouponsSchema.optional(), +}); +export { UpdateSubscriptionBodySchema }; +export type UpdateSubscriptionBody = z.infer< + typeof UpdateSubscriptionBodySchema +>; + +//Subscription.updateForItems + +const UpdateForItemsSubscriptionMetaDataSchema = z.looseObject({}); +const UpdateForItemsSubscriptionAdditionalInformationSchema = z.looseObject({}); +const UpdateForItemsSubscriptionCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + ip_address: z.string().max(50).optional(), + additional_information: + UpdateForItemsSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateForItemsSubscriptionPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + tmp_token: z.string().max(65000).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + UpdateForItemsSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateForItemsSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + UpdateForItemsSubscriptionAdditionalInformationSchema.optional(), +}); +const UpdateForItemsSubscriptionBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateForItemsSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const UpdateForItemsSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const UpdateForItemsSubscriptionCustomerSchema = z.object({ + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), + entity_identifier_scheme: z.string().max(50).optional(), + is_einvoice_enabled: z.boolean().optional(), + einvoicing_method: z.enum(['automatic', 'manual', 'site_default']).optional(), + entity_identifier_standard: z.string().max(50).optional(), + business_customer_without_vat_number: z.boolean().optional(), + registered_for_gst: z.boolean().optional(), +}); +const UpdateForItemsSubscriptionContractTermSchema = z.object({ + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), + contract_start: z.number().int().optional(), +}); +const UpdateForItemsSubscriptionBillingOverrideSchema = z.object({ + max_excess_payment_usage: z.number().int().min(-1).optional(), + max_refundable_credits_usage: z.number().int().min(-1).optional(), +}); +const UpdateForItemsSubscriptionSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + charge_on_option: z + .array(z.enum(['immediately', 'on_event']).optional()) + .optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), + proration_type: z + .array(z.enum(['full_term', 'partial_term', 'none']).optional()) + .optional(), + usage_accumulation_reset_frequency: z + .array(z.enum(['never', 'subscription_billing_frequency']).optional()) + .optional(), +}); +const UpdateForItemsSubscriptionDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + operation_type: z.array(z.enum(['add', 'remove']).optional()), + id: z.array(z.string().max(50).optional()).optional(), +}); +const UpdateForItemsSubscriptionItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const UpdateForItemsSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const UpdateForItemsSubscriptionBodySchema = z.looseObject({ + mandatory_items_to_remove: z.array(z.string().max(100).optional()).optional(), + replace_items_list: z.boolean().default(false).optional(), + setup_fee: z.number().int().min(0).optional(), + net_term_days: z.number().int().optional(), + invoice_date: z.number().int().optional(), + start_date: z.number().int().optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + coupon: z.string().max(100).optional(), + terms_to_charge: z.number().int().min(1).optional(), + reactivate_from: z.number().int().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + auto_collection: z.enum(['on', 'off']).optional(), + offline_payment_method: z + .enum([ + 'no_preference', + 'cash', + 'check', + 'bank_transfer', + 'ach_credit', + 'sepa_credit', + 'boleto', + 'us_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'uk_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + 'custom', + ]) + .optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + replace_coupon_list: z.boolean().default(false).optional(), + prorate: z.boolean().optional(), + end_of_term: z.boolean().default(false).optional(), + force_term_reset: z.boolean().default(false).optional(), + reactivate: z.boolean().optional(), + token_id: z.string().max(40).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: UpdateForItemsSubscriptionMetaDataSchema.optional(), + invoice_immediately: z.boolean().optional(), + override_relationship: z.boolean().optional(), + changes_scheduled_at: z.number().int().optional(), + change_option: z + .enum(['immediately', 'end_of_term', 'specific_date']) + .optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + free_period: z.number().int().min(1).optional(), + free_period_unit: z.enum(['day', 'week', 'month', 'year']).optional(), + create_pending_invoices: z.boolean().optional(), + auto_close_invoices: z.boolean().optional(), + trial_end_action: z + .enum([ + 'site_default', + 'plan_default', + 'activate_subscription', + 'cancel_subscription', + ]) + .optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + invoice_usages: z.boolean().default(false).optional(), + card: UpdateForItemsSubscriptionCardSchema.optional(), + payment_method: UpdateForItemsSubscriptionPaymentMethodSchema.optional(), + payment_intent: UpdateForItemsSubscriptionPaymentIntentSchema.optional(), + billing_address: UpdateForItemsSubscriptionBillingAddressSchema.optional(), + shipping_address: UpdateForItemsSubscriptionShippingAddressSchema.optional(), + statement_descriptor: + UpdateForItemsSubscriptionStatementDescriptorSchema.optional(), + customer: UpdateForItemsSubscriptionCustomerSchema.optional(), + contract_term: UpdateForItemsSubscriptionContractTermSchema.optional(), + billing_override: UpdateForItemsSubscriptionBillingOverrideSchema.optional(), + subscription_items: + UpdateForItemsSubscriptionSubscriptionItemsSchema.optional(), + discounts: UpdateForItemsSubscriptionDiscountsSchema.optional(), + item_tiers: UpdateForItemsSubscriptionItemTiersSchema.optional(), + coupons: UpdateForItemsSubscriptionCouponsSchema.optional(), +}); +export { UpdateForItemsSubscriptionBodySchema }; +export type UpdateForItemsSubscriptionBody = z.infer< + typeof UpdateForItemsSubscriptionBodySchema +>; + +//Subscription.changeTermEnd + +const ChangeTermEndSubscriptionBodySchema = z.looseObject({ + term_ends_at: z.number().int(), + prorate: z.boolean().optional(), + invoice_immediately: z.boolean().optional(), +}); +export { ChangeTermEndSubscriptionBodySchema }; +export type ChangeTermEndSubscriptionBody = z.infer< + typeof ChangeTermEndSubscriptionBodySchema +>; + +//Subscription.reactivate + +const ReactivateSubscriptionContractTermSchema = z.object({ + action_at_term_end: z.enum(['renew', 'evergreen', 'cancel']).optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const ReactivateSubscriptionStatementDescriptorSchema = z.object({ + descriptor: z.string().max(65000).optional(), +}); +const ReactivateSubscriptionAdditionalInformationSchema = z.looseObject({}); +const ReactivateSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + ReactivateSubscriptionAdditionalInformationSchema.optional(), +}); +const ReactivateSubscriptionBodySchema = z.looseObject({ + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + trial_period_days: z.number().int().min(1).max(365).optional(), + reactivate_from: z.number().int().optional(), + invoice_immediately: z.boolean().optional(), + billing_alignment_mode: z.enum(['immediate', 'delayed']).optional(), + terms_to_charge: z.number().int().min(1).optional(), + invoice_date: z.number().int().optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + contract_term: ReactivateSubscriptionContractTermSchema.optional(), + statement_descriptor: + ReactivateSubscriptionStatementDescriptorSchema.optional(), + payment_intent: ReactivateSubscriptionPaymentIntentSchema.optional(), +}); +export { ReactivateSubscriptionBodySchema }; +export type ReactivateSubscriptionBody = z.infer< + typeof ReactivateSubscriptionBodySchema +>; + +//Subscription.addChargeAtTermEnd + +const AddChargeAtTermEndSubscriptionBodySchema = z.looseObject({ + amount: z.number().int().min(1).optional(), + description: z.string().max(250), + amount_in_decimal: z.string().max(39).optional(), + avalara_sale_type: z + .enum(['wholesale', 'retail', 'consumed', 'vendor_use']) + .optional(), + avalara_transaction_type: z.number().int().optional(), + avalara_service_type: z.number().int().optional(), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +export { AddChargeAtTermEndSubscriptionBodySchema }; +export type AddChargeAtTermEndSubscriptionBody = z.infer< + typeof AddChargeAtTermEndSubscriptionBodySchema +>; + +//Subscription.chargeAddonAtTermEnd + +const ChargeAddonAtTermEndSubscriptionBodySchema = z.looseObject({ + addon_id: z.string().max(100), + addon_quantity: z.number().int().min(1).optional(), + addon_unit_price: z.number().int().min(0).optional(), + addon_quantity_in_decimal: z.string().max(33).optional(), + addon_unit_price_in_decimal: z.string().max(39).optional(), + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), +}); +export { ChargeAddonAtTermEndSubscriptionBodySchema }; +export type ChargeAddonAtTermEndSubscriptionBody = z.infer< + typeof ChargeAddonAtTermEndSubscriptionBodySchema +>; + +//Subscription.chargeFutureRenewals + +const ChargeFutureRenewalsSubscriptionFixedIntervalScheduleSchema = z.object({ + number_of_occurrences: z.number().int().min(1).optional(), + days_before_renewal: z.number().int().min(1).optional(), + end_schedule_on: z + .enum(['after_number_of_intervals', 'specific_date', 'subscription_end']) + .optional(), + end_date: z.number().int().optional(), +}); +const ChargeFutureRenewalsSubscriptionSpecificDatesScheduleSchema = z.object({ + terms_to_charge: z.array(z.number().int().optional()).optional(), + date: z.array(z.number().int().optional()).optional(), +}); +const ChargeFutureRenewalsSubscriptionBodySchema = z.looseObject({ + terms_to_charge: z.number().int().min(1).optional(), + invoice_immediately: z.boolean().optional(), + schedule_type: z + .enum(['immediate', 'specific_dates', 'fixed_intervals']) + .optional(), + fixed_interval_schedule: + ChargeFutureRenewalsSubscriptionFixedIntervalScheduleSchema.optional(), + specific_dates_schedule: + ChargeFutureRenewalsSubscriptionSpecificDatesScheduleSchema.optional(), +}); +export { ChargeFutureRenewalsSubscriptionBodySchema }; +export type ChargeFutureRenewalsSubscriptionBody = z.infer< + typeof ChargeFutureRenewalsSubscriptionBodySchema +>; + +//Subscription.editAdvanceInvoiceSchedule + +const EditAdvanceInvoiceScheduleSubscriptionFixedIntervalScheduleSchema = + z.object({ + number_of_occurrences: z.number().int().min(1).optional(), + days_before_renewal: z.number().int().min(1).optional(), + end_schedule_on: z + .enum(['after_number_of_intervals', 'specific_date', 'subscription_end']) + .optional(), + end_date: z.number().int().optional(), + }); +const EditAdvanceInvoiceScheduleSubscriptionSpecificDatesScheduleSchema = + z.object({ + id: z.array(z.string().max(50).optional()).optional(), + terms_to_charge: z.array(z.number().int().optional()).optional(), + date: z.array(z.number().int().optional()).optional(), + }); +const EditAdvanceInvoiceScheduleSubscriptionBodySchema = z.looseObject({ + terms_to_charge: z.number().int().min(1).optional(), + schedule_type: z.enum(['specific_dates', 'fixed_intervals']).optional(), + fixed_interval_schedule: + EditAdvanceInvoiceScheduleSubscriptionFixedIntervalScheduleSchema.optional(), + specific_dates_schedule: + EditAdvanceInvoiceScheduleSubscriptionSpecificDatesScheduleSchema.optional(), +}); +export { EditAdvanceInvoiceScheduleSubscriptionBodySchema }; +export type EditAdvanceInvoiceScheduleSubscriptionBody = z.infer< + typeof EditAdvanceInvoiceScheduleSubscriptionBodySchema +>; + +//Subscription.removeAdvanceInvoiceSchedule + +const RemoveAdvanceInvoiceScheduleSubscriptionSpecificDatesScheduleSchema = + z.object({ + id: z.array(z.string().max(50).optional()).optional(), + }); +const RemoveAdvanceInvoiceScheduleSubscriptionBodySchema = z.looseObject({ + specific_dates_schedule: + RemoveAdvanceInvoiceScheduleSubscriptionSpecificDatesScheduleSchema.optional(), +}); +export { RemoveAdvanceInvoiceScheduleSubscriptionBodySchema }; +export type RemoveAdvanceInvoiceScheduleSubscriptionBody = z.infer< + typeof RemoveAdvanceInvoiceScheduleSubscriptionBodySchema +>; + +//Subscription.regenerateInvoice + +const RegenerateInvoiceSubscriptionBodySchema = z.looseObject({ + date_from: z.number().int().optional(), + date_to: z.number().int().optional(), + prorate: z.boolean().optional(), + invoice_immediately: z.boolean().optional(), +}); +export { RegenerateInvoiceSubscriptionBodySchema }; +export type RegenerateInvoiceSubscriptionBody = z.infer< + typeof RegenerateInvoiceSubscriptionBodySchema +>; + +//Subscription.importSubscription + +const ImportSubscriptionSubscriptionMetaDataSchema = z.looseObject({}); +const ImportSubscriptionSubscriptionCustomerSchema = z.looseObject({ + id: z.string().max(50).optional(), + email: z.string().email().max(70).optional(), + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + locale: z.string().max(50).optional(), + taxability: z.enum(['taxable', 'exempt']).optional(), + entity_code: z + .enum([ + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'p', + 'q', + 'r', + 'med1', + 'med2', + ]) + .optional(), + exempt_number: z.string().max(100).optional(), + net_term_days: z.number().int().optional(), + taxjar_exemption_category: z + .enum(['wholesale', 'government', 'other']) + .optional(), + customer_type: z + .enum(['residential', 'business', 'senior_citizen', 'industrial']) + .optional(), + auto_collection: z.enum(['on', 'off']).optional(), + allow_direct_debit: z.boolean().default(false).optional(), + vat_number: z.string().max(20).optional(), + vat_number_prefix: z.string().max(10).optional(), +}); +const ImportSubscriptionSubscriptionContractTermSchema = z.object({ + id: z.string().max(50).optional(), + created_at: z.number().int().optional(), + contract_start: z.number().int().optional(), + billing_cycle: z.number().int().min(0).optional(), + total_amount_raised: z.number().int().min(0).optional(), + total_amount_raised_before_tax: z.number().int().min(0).optional(), + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const ImportSubscriptionSubscriptionAdditionalInformationSchema = z.looseObject( + {}, +); +const ImportSubscriptionSubscriptionCardSchema = z.object({ + gateway: z + .enum([ + 'chargebee', + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + tmp_token: z.string().max(300).optional(), + first_name: z.string().max(50).optional(), + last_name: z.string().max(50).optional(), + number: z.string().max(1500).optional(), + expiry_month: z.number().int().min(1).max(12).optional(), + expiry_year: z.number().int().optional(), + cvv: z.string().max(520).optional(), + preferred_scheme: z + .enum(['cartes_bancaires', 'mastercard', 'visa']) + .optional(), + billing_addr1: z.string().max(150).optional(), + billing_addr2: z.string().max(150).optional(), + billing_city: z.string().max(50).optional(), + billing_state_code: z.string().max(50).optional(), + billing_state: z.string().max(50).optional(), + billing_zip: z.string().max(20).optional(), + billing_country: z.string().max(50).optional(), + additional_information: + ImportSubscriptionSubscriptionAdditionalInformationSchema.optional(), +}); +const ImportSubscriptionSubscriptionPaymentMethodSchema = z.object({ + type: z + .enum([ + 'card', + 'paypal_express_checkout', + 'amazon_payments', + 'direct_debit', + 'generic', + 'alipay', + 'unionpay', + 'apple_pay', + 'wechat_pay', + 'ideal', + 'google_pay', + 'sofort', + 'bancontact', + 'giropay', + 'dotpay', + 'upi', + 'netbanking_emandates', + 'venmo', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'automated_bank_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + gateway: z + .enum([ + 'chargebee_payments', + 'adyen', + 'stripe', + 'wepay', + 'braintree', + 'authorize_net', + 'paypal_pro', + 'pin', + 'eway', + 'eway_rapid', + 'worldpay', + 'balanced_payments', + 'beanstream', + 'bluepay', + 'elavon', + 'first_data_global', + 'hdfc', + 'migs', + 'nmi', + 'ogone', + 'paymill', + 'paypal_payflow_pro', + 'sage_pay', + 'tco', + 'wirecard', + 'amazon_payments', + 'paypal_express_checkout', + 'gocardless', + 'orbital', + 'moneris_us', + 'moneris', + 'bluesnap', + 'cybersource', + 'vantiv', + 'checkout_com', + 'paypal', + 'ingenico_direct', + 'exact', + 'mollie', + 'quickbooks', + 'razorpay', + 'global_payments', + 'bank_of_america', + 'ecentric', + 'metrics_global', + 'windcave', + 'pay_com', + 'ebanx', + 'dlocal', + 'nuvei', + 'solidgate', + 'paystack', + 'jp_morgan', + 'deutsche_bank', + 'ezidebit', + 'twikey', + 'tempus', + 'moyasar', + 'payway', + ]) + .optional(), + gateway_account_id: z.string().max(50).optional(), + reference_id: z.string().max(200).optional(), + issuing_country: z.string().max(50).optional(), + additional_information: + ImportSubscriptionSubscriptionAdditionalInformationSchema.optional(), +}); +const ImportSubscriptionSubscriptionBillingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportSubscriptionSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportSubscriptionSubscriptionTransactionSchema = z.object({ + amount: z.number().int().min(0).optional(), + payment_method: z + .enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]) + .optional(), + reference_number: z.string().max(100).optional(), + date: z.number().int().optional(), +}); +const ImportSubscriptionSubscriptionAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), +}); +const ImportSubscriptionSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), +}); +const ImportSubscriptionSubscriptionChargedEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + last_charged_at: z.array(z.number().int().optional()).optional(), +}); +const ImportSubscriptionSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const ImportSubscriptionSubscriptionBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + client_profile_id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + auto_collection: z.enum(['on', 'off']).optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + status: z.enum([ + 'future', + 'in_trial', + 'active', + 'non_renewing', + 'paused', + 'cancelled', + 'transferred', + ]), + current_term_end: z.number().int().optional(), + current_term_start: z.number().int().optional(), + trial_start: z.number().int().optional(), + cancelled_at: z.number().int().optional(), + started_at: z.number().int().optional(), + activated_at: z.number().int().optional(), + pause_date: z.number().int().optional(), + resume_date: z.number().int().optional(), + create_current_term_invoice: z.boolean().default(false).optional(), + affiliate_token: z.string().max(250).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: ImportSubscriptionSubscriptionMetaDataSchema.optional(), + customer: ImportSubscriptionSubscriptionCustomerSchema.optional(), + contract_term: ImportSubscriptionSubscriptionContractTermSchema.optional(), + card: ImportSubscriptionSubscriptionCardSchema.optional(), + payment_method: ImportSubscriptionSubscriptionPaymentMethodSchema.optional(), + billing_address: + ImportSubscriptionSubscriptionBillingAddressSchema.optional(), + shipping_address: + ImportSubscriptionSubscriptionShippingAddressSchema.optional(), + transaction: ImportSubscriptionSubscriptionTransactionSchema.optional(), + addons: ImportSubscriptionSubscriptionAddonsSchema.optional(), + event_based_addons: + ImportSubscriptionSubscriptionEventBasedAddonsSchema.optional(), + charged_event_based_addons: + ImportSubscriptionSubscriptionChargedEventBasedAddonsSchema.optional(), + coupons: ImportSubscriptionSubscriptionCouponsSchema.optional(), +}); +export { ImportSubscriptionSubscriptionBodySchema }; +export type ImportSubscriptionSubscriptionBody = z.infer< + typeof ImportSubscriptionSubscriptionBodySchema +>; + +//Subscription.importForCustomer + +const ImportForCustomerSubscriptionMetaDataSchema = z.looseObject({}); +const ImportForCustomerSubscriptionContractTermSchema = z.object({ + id: z.string().max(50).optional(), + created_at: z.number().int().optional(), + contract_start: z.number().int().optional(), + billing_cycle: z.number().int().min(0).optional(), + total_amount_raised: z.number().int().min(0).optional(), + total_amount_raised_before_tax: z.number().int().min(0).optional(), + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const ImportForCustomerSubscriptionTransactionSchema = z.object({ + amount: z.number().int().min(0).optional(), + payment_method: z + .enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]) + .optional(), + reference_number: z.string().max(100).optional(), + date: z.number().int().optional(), +}); +const ImportForCustomerSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportForCustomerSubscriptionAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), +}); +const ImportForCustomerSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), + on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().default(true).optional()).optional(), +}); +const ImportForCustomerSubscriptionChargedEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + last_charged_at: z.array(z.number().int().optional()).optional(), +}); +const ImportForCustomerSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const ImportForCustomerSubscriptionBodySchema = z.looseObject({ + id: z.string().max(50).optional(), + plan_id: z.string().max(100), + plan_quantity: z.number().int().min(1).optional(), + plan_quantity_in_decimal: z.string().max(33).optional(), + plan_unit_price: z.number().int().min(0).optional(), + plan_unit_price_in_decimal: z.string().max(39).optional(), + setup_fee: z.number().int().min(0).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + start_date: z.number().int().optional(), + auto_collection: z.enum(['on', 'off']).optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + payment_source_id: z.string().max(40).optional(), + status: z.enum([ + 'future', + 'in_trial', + 'active', + 'non_renewing', + 'paused', + 'cancelled', + 'transferred', + ]), + current_term_end: z.number().int().optional(), + current_term_start: z.number().int().optional(), + trial_start: z.number().int().optional(), + cancelled_at: z.number().int().optional(), + started_at: z.number().int().optional(), + activated_at: z.number().int().optional(), + pause_date: z.number().int().optional(), + resume_date: z.number().int().optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + create_current_term_invoice: z.boolean().default(false).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: ImportForCustomerSubscriptionMetaDataSchema.optional(), + contract_term: ImportForCustomerSubscriptionContractTermSchema.optional(), + transaction: ImportForCustomerSubscriptionTransactionSchema.optional(), + shipping_address: + ImportForCustomerSubscriptionShippingAddressSchema.optional(), + addons: ImportForCustomerSubscriptionAddonsSchema.optional(), + event_based_addons: + ImportForCustomerSubscriptionEventBasedAddonsSchema.optional(), + charged_event_based_addons: + ImportForCustomerSubscriptionChargedEventBasedAddonsSchema.optional(), + coupons: ImportForCustomerSubscriptionCouponsSchema.optional(), +}); +export { ImportForCustomerSubscriptionBodySchema }; +export type ImportForCustomerSubscriptionBody = z.infer< + typeof ImportForCustomerSubscriptionBodySchema +>; + +//Subscription.importContractTerm + +const ImportContractTermSubscriptionContractTermSchema = z.object({ + id: z.string().max(50).optional(), + created_at: z.number().int().optional(), + contract_start: z.number().int().optional(), + contract_end: z.number().int().optional(), + status: z.enum(['active', 'completed', 'cancelled', 'terminated']).optional(), + total_amount_raised: z.number().int().min(0).optional(), + total_amount_raised_before_tax: z.number().int().min(0).optional(), + total_contract_value: z.number().int().min(0).optional(), + total_contract_value_before_tax: z.number().int().min(0).optional(), + billing_cycle: z.number().int().min(0).optional(), + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const ImportContractTermSubscriptionBodySchema = z.looseObject({ + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + contract_term: ImportContractTermSubscriptionContractTermSchema.optional(), +}); +export { ImportContractTermSubscriptionBodySchema }; +export type ImportContractTermSubscriptionBody = z.infer< + typeof ImportContractTermSubscriptionBodySchema +>; + +//Subscription.importUnbilledCharges + +const ImportUnbilledChargesSubscriptionUnbilledChargesSchema = z.object({ + id: z.array(z.string().max(40).optional()).optional(), + date_from: z.array(z.number().int().optional()), + date_to: z.array(z.number().int().optional()), + entity_type: z.array( + z + .enum([ + 'adhoc', + 'plan_item_price', + 'addon_item_price', + 'charge_item_price', + 'plan_setup', + 'plan', + 'addon', + ]) + .optional(), + ), + entity_id: z.array(z.string().max(100).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + quantity: z.array(z.number().int().min(0).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + discount_amount: z.array(z.number().int().min(0).optional()).optional(), + use_for_proration: z.array(z.boolean().default(false).optional()).optional(), + is_advance_charge: z.array(z.boolean().default(false).optional()).optional(), +}); +const ImportUnbilledChargesSubscriptionDiscountsSchema = z.object({ + unbilled_charge_id: z.array(z.string().max(40).optional()).optional(), + entity_type: z + .array( + z + .enum([ + 'item_level_coupon', + 'document_level_coupon', + 'item_level_discount', + 'document_level_discount', + ]) + .optional(), + ) + .optional(), + entity_id: z.array(z.string().max(100).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()), +}); +const ImportUnbilledChargesSubscriptionTiersSchema = z.object({ + unbilled_charge_id: z.array(z.string().max(40).optional()), + starting_unit: z.array(z.number().int().min(0).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + quantity_used: z.array(z.number().int().min(0).optional()).optional(), + unit_amount: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + quantity_used_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_amount_in_decimal: z.array(z.string().max(40).optional()).optional(), +}); +const ImportUnbilledChargesSubscriptionBodySchema = z.looseObject({ + unbilled_charges: + ImportUnbilledChargesSubscriptionUnbilledChargesSchema.optional(), + discounts: ImportUnbilledChargesSubscriptionDiscountsSchema.optional(), + tiers: ImportUnbilledChargesSubscriptionTiersSchema.optional(), +}); +export { ImportUnbilledChargesSubscriptionBodySchema }; +export type ImportUnbilledChargesSubscriptionBody = z.infer< + typeof ImportUnbilledChargesSubscriptionBodySchema +>; + +//Subscription.importForItems + +const ImportForItemsSubscriptionMetaDataSchema = z.looseObject({}); +const ImportForItemsSubscriptionContractTermSchema = z.object({ + id: z.string().max(50).optional(), + created_at: z.number().int().optional(), + contract_start: z.number().int().optional(), + billing_cycle: z.number().int().min(0).optional(), + total_amount_raised: z.number().int().min(0).optional(), + total_amount_raised_before_tax: z.number().int().min(0).optional(), + action_at_term_end: z + .enum(['renew', 'evergreen', 'cancel', 'renew_once']) + .optional(), + cancellation_cutoff_period: z.number().int().optional(), +}); +const ImportForItemsSubscriptionTransactionSchema = z.object({ + amount: z.number().int().min(0).optional(), + payment_method: z + .enum([ + 'cash', + 'check', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]) + .optional(), + reference_number: z.string().max(100).optional(), + date: z.number().int().optional(), +}); +const ImportForItemsSubscriptionShippingAddressSchema = z.object({ + first_name: z.string().max(150).optional(), + last_name: z.string().max(150).optional(), + email: z.string().email().max(70).optional(), + company: z.string().max(250).optional(), + phone: z.string().max(50).optional(), + line1: z.string().max(150).optional(), + line2: z.string().max(150).optional(), + line3: z.string().max(150).optional(), + city: z.string().max(50).optional(), + state_code: z.string().max(50).optional(), + state: z.string().max(50).optional(), + zip: z.string().max(20).optional(), + country: z.string().max(50).optional(), + validation_status: z + .enum(['not_validated', 'valid', 'partially_valid', 'invalid']) + .optional(), +}); +const ImportForItemsSubscriptionSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + billing_cycles: z.array(z.number().int().min(0).optional()).optional(), + trial_end: z.array(z.number().int().optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), + charge_on_event: z + .array( + z + .enum([ + 'subscription_creation', + 'subscription_trial_start', + 'plan_activation', + 'subscription_activation', + 'contract_termination', + ]) + .optional(), + ) + .optional(), + charge_once: z.array(z.boolean().optional()).optional(), + item_type: z.array(z.enum(['plan', 'addon', 'charge']).optional()).optional(), +}); +const ImportForItemsSubscriptionDiscountsSchema = z.object({ + apply_on: z + .array(z.enum(['invoice_amount', 'specific_item_price']).optional()) + .optional(), + duration_type: z.array( + z.enum(['one_time', 'forever', 'limited_period']).optional(), + ), + percentage: z.array(z.number().min(0.01).max(100).optional()).optional(), + amount: z.array(z.number().int().min(0).optional()).optional(), + period: z.array(z.number().int().min(1).optional()).optional(), + period_unit: z + .array(z.enum(['day', 'week', 'month', 'year']).optional()) + .optional(), + included_in_mrr: z.array(z.boolean().optional()).optional(), + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), +}); +const ImportForItemsSubscriptionChargedItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + last_charged_at: z.array(z.number().int().optional()).optional(), +}); +const ImportForItemsSubscriptionItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const ImportForItemsSubscriptionCouponsSchema = z.object({ + coupon_id: z.array(z.string().max(100).optional()).optional(), + apply_till: z.array(z.number().int().optional()).optional(), +}); +const ImportForItemsSubscriptionBodySchema = z.looseObject({ + exhausted_coupon_ids: z.array(z.string().max(100).optional()).optional(), + id: z.string().max(50).optional(), + trial_end: z.number().int().optional(), + billing_cycles: z.number().int().min(0).optional(), + setup_fee: z.number().int().min(0).optional(), + net_term_days: z.number().int().optional(), + start_date: z.number().int().optional(), + auto_collection: z.enum(['on', 'off']).optional(), + po_number: z.string().max(100).optional(), + coupon_ids: z.array(z.string().max(100).optional()).optional(), + payment_source_id: z.string().max(40).optional(), + status: z.enum([ + 'future', + 'in_trial', + 'active', + 'non_renewing', + 'paused', + 'cancelled', + 'transferred', + ]), + current_term_end: z.number().int().optional(), + current_term_start: z.number().int().optional(), + trial_start: z.number().int().optional(), + cancelled_at: z.number().int().optional(), + started_at: z.number().int().optional(), + activated_at: z.number().int().optional(), + pause_date: z.number().int().optional(), + resume_date: z.number().int().optional(), + contract_term_billing_cycle_on_renewal: z + .number() + .int() + .min(1) + .max(100) + .optional(), + create_current_term_invoice: z.boolean().default(false).optional(), + invoice_notes: z.string().max(2000).optional(), + meta_data: ImportForItemsSubscriptionMetaDataSchema.optional(), + cancel_reason_code: z.string().max(100).optional(), + create_pending_invoices: z.boolean().optional(), + auto_close_invoices: z.boolean().optional(), + contract_term: ImportForItemsSubscriptionContractTermSchema.optional(), + transaction: ImportForItemsSubscriptionTransactionSchema.optional(), + shipping_address: ImportForItemsSubscriptionShippingAddressSchema.optional(), + subscription_items: + ImportForItemsSubscriptionSubscriptionItemsSchema.optional(), + discounts: ImportForItemsSubscriptionDiscountsSchema.optional(), + charged_items: ImportForItemsSubscriptionChargedItemsSchema.optional(), + item_tiers: ImportForItemsSubscriptionItemTiersSchema.optional(), + coupons: ImportForItemsSubscriptionCouponsSchema.optional(), +}); +export { ImportForItemsSubscriptionBodySchema }; +export type ImportForItemsSubscriptionBody = z.infer< + typeof ImportForItemsSubscriptionBodySchema +>; + +//Subscription.overrideBillingProfile + +const OverrideBillingProfileSubscriptionBodySchema = z.looseObject({ + payment_source_id: z.string().max(40).optional(), + auto_collection: z.enum(['on', 'off']).optional(), +}); +export { OverrideBillingProfileSubscriptionBodySchema }; +export type OverrideBillingProfileSubscriptionBody = z.infer< + typeof OverrideBillingProfileSubscriptionBodySchema +>; + +//Subscription.pause + +const PauseSubscriptionBodySchema = z.looseObject({ + pause_option: z + .enum(['immediately', 'end_of_term', 'specific_date', 'billing_cycles']) + .optional(), + pause_date: z.number().int().optional(), + unbilled_charges_handling: z.enum(['no_action', 'invoice']).optional(), + invoice_dunning_handling: z.enum(['continue', 'stop']).optional(), + skip_billing_cycles: z.number().int().min(1).optional(), + resume_date: z.number().int().optional(), +}); +export { PauseSubscriptionBodySchema }; +export type PauseSubscriptionBody = z.infer; + +//Subscription.cancel + +const CancelSubscriptionEventBasedAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + service_period_in_days: z + .array(z.number().int().min(1).max(4000).optional()) + .optional(), +}); +const CancelSubscriptionBodySchema = z.looseObject({ + cancel_option: z + .enum([ + 'immediately', + 'end_of_term', + 'specific_date', + 'end_of_billing_term', + ]) + .optional(), + end_of_term: z.boolean().default(false).optional(), + cancel_at: z.number().int().optional(), + credit_option_for_current_term_charges: z + .enum(['none', 'prorate', 'full']) + .optional(), + unbilled_charges_option: z.enum(['invoice', 'delete']).optional(), + account_receivables_handling: z + .enum(['no_action', 'schedule_payment_collection', 'write_off']) + .optional(), + refundable_credits_handling: z + .enum(['no_action', 'schedule_refund']) + .optional(), + contract_term_cancel_option: z + .enum([ + 'terminate_immediately', + 'end_of_contract_term', + 'specific_date', + 'end_of_subscription_billing_term', + ]) + .optional(), + invoice_date: z.number().int().optional(), + cancel_reason_code: z.string().max(100).optional(), + event_based_addons: CancelSubscriptionEventBasedAddonsSchema.optional(), +}); +export { CancelSubscriptionBodySchema }; +export type CancelSubscriptionBody = z.infer< + typeof CancelSubscriptionBodySchema +>; + +//Subscription.cancelForItems + +const CancelForItemsSubscriptionSubscriptionItemsSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + service_period_days: z + .array(z.number().int().min(1).max(730).optional()) + .optional(), +}); +const CancelForItemsSubscriptionBodySchema = z.looseObject({ + cancel_option: z + .enum([ + 'immediately', + 'end_of_term', + 'specific_date', + 'end_of_billing_term', + ]) + .optional(), + end_of_term: z.boolean().default(false).optional(), + cancel_at: z.number().int().optional(), + credit_option_for_current_term_charges: z + .enum(['none', 'prorate', 'full']) + .optional(), + unbilled_charges_option: z.enum(['invoice', 'delete']).optional(), + account_receivables_handling: z + .enum(['no_action', 'schedule_payment_collection', 'write_off']) + .optional(), + refundable_credits_handling: z + .enum(['no_action', 'schedule_refund']) + .optional(), + contract_term_cancel_option: z + .enum([ + 'terminate_immediately', + 'end_of_contract_term', + 'specific_date', + 'end_of_subscription_billing_term', + ]) + .optional(), + invoice_date: z.number().int().optional(), + cancel_reason_code: z.string().max(100).optional(), + decommissioned: z.boolean().default(false).optional(), + subscription_items: + CancelForItemsSubscriptionSubscriptionItemsSchema.optional(), +}); +export { CancelForItemsSubscriptionBodySchema }; +export type CancelForItemsSubscriptionBody = z.infer< + typeof CancelForItemsSubscriptionBodySchema +>; + +//Subscription.resume + +const ResumeSubscriptionAdditionalInformationSchema = z.looseObject({}); +const ResumeSubscriptionPaymentIntentSchema = z.object({ + id: z.string().max(150).optional(), + gateway_account_id: z.string().max(50).optional(), + gw_token: z.string().max(65000).optional(), + payment_method_type: z + .enum([ + 'card', + 'ideal', + 'sofort', + 'bancontact', + 'google_pay', + 'dotpay', + 'giropay', + 'apple_pay', + 'upi', + 'netbanking_emandates', + 'paypal_express_checkout', + 'direct_debit', + 'boleto', + 'venmo', + 'amazon_payments', + 'pay_to', + 'faster_payments', + 'sepa_instant_transfer', + 'klarna_pay_now', + 'online_banking_poland', + 'payconiq_by_bancontact', + 'electronic_payment_standard', + 'kbc_payment_button', + 'pay_by_bank', + 'trustly', + 'stablecoin', + 'kakao_pay', + 'naver_pay', + 'revolut_pay', + 'cash_app_pay', + 'wechat_pay', + 'alipay', + 'pix', + 'twint', + 'go_pay', + 'grab_pay', + 'pay_co', + 'after_pay', + 'swish', + 'payme', + ]) + .optional(), + reference_id: z.string().max(65000).optional(), + gw_payment_method_id: z.string().max(65000).optional(), + additional_information: + ResumeSubscriptionAdditionalInformationSchema.optional(), +}); +const ResumeSubscriptionBodySchema = z.looseObject({ + resume_option: z.enum(['immediately', 'specific_date']).optional(), + resume_date: z.number().int().optional(), + charges_handling: z + .enum(['invoice_immediately', 'add_to_unbilled_charges']) + .optional(), + unpaid_invoices_handling: z + .enum(['no_action', 'schedule_payment_collection']) + .optional(), + payment_initiator: z.enum(['customer', 'merchant']).optional(), + payment_intent: ResumeSubscriptionPaymentIntentSchema.optional(), +}); +export { ResumeSubscriptionBodySchema }; +export type ResumeSubscriptionBody = z.infer< + typeof ResumeSubscriptionBodySchema +>; + +//Subscription.move + +const MoveSubscriptionBodySchema = z.looseObject({ + to_customer_id: z.string().max(50), + copy_payment_source: z.boolean().default(false).optional(), +}); +export { MoveSubscriptionBodySchema }; +export type MoveSubscriptionBody = z.infer; diff --git a/src/schema/subscription_entitlement.schema.ts b/src/schema/subscription_entitlement.schema.ts new file mode 100644 index 0000000..e7d53fc --- /dev/null +++ b/src/schema/subscription_entitlement.schema.ts @@ -0,0 +1,39 @@ +// Generated Zod schemas: SubscriptionEntitlement +// Actions: subscriptionEntitlementsForSubscription, setSubscriptionEntitlementAvailability +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//SubscriptionEntitlement.subscriptionEntitlementsForSubscription + +const SubscriptionEntitlementsForSubscriptionSubscriptionEntitlementBodySchema = + z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + include_drafts: z.boolean().default(false).optional(), + embed: z.string().max(1000).optional(), + include_scheduled_overrides: z.boolean().default(false).optional(), + }); +export { SubscriptionEntitlementsForSubscriptionSubscriptionEntitlementBodySchema }; +export type SubscriptionEntitlementsForSubscriptionSubscriptionEntitlementBody = + z.infer< + typeof SubscriptionEntitlementsForSubscriptionSubscriptionEntitlementBodySchema + >; + +//SubscriptionEntitlement.setSubscriptionEntitlementAvailability + +const SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementSubscriptionEntitlementsSchema = + z.object({ + feature_id: z.array(z.string().max(50).optional()), + }); +const SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementBodySchema = + z.looseObject({ + is_enabled: z.boolean(), + subscription_entitlements: + SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementSubscriptionEntitlementsSchema.optional(), + }); +export { SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementBodySchema }; +export type SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementBody = + z.infer< + typeof SetSubscriptionEntitlementAvailabilitySubscriptionEntitlementBodySchema + >; diff --git a/src/schema/time_machine.schema.ts b/src/schema/time_machine.schema.ts new file mode 100644 index 0000000..d5f6d5d --- /dev/null +++ b/src/schema/time_machine.schema.ts @@ -0,0 +1,25 @@ +// Generated Zod schemas: TimeMachine +// Actions: startAfresh, travelForward +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//TimeMachine.startAfresh + +const StartAfreshTimeMachineBodySchema = z.looseObject({ + genesis_time: z.number().int().optional(), +}); +export { StartAfreshTimeMachineBodySchema }; +export type StartAfreshTimeMachineBody = z.infer< + typeof StartAfreshTimeMachineBodySchema +>; + +//TimeMachine.travelForward + +const TravelForwardTimeMachineBodySchema = z.looseObject({ + destination_time: z.number().int().optional(), +}); +export { TravelForwardTimeMachineBodySchema }; +export type TravelForwardTimeMachineBody = z.infer< + typeof TravelForwardTimeMachineBodySchema +>; diff --git a/src/schema/transaction.schema.ts b/src/schema/transaction.schema.ts new file mode 100644 index 0000000..15024f8 --- /dev/null +++ b/src/schema/transaction.schema.ts @@ -0,0 +1,106 @@ +// Generated Zod schemas: Transaction +// Actions: createAuthorization, recordRefund, reconcile, refund, transactionsForCustomer, transactionsForSubscription, paymentsForInvoice, deleteOfflineTransaction +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Transaction.createAuthorization + +const CreateAuthorizationTransactionBodySchema = z.looseObject({ + customer_id: z.string().max(50), + payment_source_id: z.string().max(40).optional(), + currency_code: z.string().max(3).optional(), + amount: z.number().int().min(1), +}); +export { CreateAuthorizationTransactionBodySchema }; +export type CreateAuthorizationTransactionBody = z.infer< + typeof CreateAuthorizationTransactionBodySchema +>; + +//Transaction.recordRefund + +const RecordRefundTransactionBodySchema = z.looseObject({ + amount: z.number().int().min(1).optional(), + payment_method: z.enum([ + 'cash', + 'check', + 'chargeback', + 'bank_transfer', + 'other', + 'app_store', + 'play_store', + 'custom', + ]), + date: z.number().int(), + reference_number: z.string().max(100).optional(), + custom_payment_method_id: z.string().max(50).optional(), + comment: z.string().max(300).optional(), +}); +export { RecordRefundTransactionBodySchema }; +export type RecordRefundTransactionBody = z.infer< + typeof RecordRefundTransactionBodySchema +>; + +//Transaction.reconcile + +const ReconcileTransactionBodySchema = z.looseObject({ + id_at_gateway: z.string().max(100).optional(), + customer_id: z.string().max(50).optional(), + status: z.enum(['success', 'failure']).optional(), +}); +export { ReconcileTransactionBodySchema }; +export type ReconcileTransactionBody = z.infer< + typeof ReconcileTransactionBodySchema +>; + +//Transaction.refund + +const RefundTransactionBodySchema = z.looseObject({ + amount: z.number().int().min(1).optional(), + comment: z.string().max(300).optional(), +}); +export { RefundTransactionBodySchema }; +export type RefundTransactionBody = z.infer; + +//Transaction.transactionsForCustomer + +const TransactionsForCustomerTransactionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { TransactionsForCustomerTransactionBodySchema }; +export type TransactionsForCustomerTransactionBody = z.infer< + typeof TransactionsForCustomerTransactionBodySchema +>; + +//Transaction.transactionsForSubscription + +const TransactionsForSubscriptionTransactionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { TransactionsForSubscriptionTransactionBodySchema }; +export type TransactionsForSubscriptionTransactionBody = z.infer< + typeof TransactionsForSubscriptionTransactionBodySchema +>; + +//Transaction.paymentsForInvoice + +const PaymentsForInvoiceTransactionBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { PaymentsForInvoiceTransactionBodySchema }; +export type PaymentsForInvoiceTransactionBody = z.infer< + typeof PaymentsForInvoiceTransactionBodySchema +>; + +//Transaction.deleteOfflineTransaction + +const DeleteOfflineTransactionTransactionBodySchema = z.looseObject({ + comment: z.string().max(300).optional(), +}); +export { DeleteOfflineTransactionTransactionBodySchema }; +export type DeleteOfflineTransactionTransactionBody = z.infer< + typeof DeleteOfflineTransactionTransactionBodySchema +>; diff --git a/src/schema/unbilled_charge.schema.ts b/src/schema/unbilled_charge.schema.ts new file mode 100644 index 0000000..0863259 --- /dev/null +++ b/src/schema/unbilled_charge.schema.ts @@ -0,0 +1,132 @@ +// Generated Zod schemas: UnbilledCharge +// Actions: createUnbilledCharge, create, invoiceUnbilledCharges, invoiceNowEstimate +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//UnbilledCharge.createUnbilledCharge + +const CreateUnbilledChargeUnbilledChargeAddonsSchema = z.object({ + id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateUnbilledChargeUnbilledChargeChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateUnbilledChargeUnbilledChargeTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateUnbilledChargeUnbilledChargeBodySchema = z.looseObject({ + subscription_id: z.string().max(50), + currency_code: z.string().max(3).optional(), + addons: CreateUnbilledChargeUnbilledChargeAddonsSchema.optional(), + charges: CreateUnbilledChargeUnbilledChargeChargesSchema.optional(), + tax_providers_fields: + CreateUnbilledChargeUnbilledChargeTaxProvidersFieldsSchema.optional(), +}); +export { CreateUnbilledChargeUnbilledChargeBodySchema }; +export type CreateUnbilledChargeUnbilledChargeBody = z.infer< + typeof CreateUnbilledChargeUnbilledChargeBodySchema +>; + +//UnbilledCharge.create + +const CreateUnbilledChargeItemPricesSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + quantity: z.array(z.number().int().min(1).optional()).optional(), + quantity_in_decimal: z.array(z.string().max(33).optional()).optional(), + unit_price: z.array(z.number().int().min(0).optional()).optional(), + unit_price_in_decimal: z.array(z.string().max(39).optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateUnbilledChargeItemTiersSchema = z.object({ + item_price_id: z.array(z.string().max(100).optional()).optional(), + starting_unit: z.array(z.number().int().min(1).optional()).optional(), + ending_unit: z.array(z.number().int().optional()).optional(), + price: z.array(z.number().int().min(0).optional()).optional(), + starting_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + ending_unit_in_decimal: z.array(z.string().max(33).optional()).optional(), + price_in_decimal: z.array(z.string().max(39).optional()).optional(), + pricing_type: z + .array(z.enum(['per_unit', 'flat_fee', 'package']).optional()) + .optional(), + package_size: z.array(z.number().int().min(1).optional()).optional(), +}); +const CreateUnbilledChargeChargesSchema = z.object({ + amount: z.array(z.number().int().min(1).optional()).optional(), + amount_in_decimal: z.array(z.string().max(39).optional()).optional(), + description: z.array(z.string().max(250).optional()).optional(), + taxable: z.array(z.boolean().default(true).optional()).optional(), + tax_profile_id: z.array(z.string().max(50).optional()).optional(), + avalara_tax_code: z.array(z.string().max(50).optional()).optional(), + hsn_code: z.array(z.string().max(50).optional()).optional(), + taxjar_product_code: z.array(z.string().max(50).optional()).optional(), + avalara_sale_type: z + .array(z.enum(['wholesale', 'retail', 'consumed', 'vendor_use']).optional()) + .optional(), + avalara_transaction_type: z.array(z.number().int().optional()).optional(), + avalara_service_type: z.array(z.number().int().optional()).optional(), + date_from: z.array(z.number().int().optional()).optional(), + date_to: z.array(z.number().int().optional()).optional(), +}); +const CreateUnbilledChargeTaxProvidersFieldsSchema = z.object({ + provider_name: z.array(z.string().max(50).optional()).optional(), + field_id: z.array(z.string().max(50).optional()).optional(), + field_value: z.array(z.string().max(50).optional()).optional(), +}); +const CreateUnbilledChargeBodySchema = z.looseObject({ + subscription_id: z.string().max(50), + currency_code: z.string().max(3).optional(), + item_prices: CreateUnbilledChargeItemPricesSchema.optional(), + item_tiers: CreateUnbilledChargeItemTiersSchema.optional(), + charges: CreateUnbilledChargeChargesSchema.optional(), + tax_providers_fields: CreateUnbilledChargeTaxProvidersFieldsSchema.optional(), +}); +export { CreateUnbilledChargeBodySchema }; +export type CreateUnbilledChargeBody = z.infer< + typeof CreateUnbilledChargeBodySchema +>; + +//UnbilledCharge.invoiceUnbilledCharges + +const InvoiceUnbilledChargesUnbilledChargeBodySchema = z.looseObject({ + subscription_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), +}); +export { InvoiceUnbilledChargesUnbilledChargeBodySchema }; +export type InvoiceUnbilledChargesUnbilledChargeBody = z.infer< + typeof InvoiceUnbilledChargesUnbilledChargeBodySchema +>; + +//UnbilledCharge.invoiceNowEstimate + +const InvoiceNowEstimateUnbilledChargeBodySchema = z.looseObject({ + subscription_id: z.string().max(50).optional(), + customer_id: z.string().max(50).optional(), +}); +export { InvoiceNowEstimateUnbilledChargeBodySchema }; +export type InvoiceNowEstimateUnbilledChargeBody = z.infer< + typeof InvoiceNowEstimateUnbilledChargeBodySchema +>; diff --git a/src/schema/usage.schema.ts b/src/schema/usage.schema.ts new file mode 100644 index 0000000..094ea92 --- /dev/null +++ b/src/schema/usage.schema.ts @@ -0,0 +1,106 @@ +// Generated Zod schemas: Usage +// Actions: create, retrieve, delete, list, pdf +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//Usage.create + +const CreateUsageBodySchema = z.looseObject({ + id: z.string().max(100).optional(), + item_price_id: z.string().max(100), + quantity: z.string().max(40), + usage_date: z.number().int(), + dedupe_option: z.enum(['skip', 'update_existing']).optional(), + note: z.string().max(500).optional(), +}); +export { CreateUsageBodySchema }; +export type CreateUsageBody = z.infer; + +//Usage.retrieve + +const RetrieveUsageBodySchema = z.looseObject({ + id: z.string().max(100), +}); +export { RetrieveUsageBodySchema }; +export type RetrieveUsageBody = z.infer; + +//Usage.delete + +const DeleteUsageBodySchema = z.looseObject({ + id: z.string().max(100), +}); +export { DeleteUsageBodySchema }; +export type DeleteUsageBody = z.infer; + +//Usage.list + +const ListUsageIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListUsageSubscriptionIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListUsageUsageDateSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ListUsageUpdatedAtSchema = z.object({ + after: z.string().regex(RegExp('^d{10}$')).optional(), + before: z.string().regex(RegExp('^d{10}$')).optional(), + on: z.string().regex(RegExp('^d{10}$')).optional(), + between: z.string().regex(RegExp('^[d{10},d{10}]$')).optional(), +}); +const ListUsageItemPriceIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), +}); +const ListUsageInvoiceIdSchema = z.object({ + is: z.string().min(1).optional(), + is_not: z.string().min(1).optional(), + starts_with: z.string().min(1).optional(), + is_present: z.enum(['true', 'false']).optional(), +}); +const ListUsageSourceSchema = z.object({ + is: z.enum(['admin_console', 'api', 'bulk_operation']).optional(), + is_not: z.enum(['admin_console', 'api', 'bulk_operation']).optional(), + in: z.enum(['admin_console', 'api', 'bulk_operation']).optional(), + not_in: z.enum(['admin_console', 'api', 'bulk_operation']).optional(), +}); +const ListUsageSortBySchema = z.looseObject({ + asc: z.enum(['usage_date', 'updated_at']).optional(), + desc: z.enum(['usage_date', 'updated_at']).optional(), +}); +const ListUsageBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + id: ListUsageIdSchema.optional(), + subscription_id: ListUsageSubscriptionIdSchema.optional(), + usage_date: ListUsageUsageDateSchema.optional(), + updated_at: ListUsageUpdatedAtSchema.optional(), + item_price_id: ListUsageItemPriceIdSchema.optional(), + invoice_id: ListUsageInvoiceIdSchema.optional(), + source: ListUsageSourceSchema.optional(), + sort_by: ListUsageSortBySchema.optional(), +}); +export { ListUsageBodySchema }; +export type ListUsageBody = z.infer; + +//Usage.pdf + +const PdfUsageInvoiceSchema = z.object({ + id: z.string().max(50), +}); +const PdfUsageBodySchema = z.looseObject({ + disposition_type: z.enum(['attachment', 'inline']).optional(), + invoice: PdfUsageInvoiceSchema.optional(), +}); +export { PdfUsageBodySchema }; +export type PdfUsageBody = z.infer; diff --git a/src/schema/usage_charge.schema.ts b/src/schema/usage_charge.schema.ts new file mode 100644 index 0000000..d03962d --- /dev/null +++ b/src/schema/usage_charge.schema.ts @@ -0,0 +1,21 @@ +// Generated Zod schemas: UsageCharge +// Actions: retrieveUsageChargesForSubscription +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//UsageCharge.retrieveUsageChargesForSubscription + +const RetrieveUsageChargesForSubscriptionUsageChargeFeatureIdSchema = z.object({ + is: z.string().min(1).optional(), +}); +const RetrieveUsageChargesForSubscriptionUsageChargeBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + feature_id: + RetrieveUsageChargesForSubscriptionUsageChargeFeatureIdSchema.optional(), +}); +export { RetrieveUsageChargesForSubscriptionUsageChargeBodySchema }; +export type RetrieveUsageChargesForSubscriptionUsageChargeBody = z.infer< + typeof RetrieveUsageChargesForSubscriptionUsageChargeBodySchema +>; diff --git a/src/schema/usage_event.schema.ts b/src/schema/usage_event.schema.ts new file mode 100644 index 0000000..5a765b9 --- /dev/null +++ b/src/schema/usage_event.schema.ts @@ -0,0 +1,34 @@ +// Generated Zod schemas: UsageEvent +// Actions: create, batchIngest +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//UsageEvent.create + +const CreateUsageEventPropertiesSchema = z.looseObject({}); +const CreateUsageEventBodySchema = z.looseObject({ + deduplication_id: z.string().max(36), + subscription_id: z.string().max(50), + usage_timestamp: z.number().int(), + properties: CreateUsageEventPropertiesSchema, +}); +export { CreateUsageEventBodySchema }; +export type CreateUsageEventBody = z.infer; + +//UsageEvent.batchIngest + +const BatchIngestUsageEventPropertiesItemSchema = z.looseObject({}); +const BatchIngestUsageEventEventsSchema = z.object({ + deduplication_id: z.array(z.string().max(36).optional()), + subscription_id: z.array(z.string().max(50).optional()), + usage_timestamp: z.array(z.number().int().optional()), + properties: z.array(BatchIngestUsageEventPropertiesItemSchema.optional()), +}); +const BatchIngestUsageEventBodySchema = z.looseObject({ + events: BatchIngestUsageEventEventsSchema.optional(), +}); +export { BatchIngestUsageEventBodySchema }; +export type BatchIngestUsageEventBody = z.infer< + typeof BatchIngestUsageEventBodySchema +>; diff --git a/src/schema/usage_file.schema.ts b/src/schema/usage_file.schema.ts new file mode 100644 index 0000000..ac1afba --- /dev/null +++ b/src/schema/usage_file.schema.ts @@ -0,0 +1,16 @@ +// Generated Zod schemas: UsageFile +// Actions: uploadUrl +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//UsageFile.uploadUrl + +const UploadUrlUsageFileBodySchema = z.looseObject({ + file_name: z.string().max(150), + mime_type: z.string().max(100), +}); +export { UploadUrlUsageFileBodySchema }; +export type UploadUrlUsageFileBody = z.infer< + typeof UploadUrlUsageFileBodySchema +>; diff --git a/src/schema/usage_summary.schema.ts b/src/schema/usage_summary.schema.ts new file mode 100644 index 0000000..5f6ac38 --- /dev/null +++ b/src/schema/usage_summary.schema.ts @@ -0,0 +1,22 @@ +// Generated Zod schemas: UsageSummary +// Actions: retrieveUsageSummaryForSubscription +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//UsageSummary.retrieveUsageSummaryForSubscription + +const RetrieveUsageSummaryForSubscriptionUsageSummaryBodySchema = z.looseObject( + { + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), + feature_id: z.string().max(100), + window_size: z.enum(['month', 'week', 'day', 'hour', 'minute']).optional(), + timeframe_start: z.number().int().optional(), + timeframe_end: z.number().int().optional(), + }, +); +export { RetrieveUsageSummaryForSubscriptionUsageSummaryBodySchema }; +export type RetrieveUsageSummaryForSubscriptionUsageSummaryBody = z.infer< + typeof RetrieveUsageSummaryForSubscriptionUsageSummaryBodySchema +>; diff --git a/src/schema/virtual_bank_account.schema.ts b/src/schema/virtual_bank_account.schema.ts new file mode 100644 index 0000000..3133cc7 --- /dev/null +++ b/src/schema/virtual_bank_account.schema.ts @@ -0,0 +1,51 @@ +// Generated Zod schemas: VirtualBankAccount +// Actions: createUsingPermanentToken, create +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//VirtualBankAccount.createUsingPermanentToken + +const CreateUsingPermanentTokenVirtualBankAccountBodySchema = z.looseObject({ + customer_id: z.string().max(50), + reference_id: z.string().max(150), + gateway_account_id: z.string().max(50).optional(), + scheme: z + .enum([ + 'ach_credit', + 'sepa_credit', + 'us_automated_bank_transfer', + 'gb_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + ]) + .optional(), +}); +export { CreateUsingPermanentTokenVirtualBankAccountBodySchema }; +export type CreateUsingPermanentTokenVirtualBankAccountBody = z.infer< + typeof CreateUsingPermanentTokenVirtualBankAccountBodySchema +>; + +//VirtualBankAccount.create + +const CreateVirtualBankAccountBodySchema = z.looseObject({ + customer_id: z.string().max(50), + email: z.string().email().max(70).optional(), + gateway_account_id: z.string().max(50).optional(), + scheme: z + .enum([ + 'ach_credit', + 'sepa_credit', + 'us_automated_bank_transfer', + 'gb_automated_bank_transfer', + 'eu_automated_bank_transfer', + 'jp_automated_bank_transfer', + 'mx_automated_bank_transfer', + ]) + .optional(), +}); +export { CreateVirtualBankAccountBodySchema }; +export type CreateVirtualBankAccountBody = z.infer< + typeof CreateVirtualBankAccountBodySchema +>; diff --git a/src/schema/webhook_endpoint.schema.ts b/src/schema/webhook_endpoint.schema.ts new file mode 100644 index 0000000..abacc9c --- /dev/null +++ b/src/schema/webhook_endpoint.schema.ts @@ -0,0 +1,521 @@ +// Generated Zod schemas: WebhookEndpoint +// Actions: create, update, list +// Do not edit manually – regenerate via sdk-generator + +import { z } from 'zod'; + +//WebhookEndpoint.create + +const CreateWebhookEndpointBodySchema = z.looseObject({ + name: z.string().max(50), + api_version: z.enum(['v1', 'v2']).optional(), + url: z.string().max(512), + primary_url: z.boolean().default(false).optional(), + disabled: z.boolean().default(false).optional(), + basic_auth_password: z.string().max(250).optional(), + basic_auth_username: z.string().max(250).optional(), + send_card_resource: z.boolean().default(false).optional(), + chargebee_response_schema_type: z + .enum(['plans_addons', 'items', 'compat']) + .optional(), + enabled_events: z + .array( + z + .enum([ + 'coupon_created', + 'coupon_updated', + 'coupon_deleted', + 'coupon_set_created', + 'coupon_set_updated', + 'coupon_set_deleted', + 'coupon_codes_added', + 'coupon_codes_deleted', + 'coupon_codes_updated', + 'customer_created', + 'customer_changed', + 'customer_deleted', + 'customer_moved_out', + 'customer_moved_in', + 'promotional_credits_added', + 'promotional_credits_deducted', + 'subscription_created', + 'subscription_created_with_backdating', + 'subscription_started', + 'subscription_trial_end_reminder', + 'subscription_activated', + 'subscription_activated_with_backdating', + 'subscription_changed', + 'subscription_trial_extended', + 'mrr_updated', + 'subscription_changed_with_backdating', + 'subscription_cancellation_scheduled', + 'subscription_cancellation_reminder', + 'subscription_cancelled', + 'subscription_canceled_with_backdating', + 'subscription_reactivated', + 'subscription_reactivated_with_backdating', + 'subscription_renewed', + 'subscription_items_renewed', + 'subscription_scheduled_cancellation_removed', + 'subscription_changes_scheduled', + 'subscription_scheduled_changes_removed', + 'subscription_shipping_address_updated', + 'subscription_deleted', + 'subscription_paused', + 'subscription_pause_scheduled', + 'subscription_scheduled_pause_removed', + 'subscription_resumed', + 'subscription_resumption_scheduled', + 'subscription_scheduled_resumption_removed', + 'subscription_advance_invoice_schedule_added', + 'subscription_advance_invoice_schedule_updated', + 'subscription_advance_invoice_schedule_removed', + 'pending_invoice_created', + 'pending_invoice_updated', + 'invoice_generated', + 'invoice_generated_with_backdating', + 'invoice_updated', + 'invoice_deleted', + 'credit_note_created', + 'credit_note_created_with_backdating', + 'credit_note_updated', + 'credit_note_deleted', + 'payment_schedules_created', + 'payment_schedules_updated', + 'payment_schedule_scheme_created', + 'payment_schedule_scheme_deleted', + 'subscription_renewal_reminder', + 'add_usages_reminder', + 'payment_due_reminder', + 'transaction_created', + 'transaction_updated', + 'transaction_deleted', + 'payment_succeeded', + 'payment_failed', + 'dunning_updated', + 'payment_refunded', + 'payment_initiated', + 'refund_initiated', + 'netd_payment_due_reminder', + 'authorization_succeeded', + 'authorization_voided', + 'card_added', + 'card_updated', + 'card_expiry_reminder', + 'card_expired', + 'card_deleted', + 'payment_source_added', + 'payment_source_updated', + 'payment_source_deleted', + 'payment_source_expiring', + 'payment_source_expired', + 'payment_source_locally_deleted', + 'virtual_bank_account_added', + 'virtual_bank_account_updated', + 'virtual_bank_account_deleted', + 'token_created', + 'token_consumed', + 'token_expired', + 'unbilled_charges_created', + 'unbilled_charges_voided', + 'unbilled_charges_deleted', + 'unbilled_charges_invoiced', + 'order_created', + 'order_updated', + 'order_cancelled', + 'order_delivered', + 'order_returned', + 'order_ready_to_process', + 'order_ready_to_ship', + 'order_deleted', + 'order_resent', + 'quote_created', + 'quote_updated', + 'quote_deleted', + 'tax_withheld_recorded', + 'tax_withheld_deleted', + 'tax_withheld_refunded', + 'gift_scheduled', + 'gift_unclaimed', + 'gift_claimed', + 'gift_expired', + 'gift_cancelled', + 'gift_updated', + 'hierarchy_created', + 'hierarchy_deleted', + 'payment_intent_created', + 'payment_intent_updated', + 'contract_term_created', + 'contract_term_renewed', + 'contract_term_terminated', + 'contract_term_completed', + 'contract_term_cancelled', + 'item_family_created', + 'item_family_updated', + 'item_family_deleted', + 'item_created', + 'item_updated', + 'item_deleted', + 'item_price_created', + 'item_price_updated', + 'item_price_deleted', + 'attached_item_created', + 'attached_item_updated', + 'attached_item_deleted', + 'differential_price_created', + 'differential_price_updated', + 'differential_price_deleted', + 'feature_created', + 'feature_updated', + 'feature_deleted', + 'feature_activated', + 'feature_reactivated', + 'feature_archived', + 'item_entitlements_updated', + 'entitlement_overrides_updated', + 'entitlement_overrides_removed', + 'item_entitlements_removed', + 'entitlement_overrides_auto_removed', + 'subscription_entitlements_created', + 'subscription_entitlements_updated', + 'business_entity_created', + 'business_entity_updated', + 'business_entity_deleted', + 'customer_business_entity_changed', + 'subscription_business_entity_changed', + 'purchase_created', + 'voucher_created', + 'voucher_expired', + 'voucher_create_failed', + 'product_created', + 'product_updated', + 'product_deleted', + 'variant_created', + 'variant_updated', + 'variant_deleted', + 'item_price_entitlements_updated', + 'item_price_entitlements_removed', + 'subscription_ramp_created', + 'subscription_ramp_deleted', + 'subscription_ramp_applied', + 'subscription_ramp_drafted', + 'subscription_ramp_updated', + 'price_variant_created', + 'price_variant_updated', + 'price_variant_deleted', + 'customer_entitlements_updated', + 'subscription_moved_in', + 'subscription_moved_out', + 'subscription_movement_failed', + 'omnichannel_subscription_created', + 'omnichannel_subscription_item_renewed', + 'omnichannel_subscription_item_downgrade_scheduled', + 'omnichannel_subscription_item_scheduled_downgrade_removed', + 'omnichannel_subscription_item_downgraded', + 'omnichannel_subscription_item_expired', + 'omnichannel_subscription_item_cancellation_scheduled', + 'omnichannel_subscription_item_scheduled_cancellation_removed', + 'omnichannel_subscription_item_resubscribed', + 'omnichannel_subscription_item_upgraded', + 'omnichannel_subscription_item_cancelled', + 'omnichannel_subscription_imported', + 'omnichannel_subscription_item_grace_period_started', + 'omnichannel_subscription_item_grace_period_expired', + 'omnichannel_subscription_item_dunning_started', + 'omnichannel_subscription_item_dunning_expired', + 'rule_created', + 'rule_updated', + 'rule_deleted', + 'record_purchase_failed', + 'omnichannel_subscription_item_change_scheduled', + 'omnichannel_subscription_item_scheduled_change_removed', + 'omnichannel_subscription_item_reactivated', + 'sales_order_created', + 'sales_order_updated', + 'omnichannel_subscription_item_changed', + 'omnichannel_subscription_item_paused', + 'omnichannel_subscription_item_resumed', + 'omnichannel_one_time_order_created', + 'omnichannel_one_time_order_item_cancelled', + 'usage_file_ingested', + 'omnichannel_subscription_item_pause_scheduled', + 'omnichannel_subscription_moved_in', + 'omnichannel_transaction_created', + 'alert_status_changed', + 'plan_created', + 'plan_updated', + 'plan_deleted', + 'addon_created', + 'addon_updated', + 'addon_deleted', + ]) + .optional(), + ) + .optional(), +}); +export { CreateWebhookEndpointBodySchema }; +export type CreateWebhookEndpointBody = z.infer< + typeof CreateWebhookEndpointBodySchema +>; + +//WebhookEndpoint.update + +const UpdateWebhookEndpointBodySchema = z.looseObject({ + name: z.string().max(50).optional(), + api_version: z.enum(['v1', 'v2']).optional(), + url: z.string().max(512).optional(), + primary_url: z.boolean().default(false).optional(), + send_card_resource: z.boolean().default(false).optional(), + basic_auth_password: z.string().max(250).optional(), + basic_auth_username: z.string().max(250).optional(), + disabled: z.boolean().default(false).optional(), + enabled_events: z + .array( + z + .enum([ + 'coupon_created', + 'coupon_updated', + 'coupon_deleted', + 'coupon_set_created', + 'coupon_set_updated', + 'coupon_set_deleted', + 'coupon_codes_added', + 'coupon_codes_deleted', + 'coupon_codes_updated', + 'customer_created', + 'customer_changed', + 'customer_deleted', + 'customer_moved_out', + 'customer_moved_in', + 'promotional_credits_added', + 'promotional_credits_deducted', + 'subscription_created', + 'subscription_created_with_backdating', + 'subscription_started', + 'subscription_trial_end_reminder', + 'subscription_activated', + 'subscription_activated_with_backdating', + 'subscription_changed', + 'subscription_trial_extended', + 'mrr_updated', + 'subscription_changed_with_backdating', + 'subscription_cancellation_scheduled', + 'subscription_cancellation_reminder', + 'subscription_cancelled', + 'subscription_canceled_with_backdating', + 'subscription_reactivated', + 'subscription_reactivated_with_backdating', + 'subscription_renewed', + 'subscription_items_renewed', + 'subscription_scheduled_cancellation_removed', + 'subscription_changes_scheduled', + 'subscription_scheduled_changes_removed', + 'subscription_shipping_address_updated', + 'subscription_deleted', + 'subscription_paused', + 'subscription_pause_scheduled', + 'subscription_scheduled_pause_removed', + 'subscription_resumed', + 'subscription_resumption_scheduled', + 'subscription_scheduled_resumption_removed', + 'subscription_advance_invoice_schedule_added', + 'subscription_advance_invoice_schedule_updated', + 'subscription_advance_invoice_schedule_removed', + 'pending_invoice_created', + 'pending_invoice_updated', + 'invoice_generated', + 'invoice_generated_with_backdating', + 'invoice_updated', + 'invoice_deleted', + 'credit_note_created', + 'credit_note_created_with_backdating', + 'credit_note_updated', + 'credit_note_deleted', + 'payment_schedules_created', + 'payment_schedules_updated', + 'payment_schedule_scheme_created', + 'payment_schedule_scheme_deleted', + 'subscription_renewal_reminder', + 'add_usages_reminder', + 'payment_due_reminder', + 'transaction_created', + 'transaction_updated', + 'transaction_deleted', + 'payment_succeeded', + 'payment_failed', + 'dunning_updated', + 'payment_refunded', + 'payment_initiated', + 'refund_initiated', + 'netd_payment_due_reminder', + 'authorization_succeeded', + 'authorization_voided', + 'card_added', + 'card_updated', + 'card_expiry_reminder', + 'card_expired', + 'card_deleted', + 'payment_source_added', + 'payment_source_updated', + 'payment_source_deleted', + 'payment_source_expiring', + 'payment_source_expired', + 'payment_source_locally_deleted', + 'virtual_bank_account_added', + 'virtual_bank_account_updated', + 'virtual_bank_account_deleted', + 'token_created', + 'token_consumed', + 'token_expired', + 'unbilled_charges_created', + 'unbilled_charges_voided', + 'unbilled_charges_deleted', + 'unbilled_charges_invoiced', + 'order_created', + 'order_updated', + 'order_cancelled', + 'order_delivered', + 'order_returned', + 'order_ready_to_process', + 'order_ready_to_ship', + 'order_deleted', + 'order_resent', + 'quote_created', + 'quote_updated', + 'quote_deleted', + 'tax_withheld_recorded', + 'tax_withheld_deleted', + 'tax_withheld_refunded', + 'gift_scheduled', + 'gift_unclaimed', + 'gift_claimed', + 'gift_expired', + 'gift_cancelled', + 'gift_updated', + 'hierarchy_created', + 'hierarchy_deleted', + 'payment_intent_created', + 'payment_intent_updated', + 'contract_term_created', + 'contract_term_renewed', + 'contract_term_terminated', + 'contract_term_completed', + 'contract_term_cancelled', + 'item_family_created', + 'item_family_updated', + 'item_family_deleted', + 'item_created', + 'item_updated', + 'item_deleted', + 'item_price_created', + 'item_price_updated', + 'item_price_deleted', + 'attached_item_created', + 'attached_item_updated', + 'attached_item_deleted', + 'differential_price_created', + 'differential_price_updated', + 'differential_price_deleted', + 'feature_created', + 'feature_updated', + 'feature_deleted', + 'feature_activated', + 'feature_reactivated', + 'feature_archived', + 'item_entitlements_updated', + 'entitlement_overrides_updated', + 'entitlement_overrides_removed', + 'item_entitlements_removed', + 'entitlement_overrides_auto_removed', + 'subscription_entitlements_created', + 'subscription_entitlements_updated', + 'business_entity_created', + 'business_entity_updated', + 'business_entity_deleted', + 'customer_business_entity_changed', + 'subscription_business_entity_changed', + 'purchase_created', + 'voucher_created', + 'voucher_expired', + 'voucher_create_failed', + 'product_created', + 'product_updated', + 'product_deleted', + 'variant_created', + 'variant_updated', + 'variant_deleted', + 'item_price_entitlements_updated', + 'item_price_entitlements_removed', + 'subscription_ramp_created', + 'subscription_ramp_deleted', + 'subscription_ramp_applied', + 'subscription_ramp_drafted', + 'subscription_ramp_updated', + 'price_variant_created', + 'price_variant_updated', + 'price_variant_deleted', + 'customer_entitlements_updated', + 'subscription_moved_in', + 'subscription_moved_out', + 'subscription_movement_failed', + 'omnichannel_subscription_created', + 'omnichannel_subscription_item_renewed', + 'omnichannel_subscription_item_downgrade_scheduled', + 'omnichannel_subscription_item_scheduled_downgrade_removed', + 'omnichannel_subscription_item_downgraded', + 'omnichannel_subscription_item_expired', + 'omnichannel_subscription_item_cancellation_scheduled', + 'omnichannel_subscription_item_scheduled_cancellation_removed', + 'omnichannel_subscription_item_resubscribed', + 'omnichannel_subscription_item_upgraded', + 'omnichannel_subscription_item_cancelled', + 'omnichannel_subscription_imported', + 'omnichannel_subscription_item_grace_period_started', + 'omnichannel_subscription_item_grace_period_expired', + 'omnichannel_subscription_item_dunning_started', + 'omnichannel_subscription_item_dunning_expired', + 'rule_created', + 'rule_updated', + 'rule_deleted', + 'record_purchase_failed', + 'omnichannel_subscription_item_change_scheduled', + 'omnichannel_subscription_item_scheduled_change_removed', + 'omnichannel_subscription_item_reactivated', + 'sales_order_created', + 'sales_order_updated', + 'omnichannel_subscription_item_changed', + 'omnichannel_subscription_item_paused', + 'omnichannel_subscription_item_resumed', + 'omnichannel_one_time_order_created', + 'omnichannel_one_time_order_item_cancelled', + 'usage_file_ingested', + 'omnichannel_subscription_item_pause_scheduled', + 'omnichannel_subscription_moved_in', + 'omnichannel_transaction_created', + 'alert_status_changed', + 'plan_created', + 'plan_updated', + 'plan_deleted', + 'addon_created', + 'addon_updated', + 'addon_deleted', + ]) + .optional(), + ) + .optional(), +}); +export { UpdateWebhookEndpointBodySchema }; +export type UpdateWebhookEndpointBody = z.infer< + typeof UpdateWebhookEndpointBodySchema +>; + +//WebhookEndpoint.list + +const ListWebhookEndpointBodySchema = z.looseObject({ + limit: z.number().int().min(1).max(100).optional(), + offset: z.string().max(1000).optional(), +}); +export { ListWebhookEndpointBodySchema }; +export type ListWebhookEndpointBody = z.infer< + typeof ListWebhookEndpointBodySchema +>; diff --git a/src/types.d.ts b/src/types.d.ts index 99ac074..ae6626f 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -16,6 +16,8 @@ export type EnvType = { retryConfig?: RetryConfig; enableDebugLogs?: boolean; userAgentSuffix?: string; + /** When true, request parameters are validated against Zod schemas before each HTTP call (where a schema exists). */ + enableValidation?: boolean; }; export type RetryConfig = { @@ -40,6 +42,8 @@ export type Config = { enableDebugLogs?: boolean; userAgentSuffix?: string; httpClient?: HttpClientInterface; + /** When true, request parameters are validated against Zod schemas before each HTTP call (where a schema exists). */ + enableValidation?: boolean; }; export type Callback = (error: unknown, result: any | null) => void; @@ -62,6 +66,12 @@ export type ResourceType = { options?: { isIdempotent?: boolean; }; + /** Resource key for lazy schema loading (set when enableValidation is true). */ + resourceKey?: string; + /** Action name for lazy schema loading (set when enableValidation is true). */ + actionName?: string; + /** Optional Zod schema for opt-in request param validation. */ + validationSchema?: import('zod').ZodObject; }; type RequestWrapperType = { args: IArguments; diff --git a/src/validationLoader.ts b/src/validationLoader.ts new file mode 100644 index 0000000..c1e8533 --- /dev/null +++ b/src/validationLoader.ts @@ -0,0 +1,67 @@ +/** + * Lazy schema loader for opt-in Zod validation. + * + * Schemas are loaded on first use. Node.js automatically caches imported modules, + * so repeated imports of the same schema file are efficient. + * + * Each resource module lives at {@code schema/.schema.ts} + * and exports one body schema per action. + * + * The body schema const name follows {@code ZodNamingStrategy.bodySchemaName} in sdk-generator: + * {@code {PascalAction}{PascalResource}BodySchema} + * + * Uses native dynamic import() - TypeScript transpiles appropriately for ESM/CJS targets. + */ + +import type { ZodObject, ZodRawShape } from 'zod'; + +type AnyZodObject = ZodObject; + +function toCamel(s: string): string { + return s.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase()); +} + +function toPascal(s: string): string { + const camel = toCamel(s); + return camel.charAt(0).toUpperCase() + camel.slice(1); +} + +/** Matches ZodNamingStrategy.bodySchemaName() in sdk-generator. */ +function schemaConstName(resourceKey: string, actionName: string): string { + return toPascal(actionName) + toPascal(resourceKey) + 'BodySchema'; +} + +/** camelCase resource key → snake_case module basename (e.g. virtualBankAccount → virtual_bank_account). */ +function resourceSchemaBasename(resourceKey: string): string { + return resourceKey + .replace(/([A-Z])/g, '_$1') + .toLowerCase() + .replace(/^_/, ''); +} + +/** + * Load the Zod schema for a given resource + action. + * Returns null if no schema file exists for this combination. + * + * Node.js automatically caches the imported modules, so repeated calls + * for the same resource will reuse the cached module. + * + * TypeScript compiler handles module system differences: + * - ESM build: keeps await import() as-is + * - CJS build: transpiles to require() or Promise-based equivalent + */ +export async function getSchema( + resourceKey: string, + actionName: string, +): Promise { + const base = resourceSchemaBasename(resourceKey); + const constName = schemaConstName(resourceKey, actionName); + + try { + const mod = await import(`./schema/${base}.schema.js`); + const schema = (mod[constName] as AnyZodObject) ?? null; + return schema; + } catch { + return null; + } +} diff --git a/test/validation.test.ts b/test/validation.test.ts new file mode 100644 index 0000000..81a4120 --- /dev/null +++ b/test/validation.test.ts @@ -0,0 +1,393 @@ +import { expect } from 'chai'; +import { CreateChargebee } from '../src/createChargebee.js'; +import { ChargebeeZodValidationError } from '../src/chargebeeZodValidationError.js'; +import { getSchema } from '../src/validationLoader.js'; + +// ---- shared mock HTTP client ----------------------------------------------- +// Captures outgoing requests so tests can assert whether an HTTP call was made. +// Returns a minimal valid response so the SDK's response parsing doesn't throw. + +let capturedRequests: Request[] = []; + +const mockHttpClient = { + makeApiRequest: async (request: Request): Promise => { + capturedRequests.push(request.clone()); + return new Response(JSON.stringify({ customer: { id: 'cust_mock' } }), { + status: 200, + headers: { 'Content-Type': 'application/json' }, + }); + }, +}; + +const Chargebee = CreateChargebee(mockHttpClient); + +function createChargebee(conf: Record = {}) { + return new (Chargebee as any)({ + site: 'test-site', + apiKey: 'test-api-key', + ...conf, + }); +} + +beforeEach(() => { + capturedRequests = []; +}); + +// =========================================================================== +// Part 1 – Schema unit tests +// Tests validate the generated Zod schemas directly via getSchema(), without +// any HTTP calls. This keeps the tests fast and independent of network state. +// =========================================================================== + +describe('Validation – schema unit tests', () => { + // ── customer.create ──────────────────────────────────────────────────────── + + describe('customer.create schema', () => { + it('loads a schema for customer.create', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema).to.not.be.null; + }); + + it('accepts an empty object (all fields are optional)', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema!.safeParse({}).success).to.be.true; + }); + + it('accepts valid string fields', async () => { + const schema = await getSchema('customer', 'create'); + expect( + schema!.safeParse({ + first_name: 'Jane', + last_name: 'Doe', + company: 'Acme Inc', + phone: '+1-555-0100', + }).success, + ).to.be.true; + }); + + it('accepts a valid email address', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema!.safeParse({ email: 'jane@example.com' }).success).to.be.true; + }); + + it('accepts valid enum values for auto_collection', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema!.safeParse({ auto_collection: 'on' }).success).to.be.true; + expect(schema!.safeParse({ auto_collection: 'off' }).success).to.be.true; + }); + + it('accepts an integer for net_term_days', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema!.safeParse({ net_term_days: 30 }).success).to.be.true; + }); + + it('passes unknown keys through (looseObject / allow extra keys)', async () => { + const schema = await getSchema('customer', 'create'); + expect(schema!.safeParse({ undocumented_cf: 'value' }).success).to.be.true; + }); + + it('rejects an invalid email address', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ email: 'not-an-email' }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['email']); + }); + + it('rejects first_name exceeding maxLength(150)', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ first_name: 'a'.repeat(151) }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['first_name']); + }); + + it('rejects an invalid enum value for auto_collection', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ auto_collection: 'maybe' }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['auto_collection']); + }); + + it('rejects a non-integer for net_term_days', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ net_term_days: 1.5 }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['net_term_days']); + }); + + it('reports all violated fields in a single parse (fail-all)', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ + email: 'bad-email', + first_name: 'x'.repeat(200), + auto_collection: 'invalid', + }); + expect(result.success).to.be.false; + // All three fields should have issues reported at once. + expect(result.error!.issues.length).to.be.greaterThanOrEqual(3); + const paths = result.error!.issues.map((i) => i.path[0]); + expect(paths).to.include('email'); + expect(paths).to.include('first_name'); + expect(paths).to.include('auto_collection'); + }); + }); + + // ── customer.create – nested card sub-object ─────────────────────────────── + + describe('customer.create – nested card sub-object', () => { + it('accepts a valid card sub-object', async () => { + const schema = await getSchema('customer', 'create'); + expect( + schema!.safeParse({ card: { number: '4111111111111111', cvv: '123' } }).success, + ).to.be.true; + }); + + it('rejects card.expiry_month > 12 (max constraint)', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ card: { expiry_month: 13 } }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['card', 'expiry_month']); + }); + + it('rejects card.expiry_month < 1 (min constraint)', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ card: { expiry_month: 0 } }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['card', 'expiry_month']); + }); + + it('rejects card.gateway_account_id exceeding maxLength(50)', async () => { + const schema = await getSchema('customer', 'create'); + const result = schema!.safeParse({ + card: { gateway_account_id: 'x'.repeat(51) }, + }); + expect(result.success).to.be.false; + const paths = result.error!.issues.map((i) => i.path); + expect(paths.some((p) => p.includes('gateway_account_id'))).to.be.true; + }); + }); + + // ── customer.update ──────────────────────────────────────────────────────── + + describe('customer.update schema', () => { + it('loads a schema for customer.update', async () => { + const schema = await getSchema('customer', 'update'); + expect(schema).to.not.be.null; + }); + + it('accepts a valid email for update', async () => { + const schema = await getSchema('customer', 'update'); + expect(schema!.safeParse({ email: 'updated@example.com' }).success).to.be.true; + }); + + it('rejects an invalid email in update', async () => { + const schema = await getSchema('customer', 'update'); + const result = schema!.safeParse({ email: 'not-valid' }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['email']); + }); + }); + + // ── invoice.charge (has a required field: description) ──────────────────── + + describe('invoice.charge schema', () => { + it('loads a schema for invoice.charge', async () => { + const schema = await getSchema('invoice', 'charge'); + expect(schema).to.not.be.null; + }); + + it('accepts a payload that includes the required description', async () => { + const schema = await getSchema('invoice', 'charge'); + expect(schema!.safeParse({ description: 'Consulting fee' }).success).to.be.true; + }); + + it('accepts description alongside optional fields', async () => { + const schema = await getSchema('invoice', 'charge'); + expect( + schema!.safeParse({ description: 'Fee', amount: 500, currency_code: 'USD' }).success, + ).to.be.true; + }); + + it('rejects a payload missing the required description field', async () => { + const schema = await getSchema('invoice', 'charge'); + const result = schema!.safeParse({}); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['description']); + }); + + it('rejects amount = 0 (min constraint is 1)', async () => { + const schema = await getSchema('invoice', 'charge'); + const result = schema!.safeParse({ description: 'Fee', amount: 0 }); + expect(result.success).to.be.false; + expect(result.error!.issues[0].path).to.deep.equal(['amount']); + }); + + it('rejects a negative amount', async () => { + const schema = await getSchema('invoice', 'charge'); + const result = schema!.safeParse({ description: 'Fee', amount: -100 }); + expect(result.success).to.be.false; + }); + }); + + // ── getSchema – loader behaviour ─────────────────────────────────────────── + + describe('getSchema() loader', () => { + it('returns null for an action that has no schema', async () => { + const schema = await getSchema('customer', 'nonexistent_action_xyz'); + expect(schema).to.be.null; + }); + + it('returns null for an unknown resource', async () => { + const schema = await getSchema('nonexistent_resource_xyz', 'create'); + expect(schema).to.be.null; + }); + + it('returns the same cached object on repeated calls', async () => { + const a = await getSchema('customer', 'create'); + const b = await getSchema('customer', 'create'); + expect(a).to.equal(b); // strict reference equality → cached + }); + }); +}); + +// =========================================================================== +// Part 2 – RequestWrapper integration tests +// Tests that the SDK honours enableValidation at the API call level. +// =========================================================================== + +describe('Validation – RequestWrapper integration', () => { + // ── enableValidation: false (default) ───────────────────────────────────── + + describe('when enableValidation is false (default)', () => { + it('does not validate and still sends the HTTP request for an invalid email', async () => { + const cb = createChargebee(); // enableValidation not set → defaults to false + + await cb.customer.create({ email: 'definitely-not-an-email' }); + + expect(capturedRequests).to.have.length(1); + }); + + it('does not validate and still sends the HTTP request when a required field is missing', async () => { + const cb = createChargebee(); + + await cb.invoice.charge({}); + + expect(capturedRequests).to.have.length(1); + }); + }); + + // ── enableValidation: true ───────────────────────────────────────────────── + + describe('when enableValidation is true', () => { + it('throws ChargebeeZodValidationError for an invalid email', async () => { + const cb = createChargebee({ enableValidation: true }); + + let thrown: unknown; + try { + await cb.customer.create({ email: 'not-an-email' }); + } catch (e) { + thrown = e; + } + + expect(thrown).to.be.instanceOf(ChargebeeZodValidationError); + const err = thrown as ChargebeeZodValidationError; + expect(err.name).to.equal('ChargebeeZodValidationError'); + expect(err.message).to.include('[Chargebee] Validation failed'); + expect(err.message).to.include('email'); + // Validation must abort before any HTTP call is made. + expect(capturedRequests).to.have.length(0); + }); + + it('sets actionName to the SDK method name on the error', async () => { + const cb = createChargebee({ enableValidation: true }); + + let thrown: unknown; + try { + await cb.customer.create({ email: 'bad' }); + } catch (e) { + thrown = e; + } + + const err = thrown as ChargebeeZodValidationError; + expect(err).to.be.instanceOf(ChargebeeZodValidationError); + expect(err.actionName).to.equal('create'); + }); + + it('exposes a zodError with structured issue list', async () => { + const cb = createChargebee({ enableValidation: true }); + + let thrown: unknown; + try { + await cb.customer.create({ + email: 'bad-email', + first_name: 'x'.repeat(200), + }); + } catch (e) { + thrown = e; + } + + const err = thrown as ChargebeeZodValidationError; + expect(err).to.be.instanceOf(ChargebeeZodValidationError); + expect(err.zodError).to.exist; + expect(err.zodError.issues).to.be.an('array').with.length.greaterThan(0); + const fields = err.zodError.issues.map((i) => i.path[0]); + expect(fields).to.include('email'); + }); + + it('throws when an invalid enum value is supplied', async () => { + const cb = createChargebee({ enableValidation: true }); + + let thrown: unknown; + try { + await cb.customer.create({ auto_collection: 'definitely_invalid' }); + } catch (e) { + thrown = e; + } + + expect(thrown).to.be.instanceOf(ChargebeeZodValidationError); + expect((thrown as ChargebeeZodValidationError).message).to.include('auto_collection'); + expect(capturedRequests).to.have.length(0); + }); + + it('throws when a required field is absent (invoice.charge without description)', async () => { + const cb = createChargebee({ enableValidation: true }); + + let thrown: unknown; + try { + await cb.invoice.charge({}); + } catch (e) { + thrown = e; + } + + expect(thrown).to.be.instanceOf(ChargebeeZodValidationError); + expect((thrown as ChargebeeZodValidationError).message).to.include('description'); + expect(capturedRequests).to.have.length(0); + }); + + it('does not throw and makes the HTTP request when params are valid', async () => { + const cb = createChargebee({ enableValidation: true }); + + await cb.customer.create({ + first_name: 'Alice', + email: 'alice@example.com', + }); + + expect(capturedRequests).to.have.length(1); + }); + + it('does not throw for an empty body (all customer.create fields are optional)', async () => { + const cb = createChargebee({ enableValidation: true }); + + await cb.customer.create({}); + + expect(capturedRequests).to.have.length(1); + }); + + it('does not throw for extra unknown keys (looseObject accepts them)', async () => { + const cb = createChargebee({ enableValidation: true }); + + await cb.customer.create({ undocumented_cf_field: 'custom_value' }); + + expect(capturedRequests).to.have.length(1); + }); + }); +}); diff --git a/types/core.d.ts b/types/core.d.ts index 0a8eca1..518a0f5 100644 --- a/types/core.d.ts +++ b/types/core.d.ts @@ -5,6 +5,8 @@ declare module 'chargebee' { timeout?: number; timemachineWaitInMillis?: number; exportWaitInMillis?: number; + /** When true, request parameters are validated against Zod schemas before each HTTP call (where a schema exists). */ + enableValidation?: boolean; } export type ChargebeeResponse = T & { headers: { [key: string]: string }; diff --git a/types/index.d.ts b/types/index.d.ts index 08b1cde..b377110 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -165,6 +165,11 @@ declare module 'chargebee' { * @httpClient optional http client implementation, default http client will be used if not provided */ httpClient?: HttpClientInterface; + + /** + * @enableValidation When true, every request's parameters are validated against each endpoint's generated Zod schema before the HTTP request is sent. Violations throw `ChargebeeZodValidationError` with structured Zod issues. Calls with no params argument are validated as `{}`. Required resource ids in the URL path are still checked separately. + */ + enableValidation?: boolean; }; export interface HttpClientInterface { @@ -444,4 +449,15 @@ declare module 'chargebee' { name: string; readonly rawBody?: string; } + + /** + * Thrown when `enableValidation` is on and request parameters fail the action's Zod schema. + * Carries `actionName` and the original `ZodError` (issues, `flatten()`, etc.) for programmatic handling. + */ + export class ChargebeeZodValidationError extends Error { + constructor(actionName: string, zodError: import('zod').ZodError); + name: string; + readonly actionName: string; + readonly zodError: import('zod').ZodError; + } }