"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.sendEmailWithSingleSendApi = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const lib_1 = require("../../lib");
const config_1 = require("./config");
exports.sendEmailWithSingleSendApi = {
    key: 'sendEmailWithSingleSendApi',
    category: extensions_core_1.Category.CUSTOMER_SUPPORT,
    title: 'Send email (Single Send API)',
    description: 'Send email with the Single Send API',
    fields: config_1.fields,
    previewable: true,
    dataPoints: config_1.dataPoints,
    onEvent: async ({ payload, onComplete, onError, helpers }) => {
        const { hubSpotSdk, fields, activity } = await (0, lib_1.validatePayloadAndCreateSdks)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await hubSpotSdk.marketing.transactional.singleSendApi.sendEmail({
            emailId: Number(fields.emailId),
            message: {
                _from: fields.from,
                to: fields.to,
                sendId: `awell_activity_${activity.id}`,
            },
            contactProperties: fields.contactProperties,
            customProperties: fields.customProperties,
        });
        await onComplete({
            data_points: {
                statusId: res.statusId,
            },
        });
    },
};
//# sourceMappingURL=sendEmailWithSingleSendApi.js.map