1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 22:19:26 +00:00

Make EmailBuilder fields private

This commit is contained in:
2022-02-14 20:53:46 +00:00
parent 1c680b076a
commit c85166a7a0

View File

@@ -26,48 +26,48 @@ class EmailBuilder {
* The subject of the email
* @type {string}
*/
subject;
#subject;
/**
* The plaintext body of the email
* @type {string}
*/
body;
#body;
/**
* The html body of the email
* @type {string}
*/
HTMLBody;
#HTMLBody;
/**
* The from address for the email
* @type {string}
*/
from = 'Stratos <contact@stratos.com>';
#from = 'Stratos <stratos@heliumdev.uk>';
/**
* The addresses to send to
* @type {Array<string>}
*/
to;
#to;
/**
* The addresses to carbon copy to
* @type {Array<string>}
*/
cc;
#cc;
/**
* The addresses to blind carbon copy to
* @type {Array<string>}
*/
bcc;
#bcc;
constructor() {
this.to = [];
this.cc = [];
this.bcc = [];
this.#to = [];
this.#cc = [];
this.#bcc = [];
}
/**
@@ -76,7 +76,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
setSubject(subject) {
this.subject = subject;
this.#subject = subject;
return this;
}
@@ -86,7 +86,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
setBody(body) {
this.body = body;
this.#body = body;
return this;
}
@@ -96,7 +96,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
setHTMLBody(HTMLBody) {
this.HTMLBody = HTMLBody;
this.#HTMLBody = HTMLBody;
return this;
}
@@ -106,7 +106,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
setFrom(from) {
this.from = from;
this.#from = from;
return this;
}
@@ -116,8 +116,8 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
addTo(addresses) {
const newAddresses = removeDupes(addresses, this.to);
this.to.push(...newAddresses);
const newAddresses = removeDupes(addresses, this.#to);
this.#to.push(...newAddresses);
return this;
}
@@ -127,7 +127,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
removeTo(addresses) {
this.to = removeDupes(this.to, addresses);
this.#to = removeDupes(this.#to, addresses);
return this;
}
@@ -137,8 +137,8 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
addCC(addresses) {
const newAddresses = removeDupes(addresses, this.to);
this.cc.push(...newAddresses);
const newAddresses = removeDupes(addresses, this.#to);
this.#cc.push(...newAddresses);
return this;
}
@@ -148,7 +148,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
removeCC(addresses) {
this.cc = removeDupes(this.cc, addresses);
this.#cc = removeDupes(this.#cc, addresses);
return this;
}
@@ -158,8 +158,8 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
addBCC(addresses) {
const newAddresses = removeDupes(addresses, this.to);
this.bcc.push(...newAddresses);
const newAddresses = removeDupes(addresses, this.#to);
this.#bcc.push(...newAddresses);
return this;
}
@@ -169,7 +169,7 @@ class EmailBuilder {
* @returns {EmailBuilder}
*/
removeBCC(addresses) {
this.bcc = removeDupes(this.bcc, addresses);
this.#bcc = removeDupes(this.#bcc, addresses);
return this;
}
}