# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
Add recurring Domestic Wire with no end date
"""
from typing import List, Optional
from lxml import etree
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.base import BaseParameter
from q2_sdk.hq.models.hq_params.q2_api import Q2ApiParamsObj
from q2_sdk.hq.models.hq_request.q2_api import Q2ApiRequest
[docs]
class Q2NameValuePair(BaseParameter):
def __init__(self, name: Optional[str] = None, value: Optional[str] = None):
self.name = name
self.value = value
[docs]
def serialize_as_xml(self):
root = etree.Element("Q2NameValuePair")
elem = etree.SubElement(root, "Name")
elem.text = str(self.name)
elem = etree.SubElement(root, "Value")
elem.text = str(self.value)
return root
[docs]
def serialize_as_json(self):
return {
"Name": self.name,
"Value": self.value,
}
[docs]
class Pairs(BaseParameter):
def __init__(self, q2_name_value_pair: Optional[List[Q2NameValuePair]] = None):
self.q2_name_value_pair = q2_name_value_pair
[docs]
def serialize_as_xml(self):
root = etree.Element("Pairs")
if self.q2_name_value_pair is not None:
for elem in self.q2_name_value_pair:
root.append(elem.serialize_as_xml())
return root
[docs]
def serialize_as_json(self):
return [x.serialize_as_json() for x in self.q2_name_value_pair]
[docs]
class Item(BaseParameter):
def __init__(self, name: Optional[str] = None, value: Optional[str] = None):
self.name = name
self.value = value
[docs]
def serialize_as_xml(self):
root = etree.Element("Item")
elem = etree.SubElement(root, "Name")
elem.text = str(self.name)
elem = etree.SubElement(root, "Value")
elem.text = str(self.value)
return root
[docs]
def serialize_as_json(self):
return {
"Name": self.name,
"Value": self.value,
}
[docs]
class GtData(BaseParameter):
def __init__(
self, count: int, item: Optional[Item] = None, pairs: Optional[Pairs] = None
):
self.count = count
self.item = item
self.pairs = pairs
[docs]
def serialize_as_xml(self):
root = etree.Element("GtData")
elem = etree.SubElement(root, "Count")
elem.text = str(self.count)
if self.item is not None:
for elem in self.item:
root.append(elem.serialize_as_xml())
if self.pairs is not None:
for elem in self.pairs:
root.append(elem.serialize_as_xml())
return root
[docs]
def serialize_as_json(self):
return {
"Count": self.count,
"Item": self.item,
"Pairs": self.pairs,
}
[docs]
class ParamsObj(Q2ApiParamsObj):
"""Parameters definition for AddRecurringDomesticWireNoEndByUserId"""
def __init__(
self,
logger: Q2LoggerType,
user_id: int,
originating_account_id: int,
process_date: str,
transaction_amount: float,
currency_code_id: int,
recip_country_id: int,
subsidiary_id: int,
recip_fi_country_id: int,
intermed_country_id: int,
recurring_transaction_type: str,
every_xweeks_or_months: int,
frequency_bit_flags: int,
start_date: str,
description: Optional[str] = None,
to_account: Optional[str] = None,
to_account_type: Optional[str] = None,
recip_name: Optional[str] = None,
recip_address1: Optional[str] = None,
recip_address2: Optional[str] = None,
recip_city: Optional[str] = None,
recip_state: Optional[str] = None,
recip_postal_code: Optional[str] = None,
recip_address3: Optional[str] = None,
email_address: Optional[str] = None,
recip_fi_aba: Optional[str] = None,
recip_fi_name: Optional[str] = None,
recip_fi_address1: Optional[str] = None,
recip_fi_address2: Optional[str] = None,
recip_fi_city: Optional[str] = None,
recip_fi_state: Optional[str] = None,
recip_fi_postal_code: Optional[str] = None,
intermed_aba: Optional[str] = None,
intermed_name: Optional[str] = None,
intermed_address1: Optional[str] = None,
intermed_address2: Optional[str] = None,
intermed_city: Optional[str] = None,
intermed_state: Optional[str] = None,
intermed_postal_code: Optional[str] = None,
orig_to_benf_info: Optional[str] = None,
gt_data: Optional[GtData] = None,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param user_id: Q2_User.UserID
:param originating_account_id: Q2_HostAccount.HostAccountID
:param process_date: ex. 1980-10-23. Some HQ endpoints require a timestamp as well (1980-10-23T00:00:00)
:param transaction_amount: ex. 2.43
:param currency_code_id: Q2_CurrentyCode.CurrencyCodeID
:param recip_country_id:
:param subsidiary_id: Q2_Subsidiary.SubsidiaryID
:param recip_fi_country_id: Q2_Country.CountryID
:param intermed_country_id:
:param recurring_transaction_type: Value from `q2_sdk.hq.models.transaction_info.RecurringTransactionType`
:param every_xweeks_or_months: Applies to Weeks or Months based on the value in recurring_transaction_type
:param frequency_bit_flags: Calculated using `q2_sdk.hq.api_helpers.get_frequency_bit_flags`
:param start_date: ex. 1980-10-23. Some HQ endpoints require a timestamp as well (1980-10-23T00:00:00)
:param description: Free form text
:param to_account: Q2_HostAccount.HostAccountID
:param to_account_type:
:param recip_name: Friendly name of Recipient
:param recip_address1: Recipient's Address1 Line
:param recip_address2: Recipient's Address2 Line
:param recip_city:
:param recip_state:
:param recip_postal_code:
:param recip_address3: Recipient's Address3 Line
:param email_address: ex. test@q2ebanking.com
:param recip_fi_aba:
:param recip_fi_name: Name of Recipient's FI
:param recip_fi_address1: Address1 Line of Recipient's FI
:param recip_fi_address2: Address2 Line of Recipient's FI
:param recip_fi_city:
:param recip_fi_state:
:param recip_fi_postal_code:
:param intermed_aba:
:param intermed_name:
:param intermed_address1:
:param intermed_address2:
:param intermed_city:
:param intermed_state:
:param intermed_postal_code:
:param orig_to_benf_info:
:param gt_data:
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"UserId": user_id,
"OriginatingAccountId": originating_account_id,
"ProcessDate": process_date,
"TransactionAmount": transaction_amount,
"CurrencyCodeId": currency_code_id,
"Description": description,
"ToAccount": to_account,
"ToAccountType": to_account_type,
"RecipName": recip_name,
"RecipAddress1": recip_address1,
"RecipAddress2": recip_address2,
"RecipCity": recip_city,
"RecipState": recip_state,
"RecipPostalCode": recip_postal_code,
"RecipCountryId": recip_country_id,
"RecipAddress3": recip_address3,
"EmailAddress": email_address,
"SubsidiaryId": subsidiary_id,
"RecipFiABA": recip_fi_aba,
"RecipFiName": recip_fi_name,
"RecipFiAddress1": recip_fi_address1,
"RecipFiAddress2": recip_fi_address2,
"RecipFiCity": recip_fi_city,
"RecipFiState": recip_fi_state,
"RecipFiPostalCode": recip_fi_postal_code,
"RecipFiCountryId": recip_fi_country_id,
"IntermedABA": intermed_aba,
"IntermedName": intermed_name,
"IntermedAddress1": intermed_address1,
"IntermedAddress2": intermed_address2,
"IntermedCity": intermed_city,
"IntermedState": intermed_state,
"IntermedPostalCode": intermed_postal_code,
"IntermedCountryId": intermed_country_id,
"OrigToBenfInfo": orig_to_benf_info,
"RecurringTransactionType": recurring_transaction_type,
"EveryXweeksOrMonths": every_xweeks_or_months,
"FrequencyBitFlags": frequency_bit_flags,
"StartDate": start_date,
"GtData": gt_data,
})
[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(
"AddRecurringDomesticWireNoEndByUserId", 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(
"AddRecurringDomesticWireNoEndByUserId.get_soap is deprecated. Please use AddRecurringDomesticWireNoEndByUserId.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(
"AddRecurringDomesticWireNoEndByUserId.get_json is deprecated. Please use AddRecurringDomesticWireNoEndByUserId.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(
"AddRecurringDomesticWireNoEndByUserId", use_json=False
).build_soap(params_obj)