q2_sdk.hq.api_helpers
— Transformations for objects to HQ communication strings
A few of the HQ endpoints have some difficult to document inputs. For instance, xml_payload shows up in several of them, which can literally be any shape of xml. However, there is an appropriate shape per endpoint, which we try to build out here in this file.
You can pass the result of one of these functions as input to the functions generated into hq_api with generate_hq_api.
For instance:
from q2_sdk.hq.hq_api.q2_api import AddCustomer
xml_payload = build_add_customer_xml(demo_info, group_id, is_company) AddCustomer.ParamsObj(self.logger, xml_payload)
- q2_sdk.hq.api_helpers.build_add_customer_xml(demo_info, group_id, is_company, subsidiaries=None, host_user=None, host_pwd=None, allow_other_address_types=False)[source]
Transforms DemographicInfo into an xml_payload for use with HQ’s AddCustomer
- Parameters:
demo_info (
DemographicInfo
) – DemographicInfo instancegroup_id (
int
) – Which group the customer will be inserted intois_company (
bool
) – Sets some database fields appropriatelysubsidiaries (
Optional
[list
[Subsidiary
]]) – List of subsidiaries to add to Q2 customer. Normally used with commercial and/or treasury usershost_user (
Optional
[str
]) – populates the HostUser column on the Q2_Customer tablehost_pwd (
Optional
[str
]) – populates the HostPwd column on the Q2_Customer tableallow_other_address_types – turns off the Home only logic if True
- Return type:
str
- Returns:
Already escaped xml_payload
- q2_sdk.hq.api_helpers.build_add_user_xml(demo_info, customer_id, host_user=None, host_pwd=None, allow_other_address_types=False, *, null_primary_cif=False)[source]
Transforms DemographicInfo into an xml_payload for use with HQ’s AddUser
- Parameters:
demo_info (
DemographicInfo
) – DemographicInfo instancecustomer_id (
int
) – Which customer this user belongs tohost_user (
Optional
[str
]) – populates the HostUser column on the Q2_User tablehost_pwd (
Optional
[str
]) – populates the HostPwd column on the Q2_User tableallow_other_address_types – turns off the Home only logic if True
- Return type:
str
- Returns:
Already escaped xml_payload
- q2_sdk.hq.api_helpers.build_add_user_logon_xml(user_id, logon_name, password, skiptac=False, ui_source='OnlineBanking')[source]
Builds an xml_payload for use with HQ’s AddUserLogon
- Parameters:
user_id (
int
) – Which user this logon belongs tologon_name (
str
) – The string user will login to the online instance withpassword (
str
) – Password to register with the logon_nameskiptac (
bool
) – bool to skip tac flow on first loginui_source (
str
) – string that describes the ui source associated with the login
- Return type:
str
- Returns:
Already escaped xml_payload
- q2_sdk.hq.api_helpers.build_get_group_id_xml(group_name)[source]
Builds an xml_payload for use with HQ’s GetGroupID
- Parameters:
group_name (
str
) – Which group to find- Return type:
str
- Returns:
Already escaped xml_payload
- q2_sdk.hq.api_helpers.build_add_recipient_xml(display_name, customer_id, email_address, always_send_email, is_ccd, ach_name, is_international=False)[source]
Builds an xml_payload for use with HQ’s AddRecipient
- Parameters:
display_name (
str
) – Friendly name for the recipientcustomer_id (
int
) – Q2_Customer.CustomerIDemail_address (
str
) – Q2_Email.EmailAddressalways_send_email (
bool
)is_ccd (
bool
) – If False, will be set to PPDach_name (
str
) – Where the money is being sentis_international
- q2_sdk.hq.api_helpers.build_add_recipient_account_xml(recipient_id, account_number, account_type, aba, customer_id)[source]
Builds an xml_payload for use with HQ’s AddRecipientAccount
- Parameters:
recipient_id (
int
) – Q2_Recipient.RecipientIDaccount_number (
int
)account_type (
str
)aba (
str
)customer_id (
int
) – Q2_Customer.CustomerID
- q2_sdk.hq.api_helpers.build_secure_message_xml(source_id, target_id, message_subject, message_body, sender_type='Administrator', target_type='AdministratorGroup', creation_time=None, expiration_time=None, attachment=None)[source]
Builds an xml_payload for use with HQ’s SendSecureMessageAsXML
- Parameters:
source_id (
int
) – “from” group idtarget_id (
int
) – recipient IDmessage_subject (
str
) – Subject of the secure messagemessage_body (
str
) – Body of the secure messagesender_type (
Optional
[SecureMessengerType
]) – Optional choice fromSecureMessengerType
. Defaults to Administratortarget_type (
Optional
[SecureMessengerType
]) – Optional choice fromSecureMessengerType
. Defaults to AdministratorGroupcreation_time (
Optional
[datetime
]) – Time message was generatedexpiration_time (
Optional
[datetime
]) – Timestamp at which message will expireattachment (
Optional
[SecureMessageAttachment
]) – Optional choice fromSecureMessageAttachment
.
- Returns:
Already escaped xml_payload
- q2_sdk.hq.api_helpers.build_update_demographics_by_logon_name_xml(login_name, demographic_info)[source]
Transforms login_name and DemographicInfo into an xml_payload for use with apispUpdateDemographicsByLogonName_RT stored procedure
- Parameters:
login_name (
str
) – The string user will login to the online instance withdemographic_info (
DemographicInfo
) – Instance of q2_sdk.models.demographic.DemographicInfo
- Return type:
str
- q2_sdk.hq.api_helpers.generate_user_logon_password(policy_obj)[source]
Uses the parameters of the password policy to generate a valid password to be used when creating a login :rtype:
str
:return: a valid password
- q2_sdk.hq.api_helpers.get_frequency_bit_flags(days_of_week=None, weeks_of_month=None, days_of_month=None)[source]
- Parameters:
days_of_week (
Optional
[list
[DayOfWeek
]]) – List ofq2_sdk.hq.models.transaction_info.DayOfWeek
objectsweeks_of_month (
Optional
[list
[WeekOfMonth
]]) – List ofq2_sdk.hq.models.transaction_info.WeekOfMonth
objectsdays_of_month (
Optional
[list
[int
]]) – ex. [1, 15] for 1st and 15th of month
- Return type:
Optional
[int
]
For use with the various AddRecurring* modules in HqApi
Example usage:
from q2_sdk.hq.models.transaction_info import DayOfWeek, WeekOfMonth flags = get_frequency_bit_flags( [ DayOfWeek.Monday, DayOfWeek.Tuesday ], [ WeekOfMonth.First ] )
This would set
flags
to an integer that meant ‘Monday and Tuesday on the First week of the month’.