# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
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 elementValue(BaseParameter):
def __init__(
self,
):
pass
[docs]
def serialize_as_xml(self):
root = etree.Element("elementValue")
return root
[docs]
def serialize_as_json(self):
return {}
[docs]
class RTPEnumerationValue(BaseParameter):
def __init__(
self,
additional_value_allowed: bool,
additional_value_required: bool,
data_value: Optional[str] = None,
display_text: Optional[str] = None,
):
self.additional_value_allowed = additional_value_allowed
self.additional_value_required = additional_value_required
self.data_value = data_value
self.display_text = display_text
[docs]
def serialize_as_xml(self):
root = etree.Element("RTPEnumerationValue")
elem = etree.SubElement(root, "AdditionalValueAllowed")
elem.text = str(self.additional_value_allowed.real)
elem = etree.SubElement(root, "AdditionalValueRequired")
elem.text = str(self.additional_value_required.real)
elem = etree.SubElement(root, "DataValue")
elem.text = str(self.data_value)
elem = etree.SubElement(root, "DisplayText")
elem.text = str(self.display_text)
return root
[docs]
def serialize_as_json(self):
return {
"AdditionalValueAllowed": self.additional_value_allowed,
"AdditionalValueRequired": self.additional_value_required,
"DataValue": self.data_value,
"DisplayText": self.display_text,
}
[docs]
class possibleEnumerationValues(BaseParameter):
def __init__(
self, rtp_enumeration_value: Optional[List[RTPEnumerationValue]] = None
):
self.rtp_enumeration_value = rtp_enumeration_value
[docs]
def serialize_as_xml(self):
root = etree.Element("possibleEnumerationValues")
if self.rtp_enumeration_value is not None:
for elem in self.rtp_enumeration_value:
root.append(elem.serialize_as_xml())
return root
[docs]
def serialize_as_json(self):
return [x.serialize_as_json() for x in self.rtp_enumeration_value]
[docs]
class RTPDataElementResponse(BaseParameter):
def __init__(
self,
required: int,
data_element_id: int,
data_type_id: int,
vendor_id: int,
validation_required_pass: bool,
validation_required_if_element_is_populated_pass: bool,
validation_regex_pass: bool,
validation_type_pass: bool,
validation_enumeration_value_pass: bool,
max_occurrences: int,
additional_value_length: int,
is_enumeration: bool,
possible_enumeration_values: Optional[possibleEnumerationValues] = None,
vendor_name: Optional[str] = None,
source: Optional[str] = None,
required_if_element_is_populated: Optional[str] = None,
regex: Optional[str] = None,
data_element_name: Optional[str] = None,
request_type: Optional[str] = None,
data_type_name: Optional[str] = None,
element_value: Optional[elementValue] = None,
ui_configuration: Optional[str] = None,
additional_value: Optional[str] = None,
):
self.possible_enumeration_values = possible_enumeration_values
self.vendor_name = vendor_name
self.source = source
self.required_if_element_is_populated = required_if_element_is_populated
self.required = required
self.regex = regex
self.data_element_name = data_element_name
self.data_element_id = data_element_id
self.request_type = request_type
self.data_type_id = data_type_id
self.data_type_name = data_type_name
self.vendor_id = vendor_id
self.element_value = element_value
self.validation_required_pass = validation_required_pass
self.validation_required_if_element_is_populated_pass = (
validation_required_if_element_is_populated_pass
)
self.validation_regex_pass = validation_regex_pass
self.validation_type_pass = validation_type_pass
self.validation_enumeration_value_pass = validation_enumeration_value_pass
self.ui_configuration = ui_configuration
self.max_occurrences = max_occurrences
self.additional_value_length = additional_value_length
self.additional_value = additional_value
self.is_enumeration = is_enumeration
[docs]
def serialize_as_xml(self):
root = etree.Element("RTPDataElementResponse")
if self.possible_enumeration_values is not None:
for elem in self.possible_enumeration_values:
root.append(elem.serialize_as_xml())
elem = etree.SubElement(root, "vendorName")
elem.text = str(self.vendor_name)
elem = etree.SubElement(root, "source")
elem.text = str(self.source)
elem = etree.SubElement(root, "requiredIfElementIsPopulated")
elem.text = str(self.required_if_element_is_populated)
elem = etree.SubElement(root, "required")
elem.text = str(self.required)
elem = etree.SubElement(root, "regex")
elem.text = str(self.regex)
elem = etree.SubElement(root, "dataElementName")
elem.text = str(self.data_element_name)
elem = etree.SubElement(root, "dataElementID")
elem.text = str(self.data_element_id)
elem = etree.SubElement(root, "requestType")
elem.text = str(self.request_type)
elem = etree.SubElement(root, "dataTypeID")
elem.text = str(self.data_type_id)
elem = etree.SubElement(root, "dataTypeName")
elem.text = str(self.data_type_name)
elem = etree.SubElement(root, "vendorID")
elem.text = str(self.vendor_id)
if self.element_value is not None:
for elem in self.element_value:
root.append(elem.serialize_as_xml())
elem = etree.SubElement(root, "validationRequiredPass")
elem.text = str(self.validation_required_pass.real)
elem = etree.SubElement(root, "validationRequiredIfElementIsPopulatedPass")
elem.text = str(self.validation_required_if_element_is_populated_pass.real)
elem = etree.SubElement(root, "validationRegexPass")
elem.text = str(self.validation_regex_pass.real)
elem = etree.SubElement(root, "validationTypePass")
elem.text = str(self.validation_type_pass.real)
elem = etree.SubElement(root, "validationEnumerationValuePass")
elem.text = str(self.validation_enumeration_value_pass.real)
elem = etree.SubElement(root, "uiConfiguration")
elem.text = str(self.ui_configuration)
elem = etree.SubElement(root, "maxOccurrences")
elem.text = str(self.max_occurrences)
elem = etree.SubElement(root, "additionalValueLength")
elem.text = str(self.additional_value_length)
elem = etree.SubElement(root, "additionalValue")
elem.text = str(self.additional_value)
elem = etree.SubElement(root, "isEnumeration")
elem.text = str(self.is_enumeration.real)
return root
[docs]
def serialize_as_json(self):
return {
"possibleEnumerationValues": self.possible_enumeration_values,
"vendorName": self.vendor_name,
"source": self.source,
"requiredIfElementIsPopulated": self.required_if_element_is_populated,
"required": self.required,
"regex": self.regex,
"dataElementName": self.data_element_name,
"dataElementID": self.data_element_id,
"requestType": self.request_type,
"dataTypeID": self.data_type_id,
"dataTypeName": self.data_type_name,
"vendorID": self.vendor_id,
"elementValue": self.element_value,
"validationRequiredPass": self.validation_required_pass,
"validationRequiredIfElementIsPopulatedPass": self.validation_required_if_element_is_populated_pass,
"validationRegexPass": self.validation_regex_pass,
"validationTypePass": self.validation_type_pass,
"validationEnumerationValuePass": self.validation_enumeration_value_pass,
"uiConfiguration": self.ui_configuration,
"maxOccurrences": self.max_occurrences,
"additionalValueLength": self.additional_value_length,
"additionalValue": self.additional_value,
"isEnumeration": self.is_enumeration,
}
[docs]
class RtpDataElements(BaseParameter):
def __init__(
self, rtp_data_element_response: Optional[List[RTPDataElementResponse]] = None
):
self.rtp_data_element_response = rtp_data_element_response
[docs]
def serialize_as_xml(self):
root = etree.Element("RtpDataElements")
if self.rtp_data_element_response is not None:
for elem in self.rtp_data_element_response:
root.append(elem.serialize_as_xml())
return root
[docs]
def serialize_as_json(self):
return [x.serialize_as_json() for x in self.rtp_data_element_response]
[docs]
class ParamsObj(Q2ApiParamsObj):
"""Parameters definition for AcceptIncomingRealTimePaymentTransaction"""
def __init__(
self,
logger: Q2LoggerType,
transaction_amount: float,
amount_modification_allowed: bool,
vendor_name: Optional[str] = None,
local_external_account_number: Optional[str] = None,
request_type_short_name: Optional[str] = None,
rtp_data_elements: Optional[RtpDataElements] = None,
currency_code: Optional[str] = "USD",
description: Optional[str] = None,
local_entity_name: Optional[str] = None,
local_entity_identifier: Optional[str] = None,
local_entity_tax_id: Optional[str] = None,
local_entity_address1: Optional[str] = None,
local_entity_address2: Optional[str] = None,
local_entity_address3: Optional[str] = None,
local_entity_city: Optional[str] = None,
local_entity_state: Optional[str] = None,
local_entity_postal_code: Optional[str] = None,
local_entity_country_code: Optional[str] = None,
local_entity_email_address: Optional[str] = None,
local_entity_phone_number: Optional[str] = None,
local_entity_phone_country_code: Optional[str] = None,
remote_entity_name: Optional[str] = None,
remote_entity_identifier: Optional[str] = None,
remote_entity_address1: Optional[str] = None,
remote_entity_address2: Optional[str] = None,
remote_entity_address3: Optional[str] = None,
remote_entity_city: Optional[str] = None,
remote_entity_state: Optional[str] = None,
remote_entity_postal_code: Optional[str] = None,
remote_entity_country_code: Optional[str] = None,
remote_entity_email_address: Optional[str] = None,
remote_entity_phone_number: Optional[str] = None,
remote_entity_phone_country_code: Optional[str] = None,
remote_fi_account_number: Optional[str] = None,
remote_fi_account_type: Optional[str] = None,
remote_fi_routing_number: Optional[str] = None,
remote_fi_name: Optional[str] = None,
remote_fi_address1: Optional[str] = None,
remote_fi_address2: Optional[str] = None,
remote_fi_address3: Optional[str] = None,
remote_fi_city: Optional[str] = None,
remote_fi_state: Optional[str] = None,
remote_fi_postal_code: Optional[str] = None,
remote_fi_country_code: Optional[str] = None,
intermed_fi_routing_number: Optional[str] = None,
intermed_fi_name: Optional[str] = None,
intermed_fi_address1: Optional[str] = None,
intermed_fi_address2: Optional[str] = None,
intermed_fi_address3: Optional[str] = None,
intermed_fi_city: Optional[str] = None,
intermed_fi_state: Optional[str] = None,
intermed_fi_postal_code: Optional[str] = None,
intermed_fi_country_code: Optional[str] = None,
recipient_display_name: Optional[str] = None,
service_call_unique_identifier: Optional[str] = None,
service_call_conversation_identifier: Optional[str] = None,
service_call_response_raw: Optional[str] = None,
expiry_date: Optional[str] = None,
requested_execution_date: Optional[str] = None,
hq_credentials: Optional[HqCredentials] = None,
):
"""
:param logger: Reference to calling request's logger (self.logger in your extension)
:param transaction_amount: ex. 2.43
:param amount_modification_allowed:
:param vendor_name:
:param local_external_account_number:
:param request_type_short_name:
:param rtp_data_elements:
:param currency_code: Q2_CurrencyCode.CurrencyCode. The currency to use for a transaction. This will almost always be "USD"
:param description: Free form text
:param local_entity_name:
:param local_entity_identifier:
:param local_entity_tax_id:
:param local_entity_address1:
:param local_entity_address2:
:param local_entity_address3:
:param local_entity_city:
:param local_entity_state:
:param local_entity_postal_code:
:param local_entity_country_code:
:param local_entity_email_address:
:param local_entity_phone_number:
:param local_entity_phone_country_code:
:param remote_entity_name:
:param remote_entity_identifier:
:param remote_entity_address1:
:param remote_entity_address2:
:param remote_entity_address3:
:param remote_entity_city:
:param remote_entity_state:
:param remote_entity_postal_code:
:param remote_entity_country_code:
:param remote_entity_email_address:
:param remote_entity_phone_number:
:param remote_entity_phone_country_code:
:param remote_fi_account_number:
:param remote_fi_account_type:
:param remote_fi_routing_number:
:param remote_fi_name:
:param remote_fi_address1:
:param remote_fi_address2:
:param remote_fi_address3:
:param remote_fi_city:
:param remote_fi_state:
:param remote_fi_postal_code:
:param remote_fi_country_code:
:param intermed_fi_routing_number:
:param intermed_fi_name:
:param intermed_fi_address1:
:param intermed_fi_address2:
:param intermed_fi_address3:
:param intermed_fi_city:
:param intermed_fi_state:
:param intermed_fi_postal_code:
:param intermed_fi_country_code:
:param recipient_display_name:
:param service_call_unique_identifier:
:param service_call_conversation_identifier:
:param service_call_response_raw:
:param expiry_date:
:param requested_execution_date:
:param hq_credentials: Defaults to settings.HQ_CREDENTIALS
"""
super().__init__(logger, hq_credentials)
self.request_params.update({
"VendorName": vendor_name,
"LocalExternalAccountNumber": local_external_account_number,
"RequestTypeShortName": request_type_short_name,
"RtpDataElements": rtp_data_elements,
"TransactionAmount": transaction_amount,
"CurrencyCode": currency_code,
"Description": description,
"LocalEntityName": local_entity_name,
"LocalEntityIdentifier": local_entity_identifier,
"LocalEntityTaxId": local_entity_tax_id,
"LocalEntityAddress1": local_entity_address1,
"LocalEntityAddress2": local_entity_address2,
"LocalEntityAddress3": local_entity_address3,
"LocalEntityCity": local_entity_city,
"LocalEntityState": local_entity_state,
"LocalEntityPostalCode": local_entity_postal_code,
"LocalEntityCountryCode": local_entity_country_code,
"LocalEntityEmailAddress": local_entity_email_address,
"LocalEntityPhoneNumber": local_entity_phone_number,
"LocalEntityPhoneCountryCode": local_entity_phone_country_code,
"RemoteEntityName": remote_entity_name,
"RemoteEntityIdentifier": remote_entity_identifier,
"RemoteEntityAddress1": remote_entity_address1,
"RemoteEntityAddress2": remote_entity_address2,
"RemoteEntityAddress3": remote_entity_address3,
"RemoteEntityCity": remote_entity_city,
"RemoteEntityState": remote_entity_state,
"RemoteEntityPostalCode": remote_entity_postal_code,
"RemoteEntityCountryCode": remote_entity_country_code,
"RemoteEntityEmailAddress": remote_entity_email_address,
"RemoteEntityPhoneNumber": remote_entity_phone_number,
"RemoteEntityPhoneCountryCode": remote_entity_phone_country_code,
"RemoteFIAccountNumber": remote_fi_account_number,
"RemoteFIAccountType": remote_fi_account_type,
"RemoteFIRoutingNumber": remote_fi_routing_number,
"RemoteFIName": remote_fi_name,
"RemoteFIAddress1": remote_fi_address1,
"RemoteFIAddress2": remote_fi_address2,
"RemoteFIAddress3": remote_fi_address3,
"RemoteFICity": remote_fi_city,
"RemoteFIState": remote_fi_state,
"RemoteFIPostalCode": remote_fi_postal_code,
"RemoteFICountryCode": remote_fi_country_code,
"IntermedFIRoutingNumber": intermed_fi_routing_number,
"IntermedFIName": intermed_fi_name,
"IntermedFIAddress1": intermed_fi_address1,
"IntermedFIAddress2": intermed_fi_address2,
"IntermedFIAddress3": intermed_fi_address3,
"IntermedFICity": intermed_fi_city,
"IntermedFIState": intermed_fi_state,
"IntermedFIPostalCode": intermed_fi_postal_code,
"IntermedFICountryCode": intermed_fi_country_code,
"RecipientDisplayName": recipient_display_name,
"ServiceCallUniqueIdentifier": service_call_unique_identifier,
"ServiceCallConversationIdentifier": service_call_conversation_identifier,
"ServiceCallResponseRaw": service_call_response_raw,
"ExpiryDate": expiry_date,
"RequestedExecutionDate": requested_execution_date,
"AmountModificationAllowed": amount_modification_allowed,
})
[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(
"AcceptIncomingRealTimePaymentTransaction", 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(
"AcceptIncomingRealTimePaymentTransaction.get_soap is deprecated. Please use AcceptIncomingRealTimePaymentTransaction.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(
"AcceptIncomingRealTimePaymentTransaction.get_json is deprecated. Please use AcceptIncomingRealTimePaymentTransaction.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(
"AcceptIncomingRealTimePaymentTransaction", use_json=False
).build_soap(params_obj)