import type { Ghost } from './classes.ghost.js'; import type { ITag } from './classes.post.js'; export class Tag { public ghostInstanceRef: Ghost; public tagData: ITag; constructor(ghostInstanceRefArg: Ghost, tagData: ITag) { this.ghostInstanceRef = ghostInstanceRefArg; this.tagData = tagData; } public getId(): string { return this.tagData.id; } public getName(): string { return this.tagData.name; } public getSlug(): string { return this.tagData.slug; } public getDescription(): string | undefined { return this.tagData.description; } public toJson(): ITag { return this.tagData; } public async update(tagData: Partial): Promise { try { const updatedTagData = await this.ghostInstanceRef.adminApi.tags.edit({ ...tagData, id: this.getId() }); this.tagData = updatedTagData; return this; } catch (error) { console.error('Error updating tag:', error); throw error; } } public async delete(): Promise { try { await this.ghostInstanceRef.adminApi.tags.delete({ id: this.getId() }); } catch (error) { console.error(`Error deleting tag with id ${this.getId()}:`, error); throw error; } } }