Envio plantilla sendinblue entrada online
This commit is contained in:
parent
73f8ed5de7
commit
46f2717507
@ -1,4 +1,6 @@
|
|||||||
const moment = require("moment");
|
const moment = require("moment");
|
||||||
|
const sendinblueHelper = require("./sendinblue.helper");
|
||||||
|
|
||||||
const mailjet_public = "c9cbd50d7f4afe487e56949f95cb28a0";
|
const mailjet_public = "c9cbd50d7f4afe487e56949f95cb28a0";
|
||||||
const mailjet_private = "f8b77ee8e7b1181d94f07905d90e18c6";
|
const mailjet_private = "f8b77ee8e7b1181d94f07905d90e18c6";
|
||||||
const mailjet_from_email = "info@loquedeverdadimporta.org";
|
const mailjet_from_email = "info@loquedeverdadimporta.org";
|
||||||
@ -125,16 +127,13 @@ function sendTicket(header, values) {
|
|||||||
},
|
},
|
||||||
],*/
|
],*/
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('sendTicket >>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<', header, body)
|
|
||||||
|
|
||||||
return send(header, body);
|
return send(header, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendTicketOnline(header, values) {
|
function sendTicketOnline(header, values) {
|
||||||
//console.log('>>>>>>>>>>>>>>>>>>><<VALUES ONLINE>>>', values);
|
//console.log('>>>>>>>>>>>>>>>>>>><<VALUES ONLINE>>>', values);
|
||||||
const body = {
|
const body = {
|
||||||
TemplateID: 3717629,
|
TemplateID: 177,
|
||||||
TemplateLanguage: true,
|
TemplateLanguage: true,
|
||||||
TemplateErrorDeliver: true,
|
TemplateErrorDeliver: true,
|
||||||
TemplateErrorReporting: {
|
TemplateErrorReporting: {
|
||||||
@ -147,15 +146,15 @@ function sendTicketOnline(header, values) {
|
|||||||
eventName: values.eventName,
|
eventName: values.eventName,
|
||||||
dateEvent: values.dateEvent,
|
dateEvent: values.dateEvent,
|
||||||
dateInscription: values.dateInscription,
|
dateInscription: values.dateInscription,
|
||||||
color: values.color ? values.color : "green",
|
color: values.color ? values.color : "gray",
|
||||||
nameInscription: header.name,
|
nameInscription: header.name,
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(body.Variables);
|
// console.log(body.Variables);
|
||||||
|
return sendinblueHelper.sendEmailTransactional(header, body);
|
||||||
return send(header, body);
|
// return send(header, body);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sendListaEspera(header, values) {
|
function sendListaEspera(header, values) {
|
||||||
|
|||||||
@ -7,6 +7,47 @@ const defaultClient = SibApiV3Sdk.ApiClient.instance;
|
|||||||
const apiKey = defaultClient.authentications['api-key'];
|
const apiKey = defaultClient.authentications['api-key'];
|
||||||
apiKey.apiKey = config.sendinblue.API_KEY;
|
apiKey.apiKey = config.sendinblue.API_KEY;
|
||||||
|
|
||||||
|
|
||||||
|
function sendEmailTransactional(header, body) {
|
||||||
|
|
||||||
|
if (header === undefined || header === null) {
|
||||||
|
throw new Error("Missing the required parameter 'header' when calling sendEmailTransactional");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body === undefined || body === null) {
|
||||||
|
throw new Error("Missing the required parameter 'body' when calling sendEmailTransactional");
|
||||||
|
}
|
||||||
|
|
||||||
|
let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
|
||||||
|
let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
|
||||||
|
|
||||||
|
sendSmtpEmail.templateId = body.TemplateID;
|
||||||
|
|
||||||
|
sendSmtpEmail.sender = { name: 'Fundación Lo Que De Verdad Importa', email: 'info@loquedeverdadimporta.org' };
|
||||||
|
sendSmtpEmail.to = [{ name: header.name, email: header.to }];
|
||||||
|
if (header.bcc) { sendSmtpEmail.bcc = [{ name: header.bccName, email: header.bcc }] };
|
||||||
|
sendSmtpEmail.subject = header.subject;
|
||||||
|
|
||||||
|
sendSmtpEmail.params = {
|
||||||
|
tipoEntrada: body.Variables.tipoEntrada,
|
||||||
|
color: body.Variables.color,
|
||||||
|
descripcionEntrada: body.Variables.descripcionEntrada,
|
||||||
|
eventName: body.Variables.eventName,
|
||||||
|
dateEvent: body.Variables.dateEvent,
|
||||||
|
nameInscription: body.Variables.nameInscription,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
apiInstance.sendTransacEmail(sendSmtpEmail).then(function (data) {
|
||||||
|
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
|
||||||
|
}, function (error) {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function _createMember(member) {
|
function _createMember(member) {
|
||||||
const api = new SibApiV3Sdk.ContactsApi();
|
const api = new SibApiV3Sdk.ContactsApi();
|
||||||
|
|
||||||
@ -56,13 +97,13 @@ function _addMemberToList(member, listId) {
|
|||||||
|
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
api.addContactToList(listId, contactEmails)
|
api.addContactToList(listId, contactEmails)
|
||||||
.then(function(data) {
|
.then(function (data) {
|
||||||
console.debug('API called successfully. Returned data: ' + data);
|
console.debug('API called successfully. Returned data: ' + data);
|
||||||
if ((data.contacts.success) && (data.contacts.success[0] === member.email)) {
|
if ((data.contacts.success) && (data.contacts.success[0] === member.email)) {
|
||||||
resolve(data.contacts.success[0])
|
resolve(data.contacts.success[0])
|
||||||
} else reject()
|
} else reject()
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(function (error) {
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -115,11 +156,11 @@ function getLists() {
|
|||||||
function addMember(listId, member) {
|
function addMember(listId, member) {
|
||||||
return new Promise(function (resolve, reject) {
|
return new Promise(function (resolve, reject) {
|
||||||
_createMember(member)
|
_createMember(member)
|
||||||
.then(function(contact) {
|
.then(function (contact) {
|
||||||
console.debug('añadir a lista: ' + listId + ' * ' + contact);
|
console.debug('añadir a lista: ' + listId + ' * ' + contact);
|
||||||
return _addMemberToList(contact, listId);
|
return _addMemberToList(contact, listId);
|
||||||
})
|
})
|
||||||
.then(function() {
|
.then(function () {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
@ -135,6 +176,7 @@ function deleteMember(listId, member) {
|
|||||||
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
sendEmailTransactional,
|
||||||
getLists,
|
getLists,
|
||||||
addMember,
|
addMember,
|
||||||
deleteMember,
|
deleteMember,
|
||||||
|
|||||||
@ -65,7 +65,7 @@
|
|||||||
"sanitize-filename": "^1.6.2",
|
"sanitize-filename": "^1.6.2",
|
||||||
"sequelize": "^5.16.0",
|
"sequelize": "^5.16.0",
|
||||||
"sharp": "^0.23.0",
|
"sharp": "^0.23.0",
|
||||||
"sib-api-v3-sdk": "^7.2.4",
|
"sib-api-v3-sdk": "^8.4.2",
|
||||||
"tinytim": "^0.1.1",
|
"tinytim": "^0.1.1",
|
||||||
"unique-file-name": "^1.0.0",
|
"unique-file-name": "^1.0.0",
|
||||||
"vimeo": "^2.1.1",
|
"vimeo": "^2.1.1",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user