// Copyright (C) 2022 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import 'package:equatable/equatable.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart';

abstract class Account extends Equatable implements Entity {
  /// The user's unique ID.
  String get uid;

  /// The users email address.
  ///
  /// Will be `null` if signing in anonymously.
  String? get email;

  /// Returns whether the users email address has been verified.
  ///
  /// To send a verification email, see `SendEmailVerification`.
  bool get emailVerified;

  /// Returns whether the user is a anonymous.
  bool get isAnonymous;

  /// Returns the users account creation time.
  ///
  /// When this account was created as dictated by the server clock.
  DateTime? get creationTime;

  /// When the user last signed in as dictated by the server clock.
  DateTime? get lastSignInTime;

  /// Returns the users phone number.
  ///
  /// This property will be `null` if the user has not signed in or been has
  /// their phone number linked.
  String? get phoneNumber;

  /// Returns a photo URL for the user.
  ///
  /// This property will be populated if the user has signed in or been linked
  /// with a 3rd party OAuth provider (such as Google).
  String? get photoURL;

  /// The provider ID for the user.
  String get providerId;

  /// Whether the user account has been recently created.
  bool? get isNewUser;

  @override
  List<Object?> get props => [
        uid,
        email,
        emailVerified,
        isAnonymous,
        creationTime,
        lastSignInTime,
        phoneNumber,
        photoURL,
        providerId,
        isNewUser,
      ];

  @override
  String toString() => 'AccountModel(uid: $uid, email: $email, '
      'creationTime: $creationTime, emailVerified: $emailVerified, '
      'isAnonymous: $isAnonymous, isNewUser: $isNewUser, lastSignInTime: '
      '$lastSignInTime, phoneNumber: $phoneNumber, photoURL: $photoURL, '
      'providerId: $providerId)';
}
