Skip to content

Commit 86532d3

Browse files
committed
PHPAY-52: wip: resource pix list keys
1 parent 38fb15b commit 86532d3

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

examples/asaas/pix.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@
1717
*
1818
* @return string $pixKey
1919
*/
20-
$pixKey = $phpay
20+
$phpay
2121
->pix()
2222
->createKey();
2323

24-
print_r($pixKey);
24+
/**
25+
* get all pix keys
26+
*
27+
* @return array $pixKeys
28+
*/
29+
$phpay
30+
->pix()
31+
->getAll();

src/Gateways/Asaas/Resources/Pix/Pix.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class Pix implements PixInterface
1818
*/
1919
private Client $client;
2020

21+
/**
22+
* @var array<mixed>
23+
*/
24+
private array $queryParams = [];
25+
2126
/**
2227
* construct
2328
*
@@ -30,6 +35,19 @@ public function __construct(
3035
$this->client = $this->clientAsaasBoot();
3136
}
3237

38+
/**
39+
* set query params
40+
*
41+
* @param array<mixed> $queryParams
42+
* @return PixInterface
43+
*/
44+
public function setQueryParams(array $queryParams): PixInterface
45+
{
46+
$this->queryParams = $queryParams;
47+
48+
return $this;
49+
}
50+
3351
/**
3452
* create pix key
3553
*
@@ -44,4 +62,25 @@ public function createKey(): array
4462
'type' => 'EVP',
4563
]);
4664
}
65+
66+
/**
67+
* get all pix keys
68+
*
69+
* @return array<mixed>
70+
* @see params in https://docs.asaas.com/reference/list-keys
71+
*/
72+
public function getAll(): array
73+
{
74+
$params = $this->queryParams;
75+
76+
if (empty($params)) {
77+
$params = [
78+
'offset' => 0,
79+
'limit' => 100,
80+
'status' => 'ACTIVE',
81+
];
82+
}
83+
84+
return $this->get('pix/addressKeys', $params);
85+
}
4786
}

0 commit comments

Comments
 (0)