<?php
/*
* Disclaimer: This source code is protected by copyright law and by
* international conventions.
*
* Any reproduction or partial or total distribution of the source code, by any
* means whatsoever, is strictly forbidden.
*
* Anyone not complies with these provisions will be guilty of the offense of
* infringement and the penal sanctions provided for by law.
*
* © 2022 All rights reserved.
*/
namespace App\Controller;
use App\Core\Controller\MainAbstractController;
use App\Core\Service\CreditSimulator\CreditSimulatorCreditAgricole;
use App\Core\Service\CreditSimulator\CreditSimulatorFranFinance;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Psr7\Request as GuzzleRequest;
use GuzzleHttp\RequestOptions;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
use Symfony\Contracts\HttpClient\HttpClientInterface;
/**
* Class HomeController
*
* @author Rémy P. <r.peyron@ingeno.eu>
* @package App\Controller
*/
class HomeController extends MainAbstractController
{
/**
* @return Response
*/
public function index (): Response
{
return $this->render('home/index.html.twig');
}
public function sendMail (): Response
{
$publicFolder = $this->getParameter('public_dir');
$email = (new Email())
->from(new Address('noreply@rpfrance.fr'))
->to(
Address::create("Rémy Peyron <r.peyron@hotmail.fr>"),
Address::create('Eric Thomas <etdeveloppement@gmail.com>')
)
->subject("Devis test")
->embed(fopen($publicFolder . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . 'RP-France-long-sombre.png', 'r'), 'logo')
->html($this->renderView("emails/devis.html.twig", [
"user" => $this->getUser(),
"nom" => "Doe",
"prenom" => "John",
"email" => "j.doe@email.fr"
]));
try {
$this->getMailer()->send($email);
return $this->json("email envoyé");
} catch (\Exception|TransportExceptionInterface $exception) {
return $this->json($exception->getMessage());
}
}
public function testSignature (HttpClientInterface $client)
{
}
public function wspr (CreditSimulatorFranFinance $creditSimulatorFranFinance, CreditSimulatorCreditAgricole $simulator)
{
// $p12File = $this->getParameter('franfinance_cert') . DIRECTORY_SEPARATOR . 'RP-FRANCE.services-homo.franfinance-online.com.20231208.p12';
//
// // Récupération jeton de contexte
// $client = new Client([
// 'base_uri' => 'https://services-homo-rec7.franfinance-online.com/wspr/',
// RequestOptions::HEADERS => [
// 'Content-Type' => 'application/json'
// ],
// RequestOptions::CERT => [
// $p12File,
// '5SJrH7qo9fcFmQBPKcnVgbj5shgKRKR9c5bmRWcXdTB5'
// ],
// 'curl' => [
// CURLOPT_VERBOSE => true,
// CURLOPT_SSLCERTTYPE => 'P12'
// ],
// RequestOptions::VERIFY => true
// ]);
//
// try {
// $res = $client->post("auth/authentification", [
// RequestOptions::BODY => json_encode([
// "typeSupport" => "P",
// "chaineAuthentification" => "a=54d6k4gasyXh5cj7+hgR2Q==&b=Z4IwVTRlZc9pmdaT+Z116tSFL8mZiWp5piuKYC6Z7n30UWBo5FO+2/+7c97cBcUX",
// ]),
// ]);
//
// return $this->json([
// "status" => $res->getStatusCode(),
// "content" => json_decode($res->getBody()->getContents(), true)
// ]);
// } catch (\Exception|GuzzleException $exception) {
// dd($exception->getMessage());
// return $this->json('test');
// }
// $file = $this->getParameter('kernel.project_dir') . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'key' . DIRECTORY_SEPARATOR . 'DigiCert Global Root CA.crt';
$simulate = $creditSimulatorFranFinance->simulate();
$listAssu = $creditSimulatorFranFinance->listAssu();
// $caSimulation = $simulator->simulate([]);
return $this->json(compact("simulate", "listAssu"));
}
}