<?php

namespace App\Classes\Modules\Accounting\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Accounting\Services\ListsBankStatementDetails;
use App\Classes\Modules\Accounting\Services\ListsBankStatementTransactions;
use App\Http\Resources\BankStatementTransactionResource;
use App\Models\StatementTransaction;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListBankStatementTransactionsLogic extends AbstractControllerLogic
{


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


    /** @var ListsBankStatementTransactions */
    private $listsBankStatementTransactions;

    /**
     * @param ListsBankStatementTransactions $listsBankStatementTransactions
     */
    public function __construct(ListsBankStatementTransactions $listsBankStatementTransactions)
    {
        $this->listsBankStatementTransactions = $listsBankStatementTransactions;
    }

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

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

}
