import { Lead, SearchQuery } from '../types';

export interface LeadProvider {
  /**
   * Identifies the provider (e.g. 'Foursquare')
   */
  name: string;

  /**
   * Search for leads based on a query.
   */
  search(query: SearchQuery): Promise<Lead[]>;
}

/**
 * Calculates a basic quality score for a lead (0-3).
 * Adds 1 point for having a phone, 1 for website, 1 for email.
 */
export function calculateQualityScore(lead: Partial<Lead>): number {
  let score = 0;
  if (lead.phone && lead.phone.trim() !== '') score++;
  if (lead.website && lead.website.trim() !== '') score++;
  if (lead.email && lead.email.trim() !== '') score++;
  return score;
}
