user_auth_repository.dart
1.88 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import 'dart:io';
import 'package:appframe/config/locator.dart';
import 'package:appframe/services/api_service.dart';
import 'package:dio/dio.dart';
class UserAuthRepository {
late final ApiService _appService;
UserAuthRepository() {
_appService = getIt<ApiService>(instanceName: 'appApiService');
}
///
/// {
/// "code": 0,
/// "error": "操作成功"
/// }
///
Future<dynamic> updateUser(String userid, String name, String nickName, String avatar) async {
Response resp = await _appService.post(
'/api/v1/comm/user/update',
{
"userid": userid,
"name": name,
"nickName": nickName,
"avatar": avatar,
},
);
return resp.statusCode == HttpStatus.ok ? resp.data : null;
}
Future<dynamic> appleLogin(String userid, String authorizationCode, String identityToken) async {
Response resp = await _appService.post(
'/api/v1/comm/user/applelogin',
{
"user": userid,
"authorizationCode": authorizationCode,
"identityToken": identityToken,
},
);
return resp.statusCode == HttpStatus.ok ? resp.data : null;
}
///
/// {
/// "code": 1,
/// "data":"bxe userid" // 存在会返回
/// "error": "",
/// }
Future<dynamic> exchangeId(String userid) async {
Response resp = await _appService.post(
'/api/v1/comm/user/exchangeid',
{
"userId": userid,
"type": "apple",
},
);
return resp.statusCode == HttpStatus.ok ? resp.data : null;
}
///
/// {
/// "error": "",
/// "code": 0,
/// }
Future<dynamic> newBinding(String userid, String bxeUserId) async {
Response resp = await _appService.post(
'/api/v1/comm/user/newbinding',
{
"userId": userid,
"bxeUserId": userid,
"type": "apple",
},
);
return resp.statusCode == HttpStatus.ok ? resp.data : null;
}
}