58 lines
1.8 KiB
Dart
58 lines
1.8 KiB
Dart
class RequestHelper {
|
|
static const String _baseUrl = 'https://didvan-greatsam.fandogh.cloud';
|
|
static const String _baseUserUrl = _baseUrl + '/user';
|
|
|
|
static const String confirmUsername = _baseUserUrl + '/confirmUsername';
|
|
static const String login = _baseUserUrl + '/login';
|
|
static const String directs = _baseUserUrl + '/direct';
|
|
static const String userInfo = _baseUserUrl + '/info';
|
|
static const String updateUserProfile = _baseUserUrl + '/profile/photo';
|
|
static const String updateUsername = _baseUserUrl + '/setUsername';
|
|
|
|
static const String radarCategories = _baseUrl + '/category';
|
|
|
|
static String direct(int id) => _baseUserUrl + '/direct/$id';
|
|
static String getRadarOverviews({
|
|
required int page,
|
|
List<int> categories = const [],
|
|
String? startDate,
|
|
String? endDate,
|
|
String? search,
|
|
}) {
|
|
String? cats;
|
|
if (categories.isNotEmpty) {
|
|
cats = '';
|
|
for (var i = 0; i < categories.length; i++) {
|
|
cats = cats! + categories[i].toString();
|
|
if (i != categories.length - 1) {
|
|
cats += ',';
|
|
}
|
|
}
|
|
}
|
|
return _baseUrl +
|
|
'/radar' +
|
|
_urlConcatGenerator([
|
|
MapEntry('page', page.toString()),
|
|
MapEntry('start', startDate),
|
|
MapEntry('end', endDate),
|
|
MapEntry('search', search),
|
|
MapEntry('categories', cats),
|
|
]);
|
|
}
|
|
|
|
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 - 1) {
|
|
result += '&';
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|