Skip to content

Commit d137521

Browse files
committed
Allow to configure the reichelt info provider via env vars
1 parent 90e1b80 commit d137521

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

.env

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,18 @@ PROVIDER_OEMSECRETS_SET_PARAM=1
216216
#If unset or set to any other value, no sorting is performed.
217217
PROVIDER_OEMSECRETS_SORT_CRITERIA=C
218218

219+
220+
# Reichelt provider:
221+
# Reichelt.com offers no official API, so this info provider webscrapes the website to extract info
222+
# It could break at any time, use it at your own risk
223+
224+
# We dont require an API key for Reichelt, just set this to 1 to enable Reichelt support
225+
PROVIDER_REICHELT_ENABLED=0
226+
# The country to get prices for (only EUR supported for now)
227+
PROVIDER_REICHELT_COUNTRY=DE
228+
# The language to get results in (en, de, fr, nl, pl, it, es)
229+
PROVIDER_REICHELT_LANGUAGE=en
230+
219231
##################################################################################
220232
# EDA integration related settings
221233
##################################################################################

src/Services/InfoProviderSystem/Providers/ReicheltProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
3030
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
3131
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
32+
use Symfony\Component\DependencyInjection\Attribute\Autowire;
3233
use Symfony\Component\DomCrawler\Crawler;
3334
use Symfony\Contracts\HttpClient\HttpClientInterface;
3435

@@ -39,7 +40,13 @@ class ReicheltProvider implements InfoProviderInterface
3940

4041
private const SEARCH_ENDPOINT = "https://www.reichelt.com/index.html?ACTION=446&LA=0&nbc=1&q=%s";
4142

42-
public function __construct(private readonly HttpClientInterface $client, private readonly bool $enabled = true, private readonly string $language = "en", private readonly string $country = "DE")
43+
public function __construct(private readonly HttpClientInterface $client,
44+
#[Autowire(env: "bool:PROVIDER_REICHELT_ENABLED")]
45+
private readonly bool $enabled = true,
46+
#[Autowire(env: "PROVIDER_REICHELT_LANGUAGE")]
47+
private readonly string $language = "en",
48+
#[Autowire(env: "PROVIDER_REICHELT_COUNTRY")]
49+
private readonly string $country = "DE")
4350
{
4451
}
4552

0 commit comments

Comments
 (0)