import 'Standing.dart';
import 'ToneLevel.dart';

class UserDetails {
  String pic;

  String name;

  String timezone;

  ToneLevel tone;

  Standing standing;

  double debtScore;

  int amnestyTokens;

  bool sickMode;

  UserDetails({
    required this.pic,
    required this.name,
    this.timezone = "Africa/Nairobi",
    this.tone = ToneLevel.Strict,
    this.standing = Standing.Good,
    this.debtScore = 0,
    this.amnestyTokens = 0,
    this.sickMode = false,
  });

  factory UserDetails.fromJson(Map<String, dynamic> json) {
    return UserDetails(
      pic: json['pic'] ?? "",
      name: json['name'] ?? "",
      timezone: json['timezone'] ?? "Africa/Nairobi",
      tone: getToneLevel(json['tone']),
      standing: getStanding(json['standing']),
      debtScore: (json['debtScore'] ?? 0).toDouble(),
      amnestyTokens: json['amnestyTokens'] ?? 0,
      sickMode: json['sickMode'] ?? false,
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['pic'] = pic;
    data['name'] = name;
    data['timezone'] = timezone;
    data['tone'] = tone.name;
    data['standing'] = standing.name;
    data['debtScore'] = debtScore;
    data['amnestyTokens'] = amnestyTokens;
    data['sickMode'] = sickMode;
    return data;
  }
}
