// invite_api.dart — 邀请/奖励任务代理端点封装(JWT 经 ApiClient 自动注入)。 import 'api_client.dart'; class InviteInfo { const InviteInfo({ required this.code, required this.link, required this.invited, required this.converted, required this.earnedDays, required this.tgEnabled, required this.tgJoined, required this.channel, }); final String code, link, channel; final int invited, converted, earnedDays; final bool tgEnabled, tgJoined; factory InviteInfo.fromJson(Map j) { final tg = (j['telegram'] as Map?) ?? const {}; return InviteInfo( code: j['invite_code'] as String? ?? '', link: j['invite_link'] as String? ?? '', invited: (j['invited'] as num?)?.toInt() ?? 0, converted: (j['converted'] as num?)?.toInt() ?? 0, earnedDays: (j['earned_days'] as num?)?.toInt() ?? 0, tgEnabled: tg['enabled'] as bool? ?? false, tgJoined: tg['joined'] as bool? ?? false, channel: tg['channel'] as String? ?? '', ); } } class InviteApi { InviteApi(this._c); final ApiClient _c; Future fetch() async => InviteInfo.fromJson(await _c.getJson('/v1/invite')); Future telegramStartLink() async => (await _c.getJson('/v1/tasks/telegram/start'))['deep_link'] as String? ?? ''; }