implementsProdctApi

This commit is contained in:
bestonemitRam
2025-01-27 01:11:20 +05:30
parent 9e559bdded
commit cbeaa2af5c
24 changed files with 2231 additions and 1026 deletions

93
lib/src/data/banners.dart Normal file
View File

@@ -0,0 +1,93 @@
// To parse this JSON data, do
//
// final banner = bannerFromJson(jsonString);
import 'dart:convert';
BannerModel bannerFromJson(String str) => BannerModel.fromJson(json.decode(str));
String bannerToJson(BannerModel data) => json.encode(data.toJson());
class BannerModel {
List<BannerData>? data;
Meta? meta;
BannerModel({
this.data,
this.meta,
});
factory BannerModel.fromJson(Map<String, dynamic> json) => BannerModel(
data: List<BannerData>.from(json["data"].map((x) => BannerData.fromJson(x))),
meta: Meta.fromJson(json["meta"]),
);
Map<String, dynamic> toJson() => {
"data": List<dynamic>.from(data!.map((x) => x.toJson())),
"meta": meta!.toJson(),
};
}
class BannerData {
dynamic? id;
dynamic? imageUrl;
dynamic? redirectUrl;
dynamic altText;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
BannerData({
this.id,
this.imageUrl,
this.redirectUrl,
this.altText,
this.isActive,
this.createdAt,
this.updatedAt,
});
factory BannerData.fromJson(Map<String, dynamic> json) => BannerData(
id: json["id"],
imageUrl: json["imageUrl"],
redirectUrl: json["redirectUrl"],
altText: json["altText"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"imageUrl": imageUrl,
"redirectUrl": redirectUrl,
"altText": altText,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
};
}
class Meta {
int? total;
int? page;
int? lastPage;
Meta({
this.total,
this.page,
this.lastPage,
});
factory Meta.fromJson(Map<String, dynamic> json) => Meta(
total: json["total"],
page: json["page"],
lastPage: json["lastPage"],
);
Map<String, dynamic> toJson() => {
"total": total,
"page": page,
"lastPage": lastPage,
};
}

View File

@@ -0,0 +1,317 @@
// To parse this JSON data, do
//
// final bestDealProduct = bestDealProductFromJson(jsondynamic);
import 'dart:convert';
BestDealProduct bestDealProductFromJson(dynamic str) => BestDealProduct.fromJson(json.decode(str));
dynamic bestDealProductToJson(BestDealProduct data) => json.encode(data.toJson());
class BestDealProduct {
List<BestDeal>? data;
Meta? meta;
BestDealProduct({
this.data,
this.meta,
});
factory BestDealProduct.fromJson(Map<dynamic, dynamic> json) => BestDealProduct(
data: List<BestDeal>.from(json["data"].map((x) => BestDeal.fromJson(x))),
meta: Meta.fromJson(json["meta"]),
);
Map<dynamic, dynamic> toJson() => {
"data": List<dynamic>.from(data!.map((x) => x.toJson())),
"meta": meta!.toJson(),
};
}
class BestDeal {
dynamic id;
dynamic name;
dynamic description;
dynamic additionalInfo;
dynamic brand;
dynamic basePrice;
dynamic discountPrice;
dynamic stock;
dynamic quantity;
dynamic unit;
dynamic slug;
dynamic rating;
bool? isInStock;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic storeId;
dynamic categoryId;
dynamic productTypeId;
dynamic timeSlotId;
Store? store;
Category? category;
List<ProductImage>? productImages;
List<dynamic>? productReview;
dynamic averageRating;
dynamic discountPercentage;
double? bestDealScore;
BestDeal({
this.id,
this.name,
this.description,
this.additionalInfo,
this.brand,
this.basePrice,
this.discountPrice,
this.stock,
this.quantity,
this.unit,
this.slug,
this.rating,
this.isInStock,
this.isActive,
this.createdAt,
this.updatedAt,
this.storeId,
this.categoryId,
this.productTypeId,
this.timeSlotId,
this.store,
this.category,
this.productImages,
this.productReview,
this.averageRating,
this.discountPercentage,
this.bestDealScore,
});
factory BestDeal.fromJson(Map<dynamic, dynamic> json) => BestDeal(
id: json["id"],
name: json["name"],
description: json["description"],
additionalInfo: json["additionalInfo"],
brand: json["brand"],
basePrice: json["basePrice"],
discountPrice: json["discountPrice"],
stock: json["stock"],
quantity: json["quantity"],
unit: json["unit"],
slug: json["slug"],
rating: json["rating"],
isInStock: json["isInStock"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
storeId: json["storeId"],
categoryId: json["categoryId"],
productTypeId: json["productTypeId"],
timeSlotId: json["timeSlotId"],
store: Store.fromJson(json["store"]),
category: Category.fromJson(json["category"]),
productImages: List<ProductImage>.from(json["productImages"].map((x) => ProductImage.fromJson(x))),
productReview: List<dynamic>.from(json["ProductReview"].map((x) => x)),
averageRating: json["averageRating"],
discountPercentage: json["discountPercentage"],
bestDealScore: json["bestDealScore"].toDouble(),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"additionalInfo": additionalInfo,
"brand": brand,
"basePrice": basePrice,
"discountPrice": discountPrice,
"stock": stock,
"quantity": quantity,
"unit": unit,
"slug": slug,
"rating": rating,
"isInStock": isInStock,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
"storeId": storeId,
"categoryId": categoryId,
"productTypeId": productTypeId,
"timeSlotId": timeSlotId,
"store": store!.toJson(),
"category": category!.toJson(),
"productImages": List<dynamic>.from(productImages!.map((x) => x.toJson())),
"ProductReview": List<dynamic>.from(productReview!.map((x) => x)),
"averageRating": averageRating,
"discountPercentage": discountPercentage,
"bestDealScore": bestDealScore,
};
}
class Category {
dynamic id;
dynamic name;
dynamic description;
dynamic image;
dynamic slug;
dynamic level;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic parentCategoryId;
dynamic path;
Category({
this.id,
this.name,
this.description,
this.image,
this.slug,
this.level,
this.isActive,
this.createdAt,
this.updatedAt,
this.parentCategoryId,
this.path,
});
factory Category.fromJson(Map<dynamic, dynamic> json) => Category(
id: json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
slug: json["slug"],
level: json["level"],
isActive: json["isActive"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
parentCategoryId: json["parentCategoryId"],
path: json["path"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"image": image,
"slug": slug,
"level": level,
"isActive": isActive,
"createdAt": createdAt,
"updatedAt": updatedAt,
"parentCategoryId": parentCategoryId,
"path": path,
};
}
class ProductImage {
dynamic id;
dynamic url;
bool? isDefault;
dynamic productId;
ProductImage({
this.id,
this.url,
this.isDefault,
this.productId,
});
factory ProductImage.fromJson(Map<dynamic, dynamic> json) => ProductImage(
id: json["id"],
url: json["url"],
isDefault: json["isDefault"],
productId: json["productId"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"url": url,
"isDefault": isDefault,
"productId": productId,
};
}
class Store {
dynamic id;
dynamic storeName;
dynamic storeDescription;
dynamic officialPhoneNumber;
dynamic storeAddress;
dynamic gstNumber;
dynamic gumastaNumber;
dynamic storePicture;
DateTime? createdAt;
DateTime? updatedAt;
dynamic vendorId;
bool? isActive;
Store({
this.id,
this.storeName,
this.storeDescription,
this.officialPhoneNumber,
this.storeAddress,
this.gstNumber,
this.gumastaNumber,
this.storePicture,
this.createdAt,
this.updatedAt,
this.vendorId,
this.isActive,
});
factory Store.fromJson(Map<dynamic, dynamic> json) => Store(
id: json["id"],
storeName: json["storeName"],
storeDescription: json["storeDescription"],
officialPhoneNumber: json["officialPhoneNumber"],
storeAddress: json["storeAddress"],
gstNumber: json["gstNumber"],
gumastaNumber: json["gumastaNumber"],
storePicture: json["storePicture"],
createdAt: DateTime.parse(json["createdAt"]),
updatedAt: DateTime.parse(json["updatedAt"]),
vendorId: json["vendorId"],
isActive: json["isActive"],
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"storeName": storeName,
"storeDescription": storeDescription,
"officialPhoneNumber": officialPhoneNumber,
"storeAddress": storeAddress,
"gstNumber": gstNumber,
"gumastaNumber": gumastaNumber,
"storePicture": storePicture,
"createdAt": createdAt,
"updatedAt": updatedAt,
"vendorId": vendorId,
"isActive": isActive,
};
}
class Meta {
dynamic total;
dynamic page;
dynamic lastPage;
Meta({
this.total,
this.page,
this.lastPage,
});
factory Meta.fromJson(Map<dynamic, dynamic> json) => Meta(
total: json["total"],
page: json["page"],
lastPage: json["lastPage"],
);
Map<dynamic, dynamic> toJson() => {
"total": total,
"page": page,
"lastPage": lastPage,
};
}

View File

@@ -0,0 +1,212 @@
import 'dart:convert';
ProductCategory productCategoryFromJson(dynamic str) =>
ProductCategory.fromJson(json.decode(str));
dynamic productCategoryToJson(ProductCategory data) =>
json.encode(data.toJson());
class ProductCategory {
List<Datum>? data;
Meta? meta;
ProductCategory({
this.data,
this.meta,
});
factory ProductCategory.fromJson(Map<dynamic, dynamic> json) =>
ProductCategory(
data: json["data"] == null
? []
: List<Datum>.from(json["data"].map((x) => Datum.fromJson(x))),
meta: json["meta"] == null ? null : Meta.fromJson(json["meta"]),
);
Map<dynamic, dynamic> toJson() => {
"data": data == null
? []
: List<dynamic>.from(data!.map((x) => x.toJson())),
"meta": meta?.toJson(),
};
}
class Datum {
dynamic id;
dynamic name;
dynamic description;
dynamic image;
dynamic slug;
int? level;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic parentCategoryId;
dynamic path;
Category? parentCategory;
List<Category>? childCategories;
Datum({
this.id,
this.name,
this.description,
this.image,
this.slug,
this.level,
this.isActive,
this.createdAt,
this.updatedAt,
this.parentCategoryId,
this.path,
this.parentCategory,
this.childCategories,
});
factory Datum.fromJson(Map<dynamic, dynamic> json) => Datum(
id: json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
slug: json["slug"],
level: json["level"],
isActive: json["isActive"],
createdAt: json["createdAt"] == null
? null
: DateTime.parse(json["createdAt"]),
updatedAt: json["updatedAt"] == null
? null
: DateTime.parse(json["updatedAt"]),
parentCategoryId: json["parentCategoryId"],
path: json["path"],
parentCategory: json["parentCategory"] == null
? null
: Category.fromJson(json["parentCategory"]),
childCategories: json["childCategories"] == null
? []
: List<Category>.from(
json["childCategories"].map((x) => Category.fromJson(x))),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"image": image,
"slug": slug,
"level": level,
"isActive": isActive,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
"parentCategoryId": parentCategoryId,
"path": path,
"parentCategory": parentCategory?.toJson(),
"childCategories": childCategories == null
? []
: List<dynamic>.from(childCategories!.map((x) => x.toJson())),
};
}
class Category {
dynamic id;
dynamic name;
dynamic description;
dynamic image;
dynamic slug;
int? level;
bool? isActive;
DateTime? createdAt;
DateTime? updatedAt;
dynamic parentCategoryId;
dynamic path;
List<Category>? childCategories;
Category({
this.id,
this.name,
this.description,
this.image,
this.slug,
this.level,
this.isActive,
this.createdAt,
this.updatedAt,
this.parentCategoryId,
this.path,
this.childCategories,
});
factory Category.fromJson(Map<dynamic, dynamic> json) => Category(
id: json["id"],
name: json["name"],
description: json["description"],
image: json["image"],
slug: json["slug"],
level: json["level"],
isActive: json["isActive"],
createdAt: json["createdAt"] == null
? null
: DateTime.parse(json["createdAt"]),
updatedAt: json["updatedAt"] == null
? null
: DateTime.parse(json["updatedAt"]),
parentCategoryId: json["parentCategoryId"],
path: json["path"],
childCategories: json["childCategories"] == null
? []
: List<Category>.from(
json["childCategories"].map((x) => Category.fromJson(x))),
);
Map<dynamic, dynamic> toJson() => {
"id": id,
"name": name,
"description": description,
"image": image,
"slug": slug,
"level": level,
"isActive": isActive,
"createdAt": createdAt?.toIso8601String(),
"updatedAt": updatedAt?.toIso8601String(),
"parentCategoryId": parentCategoryId,
"path": path,
"childCategories": childCategories == null
? []
: List<dynamic>.from(childCategories!.map((x) => x.toJson())),
};
}
class Meta {
int? total;
int? page;
int? limit;
int? lastPage;
bool? hasNextPage;
bool? hasPreviousPage;
Meta({
this.total,
this.page,
this.limit,
this.lastPage,
this.hasNextPage,
this.hasPreviousPage,
});
factory Meta.fromJson(Map<dynamic, dynamic> json) => Meta(
total: json["total"],
page: json["page"],
limit: json["limit"],
lastPage: json["lastPage"],
hasNextPage: json["hasNextPage"],
hasPreviousPage: json["hasPreviousPage"],
);
Map<dynamic, dynamic> toJson() => {
"total": total,
"page": page,
"limit": limit,
"lastPage": lastPage,
"hasNextPage": hasNextPage,
"hasPreviousPage": hasPreviousPage,
};
}