You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adding creditcard application example
* adding sanity test file for creditcard example
* Added description for sanity test cases
* removed unwanted package index values
* draft version of improved creditcard example
* Updated new changes as per the review comments
* spell check
* spell check
* refactoring functions.go file
* refactoring functions.go file
* refactoring credit card example
* Fix failing sanity test cases and minor changes in functions.go file
This example demonstrates rule based processing of credit card application. In this example three tuples are used, tuples description is given below.
5
+
6
+
7
+
*`UserAccount` tuple is always stored in network, while the other tuples `NewAccount` and `UpdateCreditScore` are removed after usage as ttl is given as 0.
8
+
9
+
10
+
## Usage
11
+
12
+
Get the repo and in this example main.go, functions.go both are available. We can directly build and run the app or create flogo rule app and run it.
13
+
14
+
#### Conditions
15
+
16
+
```
17
+
cBadUser : Check for new user input data - check if age <18 and >=45, empty address and salary less than 10k
18
+
cNewUser : Check for new user input data - check if age >=18 and <= 44, address and salary >= 10k
19
+
cUserIdMatch : Check for id match from 'UserAccount' and 'UpdateCreditScore' tuples
20
+
cUserCreditScore : Check for CreditScore >= 750 && < 820
21
+
cUserLowCreditScore : Check for CreditScore < 750
22
+
cUserHighCreditScore : Check for CreditScore >= 820 && <= 900
23
+
```
24
+
#### Actions
25
+
```
26
+
aBadUser : Executes when age - < 18 and >=45, address empty, salary less than 10k
27
+
aNewUser : Add the newuser info to userAccount tuple
28
+
aApproveWithLowerLimit : Provides credit card application status approved with lower credit limit
29
+
aApproveWithHigherLimit : Provides credit card application status approved with higher credit limit
30
+
aUserReject : Rejects when lower Credit score provided and retracts NewAccount
31
+
```
32
+
### Direct build and run
33
+
```
34
+
cd $GOPATH/src/github.com/project-flogo/rules/examples/flogo/creditcard
35
+
go build
36
+
./creditcard
37
+
```
38
+
### Create app using flogo cli
39
+
```
40
+
cd $GOPATH/src/github.com/project-flogo/rules/examples/flogo/creditcard
41
+
flogo create -f flogo.json creditcard
42
+
cp functions.go creditcard/src
43
+
cd creditcard
44
+
flogo build
45
+
./bin/creditcard
46
+
```
47
+
48
+
* Input new user details
49
+
50
+
```
51
+
$ curl -X PUT http://localhost:7777/newaccount -H 'Content-Type: application/json' -d '{"Name":"Test","Age":"26","Income":"60100","Address":"TEt","Id":"12312","Gender":"male","maritalStatus":"single"}'
52
+
```
53
+
* Update credit score details of the user
54
+
55
+
```
56
+
$ curl -X PUT http://localhost:7777/credit -H 'Content-Type: application/json' -d '{"Id":12312,"creditScore":680}'
57
+
```
58
+
59
+
* Application status will be printed on the console
0 commit comments