sc-android-app/lib/models/products_response.dart

168 lines
4.0 KiB
Dart

class ProductResponse {
bool? success;
int? totalData;
int? totalPages;
List<Products>? products;
ProductResponse(
{this.success, this.totalData, this.totalPages, this.products});
ProductResponse.fromJson(Map<String, dynamic> json) {
success = json['success'];
totalData = json['total_data'];
totalPages = json['total_pages'];
if (json['products'] != null) {
products = <Products>[];
json['products'].forEach((v) {
products!.add(new Products.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['success'] = this.success;
data['total_data'] = this.totalData;
data['total_pages'] = this.totalPages;
if (this.products != null) {
data['products'] = this.products!.map((v) => v.toJson()).toList();
}
return data;
}
}
class Products {
String? sId;
String? sKU;
String? name;
Category? category;
Brand? brand;
int? price;
int? gST;
int? hSNCode;
String? description;
String? productStatus;
AddedBy? addedBy;
String? createdAt;
String? updatedAt;
int? iV;
Products(
{this.sId,
this.sKU,
this.name,
this.category,
this.brand,
this.price,
this.gST,
this.hSNCode,
this.description,
this.productStatus,
this.addedBy,
this.createdAt,
this.updatedAt,
this.iV});
Products.fromJson(Map<String, dynamic> json) {
sId = json['_id'];
sKU = json['SKU'];
name = json['name'];
category = json['category'] != null
? new Category.fromJson(json['category'])
: null;
brand = json['brand'] != null ? new Brand.fromJson(json['brand']) : null;
price = json['price'];
gST = json['GST'];
hSNCode = json['HSN_Code'];
description = json['description'];
productStatus = json['product_Status'];
addedBy =
json['addedBy'] != null ? new AddedBy.fromJson(json['addedBy']) : null;
createdAt = json['createdAt'];
updatedAt = json['updatedAt'];
iV = json['__v'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['_id'] = this.sId;
data['SKU'] = this.sKU;
data['name'] = this.name;
if (this.category != null) {
data['category'] = this.category!.toJson();
}
if (this.brand != null) {
data['brand'] = this.brand!.toJson();
}
data['price'] = this.price;
data['GST'] = this.gST;
data['HSN_Code'] = this.hSNCode;
data['description'] = this.description;
data['product_Status'] = this.productStatus;
if (this.addedBy != null) {
data['addedBy'] = this.addedBy!.toJson();
}
data['createdAt'] = this.createdAt;
data['updatedAt'] = this.updatedAt;
data['__v'] = this.iV;
return data;
}
}
class Category {
String? sId;
String? categoryName;
Category({this.sId, this.categoryName});
Category.fromJson(Map<String, dynamic> json) {
sId = json['_id'];
categoryName = json['categoryName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['_id'] = this.sId;
data['categoryName'] = this.categoryName;
return data;
}
}
class Brand {
String? sId;
String? brandName;
Brand({this.sId, this.brandName});
Brand.fromJson(Map<String, dynamic> json) {
sId = json['_id'];
brandName = json['brandName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['_id'] = this.sId;
data['brandName'] = this.brandName;
return data;
}
}
class AddedBy {
String? sId;
String? name;
AddedBy({this.sId, this.name});
AddedBy.fromJson(Map<String, dynamic> json) {
sId = json['_id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['_id'] = this.sId;
data['name'] = this.name;
return data;
}
}