<?php
declare(strict_types=1);

namespace App\Modules\Cron;

use App\Modules\Settings\ShopproOrdersSyncService;

final class ShopproOrdersImportHandler
{
    public function __construct(private readonly ShopproOrdersSyncService $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'] ?? 3),
            'page_limit' => (int) ($payload['page_limit'] ?? 50),
            'max_orders' => (int) ($payload['max_orders'] ?? 200),
        ]);
    }
}
