mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-20 02:45:01 +02:00
Started working on moving info provider settings with jbtronics/settings-bundle
This commit is contained in:
parent
4a99a5e68f
commit
5a4b7c525b
12 changed files with 358 additions and 11 deletions
|
@ -29,6 +29,7 @@ use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
|||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||
use App\Settings\InfoProviderSystem\LCSCSettings;
|
||||
use Symfony\Component\HttpFoundation\Cookie;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
|
@ -39,7 +40,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
|
||||
public const DISTRIBUTOR_NAME = 'LCSC';
|
||||
|
||||
public function __construct(private readonly HttpClientInterface $lcscClient, private readonly string $currency, private readonly bool $enabled = true)
|
||||
public function __construct(private readonly HttpClientInterface $lcscClient, private readonly LCSCSettings $settings)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -62,7 +63,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
// This provider is always active
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->enabled;
|
||||
return $this->settings->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
{
|
||||
$response = $this->lcscClient->request('GET', self::ENDPOINT_URL . "/product/detail", [
|
||||
'headers' => [
|
||||
'Cookie' => new Cookie('currencyCode', $this->currency)
|
||||
'Cookie' => new Cookie('currencyCode', $this->settings->currency)
|
||||
],
|
||||
'query' => [
|
||||
'productCode' => $id,
|
||||
|
@ -120,7 +121,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
{
|
||||
$response = $this->lcscClient->request('GET', self::ENDPOINT_URL . "/search/global", [
|
||||
'headers' => [
|
||||
'Cookie' => new Cookie('currencyCode', $this->currency)
|
||||
'Cookie' => new Cookie('currencyCode', $this->settings->currency)
|
||||
],
|
||||
'query' => [
|
||||
'keyword' => $term,
|
||||
|
@ -270,7 +271,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
'kr.' => 'DKK',
|
||||
'₹' => 'INR',
|
||||
//Fallback to the configured currency
|
||||
default => $this->currency,
|
||||
default => $this->settings->currency,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue