|
| 1 | +class ProductsModels { |
| 2 | + int count; |
| 3 | + String next; |
| 4 | + Null previous; |
| 5 | + List<Results> results; |
| 6 | + |
| 7 | + ProductsModels({this.count, this.next, this.previous, this.results}); |
| 8 | + |
| 9 | + ProductsModels.fromJson(Map<String, dynamic> json) { |
| 10 | + count = json['count']; |
| 11 | + next = json['next']; |
| 12 | + previous = json['previous']; |
| 13 | + if (json['results'] != null) { |
| 14 | + results = new List<Results>(); |
| 15 | + json['results'].forEach((v) { |
| 16 | + results.add(new Results.fromJson(v)); |
| 17 | + }); |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + Map<String, dynamic> toJson() { |
| 22 | + final Map<String, dynamic> data = new Map<String, dynamic>(); |
| 23 | + data['count'] = this.count; |
| 24 | + data['next'] = this.next; |
| 25 | + data['previous'] = this.previous; |
| 26 | + if (this.results != null) { |
| 27 | + data['results'] = this.results.map((v) => v.toJson()).toList(); |
| 28 | + } |
| 29 | + return data; |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +class Results { |
| 34 | + String name; |
| 35 | + String slug; |
| 36 | + List<String> imageUrls; |
| 37 | + String priceType; |
| 38 | + String maxPrice; |
| 39 | + String minPrice; |
| 40 | + String minDiscountedPrice; |
| 41 | + |
| 42 | + Results( |
| 43 | + {this.name, |
| 44 | + this.slug, |
| 45 | + this.imageUrls, |
| 46 | + this.priceType, |
| 47 | + this.maxPrice, |
| 48 | + this.minPrice, |
| 49 | + this.minDiscountedPrice}); |
| 50 | + |
| 51 | + Results.fromJson(Map<String, dynamic> json) { |
| 52 | + name = json['name']; |
| 53 | + slug = json['slug']; |
| 54 | + imageUrls = json['image_urls'].cast<String>(); |
| 55 | + priceType = json['price_type']; |
| 56 | + maxPrice = json['max_price']; |
| 57 | + minPrice = json['min_price']; |
| 58 | + minDiscountedPrice = json['min_discounted_price']; |
| 59 | + } |
| 60 | + |
| 61 | + Map<String, dynamic> toJson() { |
| 62 | + final Map<String, dynamic> data = new Map<String, dynamic>(); |
| 63 | + data['name'] = this.name; |
| 64 | + data['slug'] = this.slug; |
| 65 | + data['image_urls'] = this.imageUrls; |
| 66 | + data['price_type'] = this.priceType; |
| 67 | + data['max_price'] = this.maxPrice; |
| 68 | + data['min_price'] = this.minPrice; |
| 69 | + data['min_discounted_price'] = this.minDiscountedPrice; |
| 70 | + return data; |
| 71 | + } |
| 72 | +} |
0 commit comments