D1APP-22 new url & update token storing
This commit is contained in:
parent
fdff9669a6
commit
1c0faf0db5
|
|
@ -6,7 +6,7 @@ import 'package:http/http.dart' as http;
|
||||||
class RequestService {
|
class RequestService {
|
||||||
static late String _token;
|
static late String _token;
|
||||||
|
|
||||||
static set token(value) => _token = value;
|
static set token(String value) => _token = value;
|
||||||
|
|
||||||
Map get result => _body['result'] ?? const {};
|
Map get result => _body['result'] ?? const {};
|
||||||
Map get errors => _body['errors'] ?? const {};
|
Map get errors => _body['errors'] ?? const {};
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,36 @@ class RequestHelper {
|
||||||
|
|
||||||
static const String confirmUsername = _baseUrl + '/user/confirmUsername';
|
static const String confirmUsername = _baseUrl + '/user/confirmUsername';
|
||||||
static const String login = _baseUrl + '/user/login';
|
static const String login = _baseUrl + '/user/login';
|
||||||
|
|
||||||
|
static String getRadarOverviews({
|
||||||
|
required int page,
|
||||||
|
int? radarId,
|
||||||
|
String? startDate,
|
||||||
|
String? endDate,
|
||||||
|
String? search,
|
||||||
|
}) =>
|
||||||
|
_baseUrl +
|
||||||
|
'/radar' +
|
||||||
|
_urlConcatGenerator([
|
||||||
|
MapEntry('page', page.toString()),
|
||||||
|
MapEntry('start', startDate),
|
||||||
|
MapEntry('end', endDate),
|
||||||
|
MapEntry('search', search),
|
||||||
|
MapEntry('radar', radarId?.toString()),
|
||||||
|
]);
|
||||||
|
|
||||||
|
static String _urlConcatGenerator(List<MapEntry<String, String?>> additions) {
|
||||||
|
String result = '';
|
||||||
|
additions.removeWhere((element) => element.value == null);
|
||||||
|
if (additions.isNotEmpty) {
|
||||||
|
result += '?';
|
||||||
|
for (var i = 0; i < additions.length; i++) {
|
||||||
|
result += (additions[i].key + additions[i].value!);
|
||||||
|
if (i != additions.length) {
|
||||||
|
result += '&';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue