updateOne method

Future<QuickbooksVendor> updateOne({
  1. required String accessToken,
  2. required String companyId,
  3. required QuickbooksVendor data,
})

Updates a QuickbooksVendor with the given accessToken and companyId

Implementation

Future<QuickbooksVendor> updateOne({
  required String accessToken,
  required String companyId,
  required QuickbooksVendor data,
}) async {
  var oldData = await get(
    accessToken: accessToken,
    companyId: companyId,
    id: data.id!,
  );

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

  data.syncToken = oldData.syncToken;

  var result = await post(
    accessToken: accessToken,
    companyId: companyId,
    data: data.toMap(),
    location: 'Vendor',
  );
  var newData = QuickbooksVendor.fromMap(result);
  return newData;
}