import { NextRequest, NextResponse } from 'next/server'; import { getAutotaskClient } from '@/lib/services/autotask-factory'; export async function GET(request: NextRequest) { try { const client = getAutotaskClient(); const allCompanies = await client.getAllCompanies(); // Filter to only show customers (companyType = 1) // companyType 1 = Customer, 2 = Lead, 3 = Prospect, 4 = Dead, 5 = Cancelation, 6 = Vendor, 7 = Partner const companies = allCompanies.filter(company => company.companyType === 1); return NextResponse.json({ companies }); } catch (error) { console.error('Error fetching companies:', error); return NextResponse.json( { error: error instanceof Error ? error.message : 'Failed to fetch companies' }, { status: 500 } ); } }