<?php

/*
 * This file is part of the Serenity package.
 *
 * (c) CP Creation <web@cpcreation.fr>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace CpCreation\VitiCore\Bridge\Symfony\Bundle\Command;

use CpCreation\VitiCore\Bridge\Symfony\Bundle\Client\ConnectCpCreationClient;
use CpCreation\VitiCore\SocialNetwork\Model\SocialNetwork;
use CpCreation\VitiCore\SocialNetwork\Repository\SocialNetworkRepository;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(name: 'viti-core:refresh-token-instagram')]
class RefreshTokenInstagramCommand
{
    public function __construct(
        private SocialNetworkRepository $socialNetworkRepository,
        private ConnectCpCreationClient $connectCpCreationClient,
    ) {
    }

    public function __invoke(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);
        /** @var SocialNetwork $socialNetwork */
        $socialNetwork = $this->socialNetworkRepository->findByLikeSocial('basic_instagram');
        $connect = $this->connectCpCreationClient->get('api/client_socials/'.$socialNetwork->getConnectId().'/refreshtoken');

        $io->comment('refresh Token Instagram Done !');

        return Command::SUCCESS;
    }
}
