{
  "ApplicationName": "SimpleMarketplace",
  "DisplayName": "Simple Marketplace",
  "Description": "Allows a simple transaction between a seller and a buyer in a marketplace.",
  "ApplicationRoles": [
    {
      "Name": "Owner",
      "Description": "User who wants to sell an item."
    },
    {
      "Name": "Buyer",
      "Description": "User who wants to buy the item."
    }
  ],
  "Workflows": [
    {
      "Name": "SimpleMarketplace",
      "DisplayName": "Simple Marketplace",
      "Description": "Handles the business logic for a simple buyer-seller scenario.",
      "Initiators": [ "Owner" ],
      "StartState":  "ItemAvailable",
      "Properties": [
        {
          "Name": "State",
          "DisplayName": "State",
          "Description": "Holds the state of the contract",
          "Type": {
            "Name": "state"
          }
        },
        {
          "Name": "Description",
          "DisplayName": "Description",
          "Description": "Describes the asset being sold",
          "Type": {
            "Name": "string"
          }
        },
        {
          "Name": "AskingPrice",
          "DisplayName": "Asking Price",
          "Description": "The asking price for the asset",
          "Type": {
            "Name": "money"
          }
        },
        {
          "Name": "OfferPrice",
          "DisplayName": "Offer Price",
          "Description": "The price being offered for the asset",
          "Type": {
            "Name": "money"
          }
        },
        {
          "Name": "InstanceBuyer",
          "DisplayName": "Instance Buyer",
          "Description": "The user that places an offer for this asset",
          "Type": {
            "Name": "Buyer"
          }
        },
        {
          "Name": "InstanceOwner",
          "DisplayName": "Instance Owner",
          "Description": "The seller of this particular asset",
          "Type": {
            "Name": "Owner"
          }
        }
      ],
      "Constructor": {
        "Parameters": [
          {
            "Name": "description",
            "Description": "The description of this asset",
            "DisplayName": "Description",
            "Type": {
              "Name": "string"
            }
          },
          {
            "Name": "price",
            "Description": "The price of this asset",
            "DisplayName": "Price",
            "Type": {
              "Name": "money"
            }
          }
        ]
      },
      "Functions": [
        {
          "Name": "MakeOffer",
          "DisplayName": "Make Offer",
          "Description": "Make an offer",
          "Parameters": [
            {
              "Name": "offerPrice",
              "Description": "Offer Price",
              "DisplayName": "Offer Price",
              "Type": {
                "Name": "money"
              }
            }
          ]
        },
        {
          "Name": "AcceptOffer",
          "DisplayName": "Accept Offer",
          "Description": "Accept the offer made",
          "Parameters": []
        },
        {
          "Name": "Reject",
          "DisplayName": "Reject Offer",
          "Description": "Reject the offer made",
          "Parameters": []
        }
      ],
      "States": [
        {
          "Name": "ItemAvailable",
          "DisplayName": "Item Available",
          "Description": "The item is available",
          "PercentComplete": 20,
          "Style": "Success",
          "Transitions": [
            {
              "AllowedRoles": [ "Buyer" ],
              "AllowedInstanceRoles": [],
              "Description": "Make an offer for this asset",
              "Function": "MakeOffer",
              "NextStates": [ "OfferPlaced" ],
              "DisplayName": "Make Offer"
            }
          ]
        },
        {
          "Name": "OfferPlaced",
          "DisplayName": "Offer Placed",
          "Description": "Offer has been placed for the item",
          "PercentComplete": 60,
          "Style": "Success",
          "Transitions": [
            {
              "AllowedRoles": [],
              "AllowedInstanceRoles": [ "InstanceOwner" ],
              "Description": "Accept the proposed offer for the item",
              "Function": "AcceptOffer",
              "NextStates": [ "Accepted" ],
              "DisplayName": "Accept Offer"
            },
            {
              "AllowedRoles": [],
              "AllowedInstanceRoles": [ "InstanceOwner" ],
              "Description": "Reject the proposed offer for the item",
              "Function": "Reject",
              "NextStates": [ "ItemAvailable" ],
              "DisplayName": "Reject"
            }
          ]
        },
        {
          "Name": "Accepted",
          "DisplayName": "Accepted",
          "Description": "Asset transfer process is complete",
          "PercentComplete": 100,
          "Style": "Success",
          "Transitions": []
        }
      ]
    }
  ]
}
