@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
67 lines • 3.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CommerceClient = void 0;
const base_client_1 = require("../../core/base-client");
const resources_1 = require("./resources");
/**
* Commerce Service Client
* @description Client for interacting with Commerce API endpoints for e-commerce cart and checkout operations
* @fullPath api.commerce
* @service commerce
* @domain e-commerce
* @discoverable true
* @searchTerms ["commerce", "e-commerce", "shopping cart", "checkout", "cart management", "online store"]
* @relatedEndpoints ["api.commerce.cartHdr.list.get", "api.commerce.cartLine.get", "api.commerce.checkout.create", "api.avalara.rates.create"]
* @commonPatterns ["Shopping cart management", "E-commerce checkout", "Cart operations", "Payment processing"]
* @workflow ["shopping-cart", "checkout-process", "e-commerce-operations", "payment-processing"]
* @functionalArea "e-commerce-and-cart-management"
* @businessRules ["Requires valid bearer authentication", "Shopping cart session management", "Checkout processing", "ERP integration"]
* @performance "Optimized for e-commerce workflows and cart 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);
*
* // Check service health
* const health = await commerce.healthCheck.get();
* const healthData = await commerce.healthCheckData.get();
*
* // Create or lookup cart
* const cart = await commerce.cartHdr.lookup.get({ userId: 12345, customerId: 456, contactId: 123 });
*
* // Add items to cart
* await commerce.cartLine.add.create(cart.data.cartHdrUid, [{ invMastUid: 12345, quantity: 2, unitOfMeasure: 'EA' }]);
*
* // Create checkout
* const checkout = await commerce.checkout.create({ customer: {...}, payment: {...}, lineItems: [...] });
* ```
*/
class CommerceClient extends base_client_1.BaseServiceClient {
constructor(http, baseUrl) {
super('commerce', http, baseUrl || 'https://commerce.augur-api.com');
// 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);
};
// Initialize resources
this.healthCheck = (0, resources_1.createHealthCheckResource)(boundExecuteRequest);
this.healthCheckData = (0, resources_1.createHealthCheckDataResource)(this.healthCheck);
this.cartHdr = (0, resources_1.createCartHdrResource)(boundExecuteRequest);
this.cartHdrData = (0, resources_1.createCartHdrDataResource)(this.cartHdr);
this.cartLine = (0, resources_1.createCartLineResource)(boundExecuteRequest);
this.cartLineData = (0, resources_1.createCartLineDataResource)(this.cartLine);
this.checkout = (0, resources_1.createCheckoutResource)(boundExecuteRequest);
this.checkoutData = (0, resources_1.createCheckoutDataResource)(this.checkout);
}
getServiceDescription() {
return 'Commerce service for e-commerce cart and checkout operations with ERP integration';
}
}
exports.CommerceClient = CommerceClient;
//# sourceMappingURL=client.js.map