# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Get a users account list, DesiredHydraProductCodes is pipe delimited list 2 char values of
HydraProductTypeCode+HydraProductCode, with * allowed in HydraProductCode (D*|L*|C* for all deposit, loan and
credit accounts)
Sample response (may differ slightly in your environment)
.. code-block:: xml
<Q2API HqVersion="4.2.3.4215A" HqAssemblyVersion="4.2.6185.31252" ServerDateTime="2017-11-21T08:10:34.7386896-06:00">
<Result>
<ErrorCode ErrorType="Success">0</ErrorCode>
<ErrorDescription/>
<HydraErrorReturnCode>0</HydraErrorReturnCode>
</Result>
<Data>
<AccountListResponse>
<AccountListResponseRecord>
<UserID>1</UserID>
<HostAccountID>5000</HostAccountID>
<AccountNumberInternal>XXXXXX3467</AccountNumberInternal>
<ProductTypeName>Deposit</ProductTypeName>
<ProductName>Regular Checking</ProductName>
<AccountDesc>Checking</AccountDesc>
<NickName>Online Display Checking</NickName>
<LinkType>A</LinkType>
<DisplayOrder>1</DisplayOrder>
<Balance1>389.49</Balance1>
<BalanceDescription1>Available Balance</BalanceDescription1>
<BalanceName1>AvailBal</BalanceName1>
<BalanceType1>Currency</BalanceType1>
<Balance2>389.49</Balance2>
<BalanceDescription2>Current Balance</BalanceDescription2>
<BalanceName2>CurBal</BalanceName2>
<BalanceType2>Currency</BalanceType2>
<ProductTypeVoiceFile>deposit.wav</ProductTypeVoiceFile>
<ProductVoiceFile>regularChecking.wav</ProductVoiceFile>
<HydraProductCode>C</HydraProductCode>
<HydraProductTypeCode>D</HydraProductTypeCode>
<DataAsOfDate>2017-05-25T10:43:18.847-05:00</DataAsOfDate>
<APRorAPY>Y</APRorAPY>
<Access>7</Access>
<ProductID>1</ProductID>
<ProductTypeID>1</ProductTypeID>
<AllowPrincipal>false</AllowPrincipal>
<AllowInterest>false</AllowInterest>
<DisplayRunningBalance>false</DisplayRunningBalance>
<CalculateRunningBalanceForyHistory>false</CalculateRunningBalanceForyHistory>
<CalculateRunningBalanceForMemos>false</CalculateRunningBalanceForMemos>
<RunningBalanceHadeNameToUse>CurBal</RunningBalanceHadeNameToUse>
<HistoryCount>50</HistoryCount>
<HistoryCountType>Items</HistoryCountType>
<HasPendingMemos>false</HasPendingMemos>
<IsExternalAccount>false</IsExternalAccount>
<UserDisplayOrder>0</UserDisplayOrder>
<BalanceToDisplay>389.49</BalanceToDisplay>
<SortValue/>
<Cif>HQ_Test_1428315</Cif>
<MobilityDashboardBalance>389.49</MobilityDashboardBalance>
<BalanceAdditionalDescription1>Available Balance</BalanceAdditionalDescription1>
<BalanceAdditionalDescription2>Current Balance</BalanceAdditionalDescription2>
<BalanceToDisplayTransferTo>389.49</BalanceToDisplayTransferTo>
<DefaultPaymentAmountTransferFrom>389.49</DefaultPaymentAmountTransferFrom>
<BalanceToDisplayDescription>Available Balance</BalanceToDisplayDescription>
<MobilityDashboardBalanceDescription>Available Balance</MobilityDashboardBalanceDescription>
<BalanceToDisplayTransferToDescription>Current Balance</BalanceToDisplayTransferToDescription>
<DefaultPaymentAmountTransferFromDescription>Current Balance</DefaultPaymentAmountTransferFromDescription>
<CifInternal>HQ_Test_1428315</CifInternal>
<MaskedCifInternal>HQ_Test_1428315</MaskedCifInternal>
<IsPartialDetails>false</IsPartialDetails>
<AccountLabel/>
<Aba>4793490</Aba>
<statusShortName>Visible</statusShortName>
<OverviewAccountNumber/>
<AccountNumberInternalUnmasked>5293467</AccountNumberInternalUnmasked>
<AccountNumberExternalUnmasked>5293467</AccountNumberExternalUnmasked>
<CIFInternalUnmasked>HQ_Test_1428315</CIFInternalUnmasked>
</AccountListResponseRecord>
<AccountListResponseRecord>
<UserID>1</UserID>
<HostAccountID>5001</HostAccountID>
<AccountNumberInternal>XXXXXX9589</AccountNumberInternal>
<ProductTypeName>Deposit</ProductTypeName>
<ProductName>Regular Savings</ProductName>
<AccountDesc>Savings</AccountDesc>
<LinkType>A</LinkType>
<DisplayOrder>1</DisplayOrder>
<Balance1>104.26</Balance1>
<BalanceDescription1>Available Balance</BalanceDescription1>
<BalanceName1>AvailBal</BalanceName1>
<BalanceType1>Currency</BalanceType1>
<Balance2>104.26</Balance2>
<BalanceDescription2>Current Balance</BalanceDescription2>
<BalanceName2>CurBal</BalanceName2>
<BalanceType2>Currency</BalanceType2>
<ProductTypeVoiceFile>deposit.wav</ProductTypeVoiceFile>
<ProductVoiceFile>regularSavings.wav</ProductVoiceFile>
<HydraProductCode>S</HydraProductCode>
<HydraProductTypeCode>D</HydraProductTypeCode>
<DataAsOfDate>2017-05-25T10:43:18.847-05:00</DataAsOfDate>
<APRorAPY>Y</APRorAPY>
<Access>7</Access>
<ProductID>3</ProductID>
<ProductTypeID>1</ProductTypeID>
<AllowPrincipal>false</AllowPrincipal>
<AllowInterest>false</AllowInterest>
<DisplayRunningBalance>false</DisplayRunningBalance>
<CalculateRunningBalanceForyHistory>false</CalculateRunningBalanceForyHistory>
<CalculateRunningBalanceForMemos>false</CalculateRunningBalanceForMemos>
<RunningBalanceHadeNameToUse>CurBal</RunningBalanceHadeNameToUse>
<HistoryCount>50</HistoryCount>
<HistoryCountType>Items</HistoryCountType>
<HasPendingMemos>false</HasPendingMemos>
<IsExternalAccount>false</IsExternalAccount>
<UserDisplayOrder>0</UserDisplayOrder>
<BalanceToDisplay>104.26</BalanceToDisplay>
<SortValue/>
<Cif>HQ_Test_1428315</Cif>
<MobilityDashboardBalance>104.26</MobilityDashboardBalance>
<BalanceAdditionalDescription1>Available Balance</BalanceAdditionalDescription1>
<BalanceAdditionalDescription2>Current Balance</BalanceAdditionalDescription2>
<BalanceToDisplayTransferTo>104.26</BalanceToDisplayTransferTo>
<DefaultPaymentAmountTransferFrom>104.26</DefaultPaymentAmountTransferFrom>
<BalanceToDisplayDescription>Available Balance</BalanceToDisplayDescription>
<MobilityDashboardBalanceDescription>Available Balance</MobilityDashboardBalanceDescription>
<BalanceToDisplayTransferToDescription>Current Balance</BalanceToDisplayTransferToDescription>
<DefaultPaymentAmountTransferFromDescription>Current Balance</DefaultPaymentAmountTransferFromDescription>
<CifInternal>HQ_Test_1428315</CifInternal>
<MaskedCifInternal>HQ_Test_1428315</MaskedCifInternal>
<IsPartialDetails>false</IsPartialDetails>
<AccountLabel/>
<Aba>4793490</Aba>
<statusShortName>Visible</statusShortName>
<OverviewAccountNumber/>
<AccountNumberInternalUnmasked>5019589</AccountNumberInternalUnmasked>
<AccountNumberExternalUnmasked>5019589</AccountNumberExternalUnmasked>
<CIFInternalUnmasked>HQ_Test_1428315</CIFInternalUnmasked>
</AccountListResponseRecord>
<Q2_AccountDataElements>
<HostAccountID>5000</HostAccountID>
<HADE_ID>1</HADE_ID>
<HADEName>AvailBal</HADEName>
<HADEDesc>Available Balance</HADEDesc>
<HADEDataType>Currency</HADEDataType>
<DataValue>389.49</DataValue>
<DisplayOrder>-1</DisplayOrder>
<AdditionalHadeDesc>Available Balance</AdditionalHadeDesc>
</Q2_AccountDataElements>
<Q2_AccountDataElements>
<HostAccountID>5000</HostAccountID>
<HADE_ID>4</HADE_ID>
<HADEName>CurBal</HADEName>
<HADEDesc>Current Balance</HADEDesc>
<HADEDataType>Currency</HADEDataType>
<DataValue>389.49</DataValue>
<DisplayOrder>-1</DisplayOrder>
<AdditionalHadeDesc>Current Balance</AdditionalHadeDesc>
</Q2_AccountDataElements>
<Q2_AccountDataElements>
<HostAccountID>5001</HostAccountID>
<HADE_ID>1</HADE_ID>
<HADEName>AvailBal</HADEName>
<HADEDesc>Available Balance</HADEDesc>
<HADEDataType>Currency</HADEDataType>
<DataValue>104.26</DataValue>
<DisplayOrder>-1</DisplayOrder>
<AdditionalHadeDesc>Available Balance</AdditionalHadeDesc>
</Q2_AccountDataElements>
<Q2_AccountDataElements>
<HostAccountID>5001</HostAccountID>
<HADE_ID>4</HADE_ID>
<HADEName>CurBal</HADEName>
<HADEDesc>Current Balance</HADEDesc>
<HADEDataType>Currency</HADEDataType>
<DataValue>104.26</DataValue>
<DisplayOrder>-1</DisplayOrder>
<AdditionalHadeDesc>Current Balance</AdditionalHadeDesc>
</Q2_AccountDataElements>
</AccountListResponse>
</Data>
</Q2API>
"""
from dataclasses import dataclass
from typing import List, Optional, Union
from lxml.objectify import FloatElement, StringElement, IntElement, BoolElement
from q2_sdk.core.q2_logging.logger import Q2LoggerType
from q2_sdk.hq.models.hq_response import HqResponse
from q2_sdk.hq.models.hq_credentials import HqCredentials
from q2_sdk.hq.models.hq_params.q2_api import Q2ApiParamsObj
from q2_sdk.hq.models.hq_request.q2_api import Q2ApiRequest
[docs]
class ParamsObj(Q2ApiParamsObj):
"""Parameters definition for GetUserAccountList"""
def __init__(
self,
logger: Q2LoggerType,
online_user_name: str,
desired_rights_bit_flag: int,
desired_rights_is_explicit: bool,
desired_hydra_product_codes: str,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param online_user_name: Logon name of an online user
:param desired_rights_bit_flag: 0: No rights, 7: View, Deposit, and Withdraw Rights
:param desired_rights_is_explicit: True: Only show accounts with rights that match desired_rights_bit_flag exactly. False: Show accounts with at least desired_rights_big_flag
:param desired_hydra_product_codes: Pipe delimited list of 2 char values representing HydraProductTypeCode+HydraProductCode, with * allowed in HydraProductCode (D*|L*|C* for all deposit, loan and credit accounts)
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"OnlineUserName": online_user_name,
"DesiredRightsBitFlag": desired_rights_bit_flag,
"DesiredRightsIsExplicit": desired_rights_is_explicit,
"DesiredHydraProductCodes": desired_hydra_product_codes,
})
[docs]
@dataclass
class Q2_AccountDataElements:
AdditionalHadeDesc: StringElement
DataValue: FloatElement
DisplayOrder: IntElement
HADEDataType: StringElement
HADEDesc: StringElement
HADEName: StringElement
HADE_ID: IntElement
HostAccountID: IntElement
[docs]
@dataclass
class AccountListResponseRecord:
APRorAPY: StringElement
Aba: IntElement
Access: IntElement
AccountDesc: StringElement
AccountLabel: StringElement
AccountNumberExternalUnmasked: IntElement
AccountNumberInternal: StringElement
AccountNumberInternalUnmasked: IntElement
AllowInterest: BoolElement
AllowPrincipal: BoolElement
Balance1: FloatElement
Balance2: FloatElement
BalanceAdditionalDescription1: StringElement
BalanceAdditionalDescription2: StringElement
BalanceDescription1: StringElement
BalanceDescription2: StringElement
BalanceName1: StringElement
BalanceName2: StringElement
BalanceToDisplay: FloatElement
BalanceToDisplayDescription: StringElement
BalanceToDisplayTransferTo: FloatElement
BalanceToDisplayTransferToDescription: StringElement
BalanceType1: StringElement
BalanceType2: StringElement
CIFInternalUnmasked: StringElement
CalculateRunningBalanceForMemos: BoolElement
CalculateRunningBalanceForyHistory: BoolElement
Cif: StringElement
CifInternal: StringElement
DataAsOfDate: StringElement
DefaultPaymentAmountTransferFrom: FloatElement
DefaultPaymentAmountTransferFromDescription: StringElement
DisplayOrder: IntElement
DisplayRunningBalance: BoolElement
HasPendingMemos: BoolElement
HistoryCount: IntElement
HistoryCountType: StringElement
HostAccountID: IntElement
HydraProductCode: StringElement
HydraProductTypeCode: StringElement
IsExternalAccount: BoolElement
IsPartialDetails: BoolElement
LinkType: StringElement
MaskedCifInternal: StringElement
MobilityDashboardBalance: FloatElement
MobilityDashboardBalanceDescription: StringElement
NickName: StringElement
OverviewAccountNumber: StringElement
ProductID: IntElement
ProductName: StringElement
ProductTypeID: IntElement
ProductTypeName: StringElement
ProductTypeVoiceFile: StringElement
ProductVoiceFile: StringElement
RunningBalanceHadeNameToUse: StringElement
SortValue: StringElement
UserDisplayOrder: IntElement
UserID: IntElement
statusShortName: StringElement
[docs]
@dataclass
class AccountListResponse:
AccountListResponseRecord: Union[
AccountListResponseRecord, List[AccountListResponseRecord]
]
Q2_AccountDataElements: Union[Q2_AccountDataElements, List[Q2_AccountDataElements]]
[docs]
@dataclass
class Data:
AccountListResponse: Union[AccountListResponse, List[AccountListResponse]]
[docs]
class ResultNode:
def __init__(self):
self.Data = Data()
[docs]
class HqResponse(HqResponse):
def __init__(self, raw_response: Union[str, dict]):
super().__init__(raw_response)
self.result_node: ResultNode = None
[docs]
async def execute(params_obj: ParamsObj, use_json=False, **kwargs) -> HqResponse:
"""
This is the default way to submit the request to HQ.
In theory, both json and soap payloads are equally accepted by HQ, though
several variables may affect that (HQ version, Q2SDK implementation bugs, etc).
This should not affect anything about the way your code deals with the data. In fact,
the only difference to consuming extensions is the logging.
Basically, call this with default parameters unless you find a compelling
reason not to.
:param params_obj: Object containing everything necessary to call this HQ endpoint
:param use_json: If True, will call HQ's .ashx (json) endpoint instead of .asmx (soap)
"""
request = Q2ApiRequest("GetUserAccountList", use_json=use_json, **kwargs)
return await request.execute(params_obj, **kwargs)
[docs]
async def get_soap(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"GetUserAccountList.get_soap is deprecated. Please use GetUserAccountList.execute instead."
)
return await execute(params_obj, **kwargs)
[docs]
async def get_json(params_obj: ParamsObj, **kwargs) -> HqResponse:
"""Deprecated. Please use execute instead"""
params_obj.logger.warning(
"GetUserAccountList.get_json is deprecated. Please use GetUserAccountList.execute instead."
)
return await execute(params_obj, use_json=True, **kwargs)
[docs]
def build_json(params_obj: ParamsObj):
return Q2ApiRequest.build_json(params_obj)
[docs]
def build_soap(params_obj: ParamsObj):
return Q2ApiRequest("GetUserAccountList", use_json=False).build_soap(params_obj)