/**
 * Facebook 用户数据 DTO
 *
 * 
 */
import {
  FacebookUserDataSchema,
  type FacebookUserDataInput,
  type FacebookUserDataData,
} from "@/data/schemas/auth/facebook_user_data";

export class FacebookUserData {
  declare readonly id: string | null;
  declare readonly name: string | null;
  declare readonly email: string | null;
  declare readonly pictureUrl: string | null;

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

  static from(input: FacebookUserDataInput): FacebookUserData {
    return new FacebookUserData(input);
  }

  static fromJson(json: unknown): FacebookUserData {
    return FacebookUserData.from(json as FacebookUserDataInput);
  }

  toJson(): FacebookUserDataData {
    return FacebookUserDataSchema.parse(this);
  }
}
