use crate::RusaintError;
use crate::application::scholarships::model::Scholarship;
use crate::client::{USaintApplication, USaintClient};
use wdpe::body::Body;
use wdpe::element::parser::ElementParser;
pub struct ScholarshipsApplication {
client: USaintClient,
}
impl USaintApplication for ScholarshipsApplication {
const APP_NAME: &'static str = "ZCMW7530n";
fn from_client(client: USaintClient) -> Result<Self, RusaintError> {
if client.name() != Self::APP_NAME {
Err(RusaintError::InvalidClientError)
} else {
Ok(Self { client })
}
}
}
impl ScholarshipsApplication {
fn body(&self) -> &Body {
self.client.body()
}
pub async fn scholarships(&mut self) -> Result<Vec<Scholarship>, RusaintError> {
let parser = ElementParser::new(self.body());
Scholarship::with_parser(&parser)
}
pub async fn reload(&mut self) -> Result<(), RusaintError> {
self.client.reload().await?;
Ok(())
}
}
pub mod model;