getBusinessMetricData function
Implementation
Future<BusinessMetrics?> getBusinessMetricData({String startDate = '', String endDate = '', String? businessId, bool showLoader = true}) async {
if (showLoader) appStore.setLoading(true);
try {
String id = businessId != null ? "?business_id=$businessId" : '';
String selectedStartDate = startDate.isNotEmpty ? '&start_date=$startDate' : '';
String selectedEndDate = endDate.isNotEmpty ? '&end_date=$endDate' : '';
BusinessMetricsResponse res = BusinessMetricsResponse.fromMap(await (handleResponse(await buildHttpResponse("${APIEndPoint.getMetrics}$id$selectedStartDate$selectedEndDate", method: HttpMethod.GET))));
appStore.setLoading(false);
return await res.data;
} catch (e) {
appStore.setLoading(false);
throw errorSomethingWentWrong;
}
}