UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

1,088 lines (1,087 loc) 50.5 kB
import { BaseServiceClient } from '../../core/base-client'; import type { HTTPClient } from '../../core/client'; import { CartHdrListParams, CartHdrLookupParams, CartHdrLookupResponse, CartLineAddRequest, CartLineUpdateRequest, CartLineModifyResponse, CartLineDeleteResponse, AlsoBoughtParams, AlsoBoughtResponse, CheckoutCreateRequest, CheckoutDocParams } from './schemas'; /** * Commerce API Client * @description Client for interacting with Commerce microservice API endpoints for e-commerce operations * @example * ```typescript * import { HTTPClient } from '@augur/api-client/core'; * import { CommerceClient } from '@augur/api-client/services/commerce'; * * const http = new HTTPClient('commerce', { siteId: 'your-site-id', bearerToken: 'your-token' }); * const commerce = new CommerceClient(http); * * // Create or lookup cart * const cart = await commerce.cartHeaders.lookup({ userId: 12345, customerId: 456, contactId: 123 }); * * // Add items to cart * await commerce.cartLines.add(cart.cartHdrUid, [{ invMastUid: 12345, quantity: 2, unitOfMeasure: 'EA' }]); * * // Create checkout * const checkout = await commerce.checkout.create({ customer: {...}, payment: {...}, lineItems: [...] }); * ``` */ export declare class CommerceClient extends BaseServiceClient { /** * Create a new CommerceClient instance * @param http Configured HTTPClient instance * @param baseUrl Base URL for the Commerce API (default: https://commerce.augur-api.com) */ constructor(http: HTTPClient, baseUrl?: string); /** * Cart Header endpoints * @description Methods for shopping cart session management with user tracking and cart tokens */ cartHeaders: { /** * Retrieve a list of cart headers for a specific user * * @fullPath api.commerce.cartHeaders.list * @service commerce * @domain cart-management * @dataMethod listData * @discoverable true * @searchTerms ["cart", "list", "shopping cart", "user carts", "cart headers", "session", "baskets"] * @relatedEndpoints ["api.commerce.cartLines.get", "api.commerce.cartHeaders.lookup", "api.customers.customer.list", "api.joomla.users.list"] * @commonPatterns ["Get all user carts", "List shopping carts", "Find user sessions", "Shopping cart history"] * @workflow ["cart-management", "session-tracking", "user-cart-retrieval"] * @prerequisites ["Valid authentication token", "Valid user ID", "Cart management permissions"] * @nextSteps ["api.commerce.cartLines.get for cart contents", "api.commerce.cartHeaders.lookup for specific cart"] * @businessRules ["Returns only carts accessible to current user", "Respects user permissions", "Includes abandoned carts"] * @functionalArea "cart-and-session-management" * @caching "Cache for 2 minutes, invalidate on cart changes" * @performance "Lightweight operation, pagination not required for typical usage" * * @description Returns all cart headers associated with a user ID for session management and cart recovery * @param params User ID for filtering cart headers * @returns Promise<BaseResponse<CartHdr[]>> Complete response with cart headers array and metadata * @throws ValidationError When parameters are invalid or response is malformed * * @example * ```typescript * // Get all carts for a user * const response = await client.cartHeaders.list({ userId: 12345 }); * console.log(response.data); // CartHdr[] * * // Get just the data array * const carts = await client.cartHeaders.listData({ userId: 12345 }); * carts.forEach(cart => console.log(cart.cartHdrUid, cart.cartToken)); * ``` */ list: (params?: { userId: number; edgeCache?: 3 | 2 | 4 | 1 | "1" | 5 | 8 | "2" | "3" | "4" | "5" | "8" | undefined; limit?: number | undefined; offset?: number | undefined; } | undefined) => Promise<{ params: Record<string, unknown> | unknown[]; data: { customerId: number; contactId: number; userId: number; cartHdrUid: number; userCartNo: number; dateCreated?: string | undefined; dateLastModified?: string | undefined; statusCd?: number | undefined; sessionId?: string | undefined; emailAddress?: string | undefined; cartToken?: string | null | undefined; version?: number | undefined; processCd?: number | undefined; }[]; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Lookup an existing cart or create a new one * * @fullPath api.commerce.cartHeaders.lookup * @service commerce * @domain cart-management * @dataMethod lookupData * @discoverable true * @searchTerms ["cart lookup", "find cart", "get cart", "cart token", "shopping cart", "user cart", "session cart"] * @relatedEndpoints ["api.commerce.cartHeaders.list", "api.commerce.cartLines.get", "api.customers.customer.get", "api.joomla.users.get"] * @commonPatterns ["Find user's active cart", "Get or create cart", "Resume shopping session", "Cart token validation"] * @workflow ["cart-retrieval", "session-management", "cart-creation"] * @prerequisites ["Valid authentication token", "Valid user, customer, and contact IDs"] * @nextSteps ["api.commerce.cartLines.get for cart contents", "api.commerce.cartLines.add to add items"] * @businessRules ["Creates new cart if none exists", "Returns existing cart if found", "Validates user permissions"] * @functionalArea "cart-and-session-management" * @caching "Cache for 5 minutes, invalidate on cart modifications" * @performance "Fast lookup operation, includes cart creation logic" * * @description Looks up an existing cart or creates a new one for the specified user, customer, and contact * @param params User, customer, and contact identifiers with optional cart token * @returns Promise<BaseResponse<CartHdr>> Complete response with cart header details and metadata * @throws ValidationError When parameters are invalid or response is malformed * * @example * ```typescript * // Lookup existing cart * const response = await client.cartHeaders.lookup({ * userId: 12345, * customerId: 456, * contactId: 123, * cartToken: 'abc123' * }); * console.log(response.data.cartHdrUid); * * // Create new cart (data method) * const cart = await client.cartHeaders.lookupData({ * userId: 12345, * customerId: 456, * contactId: 123 * }); * ``` */ lookup: (params: CartHdrLookupParams) => Promise<CartHdrLookupResponse>; /** * Get product recommendations based on cart contents * * @fullPath api.commerce.cartHeaders.getAlsoBought * @service commerce * @domain recommendation-engine * @dataMethod getAlsoBoughtData * @discoverable true * @searchTerms ["recommendations", "also bought", "cross sell", "upsell", "related products", "suggestions", "shopping recommendations"] * @relatedEndpoints ["api.commerce.cartLines.get", "api.items.products.list", "api.legacy.alsoBought.list"] * @commonPatterns ["Get product recommendations", "Cross-sell products", "Increase cart value", "Related item suggestions"] * @workflow ["recommendation-display", "cross-selling", "cart-enhancement"] * @prerequisites ["Valid cart header UID", "Cart with existing items for best recommendations"] * @nextSteps ["api.commerce.cartLines.add to add recommended items", "api.items.products.get for product details"] * @businessRules ["Based on purchase history patterns", "Respects inventory availability", "Paginated results for performance"] * @functionalArea "recommendation-and-cross-sell" * @caching "Cache for 30 minutes, static recommendation data" * @performance "Supports pagination with limit/offset, optimized for recommendation engine" * * @description Retrieves also-bought product recommendations based on items currently in the cart * @param cartHdrUid Cart header unique identifier * @param params Optional pagination parameters (limit, offset) * @returns Promise<BaseResponse<AlsoBoughtItem[]>> Complete response with recommended products and pagination metadata * @throws ValidationError When parameters are invalid or response is malformed * * @example * ```typescript * // Get recommendations with pagination * const response = await client.cartHeaders.getAlsoBought(789, { limit: 5, offset: 0 }); * console.log(`Found ${response.total} recommendations, showing ${response.count}`); * response.data.forEach(item => console.log(item.itemId, item.description, item.price)); * * // Get just the data array * const recommendations = await client.cartHeaders.getAlsoBoughtData(789, { limit: 10 }); * ``` */ getAlsoBought: (cartHdrUid: number, params?: AlsoBoughtParams) => Promise<AlsoBoughtResponse>; /** * Get list of cart headers (data only) * @description Data-only version of list method - returns just the cart headers array * @param params User ID for filtering cart headers * @returns Array of cart headers for the user */ listData: (params: CartHdrListParams) => Promise<{ customerId: number; contactId: number; userId: number; cartHdrUid: number; userCartNo: number; dateCreated?: string | undefined; dateLastModified?: string | undefined; statusCd?: number | undefined; sessionId?: string | undefined; emailAddress?: string | undefined; cartToken?: string | null | undefined; version?: number | undefined; processCd?: number | undefined; }[]>; /** * Lookup cart header (data only) * @description Data-only version of lookup method - returns just the cart header object * @param params User, customer, and contact identifiers with optional cart token * @returns Cart header details */ lookupData: (params: CartHdrLookupParams) => Promise<{ customerId: number; contactId: number; userId: number; cartHdrUid: number; userCartNo: number; dateCreated?: string | undefined; dateLastModified?: string | undefined; statusCd?: number | undefined; sessionId?: string | undefined; emailAddress?: string | undefined; cartToken?: string | null | undefined; version?: number | undefined; processCd?: number | undefined; }>; /** * Get also bought recommendations (data only) * @description Data-only version of getAlsoBought method - returns just the recommendations array * @param cartHdrUid Cart header unique identifier * @param params Optional pagination parameters * @returns Array of recommended products */ getAlsoBoughtData: (cartHdrUid: number, params?: AlsoBoughtParams) => Promise<{ images: string[]; invMastUid: number; itemId: string; deleteFlag: string; baseUnit: string; serialized: string; trackLots: string; inventorySupplier: unknown[]; itemUom: { unitOfMeasure: string; unitSize: number; }[]; alternateCodes: string[]; legacyTags: string[]; attributes: unknown[]; categoryList: number[]; userDefined: Record<string, unknown> | unknown[]; invMastText: { sequenceNo: number; displayOnWebFlag: string; textTypeCd: number; webDisplayTypeUid: number; webDisplayTypeId: string; webDisplayTypeDesc: string; textValue: string; textTypeDesc?: string | null | undefined; }[]; length?: number | null | undefined; itemDesc?: string | null | undefined; displayDesc?: string | null | undefined; extendedDesc?: string | null | undefined; defaultSellingUnit?: string | null | undefined; defaultPurchasingUnit?: string | null | undefined; vndrStock?: number | null | undefined; classId1?: string | null | undefined; classId2?: string | null | undefined; classId3?: string | null | undefined; classId4?: string | null | undefined; classId5?: string | null | undefined; defaultProductGroup?: string | null | undefined; upcOrEan?: string | null | undefined; upcOrEanId?: string | null | undefined; weight?: number | null | undefined; width?: number | null | undefined; height?: number | null | undefined; }[]>; }; /** * Cart Line endpoints * @description Methods for managing individual line items within shopping carts */ cartLines: { /** * Retrieve all line items for a specific cart * * @fullPath api.commerce.cartLines.get * @service commerce * @domain cart-management * @dataMethod getData * @discoverable true * @searchTerms ["cart lines", "cart items", "line items", "cart contents", "shopping cart items", "cart products"] * @relatedEndpoints ["api.commerce.cartHeaders.lookup", "api.items.products.get", "api.commerce.cartLines.add", "api.commerce.cartLines.update"] * @commonPatterns ["View cart contents", "Get cart line items", "Display shopping cart", "Cart item details"] * @workflow ["cart-display", "cart-review", "checkout-preparation"] * @prerequisites ["Valid cart header UID", "Cart must exist"] * @nextSteps ["api.commerce.cartLines.update to modify items", "api.commerce.checkout.create to proceed to checkout"] * @businessRules ["Returns all line items in cart", "Includes product details and pricing", "Ordered by line number"] * @functionalArea "cart-and-session-management" * @caching "Cache for 2 minutes, invalidate on cart modifications" * @performance "Fast retrieval, includes product joins for display" * * @description Returns all line items in a cart with product details, quantities, and pricing * @param cartHdrUid Cart header unique identifier * @returns Promise<BaseResponse<CartLine[]>> Complete response with cart line items and metadata * @throws ValidationError When response is malformed * * @example * ```typescript * // Get cart line items * const response = await client.cartLines.get(789); * response.data.forEach(line => { * console.log(`Line ${line.lineNo}: ${line.quantity} x ${line.itemId} @ $${line.unitPrice}`); * }); * * // Get just the data array * const lines = await client.cartLines.getData(789); * ``` */ get: (id: string | number, params?: import("../../core/base-client").CacheParams | undefined) => Promise<{ params: Record<string, unknown> | unknown[]; data: { lineNo: number; invMastUid: number; itemId: string; isAssembly: "Y" | "N"; invMastUidCount: number; key?: string | null | undefined; dateCreated?: string | undefined; dateLastModified?: string | undefined; cartHdrUid?: number | undefined; quantity?: number | null | undefined; unitOfMeasure?: string | null | undefined; lineNote?: string | null | undefined; unitPrice?: number | null | undefined; }[]; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Add one or more items to the cart * * @fullPath api.commerce.cartLines.add * @service commerce * @domain cart-management * @dataMethod addData * @discoverable true * @searchTerms ["add to cart", "cart add", "add items", "shopping cart add", "add products", "cart line add"] * @relatedEndpoints ["api.commerce.cartLines.get", "api.commerce.cartLines.update", "api.items.products.get", "api.pricing.pricing.calculate"] * @commonPatterns ["Add item to cart", "Add multiple items", "Bulk add to cart", "Shopping cart addition"] * @workflow ["product-to-cart", "shopping-flow", "cart-building"] * @prerequisites ["Valid cart header UID", "Valid product inventory UIDs", "Items must be available"] * @nextSteps ["api.commerce.cartLines.get to view updated cart", "api.commerce.checkout.create to proceed to checkout"] * @businessRules ["Aggregates quantities for duplicate items", "Validates inventory availability", "Applies pricing rules"] * @functionalArea "cart-and-session-management" * @caching "No caching, immediate cart modification" * @performance "Batch operation for multiple items, validates inventory in bulk" * * @description Adds line items to the shopping cart with automatic quantity aggregation for matching items * @param cartHdrUid Cart header unique identifier * @param items Array of cart line items to add * @returns Promise<BaseResponse<boolean>> Complete response with success status and metadata * @throws ValidationError When request is invalid or response is malformed * * @example * ```typescript * // Add multiple items to cart * const response = await client.cartLines.add(789, [ * { * invMastUid: 12345, * quantity: 2.0, * unitOfMeasure: 'EA', * lineNote: 'Rush order', * unitPrice: 29.99 * }, * { * invMastUid: 67890, * quantity: 1.0, * unitOfMeasure: 'LB' * } * ]); * * // Get just the success boolean * const success = await client.cartLines.addData(789, items); * ``` */ add: (cartHdrUid: number, items: CartLineAddRequest) => Promise<CartLineModifyResponse>; /** * Update quantities or details for existing cart line items * @description Updates existing line items in the cart with new quantities, notes, or other modifications * @param cartHdrUid Cart header unique identifier * @param items Array of cart line items to update (must specify lineNo or key for identification) * @returns Boolean indicating successful update * @throws ValidationError When request is invalid or response is malformed * @example * ```typescript * const success = await client.cartLines.update(789, [ * { * lineNo: 1, * quantity: 5.0, * lineNote: 'Updated quantity to 5' * }, * { * key: 'unique-key-123', * quantity: 3.0 * } * ]); * ``` */ update: (cartHdrUid: number, items: CartLineUpdateRequest) => Promise<CartLineModifyResponse>; /** * Remove all line items from the cart * @description Clears all line items from the specified cart, leaving the cart header intact * @param cartHdrUid Cart header unique identifier * @returns Boolean indicating successful clearing of cart * @throws ValidationError When response is malformed * @example * ```typescript * const success = await client.cartLines.clear(789); * if (success) { * console.log('Cart has been cleared of all items'); * } * ``` */ clear: (id: string | number) => Promise<{ params: Record<string, unknown> | unknown[]; data: boolean; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Remove a specific line item from the cart * @description Removes a single line item from the cart by line number * @param cartHdrUid Cart header unique identifier * @param lineNo Line number to delete * @returns Boolean indicating successful deletion * @throws ValidationError When response is malformed * @example * ```typescript * const success = await client.cartLines.deleteLine(789, 1); * if (success) { * console.log('Line item 1 has been removed from cart'); * } * ``` */ deleteLine: (cartHdrUid: number, lineNo: number) => Promise<CartLineDeleteResponse>; /** * Get cart line items (data only) * @description Returns only the data array from cart line items response * @param cartHdrUid Cart header unique identifier * @returns Array of cart line items (data only) * @throws ValidationError When response is malformed */ getData: (cartHdrUid: number) => Promise<{ lineNo: number; invMastUid: number; itemId: string; isAssembly: "Y" | "N"; invMastUidCount: number; key?: string | null | undefined; dateCreated?: string | undefined; dateLastModified?: string | undefined; cartHdrUid?: number | undefined; quantity?: number | null | undefined; unitOfMeasure?: string | null | undefined; lineNote?: string | null | undefined; unitPrice?: number | null | undefined; }[]>; /** * Add items to cart (data only) * @description Returns only the data from cart line addition response * @param cartHdrUid Cart header unique identifier * @param items Array of cart line items to add * @returns Addition result (data only) * @throws ValidationError When request is invalid or response is malformed */ addData: (cartHdrUid: number, items: CartLineAddRequest) => Promise<boolean>; /** * Update cart line items (data only) * @description Returns only the data from cart line update response * @param cartHdrUid Cart header unique identifier * @param items Array of cart line items to update * @returns Update result (data only) * @throws ValidationError When request is invalid or response is malformed */ updateData: (cartHdrUid: number, items: CartLineUpdateRequest) => Promise<boolean>; /** * Clear all cart line items (data only) * @description Returns only the data from cart clear response * @param cartHdrUid Cart header unique identifier * @returns Clear result (data only) * @throws ValidationError When response is malformed */ clearData: (cartHdrUid: number) => Promise<boolean>; /** * Delete specific cart line item (data only) * @description Returns only the data from cart line deletion response * @param cartHdrUid Cart header unique identifier * @param lineNo Line number to delete * @returns Deletion result (data only) * @throws ValidationError When response is malformed */ deleteLineData: (cartHdrUid: number, lineNo: number) => Promise<{ message: string; success: boolean; }>; }; /** * Checkout endpoints * @description Methods for end-to-end checkout processing with Prophet21 ERP integration */ checkout: { /** * Create a new checkout session * @description Creates a new checkout with complete order data including customer, payment, and line items * @param orderData Complete checkout data with customer information, payment details, and line items * @returns Created checkout with unique identifiers and status * @throws ValidationError When request is invalid or response is malformed * @example * ```typescript * const checkout = await client.checkout.create({ * customer: { * customerId: 456, * contactId: 123, * billToName: 'John Doe', * billToAddress1: '123 Main St', * billToCity: 'Anytown', * billToState: 'CA', * billToZip: '12345', * billToCountry: 'US', * shipToName: 'John Doe', * shipToAddress1: '123 Main St', * shipToCity: 'Anytown', * shipToState: 'CA', * shipToZip: '12345', * shipToCountry: 'US' * }, * payment: { * paymentType: 'CC', * cardNumber: '4111111111111111', * expirationDate: '12/25', * cvv: '123', * cardHolderName: 'John Doe' * }, * lineItems: [ * { invMastUid: 12345, quantity: 2, unitOfMeasure: 'EA', unitPrice: 29.99 } * ] * }); * ``` */ create: (data: { oeHdr?: { customerId?: number | undefined; userId?: string | number | undefined; customer_id?: number | undefined; shipToZipCode?: string | undefined; ship_to_zip?: string | undefined; ship_to_postal_code?: string | undefined; shipToEmailAddress?: string | undefined; ship_to_email?: string | undefined; customerPoNo?: string | undefined; customer_po_no?: string | undefined; customer_po_number?: string | undefined; class1?: string | null | undefined; class_id1?: string | null | undefined; class2?: string | null | undefined; class_id2?: string | null | undefined; class3?: string | null | undefined; class_id3?: string | null | undefined; class4?: string | null | undefined; class_id4?: string | null | undefined; class5?: string | null | undefined; class_id5?: string | null | undefined; taker?: string | undefined; shippingEstimate?: number | undefined; shipping_estimate?: number | undefined; cartTax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; cart_tax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; userEmail?: string | undefined; user_email?: string | undefined; user_id?: string | number | undefined; } | undefined; oe_hdr?: { customerId?: number | undefined; userId?: string | number | undefined; customer_id?: number | undefined; shipToZipCode?: string | undefined; ship_to_zip?: string | undefined; ship_to_postal_code?: string | undefined; shipToEmailAddress?: string | undefined; ship_to_email?: string | undefined; customerPoNo?: string | undefined; customer_po_no?: string | undefined; customer_po_number?: string | undefined; class1?: string | null | undefined; class_id1?: string | null | undefined; class2?: string | null | undefined; class_id2?: string | null | undefined; class3?: string | null | undefined; class_id3?: string | null | undefined; class4?: string | null | undefined; class_id4?: string | null | undefined; class5?: string | null | undefined; class_id5?: string | null | undefined; taker?: string | undefined; shippingEstimate?: number | undefined; shipping_estimate?: number | undefined; cartTax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; cart_tax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; userEmail?: string | undefined; user_email?: string | undefined; user_id?: string | number | undefined; } | undefined; header?: { customerId?: number | undefined; userId?: string | number | undefined; customer_id?: number | undefined; shipToZipCode?: string | undefined; ship_to_zip?: string | undefined; ship_to_postal_code?: string | undefined; shipToEmailAddress?: string | undefined; ship_to_email?: string | undefined; customerPoNo?: string | undefined; customer_po_no?: string | undefined; customer_po_number?: string | undefined; class1?: string | null | undefined; class_id1?: string | null | undefined; class2?: string | null | undefined; class_id2?: string | null | undefined; class3?: string | null | undefined; class_id3?: string | null | undefined; class4?: string | null | undefined; class_id4?: string | null | undefined; class5?: string | null | undefined; class_id5?: string | null | undefined; taker?: string | undefined; shippingEstimate?: number | undefined; shipping_estimate?: number | undefined; cartTax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; cart_tax?: { taxAmount?: number | undefined; tax_amount?: number | undefined; } | undefined; userEmail?: string | undefined; user_email?: string | undefined; user_id?: string | number | undefined; } | undefined; oeLine?: { note?: string | undefined; lineNo?: number | undefined; invMastUid?: number | undefined; unitOfMeasure?: string | undefined; lineNote?: string | undefined; unitPrice?: number | undefined; itemId?: string | undefined; unitQuantity?: number | undefined; unit_quantity?: number | undefined; qty?: number | undefined; unit_price?: number | undefined; unit_of_measure?: string | undefined; uom?: string | undefined; manualPriceOverride?: "Y" | "N" | undefined; manual_price_override?: "Y" | "N" | undefined; willCall?: "Y" | "N" | undefined; will_call?: "Y" | "N" | undefined; line_note?: string | undefined; }[] | undefined; oe_line?: { note?: string | undefined; lineNo?: number | undefined; invMastUid?: number | undefined; unitOfMeasure?: string | undefined; lineNote?: string | undefined; unitPrice?: number | undefined; itemId?: string | undefined; unitQuantity?: number | undefined; unit_quantity?: number | undefined; qty?: number | undefined; unit_price?: number | undefined; unit_of_measure?: string | undefined; uom?: string | undefined; manualPriceOverride?: "Y" | "N" | undefined; manual_price_override?: "Y" | "N" | undefined; willCall?: "Y" | "N" | undefined; will_call?: "Y" | "N" | undefined; line_note?: string | undefined; }[] | undefined; lines?: { note?: string | undefined; lineNo?: number | undefined; invMastUid?: number | undefined; unitOfMeasure?: string | undefined; lineNote?: string | undefined; unitPrice?: number | undefined; itemId?: string | undefined; unitQuantity?: number | undefined; unit_quantity?: number | undefined; qty?: number | undefined; unit_price?: number | undefined; unit_of_measure?: string | undefined; uom?: string | undefined; manualPriceOverride?: "Y" | "N" | undefined; manual_price_override?: "Y" | "N" | undefined; willCall?: "Y" | "N" | undefined; will_call?: "Y" | "N" | undefined; line_note?: string | undefined; }[] | undefined; notes?: { note?: string | undefined; topic?: string | undefined; } | undefined; payments?: { state?: string | undefined; paymentAccountId?: string | undefined; payment_account_id?: string | undefined; PaymentAccountID?: string | undefined; processor?: string | undefined; lastFour?: string | number | undefined; last_four?: string | number | undefined; LastFour?: string | number | undefined; paymentBrand?: string | undefined; payment_brand?: string | undefined; PaymentBrand?: string | undefined; expirationMonth?: string | number | undefined; expiration_month?: string | number | undefined; ExpirationMonth?: string | number | undefined; expirationYear?: string | number | undefined; expiration_year?: string | number | undefined; ExpirationYear?: string | number | undefined; firstName?: string | undefined; first_name?: string | undefined; lastName?: string | undefined; last_name?: string | undefined; streetAddress1?: string | undefined; street_address1?: string | undefined; streetAddress2?: string | undefined; street_address2?: string | undefined; city?: string | undefined; zipCode?: string | undefined; zip_code?: string | undefined; country?: string | undefined; } | undefined; web?: { webShopperEmail?: string | undefined; webShopperId?: number | undefined; } | undefined; customer?: { customerId: number; contactId: number; billToName: string; billToAddress1: string; billToCity: string; billToState: string; billToZip: string; billToCountry: string; shipToName: string; shipToAddress1: string; shipToCity: string; shipToState: string; shipToZip: string; shipToCountry: string; } | undefined; payment?: { paymentType: string; cardNumber: string; expirationDate: string; cvv: string; cardHolderName: string; } | undefined; shipping?: { shippingMethod: string; shippingInstructions?: string | undefined; } | undefined; lineItems?: { invMastUid: number; quantity: number; unitOfMeasure: string; unitPrice: number; }[] | undefined; }) => Promise<{ params: Record<string, unknown> | unknown[]; data: { body: string | Record<string, unknown>; checkoutUid: number; checkoutUuid: string; statusCd?: number | undefined; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Get checkout details by ID * @description Retrieves complete details for a specific checkout including all order data * @param checkoutUid Checkout unique identifier * @returns Complete checkout details with order data and processing status * @throws ValidationError When response is malformed * @example * ```typescript * const checkout = await client.checkout.get(12345); * console.log('Checkout:', checkout.checkoutUid, 'Status:', checkout.statusCd); * console.log('Created:', checkout.dateCreated, 'Type:', checkout.checkoutType); * ``` */ get: (id: string | number, params?: import("../../core/base-client").CacheParams | undefined) => Promise<{ params: Record<string, unknown> | unknown[]; data: { dateCreated: string; dateLastModified: string; statusCd: number; cartHdrUid: number; checkoutUid: number; checkoutUuid: string; body?: unknown; checkoutType?: string | undefined; properties?: string | undefined; checkoutProcessor?: string | undefined; jsonData?: string | undefined; sourceName?: string | undefined; sourceId?: string | undefined; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Get formatted checkout document * @description Retrieves the formatted checkout document/receipt for display or printing * @param checkoutUid Checkout unique identifier * @param params Optional parameters including associated cart header UID * @returns Raw checkout document response * @throws ValidationError When response is malformed * @example * ```typescript * const doc = await client.checkout.getDoc(12345, { cartHdrUid: 789 }); * // Process or display the formatted document * ``` */ getDoc: (checkoutUid: number, params?: CheckoutDocParams) => Promise<unknown>; /** * Validate checkout data * @description Validates checkout data without processing payment or creating orders in Prophet21 * @param checkoutUid Checkout unique identifier * @returns Validation results with status, errors, and warnings * @throws ValidationError When response is malformed * @example * ```typescript * const validation = await client.checkout.validate(12345); * if (validation.data.validationResults?.isValid) { * console.log('Checkout is valid and ready for activation'); * } else { * console.log('Validation errors:', validation.data.validationResults?.errors); * } * ``` */ validate: (id: string | number) => Promise<{ params: Record<string, unknown> | unknown[]; data: { statusCd: number; checkoutUid: number; checkoutUuid: string; validationResults?: { errors: string[]; isValid: boolean; warnings: string[]; } | undefined; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Activate and process checkout * @description Activates the checkout, processes payment, and creates orders in Prophet21 ERP system * @param checkoutUid Checkout unique identifier * @returns Activated checkout details with updated status * @throws ValidationError When response is malformed * @example * ```typescript * const result = await client.checkout.activate(12345); * if (result.data.statusCd === 710) { * console.log('Checkout successfully activated and processed'); * } * ``` */ activate: (id: string | number) => Promise<{ params: Record<string, unknown> | unknown[]; data: { statusCd: number; checkoutUid: number; checkoutUuid: string; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Create Prophet21 checkout header * @description Creates Prophet21-specific checkout header for ERP integration (partially implemented) * @param checkoutUid Checkout unique identifier * @returns Prophet21 header creation result * @throws ValidationError When response is malformed * @example * ```typescript * const p21Header = await client.checkout.createProphet21Hdr(12345); * // Note: This endpoint is partially implemented * ``` */ createProphet21Hdr: (id: string | number) => Promise<{ params: Record<string, unknown> | unknown[]; data: { checkoutUid: number; } & { [k: string]: unknown; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Add Prophet21 checkout lines * @description Adds line items to Prophet21 checkout header (in early development) * @param checkoutUid Checkout unique identifier * @param prophet21HdrUid Prophet21 header unique identifier * @returns Prophet21 line creation result * @throws ValidationError When response is malformed * @example * ```typescript * const p21Lines = await client.checkout.addProphet21Lines(12345, 67890); * // Note: This endpoint is in early development * ``` */ addProphet21Lines: (checkoutUid: number, prophet21HdrUid: number) => Promise<unknown>; /** * Create checkout (data only) * @description Returns only the data from checkout creation response * @param orderData Complete checkout data * @returns Created checkout details (data only) * @throws ValidationError When request is invalid or response is malformed */ createData: (orderData: CheckoutCreateRequest) => Promise<{ body: string | Record<string, unknown>; checkoutUid: number; checkoutUuid: string; statusCd?: number | undefined; }>; /** * Get checkout details (data only) * @description Returns only the data from checkout details response * @param checkoutUid Checkout unique identifier * @returns Checkout details (data only) * @throws ValidationError When response is malformed */ getData: (checkoutUid: number) => Promise<{ dateCreated: string; dateLastModified: string; statusCd: number; cartHdrUid: number; checkoutUid: number; checkoutUuid: string; body?: unknown; checkoutType?: string | undefined; properties?: string | undefined; checkoutProcessor?: string | undefined; jsonData?: string | undefined; sourceName?: string | undefined; sourceId?: string | undefined; }>; /** * Get checkout document (data only) * @description Returns the checkout document directly * @param checkoutUid Checkout unique identifier * @param params Optional parameters * @returns Checkout document (data only) * @throws ValidationError When response is malformed */ getDocData: (checkoutUid: number, params?: CheckoutDocParams) => Promise<unknown>; /** * Validate checkout (data only) * @description Returns only the data from checkout validation response * @param checkoutUid Checkout unique identifier * @returns Validation results (data only) * @throws ValidationError When response is malformed */ validateData: (checkoutUid: number) => Promise<{ statusCd: number; checkoutUid: number; checkoutUuid: string; validationResults?: { errors: string[]; isValid: boolean; warnings: string[]; } | undefined; }>; /** * Activate checkout (data only) * @description Returns only the data from checkout activation response * @param checkoutUid Checkout unique identifier * @returns Activation results (data only) * @throws ValidationError When response is malformed */ activateData: (checkoutUid: number) => Promise<{ statusCd: number; checkoutUid: number; checkoutUuid: string; }>; /** * Create Prophet21 header (data only) * @description Returns only the data from Prophet21 header creation response * @param checkoutUid Checkout unique identifier * @returns Prophet21 header creation result (data only) * @throws ValidationError When response is malformed */ createProphet21HdrData: (checkoutUid: number) => Promise<{ checkoutUid: number; } & { [k: string]: unknown; }>; /** * Add Prophet21 lines (data only) * @description Returns the Prophet21 lines addition result directly * @param checkoutUid Checkout unique identifier * @param prophet21HdrUid Prophet21 header unique identifier * @returns Prophet21 lines addition result (data only) * @throws ValidationError When response is malformed */ addProphet21LinesData: (checkoutUid: number, prophet21HdrUid: number) => Promise<unknown>; }; /** * Check service health (no bearer token required) * @description Monitor service availability and site configuration without authentication overhead * @returns Health check response with site hash and ID for configuration verification * @throws ValidationError When response is malformed * @example * ```typescript * const health = await client.getHealthCheck(); * console.log('Service health:', health.status); * console.log('Site ID:', health.data.siteId); * console.log('Site Hash:', health.data.siteHash); * ``` */ getHealthCheck: () => Promise<{ params: Record<string, unknown> | unknown[]; data: { siteHash: string; siteId: string; }; options: Record<string, unknown> | unknown[]; status: number;