<?php

namespace App\Classes\Modules\Companies\ControllersLogic;


use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\Companies\Processors\CreateCompanyProcessor;
use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\BusinessType;
use App\Classes\ValueObjects\Constants\CompanyType;
use App\Http\Resources\CompanyResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class CreateCompanyLogic extends AbstractControllerLogic
{
    /**
     * CreateCompanyLogic constructor.
     * @param CreateCompanyProcessor $createCompanyProcessor
     */
    public function __construct(CreateCompanyProcessor $createCompanyProcessor)
    {
        $this->createCompanyProcessor = $createCompanyProcessor;
    }

    /**
     * @return array
     */
    protected function notification():array {
        return [
            'title' => 'Created Company',
            'message' => 'You have successfully created a new Company'
        ];
    }

    /** @var CreateCompanyProcessor */
    private $createCompanyProcessor;


    /**
     * @param Request $request
     * @return JsonResponse
     * @throws \App\Classes\Exceptions\AccessForbiddenException
     * @throws \App\Classes\Exceptions\MalformedRequestException
     * @throws \App\Classes\Exceptions\RequestValidationException
     */
    public function logic(Request $request) : JsonResponse
    {
        $company = $this->createCompanyProcessor->execute($request, BusinessType::CURRENCY_VENDOR, CompanyType::COMPANY_BUSINESS, ApprovalStatus::APPROVED);
        return $this->resourceResponse(new CompanyResource($company));
    }

}