createAccountFromToken method
This operation allows you to store a new bank account object from a token.
Implementation
Future<BankAccount> createAccountFromToken({
required String requestId,
required String customerId,
required String accountToken,
String? realmId,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.access_token;
realmId ??= authenticationService.getCachedRealmId();
Map<String, String> headers = {
"Request-ID": requestId,
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json',
//'Accept': 'application/json',
};
Uri endpoint = Uri.https(
baseUrl, "/quickbooks/v4/customers/$customerId/bank-accounts/createFromToken");
//print (endpoint.toString());
var response = await
http.post(endpoint, headers: headers, body: jsonEncode({"value": accountToken}));
if (response.statusCode == 200) {
return BankAccount.fromJson(jsonDecode(response.body));
}
else {
throw BankAccountException(statusCode: response.statusCode, message: response.body);
}
}