/* * 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 { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; /** * The status of the expense category. */ export const ExpenseCategoryStatus = { Active: "active", Inactive: "inactive", } as const; /** * The status of the expense category. */ export type ExpenseCategoryStatus = OpenEnum; export type ExpenseCategory = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Id to be displayed. */ displayId?: string | null | undefined; /** * The name of the expense category. */ name: string; /** * The code or external identifier of the expense category. */ code?: string | null | undefined; /** * The description of the expense category. */ description?: string | null | undefined; /** * The status of the expense category. */ status?: ExpenseCategoryStatus | null | undefined; account?: LinkedLedgerAccount | null | undefined; offsetAccount?: LinkedLedgerAccount | null | undefined; taxRate?: LinkedTaxRate | undefined; /** * Whether the expense category requires rate/quantity entry (e.g. mileage at $/mile). */ rateRequired?: boolean | null | undefined; /** * Default rate when rate_required is true (e.g. 0.67 for mileage). */ defaultRate?: number | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; /** * The third-party API ID of original entity */ downstreamId?: string | 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 ExpenseCategoryInput = { /** * Id to be displayed. */ displayId?: string | null | undefined; /** * The name of the expense category. */ name: string; /** * The code or external identifier of the expense category. */ code?: string | null | undefined; /** * The description of the expense category. */ description?: string | null | undefined; /** * The status of the expense category. */ status?: ExpenseCategoryStatus | null | undefined; account?: LinkedLedgerAccount | null | undefined; offsetAccount?: LinkedLedgerAccount | null | undefined; taxRate?: LinkedTaxRateInput | undefined; /** * Whether the expense category requires rate/quantity entry (e.g. mileage at $/mile). */ rateRequired?: boolean | null | undefined; /** * Default rate when rate_required is true (e.g. 0.67 for mileage). */ defaultRate?: number | 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 ExpenseCategoryStatus$inboundSchema: z.ZodType< ExpenseCategoryStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(ExpenseCategoryStatus) ); /** @internal */ export const ExpenseCategoryStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, ExpenseCategoryStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(ExpenseCategoryStatus) ); /** @internal */ export const ExpenseCategory$inboundSchema: z.ZodType< ExpenseCategory, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), display_id: z.nullable(types.string()).optional(), name: types.string(), code: z.nullable(types.string()).optional(), description: z.nullable(types.string()).optional(), status: z.nullable(ExpenseCategoryStatus$inboundSchema).optional(), account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), offset_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), rate_required: z.nullable(types.boolean()).optional(), default_rate: z.nullable(types.number()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), downstream_id: z.nullable(types.string()).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)), }).transform((v) => { return remap$(v, { "display_id": "displayId", "offset_account": "offsetAccount", "tax_rate": "taxRate", "rate_required": "rateRequired", "default_rate": "defaultRate", "custom_mappings": "customMappings", "downstream_id": "downstreamId", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function expenseCategoryFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ExpenseCategory$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ExpenseCategory' from JSON`, ); } /** @internal */ export type ExpenseCategoryInput$Outbound = { display_id?: string | null | undefined; name: string; code?: string | null | undefined; description?: string | null | undefined; status?: string | null | undefined; account?: LinkedLedgerAccount$Outbound | null | undefined; offset_account?: LinkedLedgerAccount$Outbound | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; rate_required?: boolean | null | undefined; default_rate?: number | null | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const ExpenseCategoryInput$outboundSchema: z.ZodType< ExpenseCategoryInput$Outbound, z.ZodTypeDef, ExpenseCategoryInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.nullable(z.string()).optional(), name: z.string(), code: z.nullable(z.string()).optional(), description: z.nullable(z.string()).optional(), status: z.nullable(ExpenseCategoryStatus$outboundSchema).optional(), account: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), offsetAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), rateRequired: z.nullable(z.boolean()).optional(), defaultRate: z.nullable(z.number()).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", offsetAccount: "offset_account", taxRate: "tax_rate", rateRequired: "rate_required", defaultRate: "default_rate", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function expenseCategoryInputToJSON( expenseCategoryInput: ExpenseCategoryInput, ): string { return JSON.stringify( ExpenseCategoryInput$outboundSchema.parse(expenseCategoryInput), ); }