<?php
declare(strict_types=1);

namespace App\Modules\Cron;

use App\Modules\Settings\AllegroOrdersSyncService;

final class AllegroOrdersImportHandler
{
    public function __construct(private readonly AllegroOrdersSyncService $syncService)
    {
    }

    /**
     * @param array<string, mixed> $payload
     * @return array<string, mixed>
     */
    public function handle(array $payload): array
    {
        return $this->syncService->sync([
            'max_pages' => (int) ($payload['max_pages'] ?? 5),
            'page_limit' => (int) ($payload['page_limit'] ?? 50),
            'max_orders' => (int) ($payload['max_orders'] ?? 200),
        ]);
    }
}
