<?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\Services\FetchesWallet;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Classes\ValueObjects\Constants\ApprovalStatus;

use App\Classes\Modules\Wallets\Standards\Rules\CanListWallet;
use App\Http\Resources\WalletResource;
use App\Classes\Modules\Transactions\Processors\UpdateWalletTransactionProcessor;

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

class UpdateStatusWalletLogic extends AbstractControllerLogic
{
    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Update Status Transaction Company Wallet',
            'message' => 'You have successfully status transaction company wallet'
        ];
    }

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

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

    /** @var UpdateWalletTransactionProcessor */
    private $updateWalletTransactionProcessor;

    /**
     * CreateWalletLogic constructor.
     * @param CreatesWallet $createsWallet
     * @param GeneratesWalletCode $generatesWalletCode
     * @param CanCreateCompanyWallet $canCreateCompanyWallet
     */
    public function __construct(FetchesWallet $fetchesWallet, UpdateWalletTransactionProcessor $updateWalletTransactionProcessor)
    {
        $this->fetchesWallet = $fetchesWallet;
        $this->updateWalletTransactionProcessor = $updateWalletTransactionProcessor;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws ErrorException
     */
    public function logic(Request $request) : JsonResponse
    {
        $status = ($request->route('status')=='approve') ? 2 : 4;

        $wallet = $this->updateWalletTransactionProcessor->execute($request->route('transaction_id'), $status);

        return $this->resourceResponse(new WalletResource($wallet));

    }
}
