{
  "info": {
    "name": "CampNow – Admin: Campsite Modules",
    "description": "CRUD for Campsite Owners and Campsites (Admin APIs). Set the `baseUrl` and `adminToken` collection variables before running.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl",    "value": "http://localhost:3000", "type": "string" },
    { "key": "adminToken", "value": "<paste-your-jwt-token-here>", "type": "string" },
    { "key": "ownerId",    "value": "", "type": "string", "description": "Populated from Create Owner response" },
    { "key": "campsiteId", "value": "", "type": "string", "description": "Populated from Create Campsite response" }
  ],
  "item": [
    {
      "name": "Campsite Owners",
      "item": [
        {
          "name": "List Campsite Owners",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language", "value": "en", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/admin/campsite-owners?page=1&limit=10&search=",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsite-owners"],
              "query": [
                { "key": "page",   "value": "1",  "description": "Page number (default: 1)" },
                { "key": "limit",  "value": "10", "description": "Items per page (max: 100)" },
                { "key": "search", "value": "",   "description": "Search by name or email" }
              ]
            },
            "description": "GET /admin/campsite-owners\nReturns a paginated list of campsite owners."
          }
        },
        {
          "name": "Get Campsite Owner",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language", "value": "en", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/admin/campsite-owners/{{ownerId}}",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsite-owners", "{{ownerId}}"]
            },
            "description": "GET /admin/campsite-owners/:id"
          }
        },
        {
          "name": "Create Campsite Owner",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const res = pm.response.json();",
                  "if (res.success && res.data && res.data.id) {",
                  "  pm.collectionVariables.set('ownerId', res.data.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" },
              { "key": "Content-Type",   "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"firstName\": \"Hans\",\n  \"lastName\": \"Müller\",\n  \"email\": \"hans.mueller@example.com\",\n  \"mobile\": \"+4915112345678\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsite-owners",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsite-owners"]
            },
            "description": "POST /admin/campsite-owners\nCreates a new campsite owner and sends a welcome email with a temporary password.\n\nRequired: firstName, lastName, email\nOptional: mobile"
          }
        },
        {
          "name": "Update Campsite Owner",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" },
              { "key": "Content-Type",   "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"firstName\": \"Hans\",\n  \"lastName\": \"Schmidt\",\n  \"email\": \"hans.schmidt@example.com\",\n  \"mobile\": \"+4915198765432\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsite-owners/{{ownerId}}",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsite-owners", "{{ownerId}}"]
            },
            "description": "PUT /admin/campsite-owners/:id\nAll fields are optional — send only what you want to update."
          }
        },
        {
          "name": "Toggle Campsite Owner Status",
          "request": {
            "method": "PATCH",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" },
              { "key": "Content-Type",   "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"isDisabled\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsite-owners/{{ownerId}}/status",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsite-owners", "{{ownerId}}", "status"]
            },
            "description": "PATCH /admin/campsite-owners/:id/status\nisDisabled: true  → disables the owner account\nisDisabled: false → enables the owner account"
          }
        }
      ]
    },
    {
      "name": "Campsites",
      "item": [
        {
          "name": "List Campsites",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language", "value": "en", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/admin/campsites?page=1&limit=10&search=&isActive=true&userId=",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites"],
              "query": [
                { "key": "page",     "value": "1",    "description": "Page number (default: 1)" },
                { "key": "limit",    "value": "10",   "description": "Items per page (max: 100)" },
                { "key": "search",   "value": "",     "description": "Search by campsite name or email" },
                { "key": "isActive", "value": "true", "description": "Filter by active status: true | false (omit to get all)" },
                { "key": "userId",   "value": "",     "description": "Filter by owner userId (24-char ObjectId)" }
              ]
            },
            "description": "GET /admin/campsites\nReturns a paginated list of campsites with owner info."
          }
        },
        {
          "name": "Get Campsite",
          "request": {
            "method": "GET",
            "header": [
              { "key": "Authorization", "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language", "value": "en", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/admin/campsites/{{campsiteId}}",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites", "{{campsiteId}}"]
            },
            "description": "GET /admin/campsites/:id\nReturns campsite detail with owner info and completeness score."
          }
        },
        {
          "name": "Create Campsite",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const res = pm.response.json();",
                  "if (res.success && res.data && res.data.id) {",
                  "  pm.collectionVariables.set('campsiteId', res.data.id);",
                  "}"
                ],
                "type": "text/javascript"
              }
            }
          ],
          "request": {
            "method": "POST",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "userId",
                  "value": "{{ownerId}}",
                  "type": "text",
                  "description": "Required – 24-char ObjectId of the campsite owner"
                },
                {
                  "key": "name",
                  "value": "Campingplatz am See",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "email",
                  "value": "info@campingplatzsee.de",
                  "type": "text",
                  "description": "Optional – contact email for the campsite"
                },
                {
                  "key": "description",
                  "value": "Ein wunderschöner Campingplatz direkt am See mit allen Annehmlichkeiten.",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[latitude]",
                  "value": "48.137154",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[longitude]",
                  "value": "11.576124",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[address]",
                  "value": "Seestraße 12, 80538 München, Germany",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "websiteUrl",
                  "value": "https://www.campingplatzsee.de",
                  "type": "text",
                  "description": "Optional – must be a valid URL"
                },
                {
                  "key": "bookingUrl",
                  "value": "https://www.campingplatzsee.de/booking",
                  "type": "text",
                  "description": "Optional – must be a valid URL"
                },
                {
                  "key": "showOnMap",
                  "value": "true",
                  "type": "text",
                  "description": "Optional – boolean: true | false"
                },
                {
                  "key": "isActive",
                  "value": "false",
                  "type": "text",
                  "description": "Optional – boolean: true | false"
                },
                {
                  "key": "coverImage",
                  "type": "file",
                  "src": [],
                  "description": "Optional – image file (jpeg, png, webp, etc.) max 10 MB"
                },
                {
                  "key": "membershipDoc",
                  "type": "file",
                  "src": [],
                  "description": "Optional – PDF file max 10 MB"
                }
              ]
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsites",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites"]
            },
            "description": "POST /admin/campsites\nRequest type: multipart/form-data (required for file uploads).\n\ncoverImage   → image file (jpg/png/webp)\nmembershipDoc → PDF file\nAll other fields are sent as text key-value pairs.\n\nThe first campsite created for an owner auto-activates their account."
          }
        },
        {
          "name": "Update Campsite",
          "request": {
            "method": "PUT",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" }
            ],
            "body": {
              "mode": "formdata",
              "formdata": [
                {
                  "key": "name",
                  "value": "Campingplatz am See (Updated)",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "email",
                  "value": "kontakt@campingplatzsee.de",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "description",
                  "value": "Aktualisierte Beschreibung des Campingplatzes.",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[latitude]",
                  "value": "48.137154",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[longitude]",
                  "value": "11.576124",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "location[address]",
                  "value": "Seestraße 12, 80538 München, Germany",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "websiteUrl",
                  "value": "https://www.campingplatzsee.de",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "bookingUrl",
                  "value": "https://www.campingplatzsee.de/buchen",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "showOnMap",
                  "value": "true",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "isActive",
                  "value": "true",
                  "type": "text",
                  "description": "Optional"
                },
                {
                  "key": "userId",
                  "value": "{{ownerId}}",
                  "type": "text",
                  "description": "Optional – reassign to a different owner"
                },
                {
                  "key": "coverImage",
                  "type": "file",
                  "src": [],
                  "description": "Optional – replaces existing cover image; old file is deleted"
                },
                {
                  "key": "membershipDoc",
                  "type": "file",
                  "src": [],
                  "description": "Optional – replaces existing PDF; old file is deleted"
                }
              ]
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsites/{{campsiteId}}",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites", "{{campsiteId}}"]
            },
            "description": "PUT /admin/campsites/:id\nRequest type: multipart/form-data.\nSend only the fields you want to update.\nUploading a new coverImage or membershipDoc replaces and deletes the old file."
          }
        },
        {
          "name": "Toggle Campsite Status",
          "request": {
            "method": "PATCH",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" },
              { "key": "Content-Type",   "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"isActive\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsites/{{campsiteId}}/status",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites", "{{campsiteId}}", "status"]
            },
            "description": "PATCH /admin/campsites/:id/status\nisActive: true  → activates the campsite\nisActive: false → deactivates the campsite"
          }
        },
        {
          "name": "Delete Campsite",
          "request": {
            "method": "DELETE",
            "header": [
              { "key": "Authorization",  "value": "Bearer {{adminToken}}", "type": "text" },
              { "key": "Accept-Language","value": "en", "type": "text" },
              { "key": "Content-Type",   "value": "application/json", "type": "text" }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"confirmed\": true\n}",
              "options": { "raw": { "language": "json" } }
            },
            "url": {
              "raw": "{{baseUrl}}/admin/campsites/{{campsiteId}}",
              "host": ["{{baseUrl}}"],
              "path": ["admin", "campsites", "{{campsiteId}}"]
            },
            "description": "DELETE /admin/campsites/:id\nSoft-delete — sets isDeleted: true and isActive: false.\nconfirmed: true is required as a safety guard."
          }
        }
      ]
    }
  ]
}
