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
linushstge committed Jun 2, 2024
1 parent 45b3938 commit 170f2e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
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 $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
);
Expand Down
15 changes: 10 additions & 5 deletions src/Factories/RequestFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -399,20 +401,23 @@ 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()
->addTimestamp($context->getDateTime())
->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(),
Expand Down

0 comments on commit 170f2e3

Please sign in to comment.