/**
 * 登录请求 DTO
 */
import {
  LoginRequestSchema,
  type LoginRequestInput,
  type LoginRequestData,
} from "@/data/schemas/auth/login_request";

export class LoginRequest {
  declare readonly email: string;
  declare readonly username: string;
  declare readonly password: string;
  declare readonly platform: string;
  declare readonly guestId: string;
  declare readonly isTestAccount: boolean;

  private constructor(input: LoginRequestInput) {
    const data = LoginRequestSchema.parse(input);
    Object.assign(this, data);
    Object.freeze(this);
  }

  static from(input: LoginRequestInput): LoginRequest {
    return new LoginRequest(input);
  }

  static fromJson(json: unknown): LoginRequest {
    return LoginRequest.from(json as LoginRequestInput);
  }

  toJson(): LoginRequestData {
    return LoginRequestSchema.parse(this);
  }
}
