{
  "info": {
    "name": "Tarevo Public Partner API V1",
    "description": "Complete collection for the Tarevo Partner API. Use the Sandbox environment for testing.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "bearer",
    "bearer": [{ "key": "token", "value": "{{access_token}}", "type": "string" }]
  },
  "variable": [
    { "key": "base_url", "value": "https://api.tarevo.com.br" },
    { "key": "client_id", "value": "" },
    { "key": "client_secret", "value": "" },
    { "key": "access_token", "value": "" }
  ],
  "item": [
    {
      "name": "Authentication",
      "item": [
        {
          "name": "Get Access Token",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "const json = pm.response.json();",
                  "if (json.access_token) {",
                  "  pm.collectionVariables.set('access_token', json.access_token);",
                  "  pm.test('Token received', () => pm.expect(json.token_type).to.eql('bearer'));",
                  "}"
                ]
              }
            }
          ],
          "request": {
            "auth": { "type": "noauth" },
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"grant_type\": \"client_credentials\",\n  \"client_id\": \"{{client_id}}\",\n  \"client_secret\": \"{{client_secret}}\"\n}"
            },
            "url": { "raw": "{{base_url}}/partner/auth/token" }
          }
        }
      ]
    },
    {
      "name": "Store",
      "item": [
        {
          "name": "Get Store Info",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/store" } }
        }
      ]
    },
    {
      "name": "Orders",
      "item": [
        {
          "name": "List Orders",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/orders?limit=10" } }
        },
        {
          "name": "Get Order by ID",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/orders/{{order_id}}" } }
        }
      ]
    },
    {
      "name": "Customers",
      "item": [
        {
          "name": "List Customers",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/customers?limit=10" } }
        },
        {
          "name": "Get Customer by ID",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/customers/{{customer_id}}" } }
        }
      ]
    },
    {
      "name": "Catalog",
      "item": [
        {
          "name": "List Categories",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/catalog/categories" } }
        },
        {
          "name": "List Products",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/catalog/products?limit=10" } }
        },
        {
          "name": "Get Product by ID",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/catalog/products/{{product_id}}" } }
        }
      ]
    },
    {
      "name": "Webhooks",
      "item": [
        {
          "name": "List Webhook Endpoints",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/webhooks" } }
        },
        {
          "name": "Create Webhook Endpoint",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": {
              "mode": "raw",
              "raw": "{\n  \"url\": \"https://your-server.com/webhooks/tarevo\",\n  \"events\": [\"order.created\", \"order.confirmed\"]\n}"
            },
            "url": { "raw": "{{base_url}}/public/v1/webhooks" }
          }
        },
        {
          "name": "Test Webhook",
          "request": { "method": "POST", "url": { "raw": "{{base_url}}/public/v1/webhooks/{{webhook_id}}/test" } }
        },
        {
          "name": "List Deliveries",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/public/v1/webhooks/deliveries" } }
        }
      ]
    },
    {
      "name": "Sandbox",
      "item": [
        {
          "name": "Provision Sandbox",
          "request": { "method": "POST", "url": { "raw": "{{base_url}}/partner/sandbox/provision" } }
        },
        {
          "name": "Get Sandbox Status",
          "request": { "method": "GET", "url": { "raw": "{{base_url}}/partner/sandbox/status" } }
        },
        {
          "name": "Generate Test Order",
          "request": {
            "method": "POST",
            "header": [{ "key": "Content-Type", "value": "application/json" }],
            "body": { "mode": "raw", "raw": "{ \"scenario\": \"delivery\" }" },
            "url": { "raw": "{{base_url}}/partner/sandbox/orders/generate" }
          }
        },
        {
          "name": "Reset Sandbox",
          "request": { "method": "POST", "url": { "raw": "{{base_url}}/partner/sandbox/reset" } }
        }
      ]
    }
  ]
}
