/* * 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 { RFCDate } from "../../types/rfcdate.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { Address, Address$inboundSchema, Address$Outbound, Address$outboundSchema, } from "./address.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { Email, Email$inboundSchema, Email$Outbound, Email$outboundSchema, } from "./email.js"; import { PhoneNumber, PhoneNumber$inboundSchema, PhoneNumber$Outbound, PhoneNumber$outboundSchema, } from "./phonenumber.js"; import { TaxRate, TaxRate$inboundSchema, TaxRate$Outbound, TaxRate$outboundSchema, } from "./taxrate.js"; /** * Based on the status some functionality is enabled or disabled. */ export const CompanyStatus = { Active: "active", Inactive: "inactive", } as const; /** * Based on the status some functionality is enabled or disabled. */ export type CompanyStatus = ClosedEnum; /** * The start month of fiscal year. */ export const TheStartMonthOfFiscalYear = { January: "January", February: "February", March: "March", April: "April", May: "May", June: "June", July: "July", August: "August", September: "September", October: "October", November: "November", December: "December", } as const; /** * The start month of fiscal year. */ export type TheStartMonthOfFiscalYear = ClosedEnum< typeof TheStartMonthOfFiscalYear >; export type CompanyInfo = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The name of the company. */ companyName?: string | null | undefined; /** * Based on the status some functionality is enabled or disabled. */ status?: CompanyStatus | undefined; /** * The legal name of the company */ legalName?: string | undefined; /** * country code according to ISO 3166-1 alpha-2. */ country?: string | null | undefined; salesTaxNumber?: string | null | undefined; /** * Whether sales tax is calculated automatically for the company */ automatedSalesTax?: boolean | undefined; /** * Whether sales tax is enabled for the company */ salesTaxEnabled?: boolean | undefined; defaultSalesTax?: TaxRate | undefined; /** * Indicates the associated currency for an amount of money. Values correspond to [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217). */ currency?: Currency | null | undefined; /** * language code according to ISO 639-1. For the United States - EN */ language?: string | null | undefined; /** * The start month of fiscal year. */ fiscalYearStartMonth?: TheStartMonthOfFiscalYear | undefined; /** * Date when company file was created */ companyStartDate?: RFCDate | undefined; addresses?: Array
| undefined; phoneNumbers?: Array | undefined; emails?: Array | 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; }; /** @internal */ export const CompanyStatus$inboundSchema: z.ZodNativeEnum< typeof CompanyStatus > = z.nativeEnum(CompanyStatus); /** @internal */ export const CompanyStatus$outboundSchema: z.ZodNativeEnum< typeof CompanyStatus > = CompanyStatus$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompanyStatus$ { /** @deprecated use `CompanyStatus$inboundSchema` instead. */ export const inboundSchema = CompanyStatus$inboundSchema; /** @deprecated use `CompanyStatus$outboundSchema` instead. */ export const outboundSchema = CompanyStatus$outboundSchema; } /** @internal */ export const TheStartMonthOfFiscalYear$inboundSchema: z.ZodNativeEnum< typeof TheStartMonthOfFiscalYear > = z.nativeEnum(TheStartMonthOfFiscalYear); /** @internal */ export const TheStartMonthOfFiscalYear$outboundSchema: z.ZodNativeEnum< typeof TheStartMonthOfFiscalYear > = TheStartMonthOfFiscalYear$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TheStartMonthOfFiscalYear$ { /** @deprecated use `TheStartMonthOfFiscalYear$inboundSchema` instead. */ export const inboundSchema = TheStartMonthOfFiscalYear$inboundSchema; /** @deprecated use `TheStartMonthOfFiscalYear$outboundSchema` instead. */ export const outboundSchema = TheStartMonthOfFiscalYear$outboundSchema; } /** @internal */ export const CompanyInfo$inboundSchema: z.ZodType< CompanyInfo, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), company_name: z.nullable(z.string()).optional(), status: CompanyStatus$inboundSchema.optional(), legal_name: z.string().optional(), country: z.nullable(z.string()).optional(), sales_tax_number: z.nullable(z.string()).optional(), automated_sales_tax: z.boolean().optional(), sales_tax_enabled: z.boolean().optional(), default_sales_tax: TaxRate$inboundSchema.optional(), currency: z.nullable(Currency$inboundSchema).optional(), language: z.nullable(z.string()).optional(), fiscal_year_start_month: TheStartMonthOfFiscalYear$inboundSchema.optional(), company_start_date: z.string().transform(v => new RFCDate(v)).optional(), addresses: z.array(Address$inboundSchema).optional(), phone_numbers: z.array(PhoneNumber$inboundSchema).optional(), emails: z.array(Email$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(), }).transform((v) => { return remap$(v, { "company_name": "companyName", "legal_name": "legalName", "sales_tax_number": "salesTaxNumber", "automated_sales_tax": "automatedSalesTax", "sales_tax_enabled": "salesTaxEnabled", "default_sales_tax": "defaultSalesTax", "fiscal_year_start_month": "fiscalYearStartMonth", "company_start_date": "companyStartDate", "phone_numbers": "phoneNumbers", "custom_mappings": "customMappings", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", }); }); /** @internal */ export type CompanyInfo$Outbound = { id?: string | undefined; company_name?: string | null | undefined; status?: string | undefined; legal_name?: string | undefined; country?: string | null | undefined; sales_tax_number?: string | null | undefined; automated_sales_tax?: boolean | undefined; sales_tax_enabled?: boolean | undefined; default_sales_tax?: TaxRate$Outbound | undefined; currency?: string | null | undefined; language?: string | null | undefined; fiscal_year_start_month?: string | undefined; company_start_date?: string | undefined; addresses?: Array | undefined; phone_numbers?: Array | undefined; emails?: Array | 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; }; /** @internal */ export const CompanyInfo$outboundSchema: z.ZodType< CompanyInfo$Outbound, z.ZodTypeDef, CompanyInfo > = z.object({ id: z.string().optional(), companyName: z.nullable(z.string()).optional(), status: CompanyStatus$outboundSchema.optional(), legalName: z.string().optional(), country: z.nullable(z.string()).optional(), salesTaxNumber: z.nullable(z.string()).optional(), automatedSalesTax: z.boolean().optional(), salesTaxEnabled: z.boolean().optional(), defaultSalesTax: TaxRate$outboundSchema.optional(), currency: z.nullable(Currency$outboundSchema).optional(), language: z.nullable(z.string()).optional(), fiscalYearStartMonth: TheStartMonthOfFiscalYear$outboundSchema.optional(), companyStartDate: z.instanceof(RFCDate).transform(v => v.toString()) .optional(), addresses: z.array(Address$outboundSchema).optional(), phoneNumbers: z.array(PhoneNumber$outboundSchema).optional(), emails: z.array(Email$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(), }).transform((v) => { return remap$(v, { companyName: "company_name", legalName: "legal_name", salesTaxNumber: "sales_tax_number", automatedSalesTax: "automated_sales_tax", salesTaxEnabled: "sales_tax_enabled", defaultSalesTax: "default_sales_tax", fiscalYearStartMonth: "fiscal_year_start_month", companyStartDate: "company_start_date", phoneNumbers: "phone_numbers", customMappings: "custom_mappings", rowVersion: "row_version", updatedBy: "updated_by", createdBy: "created_by", updatedAt: "updated_at", createdAt: "created_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CompanyInfo$ { /** @deprecated use `CompanyInfo$inboundSchema` instead. */ export const inboundSchema = CompanyInfo$inboundSchema; /** @deprecated use `CompanyInfo$outboundSchema` instead. */ export const outboundSchema = CompanyInfo$outboundSchema; /** @deprecated use `CompanyInfo$Outbound` instead. */ export type Outbound = CompanyInfo$Outbound; } export function companyInfoToJSON(companyInfo: CompanyInfo): string { return JSON.stringify(CompanyInfo$outboundSchema.parse(companyInfo)); } export function companyInfoFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CompanyInfo$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CompanyInfo' from JSON`, ); }