Skip to content

Commit

Permalink
feat: entities endpoint (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Highjhacker committed Nov 13, 2020
1 parent efbb59e commit 1d565c6
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/API/Entities.php
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

/*
* This file is part of Ark PHP Client.
*
* (c) Ark Ecosystem <info@ark.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ArkEcosystem\Client\API;

/**
* This is the entities resource class.
*
* @author Brian Faust <brian@ark.io>
*/
class Entities extends AbstractAPI
{
/**
* Get all entities.
*
* @param array $query
*
* @return array
*/
public function all(array $query = []): ?array
{
return $this->get('entities', $query);
}

/**
* Get an entity by the given id.
*
* @param string $id
*
* @return array
*/
public function show(string $id): ?array
{
return $this->get("entities/{$id}");
}
}
41 changes: 41 additions & 0 deletions tests/API/EntitiesTest.php
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);

/*
* This file is part of Ark PHP Client.
*
* (c) Ark Ecosystem <info@ark.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace ArkEcosystem\Tests\Client\API;

use ArkEcosystem\Tests\Client\TestCase;

/**
* This is the entities resource test class.
*
* @author Brian Faust <brian@ark.io>
* @covers \ArkEcosystem\Client\API\Entities
*/
class EntitiesTest extends TestCase
{
/** @test */
public function all_calls_correct_url()
{
$this->assertResponse('GET', 'entities', function ($connection) {
return $connection->entities()->all();
});
}

/** @test */
public function show_calls_correct_url()
{
$this->assertResponse('GET', 'entities/dummy', function ($connection) {
return $connection->entities()->show('dummy');
});
}
}

0 comments on commit 1d565c6

Please sign in to comment.