Skip to content
Snippets Groups Projects
Commit 4dd6db9c authored by Renzo Mauro Ontivero's avatar Renzo Mauro Ontivero
Browse files

Añadiendo envio de whatsapp Celo

parent 2172a25f
No related branches found
No related tags found
No related merge requests found
......@@ -61,6 +61,19 @@ module.exports = {
// 19. Print new balance
console.log(`Your new account balance: ${balance.toString()}`)
if(req.body.phone){
var notificacion = `Your transaction was successfully sent ! The hash is ${receipt.transactionHash}. Greetings team Celo`;
// Notifico por whatsapp
await sails.helpers.enviarWhatsapp.with({
texto: notificacion
numero: req.body.phone,
});
}
return res.json({
status: 'ok',
tx: receipt
......
const axios = require('axios');
const querystring = require('querystring'); // Luego modificar envíos por POST
module.exports = {
friendlyName: 'Enviar whatsapp',
description: '',
inputs: {
texto: {
type: 'string',
require : true
},
numero: {
type: 'string',
require: true
}
},
exits: {
success: {
description: 'All done.',
},
},
fn: async function (inputs) {
var data = querystring.stringify({
texto : inputs.texto,
telefono : inputs.telefono
});
const response = await axios.get('http://190.105.227.247/~umbot/api-whatsapp/?'+data)
.then((response) => {
return response;
})
.catch((err) => {
return {
status : 201,
statusText : String(err.message),
}
});
// Respuesta
if(response.status == 200 && response.statusText == 'OK'){
sails.log.info(
'Send whatsapp complete: \n'+
util.inspect(inputs,{depth:null})
);
return {
status : 'ok',
};
} else {
sails.log.info(
'Send whatsapp incomplete: \n'+
util.inspect(inputs,{depth:null})
);
return {
status : 'fail'
};
}
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment