// ignore_for_file: non_constant_identifier_names, avoid_init_to_null

import 'package:dart_framework/core/app_data_manager.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:oto/oto/commands/build/build_flutter.dart';
import 'package:oto/oto/commands/build/build_msbuild.dart';
import 'package:oto/oto/data/base_data.dart';

part 'build_data.g.dart';

//SimpleCommand
@JsonSerializable()
class DataSimpleCommand extends DataParam {
  DataSimpleCommand();

  late String message;

  factory DataSimpleCommand.fromJson(Map<String, dynamic> json) =>
      _$DataSimpleCommandFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataSimpleCommandToJson(this);
}

//AppDataCreator
@JsonSerializable()
class DataAppDataCreator extends DataParam {
  DataAppDataCreator();

  late SCMType scm;
  late String relativeAssetPath;
  late String setVersion;
  late String setHash;
  late String? setCount;
  late String? setDate;
  late String name;

  factory DataAppDataCreator.fromJson(Map<String, dynamic> json) =>
      _$DataAppDataCreatorFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataAppDataCreatorToJson(this);
}

//BuildMSBuild
@JsonSerializable()
class DataBuildMSBuild extends DataParam {
  DataBuildMSBuild();

  late String projectFile;
  late MSBuildType type;
  late MSBuildConfig config;

  factory DataBuildMSBuild.fromJson(Map<String, dynamic> json) =>
      _$DataBuildMSBuildFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildMSBuildToJson(this);
}

//BuildDart
@JsonSerializable()
class DataBuildDart extends DataParam {
  DataBuildDart();

  late bool? executeBuildRunner;

  factory DataBuildDart.fromJson(Map<String, dynamic> json) =>
      _$DataBuildDartFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildDartToJson(this);
}

//BuildFlutter
@JsonSerializable()
class DataBuildFlutter extends DataBuildDart {
  DataBuildFlutter();

  late String? macPassword;
  late String platform;
  late String? flavor;
  late String? additional;

  factory DataBuildFlutter.fromJson(Map<String, dynamic> json) =>
      _$DataBuildFlutterFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildFlutterToJson(this);
}

//BuildDartCompile
@JsonSerializable()
class DataBuildDartCompile extends DataBuildDart {
  DataBuildDartCompile();

  late String? targetDartFile;
  late String? buildFileName;

  factory DataBuildDartCompile.fromJson(Map<String, dynamic> json) =>
      _$DataBuildDartCompileFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildDartCompileToJson(this);
}

//BuildDotNet
@JsonSerializable()
class DataBuildDotNet extends DataParam {
  DataBuildDotNet();

  late String projectFile;

  factory DataBuildDotNet.fromJson(Map<String, dynamic> json) =>
      _$DataBuildDotNetFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildDotNetToJson(this);
}

//BuildiOS
@JsonSerializable()
class DataBuildiOS extends DataParam {
  DataBuildiOS();

  late String scheme;
  late BuildPlatform? os;
  late String? macPassword;
  late String? xcodeProjectFilePath;
  late String? xcworkspaceFilePath;
  late String? derivedDataPath;
  late bool? cleanPod;
  late String? configuration;
  late Map<String, String>? settings;

  //Version Setting
  late String?
      target; // if null, auto-detects the top-level target from xcodeproj
  late String? version; // if set, disables autoBuildNumber
  late String? buildNumber; // if set, disables autoBuildNumber
  late bool? autoBuildNumber = false;
  late String? apiKeyPath; // required when using autoVersionNumber

  //set
  late String? setVersion;
  late String? setBuildNumber;
  late String? setAppID;

  factory DataBuildiOS.fromJson(Map<String, dynamic> json) =>
      _$DataBuildiOSFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataBuildiOSToJson(this);
}

//CodeSign
@JsonSerializable()
class DataCodeSign extends DataParam {
  DataCodeSign();

  late String appPath;
  late String certificationName;
  late String? entitlementPath;

  factory DataCodeSign.fromJson(Map<String, dynamic> json) =>
      _$DataCodeSignFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataCodeSignToJson(this);
}

//CodeSignVerify
@JsonSerializable()
class DataCodeSignVerify extends DataParam {
  DataCodeSignVerify();

  late String appPath;

  factory DataCodeSignVerify.fromJson(Map<String, dynamic> json) =>
      _$DataCodeSignVerifyFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataCodeSignVerifyToJson(this);
}

//ProductBuild
@JsonSerializable()
class DataProductBuild extends DataParam {
  DataProductBuild();

  late String appPath;
  late String identifier;
  late String? scripts;
  late String installCertificationName;
  late String unsignedResultPath;
  late String signedResultPath;

  factory DataProductBuild.fromJson(Map<String, dynamic> json) =>
      _$DataProductBuildFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataProductBuildToJson(this);
}

//Notarize
@JsonSerializable()
class DataNotarize extends DataParam {
  DataNotarize();

  late String macPassword;
  late String bundleName;
  late String teamId;
  late String appleAccount;
  late String applePassword;
  late String resultPath;

  factory DataNotarize.fromJson(Map<String, dynamic> json) =>
      _$DataNotarizeFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataNotarizeToJson(this);
}

//ArchiveiOS
@JsonSerializable()
class DataArchiveiOS extends DataParam {
  DataArchiveiOS();

  late String? xcworkspaceFilePath;
  late String? xcodeProjectFilePath;
  late String scheme;
  late String archivePath;
  late String? destination;

  factory DataArchiveiOS.fromJson(Map<String, dynamic> json) =>
      _$DataArchiveiOSFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataArchiveiOSToJson(this);
}

//ExportiOS
@JsonSerializable()
class DataExportiOS extends DataParam {
  DataExportiOS();

  late String archivePath;
  late String exportOptionPlistPath;
  late String exportPath;

  factory DataExportiOS.fromJson(Map<String, dynamic> json) =>
      _$DataExportiOSFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataExportiOSToJson(this);
}

//TestflightUpload
@JsonSerializable()
class DataTestflightUpload extends DataParam {
  DataTestflightUpload();

  late String apiKeyPath;
  late String ipaPath;

  factory DataTestflightUpload.fromJson(Map<String, dynamic> json) =>
      _$DataTestflightUploadFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataTestflightUploadToJson(this);
}

//TestflightStatusCheck
@JsonSerializable()
class DataTestflightStatusCheck extends DataParam {
  DataTestflightStatusCheck();

  late String appID;
  late String apiKeyPath;
  late String version;
  late String buildNumber;

  factory DataTestflightStatusCheck.fromJson(Map<String, dynamic> json) =>
      _$DataTestflightStatusCheckFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataTestflightStatusCheckToJson(this);
}

//TestflightDistribute
@JsonSerializable()
class DataTestflightDistribute extends DataParam {
  DataTestflightDistribute();

  late String apiKeyPath;
  late String appID;
  late String? message;
  late String? testers;
  late String? platform;
  late String? buildNumber;

  factory DataTestflightDistribute.fromJson(Map<String, dynamic> json) =>
      _$DataTestflightDistributeFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataTestflightDistributeToJson(this);
}

//PublishiOS
@JsonSerializable()
class DataPublishiOS extends DataParam {
  DataPublishiOS();

  late String bundleID;
  late String version;
  late String appName;
  late String ipaURL;
  late String menifestURL;
  late String displayImageURL;
  late String fullSizeImageURL;
  late String destinationPath;

  factory DataPublishiOS.fromJson(Map<String, dynamic> json) =>
      _$DataPublishiOSFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataPublishiOSToJson(this);
}

//XcodeprojAddFile
@JsonSerializable()
class DataXcodeprojAddFile extends DataParam {
  DataXcodeprojAddFile();

  late String addFilePath;
  late String target;
  late String xcodeprojPath;

  factory DataXcodeprojAddFile.fromJson(Map<String, dynamic> json) =>
      _$DataXcodeprojAddFileFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$DataXcodeprojAddFileToJson(this);
}
