UNPKG

@simpleapps-com/augur-api

Version:

TypeScript client library for Augur microservices API endpoints

130 lines 5.21 kB
import { z } from 'zod'; import { SectionListParamsSchema, SectionListResponseSchema, SectionResponseSchema, CreateSectionRequestSchema, UpdateSectionRequestSchema, EnableSectionRequestSchema, } from '../schemas'; /** * Creates the sections resource methods * OpenAPI Path: /sections → sections.* * @description Methods for managing warehouse organizational sections */ export 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: SectionListParamsSchema, responseSchema: 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: 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: CreateSectionRequestSchema, responseSchema: 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: UpdateSectionRequestSchema, responseSchema: 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: 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: EnableSectionRequestSchema, responseSchema: SectionResponseSchema, }, request, { sectionsUid: String(sectionsUid) }); }, }; } /** * Creates the sectionsData resource methods (data-only versions) */ export 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