getBusinessMetricData function

Future<BusinessMetrics?> getBusinessMetricData(
  1. {String startDate = '',
  2. String endDate = '',
  3. String? businessId,
  4. bool showLoader = true}
)

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;
  }
}