@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
63 lines • 3.45 kB
JavaScript
import { BaseServiceClient } from '../../core/base-client';
import { createHealthCheckResource, createHealthCheckDataResource, createCartHdrResource, createCartHdrDataResource, createCartLineResource, createCartLineDataResource, createCheckoutResource, createCheckoutDataResource, } from './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: [...] });
* ```
*/
export class CommerceClient extends 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 = createHealthCheckResource(boundExecuteRequest);
this.healthCheckData = createHealthCheckDataResource(this.healthCheck);
this.cartHdr = createCartHdrResource(boundExecuteRequest);
this.cartHdrData = createCartHdrDataResource(this.cartHdr);
this.cartLine = createCartLineResource(boundExecuteRequest);
this.cartLineData = createCartLineDataResource(this.cartLine);
this.checkout = createCheckoutResource(boundExecuteRequest);
this.checkoutData = createCheckoutDataResource(this.checkout);
}
getServiceDescription() {
return 'Commerce service for e-commerce cart and checkout operations with ERP integration';
}
}
//# sourceMappingURL=client.js.map