<?php

namespace App\Classes\Modules\Jobs\Services;

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

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

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