You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
Dart
46 lines
1.2 KiB
Dart
import 'package:isekai_wiki/api/response/userinfo.dart';
|
|
|
|
import '../response/mugenapp.dart';
|
|
import 'mw_api.dart';
|
|
|
|
class MWApiUser {
|
|
static Future<MWResponse<MugenAppStartAuthInfo>> startAuth() async {
|
|
var query = {
|
|
"method": "startauth",
|
|
};
|
|
|
|
var mwRes = await MWApi.get("mugenapp", query: query);
|
|
|
|
var data = MugenAppStartAuthResponse.fromJson(mwRes.data);
|
|
|
|
return mwRes.replaceData(data.startauth);
|
|
}
|
|
|
|
static Future<MWResponse<MugenAppAttemptAuthInfo>> attemptAuth(
|
|
String loginRequestKey) async {
|
|
var query = {
|
|
"method": "attemptauth",
|
|
"requestkey": loginRequestKey,
|
|
};
|
|
|
|
var mwRes = await MWApi.get("mugenapp", query: query);
|
|
|
|
var data = MugenAppAttemptAuthResponse.fromJson(mwRes.data);
|
|
|
|
return mwRes.replaceData(data.attemptauth);
|
|
}
|
|
|
|
static Future<MWResponse<MetaUserInfoResponse>> getCurrentUserInfo() async {
|
|
var query = {
|
|
"meta": "userinfo|useravatar",
|
|
"uiprop": "blockinfo|groups|rights|options|email|realname|latestcontrib",
|
|
};
|
|
|
|
var mwRes = await MWApi.get("query", query: query);
|
|
|
|
var data = MetaUserInfoResponse.fromJson(mwRes.data);
|
|
|
|
return mwRes.replaceData(data);
|
|
}
|
|
}
|