/// YApi QuickType插件生成，具体参考文档:https://plugins.jetbrains.com/plugin/18847-yapi-quicktype/documentation

import 'dart:convert';

import 'package:widgets/load_state_layout.dart';

class RewardsListState {
  //页面 LoadView 状态的展示
  LoadState loadingState;
  String? errorMessage;
  String? sort_by = '';
  String? sort = '';
  String? category_name = 'All';
  int? page;
  int? limit = 10;
  int? count = 1;
  int? category_id = 0;
  int? point_min = 0;
  int? point_max = 0;
  List<Map<String, dynamic>>? list;
  List<Map<String, dynamic>>? categoryList;

  RewardsListState({
    this.loadingState = LoadState.State_Loading,
    String? errorMessage,
    this.sort_by = '',
    this.sort = '',
    this.category_name = 'All',
    this.page = 1,
    this.limit = 10,
    this.count = 1,
    this.category_id = 0,
    this.point_min = 0,
    this.point_max = 0,
    required this.list,
    required this.categoryList,
  });

  RewardsListState copyWith({
    LoadState? loadingState,
    String? errorMessage,
    String? category_name,
    String? sort_by,
    String? sort,
    int? page,
    int? limit,
    int? count,
    int? category_id,
    int? point_min,
    int? point_max,
    List<Map<String, dynamic>>? list,
    List<Map<String, dynamic>>? categoryList,
  }) {
    return RewardsListState(
      loadingState: loadingState ?? this.loadingState,
      errorMessage: errorMessage ?? this.errorMessage,
      category_name: category_name ?? this.category_name,
      sort_by: sort_by ?? this.sort_by,
      sort: sort ?? this.sort,
      page: page ?? this.page,
      limit: limit ?? this.limit,
      count: count ?? this.count,
      category_id: category_id ?? this.category_id,
      point_min: point_min ?? this.point_min,
      point_max: point_max ?? this.point_max,
      list: list ?? this.list,
      categoryList: list ?? this.categoryList,
    );
  }

  Map<String, dynamic> toMap() {
    return {
      'page': this.page,
      'limit': this.limit,
      'count': this.count,
      'category_id': this.category_id,
      'point_min': this.point_min,
      'point_max': this.point_max,
      'list': this.list,
      'categoryList': this.categoryList,
    };
  }

  factory RewardsListState.fromMap(Map<String, dynamic> map) {
    return RewardsListState(
      page: map['page'] as int,
      limit: map['limit'] as int,
      count: map['count'] as int,
      category_id: map['category_id'] as int,
      point_min: map['point_min'] as int,
      point_max: map['point_max'] as int,
      list: map['list'] as List<Map<String, dynamic>>,
      categoryList: map['categoryList'] as List<Map<String, dynamic>>,
    );
  }
}
