mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-03 16:09:36 +00:00
Allow to retrieve parameters from conrad
This commit is contained in:
parent
7ab33c859b
commit
3ed62f5cee
1 changed files with 16 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\InfoProviderSystem\Providers;
|
||||
|
||||
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
|
||||
use App\Settings\InfoProviderSystem\ConradSettings;
|
||||
|
|
@ -85,6 +86,20 @@ readonly class ConradProvider implements InfoProviderInterface
|
|||
return null;
|
||||
}
|
||||
|
||||
private function technicalAttributesToParameters(array $technicalAttributes): array
|
||||
{
|
||||
$parameters = [];
|
||||
foreach ($technicalAttributes as $attribute) {
|
||||
if ($attribute['multiValue'] ?? false === true) {
|
||||
throw new \LogicException('Multi value attributes are not supported yet');
|
||||
}
|
||||
$parameters[] = ParameterDTO::parseValueField($attribute['attributeName'],
|
||||
$attribute['values'][0]['value'], $attribute['values'][0]['unit']['name'] ?? null);
|
||||
}
|
||||
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
public function searchByKeyword(string $keyword): array
|
||||
{
|
||||
$url = $this->settings->shopID->getAPIRoot() . self::SEARCH_ENDPOINT . '/'
|
||||
|
|
@ -146,6 +161,7 @@ readonly class ConradProvider implements InfoProviderInterface
|
|||
provider_url: $this->getProductUrl($data['shortProductNumber']),
|
||||
footprint: $this->getFootprintFromTechnicalAttributes($data['productFullInformation']['technicalAttributes'] ?? []),
|
||||
notes: $data['productFullInformation']['description'] ?? null,
|
||||
parameters: $this->technicalAttributesToParameters($data['productFullInformation']['technicalAttributes'] ?? []),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue