2929use App \Services \InfoProviderSystem \DTOs \PriceDTO ;
3030use App \Services \InfoProviderSystem \DTOs \PurchaseInfoDTO ;
3131use App \Services \InfoProviderSystem \DTOs \SearchResultDTO ;
32+ use App \Settings \InfoProviderSystem \ReicheltSettings ;
3233use Symfony \Component \DependencyInjection \Attribute \Autowire ;
3334use Symfony \Component \DomCrawler \Crawler ;
3435use Symfony \Contracts \HttpClient \HttpClientInterface ;
@@ -39,16 +40,7 @@ class ReicheltProvider implements InfoProviderInterface
3940 public const DISTRIBUTOR_NAME = "Reichelt " ;
4041
4142 public function __construct (private readonly HttpClientInterface $ client ,
42- #[Autowire(env: "bool:PROVIDER_REICHELT_ENABLED " )]
43- private readonly bool $ enabled = true ,
44- #[Autowire(env: "PROVIDER_REICHELT_LANGUAGE " )]
45- private readonly string $ language = "en " ,
46- #[Autowire(env: "PROVIDER_REICHELT_COUNTRY " )]
47- private readonly string $ country = "DE " ,
48- #[Autowire(env: "PROVIDER_REICHELT_INCLUDE_VAT " )]
49- private readonly bool $ includeVAT = false ,
50- #[Autowire(env: "PROVIDER_REICHELT_CURRENCY " )]
51- private readonly string $ currency = "EUR " ,
43+ private readonly ReicheltSettings $ settings ,
5244 )
5345 {
5446 }
@@ -70,7 +62,7 @@ public function getProviderKey(): string
7062
7163 public function isActive (): bool
7264 {
73- return $ this ->enabled ;
65+ return $ this ->settings -> enabled ;
7466 }
7567
7668 public function searchByKeyword (string $ keyword ): array
@@ -121,8 +113,8 @@ public function getDetails(string $id): PartDetailDTO
121113 sprintf (
122114 'https://www.reichelt.com/?ACTION=514&id=74&article=%s&LANGUAGE=%s&CCOUNTRY=%s ' ,
123115 $ id ,
124- strtoupper ($ this ->language ),
125- strtoupper ($ this ->country )
116+ strtoupper ($ this ->settings -> language ),
117+ strtoupper ($ this ->settings -> country )
126118 )
127119 );
128120 $ json = $ response ->toArray ();
@@ -133,8 +125,8 @@ public function getDetails(string $id): PartDetailDTO
133125
134126 $ response = $ this ->client ->request ('GET ' , $ productPage , [
135127 'query ' => [
136- 'CCTYPE ' => $ this ->includeVAT ? 'private ' : 'business ' ,
137- 'currency ' => $ this ->currency ,
128+ 'CCTYPE ' => $ this ->settings -> includeVAT ? 'private ' : 'business ' ,
129+ 'currency ' => $ this ->settings -> currency ,
138130 ],
139131 ]);
140132 $ html = $ response ->getContent ();
@@ -158,7 +150,7 @@ public function getDetails(string $id): PartDetailDTO
158150 distributor_name: self ::DISTRIBUTOR_NAME ,
159151 order_number: $ json [0 ]['article_artnr ' ],
160152 prices: array_merge (
161- [new PriceDTO (1.0 , $ priceString , $ currency , $ this ->includeVAT )]
153+ [new PriceDTO (1.0 , $ priceString , $ currency , $ this ->settings -> includeVAT )]
162154 , $ this ->parseBatchPrices ($ dom , $ currency )),
163155 product_url: $ productPage
164156 );
@@ -218,7 +210,7 @@ private function parseBatchPrices(Crawler $dom, string $currency): array
218210 //Strip any non-numeric characters
219211 $ priceString = preg_replace ('/[^0-9.]/ ' , '' , $ priceString );
220212
221- $ prices [] = new PriceDTO ($ minAmount , $ priceString , $ currency , $ this ->includeVAT );
213+ $ prices [] = new PriceDTO ($ minAmount , $ priceString , $ currency , $ this ->settings -> includeVAT );
222214 });
223215
224216 return $ prices ;
@@ -270,7 +262,7 @@ private function parseParameters(Crawler $dom): array
270262 private function getBaseURL (): string
271263 {
272264 //Without the trailing slash
273- return 'https://www.reichelt.com/ ' . strtolower ($ this ->country ) . '/ ' . strtolower ($ this ->language );
265+ return 'https://www.reichelt.com/ ' . strtolower ($ this ->settings -> country ) . '/ ' . strtolower ($ this -> settings ->language );
274266 }
275267
276268 public function getCapabilities (): array
0 commit comments