mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 12:54:30 +02:00
Added an TME data provider
This commit is contained in:
parent
0cb46039dd
commit
f9fdae9de9
7 changed files with 397 additions and 1 deletions
|
@ -41,7 +41,22 @@ class ParameterDTO
|
|||
public static function parseValueField(string $name, string|float $value, ?string $unit = null, ?string $symbol = null, ?string $group = null): self
|
||||
{
|
||||
if (is_float($value) || is_numeric($value)) {
|
||||
return new self($name, value_typ: (float) $value, unit: $unit, symbol: $symbol);
|
||||
return new self($name, value_typ: (float) $value, unit: $unit, symbol: $symbol, group: $group);
|
||||
}
|
||||
|
||||
return new self($name, value_text: $value, unit: $unit, symbol: $symbol, group: $group);
|
||||
}
|
||||
|
||||
public static function parseValueIncludingUnit(string $name, string|float $value, ?string $symbol = null, ?string $group = null): self
|
||||
{
|
||||
if (is_float($value) || is_numeric($value)) {
|
||||
return new self($name, value_typ: (float) $value, symbol: $symbol, group: $group);
|
||||
}
|
||||
|
||||
$unit = null;
|
||||
if (preg_match('/^(?<value>[0-9.]+)\s*(?<unit>[a-zA-Z]+)$/', $value, $matches)) {
|
||||
$value = $matches['value'];
|
||||
$unit = $matches['unit'];
|
||||
}
|
||||
|
||||
return new self($name, value_text: $value, unit: $unit, symbol: $symbol, group: $group);
|
||||
|
|
|
@ -33,6 +33,7 @@ class PartDetailDTO extends SearchResultDTO
|
|||
string $provider_id,
|
||||
string $name,
|
||||
string $description,
|
||||
?string $category = null,
|
||||
?string $manufacturer = null,
|
||||
?string $mpn = null,
|
||||
?string $preview_image_url = null,
|
||||
|
@ -46,12 +47,15 @@ class PartDetailDTO extends SearchResultDTO
|
|||
public readonly ?array $parameters = null,
|
||||
/** @var PurchaseInfoDTO[]|null */
|
||||
public readonly ?array $vendor_infos = null,
|
||||
/** The mass of the product in grams */
|
||||
public readonly ?float $mass = null,
|
||||
) {
|
||||
parent::__construct(
|
||||
provider_key: $provider_key,
|
||||
provider_id: $provider_id,
|
||||
name: $name,
|
||||
description: $description,
|
||||
category: $category,
|
||||
manufacturer: $manufacturer,
|
||||
mpn: $mpn,
|
||||
preview_image_url: $preview_image_url,
|
||||
|
|
|
@ -36,6 +36,8 @@ class SearchResultDTO
|
|||
public readonly string $name,
|
||||
/** @var string A short description of the part */
|
||||
public readonly string $description,
|
||||
/** @var string|null The category the distributor assumes for the part */
|
||||
public readonly ?string $category = null,
|
||||
/** @var string|null The manufacturer of the part */
|
||||
public readonly ?string $manufacturer = null,
|
||||
/** @var string|null The manufacturer part number */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue