import 'dart:io';

import 'package:dio/dio.dart';
import 'package:electronic_assistant/base/app_base_request.dart';
import 'package:json_annotation/json_annotation.dart';

part 'talk_file_request.g.dart';

@JsonSerializable()
class TalkFileRequest extends AppBaseRequest {
  @JsonKey(name: 'id')
  String id;

  @JsonKey(name: 'duration')
  double duration;

  @JsonKey(ignore: true)
  File? file;

  TalkFileRequest(this.id, this.duration, {this.file});

  @override
  Map<String, dynamic> toJson() {
    final json = _$TalkFileRequestToJson(this);
    if (file != null) {
      json['file'] = MultipartFile.fromFileSync(file!.path);
    }
    return json;
  }
}
