interaction_models.dart 2.44 KB
import 'package:json_annotation/json_annotation.dart';

part 'interaction_models.g.dart';

@JsonSerializable()
class InteractionData {
  const InteractionData({
    this.interactionType,
    this.actionType,
    this.action,
  });

  @JsonKey(name: 'interaction_type')
  final int? interactionType;
  @JsonKey(name: 'action_type')
  final int? actionType;
  @JsonKey(name: 'action_variables')
  final InteractionDataAction? action;

  factory InteractionData.fromJson(Map<String, dynamic> json) =>
      _$InteractionDataFromJson(json);
  Map<String, dynamic> toJson() => _$InteractionDataToJson(this);
}

@JsonSerializable()
class InteractionRecordResponse {
  const InteractionRecordResponse({this.records});

  final List<InteractionRecord>? records;

  factory InteractionRecordResponse.fromJson(Map<String, dynamic> json) =>
      _$InteractionRecordResponseFromJson(json);
  Map<String, dynamic> toJson() => _$InteractionRecordResponseToJson(this);
}

@JsonSerializable()
class InteractionRecord {
  const InteractionRecord({
    this.id,
    this.createTime,
    this.userId,
    this.pairId,
    this.interactionType,
    this.actionType,
    this.action,
    this.text,
  });

  final int? id;
  @JsonKey(name: 'create_time')
  final int? createTime;
  @JsonKey(name: 'user_id')
  final int? userId;
  @JsonKey(name: 'pair_id')
  final int? pairId;
  @JsonKey(name: 'interaction_type')
  final int? interactionType;
  @JsonKey(name: 'action_type')
  final int? actionType;
  @JsonKey(name: 'action_variables')
  final InteractionDataAction? action;
  final String? text;

  factory InteractionRecord.fromJson(Map<String, dynamic> json) =>
      _$InteractionRecordFromJson(json);
  Map<String, dynamic> toJson() => _$InteractionRecordToJson(this);
}

@JsonSerializable()
class InteractionDataAction {
  const InteractionDataAction({
    this.objectTarget,
    this.status,
    this.type,
    this.date,
    this.value,
    this.unit,
    this.action,
  });

  @JsonKey(name: 'object')
  final int? objectTarget;
  @JsonKey(name: 'data_status')
  final String? status;
  @JsonKey(name: 'data_type')
  final String? type;
  @JsonKey(name: 'data_date')
  final String? date;
  @JsonKey(name: 'data_value')
  final String? value;
  @JsonKey(name: 'data_unit')
  final String? unit;
  final String? action;

  factory InteractionDataAction.fromJson(Map<String, dynamic> json) =>
      _$InteractionDataActionFromJson(json);
  Map<String, dynamic> toJson() => _$InteractionDataActionToJson(this);
}