{
  "info": {
    "name": "OpenTabacchi API",
    "description": "Tariffe di vendita al pubblico dei tabacchi lavorati (fonte: Agenzia delle Dogane e dei Monopoli, ADM) e codici a barre, come dati aperti. Servizio indipendente, non affiliato all'ADM.\n\nImposta la variabile `apiKey` con la chiave creata da «Il tuo account» (https://opentabacchi.org/docs/api-keys). Limiti: 10 letture al giorno e 100 barcode all'ora per account; ogni richiesta di lettura ne consuma una. Documentazione: https://opentabacchi.org/docs/api",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{apiKey}}",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://opentabacchi.org"
    },
    {
      "key": "apiKey",
      "value": "otb_la_tua_chiave"
    }
  ],
  "item": [
    {
      "name": "Dataset",
      "item": [
        {
          "name": "Manifest della release (1 lettura)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/version",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "version"
              ]
            },
            "description": "Da chiamare una volta al giorno: se `version` è già quella importata non c'è altro da scaricare."
          },
          "event": [
            {
              "listen": "test",
              "script": {
                "type": "text/javascript",
                "exec": [
                  "pm.test('200', () => pm.response.to.have.status(200));",
                  "pm.collectionVariables.set('lastVersion', pm.response.json().version);"
                ]
              }
            }
          ]
        },
        {
          "name": "Dataset JSON (1 lettura)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/dataset.json.gz",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "dataset.json.gz"
              ]
            },
            "description": "File compresso con gzip. Usa If-None-Match con l'ETag per non riscaricare."
          }
        }
      ]
    },
    {
      "name": "Barcode",
      "item": [
        {
          "name": "Invia barcode",
          "request": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json"
              }
            ],
            "url": {
              "raw": "{{baseUrl}}/v1/barcodes",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "barcodes"
              ]
            },
            "description": "Fino a 500 elementi; si contano i barcode (100 all'ora). Non consuma le letture. Usa codici reali verificati sul prodotto.",
            "body": {
              "mode": "raw",
              "raw": "{\n  \"items\": [\n    {\n      \"barcode\": \"4006381333931\",\n      \"admCode\": 12345,\n      \"kind\": \"pack\"\n    },\n    {\n      \"barcode\": \"4006381333948\",\n      \"admCode\": 12345,\n      \"kind\": \"carton\",\n      \"units\": 10\n    }\n  ]\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            }
          }
        },
        {
          "name": "Le mie segnalazioni (1 lettura)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/my-submissions?limit=100&offset=0",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "my-submissions"
              ],
              "query": [
                {
                  "key": "limit",
                  "value": "100"
                },
                {
                  "key": "offset",
                  "value": "0"
                }
              ]
            },
            "description": "Dalla più recente, con lo stato attuale di ogni codice."
          }
        }
      ]
    },
    {
      "name": "Account",
      "item": [
        {
          "name": "Chiave e consumi (1 lettura)",
          "request": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{baseUrl}}/v1/me",
              "host": [
                "{{baseUrl}}"
              ],
              "path": [
                "v1",
                "me"
              ]
            },
            "description": "Controlla la chiave e mostra i residui."
          }
        }
      ]
    }
  ]
}
