cat_gateway/service/common/objects/legacy/
voter_registration.rsuse chrono::{DateTime, Utc};
use poem_openapi::{types::Example, Object};
use super::voter_info::VoterInfo;
#[derive(Object)]
#[oai(example = true)]
pub(crate) struct VoterRegistration {
voter_info: VoterInfo,
as_at: DateTime<Utc>,
last_updated: DateTime<Utc>,
#[oai(rename = "final")]
is_final: bool,
}
impl Example for VoterRegistration {
fn example() -> Self {
Self {
voter_info: VoterInfo::example(),
as_at: Utc::now(),
last_updated: Utc::now(),
is_final: true,
}
}
}
impl TryFrom<crate::db::event::legacy::types::registration::Voter> for VoterRegistration {
type Error = String;
fn try_from(
value: crate::db::event::legacy::types::registration::Voter,
) -> Result<Self, Self::Error> {
Ok(Self {
voter_info: value.info.try_into()?,
as_at: value.as_at,
last_updated: value.last_updated,
is_final: value.is_final,
})
}
}