<?php

declare(strict_types=1);

/*
 * This file is part of vonRotenberg Shopware API Bundle.
 *
 * (c) vonRotenberg
 *
 * @license proprietary
 */

namespace vonRotenberg\ShopwareApiBundle\Command;

use Contao\CoreBundle\Framework\ContaoFramework;
use Contao\System;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use vonRotenberg\ShopwareApiBundle\API\Shopware;

class TestApiConnection extends Command
{
    protected static $defaultName = 'shopware:test-connection';

    protected $framework;

    public function __construct(ContaoFramework $framework)
    {
        $this->framework = $framework;

        parent::__construct();
    }

    protected function configure(): void
    {
        $this
            ->setName(self::$defaultName)
            ->setDescription('Test connection')
        ;
    }
    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->framework->initialize();

        /** @var Shopware $Shopware */
        $Shopware = System::getContainer()->get(Shopware::class);

        dump($Shopware->testApiRequest());

        return 0;
    }
}