let AI comment everything because well... yeah...
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
// * Service for handling HTTP requests to the backend API
|
||||
// * Features:
|
||||
// * - Support for camera trap and excursion data endpoints
|
||||
// * - Configurable timeouts
|
||||
// * - Error handling
|
||||
// * - JSON data formatting
|
||||
|
||||
import 'dart:convert';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Service class for making HTTP requests to the backend
|
||||
/// Handles both camera trap and excursion data submissions
|
||||
class HttpRequestService {
|
||||
/// Send data to the appropriate backend endpoint
|
||||
/// @param saveDataMap Optional map of data to send
|
||||
/// @param saveDataString Optional string of data to send
|
||||
/// @return Future<int> HTTP status code of the response
|
||||
static Future<int> httpRequest({Map<String, String>? saveDataMap, String? saveDataString}) async {
|
||||
// print(jsonEncode(place));
|
||||
|
||||
@@ -18,6 +31,7 @@ class HttpRequestService {
|
||||
Response(requestOptions: RequestOptions(path: ''), statusCode: 400);
|
||||
|
||||
try {
|
||||
// Choose endpoint based on data type (camera trap vs excursion)
|
||||
if (saveDataMap != null && saveDataMap.containsKey("CID") || saveDataString != null && saveDataString.contains("CID")) {
|
||||
response = await dio.post(prefs.getString('fotofallenApiAddress') ?? "",
|
||||
data: saveDataMap == null ? saveDataString : jsonEncode(saveDataMap));
|
||||
|
||||
Reference in New Issue
Block a user