diff --git a/app/Import/Prerequisites/BunqPrerequisites.php b/app/Import/Prerequisites/BunqPrerequisites.php index 286268b919..feaa23d477 100644 --- a/app/Import/Prerequisites/BunqPrerequisites.php +++ b/app/Import/Prerequisites/BunqPrerequisites.php @@ -91,6 +91,22 @@ class BunqPrerequisites implements PrerequisitesInterface return !$hasApiKey || !$hasServerIP; } + /** + * Indicate if all prerequisites have been met. + * + * @return bool + */ + public function isComplete(): bool + { + // is complete when user has entered both the API key + // and his IP address. + + $hasApiKey = $this->hasApiKey(); + $hasServerIP = $this->hasServerIP(); + + return $hasApiKey && $hasServerIP; + } + /** * Set the user for this Prerequisites-routine. Class is expected to implement and save this. * diff --git a/app/Import/Prerequisites/FilePrerequisites.php b/app/Import/Prerequisites/FilePrerequisites.php index e2177af913..c574cfa05b 100644 --- a/app/Import/Prerequisites/FilePrerequisites.php +++ b/app/Import/Prerequisites/FilePrerequisites.php @@ -75,6 +75,17 @@ class FilePrerequisites implements PrerequisitesInterface return false; } + /** + * Indicate if all prerequisites have been met. + * + * @return bool + */ + public function isComplete(): bool + { + // has no prerequisites, so always return true. + return true; + } + /** * Set the user for this Prerequisites-routine. Class is expected to implement and save this. * diff --git a/app/Import/Prerequisites/PrerequisitesInterface.php b/app/Import/Prerequisites/PrerequisitesInterface.php index 699ea43b31..84519a647a 100644 --- a/app/Import/Prerequisites/PrerequisitesInterface.php +++ b/app/Import/Prerequisites/PrerequisitesInterface.php @@ -53,6 +53,13 @@ interface PrerequisitesInterface */ public function hasPrerequisites(): bool; + /** + * Indicate if all prerequisites have been met. + * + * @return bool + */ + public function isComplete(): bool; + /** * Set the user for this Prerequisites-routine. Class is expected to implement and save this. * diff --git a/app/Import/Prerequisites/SpectrePrerequisites.php b/app/Import/Prerequisites/SpectrePrerequisites.php index a780c3ddd1..7da7d93942 100644 --- a/app/Import/Prerequisites/SpectrePrerequisites.php +++ b/app/Import/Prerequisites/SpectrePrerequisites.php @@ -87,6 +87,29 @@ class SpectrePrerequisites implements PrerequisitesInterface return false; } + /** + * Indicate if all prerequisites have been met. + * + * @return bool + */ + public function isComplete(): bool + { + // return true when user has set the App Id and the Spectre Secret. + $values = [ + Preferences::getForUser($this->user, 'spectre_app_id', false), + Preferences::getForUser($this->user, 'spectre_secret', false), + ]; + $result = true; + /** @var Preference $value */ + foreach ($values as $value) { + if (false === $value->data || null === $value->data) { + $result = false; + } + } + + return $result; + } + /** * Set the user for this Prerequisites-routine. Class is expected to implement and save this. *