deleteOne method

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

Deletes a QuickbooksPayment with the given accessToken and companyId

Sets the active field to false

Implementation

Future<QuickbooksPayment> 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: 'Payment',
  );

  var newData = QuickbooksPayment.fromMap(result);

  return newData;
}