class ExchangeContentModel {
  List<ExChangeContent> contents;
  int lastPage;

  ExchangeContentModel({required this.contents, required this.lastPage});

  factory ExchangeContentModel.fromJson(Map<String, dynamic> json) {
    return ExchangeContentModel(
      contents: List<ExChangeContent>.from(
          json['contents'].map((x) => ExChangeContent.fromJson(x))),
      lastPage: json['lastPage'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'contents': List<dynamic>.from(contents.map((x) => x.toJson())),
      'lastPage': lastPage,
    };
  }
}

class ExChangeContent {
  final int id;
  final String label;
  final String title;
  final int type;
  final bool marked;
  final dynamic data;

  ExChangeContent({
    required this.id,
    required this.label,
    required this.title,
    required this.type,
    required this.marked,
    required this.data,
  });

  factory ExChangeContent.fromJson(Map<String, dynamic> json) {
    return ExChangeContent(
      id: json['id'],
      label: json['label'],
      title: json['title'],
      type: json['type'],
      marked: json['marked'],
      data: json['data'] is List
          ? List<Data>.from(json['data'].map((data) => Data.fromJson(data)))
          : Data.fromJson(json['data']),
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'label': label,
      'title': title,
      'type': type,
      'marked': marked,
      'data': data is List
          ? data.map((dataItem) => dataItem.toJson()).toList()
          : data.toJson(),
    };
  }
}

class Data {
  final String? name;
  final dynamic q;
  final dynamic v;
  final dynamic p;
  final dynamic l;
  final dynamic y;
  final String? h;
  final String? d;
  final dynamic dp;
  final String? dt;
  final String? t;
  final String? tEn;
  final String? tG;
  final String? ts;
  final dynamic dl;
  final String? dtp;
  final String? dtl;

  Data(
      {this.name,
      this.q,
      this.v,
      this.p,
      this.h,
      this.l,
      this.y,
      this.d,
      this.dp,
      this.dt,
      this.t,
      this.tEn,
      this.tG,
      this.ts,
      this.dl,
      this.dtp,
      this.dtl});

  factory Data.fromJson(Map<String, dynamic> json) {
    return Data(
      name: json['name'],
      q: json['q'],
      v: json['v'],
      p: json['p'],
      y: json['y'],
      h: json['h'],
      l: json['l'],
      d: json['d'],
      dp: json['dp'],
      dt: json['dt'],
      t: json['t'],
      tEn: json['t_en'],
      tG: json['t-g'],
      ts: json['ts'],
      dl: json['dl'],
      dtp: json['dtp'],
      dtl: json['dtl'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'name': name,
      'q': q,
      'v': v,
      'p': p,
      'h': h,
      'l': l,
      'y': y,
      'd': d,
      'dp': dp,
      'dt': dt,
      't': t,
      't_en': tEn,
      't-g': tG,
      'ts': ts,
      'dl': dl,
      'dtp': dtp,
      'dtl': dtl,
    };
  }
}
