/// Statut courant d'une souscription retourné par le backend
class SouscriptionStatusModel {
  final String souscriptionId;
  final String statutValidation;
  final String typeFormule;
  final String plageMembres;
  final String plageLibelle;
  final String typePeriode;
  final String typeOrganisation;
  final double? montantTotal;
  final double? montantMensuelBase;
  final double? coefficientApplique;
  final String? waveSessionId;
  final String? waveLaunchUrl;
  final String organisationId;
  final String? organisationNom;
  final DateTime? dateDebut;
  final DateTime? dateFin;

  const SouscriptionStatusModel({
    required this.souscriptionId,
    required this.statutValidation,
    required this.typeFormule,
    required this.plageMembres,
    required this.plageLibelle,
    required this.typePeriode,
    required this.typeOrganisation,
    this.montantTotal,
    this.montantMensuelBase,
    this.coefficientApplique,
    this.waveSessionId,
    this.waveLaunchUrl,
    required this.organisationId,
    this.organisationNom,
    this.dateDebut,
    this.dateFin,
  });

  factory SouscriptionStatusModel.fromJson(Map<dynamic, dynamic> json) {
    return SouscriptionStatusModel(
      souscriptionId: json['souscriptionId'] as String,
      statutValidation: json['statutValidation'] as String,
      typeFormule: json['typeFormule'] as String,
      plageMembres: json['plageMembres'] as String,
      plageLibelle: (json['plageLibelle'] as String?) ?? '',
      typePeriode: json['typePeriode'] as String,
      typeOrganisation: (json['typeOrganisation'] as String?) ?? 'ASSOCIATION',
      montantTotal: (json['montantTotal'] as num?)?.toDouble(),
      montantMensuelBase: (json['montantMensuelBase'] as num?)?.toDouble(),
      coefficientApplique: (json['coefficientApplique'] as num?)?.toDouble(),
      waveSessionId: json['waveSessionId'] as String?,
      waveLaunchUrl: json['waveLaunchUrl'] as String?,
      organisationId: json['organisationId'] as String,
      organisationNom: json['organisationNom'] as String?,
      dateDebut: json['dateDebut'] != null
          ? DateTime.tryParse(json['dateDebut'] as String)
          : null,
      dateFin: json['dateFin'] != null
          ? DateTime.tryParse(json['dateFin'] as String)
          : null,
    );
  }
}
