from typing import Optional
[docs]
class HqCommands:
"""
For use with sending special instructions to HQ via an execute_request_as_xml response
"""
class AccountReloadType:
FROM_DB = 0
FROM_HOST = 1
NO_RELOAD = 3
@staticmethod
def get_reload_types():
return [
HqCommands.AccountReloadType.FROM_DB,
HqCommands.AccountReloadType.FROM_HOST,
HqCommands.AccountReloadType.NO_RELOAD,
]
def __init__(
self,
reload_type: AccountReloadType,
accounts_to_reload: list,
force_success_response=False,
disclaimer_id_to_skip: Optional[int] = None,
):
"""
:param reload_type: Reload from either Q2's database or the Host Adapter
:param accounts_to_reload: List of account numbers (host account ids HAIDs).
If blank, will reload ALL accounts (This can be expensive and is not recommended)
:param force_success_response: Must be set to True to allow Disclaimers to move on with their flow
:param disclaimer_id_to_skip: Q2_DisclaimerFormData.DisclaimerFormDataID.
If set, will mark the disclaimer viewed for the duration of the online session
"""
assert reload_type in self.AccountReloadType.get_reload_types(), (
"reload_type must be a valid HqCommands.AccountReloadType"
)
assert isinstance(accounts_to_reload, list), "accounts_to_reload must be a list"
self.reload_account_list_from_db = (
False # Will refresh all the users accounts from the DB
)
self.reload_account_list_from_host = (
False # Will refresh all the users accounts from the HOST
)
self.reload_all_account_info = False # Will refresh only the accounts in the session, no longer supported by HQ
self.force_success_response = force_success_response
self.account_ids_to_reload = [] # Will only refresh the accounts found in the list. Refresh type will be determined by the system.
self.disclaimer_id_to_skip = disclaimer_id_to_skip
# HQ Team states that only one of the 3 flags or a list of HAIDs should be set at a time
if reload_type != self.AccountReloadType.NO_RELOAD:
if accounts_to_reload:
self.account_ids_to_reload = accounts_to_reload
elif reload_type == self.AccountReloadType.FROM_DB:
self.reload_account_list_from_db = True
elif reload_type == self.AccountReloadType.FROM_HOST:
self.reload_account_list_from_host = True