{
  "version": "3.6",
  "name": "Simple Approval Workflow",
  "registry": {
    "services": [
      "SubmitRequest(description(STRING), amount(INT)) RETURN requestId(STRING)",
      "CheckApprovalPolicy(amount(INT)) RETURN needsApproval(BOOL), approver(STRING)",
      "NotifyApprover(requestId(STRING), approver(STRING)) RETURN notified(BOOL)"
    ],
    "components": [
      "FileOps"
    ],
    "vars": [
      "$description(STRING)",
      "$amount(INT)",
      "$requestId(STRING)",
      "$needsApproval(BOOL)",
      "$approver(STRING)",
      "$status(STRING)"
    ],
    "files": {
      "inputs": [
        "Process/Input/*"
      ],
      "artifacts": [
        "Process/Artifacts/*"
      ]
    }
  },
  "steps": [
    {
      "id": "Service_SubmitRequest",
      "in": {
        "description": "$description",
        "amount": "$amount"
      },
      "out": {
        "$requestId": "_result.requestId"
      },
      "next": "Service_CheckApprovalPolicy"
    },
    {
      "id": "Service_CheckApprovalPolicy",
      "in": {
        "amount": "$amount"
      },
      "out": {
        "$needsApproval": "_result.needsApproval",
        "$approver": "_result.approver"
      },
      "next": "Branch_CheckIfNeedsApproval"
    },
    {
      "id": "Branch_CheckIfNeedsApproval",
      "cases": [
        ["$needsApproval == true", "Service_NotifyApprover"],
        ["ELSE", "Set_AutoApproved"]
      ],
      "next": "Write_Result"
    },
    {
      "id": "Service_NotifyApprover",
      "in": {
        "requestId": "$requestId",
        "approver": "$approver"
      },
      "next": "Set_PendingApproval"
    },
    {
      "id": "Set_PendingApproval",
      "target": "$status",
      "value": "\"pending_approval\""
    },
    {
      "id": "Set_AutoApproved",
      "target": "$status",
      "value": "\"auto_approved\"",
      "next": "Write_Result"
    },
    {
      "id": "Write_Result",
      "target": "\"Process/Artifacts/request_\" + $requestId + \".json\"",
      "value": "$status",
      "mode": "overwrite",
      "next": "Stop_End"
    },
    {
      "id": "Stop_End"
    }
  ]
}
