@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
159 lines • 6.45 kB
JavaScript
import { CategoryLookupParamsSchema, CategoryResponseSchema, CategoryLookupResponseSchema, CategoryItemsResponseSchema, CategoryItemsParamsSchema, CategoryAttributesResponseSchema, CategoryImagesResponseSchema, } from '../schemas';
/**
* Creates the categories resource methods
* OpenAPI Path: /categories → categories.*
* @description Methods for managing categories
*/
export function createCategoriesResource(executeRequest) {
return {
/**
* OpenAPI Path: /categories/lookup → categories.lookup.get
* @description Lookup endpoint for categories
*/
lookup: {
/**
* Lookup categories
* @description Search for categories using lookup functionality
* @fullPath api.items.categories.lookup.get
* @service items
* @domain inventory-management
* @discoverable true
*/
get: async (params) => {
return executeRequest({
method: 'GET',
path: '/categories/lookup',
paramsSchema: CategoryLookupParamsSchema,
responseSchema: CategoryLookupResponseSchema,
}, params);
},
},
/**
* Get category details
* @description Retrieve comprehensive category information
* @fullPath api.items.categories.get
* @service items
* @domain inventory-management
* @discoverable true
*/
get: async (itemCategoryUid) => {
return executeRequest({
method: 'GET',
path: `/categories/${itemCategoryUid}`,
responseSchema: CategoryResponseSchema,
});
},
/**
* OpenAPI Path: /categories/{itemCategoryUid}/attributes → categories.attributes.list
* @description Nested path for category attributes
*/
attributes: {
/**
* List category attributes
* @description Get attributes associated with a category
* @fullPath api.items.categories.attributes.list
* @service items
* @domain inventory-management
* @discoverable true
*/
list: async (itemCategoryUid) => {
return executeRequest({
method: 'GET',
path: `/categories/${itemCategoryUid}/attributes`,
responseSchema: CategoryAttributesResponseSchema,
});
},
},
/**
* OpenAPI Path: /categories/{itemCategoryUid}/images → categories.images.list
* @description Nested path for category images
*/
images: {
/**
* List category images
* @description Get images associated with a category
* @fullPath api.items.categories.images.list
* @service items
* @domain inventory-management
* @discoverable true
*/
list: async (itemCategoryUid) => {
return executeRequest({
method: 'GET',
path: `/categories/${itemCategoryUid}/images`,
responseSchema: CategoryImagesResponseSchema,
});
},
},
/**
* OpenAPI Path: /categories/{itemCategoryUid}/items → categories.items.list
* @description Nested path for category items (plural)
*/
items: {
/**
* List category items
* @description List items in a category with filtering and search capabilities
* @fullPath api.items.categories.items.list
* @service items
* @domain inventory-management
* @discoverable true
* @dataMethod categoriesData.items.list
* @searchTerms ["category", "items", "products", "list", "filter"]
* @relatedEndpoints ["categories.get", "invMast.list", "categories.attributes.list"]
* @commonPatterns ["List items in category", "Filter category products", "Search category items"]
* @workflow ["inventory-management", "product-discovery"]
* @prerequisites ["Valid itemCategoryUid", "Bearer token", "x-site-id header", "Required q parameter"]
* @nextSteps ["Use item details for product display", "Apply filters for refinement"]
* @businessRules ["Returns array of items", "Requires q search parameter", "Supports pagination and filtering"]
* @functionalArea "inventory-management"
* @crossSite true
* @caching "Variable TTL based on cacheTtl parameter"
* @performance "Good - supports caching and filtering"
*/
list: async (itemCategoryUid, params) => {
return executeRequest({
method: 'GET',
path: `/categories/${itemCategoryUid}/items`,
paramsSchema: CategoryItemsParamsSchema,
responseSchema: CategoryItemsResponseSchema,
}, params);
},
},
};
}
/**
* Creates the categoriesData resource methods (data-only versions)
*/
export function createCategoriesDataResource(categories) {
return {
lookup: {
get: async (params) => {
const response = await categories.lookup.get(params);
return response.data;
},
},
get: async (itemCategoryUid) => {
const response = await categories.get(itemCategoryUid);
return response.data;
},
attributes: {
list: async (itemCategoryUid) => {
const response = await categories.attributes.list(itemCategoryUid);
return response.data;
},
},
images: {
list: async (itemCategoryUid) => {
const response = await categories.images.list(itemCategoryUid);
return response.data;
},
},
items: {
list: async (itemCategoryUid, params) => {
const response = await categories.items.list(itemCategoryUid, params);
return response.data;
},
},
};
}
//# sourceMappingURL=categories.js.map