Skip to content

Commit 11a2523

Browse files
authored
refactor: use query array for endpoint params (#130)
1 parent 71551d7 commit 11a2523

File tree

6 files changed

+29
-8
lines changed

6 files changed

+29
-8
lines changed

src/API/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public function crypto(): ?array
4949
/**
5050
* Get the node fee statistics.
5151
*
52-
* @param int|null $days
52+
* @param array $query
5353
*
5454
* @return array
5555
*/
56-
public function fees(?int $days = null): ?array
56+
public function fees(array $query = []): ?array
5757
{
58-
return $this->requestGet('node/fees', ['days' => $days]);
58+
return $this->requestGet('node/fees', $query);
5959
}
6060
}

src/API/Transactions.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@ public function get(string $id): ?array
4545
/**
4646
* Get all unconfirmed transactions.
4747
*
48+
* @param array $query
49+
*
4850
* @return array
4951
*/
50-
public function allUnconfirmed(): ?array
52+
public function allUnconfirmed(array $query = []): ?array
5153
{
52-
return $this->withApi('transactions')->requestGet('transactions/unconfirmed');
54+
return $this->withApi('transactions')->requestGet('transactions/unconfirmed', $query);
5355
}
5456

5557
/**

src/API/Wallets.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@ public function votes(string $id, array $query = []): ?array
8585
/**
8686
* Get all wallets sorted by balance in descending order.
8787
*
88+
* @param array $query
89+
*
8890
* @return array
8991
*/
90-
public function top(): ?array
92+
public function top(array $query = []): ?array
9193
{
92-
return $this->requestGet('wallets/top');
94+
return $this->requestGet('wallets/top', $query);
9395
}
9496

9597
/**

tests/API/NodeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@
3838

3939
it('calls the correct url for fees with query', function () {
4040
$this->assertResponse('GET', 'node/fees?days=7', function (Client $client) {
41-
return $client->node()->fees(7);
41+
return $client->node()->fees(['days' => 7]);
4242
});
4343
});

tests/API/TransactionsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@
4040
);
4141
});
4242

43+
it('calls correct url for all unconfirmed with query', function () {
44+
$this->assertResponse(
45+
method: 'GET',
46+
path: 'transactions/unconfirmed?limit=50',
47+
callback: function (Client $client) {
48+
return $client->transactions()->allUnconfirmed(['limit' => 50]);
49+
},
50+
expectedApi: 'transactions'
51+
);
52+
});
53+
4354
it('calls correct url for get unconfirmed', function () {
4455
$this->assertResponse(
4556
method: 'GET',

tests/API/WalletsTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
});
1919
});
2020

21+
it('calls correct url for top with query', function () {
22+
$this->assertResponse('GET', 'wallets/top?limit=10', function (Client $client) {
23+
return $client->wallets()->top(['limit' => 10]);
24+
});
25+
});
26+
2127
it('calls correct url for get', function () {
2228
$this->assertResponse('GET', 'wallets/dummy', function (Client $client) {
2329
return $client->wallets()->get('dummy');

0 commit comments

Comments
 (0)