Skip to content

Instantly share code, notes, and snippets.

@M001T
Created April 15, 2021 18:34
Show Gist options
  • Save M001T/7a9af20481c4ba54e0f1fcca907e914d to your computer and use it in GitHub Desktop.
Save M001T/7a9af20481c4ba54e0f1fcca907e914d to your computer and use it in GitHub Desktop.
Modelo da Model
class AnuncioModel {
String id;
String classPdtId;
String pdtId;
String content;
String stock;
String price;
String isOrganic;
String addrFull;
String addrState;
String updatedAt;
String userName;
String pdtTitle;
String patronized;
String transaction;
String unity;
String originStateFull;
PostUser postUser;
Product product;
List<dynamic> gallery;
String unityFormat;
AnuncioModel(
{this.id,
this.classPdtId,
this.pdtId,
this.content,
this.stock,
this.price,
this.isOrganic,
this.addrFull,
this.addrState,
this.updatedAt,
this.userName,
this.pdtTitle,
this.patronized,
this.transaction,
this.unity,
this.originStateFull,
this.postUser,
this.product,
this.gallery,
this.unityFormat});
AnuncioModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
classPdtId = json['class_pdt_id'];
pdtId = json['pdt_id'];
content = json['content'];
stock = json['stock'];
price = json['price'];
isOrganic = json['is_organic'];
addrFull = json['addr_full'];
addrState = json['addr_state'];
updatedAt = json['updated_at'];
userName = json['user_name'];
pdtTitle = json['pdt_title'];
patronized = json['patronized'];
transaction = json['transaction'];
unity = json['unity'];
originStateFull = json['origin_state_full'];
postUser = json['post_user'] != null
? new PostUser.fromJson(json['post_user'])
: null;
product =
json['product'] != null ? new Product.fromJson(json['product']) : null;
gallery = json['gallery'];
unityFormat = json['unity_format'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['class_pdt_id'] = this.classPdtId;
data['pdt_id'] = this.pdtId;
data['content'] = this.content;
data['stock'] = this.stock;
data['price'] = this.price;
data['is_organic'] = this.isOrganic;
data['addr_full'] = this.addrFull;
data['addr_state'] = this.addrState;
data['updated_at'] = this.updatedAt;
data['user_name'] = this.userName;
data['pdt_title'] = this.pdtTitle;
data['patronized'] = this.patronized;
data['transaction'] = this.transaction;
data['unity'] = this.unity;
data['origin_state_full'] = this.originStateFull;
if (this.postUser != null) {
data['post_user'] = this.postUser.toJson();
}
if (this.product != null) {
data['product'] = this.product.toJson();
}
data['gallery'] = this.gallery;
data['unity_format'] = this.unityFormat;
return data;
}
}
class PostUser {
String id;
String name;
String email;
String document;
String phone;
String cell;
String avatar;
String activity;
String notificationToken;
PostUser(
{this.id,
this.name,
this.email,
this.document,
this.phone,
this.cell,
this.avatar,
this.activity,
this.notificationToken});
PostUser.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
email = json['email'];
document = json['document'];
phone = json['phone'];
cell = json['cell'];
avatar = json['avatar'];
activity = json['activity'];
notificationToken = json['notification_token'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['email'] = this.email;
data['document'] = this.document;
data['phone'] = this.phone;
data['cell'] = this.cell;
data['avatar'] = this.avatar;
data['activity'] = this.activity;
data['notification_token'] = this.notificationToken;
return data;
}
}
class Product {
String pdtId;
String pdtTitle;
String pdtName;
String pdtCreated;
String image;
Category category;
Product(
{this.pdtId, this.pdtTitle, this.pdtName, this.pdtCreated, this.image});
Product.fromJson(Map<String, dynamic> json) {
category = json['category'] != null
? new Category.fromJson(json['category'])
: null;
pdtId = json['pdt_id'];
pdtTitle = json['pdt_title'];
pdtName = json['pdt_name'];
pdtCreated = json['pdt_created'];
image = json['image'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['pdt_id'] = this.pdtId;
data['pdt_title'] = this.pdtTitle;
data['pdt_name'] = this.pdtName;
data['pdt_created'] = this.pdtCreated;
data['image'] = this.image;
data['category'] = this.category;
return data;
}
}
class Category {
String catId;
String catTitle;
String catName;
String catCreated;
String catParent;
Category(
{this.catId,
this.catTitle,
this.catName,
this.catCreated,
this.catParent});
Category.fromJson(Map<String, dynamic> json) {
catId = json['cat_id'];
catTitle = json['cat_title'];
catName = json['cat_name'];
catCreated = json['cat_created'];
catParent = json['cat_parent'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['cat_id'] = this.catId;
data['cat_title'] = this.catTitle;
data['cat_name'] = this.catName;
data['cat_created'] = this.catCreated;
data['cat_parent'] = this.catParent;
return data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment