Skip to content

Commit

Permalink
Allow custom date range for order type PTK
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-svirin committed Sep 26, 2024
1 parent 47c1a9b commit fbccb1f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
8 changes: 7 additions & 1 deletion src/Contracts/EbicsClientInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,16 @@ public function HTD(DateTimeInterface $dateTime = null): DownloadOrderResult;
* Download transaction status.
*
* @param DateTimeInterface|null $dateTime
* @param DateTimeInterface|null $startDateTime
* @param DateTimeInterface|null $endDateTime
*
* @return DownloadOrderResult
*/
public function PTK(DateTimeInterface $dateTime = null): DownloadOrderResult;
public function PTK(
DateTimeInterface $dateTime = null,
DateTimeInterface $startDateTime = null,
DateTimeInterface $endDateTime = null
): DownloadOrderResult;

/**
* Download Bank available order types.
Expand Down
11 changes: 8 additions & 3 deletions src/EbicsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,16 +375,21 @@ function ($segmentNumber, $isLastSegment) use ($dateTime) {
* @inheritDoc
* @throws Exceptions\EbicsException
*/
public function PTK(DateTimeInterface $dateTime = null): DownloadOrderResult
{
public function PTK(
DateTimeInterface $dateTime = null,
DateTimeInterface $startDateTime = null,
DateTimeInterface $endDateTime = null
): DownloadOrderResult {
if (null === $dateTime) {
$dateTime = new DateTime();
}

$transaction = $this->downloadTransaction(
function ($segmentNumber, $isLastSegment) use ($dateTime) {
function ($segmentNumber, $isLastSegment) use ($dateTime, $startDateTime, $endDateTime) {
return $this->requestFactory->createPTK(
$dateTime,
$startDateTime,
$endDateTime,
$segmentNumber,
$isLastSegment
);
Expand Down
8 changes: 6 additions & 2 deletions src/Factories/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ public function createHKD(
*/
public function createPTK(
DateTimeInterface $dateTime,
DateTimeInterface $startDateTime = null,
DateTimeInterface $endDateTime = null,
int $segmentNumber = null,
bool $isLastSegment = null
): Request {
Expand All @@ -395,6 +397,8 @@ public function createPTK(
->setUser($this->user)
->setKeyring($this->keyring)
->setDateTime($dateTime)
->setStartDateTime($startDateTime)
->setEndDateTime($endDateTime)
->setSegmentNumber($segmentNumber)
->setIsLastSegment($isLastSegment);

Expand All @@ -410,10 +414,10 @@ public function createPTK(
->addPartnerId($context->getUser()->getPartnerId())
->addUserId($context->getUser()->getUserId())
->addProduct('Ebics client PHP', 'de')
->addOrderDetails(function (OrderDetailsBuilder $orderDetailsBuilder) {
->addOrderDetails(function (OrderDetailsBuilder $orderDetailsBuilder) use ($context) {
$this
->addOrderType($orderDetailsBuilder, 'PTK')
->addStandardOrderParams();
->addStandardOrderParams($context->getStartDateTime(), $context->getEndDateTime());
})
->addBankPubKeyDigests(
$context->getKeyring()->getBankSignatureXVersion(),
Expand Down

0 comments on commit fbccb1f

Please sign in to comment.