/**
 * 注册请求 DTO
 */
import {
  RegisterRequestSchema,
  type RegisterRequestInput,
  type RegisterRequestData,
} from "@/data/schemas/auth/register_request";

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

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

  static from(input: RegisterRequestInput): RegisterRequest {
    return new RegisterRequest(input);
  }

  static fromJson(json: unknown): RegisterRequest {
    return RegisterRequest.from(json as RegisterRequestInput);
  }

  toJson(): RegisterRequestData {
    return RegisterRequestSchema.parse(this);
  }
}
