UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

313 lines 12.8 kB
import { BaseServiceClient } from '../../core/base-client'; import type { HTTPClient } from '../../core/client'; import type { BaseResponse } from '../../core/base-client'; import { PriceEngineParams, PriceEngineData, TaxEngineRequest, TaxEngineData, JobPriceLineListParams, JobPriceLine } from './schemas'; /** * Pricing API Client * @description Client for interacting with Pricing microservice API endpoints for pricing calculations, tax computation, and job-based pricing management * @example * ```typescript * import { HTTPClient } from '@augur/api-client/core'; * import { PricingClient } from '@augur/api-client/services/pricing'; * * const http = new HTTPClient('pricing', { siteId: 'your-site-id', bearerToken: 'your-token' }); * const pricing = new PricingClient(http); * * // Get item price * const price = await pricing.priceEngine.calculate({ customerId: 12345, itemId: 'ABC123', quantity: 10 }); * * // Calculate tax * const tax = await pricing.taxEngine.calculate({ * customer_id: 12345, * postal_code: '12345', * items: [{ item_id: 'ABC123', quantity: 2, unit_price: 25.99, extended_amount: 51.98 }], * ship_to_address: { street: '123 Main St', city: 'Anytown', state: 'NY', postal_code: '12345' } * }); * * // List job price headers * const jobHeaders = await pricing.jobPriceHdr.list({ limit: 25, q: 'contract' }); * ``` */ export declare class PricingClient extends BaseServiceClient { /** * Create a new PricingClient instance * @param http Configured HTTPClient instance * @param baseUrl Base URL for the Pricing API (default: https://pricing.augur-api.com) */ constructor(http: HTTPClient, baseUrl?: string); /** * Price engine operations * @description Pricing calculations and price determination */ priceEngine: { /** * Calculate item price using the price engine * @description Primary pricing endpoint for calculating item prices with sophisticated caching and compression * @param params Pricing parameters including customer ID, item ID, quantity, and other options * @returns Detailed pricing information including base price, unit price, discounts, and calculation details * @throws ValidationError When parameters are invalid or response is malformed * @example * ```typescript * const price = await client.priceEngine.calculate({ * customerId: 12345, * itemId: 'ABC123', * quantity: 10, * unitOfMeasure: 'EA', * shipToId: 456 * }); * * console.log('Unit Price:', price.unit_price); * console.log('Discount:', price.discount_percent); * console.log('Price Source:', price.price_source); * ``` */ calculate: (params: PriceEngineParams) => Promise<BaseResponse<PriceEngineData>>; }; /** * Tax engine operations * @description Tax calculations and jurisdiction-based tax determination */ taxEngine: { /** * Calculate tax using the tax engine * @description Tax calculation endpoint with postal code-based rate lookups and jurisdiction breakdowns * @param request Tax calculation request with customer, items, and shipping address information * @returns Detailed tax calculation with total tax, rates, and jurisdiction-specific breakdowns * @throws ValidationError When request is invalid or response is malformed * @example * ```typescript * const tax = await client.taxEngine.calculate({ * customer_id: 12345, * postal_code: '12345', * items: [ * { * item_id: 'ABC123', * quantity: 2, * unit_price: 25.99, * extended_amount: 51.98 * } * ], * ship_to_address: { * street: '123 Main St', * city: 'Anytown', * state: 'NY', * postal_code: '12345' * } * }); * * console.log('Total Tax:', tax.total_tax); * console.log('Tax Rate:', tax.tax_rate); * tax.jurisdictions.forEach(j => { * console.log(`${j.jurisdiction_name}: ${j.tax_rate}% = $${j.tax_amount}`); * }); * ``` */ calculate: (request: TaxEngineRequest) => Promise<BaseResponse<TaxEngineData>>; }; /** * Job Price Header endpoints * @description Methods for managing job-based pricing contracts and agreements */ jobPriceHdr: { /** * List job price headers with filtering and pagination * @description Retrieves job price headers with optional search, filtering, and pagination * @param params Optional filtering and pagination parameters * @returns Paginated list of job price headers with total count * @throws ValidationError When parameters are invalid or response is malformed * @example * ```typescript * // Get all job price headers * const headers = await client.jobPriceHeaders.list(); * * // Search and filter * const filtered = await client.jobPriceHeaders.list({ * q: 'contract', * limit: 25, * orderBy: 'job_no|ASC' * }); * * console.log(`Found ${filtered.total} job price headers`); * filtered.data.forEach(header => { * console.log(`${header.job_no}: ${header.job_description}`); * }); * ``` */ list: (params?: { edgeCache?: 3 | 2 | 4 | 1 | "1" | 5 | 8 | "2" | "3" | "4" | "5" | "8" | undefined; limit?: number | undefined; offset?: number | undefined; q?: string | undefined; orderBy?: string | undefined; } | undefined) => Promise<{ params: Record<string, unknown> | unknown[]; data: { approved: boolean; customer_id: number; job_price_hdr_uid: number; job_no: string; job_description: string; company_id: string; start_date: string; end_date: string; contract_no: string; cancelled: boolean; consignment_flag: boolean; date_created: string; date_last_modified: string; last_maintained_by: string; total_commitment?: number | undefined; }[]; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Get specific job price header details * @description Retrieves detailed information for a specific job price header * @param jobPriceHdrUid Job price header unique identifier * @returns Complete job price header details including contract information * @throws ValidationError When response is malformed * @example * ```typescript * const header = await client.jobPriceHeaders.get(12345); * console.log('Job:', header.job_no, header.job_description); * console.log('Customer:', header.customer_id); * console.log('Contract:', header.contract_no); * console.log('Period:', header.start_date, 'to', header.end_date); * ``` */ get: (id: string | number, params?: import("../../core/base-client").CacheParams | undefined) => Promise<{ params: Record<string, unknown> | unknown[]; data: { approved: boolean; customer_id: number; job_price_hdr_uid: number; job_no: string; job_description: string; company_id: string; start_date: string; end_date: string; contract_no: string; cancelled: boolean; consignment_flag: boolean; date_created: string; date_last_modified: string; last_maintained_by: string; total_commitment?: number | undefined; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; }; /** * Job Price Line endpoints * @description Methods for managing individual line items within job pricing contracts */ jobPriceLines: { /** * List job price lines for a specific header * @description Retrieves job price lines with optional filtering by status, inventory, and other criteria * @param jobPriceHdrUid Job price header unique identifier * @param params Optional filtering and pagination parameters * @returns Paginated list of job price lines with total count * @throws ValidationError When parameters are invalid or response is malformed * @example * ```typescript * // Get all lines for a job * const lines = await client.jobPriceLines.list(12345); * * // Filter by status and inventory * const activeLines = await client.jobPriceLines.list(12345, { * statusCd: 704, // Active * invMastUid: 11111, * limit: 50 * }); * * console.log(`Found ${activeLines.total} active lines`); * activeLines.data.forEach(line => { * console.log(`${line.item_id}: $${line.price} (${line.uom})`); * }); * ``` */ list: (jobPriceHdrUid: number, params?: JobPriceLineListParams) => Promise<BaseResponse<JobPriceLine[]>>; /** * Get specific job price line details * @description Retrieves detailed information for a specific job price line including pricing method and cost basis * @param jobPriceHdrUid Job price header unique identifier * @param jobPriceLineUid Job price line unique identifier * @returns Complete job price line details including extended pricing information * @throws ValidationError When response is malformed * @example * ```typescript * const line = await client.jobPriceLines.get(12345, 67890); * console.log('Item:', line.item_id, line.item_description); * console.log('Price:', line.price, line.uom); * console.log('Quantities - Ordered:', line.qty_ordered, 'Max:', line.qty_maximum); * console.log('Margins - Discount:', line.discount_percent, 'Margin:', line.margin_percent); * ``` */ get: (jobPriceHdrUid: number, jobPriceLineUid: number) => Promise<BaseResponse<JobPriceLine>>; }; /** * Simple connectivity test (no bearer token required) * @description Quick endpoint for testing basic connectivity without authentication * @returns Simple pong response for connectivity verification * @throws ValidationError When response is malformed * @example * ```typescript * const pong = await client.ping(); * console.log('Ping response:', pong); // "pong" * ``` */ ping: () => Promise<{ params: Record<string, unknown> | unknown[]; data: "pong"; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; getHealthCheck: () => Promise<{ params: Record<string, unknown> | unknown[]; data: { siteHash: string; siteId: string; }; options: Record<string, unknown> | unknown[]; status: number; message: string; count: number; total: number; totalResults: number; }>; /** * Health Data Operations * @description Direct access to health check data without response metadata */ healthData: { /** * Get health check data without response metadata * @returns Promise<unknown> Health status data directly */ check: () => Promise<{ siteHash: string; siteId: string; }>; /** * Get ping data without response metadata * @returns Promise<unknown> Ping response data directly */ ping: () => Promise<"pong">; }; } //# sourceMappingURL=client.d.ts.map