@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
83 lines • 4.08 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LegacyClient = void 0;
const base_client_1 = require("../../core/base-client");
const resources_1 = require("./resources");
/**
* Legacy API Client
* @description Client for interacting with Legacy microservice API endpoints following OpenAPI Path Mirroring Pattern
* @fullPath api.legacy
* @service legacy
* @domain legacy-data-management
* @discoverable true
* @searchTerms ["legacy", "states", "inventory", "orders", "tags", "categories"]
* @relatedEndpoints ["items", "customers", "orders"]
* @commonPatterns ["CRUD operations", "state management", "inventory tagging"]
* @example
* ```typescript
* import { HTTPClient } from '@augur/api-client/core';
* import { LegacyClient } from '@augur/api-client/services/legacy';
*
* const http = new HTTPClient('legacy', { siteId: 'your-site-id', bearerToken: 'your-token' });
* const legacy = new LegacyClient(http);
*
* // Health check
* const health = await legacy.healthCheck.get();
*
* // Inventory operations
* const alsoBought = await legacy.invMast.alsoBought.list(12345);
* const tags = await legacy.invMast.tags.list(12345);
* const webDesc = await legacy.invMast.webDesc.list(12345);
*
* // State management
* const states = await legacy.legacy.state.list({ limit: 25, twoLetterCode: 'CA' });
*
* // Categories and orders
* const category = await legacy.itemCategory.get(67890);
* const resetResult = await legacy.orders.reset.get(98765);
* ```
*/
class LegacyClient extends base_client_1.BaseServiceClient {
/**
* Create a new LegacyClient instance
* @param http Configured HTTPClient instance
* @param baseUrl Base URL for the Legacy API (default: https://legacy.augur-api.com)
*/
constructor(http, baseUrl = 'https://legacy.augur-api.com') {
super('legacy', http, baseUrl);
// 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 helper methods for resources that need them
const boundCreateHealthCheckMethod = this.createHealthCheckMethod.bind(this);
const boundCreateListMethod = this.createListMethod.bind(this);
const boundCreateGetMethod = this.createGetMethod.bind(this);
const boundCreateCreateMethod = this.createCreateMethod.bind(this);
const boundCreateUpdateMethod = this.createUpdateMethod.bind(this);
const boundCreateDeleteMethod = this.createDeleteMethod.bind(this);
// Initialize resources
this.healthCheck = (0, resources_1.createHealthCheckResource)(boundCreateHealthCheckMethod);
this.healthCheckData = (0, resources_1.createHealthCheckDataResource)(this.healthCheck);
this.invMast = (0, resources_1.createInvMastResource)(boundExecuteRequest);
this.invMastData = (0, resources_1.createInvMastDataResource)(this.invMast);
this.itemCategory = (0, resources_1.createItemCategoryResource)(boundExecuteRequest);
this.itemCategoryData = (0, resources_1.createItemCategoryDataResource)(this.itemCategory);
this.orders = (0, resources_1.createOrdersResource)(boundExecuteRequest);
this.ordersData = (0, resources_1.createOrdersDataResource)(this.orders);
// State resource under legacy namespace
const stateResource = (0, resources_1.createStateResource)(boundCreateListMethod, boundCreateGetMethod, boundCreateCreateMethod, boundCreateUpdateMethod, boundCreateDeleteMethod);
const stateDataResource = (0, resources_1.createStateDataResource)(stateResource);
this.legacy = {
state: stateResource,
};
this.legacyData = {
state: stateDataResource,
};
}
}
exports.LegacyClient = LegacyClient;
//# sourceMappingURL=client.js.map