Advertisement
Alatri_Aymen

models

May 16th, 2022
1,159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 10.39 KB | None | 0 0
  1. class Order {
  2.   String? id;
  3.   String? promoCodeId;
  4.   String? clientId;
  5.   String? createdAt;
  6.   String? updatedAt;
  7.   double? amountToPay;
  8.   String? companyId;
  9.   String? deletedAt;
  10.   int? status;
  11.   PromoCode? promoCode;
  12.   List<Sale>? sales;
  13.   User? client;
  14.  
  15.   Order({
  16.     this.id,
  17.     this.promoCodeId,
  18.     this.clientId,
  19.     this.createdAt,
  20.     this.updatedAt,
  21.     this.amountToPay,
  22.     this.companyId,
  23.     this.deletedAt,
  24.     this.status,
  25.     this.promoCode,
  26.     this.sales,
  27.     this.client,
  28.   });
  29.  
  30.   Order.fromJson(Map<String, dynamic> json) {
  31.     id = json['id'];
  32.     promoCodeId = json['promo_code_id'];
  33.     clientId = json['client_id'];
  34.     createdAt = json['created_at'];
  35.     updatedAt = json['updated_at'];
  36.     amountToPay = json['amount_to_pay']?.toDouble();
  37.     companyId = json['company_id'];
  38.     deletedAt = json['deleted_at'];
  39.     status = json['status'];
  40.     promoCode = json['promo_code'] != null ? PromoCode.fromJson(json['promo_code']) : null;
  41.     if (json['sales'] != null) {
  42.       sales = [];
  43.       json['sales'].forEach((v) {
  44.         sales!.add(Sale.fromJson(v));
  45.       });
  46.     }
  47.     client = json['client'] != null ? User.fromJson(json['client']) : null;
  48.   }
  49.  
  50.   Map<String, dynamic> toJson() {
  51.     final Map<String, dynamic> data = Map<String, dynamic>();
  52.     data['id'] = this.id;
  53.     data['promo_code_id'] = this.promoCodeId;
  54.     data['client_id'] = this.clientId;
  55.     data['created_at'] = this.createdAt;
  56.     data['updated_at'] = this.updatedAt;
  57.     data['amount_to_pay'] = this.amountToPay;
  58.     data['company_id'] = this.companyId;
  59.     data['deleted_at'] = this.deletedAt;
  60.     data['status'] = this.status;
  61.     if (this.client != null) {
  62.       data['promo_code'] = this.promoCode!.toJson();
  63.     }
  64.     if (this.sales != null) {
  65.       data['sales'] = this.sales!.map((v) => v.toJson()).toList();
  66.     }
  67.     if (this.client != null) {
  68.       data['client'] = this.client!.toJson();
  69.     }
  70.     return data;
  71.   }
  72. }
  73.  
  74. class Sale {
  75.   String? id;
  76.   String? saleableType;
  77.   String? saleableId;
  78.   String? userId;
  79.   String? saleDate;
  80.   String? toBeUsedOn;
  81.   String? useDate;
  82.   double? salePrice;
  83.   String? createdAt;
  84.   String? updatedAt;
  85.   String? beneficiary;
  86.   dynamic saleable;
  87.  
  88.   Sale({
  89.     this.id,
  90.     this.saleableType,
  91.     this.saleableId,
  92.     this.userId,
  93.     this.saleDate,
  94.     this.useDate,
  95.     this.salePrice,
  96.     this.createdAt,
  97.     this.updatedAt,
  98.     this.beneficiary,
  99.     this.saleable,
  100.   });
  101.  
  102.   Sale.fromJson(Map<String, dynamic> json) {
  103.     id = json['id'];
  104.     saleableType = json['saleable_type'];
  105.     saleableId = json['saleable_id'];
  106.     userId = json['user_id'];
  107.     saleDate = json['sale_date'];
  108.     toBeUsedOn = json['to_be_used_on'];
  109.     useDate = json['use_date'] ?? null;
  110.     salePrice = json['sale_price']?.toDouble();
  111.     createdAt = json['created_at'];
  112.     updatedAt = json['updated_at'];
  113.     beneficiary = json['beneficiary'];
  114.     if (saleableType!.contains(saleableTypes[0])) {
  115.       saleable = json['saleable'] != null ? SaleableCourse.fromJson(json['saleable']) : null;
  116.     } else if (saleableType!.contains(saleableTypes[1])) {
  117.       saleable = json['saleable'] != null ? SaleableDayPass.fromJson(json['saleable']) : null;
  118.     } else if (saleableType!.contains(saleableTypes[2])) {
  119.       saleable = json['saleable'] != null ? SaleableEvent.fromJson(json['saleable']) : null;
  120.     } else {
  121.       saleable = json['saleable'] != null ? SaleableSubscription.fromJson(json['saleable']) : null;
  122.     }
  123.   }
  124.  
  125.   Map<String, dynamic> toJson() {
  126.     final Map<String, dynamic> data = Map<String, dynamic>();
  127.     data['id'] = this.id;
  128.     data['saleable_type'] = this.saleableType;
  129.     data['saleable_id'] = this.saleableId;
  130.     data['user_id'] = this.userId;
  131.     data['sale_date'] = this.saleDate;
  132.     data['to_be_used_on'] = this.toBeUsedOn;
  133.     data['use_date'] = this.useDate;
  134.     data['sale_price'] = this.salePrice;
  135.     data['created_at'] = this.createdAt;
  136.     data['updated_at'] = this.updatedAt;
  137.     data['beneficiary'] = this.beneficiary;
  138.     if (this.saleable != null) {
  139.       data['saleable'] = this.saleable.toJson();
  140.     }
  141.     return data;
  142.   }
  143. }
  144.  
  145. class SaleableCourse {
  146.   String? id;
  147.   String? date;
  148.   int? stock;
  149.   double? nomadPrice;
  150.   double? companyPrice;
  151.   String? title;
  152.   String? courseId;
  153.   String? planningId;
  154.   String? createdAt;
  155.   String? updatedAt;
  156.   Course? course;
  157.  
  158.   SaleableCourse({
  159.     this.id,
  160.     this.date,
  161.     this.stock,
  162.     this.nomadPrice,
  163.     this.companyPrice,
  164.     this.courseId,
  165.     this.planningId,
  166.     this.title,
  167.     this.createdAt,
  168.     this.updatedAt,
  169.     this.course,
  170.   });
  171.  
  172.   SaleableCourse.fromJson(Map<String, dynamic> json) {
  173.     id = json['id'];
  174.     date = json['date'];
  175.     stock = json['stock'];
  176.     nomadPrice = json['nomad_price']?.toDouble();
  177.     companyPrice = json['company_price']?.toDouble();
  178.     title = json['title'];
  179.     courseId = json['course_id'];
  180.     planningId = json['planning_id'];
  181.     createdAt = json['created_at'];
  182.     updatedAt = json['updated_at'];
  183.     course = json['course'] != null ? Course.fromJson(json['course']) : null;
  184.   }
  185.  
  186.   Map<String, dynamic> toJson() {
  187.     final Map<String, dynamic> data = Map<String, dynamic>();
  188.     data['id'] = this.id;
  189.     data['date'] = this.date;
  190.     data['stock'] = this.stock;
  191.     data['nomad_price'] = this.nomadPrice;
  192.     data['company_price'] = this.companyPrice;
  193.     data['title'] = this.title;
  194.     data['course_id'] = this.courseId;
  195.     data['planning_id'] = this.planningId;
  196.     data['created_at'] = this.createdAt;
  197.     data['updated_at'] = this.updatedAt;
  198.     if (this.course != null) {
  199.       data['course'] = this.course!.toJson();
  200.     }
  201.     return data;
  202.   }
  203. }
  204.  
  205. class SaleableDayPass {
  206.   String? id;
  207.   int? dayOrder;
  208.   String? partnerId;
  209.   String? name;
  210.   double? nomadPrice;
  211.   double? companyPrice;
  212.   String? createdAt;
  213.   String? updatedAt;
  214.  
  215.   SaleableDayPass({
  216.     this.id,
  217.     this.dayOrder,
  218.     this.partnerId,
  219.     this.name,
  220.     this.nomadPrice,
  221.     this.companyPrice,
  222.     this.createdAt,
  223.     this.updatedAt,
  224.   });
  225.  
  226.   SaleableDayPass.fromJson(Map<String, dynamic> json) {
  227.     id = json['id'];
  228.     dayOrder = json['day_order'];
  229.     partnerId = json['partner_id'];
  230.     name = json['name'];
  231.     nomadPrice = json['nomad_price'].toDouble() ?? null;
  232.     companyPrice = json['company_price'].toDouble() ?? null;
  233.     createdAt = json['created_at'];
  234.     updatedAt = json['updated_at'];
  235.   }
  236.  
  237.   Map<String, dynamic> toJson() {
  238.     final Map<String, dynamic> data = Map<String, dynamic>();
  239.     data['id'] = this.id;
  240.     data['day_order'] = this.dayOrder;
  241.     data['partner_id'] = this.partnerId;
  242.     data['name'] = this.name;
  243.     data['nomad_price'] = this.nomadPrice;
  244.     data['company_price'] = this.companyPrice;
  245.     data['created_at'] = this.createdAt;
  246.     data['updated_at'] = this.updatedAt;
  247.     return data;
  248.   }
  249. }
  250.  
  251. class SaleableEvent {
  252.   String? id;
  253.   String? name;
  254.   String? description;
  255.   String? startDate;
  256.   String? endDate;
  257.   double? nomadPrice;
  258.   double? companyPrice;
  259.   String? image;
  260.   int? stock;
  261.   int? level;
  262.   String? activityId;
  263.   String? partnerId;
  264.   String? createdAt;
  265.   String? updatedAt;
  266.  
  267.   SaleableEvent({
  268.     this.id,
  269.     this.name,
  270.     this.description,
  271.     this.startDate,
  272.     this.endDate,
  273.     this.nomadPrice,
  274.     this.image,
  275.     this.stock,
  276.     this.level,
  277.     this.activityId,
  278.     this.partnerId,
  279.     this.createdAt,
  280.     this.updatedAt,
  281.   });
  282.  
  283.   SaleableEvent.fromJson(Map<String, dynamic> json) {
  284.     id = json['id'];
  285.     name = json['name'];
  286.     description = json['description'];
  287.     startDate = json['start_date'];
  288.     endDate = json['end_date'];
  289.     nomadPrice = json['nomad_price']?.toDouble();
  290.     companyPrice = json['company_price']?.toDouble();
  291.     image = json['image'];
  292.     stock = json['stock'];
  293.     level = json['level'];
  294.     activityId = json['activity_id'];
  295.     partnerId = json['partner_id'];
  296.     createdAt = json['created_at'];
  297.     updatedAt = json['updated_at'];
  298.   }
  299.  
  300.   Map<String, dynamic> toJson() {
  301.     final Map<String, dynamic> data = Map<String, dynamic>();
  302.     data['id'] = this.id;
  303.     data['name'] = this.name;
  304.     data['description'] = this.description;
  305.     data['start_date'] = this.startDate;
  306.     data['end_date'] = this.endDate;
  307.     data['nomad_price'] = this.nomadPrice;
  308.     data['company_price'] = this.companyPrice;
  309.     data['image'] = this.image;
  310.     data['stock'] = this.stock;
  311.     data['level'] = this.level;
  312.     data['activity_id'] = this.activityId;
  313.     data['partner_id'] = this.partnerId;
  314.     data['created_at'] = this.createdAt;
  315.     data['updated_at'] = this.updatedAt;
  316.     return data;
  317.   }
  318. }
  319.  
  320. class SaleableSubscription {
  321.   String? id;
  322.   String? name;
  323.   String? description;
  324.   double? nomadPrice;
  325.   double? companyPrice;
  326.   int? stock;
  327.   int? initialStock;
  328.   int? numberOfUse;
  329.   int? duration;
  330.   String? image;
  331.   String? createdAt;
  332.   String? updatedAt;
  333.   String? deletedAt;
  334.  
  335.   SaleableSubscription(
  336.       {this.id,
  337.       this.name,
  338.       this.description,
  339.       this.nomadPrice,
  340.       this.companyPrice,
  341.       this.stock,
  342.       this.initialStock,
  343.       this.numberOfUse,
  344.       this.duration,
  345.       this.image,
  346.       this.createdAt,
  347.       this.updatedAt,
  348.       this.deletedAt});
  349.  
  350.   SaleableSubscription.fromJson(Map<String, dynamic> json) {
  351.     id = json['id'];
  352.     name = json['name'];
  353.     description = json['description'];
  354.     nomadPrice = json['nomad_price']?.toDouble();
  355.     companyPrice = json['company_price']?.toDouble();
  356.     stock = json['stock'];
  357.     initialStock = json['initial_stock'];
  358.     numberOfUse = json['number_of_use'];
  359.     duration = json['duration'];
  360.     image = json['image'];
  361.     createdAt = json['created_at'];
  362.     updatedAt = json['updated_at'];
  363.     deletedAt = json['deleted_at'];
  364.   }
  365.  
  366.   Map<String, dynamic> toJson() {
  367.     final Map<String, dynamic> data = new Map<String, dynamic>();
  368.     data['id'] = this.id;
  369.     data['name'] = this.name;
  370.     data['description'] = this.description;
  371.     data['nomad_price'] = this.nomadPrice;
  372.     data['company_price'] = this.companyPrice;
  373.     data['stock'] = this.stock;
  374.     data['initial_stock'] = this.initialStock;
  375.     data['number_of_use'] = this.numberOfUse;
  376.     data['duration'] = this.duration;
  377.     data['image'] = this.image;
  378.     data['created_at'] = this.createdAt;
  379.     data['updated_at'] = this.updatedAt;
  380.     data['deleted_at'] = this.deletedAt;
  381.     return data;
  382.   }
  383. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement