flutter_kinetra/lib/kt_model/kt_receive_coin_info.dart
2025-10-16 16:34:07 +08:00

177 lines
4.6 KiB
Dart

import 'dart:convert';
/// week_max_total : 10000
/// week_total : 1600
/// receive_coins : 500
/// receive_count : 2
/// receive_list : [{"id":1,"title":"test","week_max_total":2400,"week_total":600,"receive_coins":200,"day_text":"4/13"},{"id":5,"title":"Weekly Subscribe Coin Pack","week_max_total":7600,"week_total":1000,"receive_coins":300,"day_text":"3/23"}]
ReceiveCoinInfo ktReceiveCoinInfoFromJson(String str) => ReceiveCoinInfo.fromJson(json.decode(str));
String ktReceiveCoinInfoToJson(ReceiveCoinInfo data) => json.encode(data.toJson());
class ReceiveCoinInfo {
ReceiveCoinInfo({
int? weekMaxTotal,
int? weekTotal,
int? receiveCoins,
int? receiveCount,
List<ReceiveList>? receiveList,
}) {
_weekMaxTotal = weekMaxTotal;
_weekTotal = weekTotal;
_receiveCoins = receiveCoins;
_receiveCount = receiveCount;
_receiveList = receiveList;
}
ReceiveCoinInfo.fromJson(dynamic json) {
_weekMaxTotal = json['week_max_total'];
_weekTotal = json['week_total'];
_receiveCoins = json['receive_coins'];
_receiveCount = json['receive_count'];
if (json['receive_list'] != null) {
_receiveList = [];
json['receive_list'].forEach((v) {
_receiveList?.add(ReceiveList.fromJson(v));
});
}
}
int? _weekMaxTotal;
int? _weekTotal;
int? _receiveCoins;
int? _receiveCount;
List<ReceiveList>? _receiveList;
ReceiveCoinInfo copyWith({
int? weekMaxTotal,
int? weekTotal,
int? receiveCoins,
int? receiveCount,
List<ReceiveList>? receiveList,
}) => ReceiveCoinInfo(
weekMaxTotal: weekMaxTotal ?? _weekMaxTotal,
weekTotal: weekTotal ?? _weekTotal,
receiveCoins: receiveCoins ?? _receiveCoins,
receiveCount: receiveCount ?? _receiveCount,
receiveList: receiveList ?? _receiveList,
);
int? get weekMaxTotal => _weekMaxTotal;
int? get weekTotal => _weekTotal;
int? get receiveCoins => _receiveCoins;
int? get receiveCount => _receiveCount;
List<ReceiveList>? get receiveList => _receiveList;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['week_max_total'] = _weekMaxTotal;
map['week_total'] = _weekTotal;
map['receive_coins'] = _receiveCoins;
map['receive_count'] = _receiveCount;
if (_receiveList != null) {
map['receive_list'] = _receiveList?.map((v) => v.toJson()).toList();
}
return map;
}
}
/// id : 1
/// title : "test"
/// week_max_total : 2400
/// week_total : 600
/// receive_coins : 200
/// week_remaining_total : 200
/// day_text : "4/13"
ReceiveList receiveListFromJson(String str) => ReceiveList.fromJson(json.decode(str));
String receiveListToJson(ReceiveList data) => json.encode(data.toJson());
class ReceiveList {
ReceiveList({
int? id,
String? title,
int? weekMaxTotal,
int? weekTotal,
int? receiveCoins,
int? weekRemainingTotal,
String? dayText,
}) {
_id = id;
_title = title;
_weekMaxTotal = weekMaxTotal;
_weekTotal = weekTotal;
_receiveCoins = receiveCoins;
_weekRemainingTotal = weekRemainingTotal;
_dayText = dayText;
}
ReceiveList.fromJson(dynamic json) {
_id = json['id'];
_title = json['title'];
_weekMaxTotal = json['week_max_total'];
_weekTotal = json['week_total'];
_receiveCoins = json['receive_coins'];
_weekRemainingTotal = json['week_remaining_total'];
_dayText = json['day_text'];
}
int? _id;
String? _title;
int? _weekMaxTotal;
int? _weekTotal;
int? _receiveCoins;
int? _weekRemainingTotal;
String? _dayText;
ReceiveList copyWith({
int? id,
String? title,
int? weekMaxTotal,
int? weekTotal,
int? receiveCoins,
int? weekRemainingTotal,
String? dayText,
}) => ReceiveList(
id: id ?? _id,
title: title ?? _title,
weekMaxTotal: weekMaxTotal ?? _weekMaxTotal,
weekTotal: weekTotal ?? _weekTotal,
receiveCoins: receiveCoins ?? _receiveCoins,
weekRemainingTotal: weekRemainingTotal ?? _weekRemainingTotal,
dayText: dayText ?? _dayText,
);
int? get id => _id;
String? get title => _title;
int? get weekMaxTotal => _weekMaxTotal;
int? get weekTotal => _weekTotal;
int? get receiveCoins => _receiveCoins;
int? get weekRemainingTotal => _weekRemainingTotal;
String? get dayText => _dayText;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['id'] = _id;
map['title'] = _title;
map['week_max_total'] = _weekMaxTotal;
map['week_total'] = _weekTotal;
map['receive_coins'] = _receiveCoins;
map['week_remaining_total'] = _weekRemainingTotal;
map['day_text'] = _dayText;
return map;
}
}