@moreapp/common-nodejs 0.13.4 → 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/MailService.d.ts
CHANGED
|
@@ -12,14 +12,16 @@ export interface Attachment {
|
|
|
12
12
|
type MailSendResponse = {
|
|
13
13
|
id: string;
|
|
14
14
|
};
|
|
15
|
+
type LanguageCode = "nl" | "en" | "es" | "de" | "pt" | "fr" | "ca";
|
|
15
16
|
export declare class MailService {
|
|
16
17
|
readonly service: string;
|
|
17
18
|
readonly baseUrl: string;
|
|
18
19
|
readonly username: string;
|
|
19
20
|
readonly password: string;
|
|
20
21
|
constructor(service: string, baseUrl: string, username: string, password: string);
|
|
21
|
-
sendTemplatedMail(emailAddress: string, template: string, language:
|
|
22
|
+
sendTemplatedMail(emailAddress: string, template: string, language: LanguageCode, customerId?: number, variables?: Record<string, unknown>): Promise<MailSendResponse | undefined>;
|
|
22
23
|
sendRawMail(customerId: number, recipients: Recipient[], subject: string, body: string, attachments: Attachment[], fromName?: string, replyTo?: string, meta?: Record<string, unknown>): Promise<MailSendResponse | undefined>;
|
|
24
|
+
private toNotificationServiceLanguageCode;
|
|
23
25
|
private sendMail;
|
|
24
26
|
}
|
|
25
27
|
export {};
|
package/dist/MailService.js
CHANGED
|
@@ -34,7 +34,7 @@ class MailService {
|
|
|
34
34
|
type: "template",
|
|
35
35
|
template,
|
|
36
36
|
variables: variables ?? {},
|
|
37
|
-
language,
|
|
37
|
+
language: this.toNotificationServiceLanguageCode(language),
|
|
38
38
|
attachments: [],
|
|
39
39
|
},
|
|
40
40
|
});
|
|
@@ -54,6 +54,24 @@ class MailService {
|
|
|
54
54
|
meta,
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
toNotificationServiceLanguageCode(languageCode) {
|
|
58
|
+
switch (languageCode) {
|
|
59
|
+
case "nl":
|
|
60
|
+
return "nl-NL";
|
|
61
|
+
case "en":
|
|
62
|
+
return "en-GB";
|
|
63
|
+
case "es":
|
|
64
|
+
return "es-ES";
|
|
65
|
+
case "de":
|
|
66
|
+
return "de-DE";
|
|
67
|
+
case "pt":
|
|
68
|
+
return "pt-PT";
|
|
69
|
+
case "fr":
|
|
70
|
+
return "fr-FR";
|
|
71
|
+
case "ca":
|
|
72
|
+
return "ca";
|
|
73
|
+
}
|
|
74
|
+
}
|
|
57
75
|
async sendMail(mailRequest) {
|
|
58
76
|
if ((0, lodash_1.isEmpty)(mailRequest.recipients)) {
|
|
59
77
|
logger_1.logger.info("No recipients, not sending mail");
|
|
@@ -110,7 +110,7 @@ const newService = () => new MailService_1.MailService("some-service-name", base
|
|
|
110
110
|
content: {
|
|
111
111
|
type: "template",
|
|
112
112
|
template: "welcome",
|
|
113
|
-
language: "en",
|
|
113
|
+
language: "en-GB",
|
|
114
114
|
variables: { firstName: "Someone" },
|
|
115
115
|
attachments: [],
|
|
116
116
|
},
|
|
@@ -134,7 +134,7 @@ const newService = () => new MailService_1.MailService("some-service-name", base
|
|
|
134
134
|
content: {
|
|
135
135
|
type: "template",
|
|
136
136
|
template: "welcome",
|
|
137
|
-
language: "en",
|
|
137
|
+
language: "en-GB",
|
|
138
138
|
variables: {},
|
|
139
139
|
attachments: [],
|
|
140
140
|
},
|