feat: add Snipe-IT asset synchronization
This commit is contained in:
62
app/Integrations/SnipeIt/Data/AssetData.php
Normal file
62
app/Integrations/SnipeIt/Data/AssetData.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Integrations\SnipeIt\Data;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
final readonly class AssetData
|
||||
{
|
||||
public function __construct(
|
||||
public int $snipeAssetId,
|
||||
public string $assetTag,
|
||||
public string $name,
|
||||
public ?string $serial,
|
||||
public ?int $modelId,
|
||||
public ?string $modelName,
|
||||
public ?int $categoryId,
|
||||
public ?string $categoryName,
|
||||
public ?string $manufacturer,
|
||||
public ?int $statusId,
|
||||
public ?string $statusName,
|
||||
public ?int $locationId,
|
||||
public ?string $locationName,
|
||||
public bool $requestable,
|
||||
public ?string $assignedType,
|
||||
public ?int $assignedId,
|
||||
public ?string $imageUrl,
|
||||
public ?CarbonImmutable $sourceUpdatedAt,
|
||||
) {}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
public function toModelAttributes(): array
|
||||
{
|
||||
return [
|
||||
'snipe_asset_id' => $this->snipeAssetId,
|
||||
'asset_tag' => $this->assetTag,
|
||||
'name' => $this->name,
|
||||
'serial' => $this->serial,
|
||||
'model_id' => $this->modelId,
|
||||
'model_name' => $this->modelName,
|
||||
'category_id' => $this->categoryId,
|
||||
'category_name' => $this->categoryName,
|
||||
'manufacturer' => $this->manufacturer,
|
||||
'status_id' => $this->statusId,
|
||||
'status_name' => $this->statusName,
|
||||
'location_id' => $this->locationId,
|
||||
'location_name' => $this->locationName,
|
||||
'requestable' => $this->requestable,
|
||||
'assigned_type' => $this->assignedType,
|
||||
'assigned_id' => $this->assignedId,
|
||||
'image_url' => $this->imageUrl,
|
||||
'source_updated_at' => $this->sourceUpdatedAt,
|
||||
];
|
||||
}
|
||||
|
||||
public function contentHash(): string
|
||||
{
|
||||
$attributes = $this->toModelAttributes();
|
||||
$attributes['source_updated_at'] = $this->sourceUpdatedAt?->toIso8601String();
|
||||
|
||||
return hash('sha256', json_encode($attributes, JSON_THROW_ON_ERROR | JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
16
app/Integrations/SnipeIt/Data/HardwarePage.php
Normal file
16
app/Integrations/SnipeIt/Data/HardwarePage.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Integrations\SnipeIt\Data;
|
||||
|
||||
final readonly class HardwarePage
|
||||
{
|
||||
/**
|
||||
* @param list<array<string, mixed>> $rows
|
||||
*/
|
||||
public function __construct(
|
||||
public int $total,
|
||||
public int $offset,
|
||||
public int $limit,
|
||||
public array $rows,
|
||||
) {}
|
||||
}
|
||||
Reference in New Issue
Block a user