Skip to content

Commit 2a4768c

Browse files
PHPAY-29: PHPAY-29: feat: adding get all efi charges
1 parent 7fda7b5 commit 2a4768c

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
vendor/
22
node_modules/
33
examples/asaas/credentials.php
4-
examples/efi/credentials.php
4+
examples/efi/credentials.php
5+
.idea/

examples/efi/charges.php

+15
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@
2828
->charge($charge)
2929
->setCustomer($customer)
3030
->create();
31+
32+
33+
/**
34+
* get all charges
35+
* @return array charges
36+
*/
37+
$phpay
38+
->charge()
39+
->setQueryParams([
40+
'charge_type' => 'billet',
41+
'begin_date' => '2024-11-01',
42+
'end_date' => '2024-11-30',
43+
'status' => 'unpaid'
44+
])
45+
->getAll();

src/Gateways/Efi/Resources/Charge/Charge.php

+29
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class Charge implements ChargeInterface
2828
*/
2929
private array $items = [];
3030

31+
/**
32+
* @var array<mixed>
33+
*/
34+
private array $queryParams = [];
35+
3136
/**
3237
* @var array<mixed>
3338
*/
@@ -68,6 +73,30 @@ public function setCustomer(array $customer): Charge
6873
return $this;
6974
}
7075

76+
/**
77+
* set filters
78+
*
79+
* @param array<mixed> $queryParams
80+
* @return ChargeInterface
81+
* @deprecated
82+
*/
83+
public function setQueryParams(array $queryParams): ChargeInterface
84+
{
85+
$this->queryParams = $queryParams;
86+
87+
return $this;
88+
}
89+
90+
/**
91+
* find all charges
92+
*
93+
* @return array<array|mixed>
94+
*/
95+
public function getAll(): array
96+
{
97+
return $this->get('v1/charges', $this->queryParams);
98+
}
99+
71100
/**
72101
* create charge
73102
*

src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php

+15
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,26 @@
66

77
interface ChargeInterface
88
{
9+
/**
10+
* get all charges
11+
*
12+
* @return array<array|mixed>
13+
*/
14+
public function getAll(): array;
15+
916
/**
1017
* set customer
1118
*
1219
* @param array<mixed> $customer
1320
* @return Charge
1421
*/
1522
public function setCustomer(array $customer): Charge;
23+
24+
/**
25+
* set query params
26+
*
27+
* @param array<mixed> $queryParams
28+
* @return ChargeInterface
29+
*/
30+
public function setQueryParams(array $queryParams): ChargeInterface;
1631
}

0 commit comments

Comments
 (0)