use serde::{Deserialize, Serialize};

/// Dados de pagamento via transferência bancária
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TransferPayment {
    /// Valor do pagamento (recomendado)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub amount: Option<f64>,

    /// Descrição do pagamento (opcional)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
}

impl TransferPayment {
    pub fn new() -> Self {
        Self {
            amount: None,
            description: None,
        }
    }

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

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

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

#[cfg(test)]
mod tests {
    use crate::transfer::TransferPayment;

    #[test]
    fn test_transfer_payment_builder() {
        let payment = TransferPayment::new()
            .with_amount(500.0)
            .with_description("TED");

        assert_eq!(payment.amount, Some(500.0));
    }
}
