refs #5811 rename methods
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
c56588a472
commit
8ac3887d80
|
@ -2,7 +2,7 @@ const axios = require('axios');
|
|||
const {DOMParser} = require('xmldom');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteShipment', {
|
||||
Self.remoteMethod('deleteExpedition', {
|
||||
description: 'Delete a shipment by providing the expedition ID, interacting with Viaexpress API',
|
||||
accessType: 'WRITE',
|
||||
accepts: [{
|
||||
|
@ -15,19 +15,19 @@ module.exports = Self => {
|
|||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteShipment`,
|
||||
path: `/deleteExpedition`,
|
||||
verb: 'POST'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteShipment = async expeditionFk => {
|
||||
Self.deleteExpedition = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
fields: ['url']
|
||||
});
|
||||
|
||||
const renderedXml = await models.ViaexpressConfig.deleteShipmentRenderer(expeditionFk);
|
||||
const renderedXml = await models.ViaexpressConfig.deleteExpeditionRenderer(expeditionFk);
|
||||
const response = await axios.post(`${viaexpressConfig.url}ServicioVxClientes.asmx`, renderedXml, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
|||
const ejs = require('ejs');
|
||||
|
||||
module.exports = Self => {
|
||||
Self.remoteMethod('deleteShipmentRenderer', {
|
||||
Self.remoteMethod('deleteExpeditionRenderer', {
|
||||
description: 'Renders the data from an XML',
|
||||
accessType: 'READ',
|
||||
accepts: [{
|
||||
|
@ -15,12 +15,12 @@ module.exports = Self => {
|
|||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/deleteShipmentRenderer`,
|
||||
path: `/deleteExpeditionRenderer`,
|
||||
verb: 'GET'
|
||||
}
|
||||
});
|
||||
|
||||
Self.deleteShipmentRenderer = async expeditionFk => {
|
||||
Self.deleteExpeditionRenderer = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
|
@ -37,7 +37,7 @@ module.exports = Self => {
|
|||
externalId: expedition.externalId
|
||||
};
|
||||
|
||||
const template = fs.readFileSync(__dirname + '/deleteShipment.ejs', 'utf-8');
|
||||
const template = fs.readFileSync(__dirname + '/deleteExpedition.ejs', 'utf-8');
|
||||
const renderedXml = ejs.render(template, data);
|
||||
return renderedXml;
|
||||
};
|
|
@ -1,6 +1,6 @@
|
|||
module.exports = Self => {
|
||||
require('../methods/viaexpress-config/internationalExpedition')(Self);
|
||||
require('../methods/viaexpress-config/renderer')(Self);
|
||||
require('../methods/viaexpress-config/deleteShipment')(Self);
|
||||
require('../methods/viaexpress-config/deleteShipmentRenderer')(Self);
|
||||
require('../methods/viaexpress-config/deleteExpedition')(Self);
|
||||
require('../methods/viaexpress-config/deleteExpeditionRenderer')(Self);
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ module.exports = Self => {
|
|||
const {code} = expedition.agencyMode();
|
||||
|
||||
if (code && code.toLowerCase().substring(0, 10) == 'viaexpress') {
|
||||
const isDeleted = await models.ViaexpressConfig.deleteShipment(expeditionId);
|
||||
const isDeleted = await models.ViaexpressConfig.deleteExpedition(expeditionId);
|
||||
|
||||
if (isDeleted === 'true') {
|
||||
const deletedExpedition = await models.Expedition.destroyById(expeditionId);
|
||||
|
|
Loading…
Reference in New Issue