getCustomers method
Implementation
Future<List<Customer>> getCustomers() async {
try {
final response = await _client.get(
url: '$_baseUrl/Customer/GetCustomers/businessId=$_businessId',
user: _authService?.user,
);
if (response?.data == null) {
return [];
}
final data = response!.data;
if (data is List) {
return data
.map((e) => Customer.fromJson(e as Map<String, dynamic>))
.toList();
}
return [];
} catch (e, st) {
_logger.error(
_caller,
'Failed to fetch customers',
error: e,
stackTrace: st,
);
rethrow;
}
}