Project: Mall App Client: Maiora
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

offer.ts 850 B

123456789101112131415161718192021222324252627282930
  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. };