import { aggregateAcrossTeams, formatAggregationResult, loopGet, } from "../lib/loop-api.js";
export async function feedbackList(params) {
    const { accountId, teamName, limit } = params;
    const result = await aggregateAcrossTeams(accountId, "feedback", "loop-feedback-list", async (apiKey, team) => {
        const data = await loopGet(apiKey, "/feedback", "loop-feedback-list", team);
        return Array.isArray(data) ? data : [];
    }, { teamName, limitPerTeam: limit ?? 50, limitTotal: limit ?? 200 });
    return formatAggregationResult(result, (f) => {
        const addr = f.propertyAddress ?? "Unknown property";
        const date = f.viewingDate ?? "";
        const attendee = f.attendeeName ? ` (${f.attendeeName})` : "";
        const rating = f.rating != null ? ` ★${f.rating}` : "";
        const text = f.feedback ? `: "${f.feedback}"` : "";
        const status = f.status ? ` [${f.status}]` : "";
        return `- ${addr} ${date}${attendee}${rating}${status}${text}`;
    }, "feedback");
}
//# sourceMappingURL=feedback-list.js.map