36 lines
1.3 KiB
Dart
36 lines
1.3 KiB
Dart
// 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<String, dynamic> j) {
|
|
final tg = (j['telegram'] as Map<String, dynamic>?) ?? 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<InviteInfo> fetch() async => InviteInfo.fromJson(await _c.getJson('/v1/invite'));
|
|
Future<String> telegramStartLink() async =>
|
|
(await _c.getJson('/v1/tasks/telegram/start'))['deep_link'] as String? ?? '';
|
|
}
|