<?php

namespace App\Classes\Modules\PerfexCRM\Processors;

use App\Classes\Modules\PerfexCRM\DataTransferObjects\CreateTaskPerfexCRMObject;
use App\Classes\Jobs\CreatePerfexCRMSingleTask;
use App\Classes\ValueObjects\Constants\PerfexCRMTaskPriority;
use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Models\Company;

class NewLeadTaskToPerfexCRMProcessor
{
    /**
     * @param Company $company
     * @return true
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(Company $company)
    {
        $employee = $company->employees()->first();
        $contactEmail = $employee->email;

        $createTaskPerfexCRMObject = new CreateTaskPerfexCRMObject(
            $contactEmail,
            PerfexCRMTasks::TASK_IDENTIFICATION_1['name'],
            PerfexCRMTasks::TASK_IDENTIFICATION_1['description'],
            "",
            "",
            "",
            "",
            "",
            PerfexCRMTasks::TASK_IDENTIFICATION_1['status'],
            PerfexCRMTasks::TASK_IDENTIFICATION_1['department'],
            PerfexCRMTaskPriority::DEFAULT,
            "0",
            0
        );

        CreatePerfexCRMSingleTask::dispatch($createTaskPerfexCRMObject);
        return true;
    }

}
