export class Category { private _url: string; private _title: string; private _categories: OneCategory[] = []; constructor(obj?) { if (obj) { if (obj.url) { this._url = obj.url; } if (obj.title) { this._title = obj.title; } if (obj.categories) { for (const i in obj.categories) { this._categories.push(new OneCategory(obj.categories[i])); } // this._categories = obj.categories; } } } get url(): string { return this._url; } set url(value: string) { this._url = value; } get title(): string { return this._title; } set title(value: string) { this._title = value; } get categories(): OneCategory[] { return this._categories; } set categories(value: OneCategory[]) { this._categories = value; } public toJSON() { return { url: this.url, title: this.title, categories: this.categories, }; } } export class OneCategory { name = ''; rank = 0; probability = 1; constructor(obj?) { if (obj) { if (obj.name) { this.name = obj.name; } if (obj.rank) { this.rank = obj.rank; } if (obj.probability) { this.probability = obj.probability; } if (obj.category_name) { this.name = obj.category_name; } if (obj.category_rank) { this.rank = obj.category_rank; } if (obj.category_probability) { this.probability = obj.category_probability; } } } } export const CategoriesOptions = ['General - Press Release', 'Products', 'People', 'General - News Coverage', 'Funding', 'Financial News', 'Mergers & Acquisitions', 'Events', 'Not an article / corrupt'];