/**
 * Apple 登录请求 DTO
 */
import {
  AppleLoginRequestSchema,
  type AppleLoginRequestInput,
  type AppleLoginRequestData,
} from "@/data/schemas/auth/apple_login_request";

export class AppleLoginRequest {
  declare readonly identityToken: string;
  declare readonly platform: string;
  declare readonly isTestAccount: boolean;

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

  static from(input: AppleLoginRequestInput): AppleLoginRequest {
    return new AppleLoginRequest(input);
  }

  static fromJson(json: unknown): AppleLoginRequest {
    return AppleLoginRequest.from(json as AppleLoginRequestInput);
  }

  toJson(): AppleLoginRequestData {
    return AppleLoginRequestSchema.parse(this);
  }
}
