From 627ae62e91e3dad3ca53ca5e0a5d67d929628e74 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Thu, 27 Mar 2025 00:00:37 +0000 Subject: [PATCH 1/2] refactor: rename show methods to get --- src/API/AbstractAPI.php | 4 ++-- src/API/ApiNodes.php | 2 +- src/API/Blockchain.php | 2 +- src/API/Blocks.php | 12 ++++++------ src/API/Commits.php | 4 ++-- src/API/Delegates.php | 10 +++++----- src/API/EVM.php | 2 +- src/API/Node.php | 10 +++++----- src/API/Peers.php | 6 +++--- src/API/Receipts.php | 6 +++--- src/API/Rounds.php | 8 ++++---- src/API/Transactions.php | 22 +++++++++++----------- src/API/Votes.php | 6 +++--- src/API/Wallets.php | 16 ++++++++-------- 14 files changed, 55 insertions(+), 55 deletions(-) diff --git a/src/API/AbstractAPI.php b/src/API/AbstractAPI.php index 71d2b94..3ea7ac3 100644 --- a/src/API/AbstractAPI.php +++ b/src/API/AbstractAPI.php @@ -41,7 +41,7 @@ public function __construct(ArkClient $client) * * @return array|null|bool */ - protected function get(string $path, array $query = []) + protected function requestGet(string $path, array $query = []) { $response = $this->client->getHttpClient()->get($this->buildUrl($path), [ 'query' => Arr::dot($query), @@ -58,7 +58,7 @@ protected function get(string $path, array $query = []) * * @return array|null|bool */ - protected function post(string $path, array $parameters = []) + protected function requestPost(string $path, array $parameters = []) { $response = $this->client->getHttpClient()->post( $this->buildUrl($path), diff --git a/src/API/ApiNodes.php b/src/API/ApiNodes.php index 49c1de1..823975f 100644 --- a/src/API/ApiNodes.php +++ b/src/API/ApiNodes.php @@ -15,6 +15,6 @@ class ApiNodes extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('api-nodes', $query); + return $this->requestGet('api-nodes', $query); } } diff --git a/src/API/Blockchain.php b/src/API/Blockchain.php index d80f780..d7a278d 100644 --- a/src/API/Blockchain.php +++ b/src/API/Blockchain.php @@ -15,6 +15,6 @@ class Blockchain extends AbstractAPI */ public function blockchain(): ?array { - return $this->get('blockchain'); + return $this->requestGet('blockchain'); } } diff --git a/src/API/Blocks.php b/src/API/Blocks.php index 934f24c..ecf6645 100644 --- a/src/API/Blocks.php +++ b/src/API/Blocks.php @@ -15,7 +15,7 @@ class Blocks extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('blocks', $query); + return $this->requestGet('blocks', $query); } /** @@ -25,9 +25,9 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $id): ?array + public function get(string $id): ?array { - return $this->get("blocks/{$id}"); + return $this->requestGet("blocks/{$id}"); } /** @@ -37,7 +37,7 @@ public function show(string $id): ?array */ public function first(): ?array { - return $this->get('blocks/first'); + return $this->requestGet('blocks/first'); } /** @@ -47,7 +47,7 @@ public function first(): ?array */ public function last(): ?array { - return $this->get('blocks/last'); + return $this->requestGet('blocks/last'); } /** @@ -60,6 +60,6 @@ public function last(): ?array */ public function transactions(string $id, array $query = []): ?array { - return $this->get("blocks/{$id}/transactions", $query); + return $this->requestGet("blocks/{$id}/transactions", $query); } } diff --git a/src/API/Commits.php b/src/API/Commits.php index c1310ef..916255e 100644 --- a/src/API/Commits.php +++ b/src/API/Commits.php @@ -13,8 +13,8 @@ class Commits extends AbstractAPI * * @return array */ - public function show(int $height): ?array + public function get(int $height): ?array { - return $this->get("commits/{$height}"); + return $this->requestGet("commits/{$height}"); } } diff --git a/src/API/Delegates.php b/src/API/Delegates.php index 8d7ea28..e7142ff 100644 --- a/src/API/Delegates.php +++ b/src/API/Delegates.php @@ -15,7 +15,7 @@ class Delegates extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('delegates', $query); + return $this->requestGet('delegates', $query); } /** @@ -25,9 +25,9 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $id): ?array + public function get(string $id): ?array { - return $this->get("delegates/{$id}"); + return $this->requestGet("delegates/{$id}"); } /** @@ -40,7 +40,7 @@ public function show(string $id): ?array */ public function blocks(string $id, array $query = []): ?array { - return $this->get("delegates/{$id}/blocks", $query); + return $this->requestGet("delegates/{$id}/blocks", $query); } /** @@ -53,6 +53,6 @@ public function blocks(string $id, array $query = []): ?array */ public function voters(string $id, array $query = []): ?array { - return $this->get("delegates/{$id}/voters", $query); + return $this->requestGet("delegates/{$id}/voters", $query); } } diff --git a/src/API/EVM.php b/src/API/EVM.php index 9f972f1..2195b6a 100644 --- a/src/API/EVM.php +++ b/src/API/EVM.php @@ -26,6 +26,6 @@ public function ethCall(array $payload): ?array 'Content-Type' => 'application/json', ]; - return $this->withApi('evm')->post('api/', $body, $headers); + return $this->withApi('evm')->requestPost('api/', $body, $headers); } } diff --git a/src/API/Node.php b/src/API/Node.php index af5b82e..05dd9db 100644 --- a/src/API/Node.php +++ b/src/API/Node.php @@ -13,7 +13,7 @@ class Node extends AbstractAPI */ public function status(): ?array { - return $this->get('node/status'); + return $this->requestGet('node/status'); } /** @@ -23,7 +23,7 @@ public function status(): ?array */ public function syncing(): ?array { - return $this->get('node/syncing'); + return $this->requestGet('node/syncing'); } /** @@ -33,7 +33,7 @@ public function syncing(): ?array */ public function configuration(): ?array { - return $this->get('node/configuration'); + return $this->requestGet('node/configuration'); } /** @@ -43,7 +43,7 @@ public function configuration(): ?array */ public function crypto(): ?array { - return $this->get('node/configuration/crypto'); + return $this->requestGet('node/configuration/crypto'); } /** @@ -55,6 +55,6 @@ public function crypto(): ?array */ public function fees(?int $days = null): ?array { - return $this->get('node/fees', ['days' => $days]); + return $this->requestGet('node/fees', ['days' => $days]); } } diff --git a/src/API/Peers.php b/src/API/Peers.php index 7459333..1b4bbab 100644 --- a/src/API/Peers.php +++ b/src/API/Peers.php @@ -15,7 +15,7 @@ class Peers extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('peers', $query); + return $this->requestGet('peers', $query); } /** @@ -25,8 +25,8 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $ip): ?array + public function get(string $ip): ?array { - return $this->get("peers/{$ip}"); + return $this->requestGet("peers/{$ip}"); } } diff --git a/src/API/Receipts.php b/src/API/Receipts.php index e49b1cd..89009d1 100644 --- a/src/API/Receipts.php +++ b/src/API/Receipts.php @@ -17,7 +17,7 @@ class Receipts extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('receipts', $query); + return $this->requestGet('receipts', $query); } /** @@ -27,9 +27,9 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $txHash): ?array + public function get(string $txHash): ?array { - $result = $this->get('receipts', ['txHash' => $txHash])['data']; + $result = $this->requestGet('receipts', ['txHash' => $txHash])['data']; if (empty($result)) { throw new Exception(sprintf('No receipt found for transaction %s', $txHash)); diff --git a/src/API/Rounds.php b/src/API/Rounds.php index f490366..8f3e2c3 100644 --- a/src/API/Rounds.php +++ b/src/API/Rounds.php @@ -15,7 +15,7 @@ class Rounds extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('rounds', $query); + return $this->requestGet('rounds', $query); } /** @@ -25,9 +25,9 @@ public function all(array $query = []): ?array * * @return array */ - public function show(int $round_id): ?array + public function get(int $round_id): ?array { - return $this->get("rounds/{$round_id}"); + return $this->requestGet("rounds/{$round_id}"); } /** @@ -39,6 +39,6 @@ public function show(int $round_id): ?array */ public function delegates(int $round_id): ?array { - return $this->get("rounds/{$round_id}/delegates"); + return $this->requestGet("rounds/{$round_id}/delegates"); } } diff --git a/src/API/Transactions.php b/src/API/Transactions.php index d24c144..e6286b8 100644 --- a/src/API/Transactions.php +++ b/src/API/Transactions.php @@ -15,7 +15,7 @@ class Transactions extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('transactions', $query); + return $this->requestGet('transactions', $query); } /** @@ -27,7 +27,7 @@ public function all(array $query = []): ?array */ public function create(array $transactions): ?array { - return $this->withApi('transactions')->post('transactions', compact('transactions')); + return $this->withApi('transactions')->requestPost('transactions', compact('transactions')); } /** @@ -37,9 +37,9 @@ public function create(array $transactions): ?array * * @return array */ - public function show(string $id): ?array + public function get(string $id): ?array { - return $this->get("transactions/{$id}"); + return $this->requestGet("transactions/{$id}"); } /** @@ -49,7 +49,7 @@ public function show(string $id): ?array */ public function allUnconfirmed(): ?array { - return $this->withApi('transactions')->get('transactions/unconfirmed'); + return $this->withApi('transactions')->requestGet('transactions/unconfirmed'); } /** @@ -59,9 +59,9 @@ public function allUnconfirmed(): ?array * * @return array */ - public function showUnconfirmed(string $id): ?array + public function getUnconfirmed(string $id): ?array { - return $this->withApi('transactions')->get("transactions/unconfirmed/{$id}"); + return $this->withApi('transactions')->requestGet("transactions/unconfirmed/{$id}"); } /** @@ -71,7 +71,7 @@ public function showUnconfirmed(string $id): ?array */ public function types(): ?array { - return $this->get('transactions/types'); + return $this->requestGet('transactions/types'); } /** @@ -81,7 +81,7 @@ public function types(): ?array */ public function fees(): ?array { - return $this->get('transactions/fees'); + return $this->requestGet('transactions/fees'); } /** @@ -91,7 +91,7 @@ public function fees(): ?array */ public function schemas(): ?array { - return $this->get('transactions/schemas'); + return $this->requestGet('transactions/schemas'); } /** @@ -101,6 +101,6 @@ public function schemas(): ?array */ public function configuration(): ?array { - return $this->withApi('transactions')->get('configuration'); + return $this->withApi('transactions')->requestGet('configuration'); } } diff --git a/src/API/Votes.php b/src/API/Votes.php index b712f22..5ae431a 100644 --- a/src/API/Votes.php +++ b/src/API/Votes.php @@ -15,7 +15,7 @@ class Votes extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('votes', $query); + return $this->requestGet('votes', $query); } /** @@ -25,8 +25,8 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $id): ?array + public function get(string $id): ?array { - return $this->get("votes/{$id}"); + return $this->requestGet("votes/{$id}"); } } diff --git a/src/API/Wallets.php b/src/API/Wallets.php index e858c4b..f473a8c 100644 --- a/src/API/Wallets.php +++ b/src/API/Wallets.php @@ -15,7 +15,7 @@ class Wallets extends AbstractAPI */ public function all(array $query = []): ?array { - return $this->get('wallets', $query); + return $this->requestGet('wallets', $query); } /** @@ -25,9 +25,9 @@ public function all(array $query = []): ?array * * @return array */ - public function show(string $id): ?array + public function get(string $id): ?array { - return $this->get("wallets/{$id}"); + return $this->requestGet("wallets/{$id}"); } /** @@ -40,7 +40,7 @@ public function show(string $id): ?array */ public function transactions(string $id, array $query = []): ?array { - return $this->get("wallets/{$id}/transactions", $query); + return $this->requestGet("wallets/{$id}/transactions", $query); } /** @@ -53,7 +53,7 @@ public function transactions(string $id, array $query = []): ?array */ public function sentTransactions(string $id, array $query = []): ?array { - return $this->get("wallets/{$id}/transactions/sent", $query); + return $this->requestGet("wallets/{$id}/transactions/sent", $query); } /** @@ -66,7 +66,7 @@ public function sentTransactions(string $id, array $query = []): ?array */ public function receivedTransactions(string $id, array $query = []): ?array { - return $this->get("wallets/{$id}/transactions/received", $query); + return $this->requestGet("wallets/{$id}/transactions/received", $query); } /** @@ -79,7 +79,7 @@ public function receivedTransactions(string $id, array $query = []): ?array */ public function votes(string $id, array $query = []): ?array { - return $this->get("wallets/{$id}/votes", $query); + return $this->requestGet("wallets/{$id}/votes", $query); } /** @@ -89,6 +89,6 @@ public function votes(string $id, array $query = []): ?array */ public function top(): ?array { - return $this->get('wallets/top'); + return $this->requestGet('wallets/top'); } } From 7b1f7d66a9dd35520eb22870d15577d75fb3b956 Mon Sep 17 00:00:00 2001 From: Alex Barnsley <8069294+alexbarnsley@users.noreply.github.com> Date: Thu, 27 Mar 2025 00:00:55 +0000 Subject: [PATCH 2/2] test --- tests/API/BlocksTest.php | 4 ++-- tests/API/CommitsTest.php | 4 ++-- tests/API/DelegatesTest.php | 4 ++-- tests/API/PeersTest.php | 4 ++-- tests/API/ReceiptsTest.php | 6 +++--- tests/API/RoundsTest.php | 2 +- tests/API/TransactionsTest.php | 8 ++++---- tests/API/VotesTest.php | 4 ++-- tests/API/WalletsTest.php | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/API/BlocksTest.php b/tests/API/BlocksTest.php index a3a9d48..90035ed 100644 --- a/tests/API/BlocksTest.php +++ b/tests/API/BlocksTest.php @@ -20,10 +20,10 @@ public function all_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'blocks/dummy', function ($client) { - return $client->blocks()->show('dummy'); + return $client->blocks()->get('dummy'); }); } diff --git a/tests/API/CommitsTest.php b/tests/API/CommitsTest.php index 7aa3ef3..d0116a3 100644 --- a/tests/API/CommitsTest.php +++ b/tests/API/CommitsTest.php @@ -12,10 +12,10 @@ class CommitsTest extends TestCase { /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'commits/1', function ($client) { - return $client->commits()->show(1); + return $client->commits()->get(1); }); } } diff --git a/tests/API/DelegatesTest.php b/tests/API/DelegatesTest.php index 2c5be05..8da8435 100644 --- a/tests/API/DelegatesTest.php +++ b/tests/API/DelegatesTest.php @@ -20,10 +20,10 @@ public function all_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'delegates/dummy', function ($client) { - return $client->delegates()->show('dummy'); + return $client->delegates()->get('dummy'); }); } diff --git a/tests/API/PeersTest.php b/tests/API/PeersTest.php index 5449e0e..6fc4b12 100644 --- a/tests/API/PeersTest.php +++ b/tests/API/PeersTest.php @@ -20,10 +20,10 @@ public function all_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'peers/dummy', function ($client) { - return $client->peers()->show('dummy'); + return $client->peers()->get('dummy'); }); } } diff --git a/tests/API/ReceiptsTest.php b/tests/API/ReceiptsTest.php index 67e5996..370a31e 100644 --- a/tests/API/ReceiptsTest.php +++ b/tests/API/ReceiptsTest.php @@ -21,13 +21,13 @@ public function all_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse( method: 'GET', path: 'receipts?txHash=dummyTxHash', callback: function ($client) { - return $client->receipts()->show('dummyTxHash'); + return $client->receipts()->get('dummyTxHash'); }, response: ['data' => [['id' => 'dummyTxHash']]], expectedBody: ['id' => 'dummyTxHash'] @@ -43,7 +43,7 @@ public function validates_the_response() method: 'GET', path: 'receipts?txHash=dummyTxHash', callback: function ($client) { - return $client->receipts()->show('dummyTxHash'); + return $client->receipts()->get('dummyTxHash'); }, response: ['data' => []], ); diff --git a/tests/API/RoundsTest.php b/tests/API/RoundsTest.php index c61c3fb..e2e9636 100644 --- a/tests/API/RoundsTest.php +++ b/tests/API/RoundsTest.php @@ -23,7 +23,7 @@ public function all_calls_correct_url() public function view_calls_correct_url() { $this->assertResponse('GET', 'rounds/12345', function ($client) { - return $client->rounds()->show(12345); + return $client->rounds()->get(12345); }); } diff --git a/tests/API/TransactionsTest.php b/tests/API/TransactionsTest.php index 7088361..6052082 100644 --- a/tests/API/TransactionsTest.php +++ b/tests/API/TransactionsTest.php @@ -33,10 +33,10 @@ public function create_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'transactions/dummy', function ($client) { - return $client->transactions()->show('dummy'); + return $client->transactions()->get('dummy'); }); } @@ -54,13 +54,13 @@ public function all_unconfirmed_calls_correct_url() } /** @test */ - public function show_unconfirmed_calls_correct_url() + public function get_unconfirmed_calls_correct_url() { $this->assertResponse( method: 'GET', path: 'transactions/unconfirmed/dummy', callback: function ($client) { - return $client->transactions()->showUnconfirmed('dummy'); + return $client->transactions()->getUnconfirmed('dummy'); }, expectedApi: 'transactions' ); diff --git a/tests/API/VotesTest.php b/tests/API/VotesTest.php index fcbe61e..3f5be5f 100644 --- a/tests/API/VotesTest.php +++ b/tests/API/VotesTest.php @@ -20,10 +20,10 @@ public function all_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'votes/dummy', function ($client) { - return $client->votes()->show('dummy'); + return $client->votes()->get('dummy'); }); } diff --git a/tests/API/WalletsTest.php b/tests/API/WalletsTest.php index 91ac78f..4498154 100644 --- a/tests/API/WalletsTest.php +++ b/tests/API/WalletsTest.php @@ -28,10 +28,10 @@ public function top_calls_correct_url() } /** @test */ - public function show_calls_correct_url() + public function get_calls_correct_url() { $this->assertResponse('GET', 'wallets/dummy', function ($client) { - return $client->wallets()->show('dummy'); + return $client->wallets()->get('dummy'); }); }