# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Get account list by internal CIF
Sample response (may differ slightly in your environment)
.. code-block:: xml
<Q2API HqAssemblyVersion="4.2.6185.31252" HqVersion="4.2.3.4215A" ServerDateTime="2018-02-13T16:25:55.0150014-06:00">
<Result>
<ErrorCode ErrorType="Success">0</ErrorCode>
<ErrorDescription/>
<HydraErrorReturnCode>0</HydraErrorReturnCode>
</Result>
<Data>
<DalHostAccountLookup>
<Q2_HostAccountLookup>
<HostAccountID>5003</HostAccountID>
<AccountNumberInternal>8683224</AccountNumberInternal>
<AccountDesc>Main Checking</AccountDesc>
<CIFInternal>HQ_Test_9229627</CIFInternal>
<BranchID>1</BranchID>
<ProductID>1</ProductID>
<ProductName>Regular Checking</ProductName>
<HydraProductCode>C</HydraProductCode>
<ProductTypeID>1</ProductTypeID>
<ProductTypeName>Deposit</ProductTypeName>
<HydraProductTypeCode>D</HydraProductTypeCode>
<HostProductCode>01</HostProductCode>
<HostProductTypeCode>D</HostProductTypeCode>
<IsExternalAccount>false</IsExternalAccount>
</Q2_HostAccountLookup>
<Q2_HostAccountLookup>
<HostAccountID>5004</HostAccountID>
<AccountNumberInternal>1161171</AccountNumberInternal>
<AccountDesc>Payroll Checking</AccountDesc>
<CIFInternal>HQ_Test_9229627</CIFInternal>
<BranchID>1</BranchID>
<ProductID>1</ProductID>
<ProductName>Regular Checking</ProductName>
<HydraProductCode>C</HydraProductCode>
<ProductTypeID>1</ProductTypeID>
<ProductTypeName>Deposit</ProductTypeName>
<HydraProductTypeCode>D</HydraProductTypeCode>
<HostProductCode>01</HostProductCode>
<HostProductTypeCode>D</HostProductTypeCode>
<IsExternalAccount>false</IsExternalAccount>
</Q2_HostAccountLookup>
<Q2_HostAccountLookup>
<HostAccountID>5005</HostAccountID>
<AccountNumberInternal>3891655</AccountNumberInternal>
<AccountDesc>Emergency Savings</AccountDesc>
<CIFInternal>HQ_Test_9229627</CIFInternal>
<BranchID>1</BranchID>
<ProductID>3</ProductID>
<ProductName>Regular Savings</ProductName>
<HydraProductCode>S</HydraProductCode>
<ProductTypeID>1</ProductTypeID>
<ProductTypeName>Deposit</ProductTypeName>
<HydraProductTypeCode>D</HydraProductTypeCode>
<HostProductCode>03</HostProductCode>
<HostProductTypeCode>D</HostProductTypeCode>
<IsExternalAccount>false</IsExternalAccount>
</Q2_HostAccountLookup>
</DalHostAccountLookup>
</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 GetAccountListByCif"""
def __init__(
self,
logger: Q2LoggerType,
cif: str,
cif_is_internal: bool,
use_host_relation_table: bool,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param cif:
:param cif_is_internal:
:param use_host_relation_table:
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"Cif": cif,
"CifIsInternal": cif_is_internal,
"UseHostRelationTable": use_host_relation_table,
})
[docs]
@dataclass
class Q2_HostAccountLookup:
AccountDesc: StringElement
AccountNumberInternal: IntElement
BranchID: IntElement
CIFInternal: StringElement
HostAccountID: IntElement
HostProductCode: StringElement
HostProductTypeCode: StringElement
HydraProductCode: StringElement
HydraProductTypeCode: StringElement
IsExternalAccount: BoolElement
ProductID: IntElement
ProductName: StringElement
ProductTypeID: IntElement
ProductTypeName: StringElement
[docs]
@dataclass
class DalHostAccountLookup:
Q2_HostAccountLookup: Union[Q2_HostAccountLookup, List[Q2_HostAccountLookup]]
[docs]
@dataclass
class Data:
DalHostAccountLookup: Union[DalHostAccountLookup, List[DalHostAccountLookup]]
[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("GetAccountListByCif", 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(
"GetAccountListByCif.get_soap is deprecated. Please use GetAccountListByCif.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(
"GetAccountListByCif.get_json is deprecated. Please use GetAccountListByCif.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("GetAccountListByCif", use_json=False).build_soap(params_obj)