refactor(open-banking): drop per-provider log-message hook
validationFailureLogMessage() was an abstract hook whose only job was to return a
cosmetically different warning string per provider ("Binance credential validation
failed", "Indexa Capital token validation failed", ...). It carried no functional
value and forced five one-line overrides.
Log a single structured message in the base with the provider enum value as
context, which is more useful for filtering than the free-text variants, and
remove the hook and its five overrides. Also restore the array-shape PHPDoc on
IndexaCapital's buildPendingAccounts() that the shared mixed signature dropped.
Only the warning-log text changes (now includes a "provider" key); the HTTP
responses are untouched. OpenBanking feature tests pass (304/304).
This commit is contained in:
parent
0e6a144c2c
commit
08430c8b32
|
|
@ -41,11 +41,6 @@ class BinanceController extends CryptoPortfolioConnectController
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function validationFailureLogMessage(): string
|
||||
{
|
||||
return 'Binance credential validation failed';
|
||||
}
|
||||
|
||||
protected function credentialErrorMessage(\Throwable $e): string
|
||||
{
|
||||
return 'Invalid API credentials or failed to connect to Binance.';
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ class BitpandaController extends CryptoPortfolioConnectController
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function validationFailureLogMessage(): string
|
||||
{
|
||||
return 'Bitpanda credential validation failed';
|
||||
}
|
||||
|
||||
protected function credentialErrorMessage(\Throwable $e): string
|
||||
{
|
||||
return 'Invalid API key or failed to connect to Bitpanda.';
|
||||
|
|
|
|||
|
|
@ -41,11 +41,6 @@ class CoinbaseController extends CryptoPortfolioConnectController
|
|||
return null;
|
||||
}
|
||||
|
||||
protected function validationFailureLogMessage(): string
|
||||
{
|
||||
return 'Coinbase credential validation failed';
|
||||
}
|
||||
|
||||
protected function credentialErrorMessage(\Throwable $e): string
|
||||
{
|
||||
return 'Invalid API credentials or failed to connect to Coinbase.';
|
||||
|
|
|
|||
|
|
@ -46,11 +46,6 @@ class IndexaCapitalController extends OpenBankingConnectController
|
|||
return $client->getUser();
|
||||
}
|
||||
|
||||
protected function validationFailureLogMessage(): string
|
||||
{
|
||||
return 'Indexa Capital token validation failed';
|
||||
}
|
||||
|
||||
protected function credentialErrorMessage(\Throwable $e): string
|
||||
{
|
||||
return 'Invalid API token or failed to connect to Indexa Capital.';
|
||||
|
|
@ -58,6 +53,8 @@ class IndexaCapitalController extends OpenBankingConnectController
|
|||
|
||||
/**
|
||||
* Build the pending accounts data in the same format as EnableBanking.
|
||||
*
|
||||
* @param array{accounts?: array<int, array{account_number?: string, type?: string}>} $providerData
|
||||
*/
|
||||
protected function buildPendingAccounts(mixed $providerData, User $user): array
|
||||
{
|
||||
|
|
|
|||
|
|
@ -48,11 +48,6 @@ class InteractiveBrokersController extends OpenBankingConnectController
|
|||
return $client->fetchStatement();
|
||||
}
|
||||
|
||||
protected function validationFailureLogMessage(): string
|
||||
{
|
||||
return 'Interactive Brokers connection validation failed';
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a Flex failure into a message the user can act on: bad credentials,
|
||||
* a busy/rate-limited service, or a statement that is still generating.
|
||||
|
|
|
|||
|
|
@ -42,8 +42,6 @@ abstract class OpenBankingConnectController extends Controller
|
|||
*/
|
||||
abstract protected function fetchProviderData(array $validated): mixed;
|
||||
|
||||
abstract protected function validationFailureLogMessage(): string;
|
||||
|
||||
abstract protected function credentialErrorMessage(\Throwable $e): string;
|
||||
|
||||
/**
|
||||
|
|
@ -77,7 +75,10 @@ abstract class OpenBankingConnectController extends Controller
|
|||
try {
|
||||
$providerData = $this->fetchProviderData($validated);
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning($this->validationFailureLogMessage(), ['error' => $e->getMessage()]);
|
||||
Log::warning('OpenBanking credential validation failed', [
|
||||
'provider' => $this->provider()->value,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'message' => $this->credentialErrorMessage($e),
|
||||
|
|
|
|||
Loading…
Reference in New Issue