Skip to content

Commit 1d565c6

Browse files
authored
feat: entities endpoint (#103)
1 parent efbb59e commit 1d565c6

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

src/API/Entities.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Ark PHP Client.
7+
*
8+
* (c) Ark Ecosystem <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace ArkEcosystem\Client\API;
15+
16+
/**
17+
* This is the entities resource class.
18+
*
19+
* @author Brian Faust <[email protected]>
20+
*/
21+
class Entities extends AbstractAPI
22+
{
23+
/**
24+
* Get all entities.
25+
*
26+
* @param array $query
27+
*
28+
* @return array
29+
*/
30+
public function all(array $query = []): ?array
31+
{
32+
return $this->get('entities', $query);
33+
}
34+
35+
/**
36+
* Get an entity by the given id.
37+
*
38+
* @param string $id
39+
*
40+
* @return array
41+
*/
42+
public function show(string $id): ?array
43+
{
44+
return $this->get("entities/{$id}");
45+
}
46+
}

tests/API/EntitiesTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of Ark PHP Client.
7+
*
8+
* (c) Ark Ecosystem <[email protected]>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace ArkEcosystem\Tests\Client\API;
15+
16+
use ArkEcosystem\Tests\Client\TestCase;
17+
18+
/**
19+
* This is the entities resource test class.
20+
*
21+
* @author Brian Faust <[email protected]>
22+
* @covers \ArkEcosystem\Client\API\Entities
23+
*/
24+
class EntitiesTest extends TestCase
25+
{
26+
/** @test */
27+
public function all_calls_correct_url()
28+
{
29+
$this->assertResponse('GET', 'entities', function ($connection) {
30+
return $connection->entities()->all();
31+
});
32+
}
33+
34+
/** @test */
35+
public function show_calls_correct_url()
36+
{
37+
$this->assertResponse('GET', 'entities/dummy', function ($connection) {
38+
return $connection->entities()->show('dummy');
39+
});
40+
}
41+
}

0 commit comments

Comments
 (0)