Skip to content

Commit eaaf44b

Browse files
committed
Fixed disable logic and disable hints for info providers
1 parent a48490a commit eaaf44b

File tree

9 files changed

+28
-27
lines changed

9 files changed

+28
-27
lines changed

src/Services/InfoProviderSystem/Providers/DigikeyProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getProviderInfo(): array
7878
'description' => 'This provider uses the DigiKey API to search for parts.',
7979
'url' => 'https://www.digikey.com/',
8080
'oauth_app_name' => self::OAUTH_APP_NAME,
81-
'disabled_help' => 'Set the PROVIDER_DIGIKEY_CLIENT_ID and PROVIDER_DIGIKEY_SECRET env option and connect OAuth to enable.'
81+
'disabled_help' => 'Set the Client ID and Secret in provider settings and connect OAuth to enable.'
8282
];
8383
}
8484

@@ -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->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
104+
return $this->settings->clientId !== null && $this->settings->clientId !== '' && $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
105105
}
106106

107107
public function searchByKeyword(string $keyword): array

src/Services/InfoProviderSystem/Providers/Element14Provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function getProviderInfo(): array
6666
'name' => 'Farnell element14',
6767
'description' => 'This provider uses the Farnell element14 API to search for parts.',
6868
'url' => 'https://www.element14.com/',
69-
'disabled_help' => 'Configure the API key in the PROVIDER_ELEMENT14_KEY environment variable to enable.'
69+
'disabled_help' => 'Configure the API key in the provider settings to enable.'
7070
];
7171
}
7272

src/Services/InfoProviderSystem/Providers/LCSCProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getProviderInfo(): array
5151
'name' => 'LCSC',
5252
'description' => 'This provider uses the (unofficial) LCSC API to search for parts.',
5353
'url' => 'https://www.lcsc.com/',
54-
'disabled_help' => 'Set PROVIDER_LCSC_ENABLED to 1 (or true) in your environment variable config.'
54+
'disabled_help' => 'Enable this provider in the provider settings.'
5555
];
5656
}
5757

src/Services/InfoProviderSystem/Providers/MouserProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function getProviderInfo(): array
6161
'name' => 'Mouser',
6262
'description' => 'This provider uses the Mouser API to search for parts.',
6363
'url' => 'https://www.mouser.com/',
64-
'disabled_help' => 'Configure the API key in the PROVIDER_MOUSER_KEY environment variable to enable.'
64+
'disabled_help' => 'Configure the API key in the provider settings to enable.'
6565
];
6666
}
6767

@@ -345,4 +345,4 @@ private function releaseStatusCodeToManufacturingStatus(?string $productStatus,
345345

346346
return $tmp;
347347
}
348-
}
348+
}

src/Services/InfoProviderSystem/Providers/OEMSecretsProvider.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public function getProviderInfo(): array
246246
'name' => 'OEMSecrets',
247247
'description' => 'This provider uses the OEMSecrets API to search for parts.',
248248
'url' => 'https://www.oemsecrets.com/',
249-
'disabled_help' => 'Configure the API key in the PROVIDER_OEMSECRETS_KEY environment variable to enable.'
249+
'disabled_help' => 'Configure the API key in the provider settings to enable.'
250250
];
251251
}
252252
/**
@@ -265,7 +265,7 @@ public function getProviderKey(): string
265265
*/
266266
public function isActive(): bool
267267
{
268-
return $this->settings->apiKey !== '';
268+
return $this->settings->apiKey !== null && $this->settings->apiKey !== '';
269269
}
270270

271271

@@ -285,33 +285,33 @@ public function isActive(): bool
285285
public function searchByKeyword(string $keyword): array
286286
{
287287
/*
288-
oemsecrets Part Search API 3.0.1
288+
oemsecrets Part Search API 3.0.1
289289
290290
"https://oemsecretsapi.com/partsearch?
291291
searchTerm=BC547
292292
&apiKey=icawpb0bspoo2c6s64uv4vpdfp2vgr7e27bxw0yct2bzh87mpl027x353uelpq2x
293293
&currency=EUR
294-
&countryCode=IT"
295-
294+
&countryCode=IT"
295+
296296
partsearch description:
297-
Use the Part Search API to find distributor data for a full or partial manufacturer
297+
Use the Part Search API to find distributor data for a full or partial manufacturer
298298
part number including part details, pricing, compliance and inventory.
299-
299+
300300
Required Parameter Format Description
301301
searchTerm string Part number you are searching for
302302
apiKey string Your unique API key provided to you by OEMsecrets
303303
304304
Additional Parameter Format Description
305305
countryCode string The country you want to output for
306306
currency string / array The currency you want the prices to be displayed as
307-
307+
308308
To display the output for GB and to view prices in USD, add [ countryCode=GB ] and [ currency=USD ]
309309
as seen below:
310310
oemsecretsapi.com/partsearch?apiKey=abcexampleapikey123&searchTerm=bd04&countryCode=GB&currency=USD
311-
311+
312312
To view prices in both USD and GBP add [ currency[]=USD&currency[]=GBP ]
313313
oemsecretsapi.com/partsearch?searchTerm=bd04&apiKey=abcexampleapikey123&currency[]=USD&currency[]=GBP
314-
314+
315315
*/
316316

317317

@@ -1465,4 +1465,4 @@ private function unwrapURL(?string $url): ?string
14651465
return $url;
14661466
}
14671467

1468-
}
1468+
}

src/Services/InfoProviderSystem/Providers/OctopartProvider.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function getProviderInfo(): array
170170
'name' => 'Octopart',
171171
'description' => 'This provider uses the Nexar/Octopart API to search for parts on Octopart.',
172172
'url' => 'https://www.octopart.com/',
173-
'disabled_help' => 'Set the PROVIDER_OCTOPART_CLIENT_ID and PROVIDER_OCTOPART_SECRET env option.'
173+
'disabled_help' => 'Set the Client ID and Secret in provider settings.'
174174
];
175175
}
176176

@@ -183,7 +183,8 @@ public function isActive(): bool
183183
{
184184
//The client ID has to be set and a token has to be available (user clicked connect)
185185
//return /*!empty($this->clientId) && */ $this->authTokenManager->hasToken(self::OAUTH_APP_NAME);
186-
return $this->settings->clientId !== '' && $this->settings->secret !== '';
186+
return $this->settings->clientId !== null && $this->settings->clientId !== ''
187+
&& $this->settings->secret !== null && $this->settings->secret !== '';
187188
}
188189

189190
private function mapLifeCycleStatus(?string $value): ?ManufacturingStatus
@@ -337,7 +338,7 @@ public function searchByKeyword(string $keyword): array
337338
) {
338339
hits
339340
results {
340-
part
341+
part
341342
%s
342343
}
343344
}
@@ -403,4 +404,4 @@ public function getCapabilities(): array
403404
ProviderCapabilities::PRICE,
404405
];
405406
}
406-
}
407+
}

src/Services/InfoProviderSystem/Providers/PollinProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getProviderInfo(): array
5151
'name' => 'Pollin',
5252
'description' => 'Webscraping from pollin.de to get part information',
5353
'url' => 'https://www.pollin.de/',
54-
'disabled_help' => 'Set PROVIDER_POLLIN_ENABLED env to 1'
54+
'disabled_help' => 'Enable the provider in provider settings'
5555
];
5656
}
5757

@@ -246,4 +246,4 @@ public function getCapabilities(): array
246246
ProviderCapabilities::DATASHEET
247247
];
248248
}
249-
}
249+
}

src/Services/InfoProviderSystem/Providers/ReicheltProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getProviderInfo(): array
5151
'name' => 'Reichelt',
5252
'description' => 'Webscraping from reichelt.com to get part information',
5353
'url' => 'https://www.reichelt.com/',
54-
'disabled_help' => 'Set PROVIDER_REICHELT_ENABLED env to 1'
54+
'disabled_help' => 'Enable provider in provider settings.'
5555
];
5656
}
5757

@@ -274,4 +274,4 @@ public function getCapabilities(): array
274274
ProviderCapabilities::PRICE,
275275
];
276276
}
277-
}
277+
}

src/Services/InfoProviderSystem/Providers/TMEProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function getProviderInfo(): array
5454
'name' => 'TME',
5555
'description' => 'This provider uses the API of TME (Transfer Multipart).',
5656
'url' => 'https://tme.eu/',
57-
'disabled_help' => 'Configure the PROVIDER_TME_KEY and PROVIDER_TME_SECRET environment variables to use this provider.'
57+
'disabled_help' => 'Configure the API Token and secret in provider settings to use this provider.'
5858
];
5959
}
6060

@@ -295,4 +295,4 @@ public function getCapabilities(): array
295295
ProviderCapabilities::PRICE,
296296
];
297297
}
298-
}
298+
}

0 commit comments

Comments
 (0)