@simpleapps-com/augur-api
Version:
TypeScript client library for Augur microservices API endpoints
134 lines • 5.35 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSectionsResource = createSectionsResource;
exports.createSectionsDataResource = createSectionsDataResource;
const zod_1 = require("zod");
const schemas_1 = require("../schemas");
/**
* Creates the sections resource methods
* OpenAPI Path: /sections → sections.*
* @description Methods for managing warehouse organizational sections
*/
function createSectionsResource(executeRequest) {
return {
/**
* List sections with filtering
* @description Returns sections for a customer with optional status filtering and pagination
* @param params Filtering and pagination parameters (customerId is required)
* @returns Array of section objects
* @throws ValidationError When parameters are invalid or response is malformed
*/
list: async (params) => {
return executeRequest({
method: 'GET',
path: '/sections',
paramsSchema: schemas_1.SectionListParamsSchema,
responseSchema: schemas_1.SectionListResponseSchema,
}, params);
},
/**
* Get section details by ID
* @description Returns detailed information for a specific section
* @param sectionsUid Section unique identifier
* @returns Section details
* @throws ValidationError When response is malformed
*/
get: async (sectionsUid) => {
return executeRequest({
method: 'GET',
path: `/sections/${sectionsUid}`,
responseSchema: schemas_1.SectionResponseSchema,
}, undefined);
},
/**
* Create new section
* @description Creates a new organizational section for a customer
* @param request Section creation data
* @returns Created section information
* @throws ValidationError When request is invalid or response is malformed
*/
create: async (request) => {
return executeRequest({
method: 'POST',
path: '/sections',
paramsSchema: schemas_1.CreateSectionRequestSchema,
responseSchema: schemas_1.SectionResponseSchema,
}, request);
},
/**
* Update section information
* @description Updates section details with provided data
* @param sectionsUid Section unique identifier
* @param request Section update data
* @returns Updated section information
* @throws ValidationError When request is invalid or response is malformed
*/
update: async (sectionsUid, request) => {
return executeRequest({
method: 'PUT',
path: `/sections/${sectionsUid}`,
paramsSchema: schemas_1.UpdateSectionRequestSchema,
responseSchema: schemas_1.SectionResponseSchema,
}, request);
},
/**
* Soft delete a section
* @description Marks section as deleted without removing data
* @param sectionsUid Section unique identifier
* @returns Boolean indicating successful deletion
* @throws ValidationError When response is malformed
*/
delete: async (sectionsUid) => {
await executeRequest({
method: 'DELETE',
path: `/sections/${sectionsUid}`,
responseSchema: zod_1.z.unknown(),
});
return true;
},
/**
* Enable, disable, or delete a section
* @description Changes section status using status codes
* @param sectionsUid Section unique identifier
* @param request Status change request with new status code
* @returns Updated section information
* @throws ValidationError When request is invalid or response is malformed
*/
enable: async (sectionsUid, request) => {
return executeRequest({
method: 'PUT',
path: '/sections/{sectionsUid}/enable',
paramsSchema: schemas_1.EnableSectionRequestSchema,
responseSchema: schemas_1.SectionResponseSchema,
}, request, { sectionsUid: String(sectionsUid) });
},
};
}
/**
* Creates the sectionsData resource methods (data-only versions)
*/
function createSectionsDataResource(sections) {
return {
list: async (params) => {
const response = await sections.list(params);
return response.data;
},
get: async (sectionsUid) => {
const response = await sections.get(sectionsUid);
return response.data;
},
create: async (request) => {
const response = await sections.create(request);
return response.data;
},
update: async (sectionsUid, request) => {
const response = await sections.update(sectionsUid, request);
return response.data;
},
enable: async (sectionsUid, request) => {
const response = await sections.enable(sectionsUid, request);
return response.data;
},
};
}
//# sourceMappingURL=sections.js.map