-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathlsky_api.dart
51 lines (46 loc) · 1.45 KB
/
lsky_api.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import 'package:dio/dio.dart';
import 'package:flutter_picgo/utils/net.dart';
import 'package:path/path.dart' as path;
class LskyApi {
static Future token(String email, String pwd, String host) async {
String url = path.joinAll([host, 'api/token']);
Response res = await NetUtils.getInstance().post(url, data: {
'email': email,
'password': pwd,
});
return res.data;
}
static Future upload(String token, String host, FormData data) async {
String url = path.joinAll([host, 'api/upload']);
Response res = await NetUtils.getInstance()
.post(url, data: data, options: buildCommonOptions(token));
return res.data;
}
static Future images(String token, String host, int page,
{int rows = 10}) async {
String url = path.joinAll([host, 'api/images']);
Response res = await NetUtils.getInstance().post(
url,
data: {
'page': page,
'rows': rows,
},
options: buildCommonOptions(token),
);
return res.data;
}
static Future delete(String token, String host, String id) async {
String url = path.joinAll([host, 'api/delete']);
Response res = await NetUtils.getInstance().post(url,
data: {
'id': id,
},
options: buildCommonOptions(token));
return res.data;
}
static Options buildCommonOptions(String token) {
return Options(headers: {
'token': token,
}, contentType: Headers.formUrlEncodedContentType);
}
}