getAccount function
Future<Account?>
getAccount({
- required String? uuid,
- Client? client,
- required Credential credential,
- bool isSandbox = false,
Gets a single account for the current user by UUID.
GET /api/v3/brokerage/accounts/{account_uuid} https://docs.cdp.coinbase.com/api-reference/advanced-trade-api/rest-api/accounts/get-account
This function makes a GET request to the /accounts/{uuid} endpoint of the Coinbase Advanced Trade API.
uuid - The UUID of the account to be returned.
credential - The user's API credentials.
isSandbox - Whether to use the sandbox environment.
Returns an Account object, or null if no account is found for the given UUID.
Implementation
Future<Account?> getAccount(
{required String? uuid,
http.Client? client,
required Credential credential,
bool isSandbox = false}) async {
http.Response response = await getAuthorized('/accounts/$uuid',
client: client, credential: credential, isSandbox: isSandbox);
if (response.statusCode == 200) {
var jsonResponse = jsonDecode(response.body);
var jsonAccount = jsonResponse['account'];
return Account.fromCBJson(jsonAccount);
} else {
throw CoinbaseException(
'Failed to get account', response.statusCode, response.body);
}
}