"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createContact = exports.updateContact = exports.getExistingContact = void 0;
const getExistingContact = async (hubSpotSdk, email) => {
    try {
        const includeArchived = false;
        return await hubSpotSdk.crm.contacts.basicApi.getById(email, undefined, undefined, undefined, includeArchived, 'email');
    }
    catch (err) {
        const typedError = err;
        if (typedError.code === 404) {
            return null; // Contact does not exist
        }
        throw typedError; // Other errors should propagate
    }
};
exports.getExistingContact = getExistingContact;
/**
 * Updates an existing contact in HubSpot.
 */
const updateContact = async (hubSpotSdk, contactId, properties) => {
    return await hubSpotSdk.crm.contacts.basicApi.update(contactId, {
        properties,
    });
};
exports.updateContact = updateContact;
/**
 * Creates a new contact in HubSpot.
 */
const createContact = async (hubSpotSdk, properties) => {
    return await hubSpotSdk.crm.contacts.basicApi.create({
        associations: [],
        properties,
    });
};
exports.createContact = createContact;
//# sourceMappingURL=helpers.js.map