/* * 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"; /** * Type of entity this payment should be attributed to. */ export const AllocationType = { Invoice: "invoice", Order: "order", Expense: "expense", CreditMemo: "credit_memo", OverPayment: "over_payment", PrePayment: "pre_payment", JournalEntry: "journal_entry", Other: "other", Bill: "bill", } as const; /** * Type of entity this payment should be attributed to. */ export type AllocationType = OpenEnum; export type Allocation = { /** * Unique identifier of entity this payment should be attributed to. */ id?: string | undefined; /** * Type of entity this payment should be attributed to. */ type?: AllocationType | undefined; code?: string | undefined; /** * Amount of payment that should be attributed to this allocation. If null, the total_amount will be used. */ amount?: number | null | undefined; /** * Unique identifier of the allocation */ allocationId?: string | undefined; }; export type AllocationInput = { /** * Unique identifier of entity this payment should be attributed to. */ id?: string | undefined; /** * Type of entity this payment should be attributed to. */ type?: AllocationType | undefined; /** * Amount of payment that should be attributed to this allocation. If null, the total_amount will be used. */ amount?: number | null | undefined; /** * Unique identifier of the allocation */ allocationId?: string | undefined; }; /** @internal */ export const AllocationType$inboundSchema: z.ZodType< AllocationType, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(AllocationType)); /** @internal */ export const AllocationType$outboundSchema: z.ZodType< string, z.ZodTypeDef, AllocationType > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(AllocationType)); /** @internal */ export const Allocation$inboundSchema: z.ZodType< Allocation, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), type: types.optional(AllocationType$inboundSchema), code: types.optional(types.string()), amount: z.nullable(types.number()).optional(), allocation_id: types.optional(types.string()), }).transform((v) => { return remap$(v, { "allocation_id": "allocationId", }); }) ); export function allocationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Allocation$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Allocation' from JSON`, ); } /** @internal */ export type AllocationInput$Outbound = { id?: string | undefined; type?: string | undefined; amount?: number | null | undefined; allocation_id?: string | undefined; }; /** @internal */ export const AllocationInput$outboundSchema: z.ZodType< AllocationInput$Outbound, z.ZodTypeDef, AllocationInput > = /* @__PURE__ */ lazySchema$(() => z.object({ id: z.string().optional(), type: AllocationType$outboundSchema.optional(), amount: z.nullable(z.number()).optional(), allocationId: z.string().optional(), }).transform((v) => { return remap$(v, { allocationId: "allocation_id", }); }) ); export function allocationInputToJSON( allocationInput: AllocationInput, ): string { return JSON.stringify(AllocationInput$outboundSchema.parse(allocationInput)); }