Skip to content

Commit 77e891f

Browse files
datedfaustbrian
authored andcommitted
feat: 2.6 api endpoints (#75)
1 parent fae7b10 commit 77e891f

File tree

8 files changed

+383
-0
lines changed

8 files changed

+383
-0
lines changed

src/API/Bridgechains.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 bridgechains resource class.
18+
*
19+
* @author Brian Faust <[email protected]>
20+
*/
21+
class Bridgechains extends AbstractAPI
22+
{
23+
/**
24+
* Get all bridgechains.
25+
*
26+
* @param array $query
27+
*
28+
* @return array
29+
*/
30+
public function all(array $query = []): array
31+
{
32+
return $this->get('bridgechains', $query);
33+
}
34+
35+
/**
36+
* Get a bridgechain 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("bridgechain/{$id}");
45+
}
46+
47+
/**
48+
* Filter all bridgechains by the given parameters.
49+
*
50+
* @param array $parameters
51+
*
52+
* @return array
53+
*/
54+
public function search(array $parameters): array
55+
{
56+
return $this->post('bridgechain/search', $parameters);
57+
}
58+
}

src/API/Businesses.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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 businesses resource class.
18+
*
19+
* @author Brian Faust <[email protected]>
20+
*/
21+
class Businesses extends AbstractAPI
22+
{
23+
/**
24+
* Get all businesses.
25+
*
26+
* @param array $query
27+
*
28+
* @return array
29+
*/
30+
public function all(array $query = []): array
31+
{
32+
return $this->get('businesses', $query);
33+
}
34+
35+
/**
36+
* Get a business 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("businesses/{$id}");
45+
}
46+
47+
/**
48+
* Get all bridgechains for the given business.
49+
*
50+
* @param string $id
51+
* @param array $query
52+
*
53+
* @return array
54+
*/
55+
public function bridgechains(string $id, array $query = []): array
56+
{
57+
return $this->get("businesses/{$id}/bridgechains", $query);
58+
}
59+
60+
/**
61+
* Filter all businesses by the given parameters.
62+
*
63+
* @param array $parameters
64+
*
65+
* @return array
66+
*/
67+
public function search(array $parameters): array
68+
{
69+
return $this->post('businesses/search', $parameters);
70+
}
71+
}

src/API/Locks.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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 locks resource class.
18+
*
19+
* @author Brian Faust <[email protected]>
20+
*/
21+
class Locks extends AbstractAPI
22+
{
23+
/**
24+
* Get all locks.
25+
*
26+
* @param array $query
27+
*
28+
* @return array
29+
*/
30+
public function all(array $query = []): array
31+
{
32+
return $this->get('locks', $query);
33+
}
34+
35+
/**
36+
* Get a locks 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("locks/{$id}");
45+
}
46+
47+
/**
48+
* Filter all locks by the given parameters.
49+
*
50+
* @param array $parameters
51+
*
52+
* @return array
53+
*/
54+
public function search(array $parameters): array
55+
{
56+
return $this->post('locks/search', $parameters);
57+
}
58+
59+
/**
60+
* Filter all unlocked locks by the given parameters.
61+
*
62+
* @param array $parameters
63+
*
64+
* @return array
65+
*/
66+
public function unlocked(array $parameters): array
67+
{
68+
return $this->post('locks/unlocked', $parameters);
69+
}
70+
}

src/API/Wallets.php

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

47+
/**
48+
* Get all locks for the given wallet.
49+
*
50+
* @param string $id
51+
* @param array $query
52+
*
53+
* @return array
54+
*/
55+
public function locks(string $id, array $query = []): array
56+
{
57+
return $this->get("wallets/{$id}/locks", $query);
58+
}
59+
4760
/**
4861
* Get all transactions for the given wallet.
4962
*

tests/API/BridgechainsTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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 bridgechains resource test class.
20+
*
21+
* @author Brian Faust <[email protected]>
22+
* @covers \ArkEcosystem\Client\API\Bridgechains
23+
*/
24+
class BridgechainsTest extends TestCase
25+
{
26+
/** @test */
27+
public function all_calls_correct_url()
28+
{
29+
$this->assertResponse('GET', 'bridgechains', function ($connection) {
30+
return $connection->bridgechains()->all();
31+
});
32+
}
33+
34+
/** @test */
35+
public function show_calls_correct_url()
36+
{
37+
$this->assertResponse('GET', 'bridgechains/dummy', function ($connection) {
38+
return $connection->bridgechains()->show('dummy');
39+
});
40+
}
41+
42+
/** @test */
43+
public function search_calls_correct_url()
44+
{
45+
$this->assertResponse('POST', 'bridgechains/search', function ($connection) {
46+
return $connection->bridgechains()->search(['address' => 'dummy']);
47+
});
48+
}
49+
}

tests/API/BusinessesTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 businesses resource test class.
20+
*
21+
* @author Brian Faust <[email protected]>
22+
* @covers \ArkEcosystem\Client\API\Businesses
23+
*/
24+
class BusinessesTest extends TestCase
25+
{
26+
/** @test */
27+
public function all_calls_correct_url()
28+
{
29+
$this->assertResponse('GET', 'businesses', function ($connection) {
30+
return $connection->businesses()->all();
31+
});
32+
}
33+
34+
/** @test */
35+
public function show_calls_correct_url()
36+
{
37+
$this->assertResponse('GET', 'businesses/dummy', function ($connection) {
38+
return $connection->businesses()->show('dummy');
39+
});
40+
}
41+
42+
/** @test */
43+
public function bridgechains_calls_correct_url()
44+
{
45+
$this->assertResponse('GET', 'businesses/dummy/bridgechains', function ($connection) {
46+
return $connection->businesses()->bridgechains('dummy');
47+
});
48+
}
49+
50+
/** @test */
51+
public function search_calls_correct_url()
52+
{
53+
$this->assertResponse('POST', 'businesses/search', function ($connection) {
54+
return $connection->businesses()->search(['address' => 'dummy']);
55+
});
56+
}
57+
}

tests/API/LocksTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 locks resource test class.
20+
*
21+
* @author Brian Faust <[email protected]>
22+
* @covers \ArkEcosystem\Client\API\Locks
23+
*/
24+
class LocksTest extends TestCase
25+
{
26+
/** @test */
27+
public function all_calls_correct_url()
28+
{
29+
$this->assertResponse('GET', 'locks', function ($connection) {
30+
return $connection->locks()->all();
31+
});
32+
}
33+
34+
/** @test */
35+
public function show_calls_correct_url()
36+
{
37+
$this->assertResponse('GET', 'locks/dummy', function ($connection) {
38+
return $connection->locks()->show('dummy');
39+
});
40+
}
41+
42+
/** @test */
43+
public function search_calls_correct_url()
44+
{
45+
$this->assertResponse('POST', 'locks/search', function ($connection) {
46+
return $connection->locks()->search(['address' => 'dummy']);
47+
});
48+
}
49+
50+
/** @test */
51+
public function unlocked_calls_correct_url()
52+
{
53+
$this->assertResponse('POST', 'locks/unlocked', function ($connection) {
54+
return $connection->locks()->unlocked(['address' => 'dummy']);
55+
});
56+
}
57+
}

0 commit comments

Comments
 (0)