Filippo Bertilotti
7 days ago b35a97d09497e3e7fc561bb4a4f435ec7ae8ff4c
app/Vola/Services/VolaFakeHTTPResponder/VolaFakeHTTPResponder.php
@@ -22,8 +22,8 @@
    public function __construct()
    {
        $this->xmlResponses = config('devtools.fake_sso_profiles');
        $this->pathTemplateFolderLegacy = 'response_templates.legacy';
        $this->pathTemplateFolderPicasso = 'response_templates.picasso';
        $this->pathTemplateFolderLegacy = 'vodafone_fake_sso.response_templates.legacy';
        $this->pathTemplateFolderPicasso = 'vodafone_fake_sso.response_templates.picasso';
    }
    public function getModelBasedResponses(Request $request): array
@@ -33,7 +33,10 @@
        if (isset($profile)) {
            $responseContent["data"] = $this->fillXmlResponses($profile, $picassoRequest);
            $uriParts = explode("?", $request->url());
            $method = Str::afterLast($uriParts[0], "/");
            $responseContent["data"] = $this->fillXmlResponses($method, $profile, $picassoRequest);
            $responseContent["status"] = 200;
            \RequestLogger::logProcessedRequest($request, $responseContent, (($picassoRequest) ? 'Picasso' : 'SSO Legacy') );
            return $responseContent;
@@ -48,11 +51,13 @@
    }
    public function fillXMLResponses(string $profile, bool $picasso): string
    public function fillXMLResponses(string $method, string $profile, bool $picasso): string
    {
        $user = VodafoneUser::where(['id' => $profile]);
        $user = VodafoneUser::where(['id' => $profile])->first();
        //arguments
        $viewFolder = ($picasso) ? $this->pathTemplateFolderPicasso : $this->pathTemplateFolderLegacy;
        return view($viewFolder, ['user' => $user])->render(); //views/response_templates/legacy/*.blade.php ?? *.xml
        $view = $viewFolder . "." . $method;
        return view($view, ['user' => $user])->render(); //views/response_templates/legacy/*.blade.php ?? *.xml
    }
    public function getResponses(Request $request, $selectedUser, $picasso = false): string|array
@@ -178,9 +183,9 @@
            case 'no-method-on-user':
                return 'This method response is not set for this user. Check this server database.';
            case 'no-method':
                return 'Couldnt detect requested method. Check your request url.';
                return 'Couldnt identify requested method. Check your request url.';
            default:
                return 'Couldnt detect proper response.';
                return 'Couldnt identify proper response.';
        }
    }