objets_metier_rs 1.0.2

Bibliothèque Rust moderne et sûre pour l'API COM Objets Métier Sage 100c - Production Ready
use crate::com::{SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;

/// Wrapper pour l'objet Agenda (IBOAgenda / IBPAgenda)
///
/// ⚠️ IMPLÉMENTATION MINIMALE - Version Phase 4bis
pub struct Agenda {
    pub(crate) dispatch: IDispatch,
}

impl Agenda {
    fn dispatch(&self) -> SafeDispatch<'_> {
        SafeDispatch::new(&self.dispatch)
    }

    pub fn cbmarq(&self) -> SageResult<i32> {
        self.dispatch().call_method_by_name("cbMarq", &[])?.to_i32()
    }

    pub fn intitule(&self) -> SageResult<String> {
        self.dispatch()
            .call_method_by_name("Intitule", &[])?
            .to_string()
    }

    pub fn set_intitule(&self, value: &str) -> SageResult<()> {
        let param = SafeVariant::from_string(value);
        self.dispatch().call_property_put("Intitule", &[param])?;
        Ok(())
    }

    pub fn type_agenda(&self) -> SageResult<i32> {
        self.dispatch().call_method_by_name("Type", &[])?.to_i32()
    }

    pub fn set_type(&self, value: i32) -> SageResult<()> {
        let param = SafeVariant::I4(value);
        self.dispatch().call_property_put("Type", &[param])?;
        Ok(())
    }

    pub fn indisponible(&self) -> SageResult<bool> {
        self.dispatch()
            .call_method_by_name("Indisponible", &[])?
            .to_bool()
    }

    pub fn set_indisponible(&self, value: bool) -> SageResult<()> {
        let param = SafeVariant::Bool(value);
        self.dispatch()
            .call_property_put("Indisponible", &[param])?;
        Ok(())
    }

    pub fn write(&self) -> SageResult<()> {
        self.dispatch().call_method_by_name("Write", &[])?;
        Ok(())
    }

    pub fn write_default(&self) -> SageResult<()> {
        self.dispatch().call_method_by_name("WriteDefault", &[])?;
        Ok(())
    }

    pub fn remove(&self) -> SageResult<()> {
        self.dispatch().call_method_by_name("Remove", &[])?;
        Ok(())
    }
}