@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | use Appino\Blockchain\Objects\Cache; |
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 | } |
@@ -4,16 +4,16 @@ |
||
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(array_key_exists('receiveAccount',$params)) |
|
14 | - $this->receiveAccount = data_get($params,'receiveAccount'); |
|
15 | - if(array_key_exists('changeAccount',$params)) |
|
16 | - $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
12 | + public function __construct($params) { |
|
13 | + if (array_key_exists('receiveAccount', $params)) |
|
14 | + $this->receiveAccount = data_get($params, 'receiveAccount'); |
|
15 | + if (array_key_exists('changeAccount', $params)) |
|
16 | + $this->changeAccount = new Cache(data_get($params, 'changeAccount')); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | } |
@@ -10,10 +10,12 @@ |
||
10 | 10 | public $changeAccount; |
11 | 11 | |
12 | 12 | public function __construct($params){ |
13 | - if(array_key_exists('receiveAccount',$params)) |
|
14 | - $this->receiveAccount = data_get($params,'receiveAccount'); |
|
15 | - if(array_key_exists('changeAccount',$params)) |
|
16 | - $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
13 | + if(array_key_exists('receiveAccount',$params)) { |
|
14 | + $this->receiveAccount = data_get($params,'receiveAccount'); |
|
15 | + } |
|
16 | + if(array_key_exists('changeAccount',$params)) { |
|
17 | + $this->changeAccount = new Cache(data_get($params,'changeAccount')); |
|
18 | + } |
|
17 | 19 | } |
18 | 20 | |
19 | 21 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | use Blockchain\Exception\CredentialsError; |
12 | 12 | use Blockchain\Exception\ParameterError; |
13 | 13 | |
14 | -class Wallet{ |
|
14 | +class Wallet { |
|
15 | 15 | |
16 | 16 | protected $blockchain; |
17 | 17 | |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * Wallet constructor. |
29 | 29 | * @param Blockchain $blockchain |
30 | 30 | */ |
31 | - public function __construct(Blockchain $blockchain){ |
|
31 | + public function __construct(Blockchain $blockchain) { |
|
32 | 32 | $this->blockchain = $blockchain; |
33 | 33 | } |
34 | 34 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * @param $resource |
39 | 39 | * @return string |
40 | 40 | */ |
41 | - private function URL($resource){ |
|
41 | + private function URL($resource) { |
|
42 | 42 | return 'merchant/'.$this->identifier.'/'.$resource; |
43 | 43 | } |
44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $guid |
49 | 49 | * @param string $password |
50 | 50 | */ |
51 | - public function credentials($guid, $password){ |
|
51 | + public function credentials($guid, $password) { |
|
52 | 52 | $this->identifier = $guid; |
53 | 53 | $this->password = $password; |
54 | 54 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @throws CredentialsError |
60 | 60 | */ |
61 | 61 | private function _checkCredentials() { |
62 | - if(is_null($this->identifier) || is_null($this->password)) { |
|
62 | + if (is_null($this->identifier) || is_null($this->password)) { |
|
63 | 63 | throw new CredentialsError('Please enter wallet credentials.'); |
64 | 64 | } |
65 | 65 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @param array $extras |
71 | 71 | * @return array |
72 | 72 | */ |
73 | - private function reqParams($extras=array()) { |
|
73 | + private function reqParams($extras = array()) { |
|
74 | 74 | $ret = array('password'=>$this->password); |
75 | 75 | return array_merge($ret, $extras); |
76 | 76 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @throws CredentialsError |
83 | 83 | */ |
84 | 84 | |
85 | - private function call($resource, $params=array()) { |
|
85 | + private function call($resource, $params = array()) { |
|
86 | 86 | $this->_checkCredentials(); |
87 | 87 | return $this->blockchain->Request('post', $this->URL($resource), $this->reqParams($params)); |
88 | 88 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return AccountResponse |
94 | 94 | */ |
95 | 95 | |
96 | - public function CreateAddress($label = null){ |
|
96 | + public function CreateAddress($label = null) { |
|
97 | 97 | $response = $this->call('accounts/create'); |
98 | 98 | return new AccountResponse($response); |
99 | 99 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return int in satoshi |
106 | 106 | */ |
107 | 107 | |
108 | - public function Balance(){ |
|
108 | + public function Balance() { |
|
109 | 109 | $response = $this->call('balance'); |
110 | 110 | return $response['balance']; |
111 | 111 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @return int in satoshi |
118 | 118 | */ |
119 | 119 | |
120 | - public function AddressBallance($param){ |
|
120 | + public function AddressBallance($param) { |
|
121 | 121 | $response = $this->call('accounts/'.$param.'/balance'); |
122 | 122 | return $response['balance']; |
123 | 123 | } |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | * @return array<AccountResponse> |
128 | 128 | */ |
129 | 129 | |
130 | - public function ActiveAddresses(){ |
|
130 | + public function ActiveAddresses() { |
|
131 | 131 | $addresses = $this->call('accounts'); |
132 | 132 | $response = array(); |
133 | - foreach ($addresses as $address){ |
|
133 | + foreach ($addresses as $address) { |
|
134 | 134 | $response[] = new AccountResponse($address); |
135 | 135 | } |
136 | 136 | return $response; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @return array<string> xpub address |
143 | 143 | */ |
144 | 144 | |
145 | - public function XpubList(){ |
|
145 | + public function XpubList() { |
|
146 | 146 | $response = $this->call('accounts/xpubs'); |
147 | 147 | return $response; |
148 | 148 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return AccountResponse |
155 | 155 | */ |
156 | 156 | |
157 | - public function SingleAddress($param){ |
|
157 | + public function SingleAddress($param) { |
|
158 | 158 | $response = $this->call('accounts/'.$param); |
159 | 159 | return new AccountResponse($response); |
160 | 160 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @return string |
167 | 167 | */ |
168 | 168 | |
169 | - public function ReceivingAddress($param){ |
|
169 | + public function ReceivingAddress($param) { |
|
170 | 170 | $response = $this->call('accounts/'.$param.'/receiveAddress'); |
171 | 171 | return $response['address']; |
172 | 172 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return AccountResponse |
179 | 179 | */ |
180 | 180 | |
181 | - public function ArchiveAddress($param){ |
|
181 | + public function ArchiveAddress($param) { |
|
182 | 182 | $response = $this->call('accounts/'.$param.'/archive'); |
183 | 183 | return new AccountResponse($response); |
184 | 184 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @return AccountResponse |
191 | 191 | */ |
192 | 192 | |
193 | - public function UnArchiveAddress($param){ |
|
193 | + public function UnArchiveAddress($param) { |
|
194 | 194 | $response = $this->call('accounts/'.$param.'/unarchive'); |
195 | 195 | return new AccountResponse($response); |
196 | 196 | } |
@@ -206,21 +206,21 @@ discard block |
||
206 | 206 | * @throws ParameterError |
207 | 207 | */ |
208 | 208 | |
209 | - public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
|
210 | - if(!isset($amount)) |
|
209 | + public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) { |
|
210 | + if (!isset($amount)) |
|
211 | 211 | throw new ParameterError("Amount required."); |
212 | 212 | |
213 | 213 | $params = array( |
214 | 214 | 'to'=>$to, |
215 | 215 | 'amount'=>$amount |
216 | 216 | ); |
217 | - if(!is_null($from)) |
|
217 | + if (!is_null($from)) |
|
218 | 218 | $params['from'] = $from; |
219 | - if(!is_null($fee)) |
|
219 | + if (!is_null($fee)) |
|
220 | 220 | $params['fee'] = $fee; |
221 | - if(!is_null($fee_per_byte)) |
|
221 | + if (!is_null($fee_per_byte)) |
|
222 | 222 | $params['fee_per_byte'] = $fee_per_byte; |
223 | - $response = $this->call('payment',$params); |
|
223 | + $response = $this->call('payment', $params); |
|
224 | 224 | return new PaymentResponse($response); |
225 | 225 | } |
226 | 226 | |
@@ -233,17 +233,17 @@ discard block |
||
233 | 233 | * @param integer|null $fee_per_byte must be in satoshi |
234 | 234 | */ |
235 | 235 | |
236 | - public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){ |
|
236 | + public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) { |
|
237 | 237 | $params = array( |
238 | 238 | 'recipients'=>json_encode($recipients) |
239 | 239 | ); |
240 | - if(!is_null($from)) |
|
240 | + if (!is_null($from)) |
|
241 | 241 | $params['from'] = $from; |
242 | - if(!is_null($fee)) |
|
242 | + if (!is_null($fee)) |
|
243 | 243 | $params['fee'] = $fee; |
244 | - if(!is_null($fee_per_byte)) |
|
244 | + if (!is_null($fee_per_byte)) |
|
245 | 245 | $params['fee_per_byte'] = $fee_per_byte; |
246 | - $response = $this->call('sendmany',$params); |
|
246 | + $response = $this->call('sendmany', $params); |
|
247 | 247 | return new PaymentResponse($response); |
248 | 248 | } |
249 | 249 |