import 'dart:convert';

class TurnChainStyleModel {
  String appLogo;
  String commission;
  String provider;
  String providerName;
  String coupon;
  String totalSave;

  // String style;
  Style style;

  TurnChainStyleModel({
    this.appLogo,
    this.commission,
    this.provider,
    this.providerName,
    this.coupon,
    this.totalSave,
    this.style,
  });

  TurnChainStyleModel.fromJson(Map<String, dynamic> json) {
    appLogo = json['app_logo'];
    commission = json['commission'];
    provider = json['provider'];
    providerName = json['provider_name'];
    coupon = json['coupon'];
    totalSave = json['total_save'];
    if (null != json['style']) {
      style = json['style'] is String ? Style.fromJson(jsonDecode(json['style'])) : Style.fromJson(json['style']);
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['app_logo'] = this.appLogo;
    data['commission'] = this.commission;
    data['provider'] = this.provider;
    data['provider_name'] = this.providerName;
    data['coupon'] = this.coupon;
    data['total_save'] = this.totalSave;
    // data['style'] = this.style;
    if (null != this.style) {
      data['style'] = style.toJson();
    }
    return data;
  }
}

class Style {
  String pointColor;
  String point2Color;
  String point3Color;
  String text;
  String textColor;
  String leftBtnType;
  String leftBtnText;
  String leftBtnTextColor;
  String leftBtnColor;
  String leftBtnImg;
  String rightBtnType;
  String rightBtnText;
  String rightBtnTextColor;
  String rightBtnColor;
  String rightBtnImg;
  String saveMomenyText;
  String saveMomenyColor;
  String tipText;
  String tipColor;
  List<ProviderIcons> providerIcons;

  Style(
      {this.pointColor,
      this.point2Color,
      this.point3Color,
      this.text,
      this.textColor,
      this.leftBtnType,
      this.leftBtnText,
      this.leftBtnTextColor,
      this.leftBtnColor,
      this.leftBtnImg,
      this.rightBtnType,
      this.rightBtnText,
      this.rightBtnTextColor,
      this.rightBtnColor,
      this.rightBtnImg,
      this.saveMomenyText,
      this.saveMomenyColor,
      this.tipText,
      this.tipColor,
      this.providerIcons});

  Style.fromJson(Map<String, dynamic> json) {
    pointColor = json['point_color'];
    point2Color = json['point2_color'];
    point3Color = json['point3_color'];
    text = json['text'];
    textColor = json['text_color'];
    leftBtnType = json['left_btn_type'];
    leftBtnText = json['left_btn_text'];
    leftBtnTextColor = json['left_btn_text_color'];
    leftBtnColor = json['left_btn_color'];
    leftBtnImg = json['left_btn_img'];
    rightBtnType = json['right_btn_type'];
    rightBtnText = json['right_btn_text'];
    rightBtnTextColor = json['right_btn_text_color'];
    rightBtnColor = json['right_btn_color'];
    rightBtnImg = json['right_btn_img'];
    saveMomenyText = json['save_momeny_text'];
    saveMomenyColor = json['save_momeny_color'];
    tipText = json['tip_text'];
    tipColor = json['tip_color'];
    if (json['provider_icons'] != null) {
      providerIcons = new List<ProviderIcons>();
      json['provider_icons'].forEach((v) {
        providerIcons.add(new ProviderIcons.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['point_color'] = this.pointColor;
    data['point2_color'] = this.point2Color;
    data['point3_color'] = this.point3Color;
    data['text'] = this.text;
    data['text_color'] = this.textColor;
    data['left_btn_type'] = this.leftBtnType;
    data['left_btn_text'] = this.leftBtnText;
    data['left_btn_text_color'] = this.leftBtnTextColor;
    data['left_btn_color'] = this.leftBtnColor;
    data['left_btn_img'] = this.leftBtnImg;
    data['right_btn_type'] = this.rightBtnType;
    data['right_btn_text'] = this.rightBtnText;
    data['right_btn_text_color'] = this.rightBtnTextColor;
    data['right_btn_color'] = this.rightBtnColor;
    data['right_btn_img'] = this.rightBtnImg;
    data['save_momeny_text'] = this.saveMomenyText;
    data['save_momeny_color'] = this.saveMomenyColor;
    data['tip_text'] = this.tipText;
    data['tip_color'] = this.tipColor;
    if (this.providerIcons != null) {
      data['provider_icons'] = this.providerIcons.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class ProviderIcons {
  String type;
  String name;
  String img;

  ProviderIcons({this.type, this.name, this.img});

  ProviderIcons.fromJson(Map<String, dynamic> json) {
    type = json['type'];
    name = json['name'];
    img = json['img'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['type'] = this.type;
    data['name'] = this.name;
    data['img'] = this.img;
    return data;
  }
}