42 lines
1.1 KiB
Dart
42 lines
1.1 KiB
Dart
import 'dart:convert';
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
class DestinationService{
|
|
|
|
static Future<List<dynamic>> getDestinations(int user_id) async {
|
|
List<dynamic> cats = [];
|
|
String url = "http://localhost:8100/api/destinations/?user_id=${user_id}";
|
|
final http.Response response = await http.get(
|
|
Uri.parse(url),
|
|
headers: <String, String>{
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
}
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
cats = json.decode(utf8.decode(response.bodyBytes));
|
|
}
|
|
return cats;
|
|
}
|
|
|
|
static Future<int> updateOrder(int action_id, int order, String dir) async {
|
|
int cats = 0;
|
|
String url = "http://localhost:8100/api/updateorder/?user_action_id=${action_id}&order=${order}&dir=${dir}";
|
|
final http.Response response = await http.get(
|
|
Uri.parse(url),
|
|
headers: <String, String>{
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
|
}
|
|
);
|
|
|
|
if (response.statusCode == 200) {
|
|
cats = json.decode(utf8.decode(response.bodyBytes));
|
|
}
|
|
return cats;
|
|
}
|
|
|
|
|
|
}
|
|
|