@@ -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,21 +22,21 @@ discard block |
||
22 | 22 | * @param $params array|object |
23 | 23 | */ |
24 | 24 | |
25 | - public function __construct($params){ |
|
26 | - if(is_null($params)) |
|
25 | + public function __construct($params) { |
|
26 | + if (is_null($params)) |
|
27 | 27 | return; |
28 | - $this->guid = data_get($params,'guid'); |
|
29 | - $this->address = data_get($params,'address'); |
|
30 | - $this->label = data_get($params,'label'); |
|
28 | + $this->guid = data_get($params, 'guid'); |
|
29 | + $this->address = data_get($params, 'address'); |
|
30 | + $this->label = data_get($params, 'label'); |
|
31 | 31 | } |
32 | 32 | |
33 | - public function __toString(){ |
|
33 | + public function __toString() { |
|
34 | 34 | $class_vars = get_class_vars(get_class($this)); |
35 | 35 | $response = []; |
36 | - foreach ($class_vars as $key => $value){ |
|
36 | + foreach ($class_vars as $key => $value) { |
|
37 | 37 | $response[$key] = $this->{$key}; |
38 | 38 | } |
39 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
39 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | namespace Appino\Blockchain\Objects; |
4 | 4 | |
5 | 5 | |
6 | -class AccountResponse{ |
|
6 | +class AccountResponse { |
|
7 | 7 | /** |
8 | 8 | * @var string |
9 | 9 | */ |
@@ -46,27 +46,27 @@ discard block |
||
46 | 46 | * @param $params array|object |
47 | 47 | */ |
48 | 48 | |
49 | - public function __construct($params){ |
|
50 | - if(is_null($params)) |
|
49 | + public function __construct($params) { |
|
50 | + if (is_null($params)) |
|
51 | 51 | return; |
52 | - $this->balance = data_get($params,'balance'); |
|
53 | - $this->label = data_get($params,'label'); |
|
54 | - $this->index = data_get($params,'index'); |
|
55 | - $this->archived = data_get($params,'archived'); |
|
56 | - $this->extendedPublicKey = data_get($params,'extendedPublicKey'); |
|
57 | - $this->extendedPrivateKey = data_get($params,'extendedPrivateKey'); |
|
58 | - $this->receiveIndex = data_get($params,'receiveIndex'); |
|
59 | - $this->lastUsedReceiveIndex = data_get($params,'lastUsedReceiveIndex'); |
|
60 | - $this->receiveAddress = data_get($params,'receiveAddress'); |
|
52 | + $this->balance = data_get($params, 'balance'); |
|
53 | + $this->label = data_get($params, 'label'); |
|
54 | + $this->index = data_get($params, 'index'); |
|
55 | + $this->archived = data_get($params, 'archived'); |
|
56 | + $this->extendedPublicKey = data_get($params, 'extendedPublicKey'); |
|
57 | + $this->extendedPrivateKey = data_get($params, 'extendedPrivateKey'); |
|
58 | + $this->receiveIndex = data_get($params, 'receiveIndex'); |
|
59 | + $this->lastUsedReceiveIndex = data_get($params, 'lastUsedReceiveIndex'); |
|
60 | + $this->receiveAddress = data_get($params, 'receiveAddress'); |
|
61 | 61 | } |
62 | 62 | |
63 | - public function __toString(){ |
|
63 | + public function __toString() { |
|
64 | 64 | $class_vars = get_class_vars(get_class($this)); |
65 | 65 | $response = []; |
66 | - foreach ($class_vars as $key => $value){ |
|
66 | + foreach ($class_vars as $key => $value) { |
|
67 | 67 | $response[$key] = $this->{$key}; |
68 | 68 | } |
69 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
69 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class LogResponse{ |
|
7 | +class LogResponse { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @var string |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public $response_code; |
25 | 25 | |
26 | - public function __construct($params){ |
|
27 | - if(is_null($params)) |
|
26 | + public function __construct($params) { |
|
27 | + if (is_null($params)) |
|
28 | 28 | return; |
29 | - $this->callback = data_get($params,'callback'); |
|
30 | - $this->called_at = data_get($params,'called_at'); |
|
31 | - $this->raw_response = data_get($params,'raw_response'); |
|
32 | - $this->response_code = data_get($params,'response_code'); |
|
29 | + $this->callback = data_get($params, 'callback'); |
|
30 | + $this->called_at = data_get($params, 'called_at'); |
|
31 | + $this->raw_response = data_get($params, 'raw_response'); |
|
32 | + $this->response_code = data_get($params, 'response_code'); |
|
33 | 33 | } |
34 | 34 | |
35 | - public function __toString(){ |
|
35 | + public function __toString() { |
|
36 | 36 | $class_vars = get_class_vars(get_class($this)); |
37 | 37 | $response = []; |
38 | - foreach ($class_vars as $key => $value){ |
|
38 | + foreach ($class_vars as $key => $value) { |
|
39 | 39 | $response[$key] = $this->{$key}; |
40 | 40 | } |
41 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
41 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
@@ -4,25 +4,25 @@ |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class Cache{ |
|
7 | +class Cache { |
|
8 | 8 | |
9 | 9 | public $receiveAccount; |
10 | 10 | public $changeAccount; |
11 | 11 | |
12 | - public function __construct($params){ |
|
13 | - if(is_null($params)) |
|
12 | + public function __construct($params) { |
|
13 | + if (is_null($params)) |
|
14 | 14 | return; |
15 | - $this->receiveAccount = data_get($params,'receiveAccount'); |
|
16 | - $this->changeAccount = data_get($params,'changeAccount'); |
|
15 | + $this->receiveAccount = data_get($params, 'receiveAccount'); |
|
16 | + $this->changeAccount = data_get($params, 'changeAccount'); |
|
17 | 17 | } |
18 | 18 | |
19 | - public function __toString(){ |
|
19 | + public function __toString() { |
|
20 | 20 | $class_vars = get_class_vars(get_class($this)); |
21 | 21 | $response = []; |
22 | - foreach ($class_vars as $key => $value){ |
|
22 | + foreach ($class_vars as $key => $value) { |
|
23 | 23 | $response[$key] = $this->{$key}; |
24 | 24 | } |
25 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
25 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | } |
@@ -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,21 +18,21 @@ discard block |
||
18 | 18 | */ |
19 | 19 | public $callback; |
20 | 20 | |
21 | - public function __construct($params){ |
|
22 | - if(is_null($params)) |
|
21 | + public function __construct($params) { |
|
22 | + if (is_null($params)) |
|
23 | 23 | return; |
24 | - $this->address = data_get($params,'address'); |
|
25 | - $this->index = data_get($params,'index'); |
|
26 | - $this->callback = data_get($params,'callback'); |
|
24 | + $this->address = data_get($params, 'address'); |
|
25 | + $this->index = data_get($params, 'index'); |
|
26 | + $this->callback = data_get($params, 'callback'); |
|
27 | 27 | } |
28 | 28 | |
29 | - public function __toString(){ |
|
29 | + public function __toString() { |
|
30 | 30 | $class_vars = get_class_vars(get_class($this)); |
31 | 31 | $response = []; |
32 | - foreach ($class_vars as $key => $value){ |
|
32 | + foreach ($class_vars as $key => $value) { |
|
33 | 33 | $response[$key] = $this->{$key}; |
34 | 34 | } |
35 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
35 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | } |
@@ -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,21 +13,21 @@ discard block |
||
13 | 13 | public $op; |
14 | 14 | public $onNotification; |
15 | 15 | |
16 | - public function __construct($params){ |
|
17 | - if(is_null($params)) |
|
16 | + public function __construct($params) { |
|
17 | + if (is_null($params)) |
|
18 | 18 | return; |
19 | - foreach ($params as $key => $value){ |
|
19 | + foreach ($params as $key => $value) { |
|
20 | 20 | $this->{$key} = $value; |
21 | 21 | } |
22 | 22 | } |
23 | 23 | |
24 | - public function __toString(){ |
|
24 | + public function __toString() { |
|
25 | 25 | $class_vars = get_class_vars(get_class($this)); |
26 | 26 | $response = []; |
27 | - foreach ($class_vars as $key => $value){ |
|
27 | + foreach ($class_vars as $key => $value) { |
|
28 | 28 | $response[$key] = $this->{$key}; |
29 | 29 | } |
30 | - return json_encode($response, JSON_THROW_ON_ERROR) .""; |
|
30 | + return json_encode($response, JSON_THROW_ON_ERROR).""; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | namespace Appino\Blockchain\Objects; |
5 | 5 | |
6 | 6 | |
7 | -class Rate{ |
|
7 | +class Rate { |
|
8 | 8 | |
9 | 9 | public $currency; |
10 | 10 | public $m15; |
@@ -12,15 +12,15 @@ discard block |
||
12 | 12 | public $buy; |
13 | 13 | public $sell; |
14 | 14 | |
15 | - public function __construct($currency, $params){ |
|
16 | - if(is_null($params)) |
|
15 | + public function __construct($currency, $params) { |
|
16 | + if (is_null($params)) |
|
17 | 17 | return; |
18 | 18 | $this->currency = $currency; |
19 | - $this->m15 = data_get($params,'15m'); |
|
20 | - $this->last = data_get($params,'last'); |
|
21 | - $this->buy = data_get($params,'buy'); |
|
22 | - $this->sell = data_get($params,'sell'); |
|
23 | - $this->symbol = data_get($params,'symbol'); |
|
19 | + $this->m15 = data_get($params, '15m'); |
|
20 | + $this->last = data_get($params, 'last'); |
|
21 | + $this->buy = data_get($params, 'buy'); |
|
22 | + $this->sell = data_get($params, 'sell'); |
|
23 | + $this->symbol = data_get($params, 'symbol'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | use Appino\Blockchain\Objects\Rate; |
8 | 8 | use Appino\Blockchain\Objects\ReceiveResponse; |
9 | 9 | |
10 | -class Market{ |
|
10 | +class Market { |
|
11 | 11 | |
12 | 12 | private $blockchain; |
13 | 13 | |
14 | - public function __construct(Blockchain $blockchain){ |
|
14 | + public function __construct(Blockchain $blockchain) { |
|
15 | 15 | $this->blockchain = $blockchain; |
16 | 16 | } |
17 | 17 | |
18 | 18 | const URL = 'https://blockchain.info/'; |
19 | 19 | |
20 | - private function Uri($uri){ |
|
20 | + private function Uri($uri) { |
|
21 | 21 | return self::URL.'/'.$uri; |
22 | 22 | } |
23 | 23 | |
@@ -28,34 +28,34 @@ discard block |
||
28 | 28 | * @return array|string |
29 | 29 | * @throws \Appino\Blockchain\Exception\HttpError |
30 | 30 | */ |
31 | - private function call($method, $uri, $params = array()){ |
|
31 | + private function call($method, $uri, $params = array()) { |
|
32 | 32 | return $this->blockchain->Request($method, $this->Uri($uri), $params); |
33 | 33 | } |
34 | 34 | |
35 | - public function Rates(){ |
|
36 | - $response = $this->call('GET','ticker'); |
|
35 | + public function Rates() { |
|
36 | + $response = $this->call('GET', 'ticker'); |
|
37 | 37 | $rates = array(); |
38 | - foreach ($response as $Currency => $params){ |
|
38 | + foreach ($response as $Currency => $params) { |
|
39 | 39 | $rates[$Currency] = new Rate($Currency, $params); |
40 | 40 | } |
41 | 41 | return $rates; |
42 | 42 | } |
43 | 43 | |
44 | - public function ToBTC($currency, $amount){ |
|
44 | + public function ToBTC($currency, $amount) { |
|
45 | 45 | $params = [ |
46 | 46 | 'currency' => $currency, |
47 | 47 | 'value' => $amount |
48 | 48 | ]; |
49 | - $response = $this->call('GET','tobtc',$params); |
|
49 | + $response = $this->call('GET', 'tobtc', $params); |
|
50 | 50 | return new ReceiveResponse($response); |
51 | 51 | } |
52 | 52 | |
53 | - public function ToSatoshi($currency, $amount){ |
|
53 | + public function ToSatoshi($currency, $amount) { |
|
54 | 54 | $params = [ |
55 | 55 | 'currency' => $currency, |
56 | 56 | 'value' => $amount |
57 | 57 | ]; |
58 | - return bcmul($this->call('GET','tobtc',$params),100000000); |
|
58 | + return bcmul($this->call('GET', 'tobtc', $params), 100000000); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | use GuzzleHttp\Exception\GuzzleException; |
14 | 14 | use Illuminate\Contracts\Container\Container; |
15 | 15 | |
16 | -class Blockchain{ |
|
16 | +class Blockchain { |
|
17 | 17 | |
18 | 18 | protected $client; |
19 | 19 | protected $params; |
@@ -21,37 +21,37 @@ discard block |
||
21 | 21 | const GET = 'GET'; |
22 | 22 | const POST = 'POST'; |
23 | 23 | |
24 | - public function __construct($config){ |
|
25 | - $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]); |
|
26 | - $this->params['api_code'] = data_get($config,'api_code'); |
|
27 | - $this->params['key'] = data_get($config,'api_code'); |
|
24 | + public function __construct($config) { |
|
25 | + $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]); |
|
26 | + $this->params['api_code'] = data_get($config, 'api_code'); |
|
27 | + $this->params['key'] = data_get($config, 'api_code'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @return Create |
32 | 32 | */ |
33 | - public function Create(){ |
|
33 | + public function Create() { |
|
34 | 34 | return new Create($this); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * @return Wallet |
39 | 39 | */ |
40 | - public function Wallet(){ |
|
40 | + public function Wallet() { |
|
41 | 41 | return new Wallet($this); |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @return Receive |
46 | 46 | */ |
47 | - public function Receive(){ |
|
47 | + public function Receive() { |
|
48 | 48 | return new Receive($this); |
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @return Market |
53 | 53 | */ |
54 | - public function Market(){ |
|
54 | + public function Market() { |
|
55 | 55 | return new Market($this); |
56 | 56 | } |
57 | 57 | |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @param $base_uri string Default : http://localhost:3000 |
60 | 60 | */ |
61 | 61 | |
62 | - public function newBaseUri($base_uri){ |
|
62 | + public function newBaseUri($base_uri) { |
|
63 | 63 | $this->client = new Client(['base_uri'=>$base_uri]); |
64 | 64 | } |
65 | 65 | |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | * @throws HttpError |
72 | 72 | */ |
73 | 73 | |
74 | - public function Request($method, $url, $params){ |
|
74 | + public function Request($method, $url, $params) { |
|
75 | 75 | $params = array_merge($params, $this->params); |
76 | - switch ($method){ |
|
76 | + switch ($method) { |
|
77 | 77 | case 'GET': |
78 | 78 | case 'DELETE': |
79 | 79 | $options = array('query'=>$params); |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | } |
92 | 92 | try { |
93 | 93 | $response = $this->client->request($method, $url, $options); |
94 | - $json = json_decode($response->getBody()->getContents(),true); |
|
95 | - if(is_null($json)) { |
|
94 | + $json = json_decode($response->getBody()->getContents(), true); |
|
95 | + if (is_null($json)) { |
|
96 | 96 | // this is possibly a from btc request with a comma separation |
97 | 97 | $json = json_decode(str_replace(',', '', $response)); |
98 | 98 | if (is_null($json)) |
99 | - throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
99 | + throw new Error("Unable to decode JSON response from Blockchain: ".$response->getBody()->getContents()); |
|
100 | 100 | } |
101 | - if(array_key_exists('error', $json)) { |
|
101 | + if (array_key_exists('error', $json)) { |
|
102 | 102 | throw new ApiError($json['error']); |
103 | 103 | } |
104 | 104 | return $json; |