salix/back/methods/mrw-config/getLabel.js

38 lines
925 B
JavaScript
Raw Normal View History

2024-06-10 10:24:23 +00:00
module.exports = Self => {
Self.remoteMethod('getLabel', {
description: 'Return a base64Binary label from de MRW WebService',
accessType: 'READ',
accepts: [{
arg: 'shipmentId',
2024-06-28 07:11:20 +00:00
type: 'string',
2024-06-10 10:24:23 +00:00
required: true
},
{
arg: 'clientType',
type: 'string',
required: true
},
],
2024-06-10 10:24:23 +00:00
returns: {
type: 'string',
root: true
},
http: {
path: `/getLabel`,
verb: 'GET'
}
});
Self.getLabel = async(shipmentId, clientType) => {
2024-06-10 10:24:23 +00:00
const mrw = await Self.getConfig();
const getLabelResponse = await Self.sendXmlDoc(
__dirname + `/getLabel.ejs`,
{mrw, shipmentId, clientType},
'text/xml'
);
2024-06-10 10:24:23 +00:00
return Self.getTextByTag(getLabelResponse, 'EtiquetaFile');
};
};