use serde::{Deserialize, Serialize};

/// Dados de pagamento com boleto bancário
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct BoletoPayment {
    /// Valor do pagamento (recomendado)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub amount: Option<f64>,

    /// Data de vencimento do boleto (opcional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub expiration_date: Option<String>,

    /// Descrição do pagamento (opcional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
}
impl BoletoPayment {
    pub fn new() -> Self {
        Self {
            amount: None,
            expiration_date: None,
            description: None,
        }
    }

    pub fn with_amount(mut self, amount: f64) -> Self {
        self.amount = Some(amount);
        self
    }

    pub fn with_expiration_date(mut self, expiration_date: impl Into<String>) -> Self {
        self.expiration_date = Some(expiration_date.into());
        self
    }

    pub fn with_description(mut self, description: impl Into<String>) -> Self {
        self.description = Some(description.into());
        self
    }
}

impl Default for BoletoPayment {
    fn default() -> Self {
        Self::new()
    }
}

#[cfg(test)]
mod tests {
    use crate::boleto::BoletoPayment;

    #[test]
    fn test_boleto_payment_builder() {
        let payment = BoletoPayment::new()
            .with_amount(200.0)
            .with_expiration_date("2025-12-31")
            .with_description("Boleto bancário");

        assert_eq!(payment.amount, Some(200.0));
        assert!(payment.expiration_date.is_some());
    }
}
