428 lines
12 KiB
Dart
428 lines
12 KiB
Dart
import 'dart:convert';
|
|
|
|
DetailModel detailModelFromJson(String str) =>
|
|
DetailModel.fromJson(json.decode(str));
|
|
|
|
String detailModelToJson(DetailModel data) => json.encode(data.toJson());
|
|
|
|
class DetailModel {
|
|
final int? id;
|
|
final String? name;
|
|
final String? slug;
|
|
final String? permalink;
|
|
final String? dateCreated;
|
|
final String? dateCreatedGmt;
|
|
final String? dateModified;
|
|
final String? dateModifiedGmt;
|
|
final String? type;
|
|
final String? status;
|
|
final bool? featured;
|
|
final String? catalogVisibility;
|
|
final String? description;
|
|
final String? shortDescription;
|
|
final String? sku;
|
|
final String? price;
|
|
final String? regularPrice;
|
|
final String? salePrice;
|
|
final bool? onSale;
|
|
final bool? purchasable;
|
|
final int? totalSales;
|
|
final bool? virtual;
|
|
final bool? downloadable;
|
|
final int? downloadLimit;
|
|
final int? downloadExpiry;
|
|
final String? externalUrl;
|
|
final String? buttonText;
|
|
final String? taxStatus;
|
|
final String? taxClass;
|
|
final bool? manageStock;
|
|
final int? stockQuantity;
|
|
final String? backorders;
|
|
final bool? backordersAllowed;
|
|
final bool? backordered;
|
|
final bool? soldIndividually;
|
|
final String? weight;
|
|
final Dimensions? dimensions;
|
|
final bool? shippingRequired;
|
|
final bool? shippingTaxable;
|
|
final String? shippingClass;
|
|
final int? shippingClassId;
|
|
final bool? reviewsAllowed;
|
|
final String? averageRating;
|
|
final int? ratingCount;
|
|
final int? parentId;
|
|
final String? purchaseNote;
|
|
final List<Category>? categories;
|
|
final List<dynamic>? brands;
|
|
final List<Tag>? tags;
|
|
final List<ImageModel>? images;
|
|
final List<Attribute>? attributes;
|
|
final List<dynamic>? defaultAttributes;
|
|
final List<int>? variations;
|
|
final List<dynamic>? groupedProducts;
|
|
final int? menuOrder;
|
|
final String? priceHtml;
|
|
final List<int>? relatedIds;
|
|
final List<MetaData>? metaData;
|
|
final String? stockStatus;
|
|
final bool? hasOptions;
|
|
final String? postPassword;
|
|
final String? globalUniqueId;
|
|
|
|
DetailModel({
|
|
this.id,
|
|
this.name,
|
|
this.slug,
|
|
this.permalink,
|
|
this.dateCreated,
|
|
this.dateCreatedGmt,
|
|
this.dateModified,
|
|
this.dateModifiedGmt,
|
|
this.type,
|
|
this.status,
|
|
this.featured,
|
|
this.catalogVisibility,
|
|
this.description,
|
|
this.shortDescription,
|
|
this.sku,
|
|
this.price,
|
|
this.regularPrice,
|
|
this.salePrice,
|
|
this.onSale,
|
|
this.purchasable,
|
|
this.totalSales,
|
|
this.virtual,
|
|
this.downloadable,
|
|
this.downloadLimit,
|
|
this.downloadExpiry,
|
|
this.externalUrl,
|
|
this.buttonText,
|
|
this.taxStatus,
|
|
this.taxClass,
|
|
this.manageStock,
|
|
this.stockQuantity,
|
|
this.backorders,
|
|
this.backordersAllowed,
|
|
this.backordered,
|
|
this.soldIndividually,
|
|
this.weight,
|
|
this.dimensions,
|
|
this.shippingRequired,
|
|
this.shippingTaxable,
|
|
this.shippingClass,
|
|
this.shippingClassId,
|
|
this.reviewsAllowed,
|
|
this.averageRating,
|
|
this.ratingCount,
|
|
this.parentId,
|
|
this.purchaseNote,
|
|
this.categories,
|
|
this.brands,
|
|
this.tags,
|
|
this.images,
|
|
this.attributes,
|
|
this.defaultAttributes,
|
|
this.variations,
|
|
this.groupedProducts,
|
|
this.menuOrder,
|
|
this.priceHtml,
|
|
this.relatedIds,
|
|
this.metaData,
|
|
this.stockStatus,
|
|
this.hasOptions,
|
|
this.postPassword,
|
|
this.globalUniqueId,
|
|
});
|
|
|
|
factory DetailModel.fromJson(Map<String, dynamic> json) => DetailModel(
|
|
id: json["id"],
|
|
name: json["name"],
|
|
slug: json["slug"],
|
|
permalink: json["permalink"],
|
|
dateCreated: json["date_created"],
|
|
dateCreatedGmt: json["date_created_gmt"],
|
|
dateModified: json["date_modified"],
|
|
dateModifiedGmt: json["date_modified_gmt"],
|
|
type: json["type"],
|
|
status: json["status"],
|
|
featured: json["featured"],
|
|
catalogVisibility: json["catalog_visibility"],
|
|
description: json["description"],
|
|
shortDescription: json["short_description"],
|
|
sku: json["sku"],
|
|
price: json["price"],
|
|
regularPrice: json["regular_price"],
|
|
salePrice: json["sale_price"],
|
|
onSale: json["on_sale"],
|
|
purchasable: json["purchasable"],
|
|
totalSales: json["total_sales"],
|
|
virtual: json["virtual"],
|
|
downloadable: json["downloadable"],
|
|
downloadLimit: json["download_limit"],
|
|
downloadExpiry: json["download_expiry"],
|
|
externalUrl: json["external_url"],
|
|
buttonText: json["button_text"],
|
|
taxStatus: json["tax_status"],
|
|
taxClass: json["tax_class"],
|
|
manageStock: json["manage_stock"],
|
|
stockQuantity: json["stock_quantity"],
|
|
backorders: json["backorders"],
|
|
backordersAllowed: json["backorders_allowed"],
|
|
backordered: json["backordered"],
|
|
soldIndividually: json["sold_individually"],
|
|
weight: json["weight"],
|
|
dimensions: json["dimensions"] != null
|
|
? Dimensions.fromJson(json["dimensions"])
|
|
: null,
|
|
shippingRequired: json["shipping_required"],
|
|
shippingTaxable: json["shipping_taxable"],
|
|
shippingClass: json["shipping_class"],
|
|
shippingClassId: json["shipping_class_id"],
|
|
reviewsAllowed: json["reviews_allowed"],
|
|
averageRating: json["average_rating"],
|
|
ratingCount: json["rating_count"],
|
|
parentId: json["parent_id"],
|
|
purchaseNote: json["purchase_note"],
|
|
categories: json["categories"] == null
|
|
? []
|
|
: List<Category>.from(
|
|
json["categories"].map((x) => Category.fromJson(x)),
|
|
),
|
|
brands: json["brands"] ?? [],
|
|
tags: json["tags"] == null
|
|
? []
|
|
: List<Tag>.from(json["tags"].map((x) => Tag.fromJson(x))),
|
|
images: json["images"] == null
|
|
? []
|
|
: List<ImageModel>.from(
|
|
json["images"].map((x) => ImageModel.fromJson(x)),
|
|
),
|
|
attributes: json["attributes"] == null
|
|
? []
|
|
: List<Attribute>.from(
|
|
json["attributes"].map((x) => Attribute.fromJson(x)),
|
|
),
|
|
defaultAttributes: json["default_attributes"] ?? [],
|
|
variations: json["variations"] == null
|
|
? []
|
|
: List<int>.from(json["variations"].map((x) => x)),
|
|
groupedProducts: json["grouped_products"] ?? [],
|
|
menuOrder: json["menu_order"],
|
|
priceHtml: json["price_html"],
|
|
relatedIds: json["related_ids"] == null
|
|
? []
|
|
: List<int>.from(json["related_ids"].map((x) => x)),
|
|
metaData: json["meta_data"] == null
|
|
? []
|
|
: List<MetaData>.from(
|
|
json["meta_data"].map((x) => MetaData.fromJson(x)),
|
|
),
|
|
stockStatus: json["stock_status"],
|
|
hasOptions: json["has_options"],
|
|
postPassword: json["post_password"],
|
|
globalUniqueId: json["global_unique_id"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"name": name,
|
|
"slug": slug,
|
|
"permalink": permalink,
|
|
"date_created": dateCreated,
|
|
"date_created_gmt": dateCreatedGmt,
|
|
"date_modified": dateModified,
|
|
"date_modified_gmt": dateModifiedGmt,
|
|
"type": type,
|
|
"status": status,
|
|
"featured": featured,
|
|
"catalog_visibility": catalogVisibility,
|
|
"description": description,
|
|
"short_description": shortDescription,
|
|
"sku": sku,
|
|
"price": price,
|
|
"regular_price": regularPrice,
|
|
"sale_price": salePrice,
|
|
"on_sale": onSale,
|
|
"purchasable": purchasable,
|
|
"total_sales": totalSales,
|
|
"virtual": virtual,
|
|
"downloadable": downloadable,
|
|
"download_limit": downloadLimit,
|
|
"download_expiry": downloadExpiry,
|
|
"external_url": externalUrl,
|
|
"button_text": buttonText,
|
|
"tax_status": taxStatus,
|
|
"tax_class": taxClass,
|
|
"manage_stock": manageStock,
|
|
"stock_quantity": stockQuantity,
|
|
"backorders": backorders,
|
|
"backorders_allowed": backordersAllowed,
|
|
"backordered": backordered,
|
|
"sold_individually": soldIndividually,
|
|
"weight": weight,
|
|
"dimensions": dimensions?.toJson(),
|
|
"shipping_required": shippingRequired,
|
|
"shipping_taxable": shippingTaxable,
|
|
"shipping_class": shippingClass,
|
|
"shipping_class_id": shippingClassId,
|
|
"reviews_allowed": reviewsAllowed,
|
|
"average_rating": averageRating,
|
|
"rating_count": ratingCount,
|
|
"parent_id": parentId,
|
|
"purchase_note": purchaseNote,
|
|
"categories": categories?.map((x) => x.toJson()).toList(),
|
|
"brands": brands,
|
|
"tags": tags?.map((x) => x.toJson()).toList(),
|
|
"images": images?.map((x) => x.toJson()).toList(),
|
|
"attributes": attributes?.map((x) => x.toJson()).toList(),
|
|
"default_attributes": defaultAttributes,
|
|
"variations": variations,
|
|
"grouped_products": groupedProducts,
|
|
"menu_order": menuOrder,
|
|
"price_html": priceHtml,
|
|
"related_ids": relatedIds,
|
|
"meta_data": metaData?.map((x) => x.toJson()).toList(),
|
|
"stock_status": stockStatus,
|
|
"has_options": hasOptions,
|
|
"post_password": postPassword,
|
|
"global_unique_id": globalUniqueId,
|
|
};
|
|
}
|
|
|
|
class Dimensions {
|
|
final String? length;
|
|
final String? width;
|
|
final String? height;
|
|
|
|
Dimensions({this.length, this.width, this.height});
|
|
|
|
factory Dimensions.fromJson(Map<String, dynamic> json) => Dimensions(
|
|
length: json["length"],
|
|
width: json["width"],
|
|
height: json["height"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"length": length,
|
|
"width": width,
|
|
"height": height,
|
|
};
|
|
}
|
|
|
|
class Category {
|
|
final int? id;
|
|
final String? name;
|
|
final String? slug;
|
|
|
|
Category({this.id, this.name, this.slug});
|
|
|
|
factory Category.fromJson(Map<String, dynamic> json) =>
|
|
Category(id: json["id"], name: json["name"], slug: json["slug"]);
|
|
|
|
Map<String, dynamic> toJson() => {"id": id, "name": name, "slug": slug};
|
|
}
|
|
|
|
class Tag {
|
|
final int? id;
|
|
final String? name;
|
|
final String? slug;
|
|
|
|
Tag({this.id, this.name, this.slug});
|
|
|
|
factory Tag.fromJson(Map<String, dynamic> json) =>
|
|
Tag(id: json["id"], name: json["name"], slug: json["slug"]);
|
|
|
|
Map<String, dynamic> toJson() => {"id": id, "name": name, "slug": slug};
|
|
}
|
|
|
|
class ImageModel {
|
|
final int? id;
|
|
final String? dateCreated;
|
|
final String? dateModified;
|
|
final String? src;
|
|
final String? name;
|
|
final String? alt;
|
|
|
|
ImageModel({
|
|
this.id,
|
|
this.dateCreated,
|
|
this.dateModified,
|
|
this.src,
|
|
this.name,
|
|
this.alt,
|
|
});
|
|
|
|
factory ImageModel.fromJson(Map<String, dynamic> json) => ImageModel(
|
|
id: json["id"],
|
|
dateCreated: json["date_created"],
|
|
dateModified: json["date_modified"],
|
|
src: json["src"],
|
|
name: json["name"],
|
|
alt: json["alt"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"date_created": dateCreated,
|
|
"date_modified": dateModified,
|
|
"src": src,
|
|
"name": name,
|
|
"alt": alt,
|
|
};
|
|
}
|
|
|
|
class Attribute {
|
|
final int? id;
|
|
final String? name;
|
|
final String? slug;
|
|
final int? position;
|
|
final bool? visible;
|
|
final bool? variation;
|
|
final List<String>? options;
|
|
|
|
Attribute({
|
|
this.id,
|
|
this.name,
|
|
this.slug,
|
|
this.position,
|
|
this.visible,
|
|
this.variation,
|
|
this.options,
|
|
});
|
|
|
|
factory Attribute.fromJson(Map<String, dynamic> json) => Attribute(
|
|
id: json["id"],
|
|
name: json["name"],
|
|
slug: json["slug"],
|
|
position: json["position"],
|
|
visible: json["visible"],
|
|
variation: json["variation"],
|
|
options: json["options"] == null
|
|
? []
|
|
: List<String>.from(json["options"].map((x) => x)),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"name": name,
|
|
"slug": slug,
|
|
"position": position,
|
|
"visible": visible,
|
|
"variation": variation,
|
|
"options": options,
|
|
};
|
|
}
|
|
|
|
class MetaData {
|
|
final int? id;
|
|
final String? key;
|
|
final dynamic value;
|
|
|
|
MetaData({this.id, this.key, this.value});
|
|
|
|
factory MetaData.fromJson(Map<String, dynamic> json) =>
|
|
MetaData(id: json["id"], key: json["key"], value: json["value"]);
|
|
|
|
Map<String, dynamic> toJson() => {"id": id, "key": key, "value": value};
|
|
}
|