From 170f2e39bfae2a6bebf0dbf324218a5023d630b7 Mon Sep 17 00:00:00 2001 From: Linus Holtstiege Date: Sun, 2 Jun 2024 18:37:10 +0200 Subject: [PATCH] allow custom date range for order type PTK --- src/EbicsClient.php | 11 ++++++++--- src/Factories/RequestFactory.php | 15 ++++++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/EbicsClient.php b/src/EbicsClient.php index 6a01839..43d818e 100644 --- a/src/EbicsClient.php +++ b/src/EbicsClient.php @@ -375,16 +375,21 @@ function ($segmentNumber, $isLastSegment) use ($dateTime) { * @inheritDoc * @throws Exceptions\EbicsException */ - public function PTK(DateTimeInterface $dateTime = null): DownloadOrderResult - { + public function PTK( + DateTimeInterface $startDate = null, + DateTimeInterface $stopDate = null, + DateTimeInterface $dateTime = null + ): DownloadOrderResult { if (null === $dateTime) { $dateTime = new DateTime(); } $transaction = $this->downloadTransaction( - function ($segmentNumber, $isLastSegment) use ($dateTime) { + function ($segmentNumber, $isLastSegment) use ($startDate, $stopDate, $dateTime) { return $this->requestFactory->createPTK( $dateTime, + $startDate, + $stopDate, $segmentNumber, $isLastSegment ); diff --git a/src/Factories/RequestFactory.php b/src/Factories/RequestFactory.php index 3e5545f..222cc6d 100644 --- a/src/Factories/RequestFactory.php +++ b/src/Factories/RequestFactory.php @@ -386,6 +386,8 @@ public function createHKD( */ public function createPTK( DateTimeInterface $dateTime, + DateTimeInterface $startDate = null, + DateTimeInterface $stopDate = null, int $segmentNumber = null, bool $isLastSegment = null ): Request { @@ -399,9 +401,9 @@ public function createPTK( $request = $this ->createRequestBuilderInstance() - ->addContainerSecured(function (XmlBuilder $builder) use ($context) { - $builder->addHeader(function (HeaderBuilder $builder) use ($context) { - $builder->addStatic(function (StaticBuilder $builder) use ($context) { + ->addContainerSecured(function (XmlBuilder $builder) use ($context, $startDate, $stopDate) { + $builder->addHeader(function (HeaderBuilder $builder) use ($context, $startDate, $stopDate) { + $builder->addStatic(function (StaticBuilder $builder) use ($context, $startDate, $stopDate) { $builder ->addHostId($context->getBank()->getHostId()) ->addRandomNonce() @@ -409,10 +411,13 @@ 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 ( + $startDate, + $stopDate + ) { $this ->addOrderType($orderDetailsBuilder, 'PTK') - ->addStandardOrderParams(); + ->addStandardOrderParams($startDate, $stopDate); }) ->addBankPubKeyDigests( $context->getKeyring()->getBankSignatureXVersion(),