3131use App \Services \InfoProviderSystem \DTOs \PurchaseInfoDTO ;
3232use App \Services \InfoProviderSystem \DTOs \SearchResultDTO ;
3333use App \Services \OAuth \OAuthTokenManager ;
34+ use App \Settings \InfoProviderSystem \DigikeySettings ;
3435use Symfony \Contracts \HttpClient \HttpClientInterface ;
3536
3637class DigikeyProvider implements InfoProviderInterface
@@ -55,17 +56,16 @@ class DigikeyProvider implements InfoProviderInterface
5556 ];
5657
5758 public function __construct (HttpClientInterface $ httpClient , private readonly OAuthTokenManager $ authTokenManager ,
58- private readonly string $ currency , private readonly string $ clientId ,
59- private readonly string $ language , private readonly string $ country )
59+ private readonly DigikeySettings $ settings ,)
6060 {
6161 //Create the HTTP client with some default options
6262 $ this ->digikeyClient = $ httpClient ->withOptions ([
6363 "base_uri " => self ::BASE_URI ,
6464 "headers " => [
65- "X-DIGIKEY-Client-Id " => $ clientId ,
66- "X-DIGIKEY-Locale-Site " => $ this ->country ,
67- "X-DIGIKEY-Locale-Language " => $ this ->language ,
68- "X-DIGIKEY-Locale-Currency " => $ this ->currency ,
65+ "X-DIGIKEY-Client-Id " => $ this -> settings -> clientId ,
66+ "X-DIGIKEY-Locale-Site " => $ this ->settings -> country ,
67+ "X-DIGIKEY-Locale-Language " => $ this ->settings -> language ,
68+ "X-DIGIKEY-Locale-Currency " => $ this ->settings -> currency ,
6969 "X-DIGIKEY-Customer-Id " => 0 ,
7070 ]
7171 ]);
@@ -101,7 +101,7 @@ public function getProviderKey(): string
101101 public function isActive (): bool
102102 {
103103 //The client ID has to be set and a token has to be available (user clicked connect)
104- return $ this ->clientId !== '' && $ this ->authTokenManager ->hasToken (self ::OAUTH_APP_NAME );
104+ return $ this ->settings -> clientId !== '' && $ this ->authTokenManager ->hasToken (self ::OAUTH_APP_NAME );
105105 }
106106
107107 public function searchByKeyword (string $ keyword ): array
@@ -268,7 +268,7 @@ private function pricingToDTOs(array $price_breaks, string $order_number, string
268268 $ prices = [];
269269
270270 foreach ($ price_breaks as $ price_break ) {
271- $ prices [] = new PriceDTO (minimum_discount_amount: $ price_break ['BreakQuantity ' ], price: (string ) $ price_break ['UnitPrice ' ], currency_iso_code: $ this ->currency );
271+ $ prices [] = new PriceDTO (minimum_discount_amount: $ price_break ['BreakQuantity ' ], price: (string ) $ price_break ['UnitPrice ' ], currency_iso_code: $ this ->settings -> currency );
272272 }
273273
274274 return [
0 commit comments