Project: Mall App Client: Maiora
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
850 B

  1. export class Offer {
  2. name: string;
  3. description: string;
  4. coupon_code: string;
  5. constructor(initializationObject: any) {
  6. // Check if object has the required fields
  7. if (!initializationObject.hasOwnProperty('name')) {
  8. throw new Error('The offer needs a name');
  9. }
  10. if (!initializationObject.hasOwnProperty('description')) {
  11. throw new Error('The offer needs a description');
  12. }
  13. if (!initializationObject.hasOwnProperty('coupon_code')) {
  14. throw new Error('The offer needs a coupon_code');
  15. }
  16. this.name = initializationObject.name;
  17. this.description = initializationObject.description;
  18. this.coupon_code = initializationObject.coupon_code;
  19. }
  20. }
  21. export type OfferCollection = {
  22. name: string,
  23. offers: Array<Offer>,
  24. };