From 2a4768c049e4900e019737557022f101b8b38998 Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Tue, 24 Dec 2024 09:35:39 -0300 Subject: [PATCH 1/2] PHPAY-29: PHPAY-29: feat: adding get all efi charges --- .gitignore | 3 +- examples/efi/charges.php | 15 ++++++++++ src/Gateways/Efi/Resources/Charge/Charge.php | 29 +++++++++++++++++++ .../Charge/Interface/ChargeInterface.php | 15 ++++++++++ 4 files changed, 61 insertions(+), 1 deletion(-) 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..cacae7e 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -28,3 +28,18 @@ ->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(); \ No newline at end of file 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; } From 6988b289a94e41cb5b2cb76e369f8cb5257980dc Mon Sep 17 00:00:00 2001 From: evandrosystems Date: Tue, 24 Dec 2024 09:45:24 -0300 Subject: [PATCH 2/2] PHPAY-29: feat: adding get all efi charges --- examples/efi/charges.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/efi/charges.php b/examples/efi/charges.php index cacae7e..ae4edec 100644 --- a/examples/efi/charges.php +++ b/examples/efi/charges.php @@ -29,7 +29,6 @@ ->setCustomer($customer) ->create(); - /** * get all charges * @return array charges @@ -38,8 +37,8 @@ ->charge() ->setQueryParams([ 'charge_type' => 'billet', - 'begin_date' => '2024-11-01', - 'end_date' => '2024-11-30', - 'status' => 'unpaid' + 'begin_date' => '2024-11-01', + 'end_date' => '2024-11-30', + 'status' => 'unpaid', ]) - ->getAll(); \ No newline at end of file + ->getAll();