import { z } from "zod";
import type { CalendarEvent, CalEventResponses } from "@calcom/types/Calendar";
import type { CredentialPayload } from "@calcom/types/Credential";
import type { CRM, Contact, CrmEvent } from "@calcom/types/CrmService";
import type { writeToRecordDataSchema, appDataSchema } from "../zod";
import { SalesforceRecordEnum, SalesforceFieldType, WhenToWriteToRecord, RoutingReasons } from "./enums";
type Attendee = {
    email: string;
    name: string;
};
export default class SalesforceCRMService implements CRM {
    private integrationName;
    private conn;
    private log;
    private calWarnings;
    private appOptions;
    private doNotCreateEvent;
    private fallbackToContact;
    private accessToken;
    private instanceUrl;
    constructor(credential: CredentialPayload, appOptions: z.infer<typeof appDataSchema>, testMode?: boolean);
    getAppOptions(): {
        enabled?: boolean | undefined;
        credentialId?: number | undefined;
        appCategories?: string[] | undefined;
        roundRobinLeadSkip?: boolean | undefined;
        roundRobinSkipCheckRecordOn?: SalesforceRecordEnum | undefined;
        ifFreeEmailDomainSkipOwnerCheck?: boolean | undefined;
        roundRobinSkipFallbackToLeadOwner?: boolean | undefined;
        skipContactCreation?: boolean | undefined;
        createEventOn?: SalesforceRecordEnum | undefined;
        createNewContactUnderAccount?: boolean | undefined;
        createLeadIfAccountNull?: boolean | undefined;
        onBookingWriteToEventObject?: boolean | undefined;
        onBookingWriteToEventObjectMap?: Record<string, any> | undefined;
        createEventOnLeadCheckForContact?: boolean | undefined;
        onBookingChangeRecordOwner?: boolean | undefined;
        onBookingChangeRecordOwnerName?: string | undefined;
        sendNoShowAttendeeData?: boolean | undefined;
        sendNoShowAttendeeDataField?: string | undefined;
        onBookingWriteToRecord?: boolean | undefined;
        onBookingWriteToRecordFields?: Record<string, {
            value: string | boolean;
            fieldType: SalesforceFieldType;
            whenToWrite: WhenToWriteToRecord;
        }> | undefined;
        ignoreGuests?: boolean | undefined;
        onCancelWriteToEventRecord?: boolean | undefined;
        onCancelWriteToEventRecordFields?: Record<string, {
            value: string | boolean;
            fieldType: SalesforceFieldType;
            whenToWrite: WhenToWriteToRecord;
        }> | undefined;
    };
    private getClient;
    private getSalesforceUserIdFromEmail;
    private getSalesforceUserFromUserId;
    private getSalesforceEventBody;
    private salesforceCreateEventApiCall;
    private salesforceCreateEvent;
    private salesforceUpdateEvent;
    private salesforceDeleteEvent;
    handleEventCreation(event: CalendarEvent, contacts: Contact[]): Promise<{
        uid: string;
        id: string;
        type: string;
        password: string;
        url: string;
        additionalInfo: {
            contacts: Contact[];
            sfEvent: {
                success: true;
                id: string;
                errors: never[];
            };
            calWarnings: string[];
        };
    }>;
    createEvent(event: CalendarEvent, contacts: Contact[]): Promise<CrmEvent | undefined>;
    updateEvent(uid: string, event: CalendarEvent): Promise<CrmEvent>;
    deleteEvent(uid: string, event: CalendarEvent): Promise<void>;
    getContacts({ emails, includeOwner, forRoundRobinSkip, }: {
        emails: string | string[];
        includeOwner?: boolean;
        forRoundRobinSkip?: boolean;
    }): Promise<Contact[] | {
        ownerId?: string | undefined;
        ownerEmail?: any;
        id: any;
        email: string;
        recordType: any;
    }[]>;
    createContacts(contactsToCreate: Attendee[], organizerEmail?: string, calEventResponses?: CalEventResponses | null): Promise<{
        id: string;
        email: string;
    }[]>;
    handleAttendeeNoShow(bookingUid: string, attendees: {
        email: string;
        noShow: boolean;
    }[]): Promise<void>;
    private getExistingIdFromDuplicateError;
    private setDoNotCreateEvent;
    private getDoNotCreateEvent;
    private getDominantAccountId;
    private createAttendeeRecord;
    private generateCreateRecordBody;
    private ensureFieldsExistOnObject;
    private checkRecordOwnerNameFromRecordId;
    getAllPossibleAccountWebsiteFromEmailDomain(emailDomain: string): string;
    private getAccountIdBasedOnEmailDomainOfContacts;
    private setFallbackToContact;
    private getFallbackToContact;
    private writeToRecord;
    private buildRecordUpdatePayload;
    private generateWriteToEventBody;
    private getTextFieldValue;
    private getTextValueFromRoutingFormResponse;
    private getTextValueFromBookingTracking;
    private getTextValueFromBookingResponse;
    private getDateFieldValue;
    private getPicklistFieldValue;
    private fetchPersonRecord;
    private createNewContactUnderAnAccount;
    findUserEmailFromLookupField(attendeeEmail: string, fieldName: string, salesforceObject: SalesforceRecordEnum): Promise<{
        email: string;
        recordType: RoutingReasons;
    } | undefined>;
    /** Search the booking questions for the Company field value rather than relying on the email domain  */
    private getCompanyNameFromBookingResponse;
    private shouldSkipAttendeeIfFreeEmailDomain;
    incompleteBookingWriteToRecord(email: string, writeToRecordObject: z.infer<typeof writeToRecordDataSchema>): Promise<void>;
    /** All salesforce ids have a 3 character prefix associated with the record type
     * https://help.salesforce.com/s/articleView?id=000385203&type=1
     */
    private determineRecordTypeById;
    /** Prioritizes contacts over leads */
    private findProspectByEmail;
    private findContactByEmail;
    private findLeadByEmail;
}
export {};
//# sourceMappingURL=CrmService.d.ts.map