Add: new item interfaces and category interface
This commit is contained in:
@@ -1,5 +1,27 @@
|
||||
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;
|
||||
@@ -44,7 +66,7 @@ class GymItem {
|
||||
"title": title,
|
||||
"description": description,
|
||||
"count": count,
|
||||
"price": price * 100,
|
||||
"price": price,
|
||||
"categoryId": categoryId,
|
||||
"images": List<dynamic>.from(images.map((x) => x.toJson())),
|
||||
};
|
||||
@@ -78,3 +100,51 @@ class GymImage {
|
||||
"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,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user