/**
 * VIP 状态响应 DTO
 */
import {
  PaymentVipStatusResponseSchema,
  type PaymentVipStatusResponseData,
  type PaymentVipStatusResponseInput,
} from "@/data/schemas/payment/payment_vip_status_response";

export class PaymentVipStatusResponse {
  declare readonly isVip: boolean;
  declare readonly vipExpiresAt: string | null;

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

  static from(input: PaymentVipStatusResponseInput): PaymentVipStatusResponse {
    return new PaymentVipStatusResponse(input);
  }

  static fromJson(json: unknown): PaymentVipStatusResponse {
    return PaymentVipStatusResponse.from(
      json as PaymentVipStatusResponseInput,
    );
  }

  toJson(): PaymentVipStatusResponseData {
    return PaymentVipStatusResponseSchema.parse(this);
  }
}
