File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed
src/Services/InfoProviderSystem/Providers Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,8 @@ PROVIDER_TME_CURRENCY=EUR
143143PROVIDER_TME_LANGUAGE = en
144144# The country to get results for
145145PROVIDER_TME_COUNTRY = DE
146- # Set this to 1 to get gross prices (including VAT) instead of net prices
146+ # [DEPRECATED] Set this to 1 to get gross prices (including VAT) instead of net prices
147+ # With private API keys, this option cannot be used anymore is ignored by Part-DB. The VAT inclusion depends on your TME account settings.
147148PROVIDER_TME_GET_GROSS_PRICES = 1
148149
149150# Octopart / Nexar Provider:
Original file line number Diff line number Diff line change @@ -50,6 +50,16 @@ public function isUsable(): bool
5050 return $ this ->token !== '' && $ this ->secret !== '' ;
5151 }
5252
53+ /**
54+ * Returns true if the client is using a private (account related token) instead of a deprecated anonymous token
55+ * to authenticate with TME.
56+ * @return bool
57+ */
58+ public function isUsingPrivateToken (): bool
59+ {
60+ //Private tokens are longer than anonymous ones (50 instead of 45 characters)
61+ return strlen ($ this ->token ) > 45 ;
62+ }
5363
5464 /**
5565 * Generates the signature for the given action and parameters.
Original file line number Diff line number Diff line change @@ -36,12 +36,19 @@ class TMEProvider implements InfoProviderInterface
3636
3737 private const VENDOR_NAME = 'TME ' ;
3838
39+ /** @var bool If true, the prices are gross prices. If false, the prices are net prices. */
40+ private readonly bool $ get_gross_prices ;
41+
3942 public function __construct (private readonly TMEClient $ tmeClient , private readonly string $ country ,
4043 private readonly string $ language , private readonly string $ currency ,
41- /** @var bool If true, the prices are gross prices. If false, the prices are net prices. */
42- private readonly bool $ get_gross_prices )
44+ bool $ get_gross_prices )
4345 {
44-
46+ //If we have a private token, set get_gross_prices to false, as it is automatically determined by the account type then
47+ if ($ this ->tmeClient ->isUsingPrivateToken ()) {
48+ $ this ->get_gross_prices = false ;
49+ } else {
50+ $ this ->get_gross_prices = $ get_gross_prices ;
51+ }
4552 }
4653
4754 public function getProviderInfo (): array
You can’t perform that action at this time.
0 commit comments