use serde::{Deserialize, Serialize};

/// Tipo de documento do passageiro
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum TravelDocumentType {
    /// Passaporte
    Passport,
    /// Documento de identidade
    Id,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_document_type_serialization() {
        let passport = TravelDocumentType::Passport;
        let json = serde_json::to_string(&passport).unwrap();
        assert_eq!(json, r#""passport""#);

        let id = TravelDocumentType::Id;
        let json = serde_json::to_string(&id).unwrap();
        assert_eq!(json, r#""id""#);
    }

    #[test]
    fn test_document_type_deserialization() {
        let json = r#""passport""#;
        let doc_type: TravelDocumentType = serde_json::from_str(json).unwrap();
        assert_eq!(doc_type, TravelDocumentType::Passport);

        let json = r#""id""#;
        let doc_type: TravelDocumentType = serde_json::from_str(json).unwrap();
        assert_eq!(doc_type, TravelDocumentType::Id);
    }
}

