Skip to content

Commit 86d3f87

Browse files
committed
[Digikey provider] Do not try to interpret certain parameters (like packages) as numbers
This fixes issue #682
1 parent ddd7252 commit 86d3f87

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Services/InfoProviderSystem/Providers/DigikeyProvider.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class DigikeyProvider implements InfoProviderInterface
4545

4646
private readonly HttpClientInterface $digikeyClient;
4747

48+
/**
49+
* A list of parameter IDs, that are always assumed as text only and will never be converted to a numerical value.
50+
* This allows to fix issues like #682, where the "Supplier Device Package" was parsed as a numerical value.
51+
*/
52+
private const TEXT_ONLY_PARAMETERS = [
53+
1291, //Supplier Device Package
54+
39246, //Package / Case
55+
];
4856

4957
public function __construct(HttpClientInterface $httpClient, private readonly OAuthTokenManager $authTokenManager,
5058
private readonly string $currency, private readonly string $clientId,
@@ -214,7 +222,12 @@ private function parametersToDTOs(array $parameters, string|null &$footprint_nam
214222
continue;
215223
}
216224

217-
$results[] = ParameterDTO::parseValueIncludingUnit($parameter['Parameter'], $parameter['Value']);
225+
//If the parameter was marked as text only, then we do not try to parse it as a numerical value
226+
if (in_array($parameter['ParameterId'], self::TEXT_ONLY_PARAMETERS, true)) {
227+
$results[] = new ParameterDTO(name: $parameter['Parameter'], value_text: $parameter['Value']);
228+
} else { //Otherwise try to parse it as a numerical value
229+
$results[] = ParameterDTO::parseValueIncludingUnit($parameter['Parameter'], $parameter['Value']);
230+
}
218231
}
219232

220233
return $results;

0 commit comments

Comments
 (0)