#![cfg_attr(rustfmt, rustfmt::skip)]
use refix_message::{Instances, InvalidValue, LazyKnownTags, RawMessage, Tag, UtcTimestamp};
use super::super::components::{Header, OrdAllocGrp, Trailer};
use super::super::enums::{AllocAccountType, ConfirmType};
pub struct ConfirmationRequest(RawMessage);
impl ConfirmationRequest {
pub const MSG_TYPE: &[u8] = b"BH";
pub(in super::super) const fn known_tags() -> &'static LazyKnownTags {
static TAGS: LazyKnownTags = LazyKnownTags::new(
&[
Tag(859), Tag(773), Tag(73), Tag(70), Tag(793), Tag(467), Tag(60), Tag(79),
Tag(661), Tag(798), Tag(58), Tag(354), Tag(355),
],
&[Header::known_tags(), Trailer::known_tags(), OrdAllocGrp::known_tags()],
);
&TAGS
}
pub fn from_raw(raw: RawMessage) -> Self {
Self(raw)
}
pub fn raw(&self) -> &RawMessage {
&self.0
}
pub fn header(&self) -> Header<'_> {
Header(self.0.scope(), Self::known_tags().get())
}
pub fn trailer(&self) -> Trailer<'_> {
Trailer(self.0.scope())
}
#[doc(alias = "ConfirmReqID")]
pub fn confirm_req_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(859))
}
#[doc(alias = "ConfirmType")]
pub fn confirm_type(&self) -> Result<Option<ConfirmType>, InvalidValue> {
Ok(self.0.get_int(Tag(773))?.map(ConfirmType::from_value))
}
#[doc(alias = "NoOrders")]
pub fn orders(&self) -> Result<Instances<'_, OrdAllocGrp<'_>>, InvalidValue> {
self.0.get_group(&OrdAllocGrp::TABLE, &Self::known_tags().get()).map(Instances::from)
}
#[doc(alias = "AllocID")]
pub fn alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(70))
}
#[doc(alias = "SecondaryAllocID")]
pub fn secondary_alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(793))
}
#[doc(alias = "IndividualAllocID")]
pub fn individual_alloc_id(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(467))
}
#[doc(alias = "TransactTime")]
pub fn transact_time(&self) -> Result<Option<UtcTimestamp>, InvalidValue> {
self.0.get_utc_timestamp(Tag(60))
}
#[doc(alias = "AllocAccount")]
pub fn alloc_account(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(79))
}
#[doc(alias = "AllocAcctIDSource")]
pub fn alloc_acct_id_source(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(661))
}
#[doc(alias = "AllocAccountType")]
pub fn alloc_account_type(&self) -> Result<Option<AllocAccountType>, InvalidValue> {
Ok(self.0.get_int(Tag(798))?.map(AllocAccountType::from_value))
}
#[doc(alias = "Text")]
pub fn text(&self) -> Result<Option<&str>, InvalidValue> {
self.0.get_str(Tag(58))
}
#[doc(alias = "EncodedTextLen")]
pub fn encoded_text_len(&self) -> Result<Option<i64>, InvalidValue> {
self.0.get_int(Tag(354))
}
#[doc(alias = "EncodedText")]
pub fn encoded_text(&self) -> Option<&[u8]> {
self.0.get(Tag(355))
}
}
impl std::fmt::Debug for ConfirmationRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "ConfirmationRequest({})", self.0)
}
}
impl std::fmt::Display for ConfirmationRequest {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}