diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 14f5ad4..508050b 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -34,14 +34,8 @@ * * @return array charges */ -$phpay +$charges = $phpay ->charge() - ->setQueryParams([ - 'charge_type' => 'billet', - 'begin_date' => '2024-11-01', - 'end_date' => '2024-11-30', - 'status' => 'unpaid', - ]) ->getAll(); /** diff --git a/src/Gateways/Efi/Resources/Charge/Charge.php b/src/Gateways/Efi/Resources/Charge/Charge.php index b63eaf0..fdf6fa5 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -93,6 +93,15 @@ public function setQueryParams(array $queryParams): ChargeInterface */ public function getAll(): array { + if (empty($this->queryParams)) { + $this->setQueryParams([ + 'charge_type' => 'billet', + 'begin_date' => date('Y-m-d', strtotime('-30 days')), + 'end_date' => date('Y-m-d'), + 'status' => 'unpaid', + ]); + } + return $this->get('v1/charges', $this->queryParams); }