Skip to content

Commit

Permalink
feat: add methods for first and last block (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated committed Mar 4, 2020
1 parent c8315c6 commit e3755cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/API/Blocks.php
Expand Up @@ -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.
*
Expand Down
16 changes: 16 additions & 0 deletions tests/API/BlocksTest.php
Expand Up @@ -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()
{
Expand Down

0 comments on commit e3755cb

Please sign in to comment.