from core.models.Result import Result, ResultError from core.controllers.SyncController import new_sync from core.services.subscriptions.subscriptions_by_protocol import wipe_billing_cycle # from core.services.payment_phase.check_payment_loop import mark_as_paid # from gui.v2.actions.payment_actions import stop_payment_timer ENUM_MAP = { ResultError.UNKNOWN: None, ResultError.NEED_SYNC: (new_sync), ResultError.ACTIVE_BILLING: (wipe_billing_cycle), ResultError.EXPIRED_INVOICE: (wipe_billing_cycle), # ResultError.PAID: (mark_as_paid), ResultError.INVALID_API_REPLY: None, ResultError.ENCRYPTION: None } def register_action(error_code): def wrapper(func): ENUM_MAP[error_code] = (func) return func return wrapper # Add later potentially: # ResultError.ACTIVE_BILLING: (stop_payment_timer), # ResultError.NO_TICKET: (start_billing), # ResultError.NO_PROFILE: (go_to_new_profile_page), # ResultError.ALREADY_EXISTS: (get_invoice), # bypass_existing: True # ResultError.BILLING_CODE_EXISTS: (get_invoice) # bypass_existing: True # Potential future upgrade to multiple error codes per function: # def register_action(*error_codes): # def wrapper(func): # for code in error_codes: # ACTION_REGISTRY[code] = func # return func # return wrapper