/* * 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 { lazySchema as lazySchema$, safeParse } from "../../lib/schemas.js"; import * as openEnums from "../../types/enums.js"; import { OpenEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.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 = OpenEnum; export type Subsidiaries = { /** * The ID of the subsidiary. */ id?: string | undefined; }; export type TaxRate = { /** * ID assigned to identify this tax rate. */ id?: string | null | undefined; /** * Display ID of the tax rate */ displayId?: 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; /** * Country code according to ISO 3166-1 alpha-2. */ country?: string | 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?: { [k: string]: any } | 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; /** * The subsidiaries this belongs to. */ subsidiaries?: Array | undefined; customFields?: Array | undefined; }; export type TaxRateInput = { /** * ID assigned to identify this tax rate. */ id?: string | null | undefined; /** * Display ID of the tax rate */ displayId?: 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; /** * Country code according to ISO 3166-1 alpha-2. */ country?: string | 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; /** * The subsidiaries this belongs to. */ subsidiaries?: Array | undefined; customFields?: Array | undefined; }; /** @internal */ export const Components$inboundSchema: z.ZodType< Components, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), name: types.optional(types.string()), rate: z.nullable(types.number()).optional(), compound: z.nullable(types.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 > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()).optional(), name: z.string().optional(), rate: z.nullable(z.number()).optional(), compound: z.nullable(z.boolean()).optional(), }) ); 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.ZodType< TaxRateStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(TaxRateStatus)); /** @internal */ export const TaxRateStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, TaxRateStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(TaxRateStatus)); /** @internal */ export const Subsidiaries$inboundSchema: z.ZodType< Subsidiaries, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), }) ); /** @internal */ export type Subsidiaries$Outbound = { id?: string | undefined; }; /** @internal */ export const Subsidiaries$outboundSchema: z.ZodType< Subsidiaries$Outbound, z.ZodTypeDef, Subsidiaries > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), }) ); export function subsidiariesToJSON(subsidiaries: Subsidiaries): string { return JSON.stringify(Subsidiaries$outboundSchema.parse(subsidiaries)); } export function subsidiariesFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Subsidiaries$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Subsidiaries' from JSON`, ); } /** @internal */ export const TaxRate$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), name: types.optional(types.string()), code: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), effective_tax_rate: z.nullable(types.number()).optional(), country: z.nullable(types.string()).optional(), total_tax_rate: z.nullable(types.number()).optional(), tax_payable_account_id: z.nullable(types.string()).optional(), tax_remitted_account_id: z.nullable(types.string()).optional(), components: z.nullable(z.array(z.lazy(() => Components$inboundSchema))) .optional(), type: z.nullable(types.string()).optional(), report_tax_type: z.nullable(types.string()).optional(), original_tax_rate_id: z.nullable(types.string()).optional(), status: z.nullable(TaxRateStatus$inboundSchema).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), row_version: z.nullable(types.string()).optional(), updated_by: z.nullable(types.string()).optional(), created_by: z.nullable(types.string()).optional(), updated_at: z.nullable(types.date()).optional(), created_at: z.nullable(types.date()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), subsidiaries: types.optional( z.array(z.lazy(() => Subsidiaries$inboundSchema)), ), custom_fields: types.optional(z.array(CustomField$inboundSchema)), }).transform((v) => { return remap$(v, { "display_id": "displayId", "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", "custom_fields": "customFields", }); }) ); export function taxRateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TaxRate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TaxRate' from JSON`, ); } /** @internal */ export type TaxRateInput$Outbound = { id?: string | null | undefined; display_id?: string | null | undefined; name?: string | undefined; code?: string | null | undefined; description?: string | null | undefined; effective_tax_rate?: number | null | undefined; country?: string | 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; subsidiaries?: Array | undefined; custom_fields?: Array | undefined; }; /** @internal */ export const TaxRateInput$outboundSchema: z.ZodType< TaxRateInput$Outbound, z.ZodTypeDef, TaxRateInput > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.nullable(z.string()).optional(), displayId: 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(), country: z.nullable(z.string()).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(), subsidiaries: z.array(z.lazy(() => Subsidiaries$outboundSchema)).optional(), customFields: z.array(CustomField$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", 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", customFields: "custom_fields", }); }) ); export function taxRateInputToJSON(taxRateInput: TaxRateInput): string { return JSON.stringify(TaxRateInput$outboundSchema.parse(taxRateInput)); }