@@ -4,7 +4,7 @@ |
||
4 | 4 | namespace Appino\Blockchain\Interfaces; |
5 | 5 | |
6 | 6 | |
7 | -abstract class Operation{ |
|
7 | +abstract class Operation { |
|
8 | 8 | |
9 | 9 | const SPEND = 'SPEND'; |
10 | 10 | const RECEIVE = 'RECEIVE'; |
@@ -4,7 +4,7 @@ |
||
4 | 4 | namespace Appino\Blockchain\Interfaces; |
5 | 5 | |
6 | 6 | |
7 | -abstract class Notification{ |
|
7 | +abstract class Notification { |
|
8 | 8 | |
9 | 9 | const KEEP = 'KEEP'; |
10 | 10 | const DELETE = 'DELETE'; |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | use GuzzleHttp\Exception\GuzzleException; |
10 | 10 | use GuzzleHttp\Psr7\Uri; |
11 | 11 | |
12 | -class Blockchain{ |
|
12 | +class Blockchain { |
|
13 | 13 | |
14 | 14 | protected $client; |
15 | 15 | protected $params; |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | const GET = 'GET'; |
18 | 18 | const POST = 'POST'; |
19 | 19 | |
20 | - public function __construct($config){ |
|
21 | - $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]); |
|
22 | - $this->params['api_code'] = data_get('api_code',null); |
|
20 | + public function __construct($config) { |
|
21 | + $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]); |
|
22 | + $this->params['api_code'] = data_get('api_code', null); |
|
23 | 23 | $this->Create = new Create($this); |
24 | 24 | $this->Wallet = new Wallet($this); |
25 | 25 | $this->Receive = new Receive($this); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param $base_uri string Default : http://localhost:3000 |
30 | 30 | */ |
31 | 31 | |
32 | - public function newBaseUri($base_uri){ |
|
32 | + public function newBaseUri($base_uri) { |
|
33 | 33 | $this->client = new Client(['base_uri'=>$base_uri]); |
34 | 34 | } |
35 | 35 | |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * @return array |
41 | 41 | */ |
42 | 42 | |
43 | - public function Request($method, $url, $params){ |
|
43 | + public function Request($method, $url, $params) { |
|
44 | 44 | $params = array_merge($this->params, $params); |
45 | 45 | $options = array( |
46 | 46 | 'form-params'=>$params, |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | try { |
53 | - return json_decode($this->client->request($method, $url, $options),true); |
|
53 | + return json_decode($this->client->request($method, $url, $options), true); |
|
54 | 54 | } catch (GuzzleException $e) { |
55 | 55 | //throw $e->getMessage(); |
56 | 56 | } |
@@ -55,11 +55,11 @@ |
||
55 | 55 | $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'blockchain'); |
56 | 56 | |
57 | 57 | // Register the main class to use with the facade |
58 | - $this->app->singleton('blockchain', function () { |
|
58 | + $this->app->singleton('blockchain', function() { |
|
59 | 59 | $config = app('config')->get('blockchain'); |
60 | 60 | return new Blockchain($config); |
61 | 61 | }); |
62 | - $this->app->singleton('receive', function () { |
|
62 | + $this->app->singleton('receive', function() { |
|
63 | 63 | $config = app('config')->get('blockchain'); |
64 | 64 | return new Receive($config); |
65 | 65 | }); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use stdClass; |
6 | 6 | |
7 | -class AccountResponse{ |
|
7 | +class AccountResponse { |
|
8 | 8 | /** |
9 | 9 | * @var string |
10 | 10 | */ |
@@ -55,27 +55,27 @@ discard block |
||
55 | 55 | * @param $json array|object |
56 | 56 | */ |
57 | 57 | |
58 | - public function __construct($json){ |
|
59 | - if(array_key_exists('balance',$json)) |
|
60 | - $this->balance = data_get($json,'balance'); |
|
61 | - if(array_key_exists('address',$json)) |
|
62 | - $this->label = data_get($json,'address'); |
|
63 | - if(array_key_exists('label',$json)) |
|
64 | - $this->index = data_get($json,'label'); |
|
65 | - if(array_key_exists('archived',$json)) |
|
66 | - $this->archived = data_get($json,'archived'); |
|
67 | - if(array_key_exists('extendedPublicKey',$json)) |
|
68 | - $this->extendedPublicKey = data_get($json,'extendedPublicKey'); |
|
69 | - if(array_key_exists('extendedPrivateKey',$json)) |
|
70 | - $this->extendedPrivateKey = data_get($json,'extendedPrivateKey'); |
|
71 | - if(array_key_exists('receiveIndex',$json)) |
|
72 | - $this->receiveIndex = data_get($json,'receiveIndex'); |
|
73 | - if(array_key_exists('lastUsedReceiveIndex',$json)) |
|
74 | - $this->lastUsedReceiveIndex = data_get($json,'lastUsedReceiveIndex'); |
|
75 | - if(array_key_exists('receiveAddress',$json)) |
|
76 | - $this->receiveAddress = data_get($json,'receiveAddress'); |
|
77 | - if(array_key_exists('cache',$json)) |
|
78 | - $this->cahce = new Cache(data_get($json,'cache')); |
|
58 | + public function __construct($json) { |
|
59 | + if (array_key_exists('balance', $json)) |
|
60 | + $this->balance = data_get($json, 'balance'); |
|
61 | + if (array_key_exists('address', $json)) |
|
62 | + $this->label = data_get($json, 'address'); |
|
63 | + if (array_key_exists('label', $json)) |
|
64 | + $this->index = data_get($json, 'label'); |
|
65 | + if (array_key_exists('archived', $json)) |
|
66 | + $this->archived = data_get($json, 'archived'); |
|
67 | + if (array_key_exists('extendedPublicKey', $json)) |
|
68 | + $this->extendedPublicKey = data_get($json, 'extendedPublicKey'); |
|
69 | + if (array_key_exists('extendedPrivateKey', $json)) |
|
70 | + $this->extendedPrivateKey = data_get($json, 'extendedPrivateKey'); |
|
71 | + if (array_key_exists('receiveIndex', $json)) |
|
72 | + $this->receiveIndex = data_get($json, 'receiveIndex'); |
|
73 | + if (array_key_exists('lastUsedReceiveIndex', $json)) |
|
74 | + $this->lastUsedReceiveIndex = data_get($json, 'lastUsedReceiveIndex'); |
|
75 | + if (array_key_exists('receiveAddress', $json)) |
|
76 | + $this->receiveAddress = data_get($json, 'receiveAddress'); |
|
77 | + if (array_key_exists('cache', $json)) |
|
78 | + $this->cahce = new Cache(data_get($json, 'cache')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | } |
@@ -56,26 +56,36 @@ |
||
56 | 56 | */ |
57 | 57 | |
58 | 58 | public function __construct($json){ |
59 | - if(array_key_exists('balance',$json)) |
|
60 | - $this->balance = data_get($json,'balance'); |
|
61 | - if(array_key_exists('address',$json)) |
|
62 | - $this->label = data_get($json,'address'); |
|
63 | - if(array_key_exists('label',$json)) |
|
64 | - $this->index = data_get($json,'label'); |
|
65 | - if(array_key_exists('archived',$json)) |
|
66 | - $this->archived = data_get($json,'archived'); |
|
67 | - if(array_key_exists('extendedPublicKey',$json)) |
|
68 | - $this->extendedPublicKey = data_get($json,'extendedPublicKey'); |
|
69 | - if(array_key_exists('extendedPrivateKey',$json)) |
|
70 | - $this->extendedPrivateKey = data_get($json,'extendedPrivateKey'); |
|
71 | - if(array_key_exists('receiveIndex',$json)) |
|
72 | - $this->receiveIndex = data_get($json,'receiveIndex'); |
|
73 | - if(array_key_exists('lastUsedReceiveIndex',$json)) |
|
74 | - $this->lastUsedReceiveIndex = data_get($json,'lastUsedReceiveIndex'); |
|
75 | - if(array_key_exists('receiveAddress',$json)) |
|
76 | - $this->receiveAddress = data_get($json,'receiveAddress'); |
|
77 | - if(array_key_exists('cache',$json)) |
|
78 | - $this->cahce = new Cache(data_get($json,'cache')); |
|
59 | + if(array_key_exists('balance',$json)) { |
|
60 | + $this->balance = data_get($json,'balance'); |
|
61 | + } |
|
62 | + if(array_key_exists('address',$json)) { |
|
63 | + $this->label = data_get($json,'address'); |
|
64 | + } |
|
65 | + if(array_key_exists('label',$json)) { |
|
66 | + $this->index = data_get($json,'label'); |
|
67 | + } |
|
68 | + if(array_key_exists('archived',$json)) { |
|
69 | + $this->archived = data_get($json,'archived'); |
|
70 | + } |
|
71 | + if(array_key_exists('extendedPublicKey',$json)) { |
|
72 | + $this->extendedPublicKey = data_get($json,'extendedPublicKey'); |
|
73 | + } |
|
74 | + if(array_key_exists('extendedPrivateKey',$json)) { |
|
75 | + $this->extendedPrivateKey = data_get($json,'extendedPrivateKey'); |
|
76 | + } |
|
77 | + if(array_key_exists('receiveIndex',$json)) { |
|
78 | + $this->receiveIndex = data_get($json,'receiveIndex'); |
|
79 | + } |
|
80 | + if(array_key_exists('lastUsedReceiveIndex',$json)) { |
|
81 | + $this->lastUsedReceiveIndex = data_get($json,'lastUsedReceiveIndex'); |
|
82 | + } |
|
83 | + if(array_key_exists('receiveAddress',$json)) { |
|
84 | + $this->receiveAddress = data_get($json,'receiveAddress'); |
|
85 | + } |
|
86 | + if(array_key_exists('cache',$json)) { |
|
87 | + $this->cahce = new Cache(data_get($json,'cache')); |
|
88 | + } |
|
79 | 89 | } |
80 | 90 | |
81 | 91 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class ReceiveResponse{ |
|
7 | +class ReceiveResponse { |
|
8 | 8 | /** |
9 | 9 | * @var string |
10 | 10 | */ |
@@ -18,13 +18,13 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public $callback; |
20 | 20 | |
21 | - public function __construct($json){ |
|
22 | - if(array_key_exists('address',$json)) |
|
23 | - $this->address = data_get($json,'address'); |
|
24 | - if(array_key_exists('index',$json)) |
|
25 | - $this->index = data_get($json,'index'); |
|
26 | - if(array_key_exists('callback',$json)) |
|
27 | - $this->callback = data_get($json,'callback'); |
|
21 | + public function __construct($json) { |
|
22 | + if (array_key_exists('address', $json)) |
|
23 | + $this->address = data_get($json, 'address'); |
|
24 | + if (array_key_exists('index', $json)) |
|
25 | + $this->index = data_get($json, 'index'); |
|
26 | + if (array_key_exists('callback', $json)) |
|
27 | + $this->callback = data_get($json, 'callback'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | } |
@@ -19,12 +19,15 @@ |
||
19 | 19 | public $callback; |
20 | 20 | |
21 | 21 | public function __construct($json){ |
22 | - if(array_key_exists('address',$json)) |
|
23 | - $this->address = data_get($json,'address'); |
|
24 | - if(array_key_exists('index',$json)) |
|
25 | - $this->index = data_get($json,'index'); |
|
26 | - if(array_key_exists('callback',$json)) |
|
27 | - $this->callback = data_get($json,'callback'); |
|
22 | + if(array_key_exists('address',$json)) { |
|
23 | + $this->address = data_get($json,'address'); |
|
24 | + } |
|
25 | + if(array_key_exists('index',$json)) { |
|
26 | + $this->index = data_get($json,'index'); |
|
27 | + } |
|
28 | + if(array_key_exists('callback',$json)) { |
|
29 | + $this->callback = data_get($json,'callback'); |
|
30 | + } |
|
28 | 31 | } |
29 | 32 | |
30 | 33 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | namespace Appino\Blockchain\Objects; |
4 | 4 | |
5 | -class WalletResponse{ |
|
5 | +class WalletResponse { |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * @var string |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | * @param $json array|object |
23 | 23 | */ |
24 | 24 | |
25 | - public function __construct($json){ |
|
26 | - if(array_key_exists('guid',$json)) |
|
27 | - $this->guid = data_get($json,'balance'); |
|
28 | - if(array_key_exists('address',$json)) |
|
29 | - $this->address = data_get($json,'address'); |
|
30 | - if(array_key_exists('label',$json)) |
|
31 | - $this->label = data_get($json,'label'); |
|
25 | + public function __construct($json) { |
|
26 | + if (array_key_exists('guid', $json)) |
|
27 | + $this->guid = data_get($json, 'balance'); |
|
28 | + if (array_key_exists('address', $json)) |
|
29 | + $this->address = data_get($json, 'address'); |
|
30 | + if (array_key_exists('label', $json)) |
|
31 | + $this->label = data_get($json, 'label'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | } |
@@ -23,12 +23,15 @@ |
||
23 | 23 | */ |
24 | 24 | |
25 | 25 | public function __construct($json){ |
26 | - if(array_key_exists('guid',$json)) |
|
27 | - $this->guid = data_get($json,'balance'); |
|
28 | - if(array_key_exists('address',$json)) |
|
29 | - $this->address = data_get($json,'address'); |
|
30 | - if(array_key_exists('label',$json)) |
|
31 | - $this->label = data_get($json,'label'); |
|
26 | + if(array_key_exists('guid',$json)) { |
|
27 | + $this->guid = data_get($json,'balance'); |
|
28 | + } |
|
29 | + if(array_key_exists('address',$json)) { |
|
30 | + $this->address = data_get($json,'address'); |
|
31 | + } |
|
32 | + if(array_key_exists('label',$json)) { |
|
33 | + $this->label = data_get($json,'label'); |
|
34 | + } |
|
32 | 35 | } |
33 | 36 | |
34 | 37 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class NotificationResponse{ |
|
7 | +class NotificationResponse { |
|
8 | 8 | public $id; |
9 | 9 | public $address; |
10 | 10 | public $height; |
@@ -13,8 +13,8 @@ discard block |
||
13 | 13 | public $op; |
14 | 14 | public $onNotification; |
15 | 15 | |
16 | - public function __construct($json){ |
|
17 | - foreach ($json as $key => $value){ |
|
16 | + public function __construct($json) { |
|
17 | + foreach ($json as $key => $value) { |
|
18 | 18 | $this->{$key} = $value; |
19 | 19 | } |
20 | 20 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class PaymentResponse{ |
|
7 | +class PaymentResponse { |
|
8 | 8 | /** |
9 | 9 | * @var array of string |
10 | 10 | */ |
@@ -35,19 +35,19 @@ discard block |
||
35 | 35 | * @param $json array |
36 | 36 | */ |
37 | 37 | |
38 | - public function __construct($json){ |
|
39 | - if(array_key_exists('to',$json)) |
|
40 | - $this->to = data_get($json,'to'); |
|
41 | - if(array_key_exists('from',$json)) |
|
42 | - $this->from = data_get($json,'from'); |
|
43 | - if(array_key_exists('amount',$json)) |
|
44 | - $this->amount = data_get($json,'amount'); |
|
45 | - if(array_key_exists('fee',$json)) |
|
46 | - $this->fee = data_get($json,'fee'); |
|
47 | - if(array_key_exists('txid',$json)) |
|
48 | - $this->txid = data_get($json,'txid'); |
|
49 | - if(array_key_exists('succevss',$json)) |
|
50 | - $this->succevss = data_get($json,'success'); |
|
38 | + public function __construct($json) { |
|
39 | + if (array_key_exists('to', $json)) |
|
40 | + $this->to = data_get($json, 'to'); |
|
41 | + if (array_key_exists('from', $json)) |
|
42 | + $this->from = data_get($json, 'from'); |
|
43 | + if (array_key_exists('amount', $json)) |
|
44 | + $this->amount = data_get($json, 'amount'); |
|
45 | + if (array_key_exists('fee', $json)) |
|
46 | + $this->fee = data_get($json, 'fee'); |
|
47 | + if (array_key_exists('txid', $json)) |
|
48 | + $this->txid = data_get($json, 'txid'); |
|
49 | + if (array_key_exists('succevss', $json)) |
|
50 | + $this->succevss = data_get($json, 'success'); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -36,18 +36,24 @@ |
||
36 | 36 | */ |
37 | 37 | |
38 | 38 | public function __construct($json){ |
39 | - if(array_key_exists('to',$json)) |
|
40 | - $this->to = data_get($json,'to'); |
|
41 | - if(array_key_exists('from',$json)) |
|
42 | - $this->from = data_get($json,'from'); |
|
43 | - if(array_key_exists('amount',$json)) |
|
44 | - $this->amount = data_get($json,'amount'); |
|
45 | - if(array_key_exists('fee',$json)) |
|
46 | - $this->fee = data_get($json,'fee'); |
|
47 | - if(array_key_exists('txid',$json)) |
|
48 | - $this->txid = data_get($json,'txid'); |
|
49 | - if(array_key_exists('succevss',$json)) |
|
50 | - $this->succevss = data_get($json,'success'); |
|
39 | + if(array_key_exists('to',$json)) { |
|
40 | + $this->to = data_get($json,'to'); |
|
41 | + } |
|
42 | + if(array_key_exists('from',$json)) { |
|
43 | + $this->from = data_get($json,'from'); |
|
44 | + } |
|
45 | + if(array_key_exists('amount',$json)) { |
|
46 | + $this->amount = data_get($json,'amount'); |
|
47 | + } |
|
48 | + if(array_key_exists('fee',$json)) { |
|
49 | + $this->fee = data_get($json,'fee'); |
|
50 | + } |
|
51 | + if(array_key_exists('txid',$json)) { |
|
52 | + $this->txid = data_get($json,'txid'); |
|
53 | + } |
|
54 | + if(array_key_exists('succevss',$json)) { |
|
55 | + $this->succevss = data_get($json,'success'); |
|
56 | + } |
|
51 | 57 | } |
52 | 58 | |
53 | 59 | } |