bot-functions 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +39 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -547,6 +547,18 @@ const insertLog2 = async (params, codigo) => {
|
|
|
547
547
|
});
|
|
548
548
|
};
|
|
549
549
|
|
|
550
|
+
const insertLogExec = async (params, datoActual, datoAnterior) => {
|
|
551
|
+
return new Promise(async function (resolve) {
|
|
552
|
+
try {
|
|
553
|
+
const insertLogExecResponse = await axios.post(process.env.INSERT_LOG_EXEC, { datoActual, datoAnterior, params });
|
|
554
|
+
return resolve(insertLogExecResponse.data.data)
|
|
555
|
+
} catch (e) {
|
|
556
|
+
|
|
557
|
+
resolve();
|
|
558
|
+
}
|
|
559
|
+
});
|
|
560
|
+
};
|
|
561
|
+
|
|
550
562
|
const checkData = async (params) => {
|
|
551
563
|
return new Promise(async (resolve) => {
|
|
552
564
|
try {
|
|
@@ -870,6 +882,30 @@ const sendData2 = async (params, dataJSON) => {
|
|
|
870
882
|
});
|
|
871
883
|
}
|
|
872
884
|
|
|
885
|
+
const sendDataCH = async (params, dataJSON) => {
|
|
886
|
+
return new Promise(async function (resolve, reject) {
|
|
887
|
+
actualFunction = "sendDataCH";
|
|
888
|
+
try {
|
|
889
|
+
const batchPromises = [];
|
|
890
|
+
const stringData = JSON.stringify(dataJSON);
|
|
891
|
+
const response = await axios({
|
|
892
|
+
method: 'post', url: rocess.env.INSERT_CH, data: {jsonContent: stringData },
|
|
893
|
+
maxBodyLength: Infinity, headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
|
|
894
|
+
});
|
|
895
|
+
batchPromises.push(response.status);
|
|
896
|
+
batchPromises.map(reg => log.info('Insert status', reg));
|
|
897
|
+
if (batchPromises.every(reg => reg == 200)) {
|
|
898
|
+
resolve({ status: "Packages inserted successfully", exit: 1 });
|
|
899
|
+
} else {
|
|
900
|
+
return reject(new Error('No se insertaron todos los paquetes'));
|
|
901
|
+
}
|
|
902
|
+
} catch (error) {
|
|
903
|
+
await insertLog(params, 107);
|
|
904
|
+
return reject(new Error(error.message));
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
|
|
873
909
|
const waitFrame = (page, frame, framename, info, timeout, parent = null) => {
|
|
874
910
|
return new Promise(async function (resolve, reject) {
|
|
875
911
|
let counter = 0;
|
|
@@ -1371,5 +1407,7 @@ module.exports = {
|
|
|
1371
1407
|
diferenciaHoras,
|
|
1372
1408
|
lastDateSales,
|
|
1373
1409
|
EmailManager,
|
|
1374
|
-
manageEmails
|
|
1410
|
+
manageEmails,
|
|
1411
|
+
insertLogExec,
|
|
1412
|
+
sendDataCH
|
|
1375
1413
|
}
|