@@ -88,26 +88,26 @@ discard block |
||
| 88 | 88 | * @throws ServerExceptionInterface |
| 89 | 89 | * @throws TransportExceptionInterface |
| 90 | 90 | */ |
| 91 | - private function call(string $path, string $method, array $headers = [], array $body = []): string |
|
| 91 | + private function call(string $path, string $method, array $headers = [ ], array $body = [ ]): string |
|
| 92 | 92 | { |
| 93 | 93 | $client = HttpClient::create(); |
| 94 | 94 | $fullPath = sprintf('%s%s', $this->endpoint, $path); |
| 95 | 95 | |
| 96 | - $options = []; |
|
| 96 | + $options = [ ]; |
|
| 97 | 97 | |
| 98 | 98 | if (!empty($headers)) { |
| 99 | - $options['headers'] = $headers; |
|
| 99 | + $options[ 'headers' ] = $headers; |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | if (!empty($body)) { |
| 103 | - $options['json'] = $body; |
|
| 103 | + $options[ 'json' ] = $body; |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $request = $client->request($method, $fullPath, $options); |
| 107 | 107 | $response = $request->toArray(false); |
| 108 | 108 | |
| 109 | - if (isset($response['error_code'])) { |
|
| 110 | - throw new BitapsAPIException(sprintf('Got an error response with message: %s.', $response['message'])); |
|
| 109 | + if (isset($response[ 'error_code' ])) { |
|
| 110 | + throw new BitapsAPIException(sprintf('Got an error response with message: %s.', $response[ 'message' ])); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | return $request->getContent(); |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | private function getAccess(): array |
| 120 | 120 | { |
| 121 | 121 | $nonce = round(microtime(true) * 1000); |
| 122 | - $key = hash('sha256', hash('sha256', $this->walletId . $this->password, true), true); |
|
| 123 | - $msg = $this->walletId . $nonce; |
|
| 122 | + $key = hash('sha256', hash('sha256', $this->walletId.$this->password, true), true); |
|
| 123 | + $msg = $this->walletId.$nonce; |
|
| 124 | 124 | $signature = hash_hmac('sha256', $msg, $key); |
| 125 | 125 | |
| 126 | - return [$nonce, $signature]; |
|
| 126 | + return [ $nonce, $signature ]; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function &addPayment(string $address, int $amount): WalletAPI |
| 180 | 180 | { |
| 181 | - $this->receiversList[] = [ |
|
| 181 | + $this->receiversList[ ] = [ |
|
| 182 | 182 | 'address' => $address, |
| 183 | 183 | 'amount' => $amount |
| 184 | 184 | ]; |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | */ |
| 199 | 199 | public function pay(): SendPaymentResponse |
| 200 | 200 | { |
| 201 | - [$nonce, $signature] = $this->getAccess(); |
|
| 201 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 202 | 202 | $request = new SendPaymentRequest($this->walletId, $this->receiversList, $nonce, $signature); |
| 203 | 203 | |
| 204 | 204 | $response = $this->call($request->getPathParams(), 'POST', $request->getHeaders(), $request->getBody()); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public function getWalletState(): WalletStateResponse |
| 221 | 221 | { |
| 222 | - [$nonce, $signature] = $this->getAccess(); |
|
| 222 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 223 | 223 | $request = new WalletStateRequest($this->walletId, $nonce, $signature); |
| 224 | 224 | |
| 225 | 225 | $response = $this->call($request->getPathParams(), 'GET', $request->getHeaders(), $request->getBody()); |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | int $limit = null, |
| 249 | 249 | int $page = null |
| 250 | 250 | ): AddressTransactionsResponse { |
| 251 | - [$nonce, $signature] = $this->getAccess(); |
|
| 251 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 252 | 252 | $request = new WalletTransactionsRequest($this->walletId, $nonce, $signature, $from, $to, $limit, $page); |
| 253 | 253 | |
| 254 | 254 | $response = $this->call($request->getPathParams(), 'GET', $request->getHeaders(), $request->getBody()); |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | int $limit = null, |
| 278 | 278 | int $page = null |
| 279 | 279 | ): GetAddressesResponse { |
| 280 | - [$nonce, $signature] = $this->getAccess(); |
|
| 280 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 281 | 281 | $request = new AddressesRequest($this->walletId, $nonce, $signature, $from, $to, $limit, $page); |
| 282 | 282 | |
| 283 | 283 | $response = $this->call($request->getPathParams(), 'GET', $request->getHeaders(), $request->getBody()); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | int $limit = null, |
| 309 | 309 | int $page = null |
| 310 | 310 | ): AddressTransactionsResponse { |
| 311 | - [$nonce, $signature] = $this->getAccess(); |
|
| 311 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 312 | 312 | $request = new AddressTransactionsRequest( |
| 313 | 313 | $this->walletId, |
| 314 | 314 | $address, |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | int $limit = null, |
| 346 | 346 | int $page = null |
| 347 | 347 | ): WalletDailyStatisticsResponse { |
| 348 | - [$nonce, $signature] = $this->getAccess(); |
|
| 348 | + [ $nonce, $signature ] = $this->getAccess(); |
|
| 349 | 349 | $request = new WalletDailyStatisticsRequest($this->walletId, $nonce, $signature, $from, $to, $limit, $page); |
| 350 | 350 | |
| 351 | 351 | $response = $this->call($request->getPathParams(), 'GET', $request->getHeaders(), $request->getBody()); |