Files
dashfront/src/api/labeltemplate.js
2026-10-10 18:17:14 +02:00

53 lines
1.6 KiB
JavaScript

import { http } from './http.js';
/**
* Company-scoped ZPL label templates (selectedCompanyId from session).
* Shape: LabelTemplate = { id, company_id, name, width, height, dpi, type, content, thumb }
*/
export const labeltemplate = {
/** GET /api/labeltemplate → { labeltemplates: LabelTemplate[] } */
// #region GET /api/labeltemplate — list
list() {
return http('/api/labeltemplate');
},
// #endregion
/** GET /api/labeltemplate/:id → { labeltemplate: LabelTemplate } */
// #region GET /api/labeltemplate/:id — get
get(id) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`);
},
// #endregion
/**
* POST /api/labeltemplate
* Body: { name, width, height, dpi, type, content }
* → 201 { labeltemplate: LabelTemplate }
*/
// #region POST /api/labeltemplate — create
create(body) {
return http('/api/labeltemplate', { method: 'POST', body });
},
// #endregion
/**
* PATCH /api/labeltemplate/:id
* Body: partial { name?, width?, height?, dpi?, type?, content? }
* → 200 { labeltemplate: LabelTemplate }
*/
// #region PATCH /api/labeltemplate/:id — update
update(id, body) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`, { method: 'PATCH', body });
},
// #endregion
/** DELETE /api/labeltemplate/:id → 204 */
// #region DELETE /api/labeltemplate/:id — delete
delete(id) {
return http(`/api/labeltemplate/${encodeURIComponent(id)}`, { method: 'DELETE' });
},
// #endregion
// thumb is returned inline as a base64 string in list/get responses
};