"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getcontact = void 0;
const extensions_core_1 = require("@awell-health/extensions-core");
const lib_1 = require("../../lib");
const config_1 = require("./config");
exports.getcontact = {
    key: 'getcontact',
    category: extensions_core_1.Category.CUSTOMER_SUPPORT,
    title: 'Get contact',
    description: 'Retrieve the contact details from HubSpot',
    fields: config_1.fields,
    previewable: true,
    dataPoints: config_1.dataPoints,
    onEvent: async ({ payload, onComplete, onError, helpers }) => {
        var _a, _b, _c;
        const { hubSpotSdk, fields } = await (0, lib_1.validatePayloadAndCreateSdks)({
            fieldsSchema: config_1.FieldsValidationSchema,
            payload,
        });
        const res = await hubSpotSdk.crm.contacts.basicApi.getById(fields.contactId);
        await onComplete({
            data_points: {
                firstName: (_a = res.properties.firstname) !== null && _a !== void 0 ? _a : undefined,
                lastName: (_b = res.properties.lastname) !== null && _b !== void 0 ? _b : undefined,
                email: (_c = res.properties.email) !== null && _c !== void 0 ? _c : undefined,
            },
        });
    },
};
//# sourceMappingURL=getContact.js.map