80 lines
2.1 KiB
Dart
80 lines
2.1 KiB
Dart
class AiResponseModel {
|
|
int? chatId;
|
|
String? content;
|
|
String? aiMessageId;
|
|
String? humanMessageId;
|
|
String? chatTitle;
|
|
int? credit;
|
|
int? freeCredit;
|
|
bool? error;
|
|
int? statusCode;
|
|
String? detail;
|
|
|
|
AiResponseModel(
|
|
{this.chatId,
|
|
this.content,
|
|
this.aiMessageId,
|
|
this.humanMessageId,
|
|
this.credit,
|
|
this.detail,
|
|
this.error,
|
|
this.freeCredit,
|
|
this.statusCode,
|
|
this.chatTitle});
|
|
|
|
AiResponseModel.fromJson(Map<String, dynamic> json) {
|
|
chatId = json['chat_id'] is String
|
|
? int.tryParse(json['chat_id'])
|
|
: json['chat_id'];
|
|
chatTitle = json['chat_title'];
|
|
content = json['content'];
|
|
aiMessageId = json['ai_message_id'];
|
|
humanMessageId = json['human_message_id'];
|
|
credit = json['credit'] is String
|
|
? int.tryParse(json['credit'])
|
|
: json['credit'];
|
|
error = json['error'] ?? false;
|
|
detail = json['detail'];
|
|
statusCode = json['status_code'] ?? 200;
|
|
freeCredit =
|
|
json['free'] is String ? int.tryParse(json['free']) : json['free'];
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data['chat_id'] = chatId;
|
|
data['chat_title'] = chatTitle;
|
|
data['content'] = content;
|
|
data['ai_message_id'] = aiMessageId;
|
|
data['human_message_id'] = humanMessageId;
|
|
data['credit'] = credit;
|
|
return data;
|
|
}
|
|
|
|
AiResponseModel copyWith({
|
|
int? chatId,
|
|
String? content,
|
|
String? aiMessageId,
|
|
String? humanMessageId,
|
|
int? credit,
|
|
int? freeCredit,
|
|
String? chatTitle,
|
|
bool? error,
|
|
int? statusCode,
|
|
String? detail,
|
|
}) {
|
|
return AiResponseModel(
|
|
chatId: chatId ?? this.chatId,
|
|
content: content ?? this.content,
|
|
aiMessageId: aiMessageId ?? this.aiMessageId,
|
|
humanMessageId: humanMessageId ?? this.humanMessageId,
|
|
chatTitle: chatTitle ?? this.chatTitle,
|
|
credit: credit ?? this.credit,
|
|
error: error ?? this.error,
|
|
statusCode: statusCode ?? this.statusCode,
|
|
detail: detail ?? this.detail,
|
|
freeCredit: freeCredit ?? this.freeCredit,
|
|
);
|
|
}
|
|
}
|