148 lines
3.9 KiB
Dart
148 lines
3.9 KiB
Dart
import 'dart:convert';
|
|
|
|
class ActivateInfoResponse {
|
|
ActivateInfoResponse({
|
|
this.description,
|
|
this.errorCode,
|
|
this.data, // 现在是一个 List<ActivateInfo>
|
|
this.errorMsg,
|
|
});
|
|
|
|
ActivateInfoResponse.fromJson(dynamic json) {
|
|
description = json['description'];
|
|
errorCode = json['errorCode'];
|
|
// 修改这里:直接解析为单个 ActivateInfo 对象
|
|
data = json['data'] != null ? ActivateInfo.fromJson(json['data']) : null;
|
|
errorMsg = json['errorMsg'];
|
|
}
|
|
|
|
String? description;
|
|
int? errorCode;
|
|
ActivateInfo? data; // 改为 List<ActivateInfo>
|
|
String? errorMsg;
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final map = <String, dynamic>{};
|
|
map['description'] = description;
|
|
map['errorCode'] = errorCode;
|
|
if (data != null) {
|
|
// 修改这里:将单个 ActivateInfo 对象转换为 JSON
|
|
map['data'] = data!.toJson();
|
|
}
|
|
map['errorMsg'] = errorMsg;
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'ActivateInfoResponse{description: $description, errorCode: $errorCode, data: $data, errorMsg: $errorMsg}';
|
|
}
|
|
}
|
|
|
|
class ActivateInfo {
|
|
String? authCode;
|
|
String? activatedAt;
|
|
Map<String, dynamic>? extraParams; // 修改为 Map 类型
|
|
|
|
ActivateInfo({
|
|
this.authCode,
|
|
this.activatedAt,
|
|
this.extraParams,
|
|
});
|
|
|
|
ActivateInfo.fromJson(dynamic json) {
|
|
authCode = json['auth_code'] ?? '';
|
|
activatedAt = json['activated_at'] ?? '';
|
|
// 修改这里:将 extraParams 解析为 Map 对象
|
|
if (json['extra_params'] != null) {
|
|
if (json['extra_params'] is Map) {
|
|
extraParams = json['extra_params'];
|
|
} else if (json['extra_params'] is String) {
|
|
// 如果是字符串,尝试解析为 JSON 对象
|
|
try {
|
|
extraParams = jsonDecode(json['extra_params']);
|
|
} catch (e) {
|
|
// 解析失败则设为 null 或空 map
|
|
extraParams = {};
|
|
}
|
|
}
|
|
} else {
|
|
extraParams = {};
|
|
}
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final map = <String, dynamic>{};
|
|
map['authCode'] = authCode;
|
|
map['activatedAt'] = activatedAt;
|
|
map['extraParams'] = extraParams;
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'ActivateInfo{authCode: $authCode, activatedAt: $activatedAt, extraParams: $extraParams}';
|
|
}
|
|
}
|
|
|
|
class TppSupportResponse {
|
|
TppSupportResponse({
|
|
this.description,
|
|
this.errorCode,
|
|
this.data, // 现在是一个 List<ActivateInfo>
|
|
this.errorMsg,
|
|
});
|
|
|
|
TppSupportResponse.fromJson(dynamic json) {
|
|
description = json['description'];
|
|
errorCode = json['errorCode'];
|
|
// 修改这里:如果 json['data'] 是列表,则解析为 List<ActivateInfo>;否则为空列表
|
|
data = json['data'] != null ? (json['data'] as List).map((item) => TppSupportInfo.fromJson(item)).toList() : [];
|
|
errorMsg = json['errorMsg'];
|
|
}
|
|
|
|
String? description;
|
|
int? errorCode;
|
|
List<TppSupportInfo>? data; // 改为 List<ActivateInfo>
|
|
String? errorMsg;
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final map = <String, dynamic>{};
|
|
map['description'] = description;
|
|
map['errorCode'] = errorCode;
|
|
if (data != null) {
|
|
// 修改这里:将 List<ActivateInfo> 转换为 JSON 列表
|
|
map['data'] = data!.map((item) => item.toJson()).toList();
|
|
}
|
|
map['errorMsg'] = errorMsg;
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'TppSupportResponse{description: $description, errorCode: $errorCode, data: $data, errorMsg: $errorMsg}';
|
|
}
|
|
}
|
|
|
|
class TppSupportInfo {
|
|
int? platform;
|
|
String? platformName;
|
|
|
|
TppSupportInfo({
|
|
this.platform,
|
|
this.platformName,
|
|
});
|
|
|
|
TppSupportInfo.fromJson(dynamic json) {
|
|
platform = json['platform'] as int? ?? -1;
|
|
platformName = json['platform_name'] as String? ?? '';
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
final map = <String, dynamic>{};
|
|
map['platform'] = platform;
|
|
map['platform_name'] = platformName;
|
|
return map;
|
|
}
|
|
}
|