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 modes d'expédition (IBSCIALExpedition3)
///
/// ⚠️ IMPLÉMENTATION MINIMALE - Version Phase 3
/// Les propriétés seront enrichies progressivement selon les besoins.
pub struct Expedition {
    pub(crate) dispatch: IDispatch,
}

impl Expedition {
    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 n_numero(&self) -> SageResult<i32> {
        self.dispatch()
            .call_method_by_name("nNumero", &[])?
            .to_i32()
    }

    pub fn set_n_numero(&self, value: i32) -> SageResult<()> {
        let param = SafeVariant::I4(value);
        self.dispatch().call_property_put("nNumero", &[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(())
    }
}