/**
 * 刷新 Token 请求 DTO
 */
import {
  RefreshTokenRequestSchema,
  type RefreshTokenRequestInput,
  type RefreshTokenRequestData,
} from "@/data/schemas/auth/refresh_token_request";

export class RefreshTokenRequest {
  declare readonly refreshToken: string;

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

  static from(input: RefreshTokenRequestInput): RefreshTokenRequest {
    return new RefreshTokenRequest(input);
  }

  static fromJson(json: unknown): RefreshTokenRequest {
    return RefreshTokenRequest.from(json as RefreshTokenRequestInput);
  }

  toJson(): RefreshTokenRequestData {
    return RefreshTokenRequestSchema.parse(this);
  }
}
