{
  "info": {
    "name": "HTF Instagram Content Test Planner preview",
    "description": "Estimate the supplier cost for the NASA and ESA example. Starts no supplier collection. Apify run usage is separate. Define apifyToken in a private Postman environment and mark it sensitive.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{apifyToken}}", "type": "string" }]
  },
  "item": [
    {
      "name": "Estimate supplier cost",
      "request": {
        "method": "POST",
        "header": [{ "key": "Content-Type", "value": "application/json" }],
        "url": "https://api.apify.com/v2/acts/apifmcpfactory~htf-instagram-discovery/runs?waitForFinish=60",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"mode\": \"experimentPlan\",\n  \"brandUsername\": \"nasa\",\n  \"rivalUsername\": \"europeanspaceagency\",\n  \"sourceAction\": \"preview\",\n  \"maxCollectionChargeUsd\": 0\n}"
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.collectionVariables.unset('previewStore');",
              "const run = pm.response.json().data;",
              "pm.test('Preview completed', function () {",
              "    pm.expect(run.status).to.equal('SUCCEEDED');",
              "});",
              "if (run.status === 'SUCCEEDED') pm.collectionVariables.set('previewStore', run.defaultKeyValueStoreId);"
            ]
          }
        }
      ]
    },
    {
      "name": "Read preview output",
      "request": {
        "method": "GET",
        "url": "https://api.apify.com/v2/key-value-stores/{{previewStore}}/records/OUTPUT"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const output = pm.response.json();",
              "pm.test('No supplier collection started', function () {",
              "    pm.expect(output.action).to.equal('preview');",
              "    pm.expect(output.supplierRunsStarted).to.equal(0);",
              "});"
            ]
          }
        }
      ]
    }
  ]
}
