Skip to content

Commit e7864e8

Browse files
committed
Added balance and ledger module to V1 Apis
1 parent 816757c commit e7864e8

4 files changed

Lines changed: 127 additions & 24 deletions

File tree

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,31 @@ $executeParams['amount'] = '1';
265265
$response = $transferService->execute($executeParams)->wait();
266266
var_dump($response);
267267
```
268+
269+
### Balance Module
270+
271+
```php
272+
$balanceService = $ostObj->services->balances;
273+
```
274+
Get User balance:
275+
276+
```php
277+
$getParams = array();
278+
$response = $balanceService->get($getParams)->wait();
279+
var_dump($response);
280+
```
281+
282+
### Ledger Module
283+
284+
```php
285+
$ledgerService = $ostObj->services->ledger;
286+
```
287+
288+
Get User Ledger:
289+
290+
```php
291+
$getParams = array();
292+
$response = $ledgerService->get($getParams)->wait();
293+
var_dump($response);
294+
```
295+

src/Services/V1/Balances.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Balances class
4+
*/
5+
6+
namespace OST\V1;
7+
8+
use OST\Base;
9+
10+
/**
11+
* Class encapsulating methods to interact with V1 API's for Balances module
12+
*/
13+
class Balances extends Base
14+
{
15+
16+
const PREFIX = '/balances';
17+
18+
/**
19+
* Get balance of user
20+
*
21+
* @param array $params params for fetching balance of user
22+
*
23+
* @throws \Exception
24+
*
25+
* @return object
26+
*
27+
*/
28+
public function get($params = array()) {
29+
return $this->requestObj->get($this->getPrefix() . '/' . $this->getId($params) . '/', $params);
30+
}
31+
32+
}

src/Services/V1/Ledger.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Ledger class
4+
*/
5+
6+
namespace OST\V1;
7+
8+
use OST\Base;
9+
10+
/**
11+
* Class encapsulating methods to interact with V1 API's for Ledger module
12+
*/
13+
class Ledger extends Base
14+
{
15+
16+
const PREFIX = '/ledger';
17+
18+
/**
19+
* Get ledger for user
20+
*
21+
* @param array $params params for fetching ledger for an user
22+
*
23+
* @throws \Exception
24+
*
25+
* @return object
26+
*
27+
*/
28+
public function get($params = array()) {
29+
return $this->requestObj->get($this->getPrefix() . '/' . $this->getId($params) . '/', $params);
30+
}
31+
32+
}

src/Services/V1/Manifest.php

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,39 @@ class Manifest
3030
/** @var Transfers object which has methods to fire API's belonging to Transfers module */
3131
public $transfers;
3232

33-
/**
34-
* Constructor
35-
*
36-
* @param array $params Array containing the necessary params {
37-
* @type string $apiKey API Key.
38-
* @type string $apiSecret API Secret.
39-
* @type string $baseUrl Base API URL.
40-
* }
41-
*
42-
* @throws \Exception
43-
*
44-
*/
45-
public function __construct($params)
46-
{
47-
$requestObj = new Request($params);
48-
49-
// Define services available in V1
50-
$this->users = new Users($requestObj);
51-
$this->actions = new Actions($requestObj);
52-
$this->airdrops = new Airdrops($requestObj);
53-
$this->token = new Token($requestObj);
54-
$this->transactions = new Transactions($requestObj);
55-
$this->transfers = new Transfers($requestObj);
56-
}
33+
/** @var Balances object which has methods to fire API's belonging to Balances module */
34+
public $balances;
35+
36+
/** @var Ledger object which has methods to fire API's belonging to Ledger module */
37+
public $ledger;
38+
39+
/**
40+
* Constructor
41+
*
42+
* @param array $params Array containing the necessary params {
43+
* @type string $apiKey API Key.
44+
* @type string $apiSecret API Secret.
45+
* @type string $baseUrl Base API URL.
46+
* }
47+
*
48+
* @throws \Exception
49+
*
50+
*/
51+
public function __construct($params)
52+
{
53+
54+
$requestObj = new Request($params);
55+
56+
// Define services available in V1
57+
$this->users = new Users($requestObj);
58+
$this->actions = new Actions($requestObj);
59+
$this->airdrops = new Airdrops($requestObj);
60+
$this->token = new Token($requestObj);
61+
$this->transactions = new Transactions($requestObj);
62+
$this->transfers = new Transfers($requestObj);
63+
$this->balances = new Balances($requestObj);
64+
$this->ledger = new Ledger($requestObj);
65+
66+
}
67+
5768
}

0 commit comments

Comments
 (0)