@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
64 lines • 3.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.VMIClient = void 0;
const base_client_1 = require("../../core/base-client");
const resources_1 = require("./resources");
/**
* VMI (Vendor Managed Inventory) API Client
* @description Client for interacting with VMI microservice API endpoints for warehouse and inventory management
* @example
* ```typescript
* import { HTTPClient } from '@augur/api-client/core';
* import { VMIClient } from '@augur/api-client/services/vmi';
*
* const http = new HTTPClient('vmi', { siteId: 'your-site-id', bearerToken: 'your-token' });
* const vmi = new VMIClient(http);
*
* // List warehouses
* const warehouses = await vmi.warehouse.list({ customerId: 12345 });
*
* // Check inventory availability
* const inventory = await vmi.warehouse.availability.get(123, { q: 'wire' });
* ```
*/
class VMIClient extends base_client_1.BaseServiceClient {
/**
* Create a new VMIClient instance
* @param http Configured HTTPClient instance
* @param baseUrl Base URL for the VMI API (default: https://vmi.augur-api.com)
*/
constructor(http, baseUrl = 'https://vmi.augur-api.com') {
super('vmi', http, baseUrl);
// Create a wrapper function that calls executeRequest dynamically
// This allows tests to spy on executeRequest after construction
// Pass params when defined OR when there's a paramsSchema (for validation)
// Note: Resources build URLs directly, so pathParams is not used
const boundExecuteRequest = (config, params, pathParams) => {
// Pass params if defined or if there's a paramsSchema (expects params)
if (params !== undefined || config.paramsSchema !== undefined) {
return this.executeRequest(config, params, pathParams);
}
return this.executeRequest(config, undefined, pathParams);
};
// Initialize standard API resources
this.healthCheck = (0, resources_1.createHealthCheckResource)(boundExecuteRequest);
this.ping = (0, resources_1.createPingResource)(boundExecuteRequest);
this.warehouse = (0, resources_1.createWarehouseResource)(boundExecuteRequest);
this.distributors = (0, resources_1.createDistributorsResource)(boundExecuteRequest);
this.products = (0, resources_1.createProductsResource)(boundExecuteRequest);
this.invProfileHdr = (0, resources_1.createInvProfileHdrResource)(boundExecuteRequest);
this.restockHdr = (0, resources_1.createRestockHdrResource)(boundExecuteRequest);
this.sections = (0, resources_1.createSectionsResource)(boundExecuteRequest);
// Initialize data-only API resources (dual API pattern)
this.healthCheckData = (0, resources_1.createHealthCheckDataResource)(this.healthCheck);
this.pingData = (0, resources_1.createPingDataResource)(this.ping);
this.warehouseData = (0, resources_1.createWarehouseDataResource)(this.warehouse);
this.distributorsData = (0, resources_1.createDistributorsDataResource)(this.distributors);
this.productsData = (0, resources_1.createProductsDataResource)(this.products);
this.invProfileHdrData = (0, resources_1.createInvProfileHdrDataResource)(this.invProfileHdr);
this.restockHdrData = (0, resources_1.createRestockHdrDataResource)(this.restockHdr);
this.sectionsData = (0, resources_1.createSectionsDataResource)(this.sections);
}
}
exports.VMIClient = VMIClient;
//# sourceMappingURL=client.js.map