From 68b84d1f652aae4644c2dde96d9bb99e358294e8 Mon Sep 17 00:00:00 2001
From: davide.cucurnia@vola.it <davide.cucurnia@vola.it>
Date: Wed, 07 Feb 2024 10:18:30 +0100
Subject: [PATCH] struttura di base versione model based

---
 app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php b/app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php
index 8d7917b..f9ac83b 100644
--- a/app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php
+++ b/app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php
@@ -21,7 +21,12 @@
         $this->sso_XML = config('devtools.fake_sso_profiles');
     }
 
-    public function getResponses(Request $request, $testUser, $picasso = false)
+    public function getModelBasedResponses($request, $testUser, $picasso = false): string|array
+    {
+        return 'test. funziono ma le logiche non sono state ancora implementate';
+    }
+
+    public function getResponses(Request $request, $testUser, $picasso = false): string|array
     {
             $uriParts = explode("?", $request->url());
             $methodUri = Str::afterLast($uriParts[0], "/");
@@ -45,13 +50,13 @@
             }
     }
 
-    public function getLoggedPicasso($testUser)
+    public function getLoggedPicasso($testUser): string|array
     {
         if (isset($_COOKIE["SSOSESSIONID"])) {
             if (!isset($this->sso_XML[$testUser]["picasso"])) {
                 return 'this picasso user doesnt exist. check your SSOSESSIONID value';
             }
-            $sampleResponseString = Arr::first($this->sso_XML[$testUser]["picasso"]["getWebcustomerInformation"]["parametri"]["t"] );
+            $sampleResponseString = Arr::first($this->sso_XML[$testUser]["picasso"]["getWebcustomerInformation"]["parametri"]["k"] );
             $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString);
             $resp = [
                 'logged' => (string) 1,
@@ -70,13 +75,13 @@
         return $xml;
     }
 
-    public function getLoggedLegacy($testUser)
+    public function getLoggedLegacy($testUser): string|array
     {
         if (isset($_COOKIE["CAuthCookie"])) {
             if (!isset($this->sso_XML[$testUser]["sso"])) {
                 return 'this user doesnt exist. check your CAuthCookie value';
             }
-            $sampleResponseString = Arr::first($this->sso_XML[$testUser]["sso"]["getWebcustomerInformation"]["parametri"]["t"] );
+            $sampleResponseString = Arr::first($this->sso_XML[$testUser]["sso"]["getWebcustomerInformation"]["parametri"]["k"] );
             $sampleResponseObject = Utils::convertXMLStrToArray($sampleResponseString);
             $resp = [
                 'logged' => (string) 1,
@@ -95,7 +100,7 @@
         return $xml;
     }
 
-    public function getResponseArgumentsBased($userMethods, $methodUri, $reqParams = [])
+    public function getResponseArgumentsBased($userMethods, $methodUri, $reqParams = []): string
     {
         $method = $userMethods[$methodUri];
         $params = $method["parametri"];
@@ -103,7 +108,7 @@
         //assumo che se la richiesta sia arrivata fin qui abbia tutti i mandatory nel url
         foreach ($reqParams as $key => $value) {
             //verifico se il metodo dell' utente ha la chiave che sto cercando
-            if ($key != "t" && isset($params[$key])) {
+            if ($key != "k" && isset($params[$key])) {
                 if (array_key_exists($value, $params[$key])) {
                     \Log::channel('requests')->debug("[VolaFakeHTTPResponder] Inserisco xml specifico per key:$key ,params: " . print_r($params, 1) . " key: $key, value: $value, xml: " . print_r($params[$key][$value], 1));
                     return $params[$key][$value];
@@ -111,7 +116,7 @@
             }
         }
         //xml di default (se richiede parametri di default conterrĂ  errori)
-        $defaultResponse = Arr::first($params["t"]);
+        $defaultResponse = Arr::first($params["k"]);
         \Log::channel('requests')->debug("[VolaFakeHTTPResponder] Inserisco xml di default $defaultResponse per method: $methodUri");
         return $defaultResponse;
     }
@@ -122,7 +127,7 @@
      * @param bool $picasso
      * @return array|mixed
      */
-    private function getUserResponseSet(mixed $testUser, bool $picasso)
+    private function getUserResponseSet(mixed $testUser, bool $picasso): array
     {
         if ($picasso) {
             $userMethods = $this->sso_XML[$testUser]["picasso"] ?? [];

--
Gitblit v1.8.0