Created
July 8, 2022 16:06
-
-
Save lchanmann/56651e6bbdd2c5aee75343ad7d44c998 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Support re-triggering LEV onboarding on BusinessDetailData update | |
// https://github.com/nanoPayinc/NANOPAY/pull/14670 | |
// | |
/* Vars */ | |
DRY_RUN = true; | |
RULES_TO_UPDATE = new String[] { | |
"expanded-onboarding-securefact-business-lookup", | |
"expanded-onboarding-securefact-business-lookup-sync" | |
}; | |
DAO = x.get("localRuleDAO"); | |
PREDICATE = foam.mlang.MLang.AND(new foam.mlang.predicate.Predicate[] { | |
new net.nanopay.crunch.ruler.CheckBusinessDetailPredicate(), | |
new foam.nanos.crunch.predicate.StatusChangedTo.Builder(x) | |
.setStatus(foam.nanos.crunch.CapabilityJunctionStatus.GRANTED) | |
.setCheckInequality(false) | |
.build() | |
}); | |
/* Helper functions */ | |
void updateRule(rule) { | |
if ( ! DRY_RUN ) { | |
rule = rule.fclone(); | |
rule.setPredicate(PREDICATE); | |
DAO.put(rule); | |
} | |
print(" .updateRule(" + rule.getId() + ") -> { predicate: AND(CheckBusinessDetailPredicate, StatusChangedTo(status:GRANTED, checkInequality:false)) }"); | |
} | |
/* Main */ | |
if ( DRY_RUN ) print("DRY RUN (Please turn off DRY_RUN to commit the update)\n"); | |
for ( ruleId : RULES_TO_UPDATE ) { | |
rule = DAO.find(ruleId); | |
if ( rule.getEnabled() | |
&& rule.getLifecycleState() == foam.nanos.auth.LifecycleState.ACTIVE | |
) updateRule(rule); | |
} | |
print("DONE!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment