// TenerifeProp - API Client const API_BASE = '/api'; class API { // Properties static async getProperties(filters = {}) { const params = new URLSearchParams(filters as any); const response = await fetch(`${API_BASE}/properties?${params}`); return response.json(); } static async getProperty(slug, lang = 'es') { const response = await fetch(`${API_BASE}/properties/${slug}?lang=${lang}`); return response.json(); } static async getFeaturedProperties(lang = 'es') { const response = await fetch(`${API_BASE}/properties/featured?lang=${lang}`); return response.json(); } // Leads static async createLead(data) { const response = await fetch(`${API_BASE}/leads`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }); return response.json(); } static async getLeads(filters = {}) { const params = new URLSearchParams(filters as any); const response = await fetch(`${API_BASE}/leads?${params}`); return response.json(); } // Content static async getTestimonials(lang = 'es') { const response = await fetch(`${API_BASE}/testimonials?lang=${lang}`); return response.json(); } static async getFAQ(lang = 'es') { const response = await fetch(`${API_BASE}/faq?lang=${lang}`); return response.json(); } static async getServices(lang = 'es') { const response = await fetch(`${API_BASE}/services?lang=${lang}`); return response.json(); } static async getSettings() { const response = await fetch(`${API_BASE}/settings`); return response.json(); } // Analytics static async trackEvent(type, data = {}) { const sessionId = localStorage.getItem('session_id') || crypto.randomUUID(); localStorage.setItem('session_id', sessionId); await fetch(`${API_BASE}/analytics/event`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ type, session_id: sessionId, ...data }) }); } // Cities static async getCities() { const response = await fetch(`${API_BASE}/cities`); return response.json(); } } // Export for use window.API = API;