export class MenuItem {
    id: string;
    name: string;
    image_url?: string;
    description: string;
    is_vegeterian: boolean;
    wait_duration: number;
    price: number;
    discount: number;
    rating: number;
    tags: Array<string>;

    constructor(initializationObject: any) {
        if (!initializationObject.hasOwnProperty('id')) {
            throw new Error('Missing id')
        }
        if (!initializationObject.hasOwnProperty('name')) {
            throw new Error('Missing name')
        }
        if (!initializationObject.hasOwnProperty('description')) {
            throw new Error('Missing description')
        }
        if (!initializationObject.hasOwnProperty('is_vegeterian')) {
            throw new Error('Missing is_vegeterian')
        }
        if (!initializationObject.hasOwnProperty('wait_duration')) {
            throw new Error('Missing wait_duration')
        }
        if (!initializationObject.hasOwnProperty('price')) {
            throw new Error('Missing price')
        }
        if (!initializationObject.hasOwnProperty('discount')) {
            throw new Error('Missing discount')
        }
        if (!initializationObject.hasOwnProperty('rating')) {
            throw new Error('Missing rating')
        }
        if (!initializationObject.hasOwnProperty('tags')) {
            throw new Error('Missing tags')
        }

        this.id = initializationObject.id;
        this.name = initializationObject.name;
        this.description = initializationObject.description;
        this.is_vegeterian = initializationObject.is_vegeterian;
        this.wait_duration = initializationObject.wait_duration;
        this.price = initializationObject.price;
        this.discount = initializationObject.discount;
        this.rating = initializationObject.rating;
        this.tags = initializationObject.tags;

        if (initializationObject.hasOwnProperty('image_url')) {
            this.image_url = initializationObject.image_url;
        }
    }
};

export default MenuItem;
