Skip to content

Instantly share code, notes, and snippets.

@ricardozanini
Last active August 17, 2020 15:25
Show Gist options
  • Save ricardozanini/aece634aba271edcea1ed657d4ebea96 to your computer and use it in GitHub Desktop.
Save ricardozanini/aece634aba271edcea1ed657d4ebea96 to your computer and use it in GitHub Desktop.
{
"id": "online-vehicle-auction",
"name": "Online Vehicle Auction",
"version": "1.0v",
"functions": [
{
"name": "userAuthServiceCall",
"resource": "http://authservice.com",
"type": "rest",
"metadata": {
"method": "GET"
}
},
{
"name": "biddingServiceCall",
"resource": "http://biddingservice.com",
"type": "rest",
"metadata": {
"method": "POST"
}
},
{
"name": "inventoryServiceCall",
"resource": "http://inventoryservice.com/reserve",
"type": "rest",
"metadata": {
"method": "POST"
}
}
],
"events": [
{
"kind": "produced",
"name": "authenticationFailed",
"type": "process.kogito.authenticationFailed"
},
{
"kind": "produced",
"name": "bidResult",
"type": "process.kogito.bidResult"
}
],
"states": [
{
"start": {
"kind": "default"
},
"name": "AuthenticateUser",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"functionRef": {
"refName": "userAuthServiceCall",
"parameters": {
"user": "{{ $.bidattempt.credentials.username }}",
"password": "{{ $.bidattempt.credentials.password }}"
}
}
}
],
"transition": {
"nextState": "CheckAuth"
}
},
{
"name": "CheckAuth",
"type": "switch",
"dataConditions": [
{
"condition": "{{ $.bidattempt.credentials.user[?(@.authenticated == true)] }}",
"transition": {
"nextState": "MakeBid"
}
},
{
"condition": "{{ $.bidattempt.credentials.user[?(@.authenticated == false)] }}",
"transition": {
"nextState": "AuthFailure"
}
}
],
"default": {
"nextState": "AuthFailure"
}
},
{
"name": "MakeBid",
"type": "operation",
"actionMode": "sequential",
"actions": [
{
"name": "callBidService",
"functionRef": {
"refName": "biddingServiceCall",
"parameters": {
"bid": "{{ $.bidattempt.bid }}"
}
}
},
{
"name": "callInventoryService",
"functionRef": {
"refName": "inventoryServiceCall",
"parameters": {
"bid": "{{ $.bidattempt.bid.product }}"
}
}
}
],
"end": {
"kind": "event",
"produceEvent": {
"data": "{{ $.bidattempt.bid }}",
"eventRef": "bidResult"
}
}
},
{
"name": "AuthFailure",
"type": "inject",
"data": {
"message": "Failed to authenticate bidder."
},
"end": {
"kind": "event",
"produceEvent": {
"data": "{{ $.bidattempt.bidder }}",
"eventRef": "authenticationFailed"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment