<?php

namespace App\Controller;

use App\Services\ChargeAngelsApi;
use App\Services\EmailService;
use App\Services\HttpClientService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;

class HomeController extends AbstractController
{
    private ChargeAngelsApi $chargeAngelApi;
    public function __construct(ChargeAngelsApi $chargeAngelApi)
    {
        $this->chargeAngelApi = $chargeAngelApi;
    }

    /**
     * @throws TransportExceptionInterface
     * @throws ServerExceptionInterface
     * @throws RedirectionExceptionInterface
     * @throws ClientExceptionInterface
     */
    #[Route('/', name: 'app_home')]
    public function index(HttpClientService $httpClientService, EmailService $emailService): Response
    {
        $response = $httpClientService->getStatus('GET','https://api.github.com/repos/symfony/symfony-docs');
        $email ='contact@mathieuviot.fr';

        return $this->render('home/index.html.twig', [
            'controller_name' => 'HomeController',
            'response'=>$response
        ]);

    }
}
