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
|
2024-07-10 08:41:52 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
arg: 'clientType',
|
|
|
|
type: 'string',
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
],
|
2024-06-10 10:24:23 +00:00
|
|
|
returns: {
|
|
|
|
type: 'string',
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
|
|
|
path: `/getLabel`,
|
|
|
|
verb: 'GET'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-07-10 08:41:52 +00:00
|
|
|
Self.getLabel = async(shipmentId, clientType) => {
|
2024-06-10 10:24:23 +00:00
|
|
|
const mrw = await Self.getConfig();
|
|
|
|
|
2024-07-10 08:41:52 +00:00
|
|
|
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');
|
|
|
|
};
|
|
|
|
};
|