use model::{
StudentAcademicRecords, StudentBankAccount, StudentFamily, StudentGraduation,
StudentInformation, StudentQualification, StudentReligion, StudentResearchBankAccount,
StudentTransferRecords, StudentWorkInformation,
};
use crate::RusaintError;
use crate::client::{USaintApplication, USaintClient};
use wdpe::element::parser::ElementParser;
use wdpe::{body::Body, define_elements, element::layout::TabStrip};
#[derive(Debug)]
pub struct StudentInformationApplication {
client: USaintClient,
}
impl USaintApplication for StudentInformationApplication {
const APP_NAME: &'static str = "ZCMW1001n";
fn from_client(client: USaintClient) -> Result<Self, RusaintError> {
if client.name() != Self::APP_NAME {
Err(RusaintError::InvalidClientError)
} else {
Ok(Self { client })
}
}
}
impl<'a> StudentInformationApplication {
define_elements! {
TAB_ADDITION: TabStrip<'a> = "ZCMW1001.ID_0001:VIW_MAIN.TAB_ADDITION";
}
pub fn general(&self) -> Result<StudentInformation, RusaintError> {
Ok(StudentInformation::with_parser(&ElementParser::new(
self.body(),
))?)
}
pub fn graduation(&self) -> Result<StudentGraduation, RusaintError> {
Ok(StudentGraduation::with_parser(&ElementParser::new(
self.body(),
))?)
}
pub fn qualifications(&self) -> Result<StudentQualification, RusaintError> {
Ok(StudentQualification::with_parser(&ElementParser::new(
self.body(),
)))
}
pub async fn work(&mut self) -> Result<StudentWorkInformation, RusaintError> {
Ok(StudentWorkInformation::with_client(&mut self.client).await?)
}
pub async fn family(&mut self) -> Result<StudentFamily, RusaintError> {
Ok(StudentFamily::with_client(&mut self.client).await?)
}
pub async fn religion(&mut self) -> Result<StudentReligion, RusaintError> {
Ok(StudentReligion::with_client(&mut self.client).await?)
}
pub async fn transfer(&mut self) -> Result<StudentTransferRecords, RusaintError> {
Ok(StudentTransferRecords::with_client(&mut self.client).await?)
}
pub async fn bank_account(&mut self) -> Result<StudentBankAccount, RusaintError> {
Ok(StudentBankAccount::with_client(&mut self.client).await?)
}
pub async fn academic_record(&mut self) -> Result<StudentAcademicRecords, RusaintError> {
Ok(StudentAcademicRecords::with_client(&mut self.client).await?)
}
pub async fn research_bank_account(
&mut self,
) -> Result<StudentResearchBankAccount, RusaintError> {
Ok(StudentResearchBankAccount::with_client(&mut self.client).await?)
}
pub async fn reload(&mut self) -> Result<(), RusaintError> {
self.client.reload().await?;
Ok(())
}
fn body(&self) -> &Body {
self.client.body()
}
}
pub mod model;
#[cfg(test)]
mod test {}