Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/Core/Concerns/SdkPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function hasNextPage(): bool
public function getNextPage(): static
{
$next = $this->nextRequest();
if (!$next) {
if ($next === null) {
throw new \RuntimeException(
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.'
);
Expand Down
12 changes: 4 additions & 8 deletions src/Documents/DocumentCreate/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* allowances?: list<Allowance>|null,
* amount?: float|string|null,
* charges?: list<Charge>|null,
* date?: null|null,
* date?: \DateTimeInterface|null,
* description?: string|null,
* productCode?: string|null,
* quantity?: float|string|null,
Expand Down Expand Up @@ -53,9 +53,8 @@ final class Item implements BaseModel
#[Api(list: Charge::class, nullable: true, optional: true)]
public ?array $charges;

/** @var null|null $date */
#[Api(nullable: true, optional: true)]
public null $date;
public ?\DateTimeInterface $date;

/**
* The description of the line item.
Expand Down Expand Up @@ -119,7 +118,7 @@ public static function with(
?array $allowances = null,
float|string|null $amount = null,
?array $charges = null,
null $date = null,
?\DateTimeInterface $date = null,
?string $description = null,
?string $productCode = null,
float|string|null $quantity = null,
Expand Down Expand Up @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self
return $obj;
}

/**
* @param null|null $date
*/
public function withDate(null $date): self
public function withDate(?\DateTimeInterface $date): self
{
$obj = clone $this;
$obj->date = $date;
Expand Down
12 changes: 4 additions & 8 deletions src/Documents/DocumentCreateParams/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* allowances?: list<Allowance>|null,
* amount?: float|string|null,
* charges?: list<Charge>|null,
* date?: null|null,
* date?: \DateTimeInterface|null,
* description?: string|null,
* productCode?: string|null,
* quantity?: float|string|null,
Expand Down Expand Up @@ -53,9 +53,8 @@ final class Item implements BaseModel
#[Api(list: Charge::class, nullable: true, optional: true)]
public ?array $charges;

/** @var null|null $date */
#[Api(nullable: true, optional: true)]
public null $date;
public ?\DateTimeInterface $date;

/**
* The description of the line item.
Expand Down Expand Up @@ -119,7 +118,7 @@ public static function with(
?array $allowances = null,
float|string|null $amount = null,
?array $charges = null,
null $date = null,
?\DateTimeInterface $date = null,
?string $description = null,
?string $productCode = null,
float|string|null $quantity = null,
Expand Down Expand Up @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self
return $obj;
}

/**
* @param null|null $date
*/
public function withDate(null $date): self
public function withDate(?\DateTimeInterface $date): self
{
$obj = clone $this;
$obj->date = $date;
Expand Down
12 changes: 4 additions & 8 deletions src/Documents/DocumentNewFromPdfResponse/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* allowances?: list<Allowance>|null,
* amount?: string|null,
* charges?: list<Charge>|null,
* date?: null|null,
* date?: \DateTimeInterface|null,
* description?: string|null,
* productCode?: string|null,
* quantity?: string|null,
Expand Down Expand Up @@ -53,9 +53,8 @@ final class Item implements BaseModel
#[Api(list: Charge::class, nullable: true, optional: true)]
public ?array $charges;

/** @var null|null $date */
#[Api(nullable: true, optional: true)]
public null $date;
public ?\DateTimeInterface $date;

/**
* The description of the line item.
Expand Down Expand Up @@ -119,7 +118,7 @@ public static function with(
?array $allowances = null,
?string $amount = null,
?array $charges = null,
null $date = null,
?\DateTimeInterface $date = null,
?string $description = null,
?string $productCode = null,
?string $quantity = null,
Expand Down Expand Up @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self
return $obj;
}

/**
* @param null|null $date
*/
public function withDate(null $date): self
public function withDate(?\DateTimeInterface $date): self
{
$obj = clone $this;
$obj->date = $date;
Expand Down
12 changes: 4 additions & 8 deletions src/Documents/DocumentResponse/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* allowances?: list<Allowance>|null,
* amount?: string|null,
* charges?: list<Charge>|null,
* date?: null|null,
* date?: \DateTimeInterface|null,
* description?: string|null,
* productCode?: string|null,
* quantity?: string|null,
Expand Down Expand Up @@ -53,9 +53,8 @@ final class Item implements BaseModel
#[Api(list: Charge::class, nullable: true, optional: true)]
public ?array $charges;

/** @var null|null $date */
#[Api(nullable: true, optional: true)]
public null $date;
public ?\DateTimeInterface $date;

/**
* The description of the line item.
Expand Down Expand Up @@ -119,7 +118,7 @@ public static function with(
?array $allowances = null,
?string $amount = null,
?array $charges = null,
null $date = null,
?\DateTimeInterface $date = null,
?string $description = null,
?string $productCode = null,
?string $quantity = null,
Expand Down Expand Up @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self
return $obj;
}

/**
* @param null|null $date
*/
public function withDate(null $date): self
public function withDate(?\DateTimeInterface $date): self
{
$obj = clone $this;
$obj->date = $date;
Expand Down
14 changes: 14 additions & 0 deletions src/DocumentsNumberPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,21 @@ public function getItems(): array
public function nextRequest(): ?array
{
$currentPage = $this->page ?? 1;
$pageSize = $this->pageSize ?? 0;
$total = $this->total ?? 0;

// Check if there are more pages
if ($pageSize === 0 || $total === 0) {
return null;
}

$totalPages = (int) ceil($total / $pageSize);
if ($currentPage >= $totalPages) {
return null;
}

$nextRequest = $this->request;
$nextRequest['query']['page'] = $currentPage + 1;

return [$nextRequest, $this->options];
}
Expand Down
2 changes: 1 addition & 1 deletion src/DocumentsNumberPage/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use EInvoiceAPI\Core\Contracts\BaseModel;

/**
* @phpstan-type ItemShape = array{}
* @phpstan-type ItemShape = array<string, mixed>
*/
final class Item implements BaseModel
{
Expand Down
12 changes: 4 additions & 8 deletions src/Validate/ValidateValidateJsonParams/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* allowances?: list<Allowance>|null,
* amount?: float|string|null,
* charges?: list<Charge>|null,
* date?: null|null,
* date?: \DateTimeInterface|null,
* description?: string|null,
* productCode?: string|null,
* quantity?: float|string|null,
Expand Down Expand Up @@ -53,9 +53,8 @@ final class Item implements BaseModel
#[Api(list: Charge::class, nullable: true, optional: true)]
public ?array $charges;

/** @var null|null $date */
#[Api(nullable: true, optional: true)]
public null $date;
public ?\DateTimeInterface $date;

/**
* The description of the line item.
Expand Down Expand Up @@ -119,7 +118,7 @@ public static function with(
?array $allowances = null,
float|string|null $amount = null,
?array $charges = null,
null $date = null,
?\DateTimeInterface $date = null,
?string $description = null,
?string $productCode = null,
float|string|null $quantity = null,
Expand Down Expand Up @@ -182,10 +181,7 @@ public function withCharges(?array $charges): self
return $obj;
}

/**
* @param null|null $date
*/
public function withDate(null $date): self
public function withDate(?\DateTimeInterface $date): self
{
$obj = clone $this;
$obj->date = $date;
Expand Down