export class Blog {
  constructor(data) {
    this.id = data.id;
    this.title = data.title;
    this.content = data.content;
    this.published = data.published;
    this.authorId = data.authorId;
    this.createdAt = data.createdAt;
    this.updatedAt = data.updatedAt;
    this.author = data.author;
  }

  toJSON() {
    return {
      id: this.id,
      title: this.title,
      content: this.content,
      published: this.published,
      authorId: this.authorId,
      createdAt: this.createdAt,
      updatedAt: this.updatedAt,
      author: this.author ? {
        id: this.author.id,
        username: this.author.username,
        email: this.author.email
      } : null
    };
  }
}
