File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
src/Services/InfoProviderSystem/Providers Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 2323
2424namespace App \Services \InfoProviderSystem \Providers ;
2525
26+ use App \Services \InfoProviderSystem \DTOs \ParameterDTO ;
2627use App \Services \InfoProviderSystem \DTOs \PartDetailDTO ;
2728use App \Services \InfoProviderSystem \DTOs \SearchResultDTO ;
2829use 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
You can’t perform that action at this time.
0 commit comments