<?php

namespace App\Classes\Modules\KeyValuePairs\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\KeyValuePairs\Services\ListsKeyValuePairs;
use App\Classes\Modules\ServiceTypes\Standards\Rules\CanListServiceTypes;
use App\Http\Resources\LockResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListLocksLogic extends AbstractControllerLogic
{

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

    // /** @var CanListServiceTypes */
    // private $canListServiceTypes;

    /** @var ListsKeyValuePairs */
    private $listsKeyValuePairs;

    /**
     * ListLocksLogic constructor.
     * @param CanListServiceTypes $canListServiceTypes
     * @param ListsKeyValuePairs $listsKeyValuePairs
     */
    public function __construct(CanListServiceTypes $canListServiceTypes, ListsKeyValuePairs $listsKeyValuePairs)
    {
        // $this->canListServiceTypes = $canListServiceTypes;
        $this->listsKeyValuePairs = $listsKeyValuePairs;
    }


    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function logic(Request $request) : JsonResponse
    {
        // cief todo: 110 - CanListLocks

        // $this->canListServiceTypes->passes();

        $query = $this->listsKeyValuePairs->execute($this->listsKeyValuePairs->deserializeFilters($request->input('filters')));

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

    }

}
