import type {Variant} from "~/types/variant";
import type {Origin} from "~/types/origin";
import type {Unit} from "~/types/unit";

export class Article {
  readonly id: number;
  name: string;
  bio: boolean;
  origin: Origin;
  description: string | null;
  ingredients: string | null;
  default_unit: Unit;
  variants: Array<Variant>;
  mhd: string | null;
  bio_origin: string | null;
  allergens_text: string | null;
  bio_info: string | null;
  topm_id: string | null;
  additional_name: string | null;

  constructor(id: number, name: string, bio: boolean, origin: Origin, description: string | null,
              ingredients: string | null, default_unit: Unit, variants: Array<Variant> | null,
              mhd: string | null, bio_origin: string | null, allergens_text: string | null,
              bio_info: string | null, topm_id: string | null, additional_name: string | null) {
    this.id = id;
    this.name = name;
    this.bio = bio;
    this.origin = origin;
    this.description = description;
    this.ingredients = ingredients;
    this.default_unit = default_unit;
    
    if (variants == null) {
      this.variants = [];
    } else {
      this.variants = variants;
    }
    
    this.mhd = mhd;
    this.bio_origin = bio_origin;
    this.allergens_text = allergens_text;
    this.bio_info = bio_info;
    this.topm_id = topm_id;
    this.additional_name = additional_name;
  }
}
