{
  "info": {
    "name": "HızırYemek POS Entegrasyonu",
    "description": "HızırYemek POS entegrasyon API koleksiyonu.\n\nTüm isteklerde `x-webhook-secret` header'ı zorunludur.\nHer istekte ilgili restoranın `restaurantId` değeri gönderilmelidir.\n\nKullanmadan önce collection variables kısmından `webhookSecret` ve `restaurantId` değerlerini kendi bilgilerinizle güncelleyin.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "http://localhost:4000/api/v1/pos-webhook",
      "type": "string"
    },
    {
      "key": "webhookSecret",
      "value": "YOUR_WEBHOOK_SECRET",
      "type": "string"
    },
    {
      "key": "restaurantId",
      "value": "507f1f77bcf86cd799439011",
      "type": "string"
    },
    {
      "key": "orderId",
      "value": "507f1f77bcf86cd799439012",
      "type": "string"
    }
  ],
  "item": [
    {
      "name": "Entegrasyon Başvurusu",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"companyName\": \"Test POS Firması\",\n  \"contactName\": \"Ahmet Yılmaz\",\n  \"email\": \"ahmet@testpos.com\",\n  \"phone\": \"0 532 123 45 67\",\n  \"apiBaseUrl\": \"https://api.testpos.com\",\n  \"description\": \"Test amaçlı POS entegrasyon başvurusu\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/apply",
          "host": ["{{baseUrl}}"],
          "path": ["apply"]
        },
        "description": "POS firması entegrasyon başvurusu yapar.\n\nBu endpoint herkese açıktır (public). Kimlik doğrulama gerektirmez.\n15 dakikada en fazla 5 istek gönderilebilir (rate limit)."
      },
      "response": [
        {
          "name": "Başarılı Başvuru",
          "status": "Created",
          "code": 201,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"Başvurunuz alınmıştır. En kısa sürede sizinle iletişime geçeceğiz.\",\n  \"data\": {\n    \"id\": \"507f1f77bcf86cd799439099\"\n  }\n}"
        },
        {
          "name": "Eksik Alan Hatası",
          "status": "Bad Request",
          "code": 400,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"companyName, contactName, email, phone ve apiBaseUrl alanları zorunludur\"\n}"
        }
      ]
    },
    {
      "name": "Sipariş Durumu Güncelleme",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-webhook-secret",
            "value": "{{webhookSecret}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"restaurantId\": \"{{restaurantId}}\",\n  \"orderId\": \"{{orderId}}\",\n  \"status\": \"preparing\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/webhook",
          "host": ["{{baseUrl}}"],
          "path": ["webhook"]
        },
        "description": "POS sisteminden sipariş durumunu günceller.\n\nGerekli header: x-webhook-secret\nGerekli body alanları: restaurantId + (orderId veya posOrderId)\n\nGeçerli status değerleri: pending, confirmed, preparing, on_the_way, delivered, cancelled"
      },
      "response": [
        {
          "name": "Başarılı Güncelleme",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"Webhook işlendi\"\n}"
        },
        {
          "name": "Geçersiz Webhook Secret",
          "status": "Unauthorized",
          "code": 401,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Geçersiz webhook secret veya POS entegrasyonu durdurulmuş\"\n}"
        },
        {
          "name": "Aktif POS Bağlantısı Yok",
          "status": "Unauthorized",
          "code": 401,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Bu restoran için aktif POS bağlantısı bulunamadı\"\n}"
        },
        {
          "name": "Sipariş Bulunamadı",
          "status": "Not Found",
          "code": 404,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Sipariş bulunamadı\"\n}"
        }
      ]
    },
    {
      "name": "Sipariş Durumu Güncelleme (posOrderId ile)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-webhook-secret",
            "value": "{{webhookSecret}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"restaurantId\": \"{{restaurantId}}\",\n  \"posOrderId\": \"POS-12345\",\n  \"status\": \"on_the_way\"\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/webhook",
          "host": ["{{baseUrl}}"],
          "path": ["webhook"]
        },
        "description": "POS tarafındaki sipariş ID (posOrderId) kullanarak sipariş durumunu günceller.\n\norderId yerine posOrderId kullanılabilir."
      },
      "response": [
        {
          "name": "Başarılı Güncelleme",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"Webhook işlendi\"\n}"
        }
      ]
    },
    {
      "name": "Restoran Durumu Sorgulama",
      "request": {
        "method": "GET",
        "header": [
          {
            "key": "x-webhook-secret",
            "value": "{{webhookSecret}}"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/restaurant-status?restaurantId={{restaurantId}}",
          "host": ["{{baseUrl}}"],
          "path": ["restaurant-status"],
          "query": [
            {
              "key": "restaurantId",
              "value": "{{restaurantId}}"
            }
          ]
        },
        "description": "Restoranın aktiflik (açık/kapalı) durumunu sorgular.\n\nGerekli header: x-webhook-secret\nGerekli query parametresi: restaurantId\n\nYanıtta restoranın isOpen durumu, kalıcı/geçici kapatma bilgileri ve çalışma saatleri döner."
      },
      "response": [
        {
          "name": "Restoran Açık",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"data\": {\n    \"restaurantId\": \"507f1f77bcf86cd799439011\",\n    \"restaurantName\": \"Karadeniz Pide Salonu\",\n    \"isOpen\": true,\n    \"closed\": false,\n    \"tempClosed\": false,\n    \"workingHours\": [\n      { \"day\": 1, \"open\": \"09:00\", \"close\": \"22:00\" },\n      { \"day\": 2, \"open\": \"09:00\", \"close\": \"22:00\" },\n      { \"day\": 3, \"open\": \"09:00\", \"close\": \"22:00\" },\n      { \"day\": 4, \"open\": \"09:00\", \"close\": \"22:00\" },\n      { \"day\": 5, \"open\": \"09:00\", \"close\": \"23:00\" },\n      { \"day\": 6, \"open\": \"10:00\", \"close\": \"23:00\" },\n      { \"day\": 0, \"open\": \"10:00\", \"close\": \"22:00\" }\n    ]\n  }\n}"
        },
        {
          "name": "Restoran Kapalı",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"data\": {\n    \"restaurantId\": \"507f1f77bcf86cd799439011\",\n    \"restaurantName\": \"Karadeniz Pide Salonu\",\n    \"isOpen\": false,\n    \"closed\": false,\n    \"tempClosed\": true,\n    \"workingHours\": []\n  }\n}"
        },
        {
          "name": "Restoran Bulunamadı",
          "status": "Not Found",
          "code": 404,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Restoran bulunamadı\"\n}"
        },
        {
          "name": "Geçersiz Webhook Secret",
          "status": "Unauthorized",
          "code": 401,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Geçersiz webhook secret veya POS entegrasyonu durdurulmuş\"\n}"
        }
      ]
    },
    {
      "name": "Restoran Aç",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-webhook-secret",
            "value": "{{webhookSecret}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"restaurantId\": \"{{restaurantId}}\",\n  \"isOpen\": true\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/restaurant-status",
          "host": ["{{baseUrl}}"],
          "path": ["restaurant-status"]
        },
        "description": "Restoranı açar (tempClosed = false).\n\nGerekli header: x-webhook-secret\nGerekli body alanları: restaurantId, isOpen (boolean)\n\nKalıcı olarak kapatılmış restoranlar (closed: true) bu endpoint ile açılamaz."
      },
      "response": [
        {
          "name": "Başarılı - Restoran Açıldı",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"Restoran açıldı\",\n  \"data\": {\n    \"restaurantId\": \"507f1f77bcf86cd799439011\",\n    \"isOpen\": true,\n    \"tempClosed\": false\n  }\n}"
        },
        {
          "name": "Geçersiz Webhook Secret",
          "status": "Unauthorized",
          "code": 401,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Geçersiz webhook secret veya POS entegrasyonu durdurulmuş\"\n}"
        }
      ]
    },
    {
      "name": "Restoran Kapat",
      "request": {
        "method": "PUT",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          },
          {
            "key": "x-webhook-secret",
            "value": "{{webhookSecret}}"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"restaurantId\": \"{{restaurantId}}\",\n  \"isOpen\": false\n}"
        },
        "url": {
          "raw": "{{baseUrl}}/restaurant-status",
          "host": ["{{baseUrl}}"],
          "path": ["restaurant-status"]
        },
        "description": "Restoranı geçici olarak kapatır (tempClosed = true).\n\nGerekli header: x-webhook-secret\nGerekli body alanları: restaurantId, isOpen (boolean)"
      },
      "response": [
        {
          "name": "Başarılı - Restoran Kapatıldı",
          "status": "OK",
          "code": 200,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": true,\n  \"message\": \"Restoran geçici olarak kapatıldı\",\n  \"data\": {\n    \"restaurantId\": \"507f1f77bcf86cd799439011\",\n    \"isOpen\": false,\n    \"tempClosed\": true\n  }\n}"
        },
        {
          "name": "Kalıcı Kapalı Restoran Hatası",
          "status": "Bad Request",
          "code": 400,
          "header": [
            {
              "key": "Content-Type",
              "value": "application/json"
            }
          ],
          "body": "{\n  \"success\": false,\n  \"error\": \"Bu restoran kalıcı olarak kapatılmış. POS üzerinden açılamaz.\"\n}"
        }
      ]
    }
  ]
}
