<?php

namespace App\Classes\Modules\Documents\Processors;

use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
use App\Classes\Modules\Documents\Services\CreatesDocument;
use App\Classes\Modules\Documents\Services\CreatesFiles;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Models\Document;
use Illuminate\Http\Request;
use App\Models\QAUserAnswerSelected;

class UploadDocumentForHelpMenuProcessor
{

    /** @var CreatesDocument */
    private $createsDocument;

    /** @var CreatesFiles */
    private $createsFiles;

    /**
     * UploadDocumentForHelpMenuProcessor constructor.
     * @param CreatesDocument $createsDocument
     * @param CreatesFiles $createsFiles
     */
    public function __construct(CreatesDocument $createsDocument, CreatesFiles $createsFiles)
    {
        $this->createsDocument = $createsDocument;
        $this->createsFiles = $createsFiles;
    }


    /**
     * @param $filesUpload
     * @param QAUserAnswerSelected qaUserAnswerSelected
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute($filesUpload, QAUserAnswerSelected $qaUserAnswerSelected) {
        $object = new DocumentObject("HELP_MENU", $filesUpload,
            '123456', ApprovalStatus::PENDING_VERIFICATION, 'help_menu'); //cief todo: 123456 cannot be hardcoded

        /** @var Document $document */
        $document = $this->createsDocument->execute($qaUserAnswerSelected, $object);

        $result = $this->createsFiles->execute($document, $object);
        return $result;
    }

}
