interaction_models.dart
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
class InteractionData {
const InteractionData({
this.interactionType,
this.actionType,
this.action,
});
final int? interactionType;
final int? actionType;
final InteractionDataAction? action;
factory InteractionData.fromJson(Map<String, dynamic> json) {
return InteractionData(
interactionType: json['interaction_type'] as int?,
actionType: json['action_type'] as int?,
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (interactionType != null) val['interaction_type'] = interactionType;
if (actionType != null) val['action_type'] = actionType;
if (action != null) val['action_variables'] = action!.toJson();
return val;
}
}
class InteractionRecordResponse {
const InteractionRecordResponse({this.records});
final List<InteractionRecord>? records;
factory InteractionRecordResponse.fromJson(Map<String, dynamic> json) {
return InteractionRecordResponse(
records: (json['records'] as List<dynamic>?)
?.map((e) => InteractionRecord.fromJson(e as Map<String, dynamic>))
.toList(),
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (records != null) {
val['records'] = records!.map((e) => e.toJson()).toList();
}
return val;
}
}
class InteractionRecord {
const InteractionRecord({
this.id,
this.createTime,
this.userId,
this.pairId,
this.interactionType,
this.actionType,
this.action,
this.text,
});
final int? id;
final int? createTime;
final int? userId;
final int? pairId;
final int? interactionType;
final int? actionType;
final InteractionDataAction? action;
final String? text;
factory InteractionRecord.fromJson(Map<String, dynamic> json) {
return InteractionRecord(
id: json['id'] as int?,
createTime: json['create_time'] as int?,
userId: json['user_id'] as int?,
pairId: json['pair_id'] as int?,
interactionType: json['interaction_type'] as int?,
actionType: json['action_type'] as int?,
action: json['action_variables'] == null
? null
: InteractionDataAction.fromJson(
json['action_variables'] as Map<String, dynamic>),
text: json['text'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (id != null) val['id'] = id;
if (createTime != null) val['create_time'] = createTime;
if (userId != null) val['user_id'] = userId;
if (pairId != null) val['pair_id'] = pairId;
if (interactionType != null) val['interaction_type'] = interactionType;
if (actionType != null) val['action_type'] = actionType;
if (action != null) val['action_variables'] = action!.toJson();
if (text != null) val['text'] = text;
return val;
}
}
class InteractionDataAction {
const InteractionDataAction({
this.objectTarget,
this.status,
this.type,
this.date,
this.value,
this.unit,
this.action,
});
final int? objectTarget;
final String? status;
final String? type;
final String? date;
final String? value;
final String? unit;
final String? action;
factory InteractionDataAction.fromJson(Map<String, dynamic> json) {
return InteractionDataAction(
objectTarget: json['object'] as int?,
status: json['data_status'] as String?,
type: json['data_type'] as String?,
date: json['data_date'] as String?,
value: json['data_value'] as String?,
unit: json['data_unit'] as String?,
action: json['action'] as String?,
);
}
Map<String, dynamic> toJson() {
final val = <String, dynamic>{};
if (objectTarget != null) val['object'] = objectTarget;
if (status != null) val['data_status'] = status;
if (type != null) val['data_type'] = type;
if (date != null) val['data_date'] = date;
if (value != null) val['data_value'] = value;
if (unit != null) val['data_unit'] = unit;
if (action != null) val['action'] = action;
return val;
}
}