Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Code for Spectre.
James Coledd44a1e51795
diff --git a/app/Http/Controllers/Import/JobStatusController.php b/app/Http/Controllers/Import/JobStatusController.phpindex 54fa516f05..c9b53a4eb9 100644--- a/app/Http/Controllers/Import/JobStatusController.php+++ b/app/Http/Controllers/Import/JobStatusController.php@@ -114,7 +114,7 @@ class JobStatusController extends Controllerpublic function start(ImportJob $importJob): JsonResponse{// catch impossible status:- $allowed = ['ready_to_run', 'need_job_config'];+ $allowed = ['ready_to_run', 'need_job_config','error']; // todo remove errorif (null !== $importJob && !\in_array($importJob->status, $allowed, true)) {Log::error('Job is not ready.');diff --git a/app/Import/Routine/SpectreRoutine.php b/app/Import/Routine/SpectreRoutine.phpindex 616dd0a1ab..639351ccf5 100644--- a/app/Import/Routine/SpectreRoutine.php+++ b/app/Import/Routine/SpectreRoutine.php@@ -54,17 +54,20 @@ class SpectreRoutine implements RoutineInterface*/public function run(): void{- if ($this->importJob->status === 'ready_to_run') {-+ $valid = ['ready_to_run','error']; // should be only ready_to_run+ if(in_array($this->importJob->status, $valid)) {switch ($this->importJob->stage) {default:throw new FireflyException(sprintf('SpectreRoutine cannot handle stage "%s".', $this->importJob->stage));case 'new':+ case 'authenticate':/** @var StageNewHandler $handler */$handler = app(StageNewHandler::class);$handler->setImportJob($this->importJob);$handler->run();$this->repository->setStage($this->importJob, 'authenticate');+ var_dump($this->repository->getConfiguration($this->importJob));+ exit;break;}}diff --git a/app/Support/Import/Routine/Spectre/StageNewHandler.php b/app/Support/Import/Routine/Spectre/StageNewHandler.phpindex 823354632b..a7380462d7 100644--- a/app/Support/Import/Routine/Spectre/StageNewHandler.php+++ b/app/Support/Import/Routine/Spectre/StageNewHandler.php@@ -59,6 +59,7 @@ class StageNewHandler*/public function run(): void{+ Log::debug('Now in stageNewHandler::run()');$customer = $this->getCustomer();// get token using customer.$token = $this->getToken($customer);@@ -83,12 +84,15 @@ class StageNewHandler*/private function getCustomer(): Customer{+ Log::debug('Now in stageNewHandler::getCustomer()');$customer = $this->getExistingCustomer();if (null === $customer) {+ Log::debug('The customer is NULL, will fire a newCustomerRequest.');$newCustomerRequest = new NewCustomerRequest($this->importJob->user);$customer = $newCustomerRequest->getCustomer();}+ Log::debug('The customer is not null.');return $customer;}@@ -99,14 +103,18 @@ class StageNewHandler*/private function getExistingCustomer(): ?Customer{+ Log::debug('Now in getExistingCustomer()');$customer = null;$getCustomerRequest = new ListCustomersRequest($this->importJob->user);$getCustomerRequest->call();$customers = $getCustomerRequest->getCustomers();++ Log::debug(sprintf('Found %d customer(s)', \count($customers)));/** @var Customer $current */foreach ($customers as $current) {if ('default_ff3_customer' === $current->getIdentifier()) {$customer = $current;+ Log::debug('Found the correct customer.');break;}}@@ -122,6 +130,7 @@ class StageNewHandler*/private function getToken(Customer $customer): Token{+ Log::debug('Now in getToken()');$request = new CreateTokenRequest($this->importJob->user);$request->setUri(route('import.job.status.index', [$this->importJob->key]));$request->setCustomer($customer);