mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 12:54:30 +02:00
Disable GET_GROSS_PRICES option for TME info provider when using private key. Otherwise we receive an error.
This fixes issue #838
This commit is contained in:
parent
1e19ff24ba
commit
fd7a0156bc
3 changed files with 22 additions and 4 deletions
|
@ -50,6 +50,16 @@ class TMEClient
|
|||
return $this->token !== '' && $this->secret !== '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the client is using a private (account related token) instead of a deprecated anonymous token
|
||||
* to authenticate with TME.
|
||||
* @return bool
|
||||
*/
|
||||
public function isUsingPrivateToken(): bool
|
||||
{
|
||||
//Private tokens are longer than anonymous ones (50 instead of 45 characters)
|
||||
return strlen($this->token) > 45;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the signature for the given action and parameters.
|
||||
|
|
|
@ -36,12 +36,19 @@ class TMEProvider implements InfoProviderInterface
|
|||
|
||||
private const VENDOR_NAME = 'TME';
|
||||
|
||||
/** @var bool If true, the prices are gross prices. If false, the prices are net prices. */
|
||||
private readonly bool $get_gross_prices;
|
||||
|
||||
public function __construct(private readonly TMEClient $tmeClient, private readonly string $country,
|
||||
private readonly string $language, private readonly string $currency,
|
||||
/** @var bool If true, the prices are gross prices. If false, the prices are net prices. */
|
||||
private readonly bool $get_gross_prices)
|
||||
bool $get_gross_prices)
|
||||
{
|
||||
|
||||
//If we have a private token, set get_gross_prices to false, as it is automatically determined by the account type then
|
||||
if ($this->tmeClient->isUsingPrivateToken()) {
|
||||
$this->get_gross_prices = false;
|
||||
} else {
|
||||
$this->get_gross_prices = $get_gross_prices;
|
||||
}
|
||||
}
|
||||
|
||||
public function getProviderInfo(): array
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue