import { loopGet, loopPost, loopPut, withTeamKey } from "../lib/loop-api.js";
export async function marketingEnquiry(params) {
    const { accountId, teamName, action } = params;
    if (action === "seller-enquiry") {
        await withTeamKey(accountId, teamName, "marketing", "loop-marketing-enquiry", async (apiKey) => {
            return loopPost(apiKey, "/marketing/enquiries/seller", params.sellerEnquiryData ?? {}, "loop-marketing-enquiry", teamName);
        });
        return `Seller enquiry submitted via team "${teamName}".`;
    }
    if (!params.autoResponderId || !params.autoResponderKey) {
        throw new Error("autoResponderId and autoResponderKey are required for autoresponder actions.");
    }
    const id = params.autoResponderId;
    const key = params.autoResponderKey;
    if (action === "autoresponder-get") {
        const result = await withTeamKey(accountId, teamName, "marketing", "loop-marketing-enquiry", async (apiKey) => {
            return loopGet(apiKey, `/marketing/enquiries/auto-responder/${id}/${key}`, "loop-marketing-enquiry", teamName);
        });
        return JSON.stringify(result, null, 2);
    }
    if (action === "autoresponder-answers") {
        await withTeamKey(accountId, teamName, "marketing", "loop-marketing-enquiry", async (apiKey) => {
            return loopPut(apiKey, `/marketing/enquiries/auto-responder/${id}/answers/${key}`, params.answers ?? [], "loop-marketing-enquiry", teamName);
        });
        return `Auto-responder answers submitted for enquiry ${id} via team "${teamName}".`;
    }
    if (action === "autoresponder-details") {
        await withTeamKey(accountId, teamName, "marketing", "loop-marketing-enquiry", async (apiKey) => {
            return loopPut(apiKey, `/marketing/enquiries/auto-responder/${id}/details/${key}`, params.details ?? {}, "loop-marketing-enquiry", teamName);
        });
        return `Auto-responder details updated for enquiry ${id} via team "${teamName}".`;
    }
    if (action === "autoresponder-refer") {
        await withTeamKey(accountId, teamName, "marketing", "loop-marketing-enquiry", async (apiKey) => {
            return loopPut(apiKey, `/marketing/enquiries/auto-responder/${id}/refer/${key}`, {}, "loop-marketing-enquiry", teamName);
        });
        return `Enquiry ${id} referred via team "${teamName}".`;
    }
    throw new Error(`Unknown action: ${action}`);
}
//# sourceMappingURL=marketing-enquiry.js.map