# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Sample response (may differ slightly in your environment)
.. code-block:: xml
<Q2API HqVersion="4.5.0.6078" HqAssemblyVersion="4.5.0.0" ServerDateTime="2022-08-31T13:18:59.3275312+00:00" AuditId="2080963">
<Result>
<ErrorCode ErrorType="Success">0</ErrorCode>
<ErrorDescription/>
<HydraErrorReturnCode>0</HydraErrorReturnCode>
</Result>
<Data>
<AccountListResponse>
<AccountListResponseRecord>
<UserID>2</UserID>
<HostAccountID>5007</HostAccountID>
<AccountNumberInternal>S01</AccountNumberInternal>
<ProductTypeName>Q2 Savings</ProductTypeName>
<ProductName>Q2 BUSINESS SAVINGS</ProductName>
<AccountDesc/>
<LinkType>C</LinkType>
<DisplayOrder>0</DisplayOrder>
<Balance1>152841.28</Balance1>
<BalanceDescription1>Available Balance</BalanceDescription1>
<BalanceName1>AvailBal</BalanceName1>
<BalanceType1>Currency</BalanceType1>
<Balance2/>
<BalanceDescription2>Current Balance</BalanceDescription2>
<BalanceName2>CurBal</BalanceName2>
<BalanceType2>Currency</BalanceType2>
<ProductTypeVoiceFile>savings.wav</ProductTypeVoiceFile>
<ProductVoiceFile>sav.wav</ProductVoiceFile>
<HydraProductCode>S</HydraProductCode>
<HydraProductTypeCode>D</HydraProductTypeCode>
<DataAsOfDate>2022-01-28T18:08:58+00:00</DataAsOfDate>
<APRorAPY>R</APRorAPY>
<Access>7</Access>
<ProductID>20</ProductID>
<ProductTypeID>6</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>5</UserDisplayOrder>
<BalanceToDisplay>152841.28</BalanceToDisplay>
<SortValue/>
<Cif>07212010</Cif>
<BalanceAdditionalDescription1/>
<BalanceAdditionalDescription2/>
<BalanceToDisplayTransferTo/>
<DefaultPaymentAmountTransferFrom/>
<BalanceToDisplayDescription>Available Balance</BalanceToDisplayDescription>
<BalanceToDisplayTransferToDescription/>
<DefaultPaymentAmountTransferFromDescription/>
<CifInternal>07212010</CifInternal>
<MaskedCifInternal>07212010</MaskedCifInternal>
<CifExternal>07212010</CifExternal>
<MaskedCifExternal>07212010</MaskedCifExternal>
<IsPartialDetails>false</IsPartialDetails>
<Aba/>
<OverviewAccountNumber/>
<canDisputeTransactions>false</canDisputeTransactions>
<allowClose>false</allowClose>
<IsPriority>false</IsPriority>
<Balance3/>
<BalanceDescription3/>
<BalanceName3/>
<BalanceType3/>
</AccountListResponseRecord>
<Q2_AccountDataElements>
<HostAccountID>5007</HostAccountID>
<HADE_ID>1</HADE_ID>
<HADEName>AvailBal</HADEName>
<HADEDesc>Available Balance</HADEDesc>
<HADEDataType>Currency</HADEDataType>
<DataValue>152841.28</DataValue>
<DisplayOrder>7</DisplayOrder>
<IsEditable>false</IsEditable>
</Q2_AccountDataElements>
<Q2_AccountDataElements>
<HostAccountID>5007</HostAccountID>
<HADE_ID>8</HADE_ID>
<HADEName>IntRate</HADEName>
<HADEDesc>Interest Rate</HADEDesc>
<HADEDataType>Rate</HADEDataType>
<DataValue>.10</DataValue>
<DisplayOrder>14</DisplayOrder>
<IsEditable>false</IsEditable>
</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.wedge_online_banking import WedgeOnlineBankingParamsObj
from q2_sdk.hq.models.hq_request.wedge_online_banking import WedgeOnlineBankingRequest
[docs]
class ParamsObj(WedgeOnlineBankingParamsObj):
"""Parameters definition for GetAccounts"""
def __init__(self, logger: Q2LoggerType, hq_credentials: HqCredentials):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param hq_credentials: HqCredentials instance with an hq_url and auth_token
"""
super().__init__(logger, hq_credentials)
self.request_params.update({})
[docs]
@dataclass
class Q2_AccountDataElements:
DataValue: FloatElement
DisplayOrder: IntElement
HADEDataType: StringElement
HADEDesc: StringElement
HADEName: StringElement
HADE_ID: IntElement
HostAccountID: IntElement
IsEditable: BoolElement
[docs]
@dataclass
class AccountListResponseRecord:
APRorAPY: StringElement
Aba: StringElement
Access: IntElement
AccountDesc: StringElement
AccountNumberInternal: StringElement
AllowInterest: BoolElement
AllowPrincipal: BoolElement
Balance1: FloatElement
Balance2: StringElement
Balance3: StringElement
BalanceAdditionalDescription1: StringElement
BalanceAdditionalDescription2: StringElement
BalanceDescription1: StringElement
BalanceDescription2: StringElement
BalanceDescription3: StringElement
BalanceName1: StringElement
BalanceName2: StringElement
BalanceName3: StringElement
BalanceToDisplay: FloatElement
BalanceToDisplayDescription: StringElement
BalanceToDisplayTransferTo: StringElement
BalanceToDisplayTransferToDescription: StringElement
BalanceType1: StringElement
BalanceType2: StringElement
BalanceType3: StringElement
CalculateRunningBalanceForMemos: BoolElement
CalculateRunningBalanceForyHistory: BoolElement
Cif: StringElement
CifExternal: StringElement
CifInternal: StringElement
DataAsOfDate: StringElement
DefaultPaymentAmountTransferFrom: StringElement
DefaultPaymentAmountTransferFromDescription: StringElement
DisplayOrder: IntElement
DisplayRunningBalance: BoolElement
HasPendingMemos: BoolElement
HistoryCount: IntElement
HistoryCountType: StringElement
HostAccountID: IntElement
HydraProductCode: StringElement
HydraProductTypeCode: StringElement
IsExternalAccount: BoolElement
IsPartialDetails: BoolElement
IsPriority: BoolElement
LinkType: StringElement
MaskedCifExternal: StringElement
MaskedCifInternal: StringElement
OverviewAccountNumber: StringElement
ProductID: IntElement
ProductName: StringElement
ProductTypeID: IntElement
ProductTypeName: StringElement
ProductTypeVoiceFile: StringElement
ProductVoiceFile: StringElement
RunningBalanceHadeNameToUse: StringElement
SortValue: StringElement
UserDisplayOrder: IntElement
UserID: IntElement
allowClose: BoolElement
canDisputeTransactions: BoolElement
[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 = WedgeOnlineBankingRequest("GetAccounts", 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(
"GetAccounts.get_soap is deprecated. Please use GetAccounts.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(
"GetAccounts.get_json is deprecated. Please use GetAccounts.execute instead."
)
return await execute(params_obj, use_json=True, **kwargs)
[docs]
def build_json(params_obj: ParamsObj):
return WedgeOnlineBankingRequest.build_json(params_obj)
[docs]
def build_soap(params_obj: ParamsObj):
return WedgeOnlineBankingRequest("GetAccounts", use_json=False).build_soap(
params_obj
)