import 'package:cross_file/cross_file.dart';
import 'package:dio/dio.dart';
import 'package:hoshan/core/services/api/dio_service.dart';

class CreateAssistantRequestModel {
  // final int botId;
  final int categoryId;
  final String name;
  final String description;
  final String prompt;
  final bool public;
  // final XFile image;
  final List<String>? links;
  final List<XFile>? files;

  CreateAssistantRequestModel({
    // required this.botId,
    required this.categoryId,
    required this.name,
    required this.description,
    required this.prompt,
    required this.public,
    // required this.image,
    this.links,
    this.files,
  });

  Future<FormData> toFormData() async {
    FormData formDatBody = FormData();

    // formDatBody.fields.add(MapEntry('bot_id', botId.toString()));
    formDatBody.fields.add(MapEntry('category_id', categoryId.toString()));
    formDatBody.fields.add(MapEntry('name', name.toString()));
    formDatBody.fields.add(MapEntry('description', description.toString()));
    formDatBody.fields.add(MapEntry('prompt', prompt.toString()));
    formDatBody.fields.add(MapEntry('public', public.toString()));
    // MultipartFile multipartFile = await DioService.getMultipartFile(image);

    // formDatBody.files.add(MapEntry('image', multipartFile));
    if (links != null && links!.isNotEmpty) {
      for (var link in links!) {
        formDatBody.fields.add(MapEntry('links', link.toString()));
      }
    }
    if (files != null && files!.isNotEmpty) {
      for (var file in files!) {
        MultipartFile multipartFile = await DioService.getMultipartFile(file);
        formDatBody.files.add(MapEntry('docs', multipartFile));
      }
    }

    return formDatBody;
  }
}
