Files
ghost/ts/classes.author.ts

51 lines
1.1 KiB
TypeScript
Raw Normal View History

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<IAuthor>): Promise<Author> {
try {
const updatedAuthorData = await this.ghostInstanceRef.adminApi.users.edit({
...authorData,
id: this.getId()
});
this.authorData = updatedAuthorData;
return this;
} catch (error) {
console.error('Error updating author:', error);
throw error;
}
}
}