/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * Describes the type of requirement - each type may have additional metadata properties to describe possible values, formats, etc. * * @remarks * * - `text`: free-text input, no additional requirements * - `currency`: a value representing a dollar amount, e.g. `374.55` representing `$374.55` * - `radio`: choose one of options provided, see `options` * - `select`: choose one of options provided, see `options` * - `percent`: A decimal value representing a percentage, e.g. `0.034` representing `3.4%` * - `account_number`: An account number for a tax agency, more information provided by `mask` and `prefix` * - `tax_rate`: A decimal value representing a tax rate, e.g. `0.034` representing a tax rate of `3.4%`, see `validation` for additional validation guidance * - `workers_compensation_rate`: A decimal value representing a percentage, see `risk_class_code`, `risk_class_description`, and `rate_type` */ export const TaxRequirementMetadataType = { Text: "text", Currency: "currency", Radio: "radio", Select: "select", Percent: "percent", AccountNumber: "account_number", TaxRate: "tax_rate", WorkersCompensationRate: "workers_compensation_rate", } as const; /** * Describes the type of requirement - each type may have additional metadata properties to describe possible values, formats, etc. * * @remarks * * - `text`: free-text input, no additional requirements * - `currency`: a value representing a dollar amount, e.g. `374.55` representing `$374.55` * - `radio`: choose one of options provided, see `options` * - `select`: choose one of options provided, see `options` * - `percent`: A decimal value representing a percentage, e.g. `0.034` representing `3.4%` * - `account_number`: An account number for a tax agency, more information provided by `mask` and `prefix` * - `tax_rate`: A decimal value representing a tax rate, e.g. `0.034` representing a tax rate of `3.4%`, see `validation` for additional validation guidance * - `workers_compensation_rate`: A decimal value representing a percentage, see `risk_class_code`, `risk_class_description`, and `rate_type` */ export type TaxRequirementMetadataType = ClosedEnum< typeof TaxRequirementMetadataType >; /** * The actual value to be submitted */ export type TaxRequirementMetadataValue = string | boolean; export type TaxRequirementMetadataOptions = { /** * A customer facing label for the answer */ label: string; /** * The actual value to be submitted */ value: string | boolean; /** * A less verbose label that may sometimes be available */ shortLabel?: string | null | undefined; }; /** * [for `workers_compensation_rate`] The type of rate being collected. Either: * * @remarks * - `percent`: A percentage formatted as a decimal, e.g. `0.01` for 1% * - `currency_per_hour`: A dollar amount per hour, e.g. `3.24` for $3.24/hr */ export const RateType = { Percent: "percent", CurrencyPerHour: "currency_per_hour", } as const; /** * [for `workers_compensation_rate`] The type of rate being collected. Either: * * @remarks * - `percent`: A percentage formatted as a decimal, e.g. `0.01` for 1% * - `currency_per_hour`: A dollar amount per hour, e.g. `3.24` for $3.24/hr */ export type RateType = ClosedEnum; /** * Describes the type of tax_rate validation rule */ export const TaxRequirementMetadataValidationType = { OneOf: "one_of", MinMax: "min_max", } as const; /** * Describes the type of tax_rate validation rule */ export type TaxRequirementMetadataValidationType = ClosedEnum< typeof TaxRequirementMetadataValidationType >; /** * [for `tax_rate`] Describes the validation required for the tax rate */ export type Validation = { /** * Describes the type of tax_rate validation rule */ type: TaxRequirementMetadataValidationType; /** * [for `min_max`] The inclusive lower bound of the tax rate */ min?: string | undefined; /** * [for `min_max`] The inclusive upper bound of the tax rate */ max?: string | undefined; /** * [for `one_of`] The possible, unformatted tax rates for selection. * * @remarks * - e.g. ["0.0", "0.001"] representing 0% and 0.1% */ rates?: Array | undefined; }; export type TaxRequirementMetadata = { /** * Describes the type of requirement - each type may have additional metadata properties to describe possible values, formats, etc. * * @remarks * * - `text`: free-text input, no additional requirements * - `currency`: a value representing a dollar amount, e.g. `374.55` representing `$374.55` * - `radio`: choose one of options provided, see `options` * - `select`: choose one of options provided, see `options` * - `percent`: A decimal value representing a percentage, e.g. `0.034` representing `3.4%` * - `account_number`: An account number for a tax agency, more information provided by `mask` and `prefix` * - `tax_rate`: A decimal value representing a tax rate, e.g. `0.034` representing a tax rate of `3.4%`, see `validation` for additional validation guidance * - `workers_compensation_rate`: A decimal value representing a percentage, see `risk_class_code`, `risk_class_description`, and `rate_type` */ type: TaxRequirementMetadataType; /** * [for `select` or `radio`] An array of objects describing the possible values. */ options?: Array | undefined; /** * [for `workers_compensation_rate`] The industry risk class code for the rate being requested */ riskClassCode?: string | undefined; /** * [for `workers_compensation_rate`] A description of the industry risk class for the rate being requested */ riskClassDescription?: string | undefined; /** * [for `workers_compensation_rate`] The type of rate being collected. Either: * * @remarks * - `percent`: A percentage formatted as a decimal, e.g. `0.01` for 1% * - `currency_per_hour`: A dollar amount per hour, e.g. `3.24` for $3.24/hr */ rateType?: RateType | undefined; /** * [for `account_number`] A pattern describing the format of the account number * * @remarks * * The mask is a sequence of characters representing the requirements of the actual account number. Each character in the mask represents a single character in the account number as follows: * - `#`: a digit (`\d`) * - `@`: a upper or lower case letter (`[a-zA-Z]`) * - `^`: an uppercase letter (`[A-Z]`) * - `%`: a digit or uppercase letter (`[0-9A-Z]`) * - any other character represents the literal character * * Examples: * - mask: `WHT-######` represents `WHT-` followed by 5 digits, e.g. `WHT-33421` * - mask: `%####-^^` supports values of `75544-AB` and `Z7654-HK` */ mask?: string | null | undefined; /** * [for `account_number`] A value that precedes the value to be collected - useful for display, but should not be submitted as part of the value. E.g. some tax agencies use an account number that is a company's federal ein plus two digits. In that case the mask would be `##` and the prefix `XXXXX1234`. */ prefix?: string | null | undefined; /** * [for `tax_rate`] Describes the validation required for the tax rate */ validation?: Validation | undefined; }; /** @internal */ export const TaxRequirementMetadataType$inboundSchema: z.ZodNativeEnum< typeof TaxRequirementMetadataType > = z.nativeEnum(TaxRequirementMetadataType); /** @internal */ export const TaxRequirementMetadataValue$inboundSchema: z.ZodType< TaxRequirementMetadataValue, z.ZodTypeDef, unknown > = z.union([z.string(), z.boolean()]); export function taxRequirementMetadataValueFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRequirementMetadataValue$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRequirementMetadataValue' from JSON`, ); } /** @internal */ export const TaxRequirementMetadataOptions$inboundSchema: z.ZodType< TaxRequirementMetadataOptions, z.ZodTypeDef, unknown > = z.object({ label: z.string(), value: z.union([z.string(), z.boolean()]), short_label: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "short_label": "shortLabel", }); }); export function taxRequirementMetadataOptionsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRequirementMetadataOptions$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRequirementMetadataOptions' from JSON`, ); } /** @internal */ export const RateType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(RateType); /** @internal */ export const TaxRequirementMetadataValidationType$inboundSchema: z.ZodNativeEnum = z.nativeEnum( TaxRequirementMetadataValidationType, ); /** @internal */ export const Validation$inboundSchema: z.ZodType< Validation, z.ZodTypeDef, unknown > = z.object({ type: TaxRequirementMetadataValidationType$inboundSchema, min: z.string().optional(), max: z.string().optional(), rates: z.array(z.string()).optional(), }); export function validationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Validation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Validation' from JSON`, ); } /** @internal */ export const TaxRequirementMetadata$inboundSchema: z.ZodType< TaxRequirementMetadata, z.ZodTypeDef, unknown > = z.object({ type: TaxRequirementMetadataType$inboundSchema, options: z.array(z.lazy(() => TaxRequirementMetadataOptions$inboundSchema)) .optional(), risk_class_code: z.string().optional(), risk_class_description: z.string().optional(), rate_type: RateType$inboundSchema.optional(), mask: z.nullable(z.string()).optional(), prefix: z.nullable(z.string()).optional(), validation: z.lazy(() => Validation$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "risk_class_code": "riskClassCode", "risk_class_description": "riskClassDescription", "rate_type": "rateType", }); }); export function taxRequirementMetadataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRequirementMetadata$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRequirementMetadata' from JSON`, ); }