123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import 'package:domain/generated/json/base/json_convert_content.dart';
- import 'package:domain/entity/rewards_home_entity.dart';
- RewardsHomeEntity $RewardsHomeEntityFromJson(Map<String, dynamic> json) {
- final RewardsHomeEntity rewardsHomeEntity = RewardsHomeEntity();
- final List<RewardsHomeData>? data = (json['data'] as List<dynamic>?)
- ?.map(
- (e) => jsonConvert.convert<RewardsHomeData>(e) as RewardsHomeData)
- .toList();
- if (data != null) {
- rewardsHomeEntity.data = data;
- }
- final String? message = jsonConvert.convert<String>(json['message']);
- if (message != null) {
- rewardsHomeEntity.message = message;
- }
- final int? code = jsonConvert.convert<int>(json['code']);
- if (code != null) {
- rewardsHomeEntity.code = code;
- }
- return rewardsHomeEntity;
- }
- Map<String, dynamic> $RewardsHomeEntityToJson(RewardsHomeEntity entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['data'] = entity.data.map((v) => v.toJson()).toList();
- data['message'] = entity.message;
- data['code'] = entity.code;
- return data;
- }
- extension RewardsHomeEntityExtension on RewardsHomeEntity {
- RewardsHomeEntity copyWith({
- List<RewardsHomeData>? data,
- String? message,
- int? code,
- }) {
- return RewardsHomeEntity()
- ..data = data ?? this.data
- ..message = message ?? this.message
- ..code = code ?? this.code;
- }
- }
- RewardsHomeData $RewardsHomeDataFromJson(Map<String, dynamic> json) {
- final RewardsHomeData rewardsHomeData = RewardsHomeData();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- rewardsHomeData.id = id;
- }
- final String? name = jsonConvert.convert<String>(json['name']);
- if (name != null) {
- rewardsHomeData.name = name;
- }
- final List<RewardsHomeDataRewards>? rewards = (json['rewards'] as List<
- dynamic>?)
- ?.map(
- (e) =>
- jsonConvert.convert<RewardsHomeDataRewards>(e) as RewardsHomeDataRewards)
- .toList();
- if (rewards != null) {
- rewardsHomeData.rewards = rewards;
- }
- return rewardsHomeData;
- }
- Map<String, dynamic> $RewardsHomeDataToJson(RewardsHomeData entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['name'] = entity.name;
- data['rewards'] = entity.rewards.map((v) => v.toJson()).toList();
- return data;
- }
- extension RewardsHomeDataExtension on RewardsHomeData {
- RewardsHomeData copyWith({
- int? id,
- String? name,
- List<RewardsHomeDataRewards>? rewards,
- }) {
- return RewardsHomeData()
- ..id = id ?? this.id
- ..name = name ?? this.name
- ..rewards = rewards ?? this.rewards;
- }
- }
- RewardsHomeDataRewards $RewardsHomeDataRewardsFromJson(
- Map<String, dynamic> json) {
- final RewardsHomeDataRewards rewardsHomeDataRewards = RewardsHomeDataRewards();
- final int? id = jsonConvert.convert<int>(json['id']);
- if (id != null) {
- rewardsHomeDataRewards.id = id;
- }
- final String? name = jsonConvert.convert<String>(json['name']);
- if (name != null) {
- rewardsHomeDataRewards.name = name;
- }
- final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
- (e) => jsonConvert.convert<String>(e) as String).toList();
- if (resources != null) {
- rewardsHomeDataRewards.resources = resources;
- }
- final int? originalPoint = jsonConvert.convert<int>(json['original_point']);
- if (originalPoint != null) {
- rewardsHomeDataRewards.originalPoint = originalPoint;
- }
- final int? point = jsonConvert.convert<int>(json['point']);
- if (point != null) {
- rewardsHomeDataRewards.point = point;
- }
- return rewardsHomeDataRewards;
- }
- Map<String, dynamic> $RewardsHomeDataRewardsToJson(
- RewardsHomeDataRewards entity) {
- final Map<String, dynamic> data = <String, dynamic>{};
- data['id'] = entity.id;
- data['name'] = entity.name;
- data['resources'] = entity.resources;
- data['original_point'] = entity.originalPoint;
- data['point'] = entity.point;
- return data;
- }
- extension RewardsHomeDataRewardsExtension on RewardsHomeDataRewards {
- RewardsHomeDataRewards copyWith({
- int? id,
- String? name,
- List<String>? resources,
- int? originalPoint,
- int? point,
- }) {
- return RewardsHomeDataRewards()
- ..id = id ?? this.id
- ..name = name ?? this.name
- ..resources = resources ?? this.resources
- ..originalPoint = originalPoint ?? this.originalPoint
- ..point = point ?? this.point;
- }
- }
|