I built a basic flask app, to run the rules using API, the first issue I faced was when I was trying to run, the ruleset does not clear for every call. Resulting in an error. I saw #262 already open. Will await for an update on that.
c.first is still CA but since I made the second API call my expectation is the condition should assign c.first with US and c.second to US thereby (my custom rule - No Fraud detected)
My rule code is below for reference:
from durable.lang import *
def event(body):
with ruleset('risk'):
@when_all(c.first << m.t == 'purchase' , c.second << m.location != c.first.location)
# this condition is to identify actual fraud cases
def fraud(c):
print('Fraud detected -> {0}, {1}'.format(c.first.location, c.second.location))
c.s.result = ('Fraud detected -> {0}, {1}'.format(c.first.location, c.second.location))
@when_all(c.first << m.t == 'purchase', c.second << m.location == c.first << m.location)
# this condition is to identify No fraud cases
def fraudno(c):
print('No Fraud detected -> {0}, {1}'.format(c.first.location, c.second.location))
c.s.result = ('No Fraud detected -> {0}, {1}'.format(c.first.location, c.second.location))
I maybe doing something wrong, since, I'm very new to this.
I built a basic flask app, to run the rules using API, the first issue I faced was when I was trying to run, the ruleset does not clear for every call. Resulting in an error. I saw #262 already open. Will await for an update on that.
The second problem I faced was while testing https://github.com/jruizgit/rules/blob/master/docs/py/reference.md#events Let's say my first API call is to compare below two post:
After that I send another two post to test the same rule, example:
this will create problem, since in the condition:
c.first is still
CA
but since I made the second API call my expectation is the condition should assign c.first withUS
and c.second toUS
thereby (my custom rule - No Fraud detected)My rule code is below for reference:
I maybe doing something wrong, since, I'm very new to this.
Thanks