export class Offer { name: string; description: string; coupon_code: string; constructor(initializationObject: any) { // Check if object has the required fields if (!initializationObject.hasOwnProperty('name')) { throw new Error('The offer needs a name'); } if (!initializationObject.hasOwnProperty('description')) { throw new Error('The offer needs a description'); } if (!initializationObject.hasOwnProperty('coupon_code')) { throw new Error('The offer needs a coupon_code'); } this.name = initializationObject.name; this.description = initializationObject.description; this.coupon_code = initializationObject.coupon_code; } } export type OfferCollection = { name: string, offers: Array, };