EnrolledEntity

exception q2_sdk.hq.db.enrolled_entity.EnrollmentException(message, number, detail)[source]

Bases: Exception

Enrollment Exception handling class

exception q2_sdk.hq.db.enrolled_entity.CustomerExistsError(message, number, detail)[source]

Bases: EnrollmentException

Customer already exists in Q2’s database

exception q2_sdk.hq.db.enrolled_entity.UserExistsError(message, number, detail)[source]

Bases: EnrollmentException

User already exists in Q2’s database

exception q2_sdk.hq.db.enrolled_entity.LoginNameExistsError(message, number, detail)[source]

Bases: EnrollmentException

Login Name already exists in Q2’s database

class q2_sdk.hq.db.enrolled_entity.CreateCustomerParams(cust_info, group_id, is_company, host_user, host_pwd)[source]

Bases: object

Parameters needed to create a customer Note: grab_customer_data can be utilized to build the cust_info parameter

cust_info: DemographicInfo
group_id: int
is_company: bool
host_user: str
host_pwd: str
class q2_sdk.hq.db.enrolled_entity.CreateCustomerResult(success=False, reason=None, customer_id=None)[source]

Bases: object

Expected response object for create customer function

success: bool = False
reason: Optional[str] = None
customer_id: Optional[str] = None
class q2_sdk.hq.db.enrolled_entity.CreateCustomerDataParams(customer_id, name, value)[source]

Bases: object

Parameters needed to create customer data

customer_id: int
name: str
value: str
class q2_sdk.hq.db.enrolled_entity.CreateUserParams(user_info, customer_id, host_user, host_pwd, null_primary_cif=False)[source]

Bases: object

Parameters needed to create a user

user_info: DemographicInfo
customer_id: int
host_user: str
host_pwd: str
null_primary_cif: bool = False
class q2_sdk.hq.db.enrolled_entity.CreateUserResult(success=False, reason=None, user_id=None)[source]

Bases: object

Expected response object for create user function

success: bool = False
reason: Optional[str] = None
user_id: Optional[str] = None
class q2_sdk.hq.db.enrolled_entity.CreateUserLogonParams(user_id, logon_name, user_logon_obj, password=None, require_password_reset=True, group_id_for_zone_check=None)[source]

Bases: object

Parameters needed to create a logon

user_id: int
logon_name: str
user_logon_obj: UserLogon
password: Optional[str] = None
require_password_reset: bool = True
group_id_for_zone_check: Optional[int] = None
class q2_sdk.hq.db.enrolled_entity.CreateUserLogonResponse(logon_error='', password='', user_logon_id=None)[source]

Bases: object

Expected response object for create user logon function

logon_error: str = ''
password: str = ''
user_logon_id: Optional[int] = None
class q2_sdk.hq.db.enrolled_entity.GrabCustomerDataParams(customer_dict, user_dict, user_demographic_obj=None)[source]

Bases: object

Parameters needed to create a customer demographic info object

customer_dict: dict
user_dict: dict
user_demographic_obj: Optional[UserDemographicData] = None
class q2_sdk.hq.db.enrolled_entity.GetPhoneParams(customer_dict, user_dict, user_demographic_obj=None)[source]

Bases: object

Parameters needed to retrieve and validate phone information from a customer and user dictionary

customer_dict: dict
user_dict: dict
user_demographic_obj: Optional[UserDemographicData] = None
class q2_sdk.hq.db.enrolled_entity.CheckForExistingParams(login_name, primary_cif, ssn='', tax_id='', skip_customer_tax_check=False, skip_customer_cif_check=False, skip_user_check=False, skip_existing_customer_check=False, group_id=None)[source]

Bases: object

Parameters needed to check if customer, user, or logon exists

login_name: str
primary_cif: str
ssn: str = ''
tax_id: str = ''
skip_customer_tax_check: bool = False
skip_customer_cif_check: bool = False
skip_user_check: bool = False
skip_existing_customer_check: bool = False
group_id: Optional[int] = None
class q2_sdk.hq.db.enrolled_entity.UserDemoObjectValues(additional_user_info, emails, phone_numbers, addresses, ssn, primary_cif, dob=None, email_is_sac_target=None, email_objects=None)[source]

Bases: object

Parameters needed to create user demographic object

additional_user_info: dict
emails: list
phone_numbers: list[Phone]
addresses: list[Address]
ssn: int
primary_cif: int
dob: Optional[datetime] = None
email_is_sac_target: Optional[bool] = None
email_objects: Optional[list[Email]] = None
class q2_sdk.hq.db.enrolled_entity.LinkAccountsViaCifParams(primary_only, primary_cif, customer_id, user_id)[source]

Bases: object

Parameters needed to link accounts via primary cif

primary_only: bool
primary_cif: str
customer_id: int
user_id: int
class q2_sdk.hq.db.enrolled_entity.SsoIdentifierResponse(duplicate_exists=False, sso_result_error=False)[source]

Bases: object

Expected response object for sso enrollment function

duplicate_exists: bool = False
sso_result_error: bool = False
class q2_sdk.hq.db.enrolled_entity.EnrolledEntity(logger, hq_credentials=None, ret_table_obj=None)[source]

Bases: DbObject

Allows you to create a customer, user and logon in the Q2 Platform. Additional methods have been provided to assist you with the enrollment process

Programmatic access to the Q2 database. Not as flexible as a true ORM, but takes the guesswork out of database schemas and ensures safety in the transactions.

Parameters:
  • logger – Reference to calling request’s logger (self.logger in your extension)

  • hq_credentials (Optional[HqCredentials]) – HQ Connectivity Information (Defaults to settings file)

  • ret_table_obj (Optional[bool]) – Flag to return list of LXML elements if False or TableRow objects from DB calls if True (Defaults to settings file)

NAME = 'EnrolledEntity'
async create_customer(params)[source]

Creates a Customer in Q2 db and returns the id

Return type:

CreateCustomerResult

async create_customer_data(params)[source]

Sets CustomerData in our DB to the key|value pairs passed in in the format [{“Name”:”DataName”, “Value”: “DataValue”}]

async create_user(params)[source]

Creates a User in Q2 db and returns the id

Return type:

CreateUserResult

async create_user_data(userdata, user_id)[source]

Sets UserData in our DB to the key|value pairs passed in in the format {“key”:”value”}

async create_user_logon(params)[source]

Creates a UserLogon in Q2 db and returns the password

Return type:

CreateUserLogonResponse

async enroll_sso_identifier(user_logon_id, sso_identifier)[source]

Enrolling sso information given an sso identifier and logon id

Return type:

SsoIdentifierResponse

async check_disclaimers(disclaimers_info, user_id)[source]

Marking disclaimer as accepted. Prevents the user from having to accept them on first login

Return type:

bool

async check_db_for_existing(params)[source]

If Customer, User, or UserLogon already exists, raise an exception. Otherwise, just return None

build_user_demo_object(user_values)[source]

Creating Demographic Info object for User. Needed to created user

Return type:

DemographicInfo

async grab_customer_data(params, cache=None)[source]

Creating Demographic Info object for Customer. Required to created Customer Note: invalid phone information also gets returned

Return type:

tuple[list, DemographicInfo]

async get_customer_phones(params, cache=None)[source]

Retrieving phone information for the customer object. Note: This function first searches for customer phone information. If not found, any user phone information provided will be used to populate the customer object

Return type:

tuple[list[str], list[Phone]]

async get_user_phones(params, cache=None)[source]

Retrieving phone information for the user object. Note: This function first searches for user phone information. If not found, any customer phone information provided will be used to populate the user object

Return type:

tuple[list[str], list[Phone]]

async get_user_email(email_id)[source]
Return type:

str

Linking accounts associated to the created customer/user using given primary cif value

Return type:

bool

to_phone_type(phones)[source]

Turning given list of phone information into a list of Phone objects

Return type:

list[Phone]

to_address_type(addresses)[source]

Turning given list of address information into a list of Address objects

Return type:

list[Address]