using BimAI.Infrastructure.Sync;
using Microsoft.Extensions.Logging;

namespace BimAI.Infrastructure.Jobs;

public class ProductSyncJob
{
        private readonly ProductSyncService _productSyncService;
        private readonly ILogger<ProductSyncJob> _logger;
        
        public ProductSyncJob(ProductSyncService productSyncService, ILogger<ProductSyncJob> logger)
        {
            _productSyncService = productSyncService;
            _logger = logger;
        }

        public async Task ExecuteAsync()
        {
            _logger.LogInformation("Starting product sync...");

            try
            {
                await _productSyncService.RunAsync();
                _logger.LogInformation("Product sync finished.");
            } catch (Exception ex)
            {
                _logger.LogError(ex, "Error during product sync.");
                throw;
            }
        }
}