/* * 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 { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; import { ExpenseLineItem, ExpenseLineItem$inboundSchema, ExpenseLineItem$Outbound, ExpenseLineItem$outboundSchema, } from "./expenselineitem.js"; import { ExpenseLineItemInput, ExpenseLineItemInput$inboundSchema, ExpenseLineItemInput$Outbound, ExpenseLineItemInput$outboundSchema, } from "./expenselineiteminput.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema, LinkedTaxRate$Outbound, LinkedTaxRate$outboundSchema, } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$inboundSchema, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * The type of expense. */ export const ExpenseType = { Expense: "expense", Refund: "refund", } as const; /** * The type of expense. */ export type ExpenseType = ClosedEnum; export type Expense = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Number. */ number?: string | null | undefined; /** * The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD */ transactionDate: Date | null; /** * The unique identifier for the ledger account that this expense should be credited to. */ accountId: string; /** * The ID of the customer this entity is linked to. Used for expenses that should be marked as billable to customers. */ customerId?: string | undefined; /** * The ID of the supplier this entity is linked to. */ supplierId?: string | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | null | undefined; /** * The ID of the department this expense is linked to. */ departmentId?: string | 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; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * The type of expense. */ type?: ExpenseType | null | undefined; /** * The memo of the expense. */ memo?: string | null | undefined; taxRate?: LinkedTaxRate | undefined; /** * The total amount of the expense line item. */ totalAmount?: number | null | undefined; /** * Expense line items linked to this expense. */ lineItems: Array; customFields?: Array | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | 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; /** * 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; }; export type ExpenseInput = { /** * Number. */ number?: string | null | undefined; /** * The date of the transaction - YYYY:MM::DDThh:mm:ss.sTZD */ transactionDate: Date | null; /** * The unique identifier for the ledger account that this expense should be credited to. */ accountId: string; /** * The ID of the customer this entity is linked to. Used for expenses that should be marked as billable to customers. */ customerId?: string | undefined; /** * The ID of the supplier this entity is linked to. */ supplierId?: string | undefined; /** * The company or subsidiary id the transaction belongs to */ companyId?: string | null | undefined; /** * The ID of the department this expense is linked to. */ departmentId?: string | 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; /** * Currency Exchange Rate at the time entity was recorded/generated. */ currencyRate?: number | null | undefined; /** * The type of expense. */ type?: ExpenseType | null | undefined; /** * The memo of the expense. */ memo?: string | null | undefined; taxRate?: LinkedTaxRateInput | undefined; /** * The total amount of the expense line item. */ totalAmount?: number | null | undefined; /** * Expense line items linked to this expense. */ lineItems: Array; customFields?: Array | 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 ExpenseType$inboundSchema: z.ZodNativeEnum = z .nativeEnum(ExpenseType); /** @internal */ export const ExpenseType$outboundSchema: z.ZodNativeEnum = ExpenseType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ExpenseType$ { /** @deprecated use `ExpenseType$inboundSchema` instead. */ export const inboundSchema = ExpenseType$inboundSchema; /** @deprecated use `ExpenseType$outboundSchema` instead. */ export const outboundSchema = ExpenseType$outboundSchema; } /** @internal */ export const Expense$inboundSchema: z.ZodType = z.object({ id: z.string().optional(), number: z.nullable(z.string()).optional(), transaction_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), account_id: z.string(), customer_id: z.string().optional(), supplier_id: z.string().optional(), company_id: z.nullable(z.string()).optional(), department_id: z.string().optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(z.number()).optional(), type: z.nullable(ExpenseType$inboundSchema).optional(), memo: z.nullable(z.string()).optional(), tax_rate: LinkedTaxRate$inboundSchema.optional(), total_amount: z.nullable(z.number()).optional(), line_items: z.array(ExpenseLineItem$inboundSchema), custom_fields: z.array(CustomField$inboundSchema).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).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(), row_version: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "transaction_date": "transactionDate", "account_id": "accountId", "customer_id": "customerId", "supplier_id": "supplierId", "company_id": "companyId", "department_id": "departmentId", "currency_rate": "currencyRate", "tax_rate": "taxRate", "total_amount": "totalAmount", "line_items": "lineItems", "custom_fields": "customFields", "custom_mappings": "customMappings", "updated_at": "updatedAt", "created_at": "createdAt", "row_version": "rowVersion", "pass_through": "passThrough", }); }); /** @internal */ export type Expense$Outbound = { id?: string | undefined; number?: string | null | undefined; transaction_date: string | null; account_id: string; customer_id?: string | undefined; supplier_id?: string | undefined; company_id?: string | null | undefined; department_id?: string | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; type?: string | null | undefined; memo?: string | null | undefined; tax_rate?: LinkedTaxRate$Outbound | undefined; total_amount?: number | null | undefined; line_items: Array; custom_fields?: Array | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; updated_at?: string | null | undefined; created_at?: string | null | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const Expense$outboundSchema: z.ZodType< Expense$Outbound, z.ZodTypeDef, Expense > = z.object({ id: z.string().optional(), number: z.nullable(z.string()).optional(), transactionDate: z.nullable(z.date().transform(v => v.toISOString())), accountId: z.string(), customerId: z.string().optional(), supplierId: z.string().optional(), companyId: z.nullable(z.string()).optional(), departmentId: z.string().optional(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), type: z.nullable(ExpenseType$outboundSchema).optional(), memo: z.nullable(z.string()).optional(), taxRate: LinkedTaxRate$outboundSchema.optional(), totalAmount: z.nullable(z.number()).optional(), lineItems: z.array(ExpenseLineItem$outboundSchema), customFields: z.array(CustomField$outboundSchema).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { transactionDate: "transaction_date", accountId: "account_id", customerId: "customer_id", supplierId: "supplier_id", companyId: "company_id", departmentId: "department_id", currencyRate: "currency_rate", taxRate: "tax_rate", totalAmount: "total_amount", lineItems: "line_items", customFields: "custom_fields", customMappings: "custom_mappings", updatedAt: "updated_at", createdAt: "created_at", 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 Expense$ { /** @deprecated use `Expense$inboundSchema` instead. */ export const inboundSchema = Expense$inboundSchema; /** @deprecated use `Expense$outboundSchema` instead. */ export const outboundSchema = Expense$outboundSchema; /** @deprecated use `Expense$Outbound` instead. */ export type Outbound = Expense$Outbound; } export function expenseToJSON(expense: Expense): string { return JSON.stringify(Expense$outboundSchema.parse(expense)); } export function expenseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Expense$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Expense' from JSON`, ); } /** @internal */ export const ExpenseInput$inboundSchema: z.ZodType< ExpenseInput, z.ZodTypeDef, unknown > = z.object({ number: z.nullable(z.string()).optional(), transaction_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ), account_id: z.string(), customer_id: z.string().optional(), supplier_id: z.string().optional(), company_id: z.nullable(z.string()).optional(), department_id: z.string().optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(z.number()).optional(), type: z.nullable(ExpenseType$inboundSchema).optional(), memo: z.nullable(z.string()).optional(), tax_rate: LinkedTaxRateInput$inboundSchema.optional(), total_amount: z.nullable(z.number()).optional(), line_items: z.array(ExpenseLineItemInput$inboundSchema), custom_fields: z.array(CustomField$inboundSchema).optional(), row_version: z.nullable(z.string()).optional(), pass_through: z.array(PassThroughBody$inboundSchema).optional(), }).transform((v) => { return remap$(v, { "transaction_date": "transactionDate", "account_id": "accountId", "customer_id": "customerId", "supplier_id": "supplierId", "company_id": "companyId", "department_id": "departmentId", "currency_rate": "currencyRate", "tax_rate": "taxRate", "total_amount": "totalAmount", "line_items": "lineItems", "custom_fields": "customFields", "row_version": "rowVersion", "pass_through": "passThrough", }); }); /** @internal */ export type ExpenseInput$Outbound = { number?: string | null | undefined; transaction_date: string | null; account_id: string; customer_id?: string | undefined; supplier_id?: string | undefined; company_id?: string | null | undefined; department_id?: string | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; type?: string | null | undefined; memo?: string | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; total_amount?: number | null | undefined; line_items: Array; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const ExpenseInput$outboundSchema: z.ZodType< ExpenseInput$Outbound, z.ZodTypeDef, ExpenseInput > = z.object({ number: z.nullable(z.string()).optional(), transactionDate: z.nullable(z.date().transform(v => v.toISOString())), accountId: z.string(), customerId: z.string().optional(), supplierId: z.string().optional(), companyId: z.nullable(z.string()).optional(), departmentId: z.string().optional(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), type: z.nullable(ExpenseType$outboundSchema).optional(), memo: z.nullable(z.string()).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), totalAmount: z.nullable(z.number()).optional(), lineItems: z.array(ExpenseLineItemInput$outboundSchema), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { transactionDate: "transaction_date", accountId: "account_id", customerId: "customer_id", supplierId: "supplier_id", companyId: "company_id", departmentId: "department_id", currencyRate: "currency_rate", taxRate: "tax_rate", totalAmount: "total_amount", lineItems: "line_items", customFields: "custom_fields", 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 ExpenseInput$ { /** @deprecated use `ExpenseInput$inboundSchema` instead. */ export const inboundSchema = ExpenseInput$inboundSchema; /** @deprecated use `ExpenseInput$outboundSchema` instead. */ export const outboundSchema = ExpenseInput$outboundSchema; /** @deprecated use `ExpenseInput$Outbound` instead. */ export type Outbound = ExpenseInput$Outbound; } export function expenseInputToJSON(expenseInput: ExpenseInput): string { return JSON.stringify(ExpenseInput$outboundSchema.parse(expenseInput)); } export function expenseInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExpenseInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExpenseInput' from JSON`, ); }