@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
228 lines • 8.51 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createBrandsResource = createBrandsResource;
exports.createBrandsDataResource = createBrandsDataResource;
const common_schemas_1 = require("../../../core/common-schemas");
const schemas_1 = require("../schemas");
/**
* Creates the brands resource methods
* OpenAPI Path: /brands → brands.*
* @description Methods for managing product brands
*/
function createBrandsResource(executeRequest) {
return {
/**
* List all brands
* @description Retrieve a paginated list of brands with filtering options
* @fullPath api.items.brands.list
* @service items
* @domain inventory-management
* @discoverable true
* @dataMethod brandsData.list
*/
list: async (params) => {
return executeRequest({
method: 'GET',
path: '/brands',
paramsSchema: schemas_1.BrandListParamsSchema,
responseSchema: schemas_1.BrandListResponseSchema,
}, params);
},
/**
* Create new brand
* @description Create a new brand
* @fullPath api.items.brands.create
* @service items
* @domain inventory-management
* @discoverable true
*/
create: async (data) => {
return executeRequest({
method: 'POST',
path: '/brands',
paramsSchema: schemas_1.CreateBrandRequestSchema,
responseSchema: schemas_1.BrandResponseSchema,
}, data);
},
/**
* Get brand by ID
* @description Retrieve specific brand details
* @fullPath api.items.brands.get
* @service items
* @domain inventory-management
* @discoverable true
*/
get: async (brandsUid) => {
return executeRequest({
method: 'GET',
path: `/brands/${brandsUid}`,
responseSchema: schemas_1.BrandResponseSchema,
});
},
/**
* Update brand
* @description Update existing brand
* @fullPath api.items.brands.update
* @service items
* @domain inventory-management
* @discoverable true
*/
update: async (brandsUid, data) => {
return executeRequest({
method: 'PUT',
path: `/brands/${brandsUid}`,
paramsSchema: schemas_1.UpdateBrandRequestSchema,
responseSchema: schemas_1.BrandResponseSchema,
}, data);
},
/**
* Delete brand
* @description Delete existing brand
* @fullPath api.items.brands.delete
* @service items
* @domain inventory-management
* @discoverable true
*/
delete: async (brandsUid) => {
return executeRequest({
method: 'DELETE',
path: `/brands/${brandsUid}`,
responseSchema: schemas_1.BrandResponseSchema,
});
},
/**
* OpenAPI Path: /brands/{brandsUid}/items → brands.items.*
* @description Nested path for managing items within brands
*/
items: {
/**
* List brand items
* @description List all items associated with a brand
* @fullPath api.items.brands.items.list
* @service items
* @domain inventory-management
* @discoverable true
*/
list: async (brandsUid, params) => {
return executeRequest({
method: 'GET',
path: `/brands/${brandsUid}/items`,
paramsSchema: common_schemas_1.StandardPaginationParamsSchema,
responseSchema: schemas_1.BrandItemListResponseSchema,
}, params);
},
/**
* Add item to brand
* @description Create association between item and brand
* @fullPath api.items.brands.items.create
* @service items
* @domain inventory-management
* @discoverable true
*/
create: async (brandsUid, data) => {
return executeRequest({
method: 'POST',
path: `/brands/${brandsUid}/items`,
paramsSchema: schemas_1.CreateBrandItemRequestSchema,
responseSchema: schemas_1.BrandItemResponseSchema,
}, data);
},
/**
* Get brand item association
* @description Get specific brand-item association details
* @fullPath api.items.brands.items.get
* @service items
* @domain inventory-management
* @discoverable true
*/
get: async (brandsUid, brandsXItemsUid) => {
return executeRequest({
method: 'GET',
path: `/brands/${brandsUid}/items/${brandsXItemsUid}`,
responseSchema: schemas_1.BrandItemResponseSchema,
});
},
/**
* Update brand item association
* @description Update existing brand-item association
* @fullPath api.items.brands.items.update
* @service items
* @domain inventory-management
* @discoverable true
*/
update: async (brandsUid, brandsXItemsUid, data) => {
return executeRequest({
method: 'PUT',
path: `/brands/${brandsUid}/items/${brandsXItemsUid}`,
paramsSchema: schemas_1.UpdateBrandItemRequestSchema,
responseSchema: schemas_1.BrandItemResponseSchema,
}, data);
},
/**
* Remove item from brand
* @description Delete brand-item association
* @fullPath api.items.brands.items.delete
* @service items
* @domain inventory-management
* @discoverable true
*/
delete: async (brandsUid, brandsXItemsUid) => {
return executeRequest({
method: 'DELETE',
path: `/brands/${brandsUid}/items/${brandsXItemsUid}`,
responseSchema: schemas_1.BrandItemResponseSchema,
});
},
},
};
}
/**
* Creates the brandsData resource methods (data-only versions)
*/
function createBrandsDataResource(brands) {
return {
list: async (params) => {
const response = await brands.list(params);
return response.data;
},
create: async (data) => {
const response = await brands.create(data);
return response.data;
},
get: async (brandsUid) => {
const response = await brands.get(brandsUid);
return response.data;
},
update: async (brandsUid, data) => {
const response = await brands.update(brandsUid, data);
return response.data;
},
delete: async (brandsUid) => {
const response = await brands.delete(brandsUid);
return response.data;
},
items: {
list: async (brandsUid, params) => {
const response = await brands.items.list(brandsUid, params);
return response.data;
},
create: async (brandsUid, data) => {
const response = await brands.items.create(brandsUid, data);
return response.data;
},
get: async (brandsUid, brandsXItemsUid) => {
const response = await brands.items.get(brandsUid, brandsXItemsUid);
return response.data;
},
update: async (brandsUid, brandsXItemsUid, data) => {
const response = await brands.items.update(brandsUid, brandsXItemsUid, data);
return response.data;
},
delete: async (brandsUid, brandsXItemsUid) => {
const response = await brands.items.delete(brandsUid, brandsXItemsUid);
return response.data;
},
},
};
}
//# sourceMappingURL=brands.js.map