@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
92 lines • 5.79 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemsClient = void 0;
const base_client_1 = require("../../core/base-client");
const resources_1 = require("./resources");
/**
* Items service client implementing OpenAPI Path Mirroring Pattern
*
* **CRITICAL**: All client structures follow exact OpenAPI path segments
*
* This client provides access to the Items API with full type safety and validation.
* All endpoints are organized by their OpenAPI path structure.
*
* @example
* ```typescript
* const client = new ItemsClient(httpClient);
*
* // Standard method - returns full response with metadata
* const response = await client.invMast.list({ limit: 10 });
* console.log(response.data); // Array of items
* console.log(response.total); // Total count
*
* // Data method - returns just the data
* const items = await client.invMastData.list({ limit: 10 });
* console.log(items); // Array of items directly
* ```
*/
class ItemsClient extends base_client_1.BaseServiceClient {
/**
* Create a new ItemsClient instance
* @param http Configured HTTPClient instance
* @param baseUrl Base URL for the Items API (default: https://items.augur-api.com)
*/
constructor(http, baseUrl = 'https://items.augur-api.com') {
super('items', 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) => {
// Pass params if defined or if there's a paramsSchema (expects params)
if (params !== undefined || config.paramsSchema !== undefined) {
return this.executeRequest(config, params);
}
return this.executeRequest(config);
};
// Initialize standard API resources
this.attributeGroups = (0, resources_1.createAttributeGroupsResource)(boundExecuteRequest);
this.attributes = (0, resources_1.createAttributesResource)(boundExecuteRequest);
this.brands = (0, resources_1.createBrandsResource)(boundExecuteRequest);
this.categories = (0, resources_1.createCategoriesResource)(boundExecuteRequest);
this.contracts = (0, resources_1.createContractsResource)(boundExecuteRequest);
this.healthCheck = (0, resources_1.createHealthCheckResource)(boundExecuteRequest);
this.internal = (0, resources_1.createInternalResource)(boundExecuteRequest);
this.invMast = (0, resources_1.createInvMastResource)(boundExecuteRequest);
this.invMastLinks = (0, resources_1.createInvMastLinksResource)(boundExecuteRequest);
this.invMastSubParts = (0, resources_1.createInvMastSubPartsResource)(boundExecuteRequest);
this.itemCategory = (0, resources_1.createItemCategoryResource)(boundExecuteRequest);
this.itemFavorites = (0, resources_1.createItemFavoritesResource)(boundExecuteRequest);
this.itemUom = (0, resources_1.createItemUomResource)(boundExecuteRequest);
this.itemWishlist = (0, resources_1.createItemWishlistResource)(boundExecuteRequest);
this.locations = (0, resources_1.createLocationsResource)(boundExecuteRequest);
this.ping = (0, resources_1.createPingResource)(boundExecuteRequest);
this.variants = (0, resources_1.createVariantsResource)(boundExecuteRequest);
this.invLoc = (0, resources_1.createInvLocResource)(boundExecuteRequest);
this.invMastUd = (0, resources_1.createInvMastUdResource)(boundExecuteRequest);
this.p21 = (0, resources_1.createP21Resource)(boundExecuteRequest);
// Initialize data-only API resources (dual API pattern)
this.attributeGroupsData = (0, resources_1.createAttributeGroupsDataResource)(this.attributeGroups);
this.attributesData = (0, resources_1.createAttributesDataResource)(this.attributes);
this.brandsData = (0, resources_1.createBrandsDataResource)(this.brands);
this.categoriesData = (0, resources_1.createCategoriesDataResource)(this.categories);
this.contractsData = (0, resources_1.createContractsDataResource)(this.contracts);
this.healthCheckData = (0, resources_1.createHealthCheckDataResource)(this.healthCheck);
this.internalData = (0, resources_1.createInternalDataResource)(this.internal);
this.invMastData = (0, resources_1.createInvMastDataResource)(this.invMast);
this.invMastLinksData = (0, resources_1.createInvMastLinksDataResource)(this.invMastLinks);
this.invMastSubPartsData = (0, resources_1.createInvMastSubPartsDataResource)(this.invMastSubParts);
this.itemCategoryData = (0, resources_1.createItemCategoryDataResource)(this.itemCategory);
this.itemFavoritesData = (0, resources_1.createItemFavoritesDataResource)(this.itemFavorites);
this.itemUomData = (0, resources_1.createItemUomDataResource)(this.itemUom);
this.itemWishlistData = (0, resources_1.createItemWishlistDataResource)(this.itemWishlist);
this.locationsData = (0, resources_1.createLocationsDataResource)(this.locations);
this.pingData = (0, resources_1.createPingDataResource)(this.ping);
this.variantsData = (0, resources_1.createVariantsDataResource)(this.variants);
this.invLocData = (0, resources_1.createInvLocDataResource)(this.invLoc);
this.invMastUdData = (0, resources_1.createInvMastUdDataResource)(this.invMastUd);
this.p21Data = (0, resources_1.createP21DataResource)(this.p21);
}
}
exports.ItemsClient = ItemsClient;
//# sourceMappingURL=client.js.map