# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Add funds transfer
"""
from typing import List, Optional
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 AddFundsTransfer"""
def __init__(
self,
logger: Q2LoggerType,
hq_credentials: HqCredentials,
source_account_id: int,
target_account_id: int,
transaction_amount: float,
principal: float,
interest: float,
process_date: str,
transfer_type: int,
optional_description: Optional[str] = None,
currency_code: Optional[str] = "USD",
additional_data_name: Optional[str] = None,
additional_data_element: Optional[str] = None,
):
"""
: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
:param source_account_id: Q2_HostAccount.HostAccountID
:param target_account_id: Q2_HostAccount.HostAccountID
:param transaction_amount: ex. 2.43
:param principal: ex. 2.43
:param interest:
:param process_date: ex. 1980-10-23. Some HQ endpoints require a timestamp as well (1980-10-23T00:00:00)
:param transfer_type: From the Q2_GeneratedTransactionTypes table (accessible through TransactionType DbObject)
:param optional_description: Free form text
:param currency_code: Q2_CurrencyCode.CurrencyCode. The currency to use for a transaction. This will almost always be "USD"
:param additional_data_name:
:param additional_data_element:
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"SourceAccountId": source_account_id,
"TargetAccountId": target_account_id,
"TransactionAmount": transaction_amount,
"Principal": principal,
"Interest": interest,
"OptionalDescription": optional_description,
"ProcessDate": process_date,
"CurrencyCode": currency_code,
"TransferType": transfer_type,
"AdditionalDataName": additional_data_name,
"AdditionalDataElement": additional_data_element,
})
[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("AddFundsTransfer", 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(
"AddFundsTransfer.get_soap is deprecated. Please use AddFundsTransfer.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(
"AddFundsTransfer.get_json is deprecated. Please use AddFundsTransfer.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("AddFundsTransfer", use_json=False).build_soap(
params_obj
)