mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-16 07:09:33 +00:00
Adapt Buerklin-provider to new settings system
This commit is contained in:
parent
9438bd32fc
commit
ac0c83a311
1 changed files with 13 additions and 24 deletions
|
|
@ -29,6 +29,7 @@ use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
use App\Services\InfoProviderSystem\DTOs\PriceDTO;
|
||||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||||
|
use App\Settings\InfoProviderSystem\BuerklinSettings;
|
||||||
use App\Services\OAuth\OAuthTokenManager;
|
use App\Services\OAuth\OAuthTokenManager;
|
||||||
use Psr\Cache\CacheItemPoolInterface;
|
use Psr\Cache\CacheItemPoolInterface;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||||
|
|
@ -53,19 +54,7 @@ class BuerklinProvider implements InfoProviderInterface
|
||||||
private readonly HttpClientInterface $client,
|
private readonly HttpClientInterface $client,
|
||||||
private readonly OAuthTokenManager $authTokenManager,
|
private readonly OAuthTokenManager $authTokenManager,
|
||||||
private readonly CacheItemPoolInterface $partInfoCache,
|
private readonly CacheItemPoolInterface $partInfoCache,
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_CLIENT_ID")]
|
) {
|
||||||
private readonly string $clientId = "",
|
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_SECRET")]
|
|
||||||
private readonly string $secret = "",
|
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_USERNAME")]
|
|
||||||
private readonly string $username = "",
|
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_PASSWORD")]
|
|
||||||
private readonly string $password = "",
|
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_LANGUAGE")]
|
|
||||||
private readonly string $language = "en",
|
|
||||||
#[Autowire(env: "string:PROVIDER_BUERKLIN_CURRENCY")]
|
|
||||||
private readonly string $currency = "EUR"
|
|
||||||
) {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,10 +83,10 @@ class BuerklinProvider implements InfoProviderInterface
|
||||||
],
|
],
|
||||||
'body' => [
|
'body' => [
|
||||||
'grant_type' => 'password',
|
'grant_type' => 'password',
|
||||||
'client_id' => $this->clientId,
|
'client_id' => $this->settings->clientId,
|
||||||
'client_secret' => $this->secret,
|
'client_secret' => $this->settings->secret,
|
||||||
'username' => $this->username,
|
'username' => $this->settings->username,
|
||||||
'password' => $this->password,
|
'password' => $this->settings->password,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
@ -126,8 +115,8 @@ class BuerklinProvider implements InfoProviderInterface
|
||||||
private function getDefaultQueryParams(): array
|
private function getDefaultQueryParams(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'curr' => $this->currency ?: 'EUR',
|
'curr' => $this->settings->currency ?: 'EUR',
|
||||||
'language' => $this->language ?: 'en',
|
'language' => $this->settings->language ?: 'en',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,10 +190,10 @@ class BuerklinProvider implements InfoProviderInterface
|
||||||
public function isActive(): bool
|
public function isActive(): bool
|
||||||
{
|
{
|
||||||
//The client ID has to be set and a token has to be available (user clicked connect)
|
//The client ID has to be set and a token has to be available (user clicked connect)
|
||||||
return $this->clientId !== ''
|
return $this->settings->clientId !== ''
|
||||||
&& $this->secret !== ''
|
&& $this->settings->secret !== ''
|
||||||
&& $this->username !== ''
|
&& $this->settings->username !== ''
|
||||||
&& $this->password !== '';
|
&& $this->settings->password !== '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -355,7 +344,7 @@ class BuerklinProvider implements InfoProviderInterface
|
||||||
return new PriceDTO(
|
return new PriceDTO(
|
||||||
minimum_discount_amount: (float) ($price['minQuantity'] ?? 1),
|
minimum_discount_amount: (float) ($price['minQuantity'] ?? 1),
|
||||||
price: $valStr,
|
price: $valStr,
|
||||||
currency_iso_code: (string) ($price['currencyIso'] ?? $this->currency ?? 'EUR'),
|
currency_iso_code: (string) ($price['currencyIso'] ?? $this->settings->currency ?? 'EUR'),
|
||||||
includes_tax: false
|
includes_tax: false
|
||||||
);
|
);
|
||||||
}, $prices);
|
}, $prices);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue