using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PhilExampleCrawler.Common.Models;
using PhilExampleCrawler.Core.Abstractions.Interfaces;

namespace PhilExampleCrawler.Core.Abstractions.Services
{
    internal class CrawlingService_HAP : ICrawlingService_HAP
    {
        public event EventHandler<Insertion> OnNewInsertionFound;
        private readonly BaseCrawler_HAP _crawler = new();

        public CrawlingService_HAP()
        {
            _crawler.OnNewInsertionFound += Crawler_OnNewInsertionFound;
        }

        private void Crawler_OnNewInsertionFound(object sender, Insertion e)
        {
            OnNewInsertionFound?.Invoke(sender, e);
        }

        public void StartCrawling(CrawlSearchParams crawlSearchParams, int interval_s)
        {
            _crawler.StartCrawling(crawlSearchParams, interval_s);
        }

        public void StopCrawling()
        {
            _crawler.StopCrawling();
        }

        public void Crawl(CrawlSearchParams searchParams, int timeout_ms)
        {
            _crawler.Crawl(searchParams, timeout_ms);
        }
    }
}
