Source code for q2_sdk.hq.hq_api.q2_api.GetAccountHistoryById

# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again

"""
Get host account history by host account id

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-29T14:26:41.9020088-06:00">
        <Result>
            <ErrorCode ErrorType="Success">0</ErrorCode>
            <ErrorDescription/>
            <HydraErrorReturnCode>0</HydraErrorReturnCode>
        </Result>
        <Data>
            <AllHostTransactions>
                <Transactions>
                    <!--AllTransactionType indicates type of transaction (0 = Posted, 1 = Memo, 2 = Insufficient Funds -->
                    <AllTransactionType>0</AllTransactionType>
                    <TransactionID>1</TransactionID>
                    <HostAccountID>5000</HostAccountID>
                    <PostDate>2017-04-25T11:12:17-05:00</PostDate>
                    <TxnAmount>-1323.2500</TxnAmount>
                    <Description>Check</Description>
                    <HostTranNumber>01</HostTranNumber>
                    <DorC>D</DorC>
                    <ShowImage>true</ShowImage>
                    <HostTranCodeID>5</HostTranCodeID>
                    <OfxTrnType>CHECK</OfxTrnType>
                    <OfxCheckNumHandling>0</OfxCheckNumHandling>
                    <RunningBalance>8676.7500</RunningBalance>
                    <ShowTransactionItemDetail>true</ShowTransactionItemDetail>
                    <SignedTxnAmount>1323.2500</SignedTxnAmount>
                    <StatementDescription>Check</StatementDescription>
                </Transactions>
            </AllHostTransactions>
        </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 GetAccountHistoryById""" def __init__( self, logger: Q2LoggerType, host_account_id: int, optional_filter: Optional[str] = None, hq_credentials: Optional[HqCredentials] = None, ): """ :param logger: Reference to calling request's logger (self.logger in your extension) :param host_account_id: Q2_HostAccount.HostAccountID :param optional_filter: :param hq_credentials: Defaults to settings.HQ_CREDENTIALS """ super().__init__(logger, hq_credentials) self.request_params.update({ "HostAccountId": host_account_id, "OptionalFilter": optional_filter, })
[docs] @dataclass class Transactions: AllTransactionType: IntElement Description: StringElement DorC: StringElement HostAccountID: IntElement HostTranCodeID: IntElement HostTranNumber: StringElement OfxCheckNumHandling: IntElement OfxTrnType: StringElement PostDate: StringElement RunningBalance: FloatElement ShowImage: BoolElement ShowTransactionItemDetail: BoolElement SignedTxnAmount: FloatElement StatementDescription: StringElement TransactionID: IntElement TxnAmount: FloatElement
[docs] @dataclass class AllHostTransactions: Transactions: Union[Transactions, List[Transactions]]
[docs] @dataclass class Data: AllHostTransactions: Union[AllHostTransactions, List[AllHostTransactions]]
[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("GetAccountHistoryById", 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( "GetAccountHistoryById.get_soap is deprecated. Please use GetAccountHistoryById.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( "GetAccountHistoryById.get_json is deprecated. Please use GetAccountHistoryById.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("GetAccountHistoryById", use_json=False).build_soap(params_obj)