getAccount method
Get information about the account associated with the provided API key
Implementation
Future<Account> getAccount({
required String apiKey,
}) async {
Map<String, String> headers = {
"Authorization": apiKey,
'Content-Type': 'application/json',
"Access-Control-Allow-Origin": "*", // Required for CORS support to work
};
Uri endpoint;
if(secure) {
endpoint = Uri.https(
baseUrl, "/v1/user/account");
}
else {
endpoint = Uri.http(
baseUrl, "/v1/user/account");
}
var response = await
http.get(endpoint, headers: headers);
if (response.statusCode == 200 || response.statusCode == 201) {
return Account.fromJson(jsonDecode(const Utf8Decoder().convert(response.bodyBytes)));
}
else {
var error = ServerError.fromJson(jsonDecode(response.body));
throw UserException(statusCode: response.statusCode, message: error.message);
}
}