<?php

namespace App\Classes\Modules\Accounting\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounting\Services\ListsBankStatementDetails;
use App\Http\Resources\BankStatementDetailResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListBankStatementDetailsLogic extends AbstractControllerLogic
{

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


    /** @var ListsBankStatementDetails */
    private $listsBankStatementDetails;

    /**
     * ListBankStatementDetailsLogic constructor.
     * @param ListsBankStatementDetails $listsBankStatementDetails
     */
    public function __construct(ListsBankStatementDetails $listsBankStatementDetails)
    {
        $this->listsBankStatementDetails = $listsBankStatementDetails;
    }


    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ErrorException
     */
    public function logic(Request $request) : JsonResponse
    {
        $query = $this->listsBankStatementDetails->execute($this->listsBankStatementDetails->deserializeFilters($request->input('filters')));

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

}
