/* * 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 { BankAccount, BankAccount$inboundSchema, BankAccount$Outbound, BankAccount$outboundSchema, } from "./bankaccount.js"; import { Currency, Currency$inboundSchema, Currency$outboundSchema, } from "./currency.js"; import { CustomField, CustomField$inboundSchema, CustomField$Outbound, CustomField$outboundSchema, } from "./customfield.js"; import { Email, Email$inboundSchema, Email$Outbound, Email$outboundSchema, } from "./email.js"; import { LinkedLedgerAccount, LinkedLedgerAccount$inboundSchema, LinkedLedgerAccount$Outbound, LinkedLedgerAccount$outboundSchema, } from "./linkedledgeraccount.js"; import { LinkedSubsidiary, LinkedSubsidiary$inboundSchema, } from "./linkedsubsidiary.js"; import { LinkedSubsidiaryInput, LinkedSubsidiaryInput$Outbound, LinkedSubsidiaryInput$outboundSchema, } from "./linkedsubsidiaryinput.js"; import { LinkedTaxDetail, LinkedTaxDetail$inboundSchema, LinkedTaxDetail$Outbound, LinkedTaxDetail$outboundSchema, } from "./linkedtaxdetail.js"; import { LinkedTaxRate, LinkedTaxRate$inboundSchema } from "./linkedtaxrate.js"; import { LinkedTaxRateInput, LinkedTaxRateInput$Outbound, LinkedTaxRateInput$outboundSchema, } from "./linkedtaxrateinput.js"; import { LinkedTaxStatusDetail, LinkedTaxStatusDetail$inboundSchema, LinkedTaxStatusDetail$Outbound, LinkedTaxStatusDetail$outboundSchema, } from "./linkedtaxstatusdetail.js"; import { PassThroughBody, PassThroughBody$inboundSchema, PassThroughBody$Outbound, PassThroughBody$outboundSchema, } from "./passthroughbody.js"; import { PhoneNumber, PhoneNumber$inboundSchema, PhoneNumber$Outbound, PhoneNumber$outboundSchema, } from "./phonenumber.js"; import { Website, Website$inboundSchema, Website$Outbound, Website$outboundSchema, } from "./website.js"; /** * Supplier status */ export const SupplierStatus = { Active: "active", Inactive: "inactive", Archived: "archived", GdprErasureRequest: "gdpr-erasure-request", Unknown: "unknown", } as const; /** * Supplier status */ export type SupplierStatus = OpenEnum; export type Supplier = { /** * A unique identifier for an object. */ id: string; /** * The third-party API ID of original entity */ downstreamId?: string | null | undefined; /** * Display ID */ displayId?: string | null | undefined; /** * Display name */ displayName?: string | null | undefined; /** * The name of the company. */ companyName?: string | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiary | null | undefined; /** * The category/type of the supplier */ supplierCategory?: string | null | undefined; /** * The job title of the person. */ title?: string | null | undefined; /** * The first name of the person. */ firstName?: string | null | undefined; /** * Middle name of the person. */ middleName?: string | null | undefined; /** * The last name of the person. */ lastName?: string | null | undefined; suffix?: string | null | undefined; /** * Is this an individual or business supplier */ individual?: boolean | null | undefined; addresses?: Array
| undefined; phoneNumbers?: Array | undefined; emails?: Array | undefined; websites?: Array | undefined; bankAccounts?: Array | undefined; /** * Some notes about this supplier */ notes?: string | null | undefined; taxRate?: LinkedTaxRate | undefined; taxNumber?: string | null | undefined; /** * Whether the entity is subject to taxation */ taxable?: boolean | 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; account?: LinkedLedgerAccount | null | undefined; /** * Supplier status */ status?: SupplierStatus | null | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; /** * The channel through which the transaction is processed. */ channel?: string | null | undefined; /** * Method of issuance of the purchase order for the supplier */ issuedMethod?: string | null | undefined; /** * Email address of the person who issued the purchase order for the supplier */ issuedEmail?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: { [k: string]: any } | null | undefined; customFields?: Array | undefined; taxDetails?: Array | undefined; taxStatusDetails?: Array | 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; /** * 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; /** * The subsidiary the supplier belongs to. */ subsidiaryId?: string | undefined; /** * The integration system the supplier belongs to. */ integrationSystemId?: string | undefined; }; export type SupplierInput = { /** * Display ID */ displayId?: string | null | undefined; /** * Display name */ displayName?: string | null | undefined; /** * The name of the company. */ companyName?: string | null | undefined; /** * The company ID the transaction belongs to */ companyId?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput | null | undefined; /** * The category/type of the supplier */ supplierCategory?: string | null | undefined; /** * The job title of the person. */ title?: string | null | undefined; /** * The first name of the person. */ firstName?: string | null | undefined; /** * Middle name of the person. */ middleName?: string | null | undefined; /** * The last name of the person. */ lastName?: string | null | undefined; suffix?: string | null | undefined; /** * Is this an individual or business supplier */ individual?: boolean | null | undefined; addresses?: Array
| undefined; phoneNumbers?: Array | undefined; emails?: Array | undefined; websites?: Array | undefined; bankAccounts?: Array | undefined; /** * Some notes about this supplier */ notes?: string | null | undefined; taxRate?: LinkedTaxRateInput | undefined; taxNumber?: string | null | undefined; /** * Whether the entity is subject to taxation */ taxable?: boolean | 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; account?: LinkedLedgerAccount | null | undefined; /** * Supplier status */ status?: SupplierStatus | null | undefined; /** * Payment method used for the transaction, such as cash, credit card, bank transfer, or check */ paymentMethod?: string | null | undefined; /** * Terms of payment. */ terms?: string | null | undefined; /** * The ID of the payment terms */ termsId?: string | null | undefined; /** * The channel through which the transaction is processed. */ channel?: string | null | undefined; /** * Method of issuance of the purchase order for the supplier */ issuedMethod?: string | null | undefined; /** * Email address of the person who issued the purchase order for the supplier */ issuedEmail?: string | null | undefined; customFields?: Array | undefined; taxDetails?: Array | undefined; taxStatusDetails?: 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; /** * The subsidiary the supplier belongs to. */ subsidiaryId?: string | undefined; /** * The integration system the supplier belongs to. */ integrationSystemId?: string | undefined; }; /** @internal */ export const SupplierStatus$inboundSchema: z.ZodType< SupplierStatus, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => openEnums.inboundSchema(SupplierStatus)); /** @internal */ export const SupplierStatus$outboundSchema: z.ZodType< string, z.ZodTypeDef, SupplierStatus > = /* @__PURE__ */ lazySchema$(() => openEnums.outboundSchema(SupplierStatus)); /** @internal */ export const Supplier$inboundSchema: z.ZodType< Supplier, z.ZodTypeDef, unknown > = /* @__PURE__ */ lazySchema$(() => z.object({ id: types.string(), downstream_id: z.nullable(types.string()).optional(), display_id: z.nullable(types.string()).optional(), display_name: z.nullable(types.string()).optional(), company_name: z.nullable(types.string()).optional(), company_id: z.nullable(types.string()).optional(), subsidiary: z.nullable(LinkedSubsidiary$inboundSchema).optional(), supplier_category: z.nullable(types.string()).optional(), title: z.nullable(types.string()).optional(), first_name: z.nullable(types.string()).optional(), middle_name: z.nullable(types.string()).optional(), last_name: z.nullable(types.string()).optional(), suffix: z.nullable(types.string()).optional(), individual: z.nullable(types.boolean()).optional(), addresses: types.optional(z.array(Address$inboundSchema)), phone_numbers: types.optional(z.array(PhoneNumber$inboundSchema)), emails: types.optional(z.array(Email$inboundSchema)), websites: types.optional(z.array(Website$inboundSchema)), bank_accounts: types.optional(z.array(BankAccount$inboundSchema)), notes: z.nullable(types.string()).optional(), tax_rate: types.optional(LinkedTaxRate$inboundSchema), tax_number: z.nullable(types.string()).optional(), taxable: z.nullable(types.boolean()).optional(), currency: z.nullable(Currency$inboundSchema).optional(), account: z.nullable(LinkedLedgerAccount$inboundSchema).optional(), status: z.nullable(SupplierStatus$inboundSchema).optional(), payment_method: z.nullable(types.string()).optional(), terms: z.nullable(types.string()).optional(), terms_id: z.nullable(types.string()).optional(), channel: z.nullable(types.string()).optional(), issued_method: z.nullable(types.string()).optional(), issued_email: z.nullable(types.string()).optional(), custom_mappings: z.nullable(z.record(z.any())).optional(), custom_fields: types.optional(z.array(CustomField$inboundSchema)), tax_details: types.optional( z.array(types.nullable(LinkedTaxDetail$inboundSchema)), ), tax_status_details: types.optional( z.array(types.nullable(LinkedTaxStatusDetail$inboundSchema)), ), 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(), row_version: z.nullable(types.string()).optional(), pass_through: types.optional(z.array(PassThroughBody$inboundSchema)), subsidiary_id: types.optional(types.string()), integration_system_id: types.optional(types.string()), }).transform((v) => { return remap$(v, { "downstream_id": "downstreamId", "display_id": "displayId", "display_name": "displayName", "company_name": "companyName", "company_id": "companyId", "supplier_category": "supplierCategory", "first_name": "firstName", "middle_name": "middleName", "last_name": "lastName", "phone_numbers": "phoneNumbers", "bank_accounts": "bankAccounts", "tax_rate": "taxRate", "tax_number": "taxNumber", "payment_method": "paymentMethod", "terms_id": "termsId", "issued_method": "issuedMethod", "issued_email": "issuedEmail", "custom_mappings": "customMappings", "custom_fields": "customFields", "tax_details": "taxDetails", "tax_status_details": "taxStatusDetails", "updated_by": "updatedBy", "created_by": "createdBy", "updated_at": "updatedAt", "created_at": "createdAt", "row_version": "rowVersion", "pass_through": "passThrough", "subsidiary_id": "subsidiaryId", "integration_system_id": "integrationSystemId", }); }) ); export function supplierFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Supplier$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Supplier' from JSON`, ); } /** @internal */ export type SupplierInput$Outbound = { display_id?: string | null | undefined; display_name?: string | null | undefined; company_name?: string | null | undefined; company_id?: string | null | undefined; subsidiary?: LinkedSubsidiaryInput$Outbound | null | undefined; supplier_category?: string | null | undefined; title?: string | null | undefined; first_name?: string | null | undefined; middle_name?: string | null | undefined; last_name?: string | null | undefined; suffix?: string | null | undefined; individual?: boolean | null | undefined; addresses?: Array | undefined; phone_numbers?: Array | undefined; emails?: Array | undefined; websites?: Array | undefined; bank_accounts?: Array | undefined; notes?: string | null | undefined; tax_rate?: LinkedTaxRateInput$Outbound | undefined; tax_number?: string | null | undefined; taxable?: boolean | null | undefined; currency?: string | null | undefined; account?: LinkedLedgerAccount$Outbound | null | undefined; status?: string | null | undefined; payment_method?: string | null | undefined; terms?: string | null | undefined; terms_id?: string | null | undefined; channel?: string | null | undefined; issued_method?: string | null | undefined; issued_email?: string | null | undefined; custom_fields?: Array | undefined; tax_details?: Array | undefined; tax_status_details?: Array | undefined; row_version?: string | null | undefined; pass_through?: Array | undefined; subsidiary_id?: string | undefined; integration_system_id?: string | undefined; }; /** @internal */ export const SupplierInput$outboundSchema: z.ZodType< SupplierInput$Outbound, z.ZodTypeDef, SupplierInput > = /* @__PURE__ */ lazySchema$(() => z.object({ displayId: z.nullable(z.string()).optional(), displayName: z.nullable(z.string()).optional(), companyName: z.nullable(z.string()).optional(), companyId: z.nullable(z.string()).optional(), subsidiary: z.nullable(LinkedSubsidiaryInput$outboundSchema).optional(), supplierCategory: z.nullable(z.string()).optional(), title: z.nullable(z.string()).optional(), firstName: z.nullable(z.string()).optional(), middleName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), suffix: z.nullable(z.string()).optional(), individual: z.nullable(z.boolean()).optional(), addresses: z.array(Address$outboundSchema).optional(), phoneNumbers: z.array(PhoneNumber$outboundSchema).optional(), emails: z.array(Email$outboundSchema).optional(), websites: z.array(Website$outboundSchema).optional(), bankAccounts: z.array(BankAccount$outboundSchema).optional(), notes: z.nullable(z.string()).optional(), taxRate: LinkedTaxRateInput$outboundSchema.optional(), taxNumber: z.nullable(z.string()).optional(), taxable: z.nullable(z.boolean()).optional(), currency: z.nullable(Currency$outboundSchema).optional(), account: z.nullable(LinkedLedgerAccount$outboundSchema).optional(), status: z.nullable(SupplierStatus$outboundSchema).optional(), paymentMethod: z.nullable(z.string()).optional(), terms: z.nullable(z.string()).optional(), termsId: z.nullable(z.string()).optional(), channel: z.nullable(z.string()).optional(), issuedMethod: z.nullable(z.string()).optional(), issuedEmail: z.nullable(z.string()).optional(), customFields: z.array(CustomField$outboundSchema).optional(), taxDetails: z.array(z.nullable(LinkedTaxDetail$outboundSchema)).optional(), taxStatusDetails: z.array(z.nullable(LinkedTaxStatusDetail$outboundSchema)) .optional(), rowVersion: z.nullable(z.string()).optional(), passThrough: z.array(PassThroughBody$outboundSchema).optional(), subsidiaryId: z.string().optional(), integrationSystemId: z.string().optional(), }).transform((v) => { return remap$(v, { displayId: "display_id", displayName: "display_name", companyName: "company_name", companyId: "company_id", supplierCategory: "supplier_category", firstName: "first_name", middleName: "middle_name", lastName: "last_name", phoneNumbers: "phone_numbers", bankAccounts: "bank_accounts", taxRate: "tax_rate", taxNumber: "tax_number", paymentMethod: "payment_method", termsId: "terms_id", issuedMethod: "issued_method", issuedEmail: "issued_email", customFields: "custom_fields", taxDetails: "tax_details", taxStatusDetails: "tax_status_details", rowVersion: "row_version", passThrough: "pass_through", subsidiaryId: "subsidiary_id", integrationSystemId: "integration_system_id", }); }) ); export function supplierInputToJSON(supplierInput: SupplierInput): string { return JSON.stringify(SupplierInput$outboundSchema.parse(supplierInput)); }