253 lines
6.1 KiB
Dart
253 lines
6.1 KiB
Dart
import 'package:hoshan/data/model/tools_categories_model.dart';
|
|
|
|
class BotsModel {
|
|
List<Bots>? bots;
|
|
|
|
BotsModel({this.bots});
|
|
|
|
BotsModel.fromJson(Map<String, dynamic> json) {
|
|
if (json['bots'] != null) {
|
|
bots = <Bots>[];
|
|
json['bots'].forEach((v) {
|
|
bots!.add(Bots.fromJson(v));
|
|
});
|
|
}
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
if (bots != null) {
|
|
data['bots'] = bots!.map((v) => v.toJson()).toList();
|
|
}
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class Bots {
|
|
int? id;
|
|
String? image;
|
|
String? image2;
|
|
String? model;
|
|
String? name;
|
|
int? cost;
|
|
int? limit;
|
|
bool? public;
|
|
int? attachment;
|
|
bool? marked;
|
|
bool? tool;
|
|
bool? deleted;
|
|
List<String>? attachmentType;
|
|
|
|
double? score;
|
|
int? comments;
|
|
int? messages;
|
|
int? users;
|
|
String? description;
|
|
String? createdAt;
|
|
String? type;
|
|
User? user;
|
|
Categories? category;
|
|
UserComment? userComment;
|
|
|
|
Bots({
|
|
this.id,
|
|
this.image,
|
|
this.image2,
|
|
this.model,
|
|
this.name,
|
|
this.cost,
|
|
this.limit,
|
|
this.public,
|
|
this.attachment,
|
|
this.marked,
|
|
this.tool,
|
|
this.deleted,
|
|
this.attachmentType,
|
|
this.score,
|
|
this.comments = 0,
|
|
this.messages,
|
|
this.users,
|
|
this.description,
|
|
this.createdAt,
|
|
this.user,
|
|
this.category,
|
|
this.userComment,
|
|
this.type,
|
|
});
|
|
|
|
Bots.fromNotification(Map<String, dynamic> json) {
|
|
id = int.parse(json['id']);
|
|
name = json['name'];
|
|
model = json['model'];
|
|
image = json['image'];
|
|
image2 = json['image_2'];
|
|
attachment = int.parse(json['attachment']);
|
|
tool = json['tool'].toString().toLowerCase() == 'true';
|
|
deleted = json['deleted'].toString().toLowerCase() == 'true';
|
|
cost = int.parse(json['cost']);
|
|
limit = int.parse(json['limit']);
|
|
public = json['public'];
|
|
type = json['type'];
|
|
marked = json['marked'];
|
|
if (json['attachment_type'] != null &&
|
|
json['attachment_type'].toString().toLowerCase() != 'null') {
|
|
attachmentType = <String>[];
|
|
json['attachment_type'].forEach((v) {
|
|
attachmentType!.add(v);
|
|
});
|
|
}
|
|
score = json['score'];
|
|
comments = json['comments'];
|
|
users = json['users'];
|
|
messages = json['messages'];
|
|
description = json['description'];
|
|
createdAt = json['created_at'];
|
|
user = json['user'] != null ? User.fromJson(json['user']) : null;
|
|
category =
|
|
json['category'] != null ? Categories.fromJson(json['category']) : null;
|
|
userComment = json['user_comment'] != null
|
|
? UserComment.fromJson(json['user_comment'])
|
|
: null;
|
|
}
|
|
|
|
Bots.fromJson(Map<String, dynamic> json) {
|
|
id = json['id'];
|
|
name = json['name'];
|
|
model = json['model'];
|
|
image = json['image'];
|
|
image2 = json['image_2'];
|
|
attachment = json['attachment'];
|
|
tool = json['tool'];
|
|
deleted = json['deleted'];
|
|
type = json['type'];
|
|
cost = json['cost'];
|
|
limit = json['limit'];
|
|
public = json['public'];
|
|
marked = json['marked'];
|
|
if (json['attachment_type'] != null) {
|
|
attachmentType = <String>[];
|
|
json['attachment_type'].forEach((v) {
|
|
attachmentType!.add(v);
|
|
});
|
|
}
|
|
score = json['score'];
|
|
comments = json['comments'];
|
|
users = json['users'];
|
|
messages = json['messages'];
|
|
description = json['description'];
|
|
createdAt = json['created_at'];
|
|
user = json['user'] != null ? User.fromJson(json['user']) : null;
|
|
category =
|
|
json['category'] != null ? Categories.fromJson(json['category']) : null;
|
|
userComment = json['user_comment'] != null
|
|
? UserComment.fromJson(json['user_comment'])
|
|
: null;
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['id'] = id;
|
|
data['name'] = name;
|
|
data['model'] = model;
|
|
data['image'] = image;
|
|
data['image_2'] = image2;
|
|
data['attachment'] = attachment;
|
|
data['tool'] = tool;
|
|
data['deleted'] = deleted;
|
|
data['cost'] = cost;
|
|
data['limit'] = limit;
|
|
data['public'] = public;
|
|
data['marked'] = marked;
|
|
data['attachment_type'] = attachmentType;
|
|
return data;
|
|
}
|
|
|
|
Bots copyWith({
|
|
int? id,
|
|
String? image,
|
|
String? image2,
|
|
String? model,
|
|
String? name,
|
|
int? cost,
|
|
int? limit,
|
|
bool? public,
|
|
int? attachment,
|
|
bool? marked,
|
|
bool? tool,
|
|
bool? deleted,
|
|
List<String>? attachmentType,
|
|
double? score,
|
|
int? comments,
|
|
int? messages,
|
|
int? users,
|
|
String? description,
|
|
String? createdAt,
|
|
User? user,
|
|
Categories? category,
|
|
UserComment? userComment,
|
|
}) {
|
|
return Bots(
|
|
id: id ?? this.id,
|
|
image: image ?? this.image,
|
|
image2: image2 ?? this.image2,
|
|
model: model ?? this.model,
|
|
name: name ?? this.name,
|
|
cost: cost ?? this.cost,
|
|
limit: limit ?? this.limit,
|
|
public: public ?? this.public,
|
|
attachment: attachment ?? this.attachment,
|
|
marked: marked ?? this.marked,
|
|
tool: tool ?? this.tool,
|
|
deleted: deleted ?? this.deleted,
|
|
attachmentType: attachmentType ?? this.attachmentType,
|
|
score: score ?? this.score,
|
|
comments: comments ?? this.comments,
|
|
messages: messages ?? this.messages,
|
|
users: users ?? this.users,
|
|
description: description ?? this.description,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
user: user ?? this.user,
|
|
category: category ?? this.category,
|
|
userComment: userComment ?? this.userComment,
|
|
);
|
|
}
|
|
}
|
|
|
|
class User {
|
|
String? name;
|
|
String? username;
|
|
|
|
User({this.name, this.username});
|
|
|
|
User.fromJson(Map<String, dynamic> json) {
|
|
name = json['name'];
|
|
username = json['username'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['name'] = name;
|
|
data['username'] = username;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
class UserComment {
|
|
String? text;
|
|
double? score;
|
|
|
|
UserComment({this.text, this.score});
|
|
|
|
UserComment.fromJson(Map<String, dynamic> json) {
|
|
text = json['text'];
|
|
score = json['score'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['text'] = text;
|
|
data['score'] = score;
|
|
return data;
|
|
}
|
|
}
|