From e3755cbcbc9460c20e8e80419f6315a30b85686e Mon Sep 17 00:00:00 2001 From: Edgar Goetzendorff Date: Wed, 4 Mar 2020 06:44:35 +0100 Subject: [PATCH] feat: add methods for first and last block (#84) --- src/API/Blocks.php | 20 ++++++++++++++++++++ tests/API/BlocksTest.php | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/API/Blocks.php b/src/API/Blocks.php index c9b75e4..aaa8b2c 100644 --- a/src/API/Blocks.php +++ b/src/API/Blocks.php @@ -44,6 +44,26 @@ public function show(string $id): array return $this->get("blocks/{$id}"); } + /** + * Get the first block. + * + * @return array + */ + public function first(): array + { + return $this->get('blocks/first'); + } + + /** + * Get the last block. + * + * @return array + */ + public function last(): array + { + return $this->get('blocks/last'); + } + /** * Get all transactions by the given block. * diff --git a/tests/API/BlocksTest.php b/tests/API/BlocksTest.php index 499fe01..1aeacc8 100644 --- a/tests/API/BlocksTest.php +++ b/tests/API/BlocksTest.php @@ -39,6 +39,22 @@ public function show_calls_correct_url() }); } + /** @test */ + public function first_calls_correct_url() + { + $this->assertResponse('GET', 'blocks/first', function ($connection) { + return $connection->blocks()->first(); + }); + } + + /** @test */ + public function last_calls_correct_url() + { + $this->assertResponse('GET', 'blocks/last', function ($connection) { + return $connection->blocks()->last(); + }); + } + /** @test */ public function transactions_calls_correct_url() {