/**
 * 游客登录请求 DTO
 */
import {
  GuestLoginRequestSchema,
  type GuestLoginRequestInput,
  type GuestLoginRequestData,
} from "@/data/schemas/auth/guest_login_request";

export class GuestLoginRequest {
  declare readonly deviceId: string;
  declare readonly isTestAccount: boolean;

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

  static from(input: GuestLoginRequestInput): GuestLoginRequest {
    return new GuestLoginRequest(input);
  }

  static fromJson(json: unknown): GuestLoginRequest {
    return GuestLoginRequest.from(json as GuestLoginRequestInput);
  }

  toJson(): GuestLoginRequestData {
    return GuestLoginRequestSchema.parse(this);
  }
}
