UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

95 lines 5.82 kB
import { BaseServiceClient } from '../../core/base-client'; import { createHealthCheckResource, createHealthCheckDataResource, createPingResource, createPingDataResource, createAddressResource, createAddressDataResource, createCashDrawerResource, createCashDrawerDataResource, createCompanyResource, createCompanyDataResource, createCodeP21Resource, createCodeP21DataResource, createLocationResource, createLocationDataResource, createPaymentTypesResource, createPaymentTypesDataResource, } from './resources'; import { AddressSchema, CashDrawerSchema, CompanySchema, P21CodeSchema, LocationSchema, PaymentTypeSchema, } from './schemas'; /** * P21 Core API Client * @description Client for interacting with P21 Core system API endpoints for address management, cash drawer operations, company data, location management, and payment processing within the Prophet 21 ERP system * @fullPath api.p21Core * @service p21-core * @domain enterprise-resource-planning * @discoverable true * @searchTerms ["p21-core", "prophet 21", "ERP", "addresses", "cash drawer", "company data", "locations", "payment types", "shipping methods", "business operations", "corporate addresses"] * @relatedEndpoints ["api.p21Core.address", "api.p21Core.cashDrawer", "api.p21Core.company", "api.p21Core.location", "api.p21Core.paymentTypes", "api.p21Core.codes"] * @commonPatterns ["ERP data management", "Address and shipping setup", "Cash drawer operations", "Company configuration", "Location management", "Payment processing setup"] * @workflow ["erp-setup", "address-management", "financial-operations", "location-configuration", "payment-processing"] * @prerequisites ["Valid P21 system access", "ERP authentication", "Company-specific permissions"] * @nextSteps ["api.commerce.cartHeaders for e-commerce integration", "api.orders for order processing", "api.pricing for pricing management"] * @businessRules ["Company-scoped data access", "Location-based permissions", "Cash drawer security controls", "Address validation for shipping"] * @functionalArea "enterprise-resource-planning" * @caching "Cache company and location data for 30 minutes, real-time for cash drawer operations" * @performance "Supports pagination for all list operations, optimized for ERP transaction volumes" * @example * ```typescript * import { HTTPClient } from '@augur/api-client/core'; * import { P21CoreClient } from '@augur/api-client/services/p21-core'; * * const client = new P21CoreClient(new HTTPClient({ baseURL: 'https://p21-core.augur-api.com' })); * * // List companies with pagination * const companies = await client.company.list({ limit: 20, offset: 0 }); * console.log(companies.data); // Company[] * * // Get company details * const company = await client.company.get({ companyUid: 123 }); * console.log(company.data); // Company * * // List addresses for shipping configuration * const addresses = await client.address.list({ carrierFlag: 'Y' }); * console.log(addresses.data); // Address[] * * // Get cash drawer status * const cashDrawers = await client.cashDrawer.list({ statusCd: 704 }); * ``` */ export class P21CoreClient extends BaseServiceClient { // Ensure schemas are referenced to avoid unused import warnings get schemaRefs() { return this._schemaRefs; } /** * Create a new P21CoreClient instance * @param http Configured HTTPClient instance with authentication * @param baseUrl Base URL for the P21 Core API (default: https://p21-core.augur-api.com) */ constructor(http, baseUrl = 'https://p21-core.augur-api.com') { super('p21-core', http, baseUrl); // Schema references for 100% coverage - ensuring all exports are imported this._schemaRefs = { AddressSchema, CashDrawerSchema, CompanySchema, P21CodeSchema, LocationSchema, PaymentTypeSchema, }; // Reference schemas to ensure 100% import coverage void this.schemaRefs; // Bind executeRequest for resource factories const boundExecuteRequest = (config, params, pathParams) => { if (params !== undefined || config.paramsSchema !== undefined) { return this.executeRequest(config, params, pathParams); } return this.executeRequest(config, undefined, pathParams); }; // Bind createListMethod for resources that need it const boundCreateListMethod = this.createListMethod.bind(this); // Initialize resources this.healthCheck = createHealthCheckResource(boundExecuteRequest); this.healthCheckData = createHealthCheckDataResource(this.healthCheck); this.ping = createPingResource(boundExecuteRequest); this.pingData = createPingDataResource(this.ping); this.address = createAddressResource(boundExecuteRequest, boundCreateListMethod); this.addressData = createAddressDataResource(this.address); this.cashDrawer = createCashDrawerResource(boundExecuteRequest, boundCreateListMethod); this.cashDrawerData = createCashDrawerDataResource(this.cashDrawer); this.company = createCompanyResource(boundExecuteRequest, boundCreateListMethod); this.companyData = createCompanyDataResource(this.company); this.codeP21 = createCodeP21Resource(boundCreateListMethod); this.codeP21Data = createCodeP21DataResource(this.codeP21); this.location = createLocationResource(boundExecuteRequest, boundCreateListMethod); this.locationData = createLocationDataResource(this.location); this.paymentTypes = createPaymentTypesResource(boundCreateListMethod); this.paymentTypesData = createPaymentTypesDataResource(this.paymentTypes); } } //# sourceMappingURL=client.js.map