"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PARDOT_API_VERSION = void 0;
exports.PARDOT_API_VERSION = 'v5';
class Pardot {
    constructor(businessUnitID, baseUrl, request) {
        this.upsertRecord = async (payload) => {
            const prospect = this.buildProspectJSON(payload);
            return this.request(`${this.baseUrl}/api/${exports.PARDOT_API_VERSION}/objects/prospects/do/upsertLatestByEmail`, {
                method: 'post',
                headers: {
                    'Content-Type': 'application/json'
                },
                json: {
                    matchEmail: payload.email,
                    prospect: prospect,
                    secondaryDeletedSearch: payload.secondaryDeletedSearch
                }
            });
        };
        this.ProspectsShape = (payload) => {
            return {
                email: payload.email,
                firstName: payload.firstName,
                lastName: payload.lastName,
                salutation: payload.salutation,
                phone: payload.phone,
                company: payload.company,
                jobTitle: payload.jobTitle,
                industry: payload.industry,
                city: payload.city,
                state: payload.state,
                zip: payload.zip,
                country: payload.country,
                website: payload.website
            };
        };
        this.buildProspectJSON = (payload) => {
            let baseShape = this.ProspectsShape(payload);
            if (payload.customFields) {
                baseShape = { ...baseShape, ...payload.customFields };
            }
            return baseShape;
        };
        this.businessUnitID = businessUnitID;
        this.baseUrl = baseUrl;
        this.request = request;
    }
}
exports.default = Pardot;
//# sourceMappingURL=pa-operations.js.map