fetch: php: coinbase: add debug printing, tiny refactor

This commit is contained in:
2024-04-25 14:11:05 -07:00
parent 3c0e236aba
commit e70c899f90

View File

@@ -73,12 +73,16 @@ namespace docker_finance\exchanges\internal\exchanges\coinbase
//! @brief Implements underlying API request //! @brief Implements underlying API request
public function request(string $path): mixed public function request(string $path): mixed
{ {
$request = []; $response = [];
$timer = 10; $timer = 10;
$success = false; $success = false;
while (!$success) { while (!$success) {
try { try {
$request = $this->get_api()->request($path, 'private', 'GET'); utils\CLI::print_debug($path);
$response = $this->get_api()->request($path, 'private', 'GET');
utils\CLI::print_debug($response);
$success = true; $success = true;
} catch (\ccxt\NetworkError $ex) { } catch (\ccxt\NetworkError $ex) {
utils\CLI::print_warning( utils\CLI::print_warning(
@@ -87,7 +91,7 @@ namespace docker_finance\exchanges\internal\exchanges\coinbase
sleep($timer); sleep($timer);
} }
} }
return $request; return $response;
} }
/** @return array<string> */ /** @return array<string> */
@@ -96,6 +100,7 @@ namespace docker_finance\exchanges\internal\exchanges\coinbase
$stack = []; $stack = [];
// Push first response. Will provide us with pagination if exists // Push first response. Will provide us with pagination if exists
utils\CLI::print_debug($path);
$response = $this->request($path); $response = $this->request($path);
array_push($stack, $response); array_push($stack, $response);
@@ -144,9 +149,10 @@ namespace docker_finance\exchanges\internal\exchanges\coinbase
*/ */
private function get_transactions(string $account_id): array private function get_transactions(string $account_id): array
{ {
return $this->get_paginated_path( $path = 'accounts/' . $account_id . '/transactions?&limit=100&order=asc';
'accounts/' . $account_id . '/transactions?&limit=100&order=asc' utils\CLI::print_debug($path);
);
return $this->get_paginated_path($path);
} }
/** /**