getCachedBills method

Future<AnybillResult<List<BillBaseDto>>> getCachedBills()

Retrieve a List<BillBaseDto> with the cached bills of the database.

Returns an instance of Success with the list of BillBaseDto objects as data if it exists in the cache.

In case of an internal error, instance of Failure with AnybillErrorType.unknown is returned.

Implementation

Future<AnybillResult<List<BillBaseDto>>> getCachedBills() async {
  AnybillLogger.info("Tried to get cached bills");
  try {
    final data = await _billStore.getAllBills();
    return AnybillResult.success(
      HttpStatus.ok,
      data: data,
    );
  }
  // ----------------------------------------------------------------
  catch (error, stacktrace) {
    AnybillLogger.error(
      error: error,
      stacktrace: stacktrace,
      library: runtimeType.toString(),
      event: "getCachedBills",
    );
    return AnybillResult.failure(
      type: AnybillErrorType.unknown,
      message: error.toString(),
    );
  }
}