Files
jobifygarden/app/Services/JobApi/DTO/JobData.php
T
2026-04-03 00:23:01 +03:00

62 lines
1.9 KiB
PHP

<?php
namespace App\Services\JobApi\DTO;
use DateTime;
class JobData
{
public function __construct(
public string $externalId,
public string $title,
public string $company,
public string $description,
public ?string $location = null,
public ?float $salaryMin = null,
public ?float $salaryMax = null,
public string $salaryCurrency = 'USD',
public ?string $jobType = null,
public ?string $sourceUrl = null,
public ?string $applyUrl = null,
public ?DateTime $postedAt = null,
public ?DateTime $expiresAt = null,
public bool $remoteAllowed = false,
public ?string $experienceLevel = null,
public ?string $category = null,
public ?array $rawData = null,
) {}
/**
* Convert to array for database insertion
*/
public function toArray(): array
{
return [
'external_id' => $this->externalId,
'title' => $this->title,
'company' => $this->company,
'description' => $this->description,
'location' => $this->location,
'salary_min' => $this->salaryMin,
'salary_max' => $this->salaryMax,
'salary_currency' => $this->salaryCurrency,
'job_type' => $this->jobType,
'source_url' => $this->sourceUrl,
'apply_url' => $this->applyUrl,
'posted_at' => $this->postedAt,
'expires_at' => $this->expiresAt,
'remote_allowed' => $this->remoteAllowed,
'experience_level' => $this->experienceLevel,
];
}
/**
* Generate a fingerprint for deduplication
*/
public function generateFingerprint(): string
{
$data = strtolower(trim($this->title . '|' . $this->company . '|' . $this->location));
return hash('sha256', $data);
}
}