// Copyright (C) 2023 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';

/// {@template account}
/// Represents a user [Account] in the
/// various identity provisioning systems.
/// {@endtemplate}
class Account extends Equatable implements Entity {
  /// {@macro account}
  const Account({
    required this.id,
    required this.isAnonymous,
    required this.emailVerified,
    required this.providerId,
    this.email,
    this.phoneNumber,
    this.photoURL,
    this.creationTime,
    this.lastSignInTime,
    this.isNewUser,
    this.accessToken,
    this.refreshToken,
  });

  /// The user's unique ID.
  final String id;

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

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

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

  /// Returns the users phone number.
  ///
  /// This property will be `null` if the user has not signed in or been has
  /// their phone number linked.
  final String? 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).
  final String? photoURL;

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

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

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

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

  /// The user access token
  final String? accessToken;

  /// The user refresh token
  final String? refreshToken;

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

  @override
  bool get stringify => true;
}
