{
  "info": {
    "_postman_id": "4f07d59b-a922-454a-a4ee-b2b06848f41d",
    "name": "Vudux License API - External Partner",
    "description": "Partner-only Postman collection for the external subscription company. This collection includes only license lifecycle and subscription event endpoints intended for external integration.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "51418490",
    "_collection_link": "https://go.postman.co/collection/51418490-4f07d59b-a922-454a-a4ee-b2b06848f41d?source=collection_link"
  },
  "item": [
    {
      "name": "License lifecycle",
      "item": [
        {
          "name": "Create or update license",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Response is JSON\", function () {",
                  "    pm.response.to.be.json;",
                  "});",
                  "",
                  "const json = pm.response.json();",
                  "",
                  "pm.test(\"success is true\", function () {",
                  "    pm.expect(json.success).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"action is created or updated\", function () {",
                  "    pm.expect([\"created\", \"updated\"]).to.include(json.action);",
                  "});",
                  "",
                  "pm.test(\"isActive is true\", function () {",
                  "    pm.expect(json.isActive).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"response contains sn\", function () {",
                  "    pm.expect(json).to.have.property(\"sn\");",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\",\n  \"externalSubscriptionId\": \"{{externalSubscriptionId}}\",\n  \"externalPortal\": \"{{externalPortal}}\",\n  \"isActive\": true,\n  \"validUntil\": \"{{validUntil}}\",\n  \"plan\": \"{{plan}}\",\n  \"notes\": \"Created or updated from external partner Postman collection - no personal data\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/upsert-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "upsert-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Activate license by SN",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Response is JSON\", function () {",
                  "    pm.response.to.be.json;",
                  "});",
                  "",
                  "pm.test(\"Success is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.success).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"isActive is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.isActive).to.eql(true);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\",\n  \"validUntil\": \"{{validUntil}}\",\n  \"plan\": \"{{plan}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/activate-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "activate-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Deactivate license by SN",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Response is JSON\", function () {",
                  "    pm.response.to.be.json;",
                  "});",
                  "",
                  "pm.test(\"Success is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.success).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"isActive is false\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.isActive).to.eql(false);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/deactivate-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "deactivate-license"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Subscription events",
      "item": [
        {
          "name": "Subscription created",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Success is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.success).to.eql(true);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\",\n  \"externalSubscriptionId\": \"{{externalSubscriptionId}}\",\n  \"externalPortal\": \"{{externalPortal}}\",\n  \"isActive\": true,\n  \"validUntil\": \"{{validUntil}}\",\n  \"plan\": \"{{plan}}\",\n  \"notes\": \"Subscription created - no personal data\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/upsert-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "upsert-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Subscription renewed",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Success is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.success).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"isActive is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.isActive).to.eql(true);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"externalSubscriptionId\": \"{{externalSubscriptionId}}\",\n  \"validUntil\": \"{{validUntil}}\",\n  \"plan\": \"{{plan}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/activate-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "activate-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Subscription cancelled or expired",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Status code is 200\", function () {",
                  "    pm.response.to.have.status(200);",
                  "});",
                  "",
                  "pm.test(\"Success is true\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.success).to.eql(true);",
                  "});",
                  "",
                  "pm.test(\"isActive is false\", function () {",
                  "    const json = pm.response.json();",
                  "    pm.expect(json.isActive).to.eql(false);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"externalSubscriptionId\": \"{{externalSubscriptionId}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/deactivate-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "deactivate-license"
              ]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Negative tests",
      "item": [
        {
          "name": "Create license without token",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Unauthorized or forbidden\", function () {",
                  "    pm.expect([401, 403]).to.include(pm.response.code);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\",\n  \"isActive\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/upsert-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "upsert-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Create license with wrong token",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Unauthorized or forbidden\", function () {",
                  "    pm.expect([401, 403]).to.include(pm.response.code);",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "WRONG_TOKEN"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"sn\": \"{{sn}}\",\n  \"isActive\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/upsert-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "upsert-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Create license without SN",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Validation error\", function () {",
                  "    pm.expect([400, 404]).to.include(pm.response.code);",
                  "});",
                  "",
                  "pm.test(\"Response is JSON\", function () {",
                  "    pm.response.to.be.json;",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"isActive\": true\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/upsert-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "upsert-license"
              ]
            }
          },
          "response": []
        },
        {
          "name": "Deactivate unknown subscription",
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test(\"Validation error\", function () {",
                  "    pm.expect([400, 404]).to.include(pm.response.code);",
                  "});",
                  "",
                  "pm.test(\"Response is JSON\", function () {",
                  "    pm.response.to.be.json;",
                  "});"
                ]
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              },
              {
                "key": "X-Vudux-License-Admin-Token",
                "value": "{{adminToken}}"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"externalSubscriptionId\": \"unknown_subscription_id\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{baseUrl}}/api/deactivate-license",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "api",
                "deactivate-license"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ]
}