{
  "info": {
    "name": "jevmod",
    "description": "Moderation decisions powered by Jev. Set the collection variables: baseUrl, adminToken (JEVMOD_ADMIN_TOKEN of the server). Run '1 mint key' first: it stores the tenant key in apiKey for the other requests.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "http://localhost:8080" },
    { "key": "adminToken", "value": "change-me" },
    { "key": "apiKey", "value": "" }
  ],
  "item": [
    {
      "name": "0 health",
      "request": { "method": "GET", "url": "{{baseUrl}}/v1/health" }
    },
    {
      "name": "1 mint key (admin)",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test('key minted', () => pm.response.to.have.status(200));",
              "pm.collectionVariables.set('apiKey', pm.response.json().api_key);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{adminToken}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{baseUrl}}/v1/keys",
        "body": { "mode": "raw", "raw": "{\"tenant\": \"postman\", \"label\": \"manual test\"}" }
      }
    },
    {
      "name": "2 moderate",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{apiKey}}" },
          { "key": "Content-Type", "value": "application/json" },
          { "key": "X-Request-Id", "value": "postman-1" }
        ],
        "url": "{{baseUrl}}/v1/moderate",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"messages\": [\n    {\"id\": \"a\", \"text\": \"FREE NITRO for the first 100!! claim at discord-gifts.ru/nitro\", \"channel_topic\": \"gaming\"},\n    {\"id\": \"b\", \"text\": \"Anyone know if the patch fixed the inventory bug?\", \"channel_topic\": \"gaming\"},\n    {\"id\": \"c\", \"text\": \"you're a worthless idiot and everyone here hates you, just leave\", \"channel_topic\": \"gaming\"},\n    {\"id\": \"d\", \"text\": \"ok\", \"channel_topic\": \"gaming\"}\n  ]\n}"
        }
      }
    },
    {
      "name": "3 get policy",
      "request": {
        "method": "GET",
        "header": [{ "key": "Authorization", "value": "Bearer {{apiKey}}" }],
        "url": "{{baseUrl}}/v1/policy"
      }
    },
    {
      "name": "4 set policy (scam -> delete, custom rule)",
      "request": {
        "method": "PUT",
        "header": [
          { "key": "Authorization", "value": "Bearer {{apiKey}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{baseUrl}}/v1/policy",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"actions\": {\"scam\": \"delete\", \"offtopic\": \"flag\"},\n  \"thresholds\": {\"scam\": 0.7},\n  \"rules\": {\"no_politics\": \"No political discussion. News about the game is fine.\"},\n  \"rule_actions\": {\"no_politics\": \"flag\"}\n}"
        }
      }
    },
    {
      "name": "5 moderate again (rule + delete)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Authorization", "value": "Bearer {{apiKey}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": "{{baseUrl}}/v1/moderate",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"messages\": [\n    {\"id\": \"a\", \"text\": \"DM me if you want to double your ETH in 24h, guaranteed, I work with Binance support\"},\n    {\"id\": \"b\", \"text\": \"The left is destroying this country, vote them out next month\"},\n    {\"id\": \"c\", \"text\": \"Patch notes are out, the new raid boss got nerfed\"}\n  ]\n}"
        }
      }
    },
    {
      "name": "6 decisions (audit log)",
      "request": {
        "method": "GET",
        "header": [{ "key": "Authorization", "value": "Bearer {{apiKey}}" }],
        "url": "{{baseUrl}}/v1/decisions?limit=20"
      }
    },
    {
      "name": "7 metrics",
      "request": { "method": "GET", "url": "{{baseUrl}}/metrics" }
    },
    {
      "name": "8 delete tenant (GDPR)",
      "request": {
        "method": "DELETE",
        "header": [{ "key": "Authorization", "value": "Bearer {{apiKey}}" }],
        "url": "{{baseUrl}}/v1/tenant"
      }
    }
  ]
}
