. */ declare(strict_types=1); namespace FireflyIII\Services\Spectre\Request; use FireflyIII\Services\Spectre\Object\Customer; use FireflyIII\Services\Spectre\Object\Token; /** * Class CreateTokenRequest */ class CreateTokenRequest extends SpectreRequest { /** @var Customer */ private $customer; /** @var Token */ private $token; /** @var string */ private $uri; /** * * @throws \FireflyIII\Exceptions\FireflyException * @throws \FireflyIII\Services\Spectre\Exception\SpectreException */ public function call(): void { // add mandatory fields to login object $data = [ 'data' => [ 'customer_id' => $this->customer->getId(), 'fetch_type' => 'recent', 'daily_refresh' => true, 'include_fake_providers' => true, 'show_consent_confirmation' => true, 'credentials_strategy' => 'ask', 'return_to' => $this->uri, ], ]; $uri = '/api/v3/tokens/create'; $response = $this->sendSignedSpectrePost($uri, $data); $this->token = new Token($response['data']); return; } /** * @return Token */ public function getToken(): Token { return $this->token; } /** * @param Customer $customer */ public function setCustomer(Customer $customer): void { $this->customer = $customer; } /** * @param string $uri */ public function setUri(string $uri): void { $this->uri = $uri; } }