<?php

namespace App\Command\Crm\MozApi;

use App\Integrations\MozApi\Client;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class LinesCommand extends Command
{
    protected static $defaultName = 'crm:moz:lines';

    /**
     * @var Client
     */
    private $client;

    public function __construct(Client $client, ?string $name = null)
    {
        parent::__construct($name);
        $this->client = $client;
    }

    protected function configure()
    {
        $this
            ->setDescription('Get used lines for MozApi');
    }

    /**
     * @return void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);

        $usedRows = $this->client->getDomainAuthority('i3media.net');

        $io->success(sprintf('This month there is %d/2500 lines used', $usedRows));
    }
}
