overfast_api/lib/client.dart
2024-05-07 00:14:45 +02:00

41 lines
865 B
Dart

import 'package:http/http.dart' as http;
import 'package:overfast_api/heroes/heroes.dart';
import 'package:overfast_api/players/players.dart';
import './utils/utils.dart' as utils;
import 'maps/maps.dart';
class Overfast {
final Uri baseUri;
late final Future<T> Function<T>(
String, [
Map<String, dynamic>,
]) get;
late final Future<List<T>> Function<T>(
String, [
Map<String, dynamic>,
]) getList;
final client = http.Client();
late final Maps maps;
late final Players players;
late final Heroes heroes;
Overfast([Uri? baseUri])
: baseUri = baseUri ?? Uri.https('overfast-api.tekrop.fr') {
get = utils.get(client, this.baseUri);
getList = utils.getList(client, this.baseUri);
maps = Maps(this);
players = Players(this);
heroes = Heroes(this);
}
void close() {
client.close();
}
}