mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-29 14:28:42 +02:00
Fixed disable logic and disable hints for info providers
This commit is contained in:
parent
a48490ac1a
commit
eaaf44b391
9 changed files with 28 additions and 27 deletions
|
@ -78,7 +78,7 @@ class DigikeyProvider implements InfoProviderInterface
|
|||
'description' => 'This provider uses the DigiKey API to search for parts.',
|
||||
'url' => 'https://www.digikey.com/',
|
||||
'oauth_app_name' => self::OAUTH_APP_NAME,
|
||||
'disabled_help' => 'Set the PROVIDER_DIGIKEY_CLIENT_ID and PROVIDER_DIGIKEY_SECRET env option and connect OAuth to enable.'
|
||||
'disabled_help' => 'Set the Client ID and Secret in provider settings and connect OAuth to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class DigikeyProvider implements InfoProviderInterface
|
|||
public function isActive(): bool
|
||||
{
|
||||
//The client ID has to be set and a token has to be available (user clicked connect)
|
||||
return $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
|
||||
return $this->settings->clientId !== null && $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
|
||||
}
|
||||
|
||||
public function searchByKeyword(string $keyword): array
|
||||
|
|
|
@ -66,7 +66,7 @@ class Element14Provider implements InfoProviderInterface
|
|||
'name' => 'Farnell element14',
|
||||
'description' => 'This provider uses the Farnell element14 API to search for parts.',
|
||||
'url' => 'https://www.element14.com/',
|
||||
'disabled_help' => 'Configure the API key in the PROVIDER_ELEMENT14_KEY environment variable to enable.'
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class LCSCProvider implements InfoProviderInterface
|
|||
'name' => 'LCSC',
|
||||
'description' => 'This provider uses the (unofficial) LCSC API to search for parts.',
|
||||
'url' => 'https://www.lcsc.com/',
|
||||
'disabled_help' => 'Set PROVIDER_LCSC_ENABLED to 1 (or true) in your environment variable config.'
|
||||
'disabled_help' => 'Enable this provider in the provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ class MouserProvider implements InfoProviderInterface
|
|||
'name' => 'Mouser',
|
||||
'description' => 'This provider uses the Mouser API to search for parts.',
|
||||
'url' => 'https://www.mouser.com/',
|
||||
'disabled_help' => 'Configure the API key in the PROVIDER_MOUSER_KEY environment variable to enable.'
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -345,4 +345,4 @@ class MouserProvider implements InfoProviderInterface
|
|||
|
||||
return $tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
'name' => 'OEMSecrets',
|
||||
'description' => 'This provider uses the OEMSecrets API to search for parts.',
|
||||
'url' => 'https://www.oemsecrets.com/',
|
||||
'disabled_help' => 'Configure the API key in the PROVIDER_OEMSECRETS_KEY environment variable to enable.'
|
||||
'disabled_help' => 'Configure the API key in the provider settings to enable.'
|
||||
];
|
||||
}
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
*/
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->settings->apiKey !== '';
|
||||
return $this->settings->apiKey !== null && $this->settings->apiKey !== '';
|
||||
}
|
||||
|
||||
|
||||
|
@ -285,18 +285,18 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
public function searchByKeyword(string $keyword): array
|
||||
{
|
||||
/*
|
||||
oemsecrets Part Search API 3.0.1
|
||||
oemsecrets Part Search API 3.0.1
|
||||
|
||||
"https://oemsecretsapi.com/partsearch?
|
||||
searchTerm=BC547
|
||||
&apiKey=icawpb0bspoo2c6s64uv4vpdfp2vgr7e27bxw0yct2bzh87mpl027x353uelpq2x
|
||||
¤cy=EUR
|
||||
&countryCode=IT"
|
||||
|
||||
&countryCode=IT"
|
||||
|
||||
partsearch description:
|
||||
Use the Part Search API to find distributor data for a full or partial manufacturer
|
||||
Use the Part Search API to find distributor data for a full or partial manufacturer
|
||||
part number including part details, pricing, compliance and inventory.
|
||||
|
||||
|
||||
Required Parameter Format Description
|
||||
searchTerm string Part number you are searching for
|
||||
apiKey string Your unique API key provided to you by OEMsecrets
|
||||
|
@ -304,14 +304,14 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
Additional Parameter Format Description
|
||||
countryCode string The country you want to output for
|
||||
currency string / array The currency you want the prices to be displayed as
|
||||
|
||||
|
||||
To display the output for GB and to view prices in USD, add [ countryCode=GB ] and [ currency=USD ]
|
||||
as seen below:
|
||||
oemsecretsapi.com/partsearch?apiKey=abcexampleapikey123&searchTerm=bd04&countryCode=GB¤cy=USD
|
||||
|
||||
|
||||
To view prices in both USD and GBP add [ currency[]=USD¤cy[]=GBP ]
|
||||
oemsecretsapi.com/partsearch?searchTerm=bd04&apiKey=abcexampleapikey123¤cy[]=USD¤cy[]=GBP
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1465,4 +1465,4 @@ class OEMSecretsProvider implements InfoProviderInterface
|
|||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ class OctopartProvider implements InfoProviderInterface
|
|||
'name' => 'Octopart',
|
||||
'description' => 'This provider uses the Nexar/Octopart API to search for parts on Octopart.',
|
||||
'url' => 'https://www.octopart.com/',
|
||||
'disabled_help' => 'Set the PROVIDER_OCTOPART_CLIENT_ID and PROVIDER_OCTOPART_SECRET env option.'
|
||||
'disabled_help' => 'Set the Client ID and Secret in provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,8 @@ class OctopartProvider implements InfoProviderInterface
|
|||
{
|
||||
//The client ID has to be set and a token has to be available (user clicked connect)
|
||||
//return /*!empty($this->clientId) && */ $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
|
||||
return $this->settings->clientId !== '' && $this->settings->secret !== '';
|
||||
return $this->settings->clientId !== null && $this->settings->clientId !== ''
|
||||
&& $this->settings->secret !== null && $this->settings->secret !== '';
|
||||
}
|
||||
|
||||
private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus
|
||||
|
@ -337,7 +338,7 @@ class OctopartProvider implements InfoProviderInterface
|
|||
) {
|
||||
hits
|
||||
results {
|
||||
part
|
||||
part
|
||||
%s
|
||||
}
|
||||
}
|
||||
|
@ -403,4 +404,4 @@ class OctopartProvider implements InfoProviderInterface
|
|||
ProviderCapabilities::PRICE,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class PollinProvider implements InfoProviderInterface
|
|||
'name' => 'Pollin',
|
||||
'description' => 'Webscraping from pollin.de to get part information',
|
||||
'url' => 'https://www.pollin.de/',
|
||||
'disabled_help' => 'Set PROVIDER_POLLIN_ENABLED env to 1'
|
||||
'disabled_help' => 'Enable the provider in provider settings'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -246,4 +246,4 @@ class PollinProvider implements InfoProviderInterface
|
|||
ProviderCapabilities::DATASHEET
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class ReicheltProvider implements InfoProviderInterface
|
|||
'name' => 'Reichelt',
|
||||
'description' => 'Webscraping from reichelt.com to get part information',
|
||||
'url' => 'https://www.reichelt.com/',
|
||||
'disabled_help' => 'Set PROVIDER_REICHELT_ENABLED env to 1'
|
||||
'disabled_help' => 'Enable provider in provider settings.'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -274,4 +274,4 @@ class ReicheltProvider implements InfoProviderInterface
|
|||
ProviderCapabilities::PRICE,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ class TMEProvider implements InfoProviderInterface
|
|||
'name' => 'TME',
|
||||
'description' => 'This provider uses the API of TME (Transfer Multipart).',
|
||||
'url' => 'https://tme.eu/',
|
||||
'disabled_help' => 'Configure the PROVIDER_TME_KEY and PROVIDER_TME_SECRET environment variables to use this provider.'
|
||||
'disabled_help' => 'Configure the API Token and secret in provider settings to use this provider.'
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -295,4 +295,4 @@ class TMEProvider implements InfoProviderInterface
|
|||
ProviderCapabilities::PRICE,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue