import '../api_client.dart'; import '../api_config.dart'; import '../proxy_client.dart'; /// 用户相关 API abstract final class UserApi { static final _client = ApiClient.instance.proxy; /// 设备快速登录 /// 参数使用 V2 字段名:digest=referer, resolution=sign, origin=deviceId static Future fastLogin({ required String origin, required String resolution, String? digest, String? crest, String? accolade, }) async { return _client.request( path: '/v1/user/fast_login', method: 'POST', queryParams: { // if (crest != null) 'crest': crest, "sentinel": "HAndroid", 'portal': ApiConfig.packageName, if (accolade != null) 'accolade': accolade, }, body: { 'digest': digest ?? '', 'resolution': resolution, 'origin': origin, }, ); } /// 归因上报(登录成功后调用,digest 建议从 Adjust 获取,暂无则用 install referrer) static Future referrer({ required String sentinel, required String asset, required String digest, required String origin, String? accolade, String? portal, }) async { return _client.request( path: '/v1/user/referrer', method: 'POST', queryParams: { 'sentinel': sentinel, 'asset': asset, if (accolade != null) 'accolade': accolade, 'portal': portal ?? ApiConfig.packageName, }, body: { 'digest': digest, 'origin': origin, }, ); } /// 获取用户通用信息 static Future getCommonInfo({ required String sentinel, String? shield, String? asset, String? crest, String? item, String? origin, String? gauntlet, String? portal, }) async { return _client.request( path: '/v1/user/common_info', method: 'GET', queryParams: { 'sentinel': sentinel, if (shield != null) 'shield': shield, if (asset != null) 'asset': asset, if (crest != null) 'crest': crest, if (item != null) 'item': item, if (origin != null) 'origin': origin, if (gauntlet != null) 'gauntlet': gauntlet, if (portal != null) 'portal': portal, }, ); } /// 获取用户账户信息 static Future getAccount({ required String sentinel, String? asset, }) async { return _client.request( path: '/v1/user/account', method: 'GET', queryParams: { 'sentinel': sentinel, if (asset != null) 'asset': asset, }, ); } /// 删除账号 static Future deleteAccount({ required String sentinel, String? asset, }) async { return _client.request( path: '/v1/user/delete', method: 'GET', queryParams: { 'sentinel': sentinel, if (asset != null) 'asset': asset, }, ); } }