2018-09-29 21:57:25 +00:00
|
|
|
import * as plugins from './smartmail.plugins';
|
|
|
|
|
2019-10-26 21:45:35 +00:00
|
|
|
export interface ISmartmailOptions {
|
|
|
|
from: string;
|
|
|
|
subject: string;
|
|
|
|
body: string;
|
|
|
|
}
|
|
|
|
|
2018-09-29 21:57:25 +00:00
|
|
|
/**
|
|
|
|
* a standard representation for mails
|
|
|
|
*/
|
|
|
|
export class Smartmail {
|
2019-10-26 21:45:35 +00:00
|
|
|
public options: ISmartmailOptions;
|
|
|
|
public attachments: plugins.smartfile.Smartfile[];
|
|
|
|
|
|
|
|
constructor(optionsArg: ISmartmailOptions) {
|
|
|
|
this.options = optionsArg;
|
|
|
|
}
|
|
|
|
|
|
|
|
public addAttachment(smartfileArg: plugins.smartfile.Smartfile) {
|
|
|
|
this.attachments.push(smartfileArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getSubject(dataArg: any = {}) {
|
|
|
|
const smartmustache = new plugins.smartmustache.SmartMustache(this.options.subject);
|
|
|
|
return smartmustache.applyData(dataArg);
|
|
|
|
}
|
|
|
|
|
|
|
|
public getBody(dataArg: any = {}) {
|
|
|
|
const smartmustache = new plugins.smartmustache.SmartMustache(this.options.body);
|
|
|
|
return smartmustache.applyData(dataArg);
|
|
|
|
}
|
2018-09-29 21:57:25 +00:00
|
|
|
}
|