fromJson static method

PatchedModelUpdate? fromJson(
  1. dynamic value
)

Returns a new PatchedModelUpdate instance and imports its values from value if it's a Map, null otherwise.

Implementation

// ignore: prefer_constructors_over_static_methods
static PatchedModelUpdate? fromJson(dynamic value) {
  if (value is Map) {
    final json = value.cast<String, dynamic>();

    // Ensure that the map contains the required keys.
    // Note 1: the values aren't checked for validity beyond being non-null.
    // Note 2: this code is stripped in release mode!
    assert(() {
      requiredKeys.forEach((key) {
        assert(json.containsKey(key), 'Required key "PatchedModelUpdate[$key]" is missing from JSON.');
        assert(json[key] != null, 'Required key "PatchedModelUpdate[$key]" has a null value in JSON.');
      });
      return true;
    }());

    return PatchedModelUpdate(
      nameDe: mapValueOfType<String>(json, r'name_de'),
      nameEn: mapValueOfType<String>(json, r'name_en'),
      nameFr: mapValueOfType<String>(json, r'name_fr'),
      nameIt: mapValueOfType<String>(json, r'name_it'),
      status: ModelStatus.fromJson(json[r'status']),
      description: mapValueOfType<String>(json, r'description'),
      descriptionDe: mapValueOfType<String>(json, r'description_de'),
      descriptionEn: mapValueOfType<String>(json, r'description_en'),
      descriptionFr: mapValueOfType<String>(json, r'description_fr'),
      descriptionIt: mapValueOfType<String>(json, r'description_it'),
      number: mapValueOfType<int>(json, r'number'),
      siteUrlDe: mapValueOfType<String>(json, r'site_url_de'),
      siteUrlEn: mapValueOfType<String>(json, r'site_url_en'),
      siteUrlFr: mapValueOfType<String>(json, r'site_url_fr'),
      siteUrlIt: mapValueOfType<String>(json, r'site_url_it'),
      scaleable: mapValueOfType<bool>(json, r'scaleable'),
      sku: mapValueOfType<String>(json, r'sku'),
      price: mapValueOfType<double>(json, r'price'),
      priceCurrency: mapValueOfType<String>(json, r'price_currency'),
      verticalPlacement: mapValueOfType<bool>(json, r'vertical_placement'),
    );
  }
  return null;
}