import { loopGet, loopPost, withTeamKey, } from "../lib/loop-api.js";
export async function feedbackGet(params) {
    const { accountId, teamName, viewingId, department } = params;
    const result = await withTeamKey(accountId, teamName, "feedback", "loop-feedback-get", async (apiKey) => {
        const path = `/feedback/residential/${department}/viewings/${viewingId}`;
        return loopGet(apiKey, path, "loop-feedback-get", teamName);
    });
    if (!result || (Array.isArray(result) && result.length === 0)) {
        return `No feedback found for viewing ${viewingId} (${department}) via team "${teamName}".`;
    }
    const f = result;
    const lines = [`**Feedback for viewing ${viewingId}**`];
    if (f.propertyAddress)
        lines.push(`Property: ${f.propertyAddress}`);
    if (f.date)
        lines.push(`Date: ${f.date}`);
    if (f.attendeeName)
        lines.push(`Attendee: ${f.attendeeName}`);
    if (f.rating != null)
        lines.push(`Rating: ★${f.rating}`);
    if (f.status)
        lines.push(`Status: ${f.status}`);
    if (f.feedback)
        lines.push(`Feedback: ${f.feedback}`);
    return lines.join("\n");
}
export async function feedbackSubmit(params) {
    const { accountId, teamName, viewingId, department, feedback } = params;
    await withTeamKey(accountId, teamName, "feedback", "loop-feedback-submit", async (apiKey) => {
        const path = `/feedback/residential/${department}/viewings/${viewingId}/feedback`;
        return loopPost(apiKey, path, { result: feedback }, "loop-feedback-submit", teamName);
    });
    return `Feedback submitted for viewing ${viewingId} (${department}) via team "${teamName}".`;
}
//# sourceMappingURL=feedback.js.map