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 instance

  • group_id (int) – Which group the customer will be inserted into

  • is_company (bool) – Sets some database fields appropriately

  • subsidiaries (Optional[list[Subsidiary]]) – List of subsidiaries to add to Q2 customer. Normally used with commercial and/or treasury users

  • host_user (Optional[str]) – populates the HostUser column on the Q2_Customer table

  • host_pwd (Optional[str]) – populates the HostPwd column on the Q2_Customer table

  • allow_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 instance

  • customer_id (int) – Which customer this user belongs to

  • host_user (Optional[str]) – populates the HostUser column on the Q2_User table

  • host_pwd (Optional[str]) – populates the HostPwd column on the Q2_User table

  • allow_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 to

  • logon_name (str) – The string user will login to the online instance with

  • password (str) – Password to register with the logon_name

  • skiptac (bool) – bool to skip tac flow on first login

  • ui_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 recipient

  • customer_id (int) – Q2_Customer.CustomerID

  • email_address (str) – Q2_Email.EmailAddress

  • always_send_email (bool)

  • is_ccd (bool) – If False, will be set to PPD

  • ach_name (str) – Where the money is being sent

  • is_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.RecipientID

  • account_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 id

  • target_id (int) – recipient ID

  • message_subject (str) – Subject of the secure message

  • message_body (str) – Body of the secure message

  • sender_type (Optional[SecureMessengerType]) – Optional choice from SecureMessengerType. Defaults to Administrator

  • target_type (Optional[SecureMessengerType]) – Optional choice from SecureMessengerType. Defaults to AdministratorGroup

  • creation_time (Optional[datetime]) – Time message was generated

  • expiration_time (Optional[datetime]) – Timestamp at which message will expire

  • attachment (Optional[SecureMessageAttachment]) – Optional choice from SecureMessageAttachment.

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 with

  • demographic_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:
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’.