App móvil Flutter para capturar contenido multimedia, etiquetarlo con hashes y enviarlo a backends configurables. Features: - Captura de fotos, audio, video y archivos - Sistema de etiquetas con bibliotecas externas (HST) - Packs de etiquetas predefinidos - Cola de reintentos (hasta 20 contenedores) - Soporte GPS - Hash SHA-256 auto-generado por contenedor - Persistencia SQLite local - Múltiples destinos configurables Stack: Flutter 3.38.5, flutter_bloc, sqflite, dio 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
1.4 KiB
Dart
43 lines
1.4 KiB
Dart
import 'package:dio/dio.dart';
|
|
import '../../core/constants/app_constants.dart';
|
|
import '../../core/errors/exceptions.dart';
|
|
import '../../domain/entities/biblioteca.dart';
|
|
import '../../domain/entities/etiqueta.dart';
|
|
|
|
class BibliotecaApi {
|
|
final Dio _dio;
|
|
|
|
BibliotecaApi() : _dio = Dio() {
|
|
_dio.options.connectTimeout = AppConstants.httpTimeout;
|
|
_dio.options.receiveTimeout = AppConstants.httpTimeout;
|
|
}
|
|
|
|
Future<List<Etiqueta>> fetchEtiquetas(Biblioteca biblioteca) async {
|
|
try {
|
|
final response = await _dio.get(biblioteca.fullUrl);
|
|
final data = response.data as Map<String, dynamic>;
|
|
final results = data['results'] as List<dynamic>;
|
|
return results
|
|
.map((e) => Etiqueta.fromJson(e as Map<String, dynamic>))
|
|
.toList();
|
|
} on DioException catch (e) {
|
|
throw NetworkException(e.message ?? 'Failed to fetch etiquetas');
|
|
}
|
|
}
|
|
|
|
Future<Etiqueta?> resolveHash(String hash, Biblioteca biblioteca) async {
|
|
try {
|
|
final response = await _dio.get(
|
|
biblioteca.fullUrl,
|
|
queryParameters: {'hash': hash},
|
|
);
|
|
final data = response.data as Map<String, dynamic>;
|
|
final results = data['results'] as List<dynamic>;
|
|
if (results.isEmpty) return null;
|
|
return Etiqueta.fromJson(results.first as Map<String, dynamic>);
|
|
} on DioException {
|
|
return null;
|
|
}
|
|
}
|
|
}
|