feat: Retorno errores VIAEXPRESS refs #6682
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
08ca1a302b
commit
70f3b9292a
|
@ -20,14 +20,14 @@ module.exports = Self => {
|
|||
}
|
||||
});
|
||||
|
||||
Self.internationalExpedition = async (expeditionFk) => {
|
||||
Self.internationalExpedition = async expeditionFk => {
|
||||
const models = Self.app.models;
|
||||
|
||||
const viaexpressConfig = await models.ViaexpressConfig.findOne({
|
||||
fields: ['url']
|
||||
});
|
||||
|
||||
const renderedXml = await models.ViaexpressConfig.renderer(expeditionFk);
|
||||
|
||||
const response = await axios.post(`${viaexpressConfig.url}ServicioVxClientes.asmx`, renderedXml, {
|
||||
headers: {
|
||||
'Content-Type': 'application/soap+xml; charset=utf-8'
|
||||
|
@ -37,9 +37,12 @@ module.exports = Self => {
|
|||
const xmlString = response.data;
|
||||
const parser = new DOMParser();
|
||||
const xmlDoc = parser.parseFromString(xmlString, 'text/xml');
|
||||
const referenciaVxElement = xmlDoc.getElementsByTagName('ReferenciaVx')[0];
|
||||
const referenciaVx = referenciaVxElement.textContent;
|
||||
const {textContent} = xmlDoc.getElementsByTagName('Resultado')[0];
|
||||
|
||||
return referenciaVx;
|
||||
if (textContent === 'OK')
|
||||
return xmlDoc.getElementsByTagName('ReferenciaVx')[0].textContent;
|
||||
|
||||
const message = xmlDoc.getElementsByTagName('Mensaje')[0];
|
||||
throw new Error(textContent + ': ' + message.textContent);
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue