<?php

namespace App\Classes\Modules\Orders\ControllersLogic;

use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Orders\Processors\ApproveChangeOrderAddressProcessor;
use App\Http\Resources\AddressResource;
use App\Http\Resources\OrderResource;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;

class ApproveChangeOrderAddressLogic extends AbstractControllerLogic
{
    /**
     * @return array
     */
    protected function notification(): array
    {
        return [
            'title' => 'Change Order Address Approval',
            'message' => 'You have successfully change the order address'
        ];
    }

    /** @var ApproveChangeOrderAddressProcessor */
    private $approveChangeOrderAddressProcessor;

    /**
     * ApproveChangeOrderAddressLogic constructor.
     * @param ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor
     */

    public function __construct(ApproveChangeOrderAddressProcessor $approveChangeOrderAddressProcessor)
    {
        $this->approveChangeOrderAddressProcessor = $approveChangeOrderAddressProcessor;
    }

    public function logic(Request $request): JsonResponse
    {
        $address = $this->approveChangeOrderAddressProcessor->execute($request);

        return $this->resourceResponse(new AddressResource($address));
    }
}
