src/Services/CallApiServices.php line 688

Open in your IDE?
  1. <?php
  2. /*
  3. * ==============================================================
  4. *     Autor            :  Farid Benjomaa
  5. *     Modified by        :  
  6. *    COPYRIGHT (C) 2025, Media-Technologies
  7. * ==============================================================
  8. */
  9. namespace App\Services;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\RouterInterface;
  12. use Symfony\Component\HttpFoundation\RedirectResponse;
  13. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  14. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  15. use Psr\Log\LoggerInterface;
  16. class CallApiServices
  17. {
  18.     private $apiKey;
  19.     private $apiToken;
  20.     private $accountId;
  21.     private $serviceId;
  22.     private $apiURL;
  23.     private $baseURL;
  24.     private $session;
  25.     /* @var $router RouterInterface */
  26.     private $router;
  27.     private $parameters;
  28.     private $logger;
  29.     public function __construct(SessionInterface $session$apiKey$accountId$baseURL$serviceId$apiURLRouterInterface $routerParameterBagInterface $parametersLoggerInterface $logger)
  30.     {
  31.         $this->apiKey $apiKey;
  32.         $this->apiToken "";
  33.         $this->accountId $accountId;
  34.         $this->serviceId $serviceId;
  35.         $this->apiURL $apiURL;
  36.         $this->baseURL $baseURL;
  37.         $this->session $session;
  38.         $this->router $router;
  39.         $this->parameters $parameters;
  40.         $this->logger $logger;
  41.     }
  42.     public function postApi($endpoint, array $data): array
  43.     {
  44.         $url $this->parameters->get('apiURL') . "/" "$endpoint";
  45.         $httpHost $this->parameters->get('baseURL');
  46.         $dataEncoded json_encode($data);
  47.         $headers = array(
  48.             "Accept: application/json",
  49.             "Content-Type: application/json",
  50.         );
  51.         $this->logger->info('Posting to API :' $url ' with referer:' $httpHost ' and data: ' $dataEncoded);
  52.         $curl curl_init($url);
  53.         curl_setopt($curlCURLOPT_REFERER$httpHost);
  54.         curl_setopt($curlCURLOPT_POSTtrue);
  55.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  56.         curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
  57.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  58.         curl_setopt($curlCURLOPT_POSTFIELDS$dataEncoded);
  59.         $response curl_exec($curl);
  60.         $curl_http_code curl_getinfo($curlCURLINFO_HTTP_CODE);
  61.         $curl_error curl_error($curl);
  62.         $curl_errno curl_errno($curl);
  63.         curl_close($curl);
  64.         if ($response === false) {
  65.             throw new \Exception($curl_error$curl_errno);
  66.             return ["null" => null];
  67.         } else {
  68.             $results = [];
  69.             // if (curl_getinfo($curl, CURLINFO_HTTP_CODE) === 200) {
  70.             //   $results = json_decode($response, true);
  71.             // } else if (curl_getinfo($curl, CURLINFO_HTTP_CODE) === 401) {
  72.             //   throw $results =  new \Exception('identifiant incorecte');
  73.             // } else if (curl_getinfo($curl, CURLINFO_HTTP_CODE) === 404) {
  74.             //   $response = json_decode($response, true);
  75.             //   $results =  $response;
  76.             // } else if (curl_getinfo($curl, CURLINFO_HTTP_CODE) === 403) {
  77.             //   $response = json_decode($response, true);
  78.             //   $results = $response;
  79.             // }
  80.             switch ($curl_http_code) {
  81.                 case 200:
  82.                     $results json_decode($responsetrue);
  83.                     break;
  84.                 case 401// Accès non autorisé, l'apiKey n'existe pas
  85.                     // a rediriger vers un page d'erreur qui dirait joindre le support, car c'est une erreur qui ne devrait jamais arrivée
  86.                     die(new RedirectResponse($this->router->generate('app_login')));
  87.                     //throw $results =  new \Exception('identifiant incorrecte');
  88.                     break;
  89.                 case 403:
  90.                 case 404:
  91.                     $response json_decode($responsetrue);
  92.                     $results =  $response;
  93.                     break;
  94.                 case 409// Conflit avec le compte ID ou service ID, l'apiKey existe, mais un conflit avec les valeurs configurées
  95.                     // a rediriger vers un page d'erreur qui dirait joindre le support, car c'est une erreur qui ne devrait jamais arrivée
  96.                     die(new RedirectResponse($this->router->generate('app_login')));
  97.                     break;
  98.                 case 410// apiToken n'exite pas ou la date est dépassée, vous devez démarrer une nouvelle session
  99.                     die(new RedirectResponse($this->router->generate('app_login')));
  100.                     break;
  101.                 default:
  102.                     $response json_decode($responsetrue);
  103.                     $results =  $response;
  104.                     break;
  105.             }
  106.         }
  107.         // $data = [ 'message' => "Accès non autorisé", 'responseCode' => "401" ];  l'apiKey n'existe pas
  108.         // $data = [ 'message' => "Conflit avec le référent HTTP", 'responseCode' => "409" ]; l'apiKey existe, mais un conflit avec les valeurs configurées
  109.         // $data = [ 'message' => "Conflit avec le compte ID", 'responseCode' => "409" ];
  110.         // $data = [ 'message' => "Conflit avec le service ID", 'responseCode' => "409" ];
  111.         // $data = [ 'message' => "token n’est plus disponible, vous devez démarrer une nouvelle session", "responseCode" => "410"}]
  112.         return $results;
  113.     }
  114.     public function getData(string $colletionName): array
  115.     {
  116.         $url 'http://localhost:8080/api';
  117.         $request_url $url '/' $colletionName;
  118.         $curl curl_init($request_url);
  119.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  120.         $response curl_exec($curl);
  121.         if ($response === false) {
  122.             return null;
  123.         } else {
  124.             $results = [];
  125.             if (curl_getinfo($curlCURLINFO_HTTP_CODE) === 200) {
  126.                 $response json_decode($responsetrue);
  127.             }
  128.         }
  129.         curl_close($curl);
  130.         return $response;
  131.     }
  132.     public function getDataById(string $colletionNamestring $id): array
  133.     {
  134.         $url 'http://localhost:8080/api';
  135.         $request_url $url '/' $colletionName '/' $id;
  136.         $curl curl_init($request_url);
  137.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  138.         $response curl_exec($curl);
  139.         if ($response === false) {
  140.             return null;
  141.         } else {
  142.             $results = [];
  143.             if (curl_getinfo($curlCURLINFO_HTTP_CODE) === 200) {
  144.                 $response json_decode($responsetrue);
  145.             }
  146.         }
  147.         curl_close($curl);
  148.         return $response;
  149.     }
  150.     public function authApi(string $loginstring $password): array
  151.     {
  152.         $url 'http://localhost:8080/api/login';
  153.         $curl curl_init($url);
  154.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  155.         $headers = array(
  156.             "Accept: application/json",
  157.             "Content-Type: application/json",
  158.         );
  159.         $data = [
  160.             "username" => $login,
  161.             "password" => $password
  162.         ];
  163.         $dataEncoded json_encode($data);
  164.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  165.         curl_setopt($curlCURLOPT_POSTFIELDS$dataEncoded);
  166.         $response curl_exec($curl);
  167.         if ($response === false) {
  168.             return ["null" => null];
  169.         } else {
  170.             $results = [];
  171.             if (curl_getinfo($curlCURLINFO_HTTP_CODE) === 200) {
  172.                 $response json_decode($responsetrue);
  173.             } else if (curl_getinfo($curlCURLINFO_HTTP_CODE) === 401) {
  174.                 throw new \Exception('identifiant incorecte');
  175.             }
  176.         }
  177.         curl_close($curl);
  178.         return $response;
  179.     }
  180.     public function getUserDetails(string $token): array
  181.     {
  182.         $url 'http://localhost:8080/api/me';
  183.         $curl curl_init($url);
  184.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  185.         $headers = array(
  186.             "Accept: application/json",
  187.             "Content-Type: application/json",
  188.             "Authorization: Bearer " $token ""
  189.         );
  190.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  191.         $response curl_exec($curl);
  192.         if ($response === false) {
  193.             return ["null" => null];
  194.         } else {
  195.             $results = [];
  196.             if (curl_getinfo($curlCURLINFO_HTTP_CODE) === 200) {
  197.                 $response json_decode($responsetrue);
  198.             }
  199.         }
  200.         curl_close($curl);
  201.         return $response;
  202.     }
  203.     // ** +++++++++++++++++ ------------        --------- +++++++++++++++++ **
  204.     // ** +++++++++++++++++ ------------        --------- +++++++++++++++++ **
  205.     public function getListConseillers($accountId$serviceId): array
  206.     {
  207.         $data = [
  208.             "accountId" => $accountId,
  209.             "serviceId" => $serviceId
  210.         ];
  211.         $results $this->restApiPOSTcURL('/plateforme/listeConseillersEtPresence'$data);
  212.         return $results;
  213.     }
  214.     public function configuratationPlateforme($accountId$serviceId): array
  215.     {
  216.         $data = [
  217.             "accountId" => $accountId,
  218.             "serviceId" => $serviceId
  219.         ];
  220.         $results $this->restApiPOSTcURL('/plateforme/configuratationPlateforme'$data);
  221.         return $results;
  222.     }
  223.     public function conseillerEtPlanning($pseudoId$serviceId): array
  224.     {
  225.         $data = [
  226.             "complementId" => $pseudoId,
  227.             "serviceId" => $serviceId
  228.         ];
  229.         $results $this->restApiPOSTcURL('/plateforme/conseillerEtPlanning'$data);
  230.         return $results;
  231.     }
  232.     public function prestationEcriteMails($accountId$serviceId): array
  233.     {
  234.         $data = [
  235.             "accountId" => $accountId,
  236.             "serviceId" => $serviceId
  237.         ];
  238.         $results $this->restApiPOSTcURL('/paramaters/PrestationEcriteMails'$data);
  239.         return $results;
  240.     }
  241.     public function clientAuthentification(string $loginstring $password$serviceId): array
  242.     {
  243.         $data = [
  244.             "serviceId" => $serviceId,
  245.             "login" => $login,
  246.             "password" => $password
  247.         ];
  248.         $results $this->restApiPOSTcURL('/plateforme/clientAuthentification'$data);
  249.         if (isset($results['responseCode']) && ($results['responseCode'] != 200)) {
  250.             return $results;
  251.         }
  252.         $this->session->set('apiToken'$results["apiToken"]);
  253.         return $results;
  254.     }
  255.     //Avis
  256.     public function conseillerAvis($serviceId$complementId): array
  257.     {
  258.         $data = [
  259.             "serviceId" => $serviceId,
  260.             "complementId" => $complementId
  261.         ];
  262.         $results $this->restApiPOSTcURL('/plateforme/conseillerAvis'$data);
  263.         return $results;
  264.     }
  265.     public function clientAvis($serviceId$clientId): array
  266.     {
  267.         $data = [
  268.             "serviceId" => $serviceId,
  269.             "clientId" => $clientId
  270.         ];
  271.         $results $this->restApiPOSTcURL('/plateforme/clientAvis'$data);
  272.         return $results;
  273.     }
  274.     public function listePlateformeAvis($serviceId): array
  275.     {
  276.         $data = [
  277.             "serviceId" => $serviceId,
  278.         ];
  279.         $results $this->restApiPOSTcURL('/plateforme/listePlateformeAvis'$data);
  280.         return $results;
  281.     }
  282.     public function clientOperations($serviceId$clientId): array
  283.     {
  284.         $data = [
  285.             "serviceId" => $serviceId,
  286.             "clientId" => $clientId
  287.         ];
  288.         $results $this->restApiPOSTcURL('/plateforme/clientOperations'$data);
  289.         return $results;
  290.     }
  291.     public function clientProfile($serviceId$clientId$reqToken): array
  292.     {
  293.         $data = [
  294.             "apiToken" => $reqToken,
  295.             "serviceId" => $serviceId,
  296.             "clientId" => $clientId
  297.         ];
  298.         $results $this->restApiPOSTcURLWithOUtToken('/plateforme/clientProfile'$data);
  299.         //$results = $this->restApiPOSTcURL('/plateforme/clientProfile', $data);
  300.         return $results;
  301.     }
  302.     public function clientProfileCheck($serviceId$clientId): array
  303.     {
  304.         $data = [
  305.             "serviceId" => $serviceId,
  306.             "clientId" => $clientId
  307.         ];
  308.         $results $this->restApiPOSTcURL('/plateforme/clientProfile'$data);
  309.         return $results;
  310.     }
  311.     public function clientTransactions($serviceId$clientId): array
  312.     {
  313.         $data = [
  314.             "serviceId" => $serviceId,
  315.             "clientId" => $clientId
  316.         ];
  317.         $results $this->restApiPOSTcURL('/plateforme/clientTransactions'$data);
  318.         return $results;
  319.     }
  320.     public function clientConsultations($serviceId$clientId): array
  321.     {
  322.         $data = [
  323.             "serviceId" => $serviceId,
  324.             "clientId" => $clientId
  325.         ];
  326.         $results $this->restApiPOSTcURL('/plateforme/clientConsultations'$data);
  327.         return $results;
  328.     }
  329.     public function clientInscription($serviceId$parrainID$genre$email$password$firtsname$lastname$phoneNumber): ?array
  330.     {
  331.         $data = [
  332.             "serviceId" => $serviceId,
  333.             "parrainId" => $parrainID,
  334.             "genre" => $genre,
  335.             "username" => $email,
  336.             "password" => $password,
  337.             "nom" => $firtsname,
  338.             "prenom" => $lastname,
  339.             "pays" => "FRANCE",
  340.             "telephone" => $phoneNumber
  341.         ];
  342.         $results $this->restApiPOSTcURL('/plateforme/clientInscription'$data);
  343.         return $results;
  344.     }
  345.     public function socialInscription($serviceId$genre$email$password$firtsname$lastname$country$phoneNumber$social$socialUid): ?array
  346.     {
  347.         $data = [
  348.             "apiKey" =>  $this->apiKey,
  349.             "serviceId" => $serviceId,
  350.             "parrainId" => "0",
  351.             "genre" => $genre,
  352.             "username" => $email,
  353.             "password" => $password,
  354.             "nom" => $firtsname,
  355.             "prenom" => $lastname,
  356.             "pays" => $country,
  357.             "telephone" => $phoneNumber,
  358.             "social" => $social,
  359.             "socialUid" => $socialUid
  360.         ];
  361.         $results $this->restApiPOSTcURL('/plateforme/clientInscription'$data);
  362.         return $results;
  363.     }
  364.     public function clientForgotPassword($serviceId$username): ?array
  365.     {
  366.         $data = [
  367.             "serviceId" => $serviceId,
  368.             "username" => $username
  369.         ];
  370.         $results $this->restApiPOSTcURL('/plateforme/clientForgotPassword'$data);
  371.         return $results;
  372.     }
  373.     public function clientResetPassword($serviceId$username$oldPassword$newPassword$reqToken$limitToken): ?array
  374.     {
  375.         $data = [
  376.             "serviceId" => $serviceId,
  377.             "username" => $username,
  378.             "oldPassword" => $oldPassword,
  379.             "newPassword" => $newPassword
  380.         ];
  381.         $results $this->restApiPOSTcURL('/plateforme/clientResetPassword'$data);
  382.         return $results;
  383.     }
  384.     public function clientInscriptionValidation($serviceId$email$password$code$actif): ?array
  385.     {
  386.         $data = [
  387.             "serviceId" => $serviceId,
  388.             "username" => $email,
  389.             "password" => $password,
  390.             "code" => $code,
  391.             "actif" => $actif
  392.         ];
  393.         $results $this->restApiPOSTcURL('/plateforme/clientInscriptionValidation'$data);
  394.         return $results;
  395.     }
  396.     //Tarifs
  397.     //Tous les tarifs
  398.     public function tarifsPlateforme($serviceId): ?array
  399.     {
  400.         $data = [
  401.             "serviceId" => $serviceId,
  402.         ];
  403.         $results $this->restApiPOSTcURL('/plateforme/tarifsPlateforme'$data);
  404.         return $results;
  405.     }
  406.     public function cbTransaction($data): ?array
  407.     {
  408.         $results $this->restApiPOSTcURL('/plateforme/cbTransaction'$data);
  409.         return $results;
  410.     }
  411.     //Question Mail
  412.     //Test mise a jour lu et repondu
  413.     public function questionsMailMajMessage($serviceId$clientId$complementId$emailId$answered$isRead): ?array
  414.     {
  415.         $data = [
  416.             "serviceId" => $serviceId,
  417.             "clientId" => $clientId,
  418.             "complementId" => $complementId,
  419.             "emailsId" => $emailId,
  420.             "answered" => $answered,
  421.             "isRead" => $isRead
  422.         ];
  423.         $results $this->restApiPOSTcURL('/plateforme/questionsMailMajMessage'$data);
  424.         return $results;
  425.     }
  426.     //Info Mail
  427.     public function questionsMailConseillersListe($serviceId$clientId): ?array
  428.     {
  429.         $data = [
  430.             "serviceId" => $serviceId,
  431.             "clientId" => $clientId
  432.         ];
  433.         $results $this->restApiPOSTcURL('/plateforme/questionsMailConseillersListe'$data);
  434.         return $results;
  435.     }
  436.     //no route found for POST and GET
  437.     public function questionsMailConseiller($serviceId$clientid$complementId): ?array
  438.     {
  439.         $data = [
  440.             "serviceId" => $serviceId,
  441.             "clientId" => $clientid,
  442.             "complementId" => $complementId,
  443.         ];
  444.         $results $this->restApiPOSTcURL('/plateforme/questionsMailConseiller'$data);
  445.         return $results;
  446.     }
  447.     //Envoi de Mail
  448.     public function questionsMailEnvoiMessage($serviceId$clientId$complementId$titre$content$date$cost): ?array
  449.     {
  450.         $data = [
  451.             "serviceId" => $serviceId,
  452.             "clientId" => $clientId,
  453.             "complementId" => $complementId,
  454.             "title" => $titre,
  455.             "content" => $content,
  456.             "date" => $date->format('Y-m-d H:i:s'),
  457.             "client" => "1",
  458.             "answered" => "0",
  459.             "isRead" => "0",
  460.             "messageCost" => $cost
  461.         ];
  462.         $results $this->restApiPOSTcURL('/plateforme/questionsMailEnvoiMessage'$data);
  463.         return $results;
  464.     }
  465.     //Reponse Mail
  466.     public function questionsMailConseillerReponse(): ?array
  467.     {
  468.         $data = [
  469.             "serviceId" => "1010",
  470.             "clientId" => "1006",
  471.             "complementId" => "45",
  472.             "title" => " réponse de test titre",
  473.             "content" => "il va faire beau",
  474.             "date" => "2022-02-22 02:22:22",
  475.             "client" => "0",
  476.             "answered" => "0",
  477.             "isRead" => "0"
  478.         ];
  479.         $results $this->restApiPOSTcURL('/plateforme/questionsMailConseillerReponse'$data);
  480.         return $results;
  481.     }
  482.     //Horoscope
  483.     public function horoscopeJour(): ?array
  484.     {
  485.         $data = [
  486.             "accountId" => $this->accountId
  487.         ];
  488.         $results $this->restApiPOSTcURL('/horoscope/horoscopeJour'$data);
  489.         return $results;
  490.     }
  491.     public function horoscopeHebdomadaire(): ?array
  492.     {
  493.         $data = [
  494.             "accountId" => $this->accountId
  495.         ];
  496.         $results $this->restApiPOSTcURL('/horoscope/horoscopeHebdomadaire'$data);
  497.         return $results;
  498.     }
  499.     public function horoscopeMensuel(): ?array
  500.     {
  501.         $data = [
  502.             "accountId" => $this->accountId
  503.         ];
  504.         $results $this->restApiPOSTcURL('/horoscope/horoscopeMensuel'$data);
  505.         return $results;
  506.     }
  507.     public function request($data$endpoint): ?array
  508.     {
  509.         $results $this->restApiPOSTcURL($endpoint$data);
  510.         return $results;
  511.     }
  512.     public function restApiPOSTcURL($endpoint$data)
  513.     {
  514.         $results = [];
  515.         $this->apiToken $this->session->get('apiToken');
  516.         // ajouter les clés
  517.         $data['apiKey'] =  $this->apiKey;
  518.         $data['apiToken'] =  $this->apiToken;
  519.         $url $this->apiURL $endpoint;
  520.         $dataEncoded json_encode($data);
  521.         $headers = array(
  522.             "Accept: application/json",
  523.             "Content-Type: application/json",
  524.         );
  525.         $curl curl_init($url);
  526.         curl_setopt($curlCURLOPT_POSTtrue);
  527.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  528.         curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
  529.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  530.         curl_setopt($curlCURLOPT_POSTFIELDS$dataEncoded);
  531.         curl_setopt($curlCURLOPT_REFERER$this->baseURL);
  532.         $response curl_exec($curl);
  533.         $curl_error curl_error($curl);
  534.         $curl_errno curl_errno($curl);
  535.         $http_code curl_getinfo($curlCURLINFO_HTTP_CODE);
  536.         curl_close($curl);
  537.         //echo "<br> url:". print_r($url, 1)."<br>";
  538.         if ($response === false) {
  539.             $res =  ['responseCode' => $curl_error'message' => $curl_errno];
  540.             $results[throw new \Exception($res['message'])];
  541.         } else {
  542.             if ($http_code === 200) {
  543.                 $results json_decode($responsetrue);
  544.             } else {
  545.                 $results json_decode($responsetrue);
  546.                 if (!is_array($results)) {
  547.                     $results =  ['responseCode' => $http_code'message' => $results];
  548.                 }
  549.                 if ($http_code === 401) {
  550.                     // Accès non autorisé
  551.                 } else if ($http_code === 403) {
  552.                     // Aucun enregistrement correspondant
  553.                 } else if ($http_code === 404) {
  554.                     // Erreur sauvegarde
  555.                 } else if ($http_code === 409) {
  556.                     // Conflit 
  557.                 } else if ($http_code === 410) {
  558.                     // token n’est plus disponible
  559.                 }
  560.                 //$results [throw new \Exception( $res['message'] )];
  561.             }
  562.         }
  563.         return $results;
  564.     }
  565.     public function restApiPOSTcURLWithOUtToken($endpoint$data)
  566.     //public function restApiPOSTcURL($endpoint, $data)
  567.     {
  568.         $results = [];
  569.         $this->apiToken $this->session->get('apiToken');
  570.         // ajouter les clés
  571.         $data['apiKey'] =  $this->apiKey;
  572.         //$data['apiToken'] =  $this->apiToken;
  573.         $url $this->apiURL $endpoint;
  574.         $dataEncoded json_encode($data);
  575.         $headers = array(
  576.             "Accept: application/json",
  577.             "Content-Type: application/json",
  578.         );
  579.         $curl curl_init($url);
  580.         curl_setopt($curlCURLOPT_POSTtrue);
  581.         curl_setopt($curlCURLOPT_RETURNTRANSFERtrue);
  582.         curl_setopt($curlCURLOPT_SSL_VERIFYPEERfalse);
  583.         curl_setopt($curlCURLOPT_HTTPHEADER$headers);
  584.         curl_setopt($curlCURLOPT_POSTFIELDS$dataEncoded);
  585.         curl_setopt($curlCURLOPT_REFERER$this->baseURL);
  586.         $response curl_exec($curl);
  587.         $curl_error curl_error($curl);
  588.         $curl_errno curl_errno($curl);
  589.         $http_code curl_getinfo($curlCURLINFO_HTTP_CODE);
  590.         curl_close($curl);
  591.         //echo "<br> url:". print_r($url, 1)."<br>";
  592.         if ($response === false) {
  593.             $res =  ['responseCode' => $curl_error'message' => $curl_errno];
  594.             $results[throw new \Exception($res['message'])];
  595.         } else {
  596.             if ($http_code === 200) {
  597.                 $results json_decode($responsetrue);
  598.             } else {
  599.                 $results json_decode($responsetrue);
  600.                 if (!is_array($results)) {
  601.                     $results =  ['responseCode' => $http_code'message' => $results];
  602.                 }
  603.                 if ($http_code === 401) {
  604.                     // Accès non autorisé
  605.                 } else if ($http_code === 403) {
  606.                     // Aucun enregistrement correspondant
  607.                 } else if ($http_code === 404) {
  608.                     // Erreur sauvegarde
  609.                 } else if ($http_code === 409) {
  610.                     // Conflit 
  611.                 } else if ($http_code === 410) {
  612.                     // token n’est plus disponible
  613.                 }
  614.                 //$results [throw new \Exception( $res['message'] )];
  615.             }
  616.         }
  617.         return $results;
  618.     }
  619. }