import type { Ghost } from './classes.ghost.js'; import type { IAuthor } from './classes.post.js'; export class Author { public ghostInstanceRef: Ghost; public authorData: IAuthor; constructor(ghostInstanceRefArg: Ghost, authorData: IAuthor) { this.ghostInstanceRef = ghostInstanceRefArg; this.authorData = authorData; } public getId(): string { return this.authorData.id; } public getName(): string { return this.authorData.name; } public getSlug(): string { return this.authorData.slug; } public getProfileImage(): string | undefined { return this.authorData.profile_image; } public getBio(): string | undefined { return this.authorData.bio; } public toJson(): IAuthor { return this.authorData; } public async update(authorData: Partial): Promise { try { const updatedAuthorData = await this.ghostInstanceRef.adminApi.users.edit({ ...authorData, id: this.getId() }); this.authorData = updatedAuthorData; return this; } catch (error) { throw error; } } }