@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use GuzzleHttp\Exception\GuzzleException; |
13 | 13 | use Illuminate\Contracts\Container\Container; |
14 | 14 | |
15 | -class Blockchain{ |
|
15 | +class Blockchain { |
|
16 | 16 | |
17 | 17 | protected $client; |
18 | 18 | protected $params; |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | const GET = 'GET'; |
21 | 21 | const POST = 'POST'; |
22 | 22 | |
23 | - public function __construct($config){ |
|
24 | - $this->client = new Client(['base_uri'=>data_get($config,'base_uri')]); |
|
25 | - $this->params['api_code'] = data_get($config,'api_code'); |
|
23 | + public function __construct($config) { |
|
24 | + $this->client = new Client(['base_uri'=>data_get($config, 'base_uri')]); |
|
25 | + $this->params['api_code'] = data_get($config, 'api_code'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * @return Create |
30 | 30 | */ |
31 | - public function Create(){ |
|
31 | + public function Create() { |
|
32 | 32 | return new Create($this); |
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @return Wallet |
37 | 37 | */ |
38 | - public function Wallet(){ |
|
38 | + public function Wallet() { |
|
39 | 39 | return new Wallet($this); |
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @return Receive |
44 | 44 | */ |
45 | - public function Receive(){ |
|
45 | + public function Receive() { |
|
46 | 46 | return new Receive($this); |
47 | 47 | } |
48 | 48 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param $base_uri string Default : http://localhost:3000 |
51 | 51 | */ |
52 | 52 | |
53 | - public function newBaseUri($base_uri){ |
|
53 | + public function newBaseUri($base_uri) { |
|
54 | 54 | $this->client = new Client(['base_uri'=>$base_uri]); |
55 | 55 | } |
56 | 56 | |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * @throws HttpError |
63 | 63 | */ |
64 | 64 | |
65 | - public function Request($method, $url, $params){ |
|
65 | + public function Request($method, $url, $params) { |
|
66 | 66 | $params = array_merge($params, $this->params); |
67 | - switch ($method){ |
|
67 | + switch ($method) { |
|
68 | 68 | case 'GET': |
69 | 69 | case 'DELETE': |
70 | 70 | $options = array('query'=>$params); |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | } |
81 | 81 | try { |
82 | 82 | $response = $this->client->request($method, $url, $options); |
83 | - $json = json_decode($response->getBody()->getContents(),true); |
|
84 | - if(is_null($json)) { |
|
83 | + $json = json_decode($response->getBody()->getContents(), true); |
|
84 | + if (is_null($json)) { |
|
85 | 85 | // this is possibly a from btc request with a comma separation |
86 | 86 | $json = json_decode(str_replace(',', '', $response)); |
87 | 87 | if (is_null($json)) |
88 | - throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
88 | + throw new Error("Unable to decode JSON response from Blockchain: ".$response->getBody()->getContents()); |
|
89 | 89 | } |
90 | - if(array_key_exists('error', $json)) { |
|
90 | + if (array_key_exists('error', $json)) { |
|
91 | 91 | throw new ApiError($json['error']); |
92 | 92 | } |
93 | 93 | return $json; |
@@ -84,8 +84,9 @@ |
||
84 | 84 | if(is_null($json)) { |
85 | 85 | // this is possibly a from btc request with a comma separation |
86 | 86 | $json = json_decode(str_replace(',', '', $response)); |
87 | - if (is_null($json)) |
|
88 | - throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
87 | + if (is_null($json)) { |
|
88 | + throw new Error("Unable to decode JSON response from Blockchain: " . $response->getBody()->getContents()); |
|
89 | + } |
|
89 | 90 | } |
90 | 91 | if(array_key_exists('error', $json)) { |
91 | 92 | throw new ApiError($json['error']); |
@@ -5,12 +5,12 @@ discard block |
||
5 | 5 | use Appino\Blockchain\Exception\ParameterError; |
6 | 6 | use Appino\Blockchain\Objects\WalletResponse; |
7 | 7 | |
8 | -class Create{ |
|
8 | +class Create { |
|
9 | 9 | |
10 | 10 | protected $blockchain; |
11 | 11 | const URL = '/api/v2/create'; |
12 | 12 | |
13 | - public function __construct(Blockchain $blockchain){ |
|
13 | + public function __construct(Blockchain $blockchain) { |
|
14 | 14 | $this->blockchain = $blockchain; |
15 | 15 | } |
16 | 16 | |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @return WalletResponse |
24 | 24 | * @throws ParameterError |
25 | 25 | */ |
26 | - public function create($password, $email=null, $label=null) { |
|
26 | + public function create($password, $email = null, $label = null) { |
|
27 | 27 | $response = $this->doCreate($password, null, $email, $label); |
28 | 28 | return new WalletResponse($response); |
29 | 29 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @return WalletResponse |
39 | 39 | * @throws ParameterError |
40 | 40 | */ |
41 | - public function createWithKey($password, $privKey, $email=null, $label=null) { |
|
42 | - if(!isset($privKey) || is_null($privKey)) |
|
41 | + public function createWithKey($password, $privKey, $email = null, $label = null) { |
|
42 | + if (!isset($privKey) || is_null($privKey)) |
|
43 | 43 | throw new ParameterError("Private Key required."); |
44 | 44 | |
45 | 45 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
@@ -55,22 +55,22 @@ discard block |
||
55 | 55 | * @return array |
56 | 56 | * @throws ParameterError |
57 | 57 | */ |
58 | - protected function doCreate($password, $priv = null, $label = null, $email = null){ |
|
59 | - if(!isset($password) || empty($password)) |
|
58 | + protected function doCreate($password, $priv = null, $label = null, $email = null) { |
|
59 | + if (!isset($password) || empty($password)) |
|
60 | 60 | throw new ParameterError("Password required."); |
61 | 61 | |
62 | 62 | $params = array( |
63 | 63 | 'password'=>$password, |
64 | 64 | 'hd'=>true |
65 | 65 | ); |
66 | - if(!is_null($priv)) |
|
66 | + if (!is_null($priv)) |
|
67 | 67 | $params['priv'] = $priv; |
68 | - if(!is_null($email)) |
|
68 | + if (!is_null($email)) |
|
69 | 69 | $params['email'] = $email; |
70 | - if(!is_null($label)) |
|
70 | + if (!is_null($label)) |
|
71 | 71 | $params['label'] = $label; |
72 | 72 | |
73 | - return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
|
73 | + return $this->blockchain->Request(Blockchain::POST, self::URL, $params); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | } |
@@ -39,8 +39,9 @@ discard block |
||
39 | 39 | * @throws ParameterError |
40 | 40 | */ |
41 | 41 | public function createWithKey($password, $privKey, $email=null, $label=null) { |
42 | - if(!isset($privKey) || is_null($privKey)) |
|
43 | - throw new ParameterError("Private Key required."); |
|
42 | + if(!isset($privKey) || is_null($privKey)) { |
|
43 | + throw new ParameterError("Private Key required."); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
46 | 47 | } |
@@ -56,19 +57,23 @@ discard block |
||
56 | 57 | * @throws ParameterError |
57 | 58 | */ |
58 | 59 | protected function doCreate($password, $priv = null, $label = null, $email = null){ |
59 | - if(!isset($password) || empty($password)) |
|
60 | - throw new ParameterError("Password required."); |
|
60 | + if(!isset($password) || empty($password)) { |
|
61 | + throw new ParameterError("Password required."); |
|
62 | + } |
|
61 | 63 | |
62 | 64 | $params = array( |
63 | 65 | 'password'=>$password, |
64 | 66 | 'hd'=>true |
65 | 67 | ); |
66 | - if(!is_null($priv)) |
|
67 | - $params['priv'] = $priv; |
|
68 | - if(!is_null($email)) |
|
69 | - $params['email'] = $email; |
|
70 | - if(!is_null($label)) |
|
71 | - $params['label'] = $label; |
|
68 | + if(!is_null($priv)) { |
|
69 | + $params['priv'] = $priv; |
|
70 | + } |
|
71 | + if(!is_null($email)) { |
|
72 | + $params['email'] = $email; |
|
73 | + } |
|
74 | + if(!is_null($label)) { |
|
75 | + $params['label'] = $label; |
|
76 | + } |
|
72 | 77 | |
73 | 78 | return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
74 | 79 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Appino\Blockchain\Exception\ParameterError; |
13 | 13 | use Appino\Blockchain\Objects\WalletAddress; |
14 | 14 | |
15 | -class Wallet{ |
|
15 | +class Wallet { |
|
16 | 16 | |
17 | 17 | protected $blockchain; |
18 | 18 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * Wallet constructor. |
30 | 30 | * @param Blockchain $blockchain |
31 | 31 | */ |
32 | - public function __construct(Blockchain $blockchain){ |
|
32 | + public function __construct(Blockchain $blockchain) { |
|
33 | 33 | $this->blockchain = $blockchain; |
34 | 34 | } |
35 | 35 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param $resource |
40 | 40 | * @return string |
41 | 41 | */ |
42 | - private function URL($resource){ |
|
42 | + private function URL($resource) { |
|
43 | 43 | return 'merchant/'.$this->identifier.'/'.$resource; |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @param string $guid |
50 | 50 | * @param string $password |
51 | 51 | */ |
52 | - public function credentials($guid, $password){ |
|
52 | + public function credentials($guid, $password) { |
|
53 | 53 | $this->identifier = $guid; |
54 | 54 | $this->password = $password; |
55 | 55 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @throws CredentialsError |
62 | 62 | */ |
63 | 63 | private function _checkCredentials() { |
64 | - if(is_null($this->identifier) || is_null($this->password)) { |
|
64 | + if (is_null($this->identifier) || is_null($this->password)) { |
|
65 | 65 | throw new CredentialsError('Please enter wallet credentials.'); |
66 | 66 | } |
67 | 67 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @param array $extras |
73 | 73 | * @return array |
74 | 74 | */ |
75 | - private function reqParams($extras=array()) { |
|
75 | + private function reqParams($extras = array()) { |
|
76 | 76 | $ret = array('password'=>$this->password); |
77 | 77 | return array_merge($ret, $extras); |
78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @throws CredentialsError |
85 | 85 | */ |
86 | 86 | |
87 | - private function call($resource, $params=array()) { |
|
87 | + private function call($resource, $params = array()) { |
|
88 | 88 | $this->_checkCredentials(); |
89 | 89 | return $this->blockchain->Request('POST', $this->URL($resource), $this->reqParams($params)); |
90 | 90 | } |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | * @return AccountResponse |
96 | 96 | */ |
97 | 97 | |
98 | - public function CreateAddress($label = null){ |
|
98 | + public function CreateAddress($label = null) { |
|
99 | 99 | $params = array(); |
100 | - if(!is_null($label)) |
|
100 | + if (!is_null($label)) |
|
101 | 101 | $params = ['label'=>$label]; |
102 | - $response = $this->call('accounts/create',$params); |
|
102 | + $response = $this->call('accounts/create', $params); |
|
103 | 103 | return new WalletAddress($response); |
104 | 104 | } |
105 | 105 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * @return int in satoshi |
111 | 111 | */ |
112 | 112 | |
113 | - public function Balance(){ |
|
114 | - $response = $this->call('balance',$this->reqParams()); |
|
113 | + public function Balance() { |
|
114 | + $response = $this->call('balance', $this->reqParams()); |
|
115 | 115 | return $response['balance']; |
116 | 116 | } |
117 | 117 | |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return int in satoshi |
123 | 123 | */ |
124 | 124 | |
125 | - public function AddressBallance($param){ |
|
126 | - $response = $this->call('accounts/'.$param.'/balance',$this->reqParams()); |
|
125 | + public function AddressBallance($param) { |
|
126 | + $response = $this->call('accounts/'.$param.'/balance', $this->reqParams()); |
|
127 | 127 | return $response['balance']; |
128 | 128 | } |
129 | 129 | |
@@ -133,10 +133,10 @@ discard block |
||
133 | 133 | */ |
134 | 134 | |
135 | 135 | public function ActiveAddresses() { |
136 | - $addresses = $this->call('accounts',$this->reqParams()); |
|
136 | + $addresses = $this->call('accounts', $this->reqParams()); |
|
137 | 137 | $response = array(); |
138 | - if(!is_null($addresses)) |
|
139 | - foreach ($addresses as $address){ |
|
138 | + if (!is_null($addresses)) |
|
139 | + foreach ($addresses as $address) { |
|
140 | 140 | $response[] = new AccountResponse($address); |
141 | 141 | } |
142 | 142 | return $response; |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | * @return string[] xpub address |
149 | 149 | */ |
150 | 150 | |
151 | - public function XpubList(){ |
|
152 | - $response = $this->call('accounts/xpubs',$this->reqParams()); |
|
151 | + public function XpubList() { |
|
152 | + $response = $this->call('accounts/xpubs', $this->reqParams()); |
|
153 | 153 | return $response; |
154 | 154 | } |
155 | 155 | |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @return AccountResponse |
161 | 161 | */ |
162 | 162 | |
163 | - public function SingleAddress($param){ |
|
164 | - $response = $this->call('accounts/'.$param,$this->reqParams()); |
|
163 | + public function SingleAddress($param) { |
|
164 | + $response = $this->call('accounts/'.$param, $this->reqParams()); |
|
165 | 165 | return new AccountResponse($response); |
166 | 166 | } |
167 | 167 | |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | * @return string |
173 | 173 | */ |
174 | 174 | |
175 | - public function ReceivingAddress($param){ |
|
176 | - $response = $this->call('accounts/'.$param.'/receiveAddress',$this->reqParams()); |
|
175 | + public function ReceivingAddress($param) { |
|
176 | + $response = $this->call('accounts/'.$param.'/receiveAddress', $this->reqParams()); |
|
177 | 177 | return $response['address']; |
178 | 178 | } |
179 | 179 | |
@@ -184,8 +184,8 @@ discard block |
||
184 | 184 | * @return AccountResponse |
185 | 185 | */ |
186 | 186 | |
187 | - public function ArchiveAddress($param){ |
|
188 | - $response = $this->call('accounts/'.$param.'/archive',$this->reqParams()); |
|
187 | + public function ArchiveAddress($param) { |
|
188 | + $response = $this->call('accounts/'.$param.'/archive', $this->reqParams()); |
|
189 | 189 | return new AccountResponse($response); |
190 | 190 | } |
191 | 191 | |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @return AccountResponse |
197 | 197 | */ |
198 | 198 | |
199 | - public function UnArchiveAddress($param){ |
|
200 | - $response = $this->call('accounts/'.$param.'/unarchive',$this->reqParams()); |
|
199 | + public function UnArchiveAddress($param) { |
|
200 | + $response = $this->call('accounts/'.$param.'/unarchive', $this->reqParams()); |
|
201 | 201 | return new AccountResponse($response); |
202 | 202 | } |
203 | 203 | |
@@ -213,21 +213,21 @@ discard block |
||
213 | 213 | * @throws ParameterError |
214 | 214 | */ |
215 | 215 | |
216 | - public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
|
217 | - if(!isset($amount)) |
|
216 | + public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) { |
|
217 | + if (!isset($amount)) |
|
218 | 218 | throw new ParameterError("Amount required."); |
219 | 219 | |
220 | 220 | $params = array( |
221 | 221 | 'to'=>$to, |
222 | 222 | 'amount'=>$amount |
223 | 223 | ); |
224 | - if(!is_null($from)) |
|
224 | + if (!is_null($from)) |
|
225 | 225 | $params['from'] = $from; |
226 | - if(!is_null($fee)) |
|
226 | + if (!is_null($fee)) |
|
227 | 227 | $params['fee'] = $fee; |
228 | - if(!is_null($fee_per_byte)) |
|
228 | + if (!is_null($fee_per_byte)) |
|
229 | 229 | $params['fee_per_byte'] = $fee_per_byte; |
230 | - $response = $this->call('payment',$params); |
|
230 | + $response = $this->call('payment', $params); |
|
231 | 231 | return new PaymentResponse($response); |
232 | 232 | } |
233 | 233 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * @param integer|null $fee_per_byte must be in satoshi |
241 | 241 | */ |
242 | 242 | |
243 | - public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){ |
|
243 | + public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) { |
|
244 | 244 | $params = array( |
245 | 245 | 'recipients'=>json_encode($recipients) |
246 | 246 | ); |
247 | - if(!is_null($from)) |
|
247 | + if (!is_null($from)) |
|
248 | 248 | $params['from'] = $from; |
249 | - if(!is_null($fee)) |
|
249 | + if (!is_null($fee)) |
|
250 | 250 | $params['fee'] = $fee; |
251 | - if(!is_null($fee_per_byte)) |
|
251 | + if (!is_null($fee_per_byte)) |
|
252 | 252 | $params['fee_per_byte'] = $fee_per_byte; |
253 | - $response = $this->call('sendmany',$params); |
|
253 | + $response = $this->call('sendmany', $params); |
|
254 | 254 | return new PaymentResponse($response); |
255 | 255 | } |
256 | 256 |
@@ -97,8 +97,9 @@ discard block |
||
97 | 97 | |
98 | 98 | public function CreateAddress($label = null){ |
99 | 99 | $params = array(); |
100 | - if(!is_null($label)) |
|
101 | - $params = ['label'=>$label]; |
|
100 | + if(!is_null($label)) { |
|
101 | + $params = ['label'=>$label]; |
|
102 | + } |
|
102 | 103 | $response = $this->call('accounts/create',$params); |
103 | 104 | return new WalletAddress($response); |
104 | 105 | } |
@@ -135,9 +136,10 @@ discard block |
||
135 | 136 | public function ActiveAddresses() { |
136 | 137 | $addresses = $this->call('accounts',$this->reqParams()); |
137 | 138 | $response = array(); |
138 | - if(!is_null($addresses)) |
|
139 | - foreach ($addresses as $address){ |
|
139 | + if(!is_null($addresses)) { |
|
140 | + foreach ($addresses as $address){ |
|
140 | 141 | $response[] = new AccountResponse($address); |
142 | + } |
|
141 | 143 | } |
142 | 144 | return $response; |
143 | 145 | } |
@@ -214,19 +216,23 @@ discard block |
||
214 | 216 | */ |
215 | 217 | |
216 | 218 | public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
217 | - if(!isset($amount)) |
|
218 | - throw new ParameterError("Amount required."); |
|
219 | + if(!isset($amount)) { |
|
220 | + throw new ParameterError("Amount required."); |
|
221 | + } |
|
219 | 222 | |
220 | 223 | $params = array( |
221 | 224 | 'to'=>$to, |
222 | 225 | 'amount'=>$amount |
223 | 226 | ); |
224 | - if(!is_null($from)) |
|
225 | - $params['from'] = $from; |
|
226 | - if(!is_null($fee)) |
|
227 | - $params['fee'] = $fee; |
|
228 | - if(!is_null($fee_per_byte)) |
|
229 | - $params['fee_per_byte'] = $fee_per_byte; |
|
227 | + if(!is_null($from)) { |
|
228 | + $params['from'] = $from; |
|
229 | + } |
|
230 | + if(!is_null($fee)) { |
|
231 | + $params['fee'] = $fee; |
|
232 | + } |
|
233 | + if(!is_null($fee_per_byte)) { |
|
234 | + $params['fee_per_byte'] = $fee_per_byte; |
|
235 | + } |
|
230 | 236 | $response = $this->call('payment',$params); |
231 | 237 | return new PaymentResponse($response); |
232 | 238 | } |
@@ -244,12 +250,15 @@ discard block |
||
244 | 250 | $params = array( |
245 | 251 | 'recipients'=>json_encode($recipients) |
246 | 252 | ); |
247 | - if(!is_null($from)) |
|
248 | - $params['from'] = $from; |
|
249 | - if(!is_null($fee)) |
|
250 | - $params['fee'] = $fee; |
|
251 | - if(!is_null($fee_per_byte)) |
|
252 | - $params['fee_per_byte'] = $fee_per_byte; |
|
253 | + if(!is_null($from)) { |
|
254 | + $params['from'] = $from; |
|
255 | + } |
|
256 | + if(!is_null($fee)) { |
|
257 | + $params['fee'] = $fee; |
|
258 | + } |
|
259 | + if(!is_null($fee_per_byte)) { |
|
260 | + $params['fee_per_byte'] = $fee_per_byte; |
|
261 | + } |
|
253 | 262 | $response = $this->call('sendmany',$params); |
254 | 263 | return new PaymentResponse($response); |
255 | 264 | } |
@@ -121,8 +121,8 @@ |
||
121 | 121 | */ |
122 | 122 | |
123 | 123 | public function DeleteBalanceNotification($id){ |
124 | - $response = $this->call('DELETE','balance_update/'.$id, $this->params); |
|
125 | - return $response['deleted']; |
|
124 | + $response = $this->call('DELETE','balance_update/'.$id, $this->params); |
|
125 | + return $response['deleted']; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | use Appino\Blockchain\Objects\ReceiveResponse; |
13 | 13 | use GuzzleHttp\Client; |
14 | 14 | |
15 | -class Receive{ |
|
15 | +class Receive { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * @var array |
@@ -32,14 +32,14 @@ discard block |
||
32 | 32 | * @param Blockchain $blockchain |
33 | 33 | */ |
34 | 34 | |
35 | - public function __construct(Blockchain $blockchain){ |
|
35 | + public function __construct(Blockchain $blockchain) { |
|
36 | 36 | $this->client = new Client(['base_uri'=>self::URL]); |
37 | 37 | $this->params = [ |
38 | - 'key'=>data_get('api_code',null) |
|
38 | + 'key'=>data_get('api_code', null) |
|
39 | 39 | ]; |
40 | 40 | } |
41 | 41 | |
42 | - private function Uri($uri){ |
|
42 | + private function Uri($uri) { |
|
43 | 43 | return self::URL.'/'.$uri; |
44 | 44 | } |
45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @return array |
51 | 51 | * @throws \Appino\Blockchain\Exception\HttpError |
52 | 52 | */ |
53 | - private function call($method, $uri, $params = array()){ |
|
53 | + private function call($method, $uri, $params = array()) { |
|
54 | 54 | return $this->blockchain->Request($method, $this->Uri($uri), $params); |
55 | 55 | } |
56 | 56 | |
@@ -62,14 +62,14 @@ discard block |
||
62 | 62 | * @param int $gap_limit How many unused addresses are allowed. |
63 | 63 | * @return ReceiveResponse |
64 | 64 | */ |
65 | - public function Generate($xpub, $callback, $gap_limit = 20){ |
|
65 | + public function Generate($xpub, $callback, $gap_limit = 20) { |
|
66 | 66 | $params = [ |
67 | 67 | 'xpub' => $xpub, |
68 | 68 | 'callback' => $callback, |
69 | 69 | 'gap_limit' => $gap_limit |
70 | 70 | ]; |
71 | 71 | $params = array_merge($this->params, $params); |
72 | - $response = $this->call('GET','',$params); |
|
72 | + $response = $this->call('GET', '', $params); |
|
73 | 73 | return new ReceiveResponse($response); |
74 | 74 | } |
75 | 75 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * @return integer |
81 | 81 | * @throws \GuzzleHttp\Exception\GuzzleException |
82 | 82 | */ |
83 | - public function AddressGap($xpub){ |
|
84 | - $params = array_merge(['xpub'=>$xpub],$this->params); |
|
85 | - $response = $this->call('GET','checkgap',$params); |
|
83 | + public function AddressGap($xpub) { |
|
84 | + $params = array_merge(['xpub'=>$xpub], $this->params); |
|
85 | + $response = $this->call('GET', 'checkgap', $params); |
|
86 | 86 | return $response['gap']; |
87 | 87 | } |
88 | 88 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * @return NotificationResponse |
100 | 100 | */ |
101 | 101 | |
102 | - public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){ |
|
102 | + public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) { |
|
103 | 103 | $params = [ |
104 | 104 | 'address' => $address, |
105 | 105 | 'callback' => $callback, |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | 'op' => $op |
109 | 109 | ]; |
110 | 110 | $params = array_merge($this->params, $params); |
111 | - $response = $this->call('POST','balance_update',$params); |
|
111 | + $response = $this->call('POST', 'balance_update', $params); |
|
112 | 112 | return new NotificationResponse($response); |
113 | 113 | } |
114 | 114 | |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @throws \GuzzleHttp\Exception\GuzzleException |
121 | 121 | */ |
122 | 122 | |
123 | - public function DeleteBalanceNotification($id){ |
|
124 | - $response = $this->call('DELETE','balance_update/'.$id, $this->params); |
|
123 | + public function DeleteBalanceNotification($id) { |
|
124 | + $response = $this->call('DELETE', 'balance_update/'.$id, $this->params); |
|
125 | 125 | return $response['deleted']; |
126 | 126 | } |
127 | 127 | |
@@ -136,16 +136,16 @@ discard block |
||
136 | 136 | * @throws \GuzzleHttp\Exception\GuzzleException |
137 | 137 | */ |
138 | 138 | |
139 | - public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){ |
|
139 | + public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) { |
|
140 | 140 | $params = [ |
141 | 141 | 'callback' => $callback, |
142 | 142 | 'onNotification' => $on, |
143 | 143 | 'confs' => $confs, |
144 | 144 | ]; |
145 | - if(!is_null($height)) |
|
145 | + if (!is_null($height)) |
|
146 | 146 | $params['height'] = $height; |
147 | 147 | $params = array_merge($this->params, $params); |
148 | - $response = $this->call('POST','block_notification',$params); |
|
148 | + $response = $this->call('POST', 'block_notification', $params); |
|
149 | 149 | return new NotificationResponse($response); |
150 | 150 | } |
151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @throws \GuzzleHttp\Exception\GuzzleException |
158 | 158 | */ |
159 | 159 | |
160 | - public function DeleteBlockNotification($id){ |
|
161 | - $response = $this->call('DELETE','block_notification/'.$id,$this->params); |
|
160 | + public function DeleteBlockNotification($id) { |
|
161 | + $response = $this->call('DELETE', 'block_notification/'.$id, $this->params); |
|
162 | 162 | return $response['deleted']; |
163 | 163 | } |
164 | 164 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | * @throws \GuzzleHttp\Exception\GuzzleException |
171 | 171 | */ |
172 | 172 | |
173 | - public function CallbackLogs($callback){ |
|
174 | - $params = array_merge(['callback'=>$callback],$this->params); |
|
175 | - $logs = $this->call('GET','callback_log',['query'=>$params]); |
|
173 | + public function CallbackLogs($callback) { |
|
174 | + $params = array_merge(['callback'=>$callback], $this->params); |
|
175 | + $logs = $this->call('GET', 'callback_log', ['query'=>$params]); |
|
176 | 176 | $response = array(); |
177 | - foreach ($logs as $log){ |
|
177 | + foreach ($logs as $log) { |
|
178 | 178 | $response[] = new LogResponse($log); |
179 | 179 | } |
180 | 180 | return $response; |
@@ -142,8 +142,9 @@ |
||
142 | 142 | 'onNotification' => $on, |
143 | 143 | 'confs' => $confs, |
144 | 144 | ]; |
145 | - if(!is_null($height)) |
|
146 | - $params['height'] = $height; |
|
145 | + if(!is_null($height)) { |
|
146 | + $params['height'] = $height; |
|
147 | + } |
|
147 | 148 | $params = array_merge($this->params, $params); |
148 | 149 | $response = $this->call('POST','block_notification',$params); |
149 | 150 | return new NotificationResponse($response); |