/* * 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 { Address, Address$inboundSchema, Address$Outbound, Address$outboundSchema, } from "./address.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { LinkedCustomer, LinkedCustomer$inboundSchema, } from "./linkedcustomer.js"; import { LinkedCustomerInput, LinkedCustomerInput$Outbound, LinkedCustomerInput$outboundSchema, } from "./linkedcustomerinput.js"; import { LinkedTrackingCategory, LinkedTrackingCategory$inboundSchema, LinkedTrackingCategory$Outbound, LinkedTrackingCategory$outboundSchema, } from "./linkedtrackingcategory.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; import { QuoteLineItem, QuoteLineItem$inboundSchema, QuoteLineItemInput, QuoteLineItemInput$Outbound, QuoteLineItemInput$outboundSchema, } from "./quotelineitem.js"; /** * Quote status */ export const QuoteStatus = { Draft: "draft", Sent: "sent", Accepted: "accepted", Rejected: "rejected", Expired: "expired", Converted: "converted", Void: "void", Deleted: "deleted", } as const; /** * Quote status */ export type QuoteStatus = OpenEnum; export type Quote = { /** * A unique identifier for an object. */ id?: string | undefined; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Quote number. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomer | null | undefined; /** * The unique identifier for the invoice. */ invoiceId?: string | undefined; /** * The unique identifier for the sales order. */ salesOrderId?: string | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The unique identifier for the linked project. */ projectId?: string | undefined; /** * Date quote was issued - YYYY-MM-DD. */ quoteDate?: Date | null | undefined; /** * The date until which the quote is valid - YYYY-MM-DD. */ expiryDate?: Date | null | undefined; /** * Terms of the quote. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; /** * Optional reference identifier for the transaction. */ reference?: string | null | undefined; /** * A PO Number uniquely identifies a purchase order and is generally defined by the buyer. The buyer will match the PO number in the quote to the Purchase Order. */ poNumber?: string | null | undefined; /** * Quote status */ status?: QuoteStatus | null | 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; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Total tax amount applied to this quote. */ totalTax?: number | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; /** * Discount percentage applied to this quote. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this quote. */ discountAmount?: number | null | undefined; /** * Total amount of quote, including tax. */ total?: number | null | undefined; /** * Customer memo */ customerMemo?: string | null | undefined; lineItems?: Array | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; /** * Optional quote template */ templateId?: string | null | undefined; /** * URL link to a source document - shown as 'Go to [appName]' in the downstream app. */ sourceDocumentUrl?: string | null | undefined; 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 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 QuoteInput = { /** * Quote number. */ number?: string | null | undefined; /** * The customer this entity is linked to. */ customer?: LinkedCustomerInput | null | undefined; /** * The unique identifier for the sales order. */ salesOrderId?: string | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; /** * The ID of the department */ departmentId?: string | null | undefined; /** * The unique identifier for the linked project. */ projectId?: string | undefined; /** * Date quote was issued - YYYY-MM-DD. */ quoteDate?: Date | null | undefined; /** * The date until which the quote is valid - YYYY-MM-DD. */ expiryDate?: Date | null | undefined; /** * Terms of the quote. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; /** * Optional reference identifier for the transaction. */ reference?: string | null | undefined; /** * A PO Number uniquely identifies a purchase order and is generally defined by the buyer. The buyer will match the PO number in the quote to the Purchase Order. */ poNumber?: string | null | undefined; /** * Quote status */ status?: QuoteStatus | null | 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; /** * Amounts are including tax */ taxInclusive?: boolean | null | undefined; /** * Sub-total amount, normally before tax. */ subTotal?: number | null | undefined; /** * Total tax amount applied to this quote. */ totalTax?: number | null | undefined; /** * Applicable tax id/code override if tax is not supplied on a line item basis. */ taxCode?: string | null | undefined; /** * Discount percentage applied to this quote. */ discountPercentage?: number | null | undefined; /** * Discount amount applied to this quote. */ discountAmount?: number | null | undefined; /** * Total amount of quote, including tax. */ total?: number | null | undefined; /** * Customer memo */ customerMemo?: string | null | undefined; lineItems?: Array | undefined; billingAddress?: Address | undefined; shippingAddress?: Address | undefined; /** * A list of linked tracking categories. */ trackingCategories?: Array | null | undefined; /** * Optional quote template */ templateId?: string | null | undefined; /** * URL link to a source document - shown as 'Go to [appName]' in the downstream app. */ sourceDocumentUrl?: string | null | undefined; 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 QuoteStatus$inboundSchema: z.ZodType< QuoteStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(QuoteStatus)); /** @internal */ export const QuoteStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, QuoteStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(QuoteStatus)); /** @internal */ export const Quote$inboundSchema: z.ZodType = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.optional(types.string()), downstream_id: z.nullable(types.string()).optional(), number: z.nullable(types.string()).optional(), customer: z.nullable(LinkedCustomer$inboundSchema).optional(), invoice_id: types.optional(types.string()), sales_order_id: z.nullable(types.string()).optional(), company_id: z.nullable(types.string()).optional(), department_id: z.nullable(types.string()).optional(), project_id: types.optional(types.string()), quote_date: z.nullable(types.date()).optional(), expiry_date: z.nullable(types.date()).optional(), terms: z.nullable(types.string()).optional(), terms_id: z.nullable(types.string()).optional(), reference: z.nullable(types.string()).optional(), po_number: z.nullable(types.string()).optional(), status: z.nullable(QuoteStatus$inboundSchema).optional(), currency: z.nullable(Currency$inboundSchema).optional(), currency_rate: z.nullable(types.number()).optional(), tax_inclusive: z.nullable(types.boolean()).optional(), sub_total: z.nullable(types.number()).optional(), total_tax: z.nullable(types.number()).optional(), tax_code: z.nullable(types.string()).optional(), discount_percentage: z.nullable(types.number()).optional(), discount_amount: z.nullable(types.number()).optional(), total: z.nullable(types.number()).optional(), customer_memo: z.nullable(types.string()).optional(), line_items: types.optional(z.array(QuoteLineItem$inboundSchema)), billing_address: types.optional(Address$inboundSchema), shipping_address: types.optional(Address$inboundSchema), tracking_categories: z.nullable( z.array(types.nullable(LinkedTrackingCategory$inboundSchema)), ).optional(), template_id: z.nullable(types.string()).optional(), source_document_url: z.nullable(types.string()).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), 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, { "downstream_id": "downstreamId", "invoice_id": "invoiceId", "sales_order_id": "salesOrderId", "company_id": "companyId", "department_id": "departmentId", "project_id": "projectId", "quote_date": "quoteDate", "expiry_date": "expiryDate", "terms_id": "termsId", "po_number": "poNumber", "currency_rate": "currencyRate", "tax_inclusive": "taxInclusive", "sub_total": "subTotal", "total_tax": "totalTax", "tax_code": "taxCode", "discount_percentage": "discountPercentage", "discount_amount": "discountAmount", "customer_memo": "customerMemo", "line_items": "lineItems", "billing_address": "billingAddress", "shipping_address": "shippingAddress", "tracking_categories": "trackingCategories", "template_id": "templateId", "source_document_url": "sourceDocumentUrl", "custom_fields": "customFields", "row_version": "rowVersion", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "pass_through": "passThrough", }); }) ); export function quoteFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Quote$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Quote' from JSON`, ); } /** @internal */ export type QuoteInput$Outbound = { number?: string | null | undefined; customer?: LinkedCustomerInput$Outbound | null | undefined; sales_order_id?: string | null | undefined; company_id?: string | null | undefined; department_id?: string | null | undefined; project_id?: string | undefined; quote_date?: string | null | undefined; expiry_date?: string | null | undefined; terms?: string | null | undefined; terms_id?: string | null | undefined; reference?: string | null | undefined; po_number?: string | null | undefined; status?: string | null | undefined; currency?: string | null | undefined; currency_rate?: number | null | undefined; tax_inclusive?: boolean | null | undefined; sub_total?: number | null | undefined; total_tax?: number | null | undefined; tax_code?: string | null | undefined; discount_percentage?: number | null | undefined; discount_amount?: number | null | undefined; total?: number | null | undefined; customer_memo?: string | null | undefined; line_items?: Array | undefined; billing_address?: Address$Outbound | undefined; shipping_address?: Address$Outbound | undefined; tracking_categories?: | Array | null | undefined; template_id?: string | null | undefined; source_document_url?: string | null | undefined; custom_fields?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; }; /** @internal */ export const QuoteInput$outboundSchema: z.ZodType< QuoteInput$Outbound, z.ZodTypeDef, QuoteInput > = /* @__PURE__ */ lazySchema$(() => z.object({ number: z.nullable(z.string()).optional(), customer: z.nullable(LinkedCustomerInput$outboundSchema).optional(), salesOrderId: z.nullable(z.string()).optional(), companyId: z.nullable(z.string()).optional(), departmentId: z.nullable(z.string()).optional(), projectId: z.string().optional(), quoteDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), expiryDate: z.nullable( z.date().transform(v => v.toISOString().slice(0, "YYYY-MM-DD".length)), ).optional(), terms: z.nullable(z.string()).optional(), termsId: z.nullable(z.string()).optional(), reference: z.nullable(z.string()).optional(), poNumber: z.nullable(z.string()).optional(), status: z.nullable(QuoteStatus$outboundSchema).optional(), currency: z.nullable(Currency$outboundSchema).optional(), currencyRate: z.nullable(z.number()).optional(), taxInclusive: z.nullable(z.boolean()).optional(), subTotal: z.nullable(z.number()).optional(), totalTax: z.nullable(z.number()).optional(), taxCode: z.nullable(z.string()).optional(), discountPercentage: z.nullable(z.number()).optional(), discountAmount: z.nullable(z.number()).optional(), total: z.nullable(z.number()).optional(), customerMemo: z.nullable(z.string()).optional(), lineItems: z.array(QuoteLineItemInput$outboundSchema).optional(), billingAddress: Address$outboundSchema.optional(), shippingAddress: Address$outboundSchema.optional(), trackingCategories: z.nullable( z.array(z.nullable(LinkedTrackingCategory$outboundSchema)), ).optional(), templateId: z.nullable(z.string()).optional(), sourceDocumentUrl: z.nullable(z.string()).optional(), customFields: z.array(CustomField$outboundSchema).optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), }).transform((v) => { return remap$(v, { salesOrderId: "sales_order_id", companyId: "company_id", departmentId: "department_id", projectId: "project_id", quoteDate: "quote_date", expiryDate: "expiry_date", termsId: "terms_id", poNumber: "po_number", currencyRate: "currency_rate", taxInclusive: "tax_inclusive", subTotal: "sub_total", totalTax: "total_tax", taxCode: "tax_code", discountPercentage: "discount_percentage", discountAmount: "discount_amount", customerMemo: "customer_memo", lineItems: "line_items", billingAddress: "billing_address", shippingAddress: "shipping_address", trackingCategories: "tracking_categories", templateId: "template_id", sourceDocumentUrl: "source_document_url", customFields: "custom_fields", rowVersion: "row_version", passThrough: "pass_through", }); }) ); export function quoteInputToJSON(quoteInput: QuoteInput): string { return JSON.stringify(QuoteInput$outboundSchema.parse(quoteInput)); }