Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added currency code to filter #16

Merged
merged 3 commits into from
Jun 3, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions src/Filter/TransactionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace ThePay\ApiClient\Filter;

use ThePay\ApiClient\Model\SignableRequest;
use ThePay\ApiClient\ValueObject\CurrencyCode;

class TransactionFilter implements SignableRequest
{
Expand All @@ -15,29 +16,41 @@ class TransactionFilter implements SignableRequest
/** @var \DateTime */
private $dateTo;

/** @var CurrencyCode|null */
private $currencyCode;

/**
* TransactionFilter constructor.
* @param string $accountIban
* @param \DateTime $dateFrom
* @param \DateTime $dateTo
* @param string|null $currencyCode
*/
public function __construct(
$accountIban,
\DateTime $dateFrom,
\DateTime $dateTo
\DateTime $dateTo,
$currencyCode = null
) {
$this->accountIban = $accountIban;
$this->dateFrom = $dateFrom;
$this->dateTo = $dateTo;
$this->currencyCode = $currencyCode !== null ? new CurrencyCode($currencyCode) : null;
}

public function toArray()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add shaped array annotation for this method, what do U think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use as much shape annotation in this repository, but I don't think it can hurt anything.

{
return array(
$data = array(
'account_iban' => $this->accountIban,
'date_from' => $this->dateFrom,
'date_to' => $this->dateTo,
);

if ($this->currencyCode !== null) {
$data['currency_code'] = (string) $this->currencyCode;
}

return $data;
}

/**
Expand All @@ -63,4 +76,12 @@ public function getDateTo()
{
return $this->dateTo;
}

/**
* @return CurrencyCode|null
*/
public function getCurrencyCode()
{
return $this->currencyCode;
}
}