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