2023-08-24 12:59:28 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
const ejs = require('ejs');
|
|
|
|
|
|
|
|
module.exports = Self => {
|
2023-11-24 09:53:38 +00:00
|
|
|
Self.remoteMethod('deleteExpeditionRenderer', {
|
2023-08-24 12:59:28 +00:00
|
|
|
description: 'Renders the data from an XML',
|
|
|
|
accessType: 'READ',
|
|
|
|
accepts: [{
|
|
|
|
arg: 'expeditionFk',
|
|
|
|
type: 'number',
|
|
|
|
required: true
|
|
|
|
}],
|
|
|
|
returns: {
|
|
|
|
type: ['object'],
|
|
|
|
root: true
|
|
|
|
},
|
|
|
|
http: {
|
2023-11-24 09:53:38 +00:00
|
|
|
path: `/deleteExpeditionRenderer`,
|
2023-08-24 12:59:28 +00:00
|
|
|
verb: 'GET'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2023-11-24 09:53:38 +00:00
|
|
|
Self.deleteExpeditionRenderer = async expeditionFk => {
|
2023-08-24 12:59:28 +00:00
|
|
|
const models = Self.app.models;
|
|
|
|
|
|
|
|
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
|
|
|
fields: ['client', 'user', 'password']
|
|
|
|
});
|
|
|
|
|
|
|
|
const expedition = await models.Expedition.findOne({
|
|
|
|
fields: ['id', 'externalId'],
|
|
|
|
where: {id: expeditionFk}
|
|
|
|
});
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
viaexpressConfig,
|
|
|
|
externalId: expedition.externalId
|
|
|
|
};
|
|
|
|
|
2023-11-24 09:53:38 +00:00
|
|
|
const template = fs.readFileSync(__dirname + '/deleteExpedition.ejs', 'utf-8');
|
2023-08-24 12:59:28 +00:00
|
|
|
const renderedXml = ejs.render(template, data);
|
|
|
|
return renderedXml;
|
|
|
|
};
|
|
|
|
};
|