updateSoftPosRegisteredDevices function
Future<int>
updateSoftPosRegisteredDevices({
- required BusinessService businessService,
- required LoggerService logger,
- required String businessId,
- required bool isAddition,
- required int currentCount,
Implementation
Future<int> updateSoftPosRegisteredDevices(
{required BusinessService businessService,
required LoggerService logger,
required String businessId,
required bool isAddition,
required int currentCount}) async {
// Default limit
int registeredDevices = currentCount;
isAddition ? registeredDevices++ : registeredDevices--;
try {
var result = await businessService.upsertBusinessSystemValue(
key: 'soft_pos_device_count',
sectionKey: 'device',
businessId: businessId,
value: registeredDevices,
);
if (result is int) {
return result;
}
throw PlatformException(
code: 'FAILEDTOUPDATEREGISTEREDDEVICES',
message: 'Failed to update registered devices');
} on PlatformException catch (e) {
logger.error('updateSoftPosRegisteredDevices',
'Failed to update Soft Pos Device Limit',
error: e);
rethrow;
} catch (e) {
logger.error('updateSoftPosRegisteredDevices',
'Failed to update SoftPos Device Limit',
error: e);
throw PlatformException(
code: 'FAILEDTOUPDATEREGISTEREDDEVICES',
message: 'Failed to update registered devices');
}
}