71 lines
2.2 KiB
JavaScript
71 lines
2.2 KiB
JavaScript
import { http } from './http.js';
|
|
|
|
/**
|
|
* Outbound shipments (manifest type = shipment).
|
|
* Manifest number format: <orderNumber><shipmentPrefix><index>, e.g. AU-1001-L-1.
|
|
*/
|
|
export const shipment = {
|
|
// #region GET /api/shipment — list
|
|
list(params = {}) {
|
|
const q = new URLSearchParams();
|
|
if (params.offset) q.set('offset', String(params.offset));
|
|
if (params.limit != null) q.set('limit', String(params.limit));
|
|
if (params.search) q.set('search', String(params.search));
|
|
if (params.state) q.set('state', String(params.state));
|
|
if (params.orderId != null) q.set('orderId', String(params.orderId));
|
|
if (params.entityId != null) q.set('entityId', String(params.entityId));
|
|
if (params.seekMonths != null) q.set('seekMonths', String(params.seekMonths));
|
|
const qs = q.toString();
|
|
return http(`/api/shipment${qs ? `?${qs}` : ''}`);
|
|
},
|
|
// #endregion
|
|
|
|
// #region PATCH /api/shipment/:id — update
|
|
update(id, body) {
|
|
return http(`/api/shipment/${id}`, { method: 'PATCH', body });
|
|
},
|
|
// #endregion
|
|
|
|
// #region GET /api/order/:id/shipment — listByOrder
|
|
listByOrder(orderId) {
|
|
return http(`/api/order/${orderId}/shipment`);
|
|
},
|
|
// #endregion
|
|
|
|
// #region POST /api/order/:id/shipment — create
|
|
create(orderId, body) {
|
|
return http(`/api/order/${orderId}/shipment`, { method: 'POST', body });
|
|
},
|
|
// #endregion
|
|
|
|
// #region GET /api/shipment/:id — get
|
|
get(id) {
|
|
return http(`/api/shipment/${id}`);
|
|
},
|
|
// #endregion
|
|
|
|
// #region DELETE /api/shipment/:id — delete
|
|
delete(id) {
|
|
return http(`/api/shipment/${id}`, { method: 'DELETE' });
|
|
},
|
|
// #endregion
|
|
|
|
// #region DELETE /api/shipment/:id/file/:fileId — deleteFile
|
|
deleteFile(id, fileId) {
|
|
return http(`/api/shipment/${id}/file/${fileId}`, { method: 'DELETE' });
|
|
},
|
|
// #endregion
|
|
|
|
// #region POST /api/shipment/:id/pdf — createPdf
|
|
createPdf(id) {
|
|
return http(`/api/shipment/${id}/pdf`, { method: 'POST' });
|
|
},
|
|
// #endregion
|
|
|
|
// #region GET /api/shipment/:id/file/:fileId — getFileUrl
|
|
getFileUrl(id, fileId) {
|
|
return `/api/shipment/${encodeURIComponent(id)}/file/${encodeURIComponent(fileId)}`;
|
|
},
|
|
// #endregion
|
|
};
|