<?php

namespace App\Classes\Modules\Steps\Processors;

use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
use App\Classes\Modules\Orders\Processors\UpdatesOrderCurrentStepProcessor;
use App\Classes\Modules\Steps\Services\FetchesSteps;
use App\Classes\Modules\Steps\Services\UpdatesSteps;
use App\Classes\Modules\Orders\Services\UpdatesCurrentStep;
use App\Classes\Modules\Steps\Standards\Rules\CanUpdateStep;
use App\Classes\Modules\Steps\DataTransferObjects\StepsObject;
use App\Classes\ValueObjects\Constants\OrderStatus;
use App\Classes\ValueObjects\Constants\Steps;
use App\Models\Order;
use App\Models\Step;

class UpdateStepsProcessor
{
    private $canUpdateStep;

    private $updatesSteps;

    private $fetchesSteps;

    public function __construct(CanUpdateStep $canUpdateStep, UpdatesSteps $updatesSteps, FetchesSteps $fetchesSteps )
    {
        $this->canUpdateStep = $canUpdateStep;
        $this->updatesSteps = $updatesSteps;
        $this->fetchesSteps = $fetchesSteps;
    }

    public function execute(string $currentStep){

        $orderStepsObject = new StepsObject(0,$currentStep, 0, 0, 1, 1, null, 0, null);

        $this->canUpdateStep->passes($orderStepsObject);

        $orderSteps = $this->fetchesSteps->execute(['reference'=>$currentStep]);

        $this->updatesSteps->execute($orderSteps, $orderStepsObject);

    }
}
