requestWithdrawAll method

Future<AccountRequestWithdrawResponse> requestWithdrawAll({
  1. required String targetAccountId,
  2. required String customUserApiToken,
})

Faz um pedido de saque de todo saldo de uma conta, utilizando um user token da conta de saque

Id da conta a ser validada User token customizado da Api

Implementation

Future<AccountRequestWithdrawResponse> requestWithdrawAll({
  required String targetAccountId,
  required String customUserApiToken,
}) async {
  var _resultAccountBalance = await apiResource.getById(id: targetAccountId);
  var _accountBalanceValue = GetAccountResponseMessage.fromMap(_resultAccountBalance);
  var _convertedValue = double.parse(_accountBalanceValue.balance.replaceAll(CurrencySymbol.BRL, '').replaceAll(",", "."));
  var result = await apiResource.post(data: {
    "amount": _convertedValue
  }, partOfUrl: "/$targetAccountId/request_withdraw", apiUserToken: customUserApiToken);
  return AccountRequestWithdrawResponse.fromMap(result);
}