. */ declare(strict_types=1); namespace FireflyIII\Services\Bunq\Request; use FireflyIII\Services\Bunq\Object\MonetaryAccountBank; use FireflyIII\Services\Bunq\Object\Payment; use FireflyIII\Services\Bunq\Token\SessionToken; use Illuminate\Support\Collection; /** * Class ListPaymentRequest */ class ListPaymentRequest extends BunqRequest { /** @var MonetaryAccountBank */ private $account; /** @var Collection */ private $payments; /** @var SessionToken */ private $sessionToken; /** @var int */ private $userId = 0; /** * TODO support pagination. * * @throws \FireflyIII\Exceptions\FireflyException */ public function call(): void { $this->payments = new Collection; $uri = sprintf('user/%d/monetary-account/%d/payment', $this->userId, $this->account->getId()); $data = []; $headers = $this->getDefaultHeaders(); $headers['X-Bunq-Client-Authentication'] = $this->sessionToken->getToken(); $response = $this->sendSignedBunqGet($uri, $data, $headers); // create payment objects: $raw = $this->getArrayFromResponse('Payment', $response); foreach ($raw as $entry) { $account = new Payment($entry); $this->payments->push($account); } return; } /** * @param MonetaryAccountBank $account */ public function setAccount(MonetaryAccountBank $account): void { $this->account = $account; } /** * @param SessionToken $sessionToken */ public function setSessionToken(SessionToken $sessionToken): void { $this->sessionToken = $sessionToken; } /** * @param int $userId */ public function setUserId(int $userId): void { $this->userId = $userId; } }