Skip to content

Commit a18f35a

Browse files
committed
refactor: use query array for endpoint params
1 parent 6c05ac5 commit a18f35a

6 files changed

Lines changed: 64 additions & 7 deletions

File tree

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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@
3535
return $client->node()->fees();
3636
});
3737
});
38+
39+
it('calls the correct url for fees with query', function () {
40+
$this->assertResponse('GET', 'node/fees?days=7', function (ArkClient $client) {
41+
return $client->node()->fees(['days' => 7]);
42+
});
43+
});

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 (ArkClient $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: 36 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 (ArkClient $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 (ArkClient $client) {
2329
return $client->wallets()->get('dummy');
@@ -75,3 +81,33 @@
7581
]);
7682
});
7783
});
84+
85+
it('calls correct url for a wallet tokens with whitelist', function () {
86+
$this->assertResponse(
87+
'POST',
88+
'wallets/dummy/tokens',
89+
function (ArkClient $client) {
90+
return $client->wallets()->tokensFor('dummy', [
91+
'whitelist' => ['0x1234567890abcdef1234567890abcdef12345678'],
92+
]);
93+
},
94+
expectedRequestBody: [
95+
'whitelist' => ['0x1234567890abcdef1234567890abcdef12345678'],
96+
]
97+
);
98+
});
99+
100+
it('calls correct url for all wallet tokens with whitelist', function () {
101+
$this->assertResponse(
102+
'POST',
103+
'wallets/tokens',
104+
function (ArkClient $client) {
105+
return $client->wallets()->tokens([
106+
'whitelist' => ['0x1234567890abcdef1234567890abcdef12345678'],
107+
]);
108+
},
109+
expectedRequestBody: [
110+
'whitelist' => ['0x1234567890abcdef1234567890abcdef12345678'],
111+
]
112+
);
113+
});

0 commit comments

Comments
 (0)