import {z} from 'zod' export type VendorContact = {id: number, name?: (string | null) | undefined, first_name?: (string | null) | undefined, last_name?: (string | null) | undefined, email?: (string | null) | undefined, phone_number?: (string | null) | undefined, mobile_number?: (string | null) | undefined, last_modified_at: string, is_deleted: boolean, deleted_at: string | null}; export type VendorType391Enum = 'vendor' | 'customer' | 'employee'; export type BlankEnum = ''; export type NullEnum = unknown; export type ItaDeductionTypeCodeEnum = '1' | '2' | '3' | '4' | '5'; export type ItaVendorEntityCodeEnum = '0' | '2' | '3' | '5'; export type ItaVendorEntityTypeEnum = '1' | '2' | '3'; export type Source3b3Enum = 'BILL' | 'BREX' | 'HUBSPOT' | 'MANUAL' | 'PAYROLL' | 'SALESFORCE'; export type Status372Enum = 'ACTIVE' | 'INACTIVE'; export type TermsEnum = 'custom' | 'net_5' | 'net_7' | 'net_10' | 'net_15' | 'net_20' | 'net_30' | 'net_40' | 'net_45' | 'net_60' | 'net_90' | 'net_105' | 'net_120' | 'due_on_receipt'; export type PatchedContractCustomer = {id?: number | undefined, contacts?: Array | undefined, parent_name?: string | undefined, stripe_connection_name?: (string | null) | undefined, stripe_connection_entity?: (number | null) | undefined, stripe_connection_portal_url?: (string | null) | undefined, stripe_connection_portal_enabled?: (boolean | null) | undefined, stripe_connection_invoicing_enabled?: (boolean | null) | undefined, vendor_custom_field_1_name?: string | undefined, payment_term_name_display?: string | undefined, last_modified_at?: string | undefined, is_deleted?: boolean | undefined, deleted_at?: (string | null) | undefined, active_contracts?: number | undefined, completed_contracts?: number | undefined, pending_contracts?: number | undefined, total_contracts?: number | undefined, total_revenue?: number | undefined, total_deferred_revenue?: number | undefined, total_mrr?: number | undefined, total_billed?: number | undefined, total_unbilled?: number | undefined, total_paid?: number | undefined, total_outstanding?: number | undefined, total_credit_memos?: number | undefined, credit_memo_applied?: number | undefined, credit_memo_available?: number | undefined, currency?: string | undefined, search_vector?: (string | null) | undefined, search_text?: (string | null) | undefined, campfire_id?: (string | null) | undefined, vendor_type?: (VendorType391Enum | BlankEnum | NullEnum | null) | undefined, name?: (string | null) | undefined, dba?: (string | null) | undefined, company_name?: (string | null) | undefined, website?: (string | null) | undefined, first_name?: (string | null) | undefined, last_name?: (string | null) | undefined, email?: (string | null) | undefined, phone_number?: (string | null) | undefined, mobile_number?: (string | null) | undefined, address_street_1?: (string | null) | undefined, address_street_2?: (string | null) | undefined, city?: (string | null) | undefined, state?: (string | null) | undefined, zip_code?: (string | null) | undefined, country?: (string | null) | undefined, billing_address_street_1?: (string | null) | undefined, billing_address_street_2?: (string | null) | undefined, billing_city?: (string | null) | undefined, billing_state?: (string | null) | undefined, billing_zip_code?: (string | null) | undefined, billing_country?: (string | null) | undefined, shipping_addressee?: (string | null) | undefined, billing_addressee?: (string | null) | undefined, notes?: (string | null) | undefined, business_id_ssn?: (string | null) | undefined, is_1099?: boolean | undefined, vat_number?: (string | null) | undefined, business_type?: (string | null) | undefined, business_category?: (string | null) | undefined, entity_use_code?: (string | null) | undefined, withholding_tax_id?: (string | null) | undefined, ita_deduction_type_code?: (ItaDeductionTypeCodeEnum | BlankEnum | NullEnum | null) | undefined, ita_vendor_entity_code?: (ItaVendorEntityCodeEnum | BlankEnum | NullEnum | null) | undefined, ita_vendor_entity_type?: (ItaVendorEntityTypeEnum | BlankEnum | NullEnum | null) | undefined, stripe_customer_id?: (string | null) | undefined, use_stripe_auto_bill?: (boolean | null) | undefined, bill_vendor_id?: (string | null) | undefined, external_id?: (string | null) | undefined, source?: (Source3b3Enum | BlankEnum | NullEnum | null) | undefined, invoice_message?: (string | null) | undefined, abbreviation?: (string | null) | undefined, created_at?: string | undefined, status?: Status372Enum | undefined, anrok_customer_id?: (string | null) | undefined, avalara_customer_id?: (string | null) | undefined, terms?: (TermsEnum | BlankEnum | NullEnum | null) | undefined, invoice_labels: unknown, invoice_language?: (string | null) | undefined, lineage_array?: (Array | null) | undefined, customer?: number | undefined, parent?: (number | null) | undefined, stripe_connection?: (number | null) | undefined, default_expense_category?: (number | null) | undefined, vendor_custom_field_1?: (number | null) | undefined, payment_term?: (number | null) | undefined}; export type PatchApiRrApiV1CustomersIdArgs = {id: number, body: PatchedContractCustomer}; export type PatchApiRrApiV1CustomersIdOptions = {baseUrl?: string | undefined, knoxApiToken?: string | undefined, fetch?: typeof fetch | undefined}; export const vendorContact = z.object({id: z.number().int(), name: z.string().nullable().optional(), first_name: z.string().max(250).nullable().optional(), last_name: z.string().max(250).nullable().optional(), email: z.string().max(250).nullable().optional(), phone_number: z.string().max(250).nullable().optional(), mobile_number: z.string().max(250).nullable().optional(), last_modified_at: z.string(), is_deleted: z.boolean(), deleted_at: z.string().nullable()}); export const vendorType391Enum = z.enum(["vendor", "customer", "employee"]); export const blankEnum = z.literal(""); export const nullEnum = z.unknown(); export const itaDeductionTypeCodeEnum = z.enum(["1", "2", "3", "4", "5"]); export const itaVendorEntityCodeEnum = z.enum(["0", "2", "3", "5"]); export const itaVendorEntityTypeEnum = z.enum(["1", "2", "3"]); export const source3b3Enum = z.enum(["BILL", "BREX", "HUBSPOT", "MANUAL", "PAYROLL", "SALESFORCE"]); export const status372Enum = z.enum(["ACTIVE", "INACTIVE"]); export const termsEnum = z.enum(["custom", "net_5", "net_7", "net_10", "net_15", "net_20", "net_30", "net_40", "net_45", "net_60", "net_90", "net_105", "net_120", "due_on_receipt"]); export const contractCustomer = z.object({id: z.number().int(), contacts: z.array(vendorContact).optional(), parent_name: z.string(), stripe_connection_name: z.string().nullable(), stripe_connection_entity: z.number().int().nullable(), stripe_connection_portal_url: z.string().nullable(), stripe_connection_portal_enabled: z.boolean().nullable(), stripe_connection_invoicing_enabled: z.boolean().nullable(), vendor_custom_field_1_name: z.string(), payment_term_name_display: z.string(), last_modified_at: z.string(), is_deleted: z.boolean(), deleted_at: z.string().nullable(), active_contracts: z.number().int(), completed_contracts: z.number().int(), pending_contracts: z.number().int(), total_contracts: z.number().int(), total_revenue: z.number().gt(-10000000000000).lt(10000000000000), total_deferred_revenue: z.number().gt(-10000000000000).lt(10000000000000), total_mrr: z.number().gt(-10000000000000).lt(10000000000000), total_billed: z.number().gt(-10000000000000).lt(10000000000000), total_unbilled: z.number().gt(-10000000000000).lt(10000000000000), total_paid: z.number().gt(-10000000000000).lt(10000000000000), total_outstanding: z.number().gt(-10000000000000).lt(10000000000000), total_credit_memos: z.number().gt(-10000000000000).lt(10000000000000), credit_memo_applied: z.number().gt(-10000000000000).lt(10000000000000), credit_memo_available: z.number().gt(-10000000000000).lt(10000000000000), currency: z.string(), search_vector: z.string().nullable(), search_text: z.string().nullable(), campfire_id: z.string().nullable(), vendor_type: z.union([vendorType391Enum, blankEnum, nullEnum]).nullable().optional(), name: z.string().max(250).nullable(), dba: z.string().max(250).nullable().optional(), company_name: z.string().max(250).nullable().optional(), website: z.string().max(250).nullable().optional(), first_name: z.string().max(250).nullable().optional(), last_name: z.string().max(250).nullable().optional(), email: z.string().max(250).nullable().optional(), phone_number: z.string().max(250).nullable().optional(), mobile_number: z.string().max(250).nullable().optional(), address_street_1: z.string().max(250).nullable().optional(), address_street_2: z.string().max(250).nullable().optional(), city: z.string().max(250).nullable().optional(), state: z.string().max(250).nullable().optional(), zip_code: z.string().max(250).nullable().optional(), country: z.string().max(250).nullable().optional(), billing_address_street_1: z.string().max(250).nullable().optional(), billing_address_street_2: z.string().max(250).nullable().optional(), billing_city: z.string().max(250).nullable().optional(), billing_state: z.string().max(250).nullable().optional(), billing_zip_code: z.string().max(250).nullable().optional(), billing_country: z.string().max(250).nullable().optional(), shipping_addressee: z.string().max(255).nullable().optional(), billing_addressee: z.string().max(255).nullable().optional(), notes: z.string().max(250).nullable().optional(), business_id_ssn: z.string().max(250).nullable().optional(), is_1099: z.boolean().optional(), vat_number: z.string().max(250).nullable().optional(), business_type: z.string().max(250).nullable().optional(), business_category: z.string().max(250).nullable().optional(), entity_use_code: z.string().max(25).nullable().optional(), withholding_tax_id: z.string().max(250).nullable().optional(), ita_deduction_type_code: z.union([itaDeductionTypeCodeEnum, blankEnum, nullEnum]).nullable().optional(), ita_vendor_entity_code: z.union([itaVendorEntityCodeEnum, blankEnum, nullEnum]).nullable().optional(), ita_vendor_entity_type: z.union([itaVendorEntityTypeEnum, blankEnum, nullEnum]).nullable().optional(), stripe_customer_id: z.string().max(250).nullable().optional(), use_stripe_auto_bill: z.boolean().nullable().optional(), bill_vendor_id: z.string().max(250).nullable().optional(), external_id: z.string().max(250).nullable().optional(), source: z.union([source3b3Enum, blankEnum, nullEnum]).nullable().optional(), invoice_message: z.string().nullable().optional(), abbreviation: z.string().max(250).nullable().optional(), created_at: z.string(), status: status372Enum.optional(), anrok_customer_id: z.string().max(250).nullable().optional(), avalara_customer_id: z.string().max(250).nullable().optional(), terms: z.union([termsEnum, blankEnum, nullEnum]).nullable().optional(), invoice_labels: z.unknown(), invoice_language: z.string().max(10).nullable().optional(), lineage_array: z.array(z.string().max(50)).nullable().optional(), customer: z.number().int(), parent: z.number().int().nullable().optional(), stripe_connection: z.number().int().nullable(), default_expense_category: z.number().int().nullable().optional(), vendor_custom_field_1: z.number().int().nullable().optional(), payment_term: z.number().int().nullable().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Partial Update Contract Customer * * PATCH /rr/api/v1/customers/{id} */ export const patchApiRrApiV1CustomersId = async (args: PatchApiRrApiV1CustomersIdArgs, options?: PatchApiRrApiV1CustomersIdOptions) => { const {baseUrl = "https://api.meetcampfire.com", fetch: fetchFn = fetch, knoxApiToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (knoxApiToken !== undefined) headers.set("Authorization", knoxApiToken) const url = `${baseUrl.replace(/\/+$/, '')}/rr/api/v1/customers/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(contractCustomer, await res.json()) };