@dibs-tech/mail-client
Advanced tools
Comparing version 1.7.1 to 1.8.0
38
index.js
@@ -7,2 +7,3 @@ const SparkPost = require('sparkpost'); | ||
const isURL = require('./helpers/validators/isURL'); | ||
const getPhoneNumberFromCurrency = require('./helpers/getDibsPhoneNumber'); | ||
@@ -184,5 +185,42 @@ require('./helpers/handlebars/classOrClasses')(handlebars); | ||
/** | ||
* | ||
* @param {Object} studio object to generate email data for | ||
* @param {string} emailType of email | ||
* @returns {Object} data object for email | ||
*/ | ||
MailClient.prototype.getEmailDataForStudio = function getEmailDataForStudio(studio, emailType) { | ||
const phone = { | ||
text: getPhoneNumberFromCurrency(studio.currency), | ||
href: getPhoneNumberFromCurrency(studio.currency, { href: true }), | ||
}; | ||
let template = `white-label/${emailType}`; | ||
if (studio.custom_email_template) { | ||
switch (emailType) { | ||
case 'confirmation': | ||
default: | ||
template = studio.custom_email_template.confirmation.link; | ||
} | ||
} | ||
const domain = studio.customSendingDomain || 'no-reply@ondibs.com'; | ||
const customEmailText = (studio.custom_email_text.find(cet => cet.template === emailType) && | ||
studio.custom_email_text.find(cet => cet.template === emailType).text) || ''; | ||
const purchasePlaceLink = studio.live && !studio.liveWidget ? 'https://www.ondibs.com/users' : `http://${studio.domain}?dibs_open`; | ||
return { | ||
studio, | ||
studioName: studio.name, | ||
template, | ||
customEmailText, | ||
domain, | ||
purchasePlaceLink, | ||
phone, | ||
}; | ||
}; | ||
MailClient.prototype.transactions = function transactions(subject, message, options, cb) { | ||
this.sendEmail('transactions@ondibs.com', subject, message, options, cb); | ||
}; | ||
/** | ||
@@ -189,0 +227,0 @@ * |
{ | ||
"name": "@dibs-tech/mail-client", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "A mail client implementation, using sparkpost", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14531
8
339
1