<?php

namespace App\Classes\Modules\Transactions\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Transactions\Processors\UpdateRefundTransactionStatusProcessor;

class UpdateRefundTransactionStatusLogic extends AbstractControllerLogic
{

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Updated Refund Transaction',
            'message' => 'You have successfully updated a refund transaction'
        ];
    }

    /** @var UpdateRefundTransactionStatusProcessor */
    private $updateRefundTransactionStatusProcessor;

    /**
     * UpdateRefundTransactionStatusLogic constructor.
     * @param UpdateRefundTransactionStatusProcessor $updateRefundTransactionStatusProcessor
     */
    public function __construct(UpdateRefundTransactionStatusProcessor $updateRefundTransactionStatusProcessor)
    {
        $this->updateRefundTransactionStatusProcessor = $updateRefundTransactionStatusProcessor;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function logic(Request $request) : JsonResponse
    {
        // $this->canUpdateRefundTransactionStatus->passes();

        $this->updateRefundTransactionStatusProcessor->execute($request->route('id'), $request->route('status'), $request->input('refundRemark') ?? "");

        return $this->response([]);
    }
}
