﻿{
  "info": {
    "_postman_id": "d2f6b913-6f8f-4e5f-8a38-9c5c1e2d5f6a",
    "name": "Reverseum API - V2 First",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Collection Postman orientee V2 pour Reverseum.\n\nPrerequis:\n- Renseigner {{baseUrl}} (ex: https://localhost:5001)\n- Renseigner {{apiKey}}\n\nEndpoints V2 recommandes:\n- POST /api/geo/reverse/v2\n- POST /api/geo/reverse/batch/v2\n- POST /api/geo/search/v2"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://localhost:5001" },
    { "key": "apiKey", "value": "" },
    { "key": "latitude", "value": "48.6921" },
    { "key": "longitude", "value": "6.1844" },
    { "key": "address", "value": "10 rue de la Paix, 75002 Paris" }
  ],
  "item": [
    {
      "name": "V2 (Recommande)",
      "item": [
        {
          "name": "Reverse V2",
          "request": {
            "method": "POST",
            "header": [
              { "key": "X-Api-Key", "value": "{{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/geo/reverse/v2",
              "host": ["{{baseUrl}}"],
              "path": ["api", "geo", "reverse", "v2"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"latitude\": {{latitude}},\n  \"longitude\": {{longitude}}\n}",
              "options": { "raw": { "language": "json" } }
            },
            "description": "Endpoint reverse V2 (contrat structure: coordinates + address)."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status HTTP attendu', function () {",
                  "  pm.expect(pm.response.code).to.be.oneOf([200, 401, 402, 403]);",
                  "});",
                  "",
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  pm.test('Contrat V2: coordinates + address', function () {",
                  "    pm.expect(json).to.have.property('coordinates');",
                  "    pm.expect(json).to.have.property('address');",
                  "  });",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Reverse Batch V2",
          "request": {
            "method": "POST",
            "header": [
              { "key": "X-Api-Key", "value": "{{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/geo/reverse/batch/v2",
              "host": ["{{baseUrl}}"],
              "path": ["api", "geo", "reverse", "batch", "v2"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"points\": [\n    { \"latitude\": 48.6921, \"longitude\": 6.1844 },\n    { \"latitude\": 48.8566, \"longitude\": 2.3522 }\n  ]\n}",
              "options": { "raw": { "language": "json" } }
            },
            "description": "Endpoint reverse batch V2. Limite selon plan: 5 points (standard), 50 points (Pro+)."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status HTTP attendu', function () {",
                  "  pm.expect(pm.response.code).to.be.oneOf([200, 400, 401, 402, 403]);",
                  "});",
                  "",
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  pm.test('Batch V2: totalDemandes/totalRetours/resultats', function () {",
                  "    pm.expect(json).to.have.property('totalDemandes');",
                  "    pm.expect(json).to.have.property('totalRetours');",
                  "    pm.expect(json).to.have.property('resultats');",
                  "  });",
                  "}"
                ]
              }
            }
          ]
        },
        {
          "name": "Search V2 (Pro+)",
          "request": {
            "method": "POST",
            "header": [
              { "key": "X-Api-Key", "value": "{{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/geo/search/v2",
              "host": ["{{baseUrl}}"],
              "path": ["api", "geo", "search", "v2"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"adresseComplete\": \"{{address}}\"\n}",
              "options": { "raw": { "language": "json" } }
            },
            "description": "Endpoint geocodage V2 reserve a l'offre Pro+."
          },
          "response": [],
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('Status HTTP attendu', function () {",
                  "  pm.expect(pm.response.code).to.be.oneOf([200, 401, 402, 403]);",
                  "});",
                  "",
                  "if (pm.response.code === 200) {",
                  "  const json = pm.response.json();",
                  "  pm.test('Search V2: coordinates + address', function () {",
                  "    pm.expect(json).to.have.property('coordinates');",
                  "    pm.expect(json).to.have.property('address');",
                  "  });",
                  "}"
                ]
              }
            }
          ]
        }
      ]
    },
    {
      "name": "Legacy (Compat)",
      "item": [
        {
          "name": "Reverse Legacy",
          "request": {
            "method": "POST",
            "header": [
              { "key": "X-Api-Key", "value": "{{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/geo/reverse",
              "host": ["{{baseUrl}}"],
              "path": ["api", "geo", "reverse"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"latitude\": {{latitude}},\n  \"longitude\": {{longitude}}\n}",
              "options": { "raw": { "language": "json" } }
            },
            "description": "Endpoint historique. Conserve pour compatibilite."
          },
          "response": []
        },
        {
          "name": "Search Legacy",
          "request": {
            "method": "POST",
            "header": [
              { "key": "X-Api-Key", "value": "{{apiKey}}", "type": "text" },
              { "key": "Content-Type", "value": "application/json", "type": "text" }
            ],
            "url": {
              "raw": "{{baseUrl}}/api/geo/search",
              "host": ["{{baseUrl}}"],
              "path": ["api", "geo", "search"]
            },
            "body": {
              "mode": "raw",
              "raw": "{\n  \"adresseComplete\": \"{{address}}\"\n}",
              "options": { "raw": { "language": "json" } }
            }
          },
          "response": []
        }
      ]
    }
  ]
}
