getServerTime function
Gets the current time from the Coinbase Advanced API.
GET /api/v3/brokerage/time https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/public/get-server-time
Returns a ServerTime object.
Implementation
Future<ServerTime?> getServerTime(
{http.Client? client, bool isSandbox = false}) async {
http.Response response =
await get('/time', client: client, isSandbox: isSandbox);
if (response.statusCode == 200) {
var jsonResponse = jsonDecode(response.body);
return ServerTime.fromCBJson(jsonResponse);
} else {
var url = response.request?.url.toString();
print('Request to URL $url failed: Response code ${response.statusCode}');
print('Error Response Message: ${response.body}');
}
return null;
}