mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 18:34:32 +02:00
[Digikey provider] Do not try to interpret certain parameters (like packages) as numbers
This fixes issue #682
This commit is contained in:
parent
ddd7252051
commit
86d3f87694
1 changed files with 14 additions and 1 deletions
|
@ -45,6 +45,14 @@ class DigikeyProvider implements InfoProviderInterface
|
|||
|
||||
private readonly HttpClientInterface $digikeyClient;
|
||||
|
||||
/**
|
||||
* A list of parameter IDs, that are always assumed as text only and will never be converted to a numerical value.
|
||||
* This allows to fix issues like #682, where the "Supplier Device Package" was parsed as a numerical value.
|
||||
*/
|
||||
private const TEXT_ONLY_PARAMETERS = [
|
||||
1291, //Supplier Device Package
|
||||
39246, //Package / Case
|
||||
];
|
||||
|
||||
public function __construct(HttpClientInterface $httpClient, private readonly OAuthTokenManager $authTokenManager,
|
||||
private readonly string $currency, private readonly string $clientId,
|
||||
|
@ -214,8 +222,13 @@ class DigikeyProvider implements InfoProviderInterface
|
|||
continue;
|
||||
}
|
||||
|
||||
//If the parameter was marked as text only, then we do not try to parse it as a numerical value
|
||||
if (in_array($parameter['ParameterId'], self::TEXT_ONLY_PARAMETERS, true)) {
|
||||
$results[] = new ParameterDTO(name: $parameter['Parameter'], value_text: $parameter['Value']);
|
||||
} else { //Otherwise try to parse it as a numerical value
|
||||
$results[] = ParameterDTO::parseValueIncludingUnit($parameter['Parameter'], $parameter['Value']);
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue