

library;


class SmLoginResult {
  final bool ok;
  final String email;


  final String accessToken;


  final String refreshToken;

  final int expiresIn;


  final bool isVip;


  final int? vipExpiresAt;


  final bool vipPermanent;


  final bool needsVerification;

  final String? message;

  const SmLoginResult({
    required this.ok,
    this.email = '',
    this.accessToken = '',
    this.refreshToken = '',
    this.expiresIn = 0,
    this.isVip = false,
    this.vipExpiresAt,
    this.vipPermanent = false,
    this.needsVerification = false,
    this.message,
  });

  factory SmLoginResult.failure(
    String message, {
    bool needsVerification = false,
  }) => SmLoginResult(
    ok: false,
    needsVerification: needsVerification,
    message: message,
  );
}


class SmTokenRefreshResult {
  final bool ok;
  final String accessToken;
  final String refreshToken;
  final int expiresIn;


  final bool isVip;
  final int? vipExpiresAt;
  final bool vipPermanent;


  final bool hasVipInfo;


  final bool invalidRefreshToken;
  final String? message;

  const SmTokenRefreshResult({
    required this.ok,
    this.accessToken = '',
    this.refreshToken = '',
    this.expiresIn = 0,
    this.isVip = false,
    this.vipExpiresAt,
    this.vipPermanent = false,
    this.hasVipInfo = false,
    this.invalidRefreshToken = false,
    this.message,
  });

  factory SmTokenRefreshResult.failure(
    String message, {
    bool invalidRefreshToken = false,
  }) => SmTokenRefreshResult(
    ok: false,
    invalidRefreshToken: invalidRefreshToken,
    message: message,
  );
}


class SmActionResult {
  final bool ok;
  final String? message;

  const SmActionResult({required this.ok, this.message});

  factory SmActionResult.success() => const SmActionResult(ok: true);

  factory SmActionResult.failure(String message) =>
      SmActionResult(ok: false, message: message);
}


abstract class SmAccountGateway {


  Future<SmLoginResult> login({
    required String baseUrl,
    required String email,
    required String password,
  });


  Future<SmActionResult> registerStart({
    required String baseUrl,
    required String email,
  });


  Future<SmLoginResult> registerVerify({
    required String baseUrl,
    required String email,
    required String password,
    required String code,
  });


  Future<SmActionResult> resendCode({
    required String baseUrl,
    required String email,
  });


  Future<void> logout({required String baseUrl, required String refreshToken});


  Future<SmTokenRefreshResult> refreshAccessToken({
    required String baseUrl,
    required String refreshToken,
  });
}
