Skip to content

MPT-11279 vadalidate the parameters introduced by the customer #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

alephsur
Copy link
Contributor

No description provided.

@alephsur alephsur requested review from svazquezco and robcsegal July 23, 2025 11:33
@alephsur alephsur force-pushed the MPT-11279-validate-the-parameters-introduced-by-the-customer branch 2 times, most recently from 40981fc to e27e1e5 Compare July 23, 2025 11:52
@alephsur alephsur force-pushed the MPT-11279-validate-the-parameters-introduced-by-the-customer branch 4 times, most recently from 99373bc to 989b1b9 Compare July 25, 2025 12:14
Comment on lines 89 to 110
def set_params_visibility(params, hidden):
for param in params:
if hidden:
updated = set_parameter_hidden
else:
updated = set_parameter_visible
nonlocal updated_order
updated_order = updated(updated_order, param)

if agreement_value == "New":
set_params_visibility(PARAM_NEW_CUSTOMER_PARAMETERS, hidden=False)
set_params_visibility(
TRANSFER_CUSTOMER_PARAMETERS + (Param.MEMBERSHIP_ID,),
hidden=True
)
elif agreement_value == "Migrate":
set_params_visibility(
PARAM_NEW_CUSTOMER_PARAMETERS + TRANSFER_CUSTOMER_PARAMETERS,
hidden=True
)
set_params_visibility([Param.MEMBERSHIP_ID], hidden=False)
elif agreement_value == "Transfer":
set_params_visibility(PARAM_NEW_CUSTOMER_PARAMETERS, hidden=True)
set_params_visibility([Param.MEMBERSHIP_ID], hidden=True)
set_params_visibility(TRANSFER_CUSTOMER_PARAMETERS, hidden=False)

return updated_order
Copy link
Contributor

@svazquezco svazquezco Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel this logic a bit complicated and I'm not a big fan of using nonlocal unless if there is a really good reason for it. I believe we could use a map and then call the set_parameter_hidden and set_parameter_visible. Something like:

    param_map = {
        "new": {
            "visible": PARAM_NEW_CUSTOMER_PARAMETERS,
            "hidden": TRANSFER_CUSTOMER_PARAMETERS + (Param.MEMBERSHIP_ID,),
        },
        "Migrate": {
            "visible": [Param.MEMBERSHIP_ID],
            "hidden": PARAM_NEW_CUSTOMER_PARAMETERS + TRANSFER_CUSTOMER_PARAMETERS,
        
        },
        ...
    }
    update_order = set_parameter_visible(update_order, param_map[agreement_value] # I assume all the values have both visible and hidden params ,otherwise we can use an if conditional before with a get
    update_order = set_parameter_hidden(update_order, param_map[agreement_value] 

    return updated_order

@alephsur alephsur force-pushed the MPT-11279-validate-the-parameters-introduced-by-the-customer branch from 989b1b9 to 6ce6d86 Compare July 25, 2025 12:42
from adobe_vipm.flows.constants import (
PARAM_REQUIRED_CUSTOMER_ORDER,
Param,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused with this change and the one on line 63. Are they a Ruff change?

@alephsur alephsur force-pushed the MPT-11279-validate-the-parameters-introduced-by-the-customer branch 4 times, most recently from c8d8f56 to bd3f7eb Compare July 29, 2025 06:32
@alephsur alephsur force-pushed the MPT-11279-validate-the-parameters-introduced-by-the-customer branch from bd3f7eb to a08483d Compare July 30, 2025 10:38
Copy link

@alephsur alephsur merged commit 086d7c1 into main Jul 30, 2025
3 checks passed
@alephsur alephsur deleted the MPT-11279-validate-the-parameters-introduced-by-the-customer branch July 30, 2025 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants