import { aggregateAcrossTeams, formatAggregationResult, loopPut, } from "../lib/loop-api.js";
export async function marketingMatchBatch(params) {
    const { accountId, propertyIds, department, teamName } = params;
    const result = await aggregateAcrossTeams(accountId, "marketing", "loop-marketing-match-batch", async (apiKey, team) => {
        const prefix = department === "lettings" ? "/marketing/rentals" : "/marketing";
        const path = `${prefix}/matching/other-matches`;
        const data = await loopPut(apiKey, path, propertyIds, "loop-marketing-match-batch", team);
        return Array.isArray(data) ? data : [];
    }, { teamName });
    return formatAggregationResult(result, (p) => {
        const price = p.price ? ` — £${p.price.toLocaleString("en-GB")}` : "";
        const beds = p.bedrooms ? ` ${p.bedrooms}bed` : "";
        return `- ${p.address ?? "Unknown"}${price}${beds}`;
    }, "matching properties");
}
//# sourceMappingURL=marketing-match-batch.js.map