37 lines
1.1 KiB
Dart
37 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
class EControlService {
|
|
Future<List<dynamic>> getEControlData(
|
|
double latitude,
|
|
double longitude,
|
|
String fuelType,
|
|
) async {
|
|
// For Test purposes only - later deactivate
|
|
// latitude = 47.938783246743355;
|
|
// longitude = 13.762770926423814;
|
|
String apiUrl = 'https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=$latitude&longitude=$longitude&fuelType=$fuelType&includeClosed=false';
|
|
var response = await http.get(Uri.parse(apiUrl));
|
|
if (response.statusCode == 200) {
|
|
return jsonDecode(response.body);
|
|
}
|
|
return [];
|
|
}
|
|
|
|
/// Holt parallel Diesel ('DIE') und Super ('SUP') Daten
|
|
Future<Map<String, List<dynamic>>> getBothFuelData(
|
|
double latitude,
|
|
double longitude,
|
|
) async {
|
|
// For Test purposes only - later deactivate
|
|
// latitude = 47.938783246743355;
|
|
// longitude = 13.762770926423814;
|
|
final results = await Future.wait([
|
|
getEControlData(latitude, longitude, 'DIE'),
|
|
getEControlData(latitude, longitude, 'SUP'),
|
|
]);
|
|
|
|
return {'DIE': results[0], 'SUP': results[1]};
|
|
}
|
|
}
|