import { loopPost, withTeamKey } from "../lib/loop-api.js"; type Department = "sales" | "lettings"; // Loop API V2: distinct operator-intent endpoints (post-Task 103 split). // POST /property/residential/{dept}/{id}/viewing — request a viewing // POST /property/residential/{dept}/{id}/call-back — request a callback // POST /property/residential/{dept}/{id}/information — request more information // Each endpoint takes the same {name?, email?, phone?, message?} body but is // surfaced as a separate tool so operator intent is preserved on the agent's // tool-call surface (replaces the prior bundled loop-property-request). interface LoopBooleanResponse { success?: boolean; [key: string]: unknown; } async function submitIntent( toolName: string, action: "viewing" | "call-back" | "information", params: { accountId: string; teamName: string; propertyId: number; department: Department; name?: string; email?: string; phone?: string; message?: string; }, successLabel: string ): Promise { const { accountId, teamName, propertyId, department, ...body } = params; await withTeamKey( accountId, teamName, "properties", toolName, async (apiKey) => { const path = `/property/residential/${department}/${propertyId}/${action}`; return loopPost(apiKey, path, body, toolName, teamName); } ); return `${successLabel} submitted for property ${propertyId} (${department}) via team "${teamName}".`; } export async function propertyViewing(params: { accountId: string; teamName: string; propertyId: number; department: Department; name?: string; email?: string; phone?: string; message?: string; }): Promise { return submitIntent("loop-property-viewing", "viewing", params, "Viewing request"); } export async function propertyCallback(params: { accountId: string; teamName: string; propertyId: number; department: Department; name?: string; email?: string; phone?: string; message?: string; }): Promise { return submitIntent("loop-property-callback", "call-back", params, "Callback request"); } export async function propertyInformation(params: { accountId: string; teamName: string; propertyId: number; department: Department; name?: string; email?: string; phone?: string; message?: string; }): Promise { return submitIntent("loop-property-information", "information", params, "Information request"); }