getCachedUserQrCode method
Retrieve the cached user QR code data from the database.
Returns an instance of Success with the UserQrCodeDto object as data if it exists in the cache otherwise returns instance of Failure with type AnybillErrorType.genericError and code HttpStatus.notFound is returned.
In case of an internal error, instance of Failure with AnybillErrorType.unknown is returned
Implementation
Future<AnybillResult<UserQrCodeDto>> getCachedUserQrCode() async {
try {
final data = await _userStore.getQrCodeData();
if (data != null) {
return AnybillResult.success(
HttpStatus.ok,
data: data,
);
} else {
return AnybillResult.failure(
type: AnybillErrorType.genericError,
code: HttpStatus.notFound,
);
}
} catch (error, stacktrace) {
AnybillLogger.error(
error: error,
stacktrace: stacktrace,
library: runtimeType.toString(),
event: "getCachedUserQrCode",
);
return AnybillResult.failure(
type: AnybillErrorType.unknown,
message: error.toString(),
);
}
}