<?php

namespace App\Classes\Modules\PackingLists\ControllersLogic\Containers;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\Containers\ListsContainers;
use App\Classes\Modules\PackingLists\Standards\Rules\Containers\CanListContainers;
use App\Classes\Modules\PackingLists\Processors\FetchInboundCustomClearedProcessor;

use App\Http\Resources\ContainerResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class InboundCustomClearedLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Retrieved Containers',
            'message' => 'You have successfully retrieved a list of Containers'
        ];
    }

    /** @var CanListContainers */
    private $canListContainers;

    /** @var ListsContainers */
    private $listsContainers;

    private $fetchInboundCustomCleared;

    /**
     * ListContainersLogic constructor.
     * @param CanListContainers $canListContainers
     * @param ListsContainers $listsContainers
     */
    public function __construct(CanListContainers $canListContainers, ListsContainers $listsContainers, FetchInboundCustomClearedProcessor $fetchInboundCustomCleared)
    {
        $this->canListContainers = $canListContainers;
        $this->listsContainers = $listsContainers;
        $this->fetchInboundCustomCleared = $fetchInboundCustomCleared;
    }


    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ErrorException
     */
    public function logic(Request $request) : JsonResponse
    {

        $query = $this->fetchInboundCustomCleared->execute();

        return $this->collectionResponse(ContainerResource::collection($query));

    }
}
