Testing openlibrary support
This commit is contained in:
parent
5054b0f20f
commit
38d28e10a0
6 changed files with 203 additions and 6 deletions
53
src/models/BookModel.ts
Normal file
53
src/models/BookModel.ts
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { MediaTypeModel } from './MediaTypeModel';
|
||||
import { mediaDbTag, migrateObject } from '../utils/Utils';
|
||||
import { MediaType } from '../utils/MediaType';
|
||||
|
||||
export class BookModel extends MediaTypeModel {
|
||||
author: string;
|
||||
pages: string;
|
||||
image: string;
|
||||
|
||||
released: boolean;
|
||||
|
||||
userData: {
|
||||
read: boolean;
|
||||
lastRead: string;
|
||||
personalRating: number;
|
||||
};
|
||||
|
||||
constructor(obj: any = {}) {
|
||||
super();
|
||||
|
||||
this.author = undefined;
|
||||
this.pages = undefined;
|
||||
this.image = undefined;
|
||||
|
||||
this.released = undefined;
|
||||
|
||||
this.userData = {
|
||||
read: undefined,
|
||||
lastRead: undefined,
|
||||
personalRating: undefined,
|
||||
};
|
||||
|
||||
migrateObject(this, obj, this);
|
||||
|
||||
if (!obj.hasOwnProperty('userData')) {
|
||||
migrateObject(this.userData, obj, this.userData);
|
||||
}
|
||||
|
||||
this.type = this.getMediaType();
|
||||
}
|
||||
|
||||
getTags(): string[] {
|
||||
return [mediaDbTag, 'book'];
|
||||
}
|
||||
|
||||
getMediaType(): MediaType {
|
||||
return MediaType.Book;
|
||||
}
|
||||
|
||||
getSummary(): string {
|
||||
return this.englishTitle + ' (' + this.year + ')';
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue