Source code for q2_sdk.hq.models.sso_account

from functools import cached_property
from lxml import etree
from lxml.objectify import E
from q2_sdk.hq.models.hydra_product import get_hydra_product_object


[docs] class SSOAccount: """ Object representation of the Account information that comes in on a Q2 Online request """ def __init__(self, element: etree.Element): """ :param element: XML node form Q2 Online request :param data_elements: Optional list of Q2_AccountDataElement nodes. """ if isinstance(element, dict): element = E.root( E.UserID(element["UserID"]), E.AccountNumberInternal(element["AccountNumberInternal"]), E.AccountNumberExternal(element["AccountNumberExternal"]), E.AccountNickName(element["AccountNickName"]), E.AccountBalance(element["AccountBalance"]), E.HydraProductTypeCode(element["HydraProductTypeCode"]), E.HydraProductCode(element["HydraProductCode"]), E.IsReadOnly(element["IsReadOnly"]), E.UseInternalAccount(element["UseInternalAccount"]), E.HostProductTypeCode(element["HostProductTypeCode"]), E.HostProductCode(element["HostProductCode"]), E.CIFInternal(element["CIFInternal"]), E.CIFExternal(element["CIFExternal"]), E.HostAccountID(element["HostAccountID"]), E.ABA(element["ABA"]), ) self.element = element self._host_acct_id = None
[docs] @cached_property def acct_number_internal(self): return self.element.findtext("{*}AccountNumberInternal")
[docs] @cached_property def acct_number_internal_unmasked(self): return self.element.findtext("{*}AccountNumberInternal")
[docs] @cached_property def acct_number_external(self): return self.element.findtext("{*}AccountNumberExternal")
[docs] @cached_property def cif(self): return self.element.findtext("{*}CIFInternal")
[docs] @cached_property def cif_internal(self): return self.element.findtext("{*}CIFInternal")
[docs] @cached_property def cif_external(self): return self.element.findtext("{*}CIFExternal")
@property def host_acct_id(self): if not self._host_acct_id: self._host_acct_id = self.element.findtext("{*}HostAccountID") return self._host_acct_id @host_acct_id.setter def host_acct_id(self, value): self._host_acct_id = value
[docs] @cached_property def hydra_product_code(self): return self.element.findtext("{*}HydraProductCode")
[docs] @cached_property def hydra_product_type_code(self): return self.element.findtext("{*}HydraProductTypeCode")
[docs] @cached_property def user_id(self): return self.element.findtext("{*}UserID")
[docs] @cached_property def is_read_only(self): return self.element.findtext("{*}IsReadOnly")
[docs] @cached_property def host_product_code(self): return self.element.findtext("{*}HostProductCode")
[docs] @cached_property def host_product_type_code(self): return self.element.findtext("{*}HostProductTypeCode")
[docs] @cached_property def account_balance(self): return self.element.findtext("{*}AccountBalance")
[docs] @cached_property def account_nickname(self): return self.element.findtext("{*}AccountNickName")
[docs] @cached_property def hydra_product_name(self) -> str: """Returns a generic product name for the account""" hydra_product = get_hydra_product_object( self.hydra_product_type_code, self.hydra_product_code ) return hydra_product.name
[docs] @cached_property def aba(self): return self.element.findtext("{*}ABA")
def __repr__(self): return etree.tostring(self.element)