fromJson static method

APIDomainConfiguration? fromJson(
  1. dynamic value
)

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

Implementation

// ignore: prefer_constructors_over_static_methods
static APIDomainConfiguration? 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(() {
      assert(json.containsKey(r'id'), 'Required key "APIDomainConfiguration[id]" is missing from JSON.');
      assert(json[r'id'] != null, 'Required key "APIDomainConfiguration[id]" has a null value in JSON.');
      assert(json.containsKey(r'domain'), 'Required key "APIDomainConfiguration[domain]" is missing from JSON.');
      assert(json[r'domain'] != null, 'Required key "APIDomainConfiguration[domain]" has a null value in JSON.');
      assert(json.containsKey(r'createdAt'), 'Required key "APIDomainConfiguration[createdAt]" is missing from JSON.');
      assert(json[r'createdAt'] != null, 'Required key "APIDomainConfiguration[createdAt]" has a null value in JSON.');
      return true;
    }());

    return APIDomainConfiguration(
      id: mapValueOfType<String>(json, r'id')!,
      domain: mapValueOfType<String>(json, r'domain')!,
      emailFromName: mapValueOfType<String>(json, r'emailFromName'),
      emailFromEmail: mapValueOfType<String>(json, r'emailFromEmail'),
      emailHeaders: mapCastOfType<String, String>(json, r'emailHeaders') ?? const {},
      wpSyncToken: mapValueOfType<String>(json, r'wpSyncToken'),
      wpSynced: mapValueOfType<bool>(json, r'wpSynced'),
      wpURL: mapValueOfType<String>(json, r'wpURL'),
      createdAt: mapDateTime(json, r'createdAt', r'')!,
      autoAddedDate: mapDateTime(json, r'autoAddedDate', r''),
      siteType: ImportedSiteType.fromJson(json[r'siteType']),
      logoSrc: mapValueOfType<String>(json, r'logoSrc'),
      logoSrc100px: mapValueOfType<String>(json, r'logoSrc100px'),
      footerUnsubscribeURL: mapValueOfType<String>(json, r'footerUnsubscribeURL'),
      disableUnsubscribeLinks: mapValueOfType<bool>(json, r'disableUnsubscribeLinks'),
    );
  }
  return null;
}