@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | namespace Appino\Blockchain\Objects; |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -class BlockCallback{ |
|
| 7 | +class BlockCallback { |
|
| 8 | 8 | |
| 9 | 9 | public $hash; |
| 10 | 10 | public $confirmations; |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | public $timestamp; |
| 13 | 13 | public $size; |
| 14 | 14 | |
| 15 | - public function __construct($json){ |
|
| 16 | - foreach ($json as $key => $value){ |
|
| 15 | + public function __construct($json) { |
|
| 16 | + foreach ($json as $key => $value) { |
|
| 17 | 17 | $this->{$key} = $value; |
| 18 | 18 | } |
| 19 | 19 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | namespace Appino\Blockchain\Objects; |
| 5 | 5 | |
| 6 | 6 | |
| 7 | -class BalanceCallback{ |
|
| 7 | +class BalanceCallback { |
|
| 8 | 8 | |
| 9 | 9 | public $transaction_hash; |
| 10 | 10 | public $address; |
@@ -16,8 +16,8 @@ discard block |
||
| 16 | 16 | * @param $json |
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | - public function __construct($json){ |
|
| 20 | - foreach ($json as $key => $value){ |
|
| 19 | + public function __construct($json) { |
|
| 20 | + foreach ($json as $key => $value) { |
|
| 21 | 21 | $this->{$key} = $value; |
| 22 | 22 | } |
| 23 | 23 | } |
@@ -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 | * @var Blockchain |
| 18 | 18 | */ |
@@ -29,10 +29,10 @@ discard block |
||
| 29 | 29 | * @param Blockchain $blockchain |
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | - public function __construct($config){ |
|
| 32 | + public function __construct($config) { |
|
| 33 | 33 | $this->client = new Client(['base_uri'=>self::URL]); |
| 34 | 34 | $this->params = [ |
| 35 | - 'key'=>data_get('api_code',null) |
|
| 35 | + 'key'=>data_get('api_code', null) |
|
| 36 | 36 | ]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | * @param int $gap_limit How many unused addresses are allowed. |
| 45 | 45 | * @return ReceiveResponse |
| 46 | 46 | */ |
| 47 | - public function Generate($xpub, $callback, $gap_limit = 20){ |
|
| 47 | + public function Generate($xpub, $callback, $gap_limit = 20) { |
|
| 48 | 48 | $params = [ |
| 49 | 49 | 'xpub' => $xpub, |
| 50 | 50 | 'callback' => $callback, |
| 51 | 51 | 'gap_limit' => $gap_limit |
| 52 | 52 | ]; |
| 53 | 53 | $params = array_merge($this->params, $params); |
| 54 | - $response = json_decode($this->client->get('',['query'=>$params]),true); |
|
| 54 | + $response = json_decode($this->client->get('', ['query'=>$params]), true); |
|
| 55 | 55 | return new ReceiveResponse($response); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * @return integer |
| 63 | 63 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 64 | 64 | */ |
| 65 | - public function AddressGap($xpub){ |
|
| 66 | - $params = array_merge(['xpub'=>$xpub],$this->params); |
|
| 67 | - $response = json_decode($this->client->get('checkgap',['query'=>$params]),true); |
|
| 65 | + public function AddressGap($xpub) { |
|
| 66 | + $params = array_merge(['xpub'=>$xpub], $this->params); |
|
| 67 | + $response = json_decode($this->client->get('checkgap', ['query'=>$params]), true); |
|
| 68 | 68 | return $response['gap']; |
| 69 | 69 | } |
| 70 | 70 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @return NotificationResponse |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | - public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL){ |
|
| 84 | + public function BalanceNotification($address, $callback, $on = Notification::KEEP, $confs = 3, $op = Operation::ALL) { |
|
| 85 | 85 | $params = [ |
| 86 | 86 | 'address' => $address, |
| 87 | 87 | 'callback' => $callback, |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | 'op' => $op |
| 91 | 91 | ]; |
| 92 | 92 | $params = array_merge($this->params, $params); |
| 93 | - $response = json_decode($this->client->post('balance_update',['form_params'=>$params]),true); |
|
| 93 | + $response = json_decode($this->client->post('balance_update', ['form_params'=>$params]), true); |
|
| 94 | 94 | return new NotificationResponse($response); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -102,8 +102,8 @@ discard block |
||
| 102 | 102 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 103 | 103 | */ |
| 104 | 104 | |
| 105 | - public function DeleteBalanceNotification($id){ |
|
| 106 | - $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]),true); |
|
| 105 | + public function DeleteBalanceNotification($id) { |
|
| 106 | + $response = json_decode($this->client->delete('balance_update/'.$id, ['query'=>$this->params]), true); |
|
| 107 | 107 | return $response['deleted']; |
| 108 | 108 | } |
| 109 | 109 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 119 | 119 | */ |
| 120 | 120 | |
| 121 | - public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null){ |
|
| 121 | + public function BlockNotification($callback, $on = Notification::KEEP, $confs = 1, $height = null) { |
|
| 122 | 122 | $params = [ |
| 123 | 123 | 'callback' => $callback, |
| 124 | 124 | 'onNotification' => $on, |
| 125 | 125 | 'confs' => $confs, |
| 126 | 126 | ]; |
| 127 | - if(!is_null($height)) |
|
| 127 | + if (!is_null($height)) |
|
| 128 | 128 | $params['height'] = $height; |
| 129 | 129 | $params = array_merge($this->params, $params); |
| 130 | - $response = json_decode($this->client->post('block_notification',['form_params'=>$params]),true); |
|
| 130 | + $response = json_decode($this->client->post('block_notification', ['form_params'=>$params]), true); |
|
| 131 | 131 | return new NotificationResponse($response); |
| 132 | 132 | } |
| 133 | 133 | |
@@ -139,8 +139,8 @@ discard block |
||
| 139 | 139 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 140 | 140 | */ |
| 141 | 141 | |
| 142 | - public function DeleteBlockNotification($id){ |
|
| 143 | - $response = json_decode($this->client->delete('block_notification/'.$id,['query'=>$this->params]),true); |
|
| 142 | + public function DeleteBlockNotification($id) { |
|
| 143 | + $response = json_decode($this->client->delete('block_notification/'.$id, ['query'=>$this->params]), true); |
|
| 144 | 144 | return $response['deleted']; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | * @throws \GuzzleHttp\Exception\GuzzleException |
| 153 | 153 | */ |
| 154 | 154 | |
| 155 | - public function CallbackLogs($callback){ |
|
| 156 | - $params = array_merge(['callback'=>$callback],$this->params); |
|
| 157 | - $response = json_decode($this->client->get('callback_log',['query'=>$params]),true); |
|
| 155 | + public function CallbackLogs($callback) { |
|
| 156 | + $params = array_merge(['callback'=>$callback], $this->params); |
|
| 157 | + $response = json_decode($this->client->get('callback_log', ['query'=>$params]), true); |
|
| 158 | 158 | return new LogResponse($response); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -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 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @return AccountResponse |
| 95 | 95 | */ |
| 96 | 96 | |
| 97 | - public function Balance(){ |
|
| 97 | + public function Balance() { |
|
| 98 | 98 | $response = $this->call('balance'); |
| 99 | 99 | return new AccountResponse($response); |
| 100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * @return AccountResponse |
| 107 | 107 | */ |
| 108 | 108 | |
| 109 | - public function Address_Ballance($address){ |
|
| 109 | + public function Address_Ballance($address) { |
|
| 110 | 110 | $response = $this->call('accounts/'.$address.'/balance'); |
| 111 | 111 | return new AccountResponse($response); |
| 112 | 112 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | * @return AccountResponse |
| 117 | 117 | */ |
| 118 | 118 | |
| 119 | - public function ActiveWallets(){ |
|
| 119 | + public function ActiveWallets() { |
|
| 120 | 120 | $response = $this->call('accounts'); |
| 121 | 121 | return new AccountResponse($response); |
| 122 | 122 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return AccountResponse |
| 128 | 128 | */ |
| 129 | 129 | |
| 130 | - public function XpubList(){ |
|
| 130 | + public function XpubList() { |
|
| 131 | 131 | $response = $this->call('accounts/xpubs'); |
| 132 | 132 | return new AccountResponse($response); |
| 133 | 133 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @return AccountResponse |
| 140 | 140 | */ |
| 141 | 141 | |
| 142 | - public function SingleAddress($index){ |
|
| 142 | + public function SingleAddress($index) { |
|
| 143 | 143 | $response = $this->call('accounts/'.$index); |
| 144 | 144 | return new AccountResponse($response); |
| 145 | 145 | } |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @return AccountResponse |
| 152 | 152 | */ |
| 153 | 153 | |
| 154 | - public function ReceivingAddress($index){ |
|
| 154 | + public function ReceivingAddress($index) { |
|
| 155 | 155 | $response = $this->call('accounts/'.$index.'/receiveAddress'); |
| 156 | 156 | return new AccountResponse($response); |
| 157 | 157 | } |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @return AccountResponse |
| 164 | 164 | */ |
| 165 | 165 | |
| 166 | - public function ArchiveAddress($index){ |
|
| 166 | + public function ArchiveAddress($index) { |
|
| 167 | 167 | $response = $this->call('accounts/'.$index.'/archive'); |
| 168 | 168 | return new AccountResponse($response); |
| 169 | 169 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @return AccountResponse |
| 176 | 176 | */ |
| 177 | 177 | |
| 178 | - public function UnArchiveAddress($index){ |
|
| 178 | + public function UnArchiveAddress($index) { |
|
| 179 | 179 | $response = $this->call('accounts/'.$index.'/unarchive'); |
| 180 | 180 | return new AccountResponse($response); |
| 181 | 181 | } |
@@ -191,21 +191,21 @@ discard block |
||
| 191 | 191 | * @throws ParameterError |
| 192 | 192 | */ |
| 193 | 193 | |
| 194 | - public function SendPayment($to, $amount, $from=null, $fee=null, $fee_per_byte=null){ |
|
| 195 | - if(!isset($amount)) |
|
| 194 | + public function SendPayment($to, $amount, $from = null, $fee = null, $fee_per_byte = null) { |
|
| 195 | + if (!isset($amount)) |
|
| 196 | 196 | throw new ParameterError("Amount required."); |
| 197 | 197 | |
| 198 | 198 | $params = array( |
| 199 | 199 | 'to'=>$to, |
| 200 | 200 | 'amount'=>$amount |
| 201 | 201 | ); |
| 202 | - if(!is_null($from)) |
|
| 202 | + if (!is_null($from)) |
|
| 203 | 203 | $params['from'] = $from; |
| 204 | - if(!is_null($fee)) |
|
| 204 | + if (!is_null($fee)) |
|
| 205 | 205 | $params['fee'] = $fee; |
| 206 | - if(!is_null($fee_per_byte)) |
|
| 206 | + if (!is_null($fee_per_byte)) |
|
| 207 | 207 | $params['fee_per_byte'] = $fee_per_byte; |
| 208 | - $response = $this->call('payment',$params); |
|
| 208 | + $response = $this->call('payment', $params); |
|
| 209 | 209 | return new PaymentResponse($response); |
| 210 | 210 | } |
| 211 | 211 | |
@@ -218,17 +218,17 @@ discard block |
||
| 218 | 218 | * @param integer|null $fee_per_byte must be in satoshi |
| 219 | 219 | */ |
| 220 | 220 | |
| 221 | - public function SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null){ |
|
| 221 | + public function SendManyPayment($recipients, $from = null, $fee = null, $fee_per_byte = null) { |
|
| 222 | 222 | $params = array( |
| 223 | 223 | 'recipients'=>json_encode($recipients) |
| 224 | 224 | ); |
| 225 | - if(!is_null($from)) |
|
| 225 | + if (!is_null($from)) |
|
| 226 | 226 | $params['from'] = $from; |
| 227 | - if(!is_null($fee)) |
|
| 227 | + if (!is_null($fee)) |
|
| 228 | 228 | $params['fee'] = $fee; |
| 229 | - if(!is_null($fee_per_byte)) |
|
| 229 | + if (!is_null($fee_per_byte)) |
|
| 230 | 230 | $params['fee_per_byte'] = $fee_per_byte; |
| 231 | - $response = $this->call('sendmany',$params); |
|
| 231 | + $response = $this->call('sendmany', $params); |
|
| 232 | 232 | return new PaymentResponse($response); |
| 233 | 233 | } |
| 234 | 234 | |
@@ -5,12 +5,12 @@ discard block |
||
| 5 | 5 | use 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 | return new WalletResponse($this->doCreate($password, null, $email, $label)); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @return WalletResponse |
| 38 | 38 | * @throws ParameterError |
| 39 | 39 | */ |
| 40 | - public function createWithKey($password, $privKey, $email=null, $label=null) { |
|
| 41 | - if(!isset($privKey) || is_null($privKey)) |
|
| 40 | + public function createWithKey($password, $privKey, $email = null, $label = null) { |
|
| 41 | + if (!isset($privKey) || is_null($privKey)) |
|
| 42 | 42 | throw new ParameterError("Private Key required."); |
| 43 | 43 | |
| 44 | 44 | return new WalletResponse($this->doCreate($password, $privKey, $email, $label)); |
@@ -54,21 +54,21 @@ discard block |
||
| 54 | 54 | * @return array |
| 55 | 55 | * @throws ParameterError |
| 56 | 56 | */ |
| 57 | - protected function doCreate($password, $priv = null, $label = null, $email = null){ |
|
| 58 | - if(!isset($password) || is_null($password)) |
|
| 57 | + protected function doCreate($password, $priv = null, $label = null, $email = null) { |
|
| 58 | + if (!isset($password) || is_null($password)) |
|
| 59 | 59 | throw new ParameterError("Password required."); |
| 60 | 60 | |
| 61 | 61 | $params = array( |
| 62 | 62 | 'password'=>$password |
| 63 | 63 | ); |
| 64 | - if(!is_null($priv)) |
|
| 64 | + if (!is_null($priv)) |
|
| 65 | 65 | $params['priv'] = $priv; |
| 66 | - if(!is_null($email)) |
|
| 66 | + if (!is_null($email)) |
|
| 67 | 67 | $params['email'] = $email; |
| 68 | - if(!is_null($label)) |
|
| 68 | + if (!is_null($label)) |
|
| 69 | 69 | $params['label'] = $label; |
| 70 | 70 | |
| 71 | - return $this->blockchain->Request(Blockchain::POST,self::URL,$params); |
|
| 71 | + return $this->blockchain->Request(Blockchain::POST, self::URL, $params); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | } |
@@ -5,5 +5,5 @@ |
||
| 5 | 5 | */ |
| 6 | 6 | return [ |
| 7 | 7 | 'api_code'=>env('blockchain_api_code'), |
| 8 | - 'base_url'=>env('blockchain_base_url','http://localhost:3000/') |
|
| 8 | + 'base_url'=>env('blockchain_base_url', 'http://localhost:3000/') |
|
| 9 | 9 | ]; |