"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendEmailWithSmtp = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const lib_1 = require("../../lib");
const config_1 = require("./config");
exports.sendEmailWithSmtp = {
    key: 'sendEmailWithSmtp',
    category: extensions_core_1.Category.CUSTOMER_SUPPORT,
    title: 'Send email (SMTP)',
    description: 'Send email with SMTP',
    fields: config_1.fields,
    previewable: false,
    dataPoints: config_1.dataPoints,
    onEvent: async ({ payload, onComplete, onError, helpers }) => {
        const { hubSpotSmtpSdk, fields } = await (0, lib_1.validatePayloadAndCreateSdks)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        if (hubSpotSmtpSdk === undefined)
            throw new Error('Could not instantiate SMTP client. Make sure the SMTP username and password are provided and valid.');
        await hubSpotSmtpSdk.sendEmail(fields);
        await onComplete();
    },
};
//# sourceMappingURL=sendEmailWithSmtp.js.map