class ConfigModel {
  String? businessName;
  String? footerText;
  String? logo;
  String? address;
  String? phone;
  String? email;
  String? country;
  DefaultLocation? defaultLocation;
  String? currencySymbol;
  String? currencySymbolDirection;
  double? appMinimumVersionAndroid;
  String? appUrlAndroid;
  double? appMinimumVersionIos;
  String? appUrlIos;
  bool? customerVerification;
  bool? scheduleOrder;
  bool? orderDeliveryVerification;
  bool? cashOnDelivery;
  bool? digitalPayment;
  double? perKmShippingCharge;
  double? minimumShippingCharge;
  double? freeDeliveryOver;
  bool? demo;
  bool? maintenanceMode;
  String? orderConfirmationModel;
  bool? showDmEarning;
  bool? canceledByDeliveryman;
  String? timeformat;
  List<Language>? language;
  bool? toggleVegNonVeg;
  bool? toggleDmRegistration;
  bool? toggleStoreRegistration;
  int? scheduleOrderSlotDuration;
  int? digitAfterDecimalPoint;
  bool? canceledByStore;
  ModuleConfig? moduleConfig;
  bool? prescriptionOrderStatus;
  bool? dmPictureUploadStatus;
  String? additionalChargeName;
  String? disbursementType;
  List<PaymentBody>? activePaymentMethodList;
  double? minAmountToPayStore;
  bool? storeReviewReply;
  double? adminCommission;
  int? subscriptionDeadlineWarningDays;
  String? subscriptionDeadlineWarningMessage;
  int? subscriptionFreeTrialDays;
  bool? subscriptionFreeTrialStatus;
  int? subscriptionBusinessModel;
  int? commissionBusinessModel;
  String? subscriptionFreeTrialType;
  String? systemTaxType;
  int? systemTaxIncludeStatus;
  bool? openAiStatus;
  ReelsModule? reelsModule;
  ValidationConfig? validationConfig;

  ConfigModel({
    this.businessName,
    this.footerText,
    this.logo,
    this.address,
    this.phone,
    this.email,
    this.country,
    this.defaultLocation,
    this.currencySymbol,
    this.currencySymbolDirection,
    this.appMinimumVersionAndroid,
    this.appUrlAndroid,
    this.appMinimumVersionIos,
    this.appUrlIos,
    this.customerVerification,
    this.scheduleOrder,
    this.orderDeliveryVerification,
    this.cashOnDelivery,
    this.digitalPayment,
    this.perKmShippingCharge,
    this.minimumShippingCharge,
    this.freeDeliveryOver,
    this.demo,
    this.maintenanceMode,
    this.orderConfirmationModel,
    this.showDmEarning,
    this.canceledByDeliveryman,
    this.timeformat,
    this.language,
    this.toggleVegNonVeg,
    this.toggleDmRegistration,
    this.toggleStoreRegistration,
    this.scheduleOrderSlotDuration,
    this.digitAfterDecimalPoint,
    this.moduleConfig,
    this.canceledByStore,
    this.prescriptionOrderStatus,
    this.dmPictureUploadStatus,
    this.additionalChargeName,
    this.disbursementType,
    this.activePaymentMethodList,
    this.minAmountToPayStore,
    this.storeReviewReply,
    this.adminCommission,
    this.subscriptionDeadlineWarningDays,
    this.subscriptionDeadlineWarningMessage,
    this.subscriptionFreeTrialDays,
    this.subscriptionFreeTrialStatus,
    this.subscriptionBusinessModel,
    this.commissionBusinessModel,
    this.subscriptionFreeTrialType,
    this.systemTaxType,
    this.systemTaxIncludeStatus,
    this.openAiStatus,
    this.reelsModule,
    this.validationConfig,
  });

  ConfigModel.fromJson(Map<String, dynamic> json) {
    businessName = json['business_name'];
    footerText = json['footer_text'];
    logo = json['logo'];
    address = json['address'];
    phone = json['phone'];
    email = json['email'];
    country = json['country'];
    defaultLocation = json['default_location'] != null ? DefaultLocation.fromJson(json['default_location']) : null;
    currencySymbol = json['currency_symbol'];
    currencySymbolDirection = json['currency_symbol_direction'];
    appMinimumVersionAndroid = json['app_minimum_version_android_store'] != null ? json['app_minimum_version_android_store']?.toDouble() : 0.0;
    appUrlAndroid = json['app_url_android_store'];
    appMinimumVersionIos = json['app_minimum_version_ios_store'] != null ? json['app_minimum_version_ios_store']?.toDouble() : 0.0;
    appUrlIos = json['app_url_ios_store'];
    customerVerification = json['customer_verification'];
    scheduleOrder = json['schedule_order'];
    orderDeliveryVerification = json['order_delivery_verification'];
    cashOnDelivery = json['cash_on_delivery'];
    digitalPayment = json['digital_payment'];
    perKmShippingCharge = json['per_km_shipping_charge']?.toDouble();
    minimumShippingCharge = json['minimum_shipping_charge']?.toDouble();
    freeDeliveryOver = json['free_delivery_over']?.toDouble();
    demo = json['demo'];
    maintenanceMode = json['maintenance_mode'];
    orderConfirmationModel = json['order_confirmation_model'];
    showDmEarning = json['show_dm_earning'];
    canceledByDeliveryman = json['canceled_by_deliveryman'];
    timeformat = json['timeformat'];
    if (json['language'] != null) {
      language = <Language>[];
      json['language'].forEach((v) {
        language!.add(Language.fromJson(v));
      });
    }
    toggleVegNonVeg = json['toggle_veg_non_veg'];
    toggleDmRegistration = json['toggle_dm_registration'];
    toggleStoreRegistration = json['toggle_store_registration'];
    scheduleOrderSlotDuration = json['schedule_order_slot_duration'] == 0 ? 30 : json['schedule_order_slot_duration'];
    digitAfterDecimalPoint = json['digit_after_decimal_point'];
    canceledByStore = json['canceled_by_store'];
    moduleConfig = json['module_config'] != null ? ModuleConfig.fromJson(json['module_config']) : null;
    prescriptionOrderStatus = json['prescription_order_status'];
    dmPictureUploadStatus = json['dm_picture_upload_status'] == 1 ? true : false;
    additionalChargeName = json['additional_charge_name'];
    disbursementType = json['disbursement_type'];
    if (json['active_payment_method_list'] != null) {
      activePaymentMethodList = <PaymentBody>[];
      json['active_payment_method_list'].forEach((v) {
        activePaymentMethodList!.add(PaymentBody.fromJson(v));
      });
    }
    minAmountToPayStore = json['min_amount_to_pay_store']?.toDouble();
    storeReviewReply = json['store_review_reply'] == 1 ? true : false;
    adminCommission = json['admin_commission']?.toDouble();
    subscriptionDeadlineWarningDays = json['subscription_deadline_warning_days'];
    subscriptionDeadlineWarningMessage = json['subscription_deadline_warning_message'];
    subscriptionFreeTrialDays = json['subscription_free_trial_days'];
    subscriptionFreeTrialStatus = json['subscription_free_trial_status'] == 1 ? true : false;
    subscriptionBusinessModel = json['subscription_business_model'];
    commissionBusinessModel = json['commission_business_model'];
    subscriptionFreeTrialType = json['subscription_free_trial_type'];
    systemTaxType = json['system_tax_type'];
    systemTaxIncludeStatus = json['system_tax_include_status'];
    openAiStatus = json['open_ai_status'] == 1 ? true : false;
    reelsModule = json['reels_module'] != null ? ReelsModule.fromJson(json['reels_module']) : null;
    validationConfig = json['validation_config'] != null ? ValidationConfig.fromJson(json['validation_config']) : ValidationConfig(videoFormat: "mp4,webm,ogg", videoExtension: ".mp4,.webm,.ogg", productVideoMaxFileSize: 20, maxFileSize: 2, maxUploadFileCount: 5);
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['business_name'] = businessName;
    data['logo'] = logo;
    data['address'] = address;
    data['phone'] = phone;
    data['email'] = email;
    data['country'] = country;
    if (defaultLocation != null) {
      data['default_location'] = defaultLocation!.toJson();
    }
    data['currency_symbol'] = currencySymbol;
    data['currency_symbol_direction'] = currencySymbolDirection;
    data['app_minimum_version_android'] = appMinimumVersionAndroid;
    data['app_url_android'] = appUrlAndroid;
    data['app_minimum_version_ios'] = appMinimumVersionIos;
    data['app_url_ios'] = appUrlIos;
    data['customer_verification'] = customerVerification;
    data['schedule_order'] = scheduleOrder;
    data['order_delivery_verification'] = orderDeliveryVerification;
    data['cash_on_delivery'] = cashOnDelivery;
    data['digital_payment'] = digitalPayment;
    data['per_km_shipping_charge'] = perKmShippingCharge;
    data['minimum_shipping_charge'] = minimumShippingCharge;
    data['free_delivery_over'] = freeDeliveryOver;
    data['demo'] = demo;
    data['maintenance_mode'] = maintenanceMode;
    data['order_confirmation_model'] = orderConfirmationModel;
    data['show_dm_earning'] = showDmEarning;
    data['canceled_by_deliveryman'] = canceledByDeliveryman;
    data['timeformat'] = timeformat;
    if (language != null) {
      data['language'] = language!.map((v) => v.toJson()).toList();
    }
    data['toggle_veg_non_veg'] = toggleVegNonVeg;
    data['toggle_dm_registration'] = toggleDmRegistration;
    data['toggle_store_registration'] = toggleStoreRegistration;
    data['schedule_order_slot_duration'] = scheduleOrderSlotDuration;
    data['digit_after_decimal_point'] = digitAfterDecimalPoint;
    data['canceled_by_store'] = canceledByStore;
    if (moduleConfig != null) {
      data['module_config'] = moduleConfig!.toJson();
    }
    data['prescription_order_status'] = prescriptionOrderStatus;
    data['dm_picture_upload_status'] = dmPictureUploadStatus;
    data['additional_charge_name'] = additionalChargeName;
    data['disbursement_type'] = disbursementType;
    if (activePaymentMethodList != null) {
      data['active_payment_method_list'] = activePaymentMethodList!.map((v) => v.toJson()).toList();
    }
    data['min_amount_to_pay_store'] = minAmountToPayStore;
    data['store_review_reply'] = storeReviewReply;
    data['subscription_deadline_warning_days'] = subscriptionDeadlineWarningDays;
    data['subscription_deadline_warning_message'] = subscriptionDeadlineWarningMessage;
    data['subscription_free_trial_days'] = subscriptionFreeTrialDays;
    data['subscription_free_trial_status'] = subscriptionFreeTrialStatus;
    data['subscription_business_model'] = subscriptionBusinessModel;
    data['commission_business_model'] = commissionBusinessModel;
    data['subscription_free_trial_type'] = subscriptionFreeTrialType;
    data['system_tax_type'] = systemTaxType;
    data['system_tax_include_status'] = systemTaxIncludeStatus;
    data['open_ai_status'] = openAiStatus;
    if (reelsModule != null) {
      data['reels_module'] = reelsModule!.toJson();
    }
    data['validation_config'] = validationConfig;
    return data;
  }
}

class DefaultLocation {
  String? lat;
  String? lng;

  DefaultLocation({this.lat, this.lng});

  DefaultLocation.fromJson(Map<String, dynamic> json) {
    lat = json['lat'];
    lng = json['lng'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['lat'] = lat;
    data['lng'] = lng;
    return data;
  }
}

class Language {
  String? key;
  String? value;

  Language({this.key, this.value});

  Language.fromJson(Map<String, dynamic> json) {
    key = json['key'];
    value = json['value'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['key'] = key;
    data['value'] = value;
    return data;
  }
}

class ModuleConfig {
  List<String>? moduleType;
  Module? module;

  ModuleConfig({this.moduleType, this.module});

  ModuleConfig.fromJson(Map<String, dynamic> json) {
    moduleType = json['module_type'].cast<String>();
    module = json[moduleType![0]] != null ? Module.fromJson(json[moduleType![0]]) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['module_type'] = moduleType;
    if (module != null) {
      data[moduleType![0]] = module!.toJson();
    }
    return data;
  }
}

class Module {
  OrderStatus? orderStatus;
  bool? orderPlaceToScheduleInterval;
  bool? addOn;
  bool? stock;
  bool? vegNonVeg;
  bool? unit;
  bool? orderAttachment;
  bool? alwaysOpen;
  bool? itemAvailableTime;
  bool? showRestaurantText;
  bool? isParcel;
  bool? newVariation;
  String? description;

  Module({
    this.orderStatus,
    this.orderPlaceToScheduleInterval,
    this.addOn,
    this.stock,
    this.vegNonVeg,
    this.unit,
    this.orderAttachment,
    this.alwaysOpen,
    this.itemAvailableTime,
    this.showRestaurantText,
    this.isParcel,
    this.newVariation,
    this.description,
  });

  Module.fromJson(Map<String, dynamic> json) {
    orderStatus = json['order_status'] != null ? OrderStatus.fromJson(json['order_status']) : null;
    orderPlaceToScheduleInterval = json['order_place_to_schedule_interval'];
    addOn = json['add_on'];
    stock = json['stock'];
    vegNonVeg = json['veg_non_veg'];
    unit = json['unit'];
    orderAttachment = json['order_attachment'];
    alwaysOpen = json['always_open'];
    itemAvailableTime = json['item_available_time'];
    showRestaurantText = json['show_restaurant_text'];
    isParcel = json['is_parcel'];
    newVariation = json['new_variation'];
    description = json['description'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (orderStatus != null) {
      data['order_status'] = orderStatus!.toJson();
    }
    data['order_place_to_schedule_interval'] = orderPlaceToScheduleInterval;
    data['add_on'] = addOn;
    data['stock'] = stock;
    data['veg_non_veg'] = vegNonVeg;
    data['unit'] = unit;
    data['order_attachment'] = orderAttachment;
    data['always_open'] = alwaysOpen;
    data['item_available_time'] = itemAvailableTime;
    data['show_restaurant_text'] = showRestaurantText;
    data['is_parcel'] = isParcel;
    data['new_variation'] = newVariation;
    data['description'] = description;
    return data;
  }
}

class OrderStatus {
  bool? accepted;

  OrderStatus({this.accepted});

  OrderStatus.fromJson(Map<String, dynamic> json) {
    accepted = json['accepted'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['accepted'] = accepted;
    return data;
  }
}

class PaymentBody {
  String? getWay;
  String? getWayTitle;
  String? getWayImageFullUrl;
  String? storageType;

  PaymentBody({
    this.getWay,
    this.getWayTitle,
    this.getWayImageFullUrl,
    this.storageType,
  });

  PaymentBody.fromJson(Map<String, dynamic> json) {
    getWay = json['gateway'];
    getWayTitle = json['gateway_title'];
    getWayImageFullUrl = json['gateway_image_full_url'];
    storageType = json['storage'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['gateway'] = getWay;
    data['gateway_title'] = getWayTitle;
    data['gateway_image_full_url'] = getWayImageFullUrl;
    data['storage'] = storageType;
    return data;
  }
}

class ReelsModule {
  bool? vendorCanUploadReels;
  int? reelsMaxUploadSizeMb;
  int? reelsMaxDuration;
  String? reelsMaxDurationUnit;
  bool? reelsUploadLimitUnlimited;
  int? reelsUploadLimit;
  String? reelsUploadLimitType;

  ReelsModule({
    this.vendorCanUploadReels,
    this.reelsMaxUploadSizeMb,
    this.reelsMaxDuration,
    this.reelsMaxDurationUnit,
    this.reelsUploadLimitUnlimited,
    this.reelsUploadLimit,
    this.reelsUploadLimitType,
  });

  ReelsModule.fromJson(Map<String, dynamic> json) {
    vendorCanUploadReels = json['vendor_can_upload_reels'] == 1;
    reelsMaxUploadSizeMb = json['reels_max_upload_size_mb'] != null ? int.parse(json['reels_max_upload_size_mb'].toString()) : null;
    reelsMaxDuration = json['reels_max_duration'] != null ? int.parse(json['reels_max_duration'].toString()) : null;
    reelsMaxDurationUnit = json['reels_max_duration_unit'];
    reelsUploadLimitUnlimited = json['reels_upload_limit_unlimited'] == 1;
    reelsUploadLimit = json['reels_upload_limit'] != null ? int.parse(json['reels_upload_limit'].toString()) : null;
    reelsUploadLimitType = json['reels_upload_limit_type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['vendor_can_upload_reels'] = vendorCanUploadReels == true ? 1 : 0;
    data['reels_max_upload_size_mb'] = reelsMaxUploadSizeMb;
    data['reels_max_duration'] = reelsMaxDuration;
    data['reels_max_duration_unit'] = reelsMaxDurationUnit;
    data['reels_upload_limit_unlimited'] = reelsUploadLimitUnlimited == true ? 1 : 0;
    data['reels_upload_limit'] = reelsUploadLimit;
    data['reels_upload_limit_type'] = reelsUploadLimitType;
    return data;
  }
}

class ValidationConfig {
  String videoFormat;
  String videoExtension;
  double productVideoMaxFileSize;
  double maxFileSize;
  int maxUploadFileCount;

  ValidationConfig({
    required this.videoFormat,
    required this.videoExtension,
    required this.productVideoMaxFileSize,
    required this.maxFileSize,
    // currently static
    required this.maxUploadFileCount,
  });

  factory ValidationConfig.fromJson(Map<String, dynamic> json) {
    return ValidationConfig(
      videoFormat : json['video_format'] ?? '',
      videoExtension : json['video_extension'] ?? '',
      productVideoMaxFileSize : num.tryParse(json['product_video_max_file_size'].toString())?.toDouble() ?? 20,
      maxFileSize : num.tryParse(json['max_file_size'].toString())?.toDouble() ?? 2,
      maxUploadFileCount : num.tryParse(json['max_upload_file_count'].toString())?.toInt() ?? 5,
    );
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['video_format'] = videoFormat;
    data['video_extension'] = videoExtension;
    data['product_video_max_file_size'] = productVideoMaxFileSize;
    data['max_file_size'] = maxFileSize;
    data['max_upload_file_count'] = maxUploadFileCount;
    return data;
  }
}