package dev.lions.unionflow.client.dto;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.UUID;

/**
 * DTO client pour les sessions de paiement Wave Money
 *
 * @author UnionFlow Team
 * @version 1.0
 * @since 2025-01-17
 */
public class WaveCheckoutSessionDTO implements Serializable {

  private static final long serialVersionUID = 1L;

  private UUID id;
  private String waveSessionId;
  private String waveUrl;
  private BigDecimal montant;
  private String devise;
  private String successUrl;
  private String errorUrl;
  private String statut;
  private UUID organisationId;
  private String nomOrganisation;
  private UUID membreId;
  private String nomMembre;
  private String typePaiement;
  private String referenceUnionFlow;
  private String description;
  private String nomBusinessAffiche;
  private LocalDateTime dateCreation;
  private LocalDateTime dateExpiration;
  private LocalDateTime dateCompletion;
  private String telephonePayeur;
  private String emailPayeur;

  // Getters et Setters
  public UUID getId() { return id; }
  public void setId(UUID id) { this.id = id; }

  public String getWaveSessionId() { return waveSessionId; }
  public void setWaveSessionId(String waveSessionId) { this.waveSessionId = waveSessionId; }

  public String getWaveUrl() { return waveUrl; }
  public void setWaveUrl(String waveUrl) { this.waveUrl = waveUrl; }

  public BigDecimal getMontant() { return montant; }
  public void setMontant(BigDecimal montant) { this.montant = montant; }

  public String getDevise() { return devise; }
  public void setDevise(String devise) { this.devise = devise; }

  public String getSuccessUrl() { return successUrl; }
  public void setSuccessUrl(String successUrl) { this.successUrl = successUrl; }

  public String getErrorUrl() { return errorUrl; }
  public void setErrorUrl(String errorUrl) { this.errorUrl = errorUrl; }

  public String getStatut() { return statut; }
  public void setStatut(String statut) { this.statut = statut; }

  public UUID getOrganisationId() { return organisationId; }
  public void setOrganisationId(UUID organisationId) { this.organisationId = organisationId; }

  public String getNomOrganisation() { return nomOrganisation; }
  public void setNomOrganisation(String nomOrganisation) { this.nomOrganisation = nomOrganisation; }

  public UUID getMembreId() { return membreId; }
  public void setMembreId(UUID membreId) { this.membreId = membreId; }

  public String getNomMembre() { return nomMembre; }
  public void setNomMembre(String nomMembre) { this.nomMembre = nomMembre; }

  public String getTypePaiement() { return typePaiement; }
  public void setTypePaiement(String typePaiement) { this.typePaiement = typePaiement; }

  public String getReferenceUnionFlow() { return referenceUnionFlow; }
  public void setReferenceUnionFlow(String referenceUnionFlow) { this.referenceUnionFlow = referenceUnionFlow; }

  public String getDescription() { return description; }
  public void setDescription(String description) { this.description = description; }

  public String getNomBusinessAffiche() { return nomBusinessAffiche; }
  public void setNomBusinessAffiche(String nomBusinessAffiche) { this.nomBusinessAffiche = nomBusinessAffiche; }

  public LocalDateTime getDateCreation() { return dateCreation; }
  public void setDateCreation(LocalDateTime dateCreation) { this.dateCreation = dateCreation; }

  public LocalDateTime getDateExpiration() { return dateExpiration; }
  public void setDateExpiration(LocalDateTime dateExpiration) { this.dateExpiration = dateExpiration; }

  public LocalDateTime getDateCompletion() { return dateCompletion; }
  public void setDateCompletion(LocalDateTime dateCompletion) { this.dateCompletion = dateCompletion; }

  public String getTelephonePayeur() { return telephonePayeur; }
  public void setTelephonePayeur(String telephonePayeur) { this.telephonePayeur = telephonePayeur; }

  public String getEmailPayeur() { return emailPayeur; }
  public void setEmailPayeur(String emailPayeur) { this.emailPayeur = emailPayeur; }

  /**
   * Retourne le libellé du statut
   */
  public String getStatutLibelle() {
    if (statut == null) return "Inconnu";
    return switch (statut) {
      case "PENDING" -> "En attente";
      case "COMPLETED" -> "Complétée";
      case "CANCELLED" -> "Annulée";
      case "EXPIRED" -> "Expirée";
      case "FAILED" -> "Échouée";
      default -> statut;
    };
  }

  /**
   * Retourne la sévérité PrimeFaces pour le statut
   */
  public String getStatutSeverity() {
    if (statut == null) return "info";
    return switch (statut) {
      case "PENDING" -> "warning";
      case "COMPLETED" -> "success";
      case "CANCELLED" -> "info";
      case "EXPIRED" -> "warn";
      case "FAILED" -> "error";
      default -> "info";
    };
  }

  /**
   * Vérifie si la session est expirée
   */
  public boolean isExpiree() {
    return dateExpiration != null && LocalDateTime.now().isAfter(dateExpiration);
  }

  /**
   * Vérifie si la session est complétée
   */
  public boolean isCompletee() {
    return "COMPLETED".equals(statut);
  }
}
