import * as _ from 'lodash'; export class Coupon { id: string; tenantId: string; storeId: string; name: string; description: string; banner: string; status: string; created: string; startDate: string; endDate: string; rules: any[]; userId: string; public static fromJson (obj: any) { return new Coupon( obj.tenantId, obj.storeId, obj.name, obj.description, obj.banner, obj.status, obj.created, obj.startDate, obj.endDate, // JSON.parse(obj.rules), _.map((_.values(obj.rules)), JSON.parse), obj.userId, obj.id ); // return new Beacon(); }; public toJson() { const couponJson: any = { id: this.id, tenantId: this.tenantId, storeId: this.storeId, name: this.name, description: this.description, banner: this.banner, status: this.status, created: this.created, startDate: this.startDate, endDate: this.endDate, rules: JSON.stringify(this.rules), userId: this.userId }; return couponJson; } constructor(tenantId: string, storeId: string, name: string, description: string, banner: string, status: string, created: string, startDate: string, endDate: string, rules: any[], userId: string, id?: string ) { this.id = id ; this.tenantId = tenantId ; this.storeId = storeId ; this.name = name ; this.description = description ; this.banner = banner ; this.status = status ; this.created = created ; this.startDate = startDate ; this.endDate = endDate ; this.rules = rules ; this.userId = userId ; } getId() { return this.id; }; getStoreId() { return this.storeId; }; gettenantId() { return this.tenantId; }; getName() { return this.name; }; getDescription() { return this.description; }; getBanner() { return this.banner; }; getStatus() { return this.status; }; getcreated() { return this.created; }; getStartDate() { return this.startDate; }; getEndDate() { return this.endDate; }; getRules() { return this.rules; }; getUserId() { return this.userId; }; }