fromJson static method

ApplicationUser? fromJson(
  1. dynamic value
)

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

Implementation

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

    return ApplicationUser(
      locked: mapValueOfType<bool>(json, r'Locked'),
      registrationDate: mapDateTime(json, r'RegistrationDate', '')!,
      name: mapValueOfType<String>(json, r'Name')!,
      role: Role.fromJson(json[r'Role']),
      imageFile: mapValueOfType<String>(json, r'ImageFile'),
      editable: mapValueOfType<bool>(json, r'Editable'),
      objectAddress: mapValueOfType<String>(json, r'ObjectAddress'),
      objectTitle: mapValueOfType<String>(json, r'ObjectTitle'),
      emailFinancial: mapValueOfType<String>(json, r'EmailFinancial'),
      companyName: mapValueOfType<String>(json, r'CompanyName'),
      contractNumber: mapValueOfType<String>(json, r'ContractNumber'),
      contractDate: mapDateTime(json, r'ContractDate', ''),
      accessDate: mapDateTime(json, r'AccessDate', ''),
      key: mapValueOfType<String>(json, r'Key'),
      bankName: mapValueOfType<String>(json, r'BankName'),
      bankBIK: mapValueOfType<String>(json, r'BankBIK'),
      bankCorrAccount: mapValueOfType<String>(json, r'BankCorrAccount'),
      bankPayAccount: mapValueOfType<String>(json, r'BankPayAccount'),
      signerFIO: mapValueOfType<String>(json, r'SignerFIO'),
      signerJob: mapValueOfType<String>(json, r'SignerJob'),
      signerDoc: mapValueOfType<String>(json, r'SignerDoc'),
      financeFIO: mapValueOfType<String>(json, r'FinanceFIO'),
      financeEmail: mapValueOfType<String>(json, r'FinanceEmail'),
      financePhone: mapValueOfType<String>(json, r'FinancePhone'),
      edo: mapValueOfType<bool>(json, r'Edo'),
      techFIO: mapValueOfType<String>(json, r'TechFIO'),
      techEmail: mapValueOfType<String>(json, r'TechEmail'),
      techPhone: mapValueOfType<String>(json, r'TechPhone'),
      legalFormShort: mapValueOfType<String>(json, r'LegalFormShort'),
      legalFormFull: mapValueOfType<String>(json, r'LegalFormFull'),
      addressLegal: mapValueOfType<String>(json, r'AddressLegal'),
      addressPostal: mapValueOfType<String>(json, r'AddressPostal'),
      addressActual: mapValueOfType<String>(json, r'AddressActual'),
      INN: mapValueOfType<String>(json, r'INN'),
      hidden: mapValueOfType<bool>(json, r'Hidden'),
      KPP: mapValueOfType<String>(json, r'KPP'),
      OGRN: mapValueOfType<String>(json, r'OGRN'),
      tickets: Ticket.listFromJson(json[r'Tickets']) ?? const [],
      logs: AuditLog.listFromJson(json[r'Logs']) ?? const [],
      copyRightOwnerId: mapValueOfType<int>(json, r'CopyRightOwnerId'),
      copyRightOwner: ApplicationUserCopyRightOwner.fromJson(json[r'CopyRightOwner']),
      playlists: Playlist.listFromJson(json[r'Playlists']) ?? const [],
      feeds: Feed.listFromJson(json[r'Feeds']) ?? const [],
      places: Place.listFromJson(json[r'Places']) ?? const [],
      companyTypeUsers: CompanyTypeUser.listFromJson(json[r'CompanyTypeUsers']) ?? const [],
      id: mapValueOfType<String>(json, r'Id'),
      userName: mapValueOfType<String>(json, r'UserName'),
      normalizedUserName: mapValueOfType<String>(json, r'NormalizedUserName'),
      email: mapValueOfType<String>(json, r'Email'),
      normalizedEmail: mapValueOfType<String>(json, r'NormalizedEmail'),
      emailConfirmed: mapValueOfType<bool>(json, r'EmailConfirmed'),
      passwordHash: mapValueOfType<String>(json, r'PasswordHash'),
      securityStamp: mapValueOfType<String>(json, r'SecurityStamp'),
      concurrencyStamp: mapValueOfType<String>(json, r'ConcurrencyStamp'),
      phoneNumber: mapValueOfType<String>(json, r'PhoneNumber'),
      phoneNumberConfirmed: mapValueOfType<bool>(json, r'PhoneNumberConfirmed'),
      twoFactorEnabled: mapValueOfType<bool>(json, r'TwoFactorEnabled'),
      lockoutEnd: mapDateTime(json, r'LockoutEnd', ''),
      lockoutEnabled: mapValueOfType<bool>(json, r'LockoutEnabled'),
      accessFailedCount: mapValueOfType<int>(json, r'AccessFailedCount'),
    );
  }
  return null;
}