108 lines
2.8 KiB
JavaScript
108 lines
2.8 KiB
JavaScript
import { http } from './http.js';
|
|
|
|
export const posterminal = {
|
|
/**
|
|
* GET /api/posterminal → { posterminals: [{ id, name, token, pairingpin }] }
|
|
* List all terminals for the selected company.
|
|
*/
|
|
// #region GET /api/posterminal — list
|
|
list() {
|
|
return http('/api/posterminal');
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* PUT /api/posterminal
|
|
* Body: { name: string }
|
|
* Creates a new terminal (auto-generates 6-digit pin).
|
|
* → 200 { posterminal: { id, name, token, pairingpin } }
|
|
*/
|
|
// #region PUT /api/posterminal — create
|
|
create({ name }) {
|
|
return http('/api/posterminal', {
|
|
method: 'PUT',
|
|
body: { name },
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* PATCH /api/posterminal/:id
|
|
* Body: { name?: string, rootCategoryId?: number|null, syncRootArticles?: boolean, pairingpin?: string }
|
|
* Update posterminal configuration.
|
|
* → 200 { posterminal }
|
|
*/
|
|
// #region PATCH /api/posterminal/:id — update
|
|
update(terminalId, patch) {
|
|
return http(`/api/posterminal/${terminalId}`, {
|
|
method: 'PATCH',
|
|
body: patch,
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* DELETE /api/posterminal/:id → 204
|
|
* Deletes a terminal.
|
|
*/
|
|
// #region DELETE /api/posterminal/:id — delete
|
|
delete(terminalId) {
|
|
return http(`/api/posterminal/${terminalId}`, {
|
|
method: 'DELETE',
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* PUT /api/posterminal/:id/category/:categoryId
|
|
* Enable a category on a terminal.
|
|
* → 200 { id: number, categoryIds: number[] }
|
|
*/
|
|
// #region PUT /api/posterminal/:id/category/:categoryId — enableCategory
|
|
enableCategory(terminalId, categoryId) {
|
|
return http(`/api/posterminal/${terminalId}/category/${categoryId}`, {
|
|
method: 'PUT',
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* DELETE /api/posterminal/:id/category/:categoryId
|
|
* Disable a category on a terminal.
|
|
* → 200 { id: number, categoryIds: number[] }
|
|
*/
|
|
// #region DELETE /api/posterminal/:id/category/:categoryId — disableCategory
|
|
disableCategory(terminalId, categoryId) {
|
|
return http(`/api/posterminal/${terminalId}/category/${categoryId}`, {
|
|
method: 'DELETE',
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* PUT /api/posterminal/:id/all
|
|
* Enable all categories on a terminal.
|
|
* → 200 { id: number, categoryIds: number[] }
|
|
*/
|
|
// #region PUT /api/posterminal/:id/all — enableAllCategories
|
|
enableAllCategories(terminalId) {
|
|
return http(`/api/posterminal/${terminalId}/all`, {
|
|
method: 'PUT',
|
|
});
|
|
},
|
|
// #endregion
|
|
|
|
/**
|
|
* DELETE /api/posterminal/:id/all
|
|
* Disable all categories on a terminal.
|
|
* → 200 { id: number, categoryIds: number[] }
|
|
*/
|
|
// #region DELETE /api/posterminal/:id/all — disableAllCategories
|
|
disableAllCategories(terminalId) {
|
|
return http(`/api/posterminal/${terminalId}/all`, {
|
|
method: 'DELETE',
|
|
});
|
|
},
|
|
// #endregion
|
|
};
|