{
  "name": "iSTAR Robotics Purchase Candidate",
  "nodes": [
    {
      "id": "robot-start",
      "name": "Run workflow",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "parameters": {}
    },
    {
      "id": "robot-search",
      "name": "Query catalog",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        230,
        0
      ],
      "parameters": {
        "url": "https://istar.website/api/v1/catalog?q=robot-pick-place-kinematic-v1",
        "options": {}
      }
    },
    {
      "id": "robot-detail",
      "name": "Read version and license",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        460,
        0
      ],
      "parameters": {
        "url": "={{ \"https://istar.website\" + $json.items.find(entry => entry.id === \"robot-pick-place-kinematic-v1\").metadata }}",
        "options": {}
      }
    },
    {
      "id": "robot-candidate",
      "name": "Build purchase candidate",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        690,
        0
      ],
      "parameters": {
        "jsCode": "const asset = $input.first().json;\nif (!asset.version || !asset.license || !asset.offer || !asset.delivery) {\n  throw new Error('Incomplete version, license, offer, or delivery metadata');\n}\nreturn [{json: {\n  id: asset.id, version: asset.version, license: asset.license,\n  amount: asset.offer.baseAmount, currency: asset.offer.currency,\n  unit: asset.offer.unit, delivery: asset.delivery, sample: asset.sample,\n  sampleSha256: asset.sampleSha256, discussion: asset.discussion,\n  nextAction: asset.offer.checkoutAvailable ? asset.offer.quoteEndpoint : asset.discussion,\n  checkoutAvailable: asset.offer.checkoutAvailable,\n  status: asset.offer.checkoutAvailable ? 'invitation_required' : 'merchant_setup_pending'\n}}];"
      }
    }
  ],
  "connections": {
    "Run workflow": {
      "main": [
        [
          {
            "node": "Query catalog",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query catalog": {
      "main": [
        [
          {
            "node": "Read version and license",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read version and license": {
      "main": [
        [
          {
            "node": "Build purchase candidate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}