import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:flutter/foundation.dart';

import '../channelplan/channel_plan_list.dart';
part 'user.freezed.dart';
part 'user.g.dart';

@freezed
class User with _$User {
  const factory User({
    String? country,
    String? countryName,
    String? userIp,
    String? accessToken,
    String? refreshToken,
    String? accountKey,
    String? accountPassword,
    int? createTime, // API 返回 int 类型的时间戳
    bool? geographyEea,
    int? memberLevel, // 1设备用户 2注册用户
    int? userLevel, // 1试用 2免费 3会员 9999内部
    int? expireTime, // VIP套餐到期时间
    int? remainTime, // VIP套餐剩余时间
    bool? isExpired, // VIP套餐是否过期
    bool? isTestUser, // 是否是测试用户
    bool? isSubscribeUser, // 是否是连续订阅用户
    Account? account,
    //isSubscribeUser=false 时返回最后一次购买套餐信息
    //isSubscribeUser=true 时返回当前订阅套餐信息
    ChannelPlan? planInfo, // userLevel=3时生效
    bool? activated, // 是否激活
  }) = _User;

  factory User.fromJson(Map<String, Object?> json) => _$UserFromJson(json);
}

@freezed
class Account with _$Account {
  const factory Account({
    String? username,
    String? phone,
    String? email,
    String? wechat,
    String? qq,
    String? google,
    String? apple,
  }) = _Account;

  factory Account.fromJson(Map<String, Object?> json) =>
      _$AccountFromJson(json);
}
