// GENERATED CODE - DO NOT MODIFY BY HAND

part of 'weather.dart';

// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************

Temperature _$TemperatureFromJson(Map<String, dynamic> json) {
  return $checkedNew('Temperature', json, () {
    final val = Temperature(
      value: $checkedConvert(json, 'value', (v) => (v as num)?.toDouble()),
    );
    return val;
  });
}

Map<String, dynamic> _$TemperatureToJson(Temperature instance) =>
    <String, dynamic>{
      'value': instance.value,
    };

Weather _$WeatherFromJson(Map<String, dynamic> json) {
  return $checkedNew('Weather', json, () {
    final val = Weather(
      condition: $checkedConvert(json, 'condition',
          (v) => _$enumDecodeNullable(_$WeatherConditionEnumMap, v)),
      lastUpdated: $checkedConvert(json, 'last_updated',
          (v) => v == null ? null : DateTime.parse(v as String)),
      location: $checkedConvert(json, 'location', (v) => v as String),
      temperature: $checkedConvert(
          json,
          'temperature',
          (v) => v == null
              ? null
              : Temperature.fromJson(v as Map<String, dynamic>)),
    );
    return val;
  }, fieldKeyMap: const {'lastUpdated': 'last_updated'});
}

Map<String, dynamic> _$WeatherToJson(Weather instance) => <String, dynamic>{
      'condition': _$WeatherConditionEnumMap[instance.condition],
      'last_updated': instance.lastUpdated?.toIso8601String(),
      'location': instance.location,
      'temperature': instance.temperature?.toJson(),
    };

T _$enumDecode<T>(
  Map<T, dynamic> enumValues,
  dynamic source, {
  T unknownValue,
}) {
  if (source == null) {
    throw ArgumentError('A value must be provided. Supported values: '
        '${enumValues.values.join(', ')}');
  }

  final value = enumValues.entries
      .singleWhere((e) => e.value == source, orElse: () => null)
      ?.key;

  if (value == null && unknownValue == null) {
    throw ArgumentError('`$source` is not one of the supported values: '
        '${enumValues.values.join(', ')}');
  }
  return value ?? unknownValue;
}

T _$enumDecodeNullable<T>(
  Map<T, dynamic> enumValues,
  dynamic source, {
  T unknownValue,
}) {
  if (source == null) {
    return null;
  }
  return _$enumDecode<T>(enumValues, source, unknownValue: unknownValue);
}

const _$WeatherConditionEnumMap = {
  WeatherCondition.clear: 'clear',
  WeatherCondition.rainy: 'rainy',
  WeatherCondition.cloudy: 'cloudy',
  WeatherCondition.snowy: 'snowy',
  WeatherCondition.unknown: 'unknown',
};
