<?php

namespace App\Classes\Modules\Jobs\Services;

use App\Classes\General\Eloquent\AbstractUpdateRecord;
use App\Models\JobResult;
use App\Classes\Modules\Jobs\DataTransferObjects\ListGenericJobObject;

class CreatesJobResult extends AbstractUpdateRecord
{
    /**
     * @param ListGenericJobObject $listGenericJobObject
     * @return \Illuminate\Database\Eloquent\Model
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function execute(ListGenericJobObject $listGenericJobObject)
    {
        $model = new JobResult();
        $model->job_id = $listGenericJobObject->getJobId();
        $model->request_signature = $listGenericJobObject->getRequestSignature();
        $model->result_signature = $listGenericJobObject->getResultSignature();
        $model->url = $listGenericJobObject->getName();

        return $this->handler($model);
    }
}
