Source code for q2_sdk.hq.hq_api.backoffice.UpdateUserProfile_models

# This is an autogenerated file from the command "q2 generate_hq_api" and will be overwritten if run again
"""
DataSet models for UpdateUserProfile.

These typed dataclass models represent the tables and columns within the
DataSet parameters for the UpdateUserProfile HQ operation.

IMPORTANT: Update operations require a GET first to populate the original_record
field. HQ uses the unchanged row for optimistic concurrency checking.

Usage::

    from q2_sdk.hq.hq_api.backoffice import UpdateUserProfile

    q2_phone_number = UpdateUserProfile.Q2PhoneNumber(
        country_id=1,
        city_or_area_code="...",
        local_number="...",
        phone_type=1,
    )

    q2_email = UpdateUserProfile.Q2Email(
        email_address="...",
        user_id=1,
    )

    q2_user_logon = UpdateUserProfile.Q2UserLogon(
        user_id=1,
        login_name="...",
        user_password="...",
        ui_source_id=1,
        status=1,
        create_date="...",
        auto_generated=True,
        password_change_required=True,
        password_has_never_changed=True,
    )

    q2_user_account = UpdateUserProfile.Q2UserAccount(
        user_id=1,
        customer_account_id=1,
        access=1,
    )

    q2_access_code_target = UpdateUserProfile.Q2AccessCodeTarget(
        user_id=1,
        notification_type_id=1,
        target_address="...",
        access_code_target_type_id=1,
    )

    q2_auth_token = UpdateUserProfile.Q2AuthToken(
        user_id=1,
        create_date="...",
        serial="...",
    )

    q2_user = UpdateUserProfile.Q2User(
        customer_id=1,
        create_date="...",
        auto_generated=True,
        use_customer_accounts=True,
        user_status_id=1,
    )

    q2_address = UpdateUserProfile.Q2Address(
        street_address1="...",
        city="...",
        address_type=1,
        country_id=1,
        is_international=True,
    )

    transaction_rights = UpdateUserProfile.TransactionRights(
        transaction_type_id=1,
        transaction_type="...",
        description="...",
        enabled=True,
        authorize=True,
        cancel=True,
        create=True,
        create_restricted=True,
        update=True,
        view=1,
        limit_per_transaction=1.0,
        limit_per_day=1.0,
        limit_per_month=1.0,
        limit_per_acct_per_day=1.0,
        count_per_acct_per_day=1,
        count_per_day=1,
        count_per_month=1,
        dual_approval_limit=1.0,
        token_required_limit=1.0,
        bit_flags=1,
    )

    user_rights = UpdateUserProfile.UserRights(
        rights_short_name="...",
        rights_long_name="...",
        has_rights=True,
    )

    user_monetary_rights = UpdateUserProfile.UserMonetaryRights(
        rights_short_name="...",
        rights_long_name="...",
        amount=1.0,
    )

    q2_customer_account_view = UpdateUserProfile.Q2CustomerAccountView(
        customer_account_id=1,
        customer_id=1,
        host_account_id=1,
        account_number_internal="...",
        product_name="...",
        is_external_account=True,
        product_id=1,
        product_type_id=1,
        user_access=1,
        current_access_flag=1,
    )
"""

from __future__ import annotations

import copy
from dataclasses import dataclass, field
from typing import Any, ClassVar, Optional

from q2_sdk.hq.models.dataset_builder import DataSetBuilder, DataSetTable, RowState


[docs] @dataclass class Q2PhoneNumber: """ Represents a row in the Q2_PhoneNumber table. """ phone_id: int = -1 country_id: int = 0 city_or_area_code: str = "" local_number: str = "" extension: Optional[str] = None phone_type: int = 0 user_id: Optional[int] = None customer_id: Optional[int] = None original_record: Optional["Q2PhoneNumber"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["PhoneID", "phone_id"], ["CountryID", "country_id"], ["CityOrAreaCode", "city_or_area_code"], ["LocalNumber", "local_number"], ["Extension", "extension"], ["PhoneType", "phone_type"], ["UserID", "user_id"], ["CustomerID", "customer_id"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.phone_id, self.country_id, self.city_or_area_code, self.local_number, self.extension, self.phone_type, self.user_id, self.customer_id, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "phone_id": int, "country_id": int, "city_or_area_code": str, "local_number": str, "extension": str, "phone_type": int, "user_id": int, "customer_id": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2PhoneNumber": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2Email: """ Represents a row in the Q2_Email table. """ email_id: int = -1 email_address: str = "" user_id: int = 0 original_record: Optional["Q2Email"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["EmailID", "email_id"], ["EmailAddress", "email_address"], ["UserID", "user_id"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.email_id, self.email_address, self.user_id, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "email_id": int, "email_address": str, "user_id": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2Email": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2UserLogon: """ Represents a row in the Q2_UserLogon table. """ user_logon_id: int = -1 user_id: int = 0 login_name: str = "" user_password: str = "" ui_source_id: int = 0 last_change: Optional[str] = None last_logon: Optional[str] = None status: int = 0 status_reason: Optional[str] = None last_failed: Optional[str] = None create_date: str = "" num_invalid_attempts: Optional[int] = None auto_generated: bool = False deleted_date: Optional[str] = None sync_pwd_user_logon_id: Optional[int] = None csr_assist_policy_id: Optional[int] = None csr_assist_admin_user_id: Optional[int] = None mla_challenge_code: Optional[str] = None password_change_required: bool = False password_has_never_changed: bool = False original_record: Optional["Q2UserLogon"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["UserLogonID", "user_logon_id"], ["UserID", "user_id"], ["LoginName", "login_name"], ["UserPassword", "user_password"], ["UISourceID", "ui_source_id"], ["LastChange", "last_change"], ["LastLogon", "last_logon"], ["Status", "status"], ["StatusReason", "status_reason"], ["LastFailed", "last_failed"], ["CreateDate", "create_date"], ["NumInvalidAttempts", "num_invalid_attempts"], ["AutoGenerated", "auto_generated"], ["DeletedDate", "deleted_date"], ["SyncPwdUserLogonID", "sync_pwd_user_logon_id"], ["CsrAssistPolicyID", "csr_assist_policy_id"], ["CsrAssistAdminUserID", "csr_assist_admin_user_id"], ["MlaChallengeCode", "mla_challenge_code"], ["PasswordChangeRequired", "password_change_required"], ["PasswordHasNeverChanged", "password_has_never_changed"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.user_logon_id, self.user_id, self.login_name, self.user_password, self.ui_source_id, self.last_change, self.last_logon, self.status, self.status_reason, self.last_failed, self.create_date, self.num_invalid_attempts, self.auto_generated, self.deleted_date, self.sync_pwd_user_logon_id, self.csr_assist_policy_id, self.csr_assist_admin_user_id, self.mla_challenge_code, self.password_change_required, self.password_has_never_changed, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "user_logon_id": int, "user_id": int, "login_name": str, "user_password": str, "ui_source_id": int, "last_change": str, "last_logon": str, "status": int, "status_reason": str, "last_failed": str, "create_date": str, "num_invalid_attempts": int, "auto_generated": bool, "deleted_date": str, "sync_pwd_user_logon_id": int, "csr_assist_policy_id": int, "csr_assist_admin_user_id": int, "mla_challenge_code": str, "password_change_required": bool, "password_has_never_changed": bool, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2UserLogon": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2UserAccount: """ Represents a row in the Q2_UserAccount table. """ user_account_id: int = -1 user_id: int = 0 customer_account_id: int = 0 access: int = 0 host_account_id: Optional[int] = None original_record: Optional["Q2UserAccount"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["UserAccountID", "user_account_id"], ["UserID", "user_id"], ["CustomerAccountID", "customer_account_id"], ["Access", "access"], ["HostAccountID", "host_account_id"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.user_account_id, self.user_id, self.customer_account_id, self.access, self.host_account_id, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "user_account_id": int, "user_id": int, "customer_account_id": int, "access": int, "host_account_id": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2UserAccount": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2AccessCodeTarget: """ Represents a row in the Q2_AccessCodeTarget table. """ target_id: int = -1 user_id: int = 0 notification_type_id: int = 0 target_address: str = "" access_code_target_type_id: int = 0 country_id: Optional[int] = None original_record: Optional["Q2AccessCodeTarget"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["TargetID", "target_id"], ["UserID", "user_id"], ["NotificationTypeID", "notification_type_id"], ["TargetAddress", "target_address"], ["AccessCodeTargetTypeID", "access_code_target_type_id"], ["CountryID", "country_id"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.target_id, self.user_id, self.notification_type_id, self.target_address, self.access_code_target_type_id, self.country_id, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "target_id": int, "user_id": int, "notification_type_id": int, "target_address": str, "access_code_target_type_id": int, "country_id": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2AccessCodeTarget": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2AuthToken: """ Represents a row in the Q2_AuthToken table. """ auth_token_id: int = -1 user_id: int = 0 create_date: str = "" deleted_date: Optional[str] = None serial: str = "" first_use: Optional[str] = None original_record: Optional["Q2AuthToken"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["AuthTokenID", "auth_token_id"], ["UserID", "user_id"], ["CreateDate", "create_date"], ["DeletedDate", "deleted_date"], ["Serial", "serial"], ["FirstUse", "first_use"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.auth_token_id, self.user_id, self.create_date, self.deleted_date, self.serial, self.first_use, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "auth_token_id": int, "user_id": int, "create_date": str, "deleted_date": str, "serial": str, "first_use": str, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2AuthToken": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2User: """ Represents a row in the Q2_User table. """ user_id: int = -1 customer_id: int = 0 first_name: Optional[str] = None middle_name: Optional[str] = None last_name: Optional[str] = None salutation: Optional[str] = None suffix: Optional[str] = None ssn: Optional[str] = None create_date: str = "" deleted_date: Optional[str] = None default_email_id: Optional[int] = None default_address_id: Optional[int] = None auto_generated: bool = False host_user: Optional[str] = None host_pwd: Optional[str] = None user_info: Optional[str] = None profile_updated: Optional[bool] = None mobile_auth_code: Optional[str] = None use_customer_accounts: bool = False primary_cif: Optional[str] = None last_user_profile_update: Optional[str] = None user_role_id: Optional[int] = None policy_id: Optional[int] = None user_status_id: int = 0 status_change_date: Optional[str] = None dob: Optional[str] = None is_primary_contact: Optional[bool] = None original_record: Optional["Q2User"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["UserID", "user_id"], ["CustomerID", "customer_id"], ["FirstName", "first_name"], ["MiddleName", "middle_name"], ["LastName", "last_name"], ["Salutation", "salutation"], ["Suffix", "suffix"], ["SSN", "ssn"], ["CreateDate", "create_date"], ["DeletedDate", "deleted_date"], ["DefaultEmailID", "default_email_id"], ["DefaultAddressID", "default_address_id"], ["AutoGenerated", "auto_generated"], ["HostUser", "host_user"], ["HostPwd", "host_pwd"], ["UserInfo", "user_info"], ["ProfileUpdated", "profile_updated"], ["MobileAuthCode", "mobile_auth_code"], ["UseCustomerAccounts", "use_customer_accounts"], ["PrimaryCIF", "primary_cif"], ["LastUserProfileUpdate", "last_user_profile_update"], ["UserRoleID", "user_role_id"], ["PolicyID", "policy_id"], ["UserStatusID", "user_status_id"], ["StatusChangeDate", "status_change_date"], ["DOB", "dob"], ["IsPrimaryContact", "is_primary_contact"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.user_id, self.customer_id, self.first_name, self.middle_name, self.last_name, self.salutation, self.suffix, self.ssn, self.create_date, self.deleted_date, self.default_email_id, self.default_address_id, self.auto_generated, self.host_user, self.host_pwd, self.user_info, self.profile_updated, self.mobile_auth_code, self.use_customer_accounts, self.primary_cif, self.last_user_profile_update, self.user_role_id, self.policy_id, self.user_status_id, self.status_change_date, self.dob, self.is_primary_contact, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "user_id": int, "customer_id": int, "first_name": str, "middle_name": str, "last_name": str, "salutation": str, "suffix": str, "ssn": str, "create_date": str, "deleted_date": str, "default_email_id": int, "default_address_id": int, "auto_generated": bool, "host_user": str, "host_pwd": str, "user_info": str, "profile_updated": bool, "mobile_auth_code": str, "use_customer_accounts": bool, "primary_cif": str, "last_user_profile_update": str, "user_role_id": int, "policy_id": int, "user_status_id": int, "status_change_date": str, "dob": str, "is_primary_contact": bool, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2User": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2Address: """ Represents a row in the Q2_Address table. """ address_id: int = -1 street_address1: str = "" street_address2: Optional[str] = None city: str = "" state: Optional[str] = None postal_code: Optional[str] = None customer_id: Optional[int] = None address_type: int = 0 user_id: Optional[int] = None country_id: int = 0 is_international: bool = False province: Optional[str] = None original_record: Optional["Q2Address"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["AddressID", "address_id"], ["StreetAddress1", "street_address1"], ["StreetAddress2", "street_address2"], ["City", "city"], ["State", "state"], ["PostalCode", "postal_code"], ["CustomerID", "customer_id"], ["AddressType", "address_type"], ["UserID", "user_id"], ["CountryID", "country_id"], ["IsInternational", "is_international"], ["Province", "province"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.address_id, self.street_address1, self.street_address2, self.city, self.state, self.postal_code, self.customer_id, self.address_type, self.user_id, self.country_id, self.is_international, self.province, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "address_id": int, "street_address1": str, "street_address2": str, "city": str, "state": str, "postal_code": str, "customer_id": int, "address_type": int, "user_id": int, "country_id": int, "is_international": bool, "province": str, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2Address": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class TransactionRights: """ Represents a row in the TransactionRights table. """ transaction_type_id: int = 0 transaction_type: str = "" description: str = "" enabled: bool = False authorize: bool = False cancel: bool = False create: bool = False create_restricted: bool = False update: bool = False view: int = 0 limit_per_transaction: float = 0.0 limit_per_day: float = 0.0 limit_per_month: float = 0.0 limit_per_acct_per_day: float = 0.0 count_per_acct_per_day: int = 0 count_per_day: int = 0 count_per_month: int = 0 dual_approval_limit: float = 0.0 token_required_limit: float = 0.0 bit_flags: int = 0 original_record: Optional["TransactionRights"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["TransactionTypeID", "transaction_type_id"], ["TransactionType", "transaction_type"], ["Description", "description"], ["Enabled", "enabled"], ["Authorize", "authorize"], ["Cancel", "cancel"], ["Create", "create"], ["CreateRestricted", "create_restricted"], ["Update", "update"], ["View", "view"], ["LimitPerTransaction", "limit_per_transaction"], ["LimitPerDay", "limit_per_day"], ["LimitPerMonth", "limit_per_month"], ["LimitPerAcctPerDay", "limit_per_acct_per_day"], ["CountPerAcctPerDay", "count_per_acct_per_day"], ["CountPerDay", "count_per_day"], ["CountPerMonth", "count_per_month"], ["DualApprovalLimit", "dual_approval_limit"], ["TokenRequiredLimit", "token_required_limit"], ["BitFlags", "bit_flags"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.transaction_type_id, self.transaction_type, self.description, self.enabled, self.authorize, self.cancel, self.create, self.create_restricted, self.update, self.view, self.limit_per_transaction, self.limit_per_day, self.limit_per_month, self.limit_per_acct_per_day, self.count_per_acct_per_day, self.count_per_day, self.count_per_month, self.dual_approval_limit, self.token_required_limit, self.bit_flags, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "transaction_type_id": int, "transaction_type": str, "description": str, "enabled": bool, "authorize": bool, "cancel": bool, "create": bool, "create_restricted": bool, "update": bool, "view": int, "limit_per_transaction": float, "limit_per_day": float, "limit_per_month": float, "limit_per_acct_per_day": float, "count_per_acct_per_day": int, "count_per_day": int, "count_per_month": int, "dual_approval_limit": float, "token_required_limit": float, "bit_flags": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "TransactionRights": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class UserRights: """ Represents a row in the UserRights table. """ rights_short_name: str = "" rights_long_name: str = "" has_rights: bool = False original_record: Optional["UserRights"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["RightsShortName", "rights_short_name"], ["RightsLongName", "rights_long_name"], ["HasRights", "has_rights"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.rights_short_name, self.rights_long_name, self.has_rights, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "rights_short_name": str, "rights_long_name": str, "has_rights": bool, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "UserRights": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class UserMonetaryRights: """ Represents a row in the UserMonetaryRights table. """ rights_short_name: str = "" rights_long_name: str = "" amount: float = 0.0 original_record: Optional["UserMonetaryRights"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["RightsShortName", "rights_short_name"], ["RightsLongName", "rights_long_name"], ["Amount", "amount"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.rights_short_name, self.rights_long_name, self.amount, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "rights_short_name": str, "rights_long_name": str, "amount": float, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "UserMonetaryRights": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] @dataclass class Q2CustomerAccountView: """ Represents a row in the Q2_CustomerAccountView table. """ customer_account_id: int = 0 customer_id: int = 0 is_cif_rel: Optional[bool] = None host_account_id: int = 0 account_number_internal: str = "" product_name: str = "" is_user_enabled: Optional[bool] = None is_external_account: bool = False product_id: int = 0 product_type_id: int = 0 user_access: int = 0 current_access_flag: int = 0 valid_customer_access_flag: Optional[int] = None valid_system_access_flag: Optional[int] = None original_record: Optional["Q2CustomerAccountView"] = field(default=None, repr=False)
[docs] @staticmethod def get_columns() -> list[list[str]]: """Returns [[HqColumnName, pythonAttrName], ...] mapping.""" return [ ["CustomerAccountID", "customer_account_id"], ["CustomerID", "customer_id"], ["IsCifRel", "is_cif_rel"], ["HostAccountID", "host_account_id"], ["AccountNumberInternal", "account_number_internal"], ["ProductName", "product_name"], ["IsUserEnabled", "is_user_enabled"], ["IsExternalAccount", "is_external_account"], ["ProductID", "product_id"], ["ProductTypeID", "product_type_id"], ["UserAccess", "user_access"], ["CurrentAccessFlag", "current_access_flag"], ["ValidCustomerAccessFlag", "valid_customer_access_flag"], ["ValidSystemAccessFlag", "valid_system_access_flag"], ]
[docs] def to_row_values(self) -> list[Any]: """Returns column values in get_columns() order.""" return [ self.customer_account_id, self.customer_id, self.is_cif_rel, self.host_account_id, self.account_number_internal, self.product_name, self.is_user_enabled, self.is_external_account, self.product_id, self.product_type_id, self.user_access, self.current_access_flag, self.valid_customer_access_flag, self.valid_system_access_flag, ]
_COLUMN_TYPES: ClassVar[dict[str, type]] = { "customer_account_id": int, "customer_id": int, "is_cif_rel": bool, "host_account_id": int, "account_number_internal": str, "product_name": str, "is_user_enabled": bool, "is_external_account": bool, "product_id": int, "product_type_id": int, "user_access": int, "current_access_flag": int, "valid_customer_access_flag": int, "valid_system_access_flag": int, }
[docs] @classmethod def from_hq_response(cls, row_elem) -> "Q2CustomerAccountView": """Parse an lxml row element into this model with original_record set.""" kwargs: dict[str, Any] = {} for hq_name, python_name in cls.get_columns(): child = row_elem.find(hq_name) if child is not None and child.text is not None: target_type = cls._COLUMN_TYPES.get(python_name, str) if target_type is bool: kwargs[python_name] = child.text.lower() in ("true", "1") elif target_type in (int, float): try: kwargs[python_name] = target_type(child.text) except (ValueError, TypeError): kwargs[python_name] = child.text else: kwargs[python_name] = child.text instance = cls(**kwargs) instance.original_record = copy.deepcopy(instance) return instance
[docs] def build_dup_dataset( q2_phone_number: Optional[Q2PhoneNumber | list[Q2PhoneNumber]] = None, q2_email: Optional[Q2Email | list[Q2Email]] = None, q2_user_logon: Optional[Q2UserLogon | list[Q2UserLogon]] = None, q2_user_account: Optional[Q2UserAccount | list[Q2UserAccount]] = None, q2_access_code_target: Optional[ Q2AccessCodeTarget | list[Q2AccessCodeTarget] ] = None, q2_auth_token: Optional[Q2AuthToken | list[Q2AuthToken]] = None, q2_user: Optional[Q2User | list[Q2User]] = None, q2_address: Optional[Q2Address | list[Q2Address]] = None, ) -> DataSetBuilder: """ Build the dup DataSet parameter for UpdateUserProfile. For update operations, each model instance should have its original_record set to the pre-modification state (from a prior GET call). For add operations, set auto-increment ID fields to negative values. :returns: DataSetBuilder ready to pass as the 'dup' parameter """ dataset = DataSetBuilder("DalUserProfile") # Q2_PhoneNumber q2_phone_number_cols = [col[0] for col in Q2PhoneNumber.get_columns()] q2_phone_number_table = dataset.add_table("Q2_PhoneNumber", q2_phone_number_cols) _add_rows_to_table(q2_phone_number_table, q2_phone_number) # Q2_Email q2_email_cols = [col[0] for col in Q2Email.get_columns()] q2_email_table = dataset.add_table("Q2_Email", q2_email_cols) _add_rows_to_table(q2_email_table, q2_email) # Q2_UserLogon q2_user_logon_cols = [col[0] for col in Q2UserLogon.get_columns()] q2_user_logon_table = dataset.add_table("Q2_UserLogon", q2_user_logon_cols) _add_rows_to_table(q2_user_logon_table, q2_user_logon) # Q2_UserAccount q2_user_account_cols = [col[0] for col in Q2UserAccount.get_columns()] q2_user_account_table = dataset.add_table("Q2_UserAccount", q2_user_account_cols) _add_rows_to_table(q2_user_account_table, q2_user_account) # Q2_AccessCodeTarget q2_access_code_target_cols = [col[0] for col in Q2AccessCodeTarget.get_columns()] q2_access_code_target_table = dataset.add_table( "Q2_AccessCodeTarget", q2_access_code_target_cols ) _add_rows_to_table(q2_access_code_target_table, q2_access_code_target) # Q2_AuthToken q2_auth_token_cols = [col[0] for col in Q2AuthToken.get_columns()] q2_auth_token_table = dataset.add_table("Q2_AuthToken", q2_auth_token_cols) _add_rows_to_table(q2_auth_token_table, q2_auth_token) # Q2_User q2_user_cols = [col[0] for col in Q2User.get_columns()] q2_user_table = dataset.add_table("Q2_User", q2_user_cols) _add_rows_to_table(q2_user_table, q2_user) # Q2_Address q2_address_cols = [col[0] for col in Q2Address.get_columns()] q2_address_table = dataset.add_table("Q2_Address", q2_address_cols) _add_rows_to_table(q2_address_table, q2_address) return dataset
[docs] def build_user_rights_dataset( transaction_rights: Optional[TransactionRights | list[TransactionRights]] = None, user_rights: Optional[UserRights | list[UserRights]] = None, user_monetary_rights: Optional[ UserMonetaryRights | list[UserMonetaryRights] ] = None, q2_customer_account_view: Optional[ Q2CustomerAccountView | list[Q2CustomerAccountView] ] = None, ) -> DataSetBuilder: """ Build the user_rights DataSet parameter for UpdateUserProfile. For update operations, each model instance should have its original_record set to the pre-modification state (from a prior GET call). For add operations, set auto-increment ID fields to negative values. :returns: DataSetBuilder ready to pass as the 'user_rights' parameter """ dataset = DataSetBuilder("UserRightsEdit") # TransactionRights transaction_rights_cols = [col[0] for col in TransactionRights.get_columns()] transaction_rights_table = dataset.add_table( "TransactionRights", transaction_rights_cols ) _add_rows_to_table(transaction_rights_table, transaction_rights) # UserRights user_rights_cols = [col[0] for col in UserRights.get_columns()] user_rights_table = dataset.add_table("UserRights", user_rights_cols) _add_rows_to_table(user_rights_table, user_rights) # UserMonetaryRights user_monetary_rights_cols = [col[0] for col in UserMonetaryRights.get_columns()] user_monetary_rights_table = dataset.add_table( "UserMonetaryRights", user_monetary_rights_cols ) _add_rows_to_table(user_monetary_rights_table, user_monetary_rights) # Q2_CustomerAccountView q2_customer_account_view_cols = [ col[0] for col in Q2CustomerAccountView.get_columns() ] q2_customer_account_view_table = dataset.add_table( "Q2_CustomerAccountView", q2_customer_account_view_cols ) _add_rows_to_table(q2_customer_account_view_table, q2_customer_account_view) return dataset
def _add_rows_to_table( table: DataSetTable, records: Optional[Any | list], ) -> None: """ Add rows to a DataSetTable from one or more model instances. Handles Modified+Unchanged pairs (for updates), Added rows (for inserts), and Deleted rows automatically based on each record's original_record field. """ if records is None: return if not isinstance(records, list): records = [records] for record in records: values = record.to_row_values() if record.original_record is not None: # Update: emit Modified row (new values) + Unchanged row (original) table.add_row(RowState.MODIFIED, values) table.add_row(RowState.UNCHANGED, record.original_record.to_row_values()) else: # Add: emit Added row (new record) table.add_row(RowState.ADDED, values)