import 'dart:convert'; class ItemsDataResponse { final List rows; ItemsDataResponse({ required this.rows, }); factory ItemsDataResponse.fromRawJson(String str) => ItemsDataResponse.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory ItemsDataResponse.fromJson(Map json) => ItemsDataResponse( rows: List.from(json["rows"].map((x) => GymItem.fromJson(x))), ); Map toJson() => { "rows": List.from(rows.map((x) => x.toJson())), }; } class GymItem { final String id; final String externalId; final String title; final String description; final int count; final double price; final String categoryId; final List images; int localCount = 0; GymItem({ required this.id, required this.externalId, required this.title, required this.description, required this.count, required this.price, required this.categoryId, required this.images, }); factory GymItem.fromRawJson(String str) => GymItem.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory GymItem.fromJson(Map json) => GymItem( id: json["id"], externalId: json["ExternalId"], title: json["title"], description: json["description"], count: json["count"], price: json["price"] / 100, categoryId: json["categoryId"], images: List.from( json["images"].map((x) => GymImage.fromJson(x))), ); Map toJson() => { "id": id, "ExternalId": externalId, "title": title, "description": description, "count": count, "price": price, "categoryId": categoryId, "images": List.from(images.map((x) => x.toJson())), }; } class GymImage { final String id; final dynamic deletedAt; final String url; GymImage({ required this.id, required this.deletedAt, required this.url, }); factory GymImage.fromRawJson(String str) => GymImage.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory GymImage.fromJson(Map json) => GymImage( id: json["id"], deletedAt: json["deletedAt"], url: json["url"], ); Map toJson() => { "id": id, "deletedAt": deletedAt, "url": url, }; } class CategoryDataResponse { final List rows; CategoryDataResponse({ required this.rows, }); factory CategoryDataResponse.fromRawJson(String str) => CategoryDataResponse.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory CategoryDataResponse.fromJson(Map json) => CategoryDataResponse( rows: List.from( json["rows"].map((x) => GymCategory.fromJson(x))), ); Map toJson() => { "rows": List.from(rows.map((x) => x.toJson())), }; } class GymCategory { final String id; final String name; GymCategory({ required this.id, required this.name, }); factory GymCategory.fromRawJson(String str) => GymCategory.fromJson(json.decode(str)); String toRawJson() => json.encode(toJson()); factory GymCategory.fromJson(Map json) => GymCategory( id: json["id"], name: json["name"], ); Map toJson() => { "id": id, "name": name, }; }