Project: Mall App Client: Maiora
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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