fromJson static method

UpdateUserRequest? fromJson(
  1. dynamic value
)

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

Implementation

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

    return UpdateUserRequest(
      externalId: mapValueOfType<String>(json, r'external_id'),
      firstName: mapValueOfType<String>(json, r'first_name'),
      lastName: mapValueOfType<String>(json, r'last_name'),
      primaryEmailAddressId:
          mapValueOfType<String>(json, r'primary_email_address_id'),
      notifyPrimaryEmailAddressChanged: mapValueOfType<bool>(
              json, r'notify_primary_email_address_changed') ??
          false,
      primaryPhoneNumberId:
          mapValueOfType<String>(json, r'primary_phone_number_id'),
      primaryWeb3WalletId:
          mapValueOfType<String>(json, r'primary_web3_wallet_id'),
      username: mapValueOfType<String>(json, r'username'),
      profileImageId: mapValueOfType<String>(json, r'profile_image_id'),
      password: mapValueOfType<String>(json, r'password'),
      passwordDigest: mapValueOfType<String>(json, r'password_digest'),
      passwordHasher: mapValueOfType<String>(json, r'password_hasher'),
      skipPasswordChecks: mapValueOfType<bool>(json, r'skip_password_checks'),
      signOutOfOtherSessions:
          mapValueOfType<bool>(json, r'sign_out_of_other_sessions'),
      totpSecret: mapValueOfType<String>(json, r'totp_secret'),
      backupCodes: json[r'backup_codes'] is Iterable
          ? (json[r'backup_codes'] as Iterable)
              .cast<String>()
              .toList(growable: false)
          : const [],
      publicMetadata:
          mapCastOfType<String, Object>(json, r'public_metadata') ?? const {},
      privateMetadata:
          mapCastOfType<String, Object>(json, r'private_metadata') ??
              const {},
      unsafeMetadata:
          mapCastOfType<String, Object>(json, r'unsafe_metadata') ?? const {},
      deleteSelfEnabled: mapValueOfType<bool>(json, r'delete_self_enabled'),
      createOrganizationEnabled:
          mapValueOfType<bool>(json, r'create_organization_enabled'),
      legalAcceptedAt: mapValueOfType<String>(json, r'legal_accepted_at'),
      skipLegalChecks: mapValueOfType<bool>(json, r'skip_legal_checks'),
      createOrganizationsLimit:
          mapValueOfType<int>(json, r'create_organizations_limit'),
      createdAt: mapValueOfType<String>(json, r'created_at'),
    );
  }
  return null;
}