151 lines
3.5 KiB
Dart
151 lines
3.5 KiB
Dart
import 'dart:convert';
|
|
|
|
class ItemsDataResponse {
|
|
final List<GymItem> rows;
|
|
|
|
ItemsDataResponse({
|
|
required this.rows,
|
|
});
|
|
|
|
factory ItemsDataResponse.fromRawJson(String str) =>
|
|
ItemsDataResponse.fromJson(json.decode(str));
|
|
|
|
String toRawJson() => json.encode(toJson());
|
|
|
|
factory ItemsDataResponse.fromJson(Map<String, dynamic> json) =>
|
|
ItemsDataResponse(
|
|
rows: List<GymItem>.from(json["rows"].map((x) => GymItem.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"rows": List<dynamic>.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<GymImage> 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<String, dynamic> 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<GymImage>.from(
|
|
json["images"].map((x) => GymImage.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"ExternalId": externalId,
|
|
"title": title,
|
|
"description": description,
|
|
"count": count,
|
|
"price": price,
|
|
"categoryId": categoryId,
|
|
"images": List<dynamic>.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<String, dynamic> json) => GymImage(
|
|
id: json["id"],
|
|
deletedAt: json["deletedAt"],
|
|
url: json["url"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"deletedAt": deletedAt,
|
|
"url": url,
|
|
};
|
|
}
|
|
|
|
class CategoryDataResponse {
|
|
final List<GymCategory> rows;
|
|
|
|
CategoryDataResponse({
|
|
required this.rows,
|
|
});
|
|
|
|
factory CategoryDataResponse.fromRawJson(String str) =>
|
|
CategoryDataResponse.fromJson(json.decode(str));
|
|
|
|
String toRawJson() => json.encode(toJson());
|
|
|
|
factory CategoryDataResponse.fromJson(Map<String, dynamic> json) =>
|
|
CategoryDataResponse(
|
|
rows: List<GymCategory>.from(
|
|
json["rows"].map((x) => GymCategory.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"rows": List<dynamic>.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<String, dynamic> json) => GymCategory(
|
|
id: json["id"],
|
|
name: json["name"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"name": name,
|
|
};
|
|
}
|