@fabrix/spool-cart
Version:
Spool - eCommerce Spool for Fabrix
77 lines (76 loc) • 3.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const spool_email_1 = require("@fabrix/spool-email");
class Customer extends spool_email_1.Email {
invite(customer, data, options) {
const CustomerModel = this.app.models['Customer'];
let resCustomer;
return CustomerModel.resolve(customer, options)
.then(_customer => {
if (!_customer) {
throw new Error('Customer did not resolve');
}
resCustomer = _customer;
const subject = data.subject || `${resCustomer.name} Invitation`;
const sendEmail = typeof data.send_email !== 'undefined' ? data.send_email : true;
return this.compose('invite', subject, resCustomer, sendEmail);
});
}
inviteAccepted(customer, data, options) {
const CustomerModel = this.app.models['Customer'];
let resCustomer;
return CustomerModel.resolve(customer, options)
.then(_customer => {
if (!_customer) {
throw new Error('Customer did not resolve');
}
resCustomer = _customer;
const subject = data.subject || `${resCustomer.name} Invite Accepted`;
const sendEmail = typeof data.send_email !== 'undefined' ? data.send_email : true;
return this.compose('inviteAccepted', subject, resCustomer, sendEmail);
});
}
accountBalanceUpdated(customer, data, options) {
const CustomerModel = this.app.models['Customer'];
let resCustomer;
return CustomerModel.resolve(customer, options)
.then(_customer => {
if (!_customer) {
throw new Error('Customer did not resolve');
}
resCustomer = _customer;
const subject = data.subject || `${resCustomer.name} Account Balance Updated`;
const sendEmail = typeof data.send_email !== 'undefined' ? data.send_email : true;
return this.compose('accountBalanceUpdated', subject, resCustomer, sendEmail);
});
}
accountBalanceDeducted(customer, data, options) {
const CustomerModel = this.app.models['Custome'];
let resCustomer;
return CustomerModel.resolve(customer, options)
.then(_customer => {
if (!_customer) {
throw new Error('Customer did not resolve');
}
resCustomer = _customer;
const subject = data.subject || `${resCustomer.name} Account Balance Deducted`;
const sendEmail = typeof data.send_email !== 'undefined' ? data.send_email : true;
return this.compose('accountBalanceDeducted', subject, resCustomer, sendEmail);
});
}
retarget(customer, data, options) {
const CustomerModel = this.app.models['Customer'];
let resCustomer;
return CustomerModel.resolve(customer, options)
.then(_customer => {
if (!_customer) {
throw new Error('Customer did not resolve');
}
resCustomer = _customer;
const subject = data.subject || `${resCustomer.name} you have items in your cart!`;
const sendEmail = typeof data.send_email !== 'undefined' ? data.send_email : true;
return this.compose('retarget', subject, resCustomer, sendEmail);
});
}
}
exports.Customer = Customer;