feat: add HelpText model, service, and controller for dynamic help text management
This commit is contained in:
@@ -7,6 +7,7 @@ import 'dart:developer' as developer;
|
||||
|
||||
import '../../../core/api/api_paths.dart';
|
||||
import '../../../core/api/api_exception.dart';
|
||||
import '../domain/help_text_content.dart';
|
||||
import '../domain/quick_import_result.dart';
|
||||
|
||||
/// Handles communication with the quick-import API endpoint.
|
||||
@@ -25,6 +26,38 @@ class ImportRepository {
|
||||
defaultValue: '/api',
|
||||
);
|
||||
|
||||
Future<HelpTextContent> fetchHelpTextByKey(
|
||||
String key, {
|
||||
String? token,
|
||||
}) async {
|
||||
final uri = Uri.parse('$_baseUrl${HelpTextApiPaths.byKey(key)}');
|
||||
final response = await _client.get(
|
||||
uri,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
if (token != null) 'Authorization': 'Bearer $token',
|
||||
},
|
||||
);
|
||||
|
||||
if (response.statusCode < 200 || response.statusCode >= 300) {
|
||||
throw ApiException(
|
||||
type: _mapStatusCodeToErrorType(response.statusCode),
|
||||
message: 'Kunde inte hämta hjälptext: ${response.body}',
|
||||
statusCode: response.statusCode,
|
||||
);
|
||||
}
|
||||
|
||||
final parsed = _parseResponse(response);
|
||||
if (parsed is! Map<String, dynamic>) {
|
||||
throw ApiException(
|
||||
type: ApiErrorType.unknown,
|
||||
message: 'Felaktigt svar vid hämtning av hjälptext.',
|
||||
);
|
||||
}
|
||||
|
||||
return HelpTextContent.fromJson(parsed);
|
||||
}
|
||||
|
||||
/// Upload a receipt file for parsing (Fas 6b).
|
||||
/// Returns a list of parsed receipt items.
|
||||
Future<List<ParsedReceiptItem>> importReceiptFile({
|
||||
|
||||
Reference in New Issue
Block a user