Skip to content

Instantly share code, notes, and snippets.

@lchanmann
Created July 8, 2022 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lchanmann/56651e6bbdd2c5aee75343ad7d44c998 to your computer and use it in GitHub Desktop.
Save lchanmann/56651e6bbdd2c5aee75343ad7d44c998 to your computer and use it in GitHub Desktop.
//
// 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