downSync method

FutureOr<Map<String, dynamic>> downSync(
  1. AttendanceLogSearchModel query, {
  2. int? offSet,
  3. int? limit,
})
inherited

Implementation

FutureOr<Map<String, dynamic>> downSync(
  R query, {
  int? offSet,
  int? limit,
}) async {
  Response response;

  try {
    response = await executeFuture(
      future: () async {
        return await dio.post(
          searchPath,
          queryParameters: {
            'offset': offSet ?? 0,
            'limit': limit ?? 100,
            'tenantId': DigitDataModelSingleton().tenantId,
            if (query.isDeleted ?? false) 'includeDeleted': query.isDeleted,
          },
          data: {
            entityName == 'Downsync' ? 'DownsyncCriteria' : entityName:
                query.toMap(),
          },
        );
      },
    );
  } catch (error) {
    return {};
  }

  final responseMap = response.data;

  if (!responseMap.containsKey(
    entityName,
  )) {
    throw InvalidApiResponseException(
      data: query.toMap(),
      path: searchPath,
      response: responseMap,
    );
  }

  return responseMap[entityName];
}