diff --git a/.gitignore b/.gitignore index e39b05d..5227e6b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ vendor/ node_modules/ examples/asaas/credentials.php -examples/efi/credentials.php \ No newline at end of file +examples/efi/credentials.php +.idea/ \ No newline at end of file diff --git a/examples/efi/charges.php b/examples/efi/charges.php index 3024df6..ae4edec 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -28,3 +28,17 @@ ->charge($charge) ->setCustomer($customer) ->create(); + +/** + * get all charges + * @return array 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 1d5ad79..bc918ea 100644 --- a/src/Gateways/Efi/Resources/Charge/Charge.php +++ b/src/Gateways/Efi/Resources/Charge/Charge.php @@ -28,6 +28,11 @@ class Charge implements ChargeInterface */ private array $items = []; + /** + * @var array + */ + private array $queryParams = []; + /** * @var array */ @@ -68,6 +73,30 @@ public function setCustomer(array $customer): Charge return $this; } + /** + * set filters + * + * @param array $queryParams + * @return ChargeInterface + * @deprecated + */ + public function setQueryParams(array $queryParams): ChargeInterface + { + $this->queryParams = $queryParams; + + return $this; + } + + /** + * find all charges + * + * @return array + */ + public function getAll(): array + { + return $this->get('v1/charges', $this->queryParams); + } + /** * create charge * diff --git a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php index 1b808ee..6dadcfe 100644 --- a/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php +++ b/src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php @@ -6,6 +6,13 @@ interface ChargeInterface { + /** + * get all charges + * + * @return array + */ + public function getAll(): array; + /** * set customer * @@ -13,4 +20,12 @@ interface ChargeInterface * @return Charge */ public function setCustomer(array $customer): Charge; + + /** + * set query params + * + * @param array $queryParams + * @return ChargeInterface + */ + public function setQueryParams(array $queryParams): ChargeInterface; }