src/Controller/HomeController.php line 45

Open in your IDE?
  1. <?php
  2. /*
  3. * Disclaimer: This source code is protected by copyright law and by
  4. * international conventions.
  5. *
  6. * Any reproduction or partial or total distribution of the source code, by any
  7. * means whatsoever, is strictly forbidden.
  8. *
  9. * Anyone not complies with these provisions will be guilty of the offense of
  10. * infringement and the penal sanctions provided for by law.
  11. *
  12. * © 2022 All rights reserved.
  13. */
  14. namespace App\Controller;
  15. use App\Core\Controller\MainAbstractController;
  16. use App\Core\Service\CreditSimulator\CreditSimulatorCreditAgricole;
  17. use App\Core\Service\CreditSimulator\CreditSimulatorFranFinance;
  18. use GuzzleHttp\Client;
  19. use GuzzleHttp\Exception\GuzzleException;
  20. use GuzzleHttp\Psr7\Request as GuzzleRequest;
  21. use GuzzleHttp\RequestOptions;
  22. use Symfony\Component\Filesystem\Filesystem;
  23. use Symfony\Component\HttpFoundation\Response;
  24. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  25. use Symfony\Component\Mime\Address;
  26. use Symfony\Component\Mime\Email;
  27. use Symfony\Contracts\HttpClient\HttpClientInterface;
  28. /**
  29.  * Class HomeController
  30.  *
  31.  * @author Rémy P. <r.peyron@ingeno.eu>
  32.  * @package App\Controller
  33.  */
  34. class HomeController extends MainAbstractController
  35. {
  36.     /**
  37.      * @return Response
  38.      */
  39.     public function index (): Response
  40.     {
  41.         return $this->render('home/index.html.twig');
  42.     }
  43.     public function sendMail (): Response
  44.     {
  45.         $publicFolder $this->getParameter('public_dir');
  46.         $email = (new Email())
  47.             ->from(new Address('noreply@rpfrance.fr'))
  48.             ->to(
  49.                 Address::create("Rémy Peyron <r.peyron@hotmail.fr>"),
  50.                 Address::create('Eric Thomas <etdeveloppement@gmail.com>')
  51.             )
  52.             ->subject("Devis test")
  53.             ->embed(fopen($publicFolder DIRECTORY_SEPARATOR 'assets' DIRECTORY_SEPARATOR 'images' DIRECTORY_SEPARATOR 'RP-France-long-sombre.png''r'), 'logo')
  54.             ->html($this->renderView("emails/devis.html.twig", [
  55.                 "user"   => $this->getUser(),
  56.                 "nom"    => "Doe",
  57.                 "prenom" => "John",
  58.                 "email"  => "j.doe@email.fr"
  59.             ]));
  60.         try {
  61.             $this->getMailer()->send($email);
  62.             return $this->json("email envoyé");
  63.         } catch (\Exception|TransportExceptionInterface $exception) {
  64.             return $this->json($exception->getMessage());
  65.         }
  66.     }
  67.     public function testSignature (HttpClientInterface $client)
  68.     {
  69.     }
  70.     public function wspr (CreditSimulatorFranFinance $creditSimulatorFranFinanceCreditSimulatorCreditAgricole $simulator)
  71.     {
  72. //        $p12File = $this->getParameter('franfinance_cert') . DIRECTORY_SEPARATOR . 'RP-FRANCE.services-homo.franfinance-online.com.20231208.p12';
  73. //
  74. //        // Récupération jeton de contexte
  75. //        $client = new Client([
  76. //            'base_uri'              => 'https://services-homo-rec7.franfinance-online.com/wspr/',
  77. //            RequestOptions::HEADERS => [
  78. //                'Content-Type' => 'application/json'
  79. //            ],
  80. //            RequestOptions::CERT    => [
  81. //                $p12File,
  82. //                '5SJrH7qo9fcFmQBPKcnVgbj5shgKRKR9c5bmRWcXdTB5'
  83. //            ],
  84. //            'curl'                  => [
  85. //                CURLOPT_VERBOSE     => true,
  86. //                CURLOPT_SSLCERTTYPE => 'P12'
  87. //            ],
  88. //            RequestOptions::VERIFY  => true
  89. //        ]);
  90. //
  91. //        try {
  92. //            $res = $client->post("auth/authentification", [
  93. //                RequestOptions::BODY => json_encode([
  94. //                    "typeSupport"            => "P",
  95. //                    "chaineAuthentification" => "a=54d6k4gasyXh5cj7+hgR2Q==&b=Z4IwVTRlZc9pmdaT+Z116tSFL8mZiWp5piuKYC6Z7n30UWBo5FO+2/+7c97cBcUX",
  96. //                ]),
  97. //            ]);
  98. //
  99. //            return $this->json([
  100. //                "status"  => $res->getStatusCode(),
  101. //                "content" => json_decode($res->getBody()->getContents(), true)
  102. //            ]);
  103. //        } catch (\Exception|GuzzleException $exception) {
  104. //            dd($exception->getMessage());
  105. //            return $this->json('test');
  106. //        }
  107. //        $file = $this->getParameter('kernel.project_dir') . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'key' . DIRECTORY_SEPARATOR . 'DigiCert Global Root CA.crt';
  108.         $simulate $creditSimulatorFranFinance->simulate();
  109.         $listAssu $creditSimulatorFranFinance->listAssu();
  110. //        $caSimulation = $simulator->simulate([]);
  111.         return $this->json(compact("simulate""listAssu"));
  112.     }
  113. }