Skip to content

Commit 11dd776

Browse files
authored
refactor: schema changes (#122)
1 parent 6e7f3e2 commit 11dd776

File tree

6 files changed

+61
-61
lines changed

6 files changed

+61
-61
lines changed

src/API/Commits.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
class Commits extends AbstractAPI
88
{
99
/**
10-
* Takes a block height and returns the commit details.
10+
* Takes a block number and returns the commit details.
1111
*
1212
* @param int $id
1313
*
1414
* @return array
1515
*/
16-
public function get(int $height): ?array
16+
public function get(int $number): ?array
1717
{
18-
return $this->requestGet("commits/{$height}");
18+
return $this->requestGet("commits/{$number}");
1919
}
2020
}

src/API/Rounds.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ public function get(int $round_id): ?array
3131
}
3232

3333
/**
34-
* Get the forging delegates of a round by the given id.
34+
* Get the forging validators of a round by the given id.
3535
*
3636
* @param int $round_id
3737
*
3838
* @return array
3939
*/
40-
public function delegates(int $round_id): ?array
40+
public function validators(int $round_id): ?array
4141
{
42-
return $this->requestGet("rounds/{$round_id}/delegates");
42+
return $this->requestGet("rounds/{$round_id}/validators");
4343
}
4444
}

src/API/Delegates.php renamed to src/API/Validators.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace ArkEcosystem\Client\API;
66

7-
class Delegates extends AbstractAPI
7+
class Validators extends AbstractAPI
88
{
99
/**
1010
* Get all accounts.
@@ -15,7 +15,7 @@ class Delegates extends AbstractAPI
1515
*/
1616
public function all(array $query = []): ?array
1717
{
18-
return $this->requestGet('delegates', $query);
18+
return $this->requestGet('validators', $query);
1919
}
2020

2121
/**
@@ -27,11 +27,11 @@ public function all(array $query = []): ?array
2727
*/
2828
public function get(string $id): ?array
2929
{
30-
return $this->requestGet("delegates/{$id}");
30+
return $this->requestGet("validators/{$id}");
3131
}
3232

3333
/**
34-
* Get all blocks for the given delegate.
34+
* Get all blocks for the given validator.
3535
*
3636
* @param string $id
3737
* @param array $query
@@ -40,11 +40,11 @@ public function get(string $id): ?array
4040
*/
4141
public function blocks(string $id, array $query = []): ?array
4242
{
43-
return $this->requestGet("delegates/{$id}/blocks", $query);
43+
return $this->requestGet("validators/{$id}/blocks", $query);
4444
}
4545

4646
/**
47-
* Get all voters for the given delegate.
47+
* Get all voters for the given validator.
4848
*
4949
* @param string $id
5050
* @param array $query
@@ -53,6 +53,6 @@ public function blocks(string $id, array $query = []): ?array
5353
*/
5454
public function voters(string $id, array $query = []): ?array
5555
{
56-
return $this->requestGet("delegates/{$id}/voters", $query);
56+
return $this->requestGet("validators/{$id}/voters", $query);
5757
}
5858
}

tests/API/DelegatesTest.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/API/RoundsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function view_calls_correct_url()
2828
}
2929

3030
/** @test */
31-
public function delegates_calls_correct_url()
31+
public function validators_calls_correct_url()
3232
{
33-
$this->assertResponse('GET', 'rounds/12345/delegates', function ($client) {
34-
return $client->rounds()->delegates(12345);
33+
$this->assertResponse('GET', 'rounds/12345/validators', function ($client) {
34+
return $client->rounds()->validators(12345);
3535
});
3636
}
3737
}

tests/API/ValidatorsTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ArkEcosystem\Tests\Client\API;
6+
7+
use ArkEcosystem\Tests\Client\TestCase;
8+
9+
/**
10+
* @covers \ArkEcosystem\Client\API\Validators
11+
*/
12+
class ValidatorsTest extends TestCase
13+
{
14+
/** @test */
15+
public function all_calls_correct_url()
16+
{
17+
$this->assertResponse('GET', 'validators', function ($client) {
18+
return $client->validators()->all();
19+
});
20+
}
21+
22+
/** @test */
23+
public function get_calls_correct_url()
24+
{
25+
$this->assertResponse('GET', 'validators/dummy', function ($client) {
26+
return $client->validators()->get('dummy');
27+
});
28+
}
29+
30+
/** @test */
31+
public function blocks_calls_correct_url()
32+
{
33+
$this->assertResponse('GET', 'validators/dummy/blocks', function ($client) {
34+
return $client->validators()->blocks('dummy');
35+
});
36+
}
37+
38+
/** @test */
39+
public function voters_calls_correct_url()
40+
{
41+
$this->assertResponse('GET', 'validators/dummy/voters', function ($client) {
42+
return $client->validators()->voters('dummy');
43+
});
44+
}
45+
}

0 commit comments

Comments
 (0)