Skip to content

Commit e3755cb

Browse files
authored
feat: add methods for first and last block (#84)
1 parent c8315c6 commit e3755cb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/API/Blocks.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,26 @@ public function show(string $id): array
4444
return $this->get("blocks/{$id}");
4545
}
4646

47+
/**
48+
* Get the first block.
49+
*
50+
* @return array
51+
*/
52+
public function first(): array
53+
{
54+
return $this->get('blocks/first');
55+
}
56+
57+
/**
58+
* Get the last block.
59+
*
60+
* @return array
61+
*/
62+
public function last(): array
63+
{
64+
return $this->get('blocks/last');
65+
}
66+
4767
/**
4868
* Get all transactions by the given block.
4969
*

tests/API/BlocksTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ public function show_calls_correct_url()
3939
});
4040
}
4141

42+
/** @test */
43+
public function first_calls_correct_url()
44+
{
45+
$this->assertResponse('GET', 'blocks/first', function ($connection) {
46+
return $connection->blocks()->first();
47+
});
48+
}
49+
50+
/** @test */
51+
public function last_calls_correct_url()
52+
{
53+
$this->assertResponse('GET', 'blocks/last', function ($connection) {
54+
return $connection->blocks()->last();
55+
});
56+
}
57+
4258
/** @test */
4359
public function transactions_calls_correct_url()
4460
{

0 commit comments

Comments
 (0)