platformclient/ts/email/classes.emailconnector.ts

35 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-02-17 19:24:28 +00:00
import type { SzPlatformClient } from '../classes.platformclient.js';
import * as plugins from '../plugins.js';
import { logger } from '../logger.js';
2024-02-17 19:24:28 +00:00
export class SzEmailConnector {
public platformClientRef: SzPlatformClient;
constructor(platformClientRefArg: SzPlatformClient) {
this.platformClientRef = platformClientRefArg;
}
public async sendEmail(
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
) {
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
body:
${optionsArg.body.split('\n').map(line => ` ${line}`).join('\n')}
`);
}
const typedRequest =
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
'sendEmail'
);
const response = await typedRequest.fire(optionsArg);
2024-02-17 19:24:28 +00:00
}
public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
public async sendActionLink(optionsArg: { toArg: string; subject: string; text: string }) {}
}