fromJson static method

DomainDto? fromJson(
  1. dynamic value
)

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

Implementation

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

    return DomainDto(
      id: mapValueOfType<String>(json, r'id')!,
      userId: mapValueOfType<String>(json, r'userId')!,
      domain: mapValueOfType<String>(json, r'domain')!,
      verificationToken: mapValueOfType<String>(json, r'verificationToken')!,
      dkimTokens: json[r'dkimTokens'] is List
          ? (json[r'dkimTokens'] as List).cast<String>()
          : const [],
      missingRecordsMessage: mapValueOfType<String>(json, r'missingRecordsMessage'),
      hasMissingRecords: mapValueOfType<bool>(json, r'hasMissingRecords')!,
      isVerified: mapValueOfType<bool>(json, r'isVerified')!,
      domainNameRecords: DomainNameRecord.listFromJson(json[r'domainNameRecords'])!,
      catchAllInboxId: mapValueOfType<String>(json, r'catchAllInboxId'),
      createdAt: mapDateTime(json, r'createdAt', '')!,
      updatedAt: mapDateTime(json, r'updatedAt', '')!,
      domainType: DomainDtoDomainTypeEnum.fromJson(json[r'domainType'])!,
    );
  }
  return null;
}