mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Improve test coverage, remove dead code.
This commit is contained in:
@@ -30,7 +30,7 @@ use Requests;
|
||||
use Requests_Response;
|
||||
|
||||
/**
|
||||
* Class BunqRequest.
|
||||
* Class SpectreRequest
|
||||
*/
|
||||
abstract class SpectreRequest
|
||||
{
|
||||
@@ -47,31 +47,6 @@ abstract class SpectreRequest
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* SpectreRequest constructor.
|
||||
*
|
||||
* @param User $user
|
||||
*
|
||||
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||
* @throws \Psr\Container\ContainerExceptionInterface
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->server = 'https://' . config('import.options.spectre.server');
|
||||
$this->expiresAt = time() + 180;
|
||||
$privateKey = app('preferences')->get('spectre_private_key', null);
|
||||
$this->privateKey = $privateKey->data;
|
||||
|
||||
// set client ID
|
||||
$appId = app('preferences')->get('spectre_app_id', null);
|
||||
$this->appId = $appId->data;
|
||||
|
||||
// set service secret
|
||||
$secret = app('preferences')->get('spectre_secret', null);
|
||||
$this->secret = $secret->data;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -125,6 +100,30 @@ abstract class SpectreRequest
|
||||
$this->privateKey = $privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
*/
|
||||
public function setUser(User $user): void
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->server = 'https://' . config('import.options.spectre.server');
|
||||
$this->expiresAt = time() + 180;
|
||||
$privateKey = app('preferences')->getForUser($user, 'spectre_private_key', null);
|
||||
$this->privateKey = $privateKey->data;
|
||||
|
||||
// set client ID
|
||||
$appId = app('preferences')->getForUser($user, 'spectre_app_id', null);
|
||||
if (null !== $appId && '' !== (string)$appId->data) {
|
||||
$this->appId = $appId->data;
|
||||
}
|
||||
|
||||
// set service secret
|
||||
$secret = app('preferences')->getForUser($user, 'spectre_secret', null);
|
||||
if (null !== $secret && '' !== (string)$secret->data) {
|
||||
$this->secret = $secret->data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param string $uri
|
||||
|
Reference in New Issue
Block a user