/// Created by Haoyi on 2022/8/25

class CdnConfig {
  final List<String> prefix;

  final String cdnPrefix;

  final String fallbackPrefix;

  final int fatalThreshold;

  final bool monitor;

  CdnConfig(this.prefix, this.cdnPrefix, this.fatalThreshold, this.fallbackPrefix, this.monitor);


  @override
  String toString() {
    return 'CdnConfig{prefix: $prefix, cdnPrefix: $cdnPrefix, fallbackPrefix: $fallbackPrefix, fatalThreshold: $fatalThreshold, monitor: $monitor}';
  }

  factory CdnConfig.fromJson(Map<String, dynamic> json,
          {String defaultStoragePrefix = '', String defaultCdnPrefix = ''}) =>
      CdnConfig(
        (json['prefix'] as List<dynamic>?)?.map((e) => e as String).toList() ??
            [defaultStoragePrefix],
        json['cdn'] as String? ?? defaultCdnPrefix,
        json['fatal_threshold'] as int? ?? 5,
        json['fallback'] as String? ?? defaultStoragePrefix,
        json['monitor'] as bool? ?? false,
      );

  Map<String, dynamic> toJson() => <String, dynamic>{
        'prefix': prefix,
        'cdn': cdnPrefix,
        'fallback': fallbackPrefix,
        'fatal_threshold': fatalThreshold,
        'monitor': monitor,
      };
}
