/* * 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 { LinkedInvoiceItem, LinkedInvoiceItem$inboundSchema, LinkedInvoiceItem$Outbound, LinkedInvoiceItem$outboundSchema, } from "./linkedinvoiceitem.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedLedgerAccountInput, LinkedLedgerAccountInput$inboundSchema, LinkedLedgerAccountInput$Outbound, LinkedLedgerAccountInput$outboundSchema, } from "./linkedledgeraccountinput.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema, LinkedTaxRate$Outbound, LinkedTaxRate$outboundSchema, } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$inboundSchema, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; /** * Bill Line Item type */ export const BillLineItemType = { ExpenseItem: "expense_item", ExpenseAccount: "expense_account", Other: "other", } as const; /** * Bill Line Item type */ export type BillLineItemType = ClosedEnum; export type BillLineItem = { /** * A unique identifier for an object. */ id?: string | undefined; /** * Row ID */ rowId?: string | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Line number in the invoice */ lineNumber?: number | null | undefined; /** * User defined description */ description?: string | null | undefined; /** * Bill Line Item type */ type?: BillLineItemType | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Total amount of the line item */ totalAmount?: number | null | undefined; quantity?: number | null | undefined; unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Discount percentage applied to the line item when supported downstream. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to the line item when supported downstream. */ discountAmount?: number | null | undefined; /** * Location id */ locationId?: string | null | undefined; /** * Department id */ departmentId?: string | null | undefined; item?: LinkedInvoiceItem | undefined; taxRate?: LinkedTaxRate | undefined; ledgerAccount?: LinkedLedgerAccount | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | 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 created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; export type BillLineItemInput = { /** * Row ID */ rowId?: string | undefined; /** * User defined item code */ code?: string | null | undefined; /** * Line number in the invoice */ lineNumber?: number | null | undefined; /** * User defined description */ description?: string | null | undefined; /** * Bill Line Item type */ type?: BillLineItemType | null | undefined; /** * Tax amount */ taxAmount?: number | null | undefined; /** * Total amount of the line item */ totalAmount?: number | null | undefined; quantity?: number | null | undefined; unitPrice?: number | null | undefined; /** * Description of the unit type the item is sold as, ie: kg, hour. */ unitOfMeasure?: string | null | undefined; /** * Discount percentage applied to the line item when supported downstream. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to the line item when supported downstream. */ discountAmount?: number | null | undefined; /** * Location id */ locationId?: string | null | undefined; /** * Department id */ departmentId?: string | null | undefined; item?: LinkedInvoiceItem | undefined; taxRate?: LinkedTaxRateInput | undefined; ledgerAccount?: LinkedLedgerAccountInput | null | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | 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; }; /** @internal */ export const BillLineItemType$inboundSchema: z.ZodNativeEnum< typeof BillLineItemType > = z.nativeEnum(BillLineItemType); /** @internal */ export const BillLineItemType$outboundSchema: z.ZodNativeEnum< typeof BillLineItemType > = BillLineItemType$inboundSchema; /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BillLineItemType$ { /** @deprecated use `BillLineItemType$inboundSchema` instead. */ export const inboundSchema = BillLineItemType$inboundSchema; /** @deprecated use `BillLineItemType$outboundSchema` instead. */ export const outboundSchema = BillLineItemType$outboundSchema; } /** @internal */ export const BillLineItem$inboundSchema: z.ZodType< BillLineItem, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), row_id: z.string().optional(), code: z.nullable(z.string()).optional(), line_number: z.nullable(z.number().int()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(BillLineItemType$inboundSchema).optional(), tax_amount: z.nullable(z.number()).optional(), total_amount: z.nullable(z.number()).optional(), quantity: z.nullable(z.number()).optional(), unit_price: z.nullable(z.number()).optional(), unit_of_measure: z.nullable(z.string()).optional(), discount_percentage: z.nullable(z.number()).optional(), discount_amount: z.nullable(z.number()).optional(), location_id: z.nullable(z.string()).optional(), department_id: z.nullable(z.string()).optional(), item: LinkedInvoiceItem$inboundSchema.optional(), tax_rate: LinkedTaxRate$inboundSchema.optional(), ledger_account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), row_version: z.nullable(z.string()).optional(), updated_by: z.nullable(z.string()).optional(), created_by: z.nullable(z.string()).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "row_id": "rowId", "line_number": "lineNumber", "tax_amount": "taxAmount", "total_amount": "totalAmount", "unit_price": "unitPrice", "unit_of_measure": "unitOfMeasure", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "location_id": "locationId", "department_id": "departmentId", "tax_rate": "taxRate", "ledger_account": "ledgerAccount", "tracking_categories": "trackingCategories", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "created_at": "createdAt", "updated_at": "updatedAt", }); }); /** @internal */ export type BillLineItem$Outbound = { id?: string | undefined; row_id?: string | undefined; code?: string | null | undefined; line_number?: number | null | undefined; description?: string | null | undefined; type?: string | null | undefined; tax_amount?: number | null | undefined; total_amount?: number | null | undefined; quantity?: number | null | undefined; unit_price?: number | null | undefined; unit_of_measure?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; location_id?: string | null | undefined; department_id?: string | null | undefined; item?: LinkedInvoiceItem$Outbound | undefined; tax_rate?: LinkedTaxRate$Outbound | undefined; ledger_account?: LinkedLedgerAccount$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; row_version?: string | null | undefined; updated_by?: string | null | undefined; created_by?: string | null | undefined; created_at?: string | null | undefined; updated_at?: string | null | undefined; }; /** @internal */ export const BillLineItem$outboundSchema: z.ZodType< BillLineItem$Outbound, z.ZodTypeDef, BillLineItem > = z.object({ id: z.string().optional(), rowId: z.string().optional(), code: z.nullable(z.string()).optional(), lineNumber: z.nullable(z.number().int()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(BillLineItemType$outboundSchema).optional(), taxAmount: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()).optional(), quantity: z.nullable(z.number()).optional(), unitPrice: z.nullable(z.number()).optional(), unitOfMeasure: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), locationId: z.nullable(z.string()).optional(), departmentId: z.nullable(z.string()).optional(), item: LinkedInvoiceItem$outboundSchema.optional(), taxRate: LinkedTaxRate$outboundSchema.optional(), ledgerAccount: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), rowVersion: z.nullable(z.string()).optional(), updatedBy: z.nullable(z.string()).optional(), createdBy: z.nullable(z.string()).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { rowId: "row_id", lineNumber: "line_number", taxAmount: "tax_amount", totalAmount: "total_amount", unitPrice: "unit_price", unitOfMeasure: "unit_of_measure", discountPercentage: "discount_percentage", discountAmount: "discount_amount", locationId: "location_id", departmentId: "department_id", taxRate: "tax_rate", ledgerAccount: "ledger_account", trackingCategories: "tracking_categories", rowVersion: "row_version", updatedBy: "updated_by", createdBy: "created_by", createdAt: "created_at", updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BillLineItem$ { /** @deprecated use `BillLineItem$inboundSchema` instead. */ export const inboundSchema = BillLineItem$inboundSchema; /** @deprecated use `BillLineItem$outboundSchema` instead. */ export const outboundSchema = BillLineItem$outboundSchema; /** @deprecated use `BillLineItem$Outbound` instead. */ export type Outbound = BillLineItem$Outbound; } export function billLineItemToJSON(billLineItem: BillLineItem): string { return JSON.stringify(BillLineItem$outboundSchema.parse(billLineItem)); } export function billLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BillLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillLineItem' from JSON`, ); } /** @internal */ export const BillLineItemInput$inboundSchema: z.ZodType< BillLineItemInput, z.ZodTypeDef, unknown > = z.object({ row_id: z.string().optional(), code: z.nullable(z.string()).optional(), line_number: z.nullable(z.number().int()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(BillLineItemType$inboundSchema).optional(), tax_amount: z.nullable(z.number()).optional(), total_amount: z.nullable(z.number()).optional(), quantity: z.nullable(z.number()).optional(), unit_price: z.nullable(z.number()).optional(), unit_of_measure: z.nullable(z.string()).optional(), discount_percentage: z.nullable(z.number()).optional(), discount_amount: z.nullable(z.number()).optional(), location_id: z.nullable(z.string()).optional(), department_id: z.nullable(z.string()).optional(), item: LinkedInvoiceItem$inboundSchema.optional(), tax_rate: LinkedTaxRateInput$inboundSchema.optional(), ledger_account: z.nullable(LinkedLedgerAccountInput$inboundSchema).optional(), tracking_categories: z.nullable(z.array(LinkedTrackingCategory$inboundSchema)) .optional(), row_version: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "row_id": "rowId", "line_number": "lineNumber", "tax_amount": "taxAmount", "total_amount": "totalAmount", "unit_price": "unitPrice", "unit_of_measure": "unitOfMeasure", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "location_id": "locationId", "department_id": "departmentId", "tax_rate": "taxRate", "ledger_account": "ledgerAccount", "tracking_categories": "trackingCategories", "row_version": "rowVersion", }); }); /** @internal */ export type BillLineItemInput$Outbound = { row_id?: string | undefined; code?: string | null | undefined; line_number?: number | null | undefined; description?: string | null | undefined; type?: string | null | undefined; tax_amount?: number | null | undefined; total_amount?: number | null | undefined; quantity?: number | null | undefined; unit_price?: number | null | undefined; unit_of_measure?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; location_id?: string | null | undefined; department_id?: string | null | undefined; item?: LinkedInvoiceItem$Outbound | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; ledger_account?: LinkedLedgerAccountInput$Outbound | null | undefined; tracking_categories?: | Array | null | undefined; row_version?: string | null | undefined; }; /** @internal */ export const BillLineItemInput$outboundSchema: z.ZodType< BillLineItemInput$Outbound, z.ZodTypeDef, BillLineItemInput > = z.object({ rowId: z.string().optional(), code: z.nullable(z.string()).optional(), lineNumber: z.nullable(z.number().int()).optional(), description: z.nullable(z.string()).optional(), type: z.nullable(BillLineItemType$outboundSchema).optional(), taxAmount: z.nullable(z.number()).optional(), totalAmount: z.nullable(z.number()).optional(), quantity: z.nullable(z.number()).optional(), unitPrice: z.nullable(z.number()).optional(), unitOfMeasure: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), locationId: z.nullable(z.string()).optional(), departmentId: z.nullable(z.string()).optional(), item: LinkedInvoiceItem$outboundSchema.optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), ledgerAccount: z.nullable(LinkedLedgerAccountInput$outboundSchema).optional(), trackingCategories: z.nullable(z.array(LinkedTrackingCategory$outboundSchema)) .optional(), rowVersion: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { rowId: "row_id", lineNumber: "line_number", taxAmount: "tax_amount", totalAmount: "total_amount", unitPrice: "unit_price", unitOfMeasure: "unit_of_measure", discountPercentage: "discount_percentage", discountAmount: "discount_amount", locationId: "location_id", departmentId: "department_id", taxRate: "tax_rate", ledgerAccount: "ledger_account", trackingCategories: "tracking_categories", rowVersion: "row_version", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BillLineItemInput$ { /** @deprecated use `BillLineItemInput$inboundSchema` instead. */ export const inboundSchema = BillLineItemInput$inboundSchema; /** @deprecated use `BillLineItemInput$outboundSchema` instead. */ export const outboundSchema = BillLineItemInput$outboundSchema; /** @deprecated use `BillLineItemInput$Outbound` instead. */ export type Outbound = BillLineItemInput$Outbound; } export function billLineItemInputToJSON( billLineItemInput: BillLineItemInput, ): string { return JSON.stringify( BillLineItemInput$outboundSchema.parse(billLineItemInput), ); } export function billLineItemInputFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BillLineItemInput$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillLineItemInput' from JSON`, ); }