<?php

namespace App\Classes\Modules\Wallets\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;

use App\Classes\Modules\Wallets\DataTransferObjects\WalletObject;
use App\Classes\Modules\Wallets\Services\ListsWallet;
use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
use App\Http\Resources\WalletResource;

use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

class ListWalletLogic extends AbstractControllerLogic
{
    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'List Company Wallet',
            'message' => 'You have successfully list company wallet'
        ];
    }

    /** @var ListWallet  */
   private $listsWallet;

   /** @var CanCreateCompanyWallet */
   private $canListWallet;

    /**
     * CreateWalletLogic constructor.
     * @param CreatesWallet $createsWallet
     * @param GeneratesWalletCode $generatesWalletCode
     * @param CanCreateCompanyWallet $canCreateCompanyWallet
     */
    public function __construct(CanListWallet $canListWallet, ListsWallet $listsWallet)
    {
        $this->canListWallet = $canListWallet;
        $this->listsWallet = $listsWallet;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ErrorException
     */
    public function logic(Request $request) : JsonResponse
    {
        //$this->canListWallet->passes();

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

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