/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; export type Components = { id?: string | null | undefined; name?: string | undefined; rate?: number | null | undefined; compound?: boolean | null | undefined; }; /** * Tax rate status */ export const TaxRateStatus = { Active: "active", Inactive: "inactive", Archived: "archived", } as const; /** * Tax rate status */ export type TaxRateStatus = ClosedEnum; export type TaxRate = { /** * ID assigned to identify this tax rate. */ id?: string | null | undefined; /** * Name assigned to identify this tax rate. */ name?: string | undefined; /** * Tax code assigned to identify this tax rate. */ code?: string | null | undefined; /** * Description of tax rate */ description?: string | null | undefined; /** * Effective tax rate */ effectiveTaxRate?: number | null | undefined; /** * Not compounded sum of the components of a tax rate */ totalTaxRate?: number | null | undefined; /** * Unique identifier for the account for tax collected. */ taxPayableAccountId?: string | null | undefined; /** * Unique identifier for the account for tax remitted. */ taxRemittedAccountId?: string | null | undefined; components?: Array | null | undefined; /** * Tax type used to indicate the source of tax collected or paid */ type?: string | null | undefined; /** * Report Tax type to aggregate tax collected or paid for reporting purposes */ reportTaxType?: string | null | undefined; /** * ID of the original tax rate from which the new tax rate is derived. Helps to understand the relationship between corresponding tax rate entities. */ originalTaxRateId?: string | null | undefined; /** * Tax rate status */ status?: TaxRateStatus | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | null | undefined; /** * The user who last updated the object. */ updatedBy?: string | null | undefined; /** * The user who created the object. */ createdBy?: string | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; export type TaxRateInput = { /** * ID assigned to identify this tax rate. */ id?: string | null | undefined; /** * Name assigned to identify this tax rate. */ name?: string | undefined; /** * Tax code assigned to identify this tax rate. */ code?: string | null | undefined; /** * Description of tax rate */ description?: string | null | undefined; /** * Effective tax rate */ effectiveTaxRate?: number | null | undefined; /** * Not compounded sum of the components of a tax rate */ totalTaxRate?: number | null | undefined; /** * Unique identifier for the account for tax collected. */ taxPayableAccountId?: string | null | undefined; /** * Unique identifier for the account for tax remitted. */ taxRemittedAccountId?: string | null | undefined; components?: Array | null | undefined; /** * Tax type used to indicate the source of tax collected or paid */ type?: string | null | undefined; /** * Report Tax type to aggregate tax collected or paid for reporting purposes */ reportTaxType?: string | null | undefined; /** * ID of the original tax rate from which the new tax rate is derived. Helps to understand the relationship between corresponding tax rate entities. */ originalTaxRateId?: string | null | undefined; /** * Tax rate status */ status?: TaxRateStatus | null | undefined; /** * A binary value used to detect updates to a object and prevent data conflicts. It is incremented each time an update is made to the object. */ rowVersion?: string | null | undefined; /** * The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources. */ passThrough?: Array | undefined; }; /** @internal */ export const Components$inboundSchema: z.ZodType< Components, z.ZodTypeDef, unknown > = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), rate: z.nullable(z.number()).optional(), compound: z.nullable(z.boolean()).optional(), }); /** @internal */ export type Components$Outbound = { id?: string | null | undefined; name?: string | undefined; rate?: number | null | undefined; compound?: boolean | null | undefined; }; /** @internal */ export const Components$outboundSchema: z.ZodType< Components$Outbound, z.ZodTypeDef, Components > = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), rate: z.nullable(z.number()).optional(), compound: z.nullable(z.boolean()).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Components$ { /** @deprecated use `Components$inboundSchema` instead. */ export const inboundSchema = Components$inboundSchema; /** @deprecated use `Components$outboundSchema` instead. */ export const outboundSchema = Components$outboundSchema; /** @deprecated use `Components$Outbound` instead. */ export type Outbound = Components$Outbound; } export function componentsToJSON(components: Components): string { return JSON.stringify(Components$outboundSchema.parse(components)); } export function componentsFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Components$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Components' from JSON`, ); } /** @internal */ export const TaxRateStatus$inboundSchema: z.ZodNativeEnum< typeof TaxRateStatus > = z.nativeEnum(TaxRateStatus); /** @internal */ export const TaxRateStatus$outboundSchema: z.ZodNativeEnum< typeof TaxRateStatus > = TaxRateStatus$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TaxRateStatus$ { /** @deprecated use `TaxRateStatus$inboundSchema` instead. */ export const inboundSchema = TaxRateStatus$inboundSchema; /** @deprecated use `TaxRateStatus$outboundSchema` instead. */ export const outboundSchema = TaxRateStatus$outboundSchema; } /** @internal */ export const TaxRate$inboundSchema: z.ZodType = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), code: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), effective_tax_rate: z.nullable(z.number()).optional(), total_tax_rate: z.nullable(z.number()).optional(), tax_payable_account_id: z.nullable(z.string()).optional(), tax_remitted_account_id: z.nullable(z.string()).optional(), components: z.nullable(z.array(z.lazy(() => Components$inboundSchema))) .optional(), type: z.nullable(z.string()).optional(), report_tax_type: z.nullable(z.string()).optional(), original_tax_rate_id: z.nullable(z.string()).optional(), status: z.nullable(TaxRateStatus$inboundSchema).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "effective_tax_rate": "effectiveTaxRate", "total_tax_rate": "totalTaxRate", "tax_payable_account_id": "taxPayableAccountId", "tax_remitted_account_id": "taxRemittedAccountId", "report_tax_type": "reportTaxType", "original_tax_rate_id": "originalTaxRateId", "custom_mappings": "customMappings", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }); /** @internal */ export type TaxRate$Outbound = { id?: string | null | undefined; name?: string | undefined; code?: string | null | undefined; description?: string | null | undefined; effective_tax_rate?: number | null | undefined; total_tax_rate?: number | null | undefined; tax_payable_account_id?: string | null | undefined; tax_remitted_account_id?: string | null | undefined; components?: Array | null | undefined; type?: string | null | undefined; report_tax_type?: string | null | undefined; original_tax_rate_id?: string | null | undefined; status?: string | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; row_version?: string | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const TaxRate$outboundSchema: z.ZodType< TaxRate$Outbound, z.ZodTypeDef, TaxRate > = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), code: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), effectiveTaxRate: z.nullable(z.number()).optional(), totalTaxRate: z.nullable(z.number()).optional(), taxPayableAccountId: z.nullable(z.string()).optional(), taxRemittedAccountId: z.nullable(z.string()).optional(), components: z.nullable(z.array(z.lazy(() => Components$outboundSchema))) .optional(), type: z.nullable(z.string()).optional(), reportTaxType: z.nullable(z.string()).optional(), originalTaxRateId: z.nullable(z.string()).optional(), status: z.nullable(TaxRateStatus$outboundSchema).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { effectiveTaxRate: "effective_tax_rate", totalTaxRate: "total_tax_rate", taxPayableAccountId: "tax_payable_account_id", taxRemittedAccountId: "tax_remitted_account_id", reportTaxType: "report_tax_type", originalTaxRateId: "original_tax_rate_id", customMappings: "custom_mappings", rowVersion: "row_version", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TaxRate$ { /** @deprecated use `TaxRate$inboundSchema` instead. */ export const inboundSchema = TaxRate$inboundSchema; /** @deprecated use `TaxRate$outboundSchema` instead. */ export const outboundSchema = TaxRate$outboundSchema; /** @deprecated use `TaxRate$Outbound` instead. */ export type Outbound = TaxRate$Outbound; } export function taxRateToJSON(taxRate: TaxRate): string { return JSON.stringify(TaxRate$outboundSchema.parse(taxRate)); } export function taxRateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRate' from JSON`, ); } /** @internal */ export const TaxRateInput$inboundSchema: z.ZodType< TaxRateInput, z.ZodTypeDef, unknown > = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), code: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), effective_tax_rate: z.nullable(z.number()).optional(), total_tax_rate: z.nullable(z.number()).optional(), tax_payable_account_id: z.nullable(z.string()).optional(), tax_remitted_account_id: z.nullable(z.string()).optional(), components: z.nullable(z.array(z.lazy(() => Components$inboundSchema))) .optional(), type: z.nullable(z.string()).optional(), report_tax_type: z.nullable(z.string()).optional(), original_tax_rate_id: z.nullable(z.string()).optional(), status: z.nullable(TaxRateStatus$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "effective_tax_rate": "effectiveTaxRate", "total_tax_rate": "totalTaxRate", "tax_payable_account_id": "taxPayableAccountId", "tax_remitted_account_id": "taxRemittedAccountId", "report_tax_type": "reportTaxType", "original_tax_rate_id": "originalTaxRateId", "row_version": "rowVersion", "pass_through": "passThrough", }); }); /** @internal */ export type TaxRateInput$Outbound = { id?: string | null | undefined; name?: string | undefined; code?: string | null | undefined; description?: string | null | undefined; effective_tax_rate?: number | null | undefined; total_tax_rate?: number | null | undefined; tax_payable_account_id?: string | null | undefined; tax_remitted_account_id?: string | null | undefined; components?: Array | null | undefined; type?: string | null | undefined; report_tax_type?: string | null | undefined; original_tax_rate_id?: string | null | undefined; status?: string | null | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const TaxRateInput$outboundSchema: z.ZodType< TaxRateInput$Outbound, z.ZodTypeDef, TaxRateInput > = z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), code: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), effectiveTaxRate: z.nullable(z.number()).optional(), totalTaxRate: z.nullable(z.number()).optional(), taxPayableAccountId: z.nullable(z.string()).optional(), taxRemittedAccountId: z.nullable(z.string()).optional(), components: z.nullable(z.array(z.lazy(() => Components$outboundSchema))) .optional(), type: z.nullable(z.string()).optional(), reportTaxType: z.nullable(z.string()).optional(), originalTaxRateId: z.nullable(z.string()).optional(), status: z.nullable(TaxRateStatus$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { effectiveTaxRate: "effective_tax_rate", totalTaxRate: "total_tax_rate", taxPayableAccountId: "tax_payable_account_id", taxRemittedAccountId: "tax_remitted_account_id", reportTaxType: "report_tax_type", originalTaxRateId: "original_tax_rate_id", rowVersion: "row_version", passThrough: "pass_through", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TaxRateInput$ { /** @deprecated use `TaxRateInput$inboundSchema` instead. */ export const inboundSchema = TaxRateInput$inboundSchema; /** @deprecated use `TaxRateInput$outboundSchema` instead. */ export const outboundSchema = TaxRateInput$outboundSchema; /** @deprecated use `TaxRateInput$Outbound` instead. */ export type Outbound = TaxRateInput$Outbound; } export function taxRateInputToJSON(taxRateInput: TaxRateInput): string { return JSON.stringify(TaxRateInput$outboundSchema.parse(taxRateInput)); } export function taxRateInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRateInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRateInput' from JSON`, ); }