Skip to content

Commit 3ed62f5

Browse files
committed
Allow to retrieve parameters from conrad
1 parent 7ab33c8 commit 3ed62f5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/Services/InfoProviderSystem/Providers/ConradProvider.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
namespace App\Services\InfoProviderSystem\Providers;
2525

26+
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
2627
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
2728
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
2829
use App\Settings\InfoProviderSystem\ConradSettings;
@@ -85,6 +86,20 @@ private function getFootprintFromTechnicalAttributes(array $technicalDetails): ?
8586
return null;
8687
}
8788

89+
private function technicalAttributesToParameters(array $technicalAttributes): array
90+
{
91+
$parameters = [];
92+
foreach ($technicalAttributes as $attribute) {
93+
if ($attribute['multiValue'] ?? false === true) {
94+
throw new \LogicException('Multi value attributes are not supported yet');
95+
}
96+
$parameters[] = ParameterDTO::parseValueField($attribute['attributeName'],
97+
$attribute['values'][0]['value'], $attribute['values'][0]['unit']['name'] ?? null);
98+
}
99+
100+
return $parameters;
101+
}
102+
88103
public function searchByKeyword(string $keyword): array
89104
{
90105
$url = $this->settings->shopID->getAPIRoot() . self::SEARCH_ENDPOINT . '/'
@@ -146,6 +161,7 @@ public function getDetails(string $id): PartDetailDTO
146161
provider_url: $this->getProductUrl($data['shortProductNumber']),
147162
footprint: $this->getFootprintFromTechnicalAttributes($data['productFullInformation']['technicalAttributes'] ?? []),
148163
notes: $data['productFullInformation']['description'] ?? null,
164+
parameters: $this->technicalAttributesToParameters($data['productFullInformation']['technicalAttributes'] ?? []),
149165
);
150166
}
151167

0 commit comments

Comments
 (0)