<?php

namespace App\Classes\Modules\Orders\ControllersLogic;

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

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

    /** @var RequestChangeOrderAddressProcessor */
    private $requestChangeOrderAddressProcessor;

    /**
     * RequestChangeOrderAddressLogic constructor.
     * @param RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor
     */

    public function __construct(RequestChangeOrderAddressProcessor $requestChangeOrderAddressProcessor)
    {
        $this->requestChangeOrderAddressProcessor = $requestChangeOrderAddressProcessor;
    }

    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */

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

        return $this->resourceResponse(new OrderResource($order));
    }
}
