{
  "info": {
    "name": "Gunel Abasova \u2014 Onboarding API sample",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Independent design sample. Fictional API contract. Configure your own authorized sandbox implementing this contract. Not executed against a live service; no credentials included."
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:8080"
    },
    {
      "key": "customerId",
      "value": "C01"
    }
  ],
  "item": [
    {
      "name": "Create synthetic customer",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/customers",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"id\": \"{{customerId}}\",\n  \"email\": \"sample@example.test\",\n  \"country\": \"US\",\n  \"reviewFlag\": false\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Created\", () => pm.response.to.have.status(201));",
              "const body = pm.response.json();",
              "pm.test(\"Fields preserved\", () => { pm.expect(body.id).to.eql(pm.collectionVariables.get(\"customerId\")); pm.expect(body.email).to.eql(\"sample@example.test\"); pm.expect(body.country).to.eql(\"US\"); });",
              "pm.test(\"Initial state\", () => pm.expect(body.status).to.eql(\"pending\"));"
            ]
          }
        }
      ]
    },
    {
      "name": "Retrieve and compare",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/customers/{{customerId}}"
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Retrieved\", () => pm.response.to.have.status(200));",
              "const body = pm.response.json();",
              "pm.test(\"Persisted fields match\", () => { pm.expect(body.id).to.eql(pm.collectionVariables.get(\"customerId\")); pm.expect(body.email).to.eql(\"sample@example.test\"); pm.expect(body.status).to.eql(\"pending\"); });"
            ]
          }
        }
      ]
    },
    {
      "name": "Reject duplicate identifier",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/customers",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"id\": \"{{customerId}}\",\n  \"email\": \"other@example.test\",\n  \"country\": \"US\",\n  \"reviewFlag\": false\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        }
      },
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test(\"Conflict\", () => pm.response.to.have.status(409));"
            ]
          }
        }
      ]
    }
  ]
}