deleteOne method

Future<QuickbooksAccount> deleteOne({
  1. required String accessToken,
  2. required String companyId,
  3. required String id,
})

Deletes a QuickbooksAccount with the given accessToken and companyId

Sets the active field to false

Implementation

Future<QuickbooksAccount> deleteOne({
  required String accessToken,
  required String companyId,
  required String id,
}) async {
  var data = await get(
    accessToken: accessToken,
    companyId: companyId,
    id: id,
  );

  if (data == null) {
    throw AlfredException(404, 'Data not found');
  }

  data.active = false;

  var result = await post(
    accessToken: accessToken,
    companyId: companyId,
    data: data.toMap(),
    location: 'Account',
  );

  var newData = QuickbooksAccount.fromMap(result);

  return newData;
}