|
|
|
@@ -1,2 +1,73 @@ |
|
|
|
export class Mall { |
|
|
|
import Offer from '../models/offer'; |
|
|
|
import { CoOrdinates } from '../shared/common-types'; |
|
|
|
import Outlet from '../models/outlet'; |
|
|
|
|
|
|
|
class Mall { |
|
|
|
id: string; |
|
|
|
name: string; |
|
|
|
is_bookmarked: boolean; |
|
|
|
is_archived: boolean; |
|
|
|
image_url?: string; |
|
|
|
description: string; |
|
|
|
offers: Array<Offer>; |
|
|
|
outlets: Array<Outlet>; |
|
|
|
rating: number; |
|
|
|
distance: number; |
|
|
|
location: CoOrdinates; |
|
|
|
address: 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('is_bookmarked')) { |
|
|
|
throw new Error('Missing is_bookmarked'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('is_archived')) { |
|
|
|
throw new Error('Missing is_archived'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('description')) { |
|
|
|
throw new Error('Missing description'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('offers')) { |
|
|
|
throw new Error('Missing offers'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('outlets')) { |
|
|
|
throw new Error('Missing outlets'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('rating')) { |
|
|
|
throw new Error('Missing rating'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('distance')) { |
|
|
|
throw new Error('Missing distance'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('location')) { |
|
|
|
throw new Error('Missing location'); |
|
|
|
} |
|
|
|
if (!initializationObject.hasOwnProperty('address')) { |
|
|
|
throw new Error('Missing address'); |
|
|
|
} |
|
|
|
|
|
|
|
this.id = initializationObject.id; |
|
|
|
this.name = initializationObject.name; |
|
|
|
this.is_bookmarked = initializationObject.is_bookmarked; |
|
|
|
this.is_archived = initializationObject.is_archived; |
|
|
|
this.description = initializationObject.description; |
|
|
|
this.offers = initializationObject.offers; |
|
|
|
this.outlets = initializationObject.outlets; |
|
|
|
this.rating = initializationObject.rating; |
|
|
|
this.distance = initializationObject.distance; |
|
|
|
this.location = initializationObject.location; |
|
|
|
this.address = initializationObject.address; |
|
|
|
|
|
|
|
if (initializationObject.hasOwnProperty('image_url')) { |
|
|
|
this.image_url = initializationObject.image_url; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export default Mall; |